Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack
File: class-jetpack-gallery-settings.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Adding extra functions for the gallery.
[2] Fix | Delete
*
[3] Fix | Delete
* @package automattic/jetpack
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
use Automattic\Jetpack\Assets;
[7] Fix | Delete
[8] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[9] Fix | Delete
exit( 0 );
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Renders extra controls in the Gallery Settings section of the new media UI.
[14] Fix | Delete
*
[15] Fix | Delete
* @phan-constructor-used-for-side-effects
[16] Fix | Delete
*/
[17] Fix | Delete
class Jetpack_Gallery_Settings {
[18] Fix | Delete
/**
[19] Fix | Delete
* Available gallery types.
[20] Fix | Delete
*
[21] Fix | Delete
* @var array
[22] Fix | Delete
*/
[23] Fix | Delete
public $gallery_types;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The constructor.
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct() {
[29] Fix | Delete
add_action( 'admin_init', array( $this, 'admin_init' ) );
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Initialize the admin resources.
[34] Fix | Delete
*/
[35] Fix | Delete
public function admin_init() {
[36] Fix | Delete
/**
[37] Fix | Delete
* Filter the available gallery types.
[38] Fix | Delete
*
[39] Fix | Delete
* @module shortcodes, tiled-gallery
[40] Fix | Delete
*
[41] Fix | Delete
* @since 2.5.1
[42] Fix | Delete
*
[43] Fix | Delete
* @param array $value Array of the default thumbnail grid gallery type. Default array contains one key, ‘default’.
[44] Fix | Delete
*/
[45] Fix | Delete
$this->gallery_types = apply_filters( 'jetpack_gallery_types', array( 'default' => __( 'Thumbnail Grid', 'jetpack' ) ) );
[46] Fix | Delete
[47] Fix | Delete
// Enqueue the media UI only if needed.
[48] Fix | Delete
if ( is_countable( $this->gallery_types ) && count( $this->gallery_types ) > 1 ) {
[49] Fix | Delete
add_action( 'wp_enqueue_media', array( $this, 'wp_enqueue_media' ) );
[50] Fix | Delete
add_action( 'print_media_templates', array( $this, 'print_media_templates' ) );
[51] Fix | Delete
}
[52] Fix | Delete
// Add Slideshow and Galleries functionality to core's media gallery widget.
[53] Fix | Delete
add_filter( 'widget_media_gallery_instance_schema', array( $this, 'core_media_widget_compat' ) );
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Updates the schema of the core gallery widget so we can save the
[58] Fix | Delete
* fields that we add to Gallery Widgets, like `type` and `conditions`
[59] Fix | Delete
*
[60] Fix | Delete
* @param array $schema The current schema for the core gallery widget.
[61] Fix | Delete
* @return array the updated schema
[62] Fix | Delete
*/
[63] Fix | Delete
public function core_media_widget_compat( $schema ) {
[64] Fix | Delete
$schema['type'] = array(
[65] Fix | Delete
'type' => 'string',
[66] Fix | Delete
'enum' => array_keys( $this->gallery_types ),
[67] Fix | Delete
'description' => __( 'Type of gallery.', 'jetpack' ),
[68] Fix | Delete
'default' => 'default',
[69] Fix | Delete
);
[70] Fix | Delete
return $schema;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Registers/enqueues the gallery settings admin js.
[75] Fix | Delete
*/
[76] Fix | Delete
public function wp_enqueue_media() {
[77] Fix | Delete
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) {
[78] Fix | Delete
/**
[79] Fix | Delete
* This only happens if we're not in Jetpack, but on WPCOM instead.
[80] Fix | Delete
* This is the correct path for WPCOM.
[81] Fix | Delete
*/
[82] Fix | Delete
wp_register_script(
[83] Fix | Delete
'jetpack-gallery-settings',
[84] Fix | Delete
Assets::get_file_url_for_environment( '_inc/build/gallery-settings.min.js', '_inc/gallery-settings.js' ),
[85] Fix | Delete
array( 'jquery', 'media-views' ),
[86] Fix | Delete
'20121225',
[87] Fix | Delete
false
[88] Fix | Delete
);
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
wp_enqueue_script( 'jetpack-gallery-settings' );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Outputs a view template which can be used with wp.media.template
[96] Fix | Delete
*/
[97] Fix | Delete
public function print_media_templates() {
[98] Fix | Delete
/**
[99] Fix | Delete
* Filter the default gallery type.
[100] Fix | Delete
*
[101] Fix | Delete
* @module tiled-gallery
[102] Fix | Delete
*
[103] Fix | Delete
* @since 2.5.1
[104] Fix | Delete
*
[105] Fix | Delete
* @param string $value A string of the gallery type. Default is ‘default’.
[106] Fix | Delete
*/
[107] Fix | Delete
$default_gallery_type = apply_filters( 'jetpack_default_gallery_type', 'default' );
[108] Fix | Delete
[109] Fix | Delete
?>
[110] Fix | Delete
<script type="text/html" id="tmpl-jetpack-gallery-settings">
[111] Fix | Delete
<label class="setting">
[112] Fix | Delete
<span><?php esc_html_e( 'Type', 'jetpack' ); ?></span>
[113] Fix | Delete
<select class="type" name="type" data-setting="type">
[114] Fix | Delete
<?php foreach ( $this->gallery_types as $value => $caption ) : ?>
[115] Fix | Delete
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $default_gallery_type ); ?>><?php echo esc_html( $caption ); ?></option>
[116] Fix | Delete
<?php endforeach; ?>
[117] Fix | Delete
</select>
[118] Fix | Delete
</label>
[119] Fix | Delete
</script>
[120] Fix | Delete
<?php
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
new Jetpack_Gallery_Settings();
[124] Fix | Delete
[125] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function