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.../httpdocs/wp-conte.../themes/Divi/core/componen...
File: SupportCenter.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// Quick exit if accessed directly
[2] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[3] Fix | Delete
exit;
[4] Fix | Delete
}
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Elegant Themes Support Center adds a new page to the WP Admin menu.
[8] Fix | Delete
*
[9] Fix | Delete
* System Status
[10] Fix | Delete
* Here we note system settings that could potentially cause problems. An extended view (displaying all settings we
[11] Fix | Delete
* check, not just those with problematic results) can be toggled, with an option to copy this report to the
[12] Fix | Delete
* clipboard so it can be pasted in a support ticket.
[13] Fix | Delete
*
[14] Fix | Delete
* Elegant Themes Support
[15] Fix | Delete
* If Remote Access is enabled in this section, Elegant Themes Support will be granted limited access to the user's site
[16] Fix | Delete
* (@see ET_Core_SupportCenter::support_user_maybe_create_user()). When this is activated, a second toggle appears
[17] Fix | Delete
* for the user that will allow them to enable "Full Admin Privileges" which has no restrictions (only certain ET
[18] Fix | Delete
* Support staff will be able to request that the user enables this). Full Admin Privileges can be disabled at any
[19] Fix | Delete
* time, but are automatically disabled whenever the Remote Access is disabled (manually or by timeout). Time
[20] Fix | Delete
* remaining until Remote Access is automatically deactivated is indicated alongside the toggle. A link for
[21] Fix | Delete
* initiating a chat https://www.elegantthemes.com/members-area/help/ is also available in this section.
[22] Fix | Delete
*
[23] Fix | Delete
* Divi Documentation & Help
[24] Fix | Delete
* This section contains common help videos, articles, and a link to full documentation. This is not meant to be a
[25] Fix | Delete
* full service documentation center; it's mainly a launch off point.
[26] Fix | Delete
*
[27] Fix | Delete
* Divi Safe Mode
[28] Fix | Delete
* A quick and easy way for users and support to quickly disable plugins and scripts to see if Divi is the cause of
[29] Fix | Delete
* an issue. This call to action disables active plugins, custom css, child themes, scripts in the Integrations tab,
[30] Fix | Delete
* static css, and combination/minification of CSS and JS. When enabling this, the user will be presented with a
[31] Fix | Delete
* list of plugins that will be affected (disabled). Sitewide (not including the Visual Builder), there will be a
[32] Fix | Delete
* floating indicator in the upper right or left corner of the website that will indicate that Safe Mode is enabled
[33] Fix | Delete
* and will contain a link that takes you to the Support Page to disabled it.
[34] Fix | Delete
*
[35] Fix | Delete
* Logs
[36] Fix | Delete
* If WP_DEBUG_LOG is enabled, WordPress related errors will be archived in a log file. We load the most recent entries
[37] Fix | Delete
* of this log file for convienient viewing here, with a link to download the full log, as well as an option to copy
[38] Fix | Delete
* the log to the clipboard so it can be pasted in a support ticket.
[39] Fix | Delete
*
[40] Fix | Delete
* @package ET\Core\SupportCenter
[41] Fix | Delete
* @author Elegant Themes <http://www.elegantthemes.com>
[42] Fix | Delete
* @license GNU General Public License v2 <http://www.gnu.org/licenses/gpl-2.0.html>
[43] Fix | Delete
*
[44] Fix | Delete
* @since 3.24.1 Renamed from `ET_Support_Center` to `ET_Core_SupportCenter`.
[45] Fix | Delete
* @since 3.20
[46] Fix | Delete
*/
[47] Fix | Delete
class ET_Core_SupportCenter {
[48] Fix | Delete
/**
[49] Fix | Delete
* Catch whether the ET_DEBUG flag is set.
[50] Fix | Delete
*
[51] Fix | Delete
* @since 3.20
[52] Fix | Delete
*
[53] Fix | Delete
* @type string
[54] Fix | Delete
*/
[55] Fix | Delete
protected $DEBUG_ET_SUPPORT_CENTER = false;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Identifier for the parent theme or plugin activating the Support Center.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 3.20
[61] Fix | Delete
*
[62] Fix | Delete
* @type string
[63] Fix | Delete
*/
[64] Fix | Delete
protected $parent = '';
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* "Nice name" for the parent theme or plugin activating the Support Center.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 3.20
[70] Fix | Delete
*
[71] Fix | Delete
* @type string
[72] Fix | Delete
*/
[73] Fix | Delete
protected $parent_nicename = '';
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Whether the Support Center was activated through a `plugin` or a `theme`.
[77] Fix | Delete
*
[78] Fix | Delete
* @since 3.20
[79] Fix | Delete
*
[80] Fix | Delete
* @type string
[81] Fix | Delete
*/
[82] Fix | Delete
protected $child_of = '';
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Identifier for the parent theme or plugin activating the Support Center.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 3.20
[88] Fix | Delete
*
[89] Fix | Delete
* @type string
[90] Fix | Delete
*/
[91] Fix | Delete
protected $local_path;
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Support User options
[95] Fix | Delete
*
[96] Fix | Delete
* @since 3.20
[97] Fix | Delete
*
[98] Fix | Delete
* @type array
[99] Fix | Delete
*/
[100] Fix | Delete
protected $support_user_options;
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Support User account name
[104] Fix | Delete
*
[105] Fix | Delete
* @since 3.20
[106] Fix | Delete
*
[107] Fix | Delete
* @type string
[108] Fix | Delete
*/
[109] Fix | Delete
protected $support_user_account_name = 'elegant_themes_support';
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Support options name in the database
[113] Fix | Delete
*
[114] Fix | Delete
* @since 3.20
[115] Fix | Delete
*
[116] Fix | Delete
* @type string
[117] Fix | Delete
*/
[118] Fix | Delete
protected $support_user_options_name = 'et_support_options';
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* Name of the cron job we use to auto-delete the Support User account
[122] Fix | Delete
*
[123] Fix | Delete
* @since 3.20
[124] Fix | Delete
*
[125] Fix | Delete
* @type string
[126] Fix | Delete
*/
[127] Fix | Delete
protected $support_user_cron_name = 'et_cron_delete_support_account';
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Expiration time to auto-delete the Support User account via cron
[131] Fix | Delete
*
[132] Fix | Delete
* @since 3.20
[133] Fix | Delete
*
[134] Fix | Delete
* @type string
[135] Fix | Delete
*/
[136] Fix | Delete
protected $support_user_expiration_time = '+4 days';
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Provide nicename equivalents for boolean values
[140] Fix | Delete
*
[141] Fix | Delete
* @since 3.23
[142] Fix | Delete
*
[143] Fix | Delete
* @type array
[144] Fix | Delete
*/
[145] Fix | Delete
protected $boolean_label = array( 'False', 'True' );
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Collection of plugins that we will NOT disable when Safe Mode is activated.
[149] Fix | Delete
*
[150] Fix | Delete
* @since 3.20
[151] Fix | Delete
*
[152] Fix | Delete
* @type array
[153] Fix | Delete
*/
[154] Fix | Delete
protected $safe_mode_plugins_allowlist = array(
[155] Fix | Delete
'etdev/etdev.php', // ET Development Workspace
[156] Fix | Delete
'bloom/bloom.php', // ET Bloom Plugin
[157] Fix | Delete
'monarch/monarch.php', // ET Monarch Plugin
[158] Fix | Delete
'divi-builder/divi-builder.php', // ET Divi Builder Plugin
[159] Fix | Delete
'ari-adminer/ari-adminer.php', // ARI Adminer
[160] Fix | Delete
'query-monitor/query-monitor.php', // Query Monitor
[161] Fix | Delete
'woocommerce/woocommerce.php', // WooCommerce
[162] Fix | Delete
'really-simple-ssl/rlrsssl-really-simple-ssl.php', // Really Simple SSL
[163] Fix | Delete
);
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Capabilities that should be granted to the Administrator role on activation.
[167] Fix | Delete
*
[168] Fix | Delete
* @since 3.28
[169] Fix | Delete
*
[170] Fix | Delete
* @type array
[171] Fix | Delete
*/
[172] Fix | Delete
protected $support_center_administrator_caps = array(
[173] Fix | Delete
'et_support_center',
[174] Fix | Delete
'et_support_center_system',
[175] Fix | Delete
'et_support_center_remote_access',
[176] Fix | Delete
'et_support_center_documentation',
[177] Fix | Delete
'et_support_center_safe_mode',
[178] Fix | Delete
'et_support_center_logs',
[179] Fix | Delete
);
[180] Fix | Delete
[181] Fix | Delete
/**
[182] Fix | Delete
* Collection of Cards that has button to dismiss the Card.
[183] Fix | Delete
*
[184] Fix | Delete
* @since 4.4.7
[185] Fix | Delete
*
[186] Fix | Delete
* @type array
[187] Fix | Delete
*/
[188] Fix | Delete
protected $card_with_dismiss_button = array(
[189] Fix | Delete
'et_hosting_card',
[190] Fix | Delete
);
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Core functionality of the class
[194] Fix | Delete
*
[195] Fix | Delete
* @since 4.4.7 Added WP AJAX action for dismissible button for a card
[196] Fix | Delete
* @since 3.20
[197] Fix | Delete
*
[198] Fix | Delete
* @param string $parent Identifier for the parent theme or plugin activating the Support Center.
[199] Fix | Delete
*/
[200] Fix | Delete
public function __construct( $parent = '' ) {
[201] Fix | Delete
// Verbose logging: only log if `wp-config.php` has defined `ET_DEBUG='support_center'`
[202] Fix | Delete
$this->DEBUG_ET_SUPPORT_CENTER = defined( 'ET_DEBUG' ) && 'support_center' === ET_DEBUG;
[203] Fix | Delete
[204] Fix | Delete
// Set the identifier for the parent theme or plugin activating the Support Center.
[205] Fix | Delete
$this->parent = $parent;
[206] Fix | Delete
[207] Fix | Delete
// Get `et_support_options` settings & set $this->support_user_options
[208] Fix | Delete
$this->support_user_get_options();
[209] Fix | Delete
[210] Fix | Delete
// Set the Site ID data via Elegant Themes API & token
[211] Fix | Delete
$this->maybe_set_site_id();
[212] Fix | Delete
[213] Fix | Delete
// Set the plugins allowlist for Safe Mode
[214] Fix | Delete
$this->set_safe_mode_plugins_allowlist();
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* WordPress action & filter setup
[219] Fix | Delete
*
[220] Fix | Delete
* @since 3.20
[221] Fix | Delete
*/
[222] Fix | Delete
public function init() {
[223] Fix | Delete
update_option( 'et_support_center_installed', 'true' );
[224] Fix | Delete
[225] Fix | Delete
// Establish which theme or plugin has loaded the Support Center
[226] Fix | Delete
$this->set_parent_properties();
[227] Fix | Delete
[228] Fix | Delete
// When initialized, deactivate conflicting plugins
[229] Fix | Delete
$this->deactivate_conflicting_plugins();
[230] Fix | Delete
[231] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts_styles' ) );
[232] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) );
[233] Fix | Delete
[234] Fix | Delete
// SC scripts are only used in FE for the "Turn Off Divi Safe Mode" floating button.
[235] Fix | Delete
if ( et_core_is_safe_mode_active() ) {
[236] Fix | Delete
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) );
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
// Add extra User Role capabilities needed for Remote Access to work with 3rd party software
[240] Fix | Delete
add_filter( 'add_et_support_standard_capabilities', array( $this, 'support_user_extra_caps_standard' ), 10, 1 );
[241] Fix | Delete
add_filter( 'add_et_support_elevated_capabilities', array( $this, 'support_user_extra_caps_elevated' ), 10, 1 );
[242] Fix | Delete
[243] Fix | Delete
// Make sure that our Support Account's roles are set up
[244] Fix | Delete
add_filter( 'add_et_builder_role_options', array( $this, 'support_user_add_role_options' ), 10, 1 );
[245] Fix | Delete
[246] Fix | Delete
// On Multisite installs, grant `unfiltered_html` capabilities to the Support User
[247] Fix | Delete
add_filter( 'map_meta_cap', array( $this, 'support_user_map_meta_cap' ), 1, 3 );
[248] Fix | Delete
[249] Fix | Delete
// Add CSS class name(s) to the Support Center page's body tag
[250] Fix | Delete
add_filter( 'admin_body_class', array( $this, 'add_admin_body_class_name' ) );
[251] Fix | Delete
[252] Fix | Delete
// Add a link to the Support Center in the admin menu
[253] Fix | Delete
add_filter( 'admin_menu', array( $this, 'add_admin_menu_item' ) );
[254] Fix | Delete
[255] Fix | Delete
// When Safe Mode is enabled, add floating frontend indicator
[256] Fix | Delete
add_action( 'admin_footer', array( $this, 'maybe_add_safe_mode_indicator' ) );
[257] Fix | Delete
add_action( 'wp_footer', array( $this, 'maybe_add_safe_mode_indicator' ) );
[258] Fix | Delete
[259] Fix | Delete
// Add User capabilities to the Administrator Role
[260] Fix | Delete
add_action( 'admin_init', array( $this, 'support_center_capabilities_setup' ) );
[261] Fix | Delete
[262] Fix | Delete
if ( 'plugin' === $this->child_of ) {
[263] Fix | Delete
// Delete our Support User settings on deactivation
[264] Fix | Delete
register_deactivation_hook( __FILE__, array( $this, 'support_user_delete_account' ) );
[265] Fix | Delete
register_deactivation_hook( __FILE__, array( $this, 'unlist_support_center' ) );
[266] Fix | Delete
register_deactivation_hook( __FILE__, array( $this, 'support_center_capabilities_teardown' ) );
[267] Fix | Delete
}
[268] Fix | Delete
if ( 'theme' === $this->child_of ) {
[269] Fix | Delete
// Delete our Support User settings on deactivation
[270] Fix | Delete
add_action( 'switch_theme', array( $this, 'maybe_deactivate_on_theme_switch' ) );
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// Automatically delete our Support User when the time runs out
[274] Fix | Delete
add_action( $this->support_user_cron_name, array( $this, 'support_user_cron_maybe_delete_account' ) );
[275] Fix | Delete
add_action( 'init', array( $this, 'support_user_maybe_delete_expired_account' ) );
[276] Fix | Delete
add_action( 'admin_init', array( $this, 'support_user_maybe_delete_expired_account' ) );
[277] Fix | Delete
[278] Fix | Delete
// Remove KSES filters for ET Support User
[279] Fix | Delete
add_action( 'admin_init', array( $this, 'support_user_kses_remove_filters' ) );
[280] Fix | Delete
[281] Fix | Delete
// Update Support User settings via AJAX
[282] Fix | Delete
add_action( 'wp_ajax_et_support_user_update', array( $this, 'support_user_update_via_ajax' ) );
[283] Fix | Delete
[284] Fix | Delete
// Toggle Safe Mode via AJAX
[285] Fix | Delete
add_action( 'wp_ajax_et_safe_mode_update', array( $this, 'safe_mode_update_via_ajax' ) );
[286] Fix | Delete
[287] Fix | Delete
// Safe Mode: Block restricted actions when Safe Mode active
[288] Fix | Delete
add_action( 'admin_footer', array( $this, 'render_safe_mode_block_restricted' ) );
[289] Fix | Delete
[290] Fix | Delete
// Safe Mode: Temporarily disable Custom CSS
[291] Fix | Delete
add_action( 'init', array( $this, 'maybe_disable_custom_css' ) );
[292] Fix | Delete
[293] Fix | Delete
// Safe Mode: Remove "Additional CSS" from WP Head action hook
[294] Fix | Delete
if ( et_core_is_safe_mode_active() ) {
[295] Fix | Delete
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
// Support Center Card: Handle Dismiss Button
[299] Fix | Delete
add_action( 'wp_ajax_et_dismiss_support_center_card', array( $this, 'dismiss_support_center_card_via_ajax' ) );
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
/**
[303] Fix | Delete
* Add User capabilities to the Administrator Role (if it exists) on first run
[304] Fix | Delete
*
[305] Fix | Delete
* @since 3.29.2 Added check to verify the Administrator Role exists before attempting to run `add_cap()`.
[306] Fix | Delete
* @since 3.28
[307] Fix | Delete
*/
[308] Fix | Delete
public function support_center_capabilities_setup() {
[309] Fix | Delete
$support_capabilities = get_option( 'et_support_center_setup_done' );
[310] Fix | Delete
$administrator_role = get_role( 'administrator' );
[311] Fix | Delete
[312] Fix | Delete
if ( $administrator_role && ! $support_capabilities ) {
[313] Fix | Delete
foreach ( $this->support_center_administrator_caps as $cap ) {
[314] Fix | Delete
$administrator_role->add_cap( $cap );
[315] Fix | Delete
}
[316] Fix | Delete
update_option( 'et_support_center_setup_done', 'processed' );
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
/**
[321] Fix | Delete
* Remove User capabilities from the Administrator Role when product with Support Center is removed
[322] Fix | Delete
*
[323] Fix | Delete
* @since 3.29.2 Added check to verify the Administrator Role exists before attempting to run `remove_cap()`.
[324] Fix | Delete
* @since 3.28
[325] Fix | Delete
*/
[326] Fix | Delete
public function support_center_capabilities_teardown() {
[327] Fix | Delete
$support_capabilities = get_option( 'et_support_center_setup_done' );
[328] Fix | Delete
$administrator_role = get_role( 'administrator' );
[329] Fix | Delete
[330] Fix | Delete
if ( $administrator_role && $support_capabilities ) {
[331] Fix | Delete
foreach ( $this->support_center_administrator_caps as $cap ) {
[332] Fix | Delete
$administrator_role->remove_cap( $cap );
[333] Fix | Delete
}
[334] Fix | Delete
delete_option( 'et_support_center_setup_done' );
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* Set variables that change depending on whether a theme or a plugin activated the Support Center
[340] Fix | Delete
*
[341] Fix | Delete
* @since 3.20
[342] Fix | Delete
*/
[343] Fix | Delete
public function set_parent_properties() {
[344] Fix | Delete
$core_path = _et_core_normalize_path( trailingslashit( dirname( __FILE__ ) ) );
[345] Fix | Delete
$theme_dir = _et_core_normalize_path( trailingslashit( realpath( get_template_directory() ) ) );
[346] Fix | Delete
[347] Fix | Delete
if ( 0 === strpos( $core_path, $theme_dir ) ) {
[348] Fix | Delete
$this->child_of = 'theme';
[349] Fix | Delete
$this->local_path = trailingslashit( get_template_directory_uri() . '/core/' );
[350] Fix | Delete
} else {
[351] Fix | Delete
$this->child_of = 'plugin';
[352] Fix | Delete
$this->local_path = plugins_url( '/', dirname( __FILE__ ) );
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
$this->parent_nicename = $this->get_parent_nicename( $this->parent );
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
/**
[359] Fix | Delete
* Get the "Nice Name" for the parent theme/plugin
[360] Fix | Delete
*
[361] Fix | Delete
* @param $parent
[362] Fix | Delete
*
[363] Fix | Delete
* @return bool|string
[364] Fix | Delete
*/
[365] Fix | Delete
public function get_parent_nicename( $parent ) {
[366] Fix | Delete
switch ( $parent ) {
[367] Fix | Delete
case 'bloom_plugin':
[368] Fix | Delete
return 'Bloom';
[369] Fix | Delete
break;
[370] Fix | Delete
case 'monarch_plugin':
[371] Fix | Delete
return 'Monarch';
[372] Fix | Delete
break;
[373] Fix | Delete
case 'extra_theme':
[374] Fix | Delete
return 'Extra';
[375] Fix | Delete
break;
[376] Fix | Delete
case 'divi_theme':
[377] Fix | Delete
return 'Divi';
[378] Fix | Delete
break;
[379] Fix | Delete
case 'divi_builder_plugin':
[380] Fix | Delete
return 'Divi Builder';
[381] Fix | Delete
break;
[382] Fix | Delete
default:
[383] Fix | Delete
return false;
[384] Fix | Delete
}
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Prevent any possible conflicts with the Elegant Themes Support plugin
[389] Fix | Delete
*
[390] Fix | Delete
* @since 3.20
[391] Fix | Delete
*/
[392] Fix | Delete
public function deactivate_conflicting_plugins() {
[393] Fix | Delete
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
[394] Fix | Delete
[395] Fix | Delete
// Load WP user management functions
[396] Fix | Delete
if ( is_multisite() ) {
[397] Fix | Delete
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
[398] Fix | Delete
} else {
[399] Fix | Delete
require_once( ABSPATH . 'wp-admin/includes/user.php' );
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
// Verify that WP user management functions are available
[403] Fix | Delete
$can_delete_user = false;
[404] Fix | Delete
if ( is_multisite() && function_exists( 'wpmu_delete_user' ) ) {
[405] Fix | Delete
$can_delete_user = true;
[406] Fix | Delete
}
[407] Fix | Delete
if ( ! is_multisite() && function_exists( 'wp_delete_user' ) ) {
[408] Fix | Delete
$can_delete_user = true;
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
if ( $can_delete_user ) {
[412] Fix | Delete
deactivate_plugins( '/elegant-themes-support/elegant-themes-support.php' );
[413] Fix | Delete
} else {
[414] Fix | Delete
et_error( 'Support Center: Unable to deactivate the ET Support Plugin.' );
[415] Fix | Delete
}
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
/**
[419] Fix | Delete
* @param string $capability
[420] Fix | Delete
*
[421] Fix | Delete
* @return bool
[422] Fix | Delete
*/
[423] Fix | Delete
protected function current_user_can( $capability = '' ) {
[424] Fix | Delete
if ( function_exists( 'et_is_builder_plugin_active' ) ) {
[425] Fix | Delete
return et_pb_is_allowed( $capability );
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
return current_user_can( $capability );
[429] Fix | Delete
}
[430] Fix | Delete
[431] Fix | Delete
/**
[432] Fix | Delete
* Add Safe Mode Autoloader Must-Use Plugin
[433] Fix | Delete
*
[434] Fix | Delete
* @since 3.20
[435] Fix | Delete
*/
[436] Fix | Delete
public function maybe_add_mu_autoloader() {
[437] Fix | Delete
$file_name = '/SupportCenterMUAutoloader.php';
[438] Fix | Delete
$file_path = dirname( __FILE__ );
[439] Fix | Delete
[440] Fix | Delete
// Exit if the `mu-plugins` directory doesn't exist & we're unable to create it
[441] Fix | Delete
if ( ! wp_mkdir_p( WPMU_PLUGIN_DIR ) ) {
[442] Fix | Delete
et_error( 'Support Center Safe Mode: mu-plugin folder not found.' );
[443] Fix | Delete
[444] Fix | Delete
return;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
$pathname_to = WPMU_PLUGIN_DIR . $file_name;
[448] Fix | Delete
$pathname_from = $file_path . $file_name;
[449] Fix | Delete
[450] Fix | Delete
// Exit if we can't find the mu-plugins autoloader
[451] Fix | Delete
if ( ! file_exists( $pathname_from ) ) {
[452] Fix | Delete
et_error( 'Support Center Safe Mode: mu-plugin autoloader not found.' );
[453] Fix | Delete
[454] Fix | Delete
return;
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
// Try to create a new subdirectory for our mu-plugins; if it fails, log an error message
[458] Fix | Delete
$pathname_plugins_from = dirname( __FILE__ ) . '/mu-plugins';
[459] Fix | Delete
$pathname_plugins_to = WPMU_PLUGIN_DIR . '/et-safe-mode';
[460] Fix | Delete
if ( ! wp_mkdir_p( $pathname_plugins_to ) ) {
[461] Fix | Delete
et_error( 'Support Center Safe Mode: mu-plugins subfolder not found.' );
[462] Fix | Delete
[463] Fix | Delete
return;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
// Try to copy the mu-plugins; if any fail, log an error message
[467] Fix | Delete
if ( $mu_plugins = glob( dirname( __FILE__ ) . '/mu-plugins/*.php' ) ) {
[468] Fix | Delete
foreach ( $mu_plugins as $plugin ) {
[469] Fix | Delete
$new_file_path = str_replace( $pathname_plugins_from, $pathname_plugins_to, $plugin );
[470] Fix | Delete
[471] Fix | Delete
// Skip if this particular mu-plugin hasn't changed
[472] Fix | Delete
if ( file_exists( $new_file_path ) && md5_file( $new_file_path ) === md5_file( $plugin ) ) {
[473] Fix | Delete
continue;
[474] Fix | Delete
}
[475] Fix | Delete
[476] Fix | Delete
$copy_file = @copy( $plugin, $new_file_path );
[477] Fix | Delete
[478] Fix | Delete
if ( ! $this->DEBUG_ET_SUPPORT_CENTER ) {
[479] Fix | Delete
continue;
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
if ( $copy_file ) {
[483] Fix | Delete
et_error( 'Support Center Safe Mode: mu-plugin [' . $plugin . '] installed.' );
[484] Fix | Delete
} else {
[485] Fix | Delete
et_error( 'Support Center Safe Mode: mu-plugin [' . $plugin . '] failed installation. ' );
[486] Fix | Delete
}
[487] Fix | Delete
}
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
// Finally, try to copy the autoloader file; if it fails, log an error message
[491] Fix | Delete
[492] Fix | Delete
// Skip if the mu-plugins autoloader hasn't changed
[493] Fix | Delete
if ( file_exists( $pathname_to ) && md5_file( $pathname_to ) === md5_file( $pathname_from ) ) {
[494] Fix | Delete
return;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
$copy_file = @copy( $pathname_from, $pathname_to );
[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