Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-inclu.../customiz...
File: class-wp-customize-media-control.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Customize API: WP_Customize_Media_Control class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Customize
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Customize Media Control class.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 4.2.0
[12] Fix | Delete
*
[13] Fix | Delete
* @see WP_Customize_Control
[14] Fix | Delete
*/
[15] Fix | Delete
class WP_Customize_Media_Control extends WP_Customize_Control {
[16] Fix | Delete
/**
[17] Fix | Delete
* Control type.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 4.2.0
[20] Fix | Delete
* @var string
[21] Fix | Delete
*/
[22] Fix | Delete
public $type = 'media';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Media control mime type.
[26] Fix | Delete
*
[27] Fix | Delete
* @since 4.2.0
[28] Fix | Delete
* @var string
[29] Fix | Delete
*/
[30] Fix | Delete
public $mime_type = '';
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Button labels.
[34] Fix | Delete
*
[35] Fix | Delete
* @since 4.2.0
[36] Fix | Delete
* @var array
[37] Fix | Delete
*/
[38] Fix | Delete
public $button_labels = array();
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Constructor.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 4.1.0
[44] Fix | Delete
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
[45] Fix | Delete
*
[46] Fix | Delete
* @see WP_Customize_Control::__construct()
[47] Fix | Delete
*
[48] Fix | Delete
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
[49] Fix | Delete
* @param string $id Control ID.
[50] Fix | Delete
* @param array $args Optional. Arguments to override class property defaults.
[51] Fix | Delete
* See WP_Customize_Control::__construct() for information
[52] Fix | Delete
* on accepted arguments. Default empty array.
[53] Fix | Delete
*/
[54] Fix | Delete
public function __construct( $manager, $id, $args = array() ) {
[55] Fix | Delete
parent::__construct( $manager, $id, $args );
[56] Fix | Delete
[57] Fix | Delete
$this->button_labels = wp_parse_args( $this->button_labels, $this->get_default_button_labels() );
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Enqueue control related scripts/styles.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 3.4.0
[64] Fix | Delete
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
[65] Fix | Delete
*/
[66] Fix | Delete
public function enqueue() {
[67] Fix | Delete
wp_enqueue_media();
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Refresh the parameters passed to the JavaScript via JSON.
[72] Fix | Delete
*
[73] Fix | Delete
* @since 3.4.0
[74] Fix | Delete
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
[75] Fix | Delete
*
[76] Fix | Delete
* @see WP_Customize_Control::to_json()
[77] Fix | Delete
*/
[78] Fix | Delete
public function to_json() {
[79] Fix | Delete
parent::to_json();
[80] Fix | Delete
$this->json['label'] = html_entity_decode( $this->label, ENT_QUOTES, get_bloginfo( 'charset' ) );
[81] Fix | Delete
$this->json['mime_type'] = $this->mime_type;
[82] Fix | Delete
$this->json['button_labels'] = $this->button_labels;
[83] Fix | Delete
$this->json['canUpload'] = current_user_can( 'upload_files' );
[84] Fix | Delete
[85] Fix | Delete
$value = $this->value();
[86] Fix | Delete
[87] Fix | Delete
if ( is_object( $this->setting ) ) {
[88] Fix | Delete
if ( $this->setting->default ) {
[89] Fix | Delete
/*
[90] Fix | Delete
* Fake an attachment model - needs all fields used by template.
[91] Fix | Delete
* Note that the default value must be a URL, NOT an attachment ID.
[92] Fix | Delete
*/
[93] Fix | Delete
$ext = substr( $this->setting->default, -3 );
[94] Fix | Delete
$type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp', 'webp', 'avif' ), true ) ? 'image' : 'document';
[95] Fix | Delete
[96] Fix | Delete
$default_attachment = array(
[97] Fix | Delete
'id' => 1,
[98] Fix | Delete
'url' => $this->setting->default,
[99] Fix | Delete
'type' => $type,
[100] Fix | Delete
'icon' => wp_mime_type_icon( $type, '.svg' ),
[101] Fix | Delete
'title' => wp_basename( $this->setting->default ),
[102] Fix | Delete
);
[103] Fix | Delete
[104] Fix | Delete
if ( 'image' === $type ) {
[105] Fix | Delete
$default_attachment['sizes'] = array(
[106] Fix | Delete
'full' => array( 'url' => $this->setting->default ),
[107] Fix | Delete
);
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
$this->json['defaultAttachment'] = $default_attachment;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
if ( $value && $this->setting->default && $value === $this->setting->default ) {
[114] Fix | Delete
// Set the default as the attachment.
[115] Fix | Delete
$this->json['attachment'] = $this->json['defaultAttachment'];
[116] Fix | Delete
} elseif ( $value ) {
[117] Fix | Delete
$this->json['attachment'] = wp_prepare_attachment_for_js( $value );
[118] Fix | Delete
}
[119] Fix | Delete
}
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
/**
[123] Fix | Delete
* Don't render any content for this control from PHP.
[124] Fix | Delete
*
[125] Fix | Delete
* @since 3.4.0
[126] Fix | Delete
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
[127] Fix | Delete
*
[128] Fix | Delete
* @see WP_Customize_Media_Control::content_template()
[129] Fix | Delete
*/
[130] Fix | Delete
public function render_content() {}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Render a JS template for the content of the media control.
[134] Fix | Delete
*
[135] Fix | Delete
* @since 4.1.0
[136] Fix | Delete
* @since 4.2.0 Moved from WP_Customize_Upload_Control.
[137] Fix | Delete
*/
[138] Fix | Delete
public function content_template() {
[139] Fix | Delete
?>
[140] Fix | Delete
<#
[141] Fix | Delete
var descriptionId = _.uniqueId( 'customize-media-control-description-' );
[142] Fix | Delete
var describedByAttr = data.description ? ' aria-describedby="' + descriptionId + '" ' : '';
[143] Fix | Delete
#>
[144] Fix | Delete
<# if ( data.label ) { #>
[145] Fix | Delete
<span class="customize-control-title">{{ data.label }}</span>
[146] Fix | Delete
<# } #>
[147] Fix | Delete
<div class="customize-control-notifications-container"></div>
[148] Fix | Delete
<# if ( data.description ) { #>
[149] Fix | Delete
<span id="{{ descriptionId }}" class="description customize-control-description">{{{ data.description }}}</span>
[150] Fix | Delete
<# } #>
[151] Fix | Delete
[152] Fix | Delete
<# if ( data.attachment && data.attachment.id ) { #>
[153] Fix | Delete
<div class="attachment-media-view attachment-media-view-{{ data.attachment.type }} {{ data.attachment.orientation }}">
[154] Fix | Delete
<div class="thumbnail thumbnail-{{ data.attachment.type }}">
[155] Fix | Delete
<# if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.medium ) { #>
[156] Fix | Delete
<img class="attachment-thumb" src="{{ data.attachment.sizes.medium.url }}" draggable="false" alt="" />
[157] Fix | Delete
<# } else if ( 'image' === data.attachment.type && data.attachment.sizes && data.attachment.sizes.full ) { #>
[158] Fix | Delete
<img class="attachment-thumb" src="{{ data.attachment.sizes.full.url }}" draggable="false" alt="" />
[159] Fix | Delete
<# } else if ( 'audio' === data.attachment.type ) { #>
[160] Fix | Delete
<# if ( data.attachment.image && data.attachment.image.src && data.attachment.image.src !== data.attachment.icon ) { #>
[161] Fix | Delete
<img src="{{ data.attachment.image.src }}" class="thumbnail" draggable="false" alt="" />
[162] Fix | Delete
<# } else { #>
[163] Fix | Delete
<img src="{{ data.attachment.icon }}" class="attachment-thumb type-icon" draggable="false" alt="" />
[164] Fix | Delete
<# } #>
[165] Fix | Delete
<p class="attachment-meta attachment-meta-title">&#8220;{{ data.attachment.title }}&#8221;</p>
[166] Fix | Delete
<# if ( data.attachment.album || data.attachment.meta.album ) { #>
[167] Fix | Delete
<p class="attachment-meta"><em>{{ data.attachment.album || data.attachment.meta.album }}</em></p>
[168] Fix | Delete
<# } #>
[169] Fix | Delete
<# if ( data.attachment.artist || data.attachment.meta.artist ) { #>
[170] Fix | Delete
<p class="attachment-meta">{{ data.attachment.artist || data.attachment.meta.artist }}</p>
[171] Fix | Delete
<# } #>
[172] Fix | Delete
<audio style="visibility: hidden" controls class="wp-audio-shortcode" width="100%" preload="none">
[173] Fix | Delete
<source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}" />
[174] Fix | Delete
</audio>
[175] Fix | Delete
<# } else if ( 'video' === data.attachment.type ) { #>
[176] Fix | Delete
<div class="wp-media-wrapper wp-video">
[177] Fix | Delete
<video controls="controls" class="wp-video-shortcode" preload="metadata"
[178] Fix | Delete
<# if ( data.attachment.image && data.attachment.image.src !== data.attachment.icon ) { #>poster="{{ data.attachment.image.src }}"<# } #>>
[179] Fix | Delete
<source type="{{ data.attachment.mime }}" src="{{ data.attachment.url }}" />
[180] Fix | Delete
</video>
[181] Fix | Delete
</div>
[182] Fix | Delete
<# } else { #>
[183] Fix | Delete
<img class="attachment-thumb type-icon icon" src="{{ data.attachment.icon }}" draggable="false" alt="" />
[184] Fix | Delete
<p class="attachment-title">{{ data.attachment.title }}</p>
[185] Fix | Delete
<# } #>
[186] Fix | Delete
</div>
[187] Fix | Delete
<div class="actions">
[188] Fix | Delete
<# if ( data.canUpload ) { #>
[189] Fix | Delete
<button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
[190] Fix | Delete
<button type="button" class="button upload-button control-focus" {{{ describedByAttr }}}>{{ data.button_labels.change }}</button>
[191] Fix | Delete
<# } #>
[192] Fix | Delete
</div>
[193] Fix | Delete
</div>
[194] Fix | Delete
<# } else { #>
[195] Fix | Delete
<div class="attachment-media-view">
[196] Fix | Delete
<# if ( data.canUpload ) { #>
[197] Fix | Delete
<button type="button" class="upload-button button-add-media" {{{ describedByAttr }}}>{{ data.button_labels.select }}</button>
[198] Fix | Delete
<# } #>
[199] Fix | Delete
<div class="actions">
[200] Fix | Delete
<# if ( data.defaultAttachment ) { #>
[201] Fix | Delete
<button type="button" class="button default-button">{{ data.button_labels['default'] }}</button>
[202] Fix | Delete
<# } #>
[203] Fix | Delete
</div>
[204] Fix | Delete
</div>
[205] Fix | Delete
<# } #>
[206] Fix | Delete
<?php
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
/**
[210] Fix | Delete
* Get default button labels.
[211] Fix | Delete
*
[212] Fix | Delete
* Provides an array of the default button labels based on the mime type of the current control.
[213] Fix | Delete
*
[214] Fix | Delete
* @since 4.9.0
[215] Fix | Delete
*
[216] Fix | Delete
* @return string[] An associative array of default button labels keyed by the button name.
[217] Fix | Delete
*/
[218] Fix | Delete
public function get_default_button_labels() {
[219] Fix | Delete
// Get just the mime type and strip the mime subtype if present.
[220] Fix | Delete
$mime_type = ! empty( $this->mime_type ) ? strtok( ltrim( $this->mime_type, '/' ), '/' ) : 'default';
[221] Fix | Delete
[222] Fix | Delete
switch ( $mime_type ) {
[223] Fix | Delete
case 'video':
[224] Fix | Delete
return array(
[225] Fix | Delete
'select' => __( 'Select video' ),
[226] Fix | Delete
'change' => __( 'Change video' ),
[227] Fix | Delete
'default' => __( 'Default' ),
[228] Fix | Delete
'remove' => __( 'Remove' ),
[229] Fix | Delete
'placeholder' => __( 'No video selected' ),
[230] Fix | Delete
'frame_title' => __( 'Select video' ),
[231] Fix | Delete
'frame_button' => __( 'Choose video' ),
[232] Fix | Delete
);
[233] Fix | Delete
case 'audio':
[234] Fix | Delete
return array(
[235] Fix | Delete
'select' => __( 'Select audio' ),
[236] Fix | Delete
'change' => __( 'Change audio' ),
[237] Fix | Delete
'default' => __( 'Default' ),
[238] Fix | Delete
'remove' => __( 'Remove' ),
[239] Fix | Delete
'placeholder' => __( 'No audio selected' ),
[240] Fix | Delete
'frame_title' => __( 'Select audio' ),
[241] Fix | Delete
'frame_button' => __( 'Choose audio' ),
[242] Fix | Delete
);
[243] Fix | Delete
case 'image':
[244] Fix | Delete
return array(
[245] Fix | Delete
'select' => __( 'Select image' ),
[246] Fix | Delete
'site_icon' => __( 'Select Site Icon' ),
[247] Fix | Delete
'change' => __( 'Change image' ),
[248] Fix | Delete
'default' => __( 'Default' ),
[249] Fix | Delete
'remove' => __( 'Remove' ),
[250] Fix | Delete
'placeholder' => __( 'No image selected' ),
[251] Fix | Delete
'frame_title' => __( 'Select image' ),
[252] Fix | Delete
'frame_button' => __( 'Choose image' ),
[253] Fix | Delete
);
[254] Fix | Delete
default:
[255] Fix | Delete
return array(
[256] Fix | Delete
'select' => __( 'Select file' ),
[257] Fix | Delete
'change' => __( 'Change file' ),
[258] Fix | Delete
'default' => __( 'Default' ),
[259] Fix | Delete
'remove' => __( 'Remove' ),
[260] Fix | Delete
'placeholder' => __( 'No file selected' ),
[261] Fix | Delete
'frame_title' => __( 'Select file' ),
[262] Fix | Delete
'frame_button' => __( 'Choose file' ),
[263] Fix | Delete
);
[264] Fix | Delete
} // End switch().
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function