Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/core/componen...
File: CompatibilityWarning.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* ET_Core_CompatibilityWarning class file.
[2] Fix | Delete
*
[3] Fix | Delete
* @class ET_Core_CompatibilityWarning
[4] Fix | Delete
* @package Core
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit; // Exit if accessed directly.
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
if ( ! class_exists( 'ET_Core_CompatibilityWarning' ) ) :
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Plugin & theme compatibility warning system backported from WP 5.5.
[15] Fix | Delete
*
[16] Fix | Delete
* This system is only intended for users who use Divi theme with WP 5.4.2 below and Divi
[17] Fix | Delete
* Builder plugin with WP 5.2 below. There are some areas where it overrides or modifies
[18] Fix | Delete
* the themes & plugins management template to show warnings when the current WP and/or
[19] Fix | Delete
* PHP versions doesn't work with the current and/or upcoming ET plugins/themes.
[20] Fix | Delete
*
[21] Fix | Delete
* A. Update Core
[22] Fix | Delete
* 1. Plugins list section.
[23] Fix | Delete
* 2. Themes list section.
[24] Fix | Delete
*
[25] Fix | Delete
* B. Manage Themes
[26] Fix | Delete
* On each of incompatible themes, shows warning and disables Activate & Live Preview
[27] Fix | Delete
* buttons when the theme is not activated yet.
[28] Fix | Delete
* 1. Themes List (tmpl-theme).
[29] Fix | Delete
* 2. Theme Details (tmpl-theme-single).
[30] Fix | Delete
*
[31] Fix | Delete
* C. Theme Customizer
[32] Fix | Delete
* On each of incompatible themes, shows warning and disables Live Preview button when
[33] Fix | Delete
* the theme is not activated yet. In addition, disable Publish button for the current
[34] Fix | Delete
* active theme.
[35] Fix | Delete
* 1. Themes List (tmpl-theme).
[36] Fix | Delete
* 2. Theme Details (tmpl-theme-single).
[37] Fix | Delete
* 3. Publish Button for current active theme.
[38] Fix | Delete
*
[39] Fix | Delete
* D. Plugins List
[40] Fix | Delete
* 1. Plugins List via `after_plugin_row_` action hook.
[41] Fix | Delete
* 2. Plugin activation warning. ET plugins that want to use this warning should
[42] Fix | Delete
* register `maybe_deactivate_incompatible_plugin()` on their activation hook.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 4.7.0
[45] Fix | Delete
*/
[46] Fix | Delete
class ET_Core_CompatibilityWarning {
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Class instance.
[50] Fix | Delete
*
[51] Fix | Delete
* @var ET_Core_CompatibilityWarning
[52] Fix | Delete
*/
[53] Fix | Delete
public static $instance_class;
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* WP version where the official warning system is introduced.
[57] Fix | Delete
*
[58] Fix | Delete
* @var string
[59] Fix | Delete
*/
[60] Fix | Delete
public $supported_wp_version = array(
[61] Fix | Delete
'plugin' => '5.3.0',
[62] Fix | Delete
'theme' => '5.5.0',
[63] Fix | Delete
);
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Class constructor.
[67] Fix | Delete
*/
[68] Fix | Delete
public function __construct() {
[69] Fix | Delete
global $wp_version;
[70] Fix | Delete
[71] Fix | Delete
// Ensure the system is loaded on lower version of supported version.
[72] Fix | Delete
if ( version_compare( $wp_version, $this->supported_wp_version[ ET_CORE_TYPE ], '>=' ) ) {
[73] Fix | Delete
return;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
[77] Fix | Delete
[78] Fix | Delete
// A. Update Core - Overrides plugins and themes updates table body.
[79] Fix | Delete
add_action( 'admin_print_footer_scripts-update-core.php', array( $this, 'overrides_update_core_plugins_table_body' ) );
[80] Fix | Delete
add_action( 'admin_print_footer_scripts-update-core.php', array( $this, 'overrides_update_core_themes_table_body' ) );
[81] Fix | Delete
[82] Fix | Delete
// B. Manage Themes - Overrides themes list & details templates.
[83] Fix | Delete
add_filter( 'wp_prepare_themes_for_js', array( $this, 'set_theme_additional_properties' ) );
[84] Fix | Delete
add_action( 'admin_print_footer_scripts-themes.php', array( $this, 'overrides_tmpl_theme' ) );
[85] Fix | Delete
[86] Fix | Delete
// C. Theme Customizer - Overrides themes list & details templates.
[87] Fix | Delete
add_action( 'customize_controls_print_footer_scripts', array( $this, 'overrides_tmpl_customize_control_theme_content' ) );
[88] Fix | Delete
[89] Fix | Delete
// D. Plugins - Overrides current plugin list. Default priority is 20.
[90] Fix | Delete
add_action( 'load-plugins.php', array( $this, 'overrides_plugins_table_rows' ), 21 );
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Returns instance of the class.
[95] Fix | Delete
*
[96] Fix | Delete
* @since 4.7.0
[97] Fix | Delete
*
[98] Fix | Delete
* @return ET_Core_CompatibilityWarning
[99] Fix | Delete
*/
[100] Fix | Delete
public static function instance() {
[101] Fix | Delete
if ( ! isset( self::$instance_class ) ) {
[102] Fix | Delete
self::$instance_class = new self();
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
return self::$instance_class;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Set theme additional properties before it's rendered on Manage Themes page.
[110] Fix | Delete
*
[111] Fix | Delete
* @since 4.7.0
[112] Fix | Delete
*
[113] Fix | Delete
* @param array $prepared_themes List of available themes.
[114] Fix | Delete
*
[115] Fix | Delete
* @return array
[116] Fix | Delete
*/
[117] Fix | Delete
public function set_theme_additional_properties( $prepared_themes ) {
[118] Fix | Delete
// Bail early if the $prepared_themes is empty.
[119] Fix | Delete
if ( empty( $prepared_themes ) ) {
[120] Fix | Delete
return $prepared_themes;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// 1. Get available themes update.
[124] Fix | Delete
$theme_updates = array();
[125] Fix | Delete
[126] Fix | Delete
if ( current_user_can( 'update_themes' ) ) {
[127] Fix | Delete
$updates_themes_transient = get_site_transient( 'update_themes' );
[128] Fix | Delete
[129] Fix | Delete
if ( isset( $updates_themes_transient->response ) ) {
[130] Fix | Delete
$theme_updates = $updates_themes_transient->response;
[131] Fix | Delete
}
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
// 2. Assign compatibility properties.
[135] Fix | Delete
$themes = $prepared_themes;
[136] Fix | Delete
[137] Fix | Delete
foreach ( $themes as $theme_slug => $theme_info ) {
[138] Fix | Delete
// Ensure style.css file exist.
[139] Fix | Delete
$theme_root = get_theme_root( $theme_slug );
[140] Fix | Delete
$theme_file = "{$theme_root}/{$theme_slug}/style.css";
[141] Fix | Delete
[142] Fix | Delete
if ( ! file_exists( $theme_file ) ) {
[143] Fix | Delete
continue;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
// Get WP & PHP compatibility info.
[147] Fix | Delete
$theme_headers = get_file_data(
[148] Fix | Delete
$theme_file,
[149] Fix | Delete
array(
[150] Fix | Delete
'RequiresWP' => 'Requires at least',
[151] Fix | Delete
'RequiresPHP' => 'Requires PHP',
[152] Fix | Delete
),
[153] Fix | Delete
'theme'
[154] Fix | Delete
);
[155] Fix | Delete
[156] Fix | Delete
$require_wp = et_()->array_get( $theme_headers, 'RequiresWP', null );
[157] Fix | Delete
$require_php = et_()->array_get( $theme_headers, 'RequiresPHP', null );
[158] Fix | Delete
$update_requires_wp = et_()->array_get( $theme_updates, array( $theme_slug, 'requires' ), null );
[159] Fix | Delete
$update_requires_php = et_()->array_get( $theme_updates, array( $theme_slug, 'requires_php' ), null );
[160] Fix | Delete
[161] Fix | Delete
$compatibility_properties = array(
[162] Fix | Delete
'compatibleWP' => is_wp_version_compatible( $require_wp ),
[163] Fix | Delete
'compatiblePHP' => is_php_version_compatible( $require_php ),
[164] Fix | Delete
'updateResponse' => array(
[165] Fix | Delete
'compatibleWP' => is_wp_version_compatible( $update_requires_wp ),
[166] Fix | Delete
'compatiblePHP' => is_php_version_compatible( $update_requires_php ),
[167] Fix | Delete
),
[168] Fix | Delete
);
[169] Fix | Delete
[170] Fix | Delete
$prepared_themes[ $theme_slug ] = array_merge( $prepared_themes[ $theme_slug ], $compatibility_properties );
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
return $prepared_themes;
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Get plugins data for Update Core page.
[178] Fix | Delete
*
[179] Fix | Delete
* The data processing is backported from WP 5.5 with few modification.
[180] Fix | Delete
*
[181] Fix | Delete
* @see {list_plugin_updates()} of WP 5.5
[182] Fix | Delete
*
[183] Fix | Delete
* @since 4.7.0
[184] Fix | Delete
*
[185] Fix | Delete
* @return array
[186] Fix | Delete
*/
[187] Fix | Delete
public function get_update_core_plugins_data() {
[188] Fix | Delete
$plugin_updates = get_plugin_updates();
[189] Fix | Delete
$plugin_processed = array();
[190] Fix | Delete
[191] Fix | Delete
// Bail early if there is no plugin updates.
[192] Fix | Delete
if ( empty( $plugin_updates ) ) {
[193] Fix | Delete
return array();
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
foreach ( $plugin_updates as $plugin_file => $plugin_data ) {
[197] Fix | Delete
// reason: The properties come from WP plugin data.
[198] Fix | Delete
// phpcs:disable ET.Sniffs.ValidVariableName.UsedPropertyNotSnakeCase
[199] Fix | Delete
$plugin_name = $plugin_data->Name;
[200] Fix | Delete
$plugin_version = $plugin_data->Version;
[201] Fix | Delete
// phpcs:enable
[202] Fix | Delete
[203] Fix | Delete
// a. Get current and update WP version.
[204] Fix | Delete
$wp_version = get_bloginfo( 'version' );
[205] Fix | Delete
$cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
[206] Fix | Delete
[207] Fix | Delete
$core_updates = get_core_updates();
[208] Fix | Delete
if ( ! isset( $core_updates[0]->response ) || 'latest' === $core_updates[0]->response || 'development' === $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=' ) ) {
[209] Fix | Delete
$core_update_version = false;
[210] Fix | Delete
} else {
[211] Fix | Delete
$core_update_version = $core_updates[0]->current;
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
// b. Check PHP versions compatibility. WP doesn't check WP versions compatibility.
[215] Fix | Delete
$requires_php = isset( $plugin_data->update->requires_php ) ? $plugin_data->update->requires_php : null;
[216] Fix | Delete
$compatible_php = is_php_version_compatible( $requires_php );
[217] Fix | Delete
[218] Fix | Delete
// c. Icon.
[219] Fix | Delete
$icon = '<span class="dashicons dashicons-admin-plugins"></span>';
[220] Fix | Delete
$preferred_icons = array( 'svg', '2x', '1x', 'default' );
[221] Fix | Delete
foreach ( $preferred_icons as $preferred_icon ) {
[222] Fix | Delete
if ( ! empty( $plugin_data->update->icons[ $preferred_icon ] ) ) {
[223] Fix | Delete
$icon = '<img src="' . esc_url( $plugin_data->update->icons[ $preferred_icon ] ) . '" alt="" />';
[224] Fix | Delete
break;
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
// d. Process compatibility warning text.
[229] Fix | Delete
// Get plugin compat for running version of WordPress.
[230] Fix | Delete
if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $cur_wp_version, '>=' ) ) {
[231] Fix | Delete
/* translators: %s: WordPress version. */
[232] Fix | Delete
$compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $cur_wp_version );
[233] Fix | Delete
} else {
[234] Fix | Delete
/* translators: %s: WordPress version. */
[235] Fix | Delete
$compat = '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $cur_wp_version );
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
// Get plugin compat for updated version of WordPress.
[239] Fix | Delete
if ( $core_update_version ) {
[240] Fix | Delete
if ( isset( $plugin_data->update->tested ) && version_compare( $plugin_data->update->tested, $core_update_version, '>=' ) ) {
[241] Fix | Delete
/* translators: %s: WordPress version. */
[242] Fix | Delete
$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: 100%% (according to its author)' ), $core_update_version );
[243] Fix | Delete
} else {
[244] Fix | Delete
/* translators: %s: WordPress version. */
[245] Fix | Delete
$compat .= '<br />' . sprintf( __( 'Compatibility with WordPress %s: Unknown' ), $core_update_version );
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
// Get plugin compat for updated version of PHP.
[250] Fix | Delete
if ( ! $compatible_php && current_user_can( 'update_php' ) ) {
[251] Fix | Delete
$compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
[252] Fix | Delete
$compat .= sprintf(
[253] Fix | Delete
/* translators: %s: URL to Update PHP page. */
[254] Fix | Delete
__( '<a href="%s">Learn more about updating PHP</a>.' ),
[255] Fix | Delete
esc_url( wp_get_update_php_url() )
[256] Fix | Delete
);
[257] Fix | Delete
[258] Fix | Delete
$annotation = wp_get_update_php_annotation();
[259] Fix | Delete
[260] Fix | Delete
if ( $annotation ) {
[261] Fix | Delete
$compat .= '</p><p><em>' . $annotation . '</em>';
[262] Fix | Delete
}
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
// Get the upgrade notice for the new plugin version.
[266] Fix | Delete
if ( isset( $plugin_data->update->upgrade_notice ) ) {
[267] Fix | Delete
$upgrade_notice = '<br />' . wp_strip_all_tags( $plugin_data->update->upgrade_notice );
[268] Fix | Delete
} else {
[269] Fix | Delete
$upgrade_notice = '';
[270] Fix | Delete
}
[271] Fix | Delete
[272] Fix | Delete
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662' );
[273] Fix | Delete
$details = sprintf(
[274] Fix | Delete
'<a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
[275] Fix | Delete
esc_url( $details_url ),
[276] Fix | Delete
/* translators: 1: Plugin name, 2: Version number. */
[277] Fix | Delete
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $plugin_data->update->new_version ) ),
[278] Fix | Delete
/* translators: %s: Plugin version. */
[279] Fix | Delete
sprintf( __( 'View version %s details.' ), $plugin_data->update->new_version )
[280] Fix | Delete
);
[281] Fix | Delete
[282] Fix | Delete
$checkbox_id = 'checkbox_' . md5( $plugin_name );
[283] Fix | Delete
[284] Fix | Delete
// Plugin template properties. There is no compatible_wp property passed here.
[285] Fix | Delete
$plugin_processed[ $plugin_file ] = array(
[286] Fix | Delete
'plugin_file' => esc_attr( $plugin_file ),
[287] Fix | Delete
'name' => esc_attr( $plugin_name ),
[288] Fix | Delete
'checkbox_id' => esc_attr( 'checkbox_' . md5( $plugin_name ) ),
[289] Fix | Delete
'icon' => et_core_intentionally_unescaped( $icon, 'html' ),
[290] Fix | Delete
'version' => esc_attr( $plugin_version ),
[291] Fix | Delete
'new_version' => esc_attr( $plugin_data->update->new_version ),
[292] Fix | Delete
'compatible_php' => $compatible_php,
[293] Fix | Delete
'compat' => et_core_intentionally_unescaped( $compat, 'html' ),
[294] Fix | Delete
'upgrade_notice' => et_core_intentionally_unescaped( $upgrade_notice, 'html' ),
[295] Fix | Delete
'details' => et_core_intentionally_unescaped( $details, 'html' ),
[296] Fix | Delete
);
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
return $plugin_processed;
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
/**
[303] Fix | Delete
* Get themes data for Update Core page.
[304] Fix | Delete
*
[305] Fix | Delete
* @since 4.7.0
[306] Fix | Delete
*
[307] Fix | Delete
* @return array
[308] Fix | Delete
*/
[309] Fix | Delete
public function get_update_core_themes_data() {
[310] Fix | Delete
$theme_updates = get_theme_updates();
[311] Fix | Delete
$theme_processed = array();
[312] Fix | Delete
[313] Fix | Delete
// Bail early if there is no theme updates.
[314] Fix | Delete
if ( empty( $theme_updates ) ) {
[315] Fix | Delete
return array();
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
foreach ( $theme_updates as $stylesheet => $theme ) {
[319] Fix | Delete
// a. Check compatibility.
[320] Fix | Delete
$requires_wp = et_()->array_get( $theme->update, 'requires', null );
[321] Fix | Delete
$requires_php = et_()->array_get( $theme->update, 'requires_php', null );
[322] Fix | Delete
$compatible_wp = is_wp_version_compatible( $requires_wp );
[323] Fix | Delete
$compatible_php = is_php_version_compatible( $requires_php );
[324] Fix | Delete
[325] Fix | Delete
// b. Process compatibility warning text.
[326] Fix | Delete
$compat = '';
[327] Fix | Delete
[328] Fix | Delete
if ( ! $compatible_wp && ! $compatible_php ) {
[329] Fix | Delete
$compat .= '<br>' . __( 'This update doesn&#8217;t work with your versions of WordPress and PHP.' ) . '&nbsp;';
[330] Fix | Delete
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
[331] Fix | Delete
$compat .= sprintf(
[332] Fix | Delete
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
[333] Fix | Delete
__( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
[334] Fix | Delete
esc_url( self_admin_url( 'update-core.php' ) ),
[335] Fix | Delete
esc_url( wp_get_update_php_url() )
[336] Fix | Delete
);
[337] Fix | Delete
[338] Fix | Delete
$annotation = wp_get_update_php_annotation();
[339] Fix | Delete
[340] Fix | Delete
if ( $annotation ) {
[341] Fix | Delete
$compat .= '</p><p><em>' . $annotation . '</em>';
[342] Fix | Delete
}
[343] Fix | Delete
} elseif ( current_user_can( 'update_core' ) ) {
[344] Fix | Delete
$compat .= sprintf(
[345] Fix | Delete
/* translators: %s: URL to WordPress Updates screen. */
[346] Fix | Delete
__( '<a href="%s">Please update WordPress</a>.' ),
[347] Fix | Delete
esc_url( self_admin_url( 'update-core.php' ) )
[348] Fix | Delete
);
[349] Fix | Delete
} elseif ( current_user_can( 'update_php' ) ) {
[350] Fix | Delete
$compat .= sprintf(
[351] Fix | Delete
/* translators: %s: URL to Update PHP page. */
[352] Fix | Delete
__( '<a href="%s">Learn more about updating PHP</a>.' ),
[353] Fix | Delete
esc_url( wp_get_update_php_url() )
[354] Fix | Delete
);
[355] Fix | Delete
[356] Fix | Delete
$annotation = wp_get_update_php_annotation();
[357] Fix | Delete
[358] Fix | Delete
if ( $annotation ) {
[359] Fix | Delete
$compat .= '</p><p><em>' . $annotation . '</em>';
[360] Fix | Delete
}
[361] Fix | Delete
}
[362] Fix | Delete
} elseif ( ! $compatible_wp ) {
[363] Fix | Delete
$compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of WordPress.' ) . '&nbsp;';
[364] Fix | Delete
if ( current_user_can( 'update_core' ) ) {
[365] Fix | Delete
$compat .= sprintf(
[366] Fix | Delete
/* translators: %s: URL to WordPress Updates screen. */
[367] Fix | Delete
__( '<a href="%s">Please update WordPress</a>.' ),
[368] Fix | Delete
esc_url( self_admin_url( 'update-core.php' ) )
[369] Fix | Delete
);
[370] Fix | Delete
}
[371] Fix | Delete
} elseif ( ! $compatible_php ) {
[372] Fix | Delete
$compat .= '<br>' . __( 'This update doesn&#8217;t work with your version of PHP.' ) . '&nbsp;';
[373] Fix | Delete
if ( current_user_can( 'update_php' ) ) {
[374] Fix | Delete
$compat .= sprintf(
[375] Fix | Delete
/* translators: %s: URL to Update PHP page. */
[376] Fix | Delete
__( '<a href="%s">Learn more about updating PHP</a>.' ),
[377] Fix | Delete
esc_url( wp_get_update_php_url() )
[378] Fix | Delete
);
[379] Fix | Delete
[380] Fix | Delete
$annotation = wp_get_update_php_annotation();
[381] Fix | Delete
[382] Fix | Delete
if ( $annotation ) {
[383] Fix | Delete
$compat .= '</p><p><em>' . $annotation . '</em>';
[384] Fix | Delete
}
[385] Fix | Delete
}
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
// Theme template properties.
[389] Fix | Delete
$theme_processed[ $stylesheet ] = array(
[390] Fix | Delete
'stylesheet' => esc_attr( $stylesheet ),
[391] Fix | Delete
'name' => esc_attr( $theme->display( 'Name' ) ),
[392] Fix | Delete
'checkbox_id' => esc_attr( 'checkbox_' . md5( $theme->get( 'Name' ) ) ),
[393] Fix | Delete
'screenshot' => esc_url( $theme->get_screenshot() ),
[394] Fix | Delete
'version' => esc_attr( $theme->display( 'Version' ) ),
[395] Fix | Delete
'new_version' => esc_attr( et_()->array_get( $theme->update, 'new_version', '' ) ),
[396] Fix | Delete
'compatible_wp' => $compatible_wp,
[397] Fix | Delete
'compatible_php' => $compatible_php,
[398] Fix | Delete
'compat' => et_core_esc_previously( $compat ),
[399] Fix | Delete
);
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
return $theme_processed;
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
/**
[406] Fix | Delete
* Enqueue compatibility warning scripts and its local data.
[407] Fix | Delete
*
[408] Fix | Delete
* @since 4.7.0
[409] Fix | Delete
*/
[410] Fix | Delete
public function enqueue_scripts() {
[411] Fix | Delete
global $pagenow, $wp_customize;
[412] Fix | Delete
[413] Fix | Delete
// Bail early if the current page is not one of the allowed pages.
[414] Fix | Delete
$allowed_pages = array(
[415] Fix | Delete
'update-core.php',
[416] Fix | Delete
'customize.php',
[417] Fix | Delete
'themes.php',
[418] Fix | Delete
);
[419] Fix | Delete
[420] Fix | Delete
if ( ! in_array( $pagenow, $allowed_pages, true ) ) {
[421] Fix | Delete
return;
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
// Enqueue main scripts.
[425] Fix | Delete
wp_enqueue_script( 'et_compatibility_warning_script', ET_CORE_URL . 'admin/js/compatibility-warning.js', array( 'jquery' ), ET_CORE_VERSION, true );
[426] Fix | Delete
[427] Fix | Delete
$compatibility_warning = array();
[428] Fix | Delete
[429] Fix | Delete
if ( 'update-core.php' === $pagenow ) {
[430] Fix | Delete
$compatibility_warning['update_core_data'] = array(
[431] Fix | Delete
'plugins' => self::get_update_core_plugins_data(),
[432] Fix | Delete
'themes' => self::get_update_core_themes_data(),
[433] Fix | Delete
);
[434] Fix | Delete
} elseif ( 'themes.php' === $pagenow ) {
[435] Fix | Delete
$compatibility_warning['manage_themes_data'] = true;
[436] Fix | Delete
} elseif ( 'customize.php' === $pagenow ) {
[437] Fix | Delete
// Theme Customizer - Used for disable publish button.
[438] Fix | Delete
$compatibility_warning['customizer_data'] = array(
[439] Fix | Delete
'compatible_wp' => is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) ),
[440] Fix | Delete
'compatible_php' => is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) ),
[441] Fix | Delete
'disabled_text' => esc_html_x( 'Cannot Activate', 'theme' ),
[442] Fix | Delete
);
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
wp_localize_script( 'et_compatibility_warning_script', 'et_compatibility_warning', $compatibility_warning );
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
/**
[449] Fix | Delete
* Overrides table body of plugin updates section.
[450] Fix | Delete
*
[451] Fix | Delete
* The structure is backported from WP 5.5 without any modification.
[452] Fix | Delete
*
[453] Fix | Delete
* @see {list_plugin_updates()} of WP 5.5
[454] Fix | Delete
*
[455] Fix | Delete
* @since 4.7.0
[456] Fix | Delete
*/
[457] Fix | Delete
public function overrides_update_core_plugins_table_body() {
[458] Fix | Delete
// Bail early if there is no plugin updates.
[459] Fix | Delete
if ( empty( get_plugin_updates() ) ) {
[460] Fix | Delete
return;
[461] Fix | Delete
}
[462] Fix | Delete
?>
[463] Fix | Delete
<script type="text/html" id="tmpl-et-update-core-plugins-table-body">
[464] Fix | Delete
<# if (data.plugins) { #>
[465] Fix | Delete
<# _.each(data.plugins, function(plugin, slug) { #>
[466] Fix | Delete
<tr>
[467] Fix | Delete
<td class="check-column">
[468] Fix | Delete
<# if (plugin.compatible_php) { #>
[469] Fix | Delete
<input type="checkbox" name="checked[]" id="{{plugin.checkbox_id}}" value="{{plugin.plugin_file}}" />
[470] Fix | Delete
<label for="{{plugin.checkbox_id}}" class="screen-reader-text">
[471] Fix | Delete
<?php
[472] Fix | Delete
/* translators: %s: Plugin name. */
[473] Fix | Delete
printf( esc_html__( 'Select %s' ), '{{plugin.name}}' );
[474] Fix | Delete
?>
[475] Fix | Delete
</label>
[476] Fix | Delete
<# } #>
[477] Fix | Delete
</td>
[478] Fix | Delete
<td class="plugin-title"><p>
[479] Fix | Delete
{{{plugin.icon}}}
[480] Fix | Delete
<strong>{{plugin.name}}</strong>
[481] Fix | Delete
<?php
[482] Fix | Delete
printf(
[483] Fix | Delete
/* translators: 1: Plugin version, 2: New version. */
[484] Fix | Delete
esc_html__( 'You have version %1$s installed. Update to %2$s.' ),
[485] Fix | Delete
'{{plugin.version}}',
[486] Fix | Delete
'{{plugin.new_version}}'
[487] Fix | Delete
);
[488] Fix | Delete
[489] Fix | Delete
echo ' {{{plugin.details}}}{{{plugin.compat}}}{{{plugin.upgrade_notice}}}';
[490] Fix | Delete
?>
[491] Fix | Delete
</p></td>
[492] Fix | Delete
</tr>
[493] Fix | Delete
<# }); #>
[494] Fix | Delete
<# } #>
[495] Fix | Delete
</script>
[496] Fix | Delete
<?php
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function