: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$message_minimum = sprintf(
esc_html__( 'This meets our minimum required value of %1$s. ', 'et-core' ),
esc_html( is_bool( $scan['minimum'] ) ? $this->boolean_label[ $scan['minimum'] ] : $scan['minimum'] )
* Build description messaging for results & recommendation
if ( ! is_null( $scan['learn_more'] ) ) {
$learn_more_link = sprintf( ' <a href="%1$s" target="_blank">%2$s</a>',
esc_url( $scan['learn_more'] ),
esc_html__( 'Learn more.', 'et-core' )
switch ( $system_diagnostics_settings[ $i ]['pass_fail'] ) {
$system_diagnostics_settings[ $i ]['description'] = sprintf(
esc_html__( 'Congratulations! This meets or exceeds our recommendation of %1$s.', 'et-core' ),
esc_html( is_bool( $scan['recommended'] ) ? $this->boolean_label[ $scan['recommended'] ] : $scan['recommended'] )
et_core_intentionally_unescaped( $learn_more_link, 'html' )
$system_diagnostics_settings[ $i ]['description'] = sprintf(
esc_html( $message_minimum ),
esc_html__( 'We recommend %1$s for the best experience.', 'et-core' ),
esc_html( is_bool( $scan['recommended'] ) ? $this->boolean_label[ $scan['recommended'] ] : $scan['recommended'] )
et_core_intentionally_unescaped( $learn_more_link, 'html' )
$system_diagnostics_settings[ $i ]['description'] = sprintf(
esc_html__( '- We are unable to determine your setting. %1$s', 'et-core' ),
et_core_intentionally_unescaped( $learn_more_link, 'html' )
// If we just want the array (not a formatted HTML block), return that now
if ( false === $formatted ) {
return $system_diagnostics_settings;
foreach ( $system_diagnostics_settings as $item ) {
// Add reported setting to plaintext report:
if ( 'plain' === $format ) {
switch ( $item['pass_fail'] ) {
$report .= $status . $item['name'] . PHP_EOL
. ' ' . $item['actual'] . PHP_EOL . PHP_EOL;
// Add reported setting to table:
if ( 'div' === $format ) {
if ( ! is_null( $item['help_text'] ) ) {
$help_text = $item['help_text'];
$report .= sprintf( '<div class="et-epanel-box et_system_status_row et_system_status_%1$s">
<div class="et-box-title setting">
<div class="et-box-descr"><p>%3$s</p></div>
<div class="et-box-content results">
<span class="actual">%4$s</span>
<span class="description">%5$s</span>
<span class="et-box-description"></span>
esc_attr( $item['pass_fail'] ),
esc_html( $item['name'] ),
et_core_intentionally_unescaped( $help_text, 'html' ),
esc_html( is_bool( $item['actual'] ) ? $this->boolean_label[ $item['actual'] ] : $item['actual'] ),
et_core_intentionally_unescaped( $item['description'], 'html' )
// Prepend title and timestamp
if ( 'plain' === $format ) {
$report = '## ' . esc_html__( 'System Status', 'et-core' ) . ' ##' . PHP_EOL
. ':: ' . date( 'Y-m-d @ H:i:s e' ) . PHP_EOL . PHP_EOL
if ( 'div' === $format ) {
$report = sprintf( '<div class="%3$s-report">%1$s</div><p class="%3$s-congratulations">%2$s</p>',
esc_html__( 'Congratulations, all system checks have passed. Your hosting configuration is compatible with Divi.', 'et-core' ),
* Convert size string with "shorthand byte" notation to raw byte value for comparisons.
* @return int size in bytes
protected function get_size_in_bytes( $size = '' ) {
// Capture the denomination and convert to uppercase, then do math to it
switch ( strtoupper( substr( $size, -1 ) ) ) {
return (int) $size * 1099511627776;
return (int) $size * 1073741824;
return (int) $size * 1048576;
return (int) $size * 1024;
* Convert size string with "shorthand byte" notation to raw byte value for comparisons.
* @return string size in "shorthand byte" notation
protected function get_size_in_shorthand( $bytes = 0, $precision = 2 ) {
$units = array( ' bytes', 'KB', 'MB', 'GB', 'TB' );
while ( $bytes > 1024 ) {
return round( $bytes, $precision ) . $units[ $i ];
* Size comparisons between two values using a variety of calculation methods.
* @param string|int|float $a Our value to compare against
* @param string|int|float $b Server value being compared
* @param string $type Comparison type
* @return bool Whether the second value is equal to or greater than the first
protected function value_is_at_least( $a, $b, $type = 'size' ) {
return $this->value_is_falsy( $a ) === $this->value_is_falsy( $b );
return (float) $a <= (float) $b;
return (int) $a <= (int) $b;
return $this->get_size_in_bytes( $a ) <= $this->get_size_in_bytes( $b );
* Check value against a collection of "falsy" values
* @param string|int|float $a Value to compare against
* @return bool Whether the second value is equal to or greater than the first
protected function value_is_falsy( $a ) {
// Accept falsy strings regardless of case (e.g. 'off', 'Off', 'OFF', 'oFf')
return in_array( $a, array( false, 'false', 0, '0', 'off' ), true );
* SUPPORT CENTER :: REMOTE ACCESS
* Add Support Center options to the Role Editor screen
* @see ET_Core_SupportCenter::current_user_can()
* @param $all_role_options
public function support_user_add_role_options( $all_role_options ) {
$all_role_options['support_center'] = array(
'section_title' => esc_attr__( 'Support Center', 'et-core' ),
'et_support_center' => array(
'name' => esc_attr__( 'Divi Support Center Page', 'et-core' ),
'et_support_center_system' => array(
'name' => esc_attr__( 'System Status', 'et-core' ),
'et_support_center_remote_access' => array(
'name' => esc_attr__( 'Remote Access', 'et-core' ),
'et_support_center_documentation' => array(
'name' => esc_attr__( 'Divi Documentation & Help', 'et-core' ),
'et_support_center_safe_mode' => array(
'name' => esc_attr__( 'Safe Mode', 'et-core' ),
'et_support_center_logs' => array(
'name' => esc_attr__( 'Logs', 'et-core' ),
return $all_role_options;
* Add third party capabilities to Remote Access roles
* @return array Capabilities to add to the Remote Access user roles.
public function support_user_extra_caps_standard( $extra_capabilities = array() ) {
// The Events Calendar (if active on the site)
if ( class_exists( 'Tribe__Events__Main' ) ) {
$the_events_calendar = array(
'delete_tribe_event' => 1,
'delete_tribe_events' => 1,
'edit_tribe_events' => 1,
'edit_others_tribe_events' => 1,
'delete_others_tribe_events' => 1,
'publish_tribe_events' => 1,
'edit_published_tribe_events' => 1,
'delete_published_tribe_events' => 1,
'delete_private_tribe_events' => 1,
'edit_private_tribe_events' => 1,
'read_private_tribe_events' => 1,
'delete_tribe_venue' => 1,
'delete_tribe_venues' => 1,
'edit_tribe_venues' => 1,
'edit_others_tribe_venues' => 1,
'delete_others_tribe_venues' => 1,
'publish_tribe_venues' => 1,
'edit_published_tribe_venues' => 1,
'delete_published_tribe_venues' => 1,
'delete_private_tribe_venues' => 1,
'edit_private_tribe_venues' => 1,
'read_private_tribe_venues' => 1,
'edit_tribe_organizer' => 1,
'read_tribe_organizer' => 1,
'delete_tribe_organizer' => 1,
'delete_tribe_organizers' => 1,
'edit_tribe_organizers' => 1,
'edit_others_tribe_organizers' => 1,
'delete_others_tribe_organizers' => 1,
'publish_tribe_organizers' => 1,
'edit_published_tribe_organizers' => 1,
'delete_published_tribe_organizers' => 1,
'delete_private_tribe_organizers' => 1,
'edit_private_tribe_organizers' => 1,
'read_private_tribe_organizers' => 1,
$extra_capabilities = array_merge( $extra_capabilities, $the_events_calendar );
return $extra_capabilities;
* Add third party capabilities to the *Elevated* Remote Access role only
* @return array Capabilities to add to the Elevated Remote Access user role.
public function support_user_extra_caps_elevated() {
$extra_capabilities = array();
return $extra_capabilities;
* Create the Divi Support user (if it doesn't already exist)
public function support_user_maybe_create_user() {
if ( username_exists( $this->support_user_account_name ) ) {
// Define user roles that will be used to control ET Support User permissions
$this->support_user_create_roles();
$token = $this->support_user_generate_token();
$password = $this->support_user_generate_password( $token );
if ( is_wp_error( $password ) ) {
$user_id = wp_insert_user( array(
'user_login' => $this->support_user_account_name,
'user_pass' => $password,
'first_name' => 'Elegant Themes',
'last_name' => 'Support',
'display_name' => 'Elegant Themes Support',
if ( is_wp_error( $user_id ) ) {
$account_settings = array(
'date_created' => time(),
update_option( $this->support_user_options_name, $account_settings );
// update options variable
$this->support_user_get_options();
$this->support_user_init_cron_delete_account();
* Define both Standard and Elevated roles for the Divi Support user
* @since 3.22 Added filters to extend the list of capabilities for the ET Support User
public function support_user_create_roles() {
// Make sure old versions of these roles do not exist
$this->support_user_remove_roles();
// Divi Support :: Standard
$standard_capabilities = array(
'assign_product_terms' => true,
'delete_private_pages' => true,
'delete_private_posts' => true,
'delete_private_products' => true,
'delete_product' => true,
'delete_product_terms' => true,
'delete_products' => true,
'delete_published_pages' => true,
'delete_published_posts' => true,
'delete_published_products' => true,
'edit_dashboard' => true,
'edit_others_pages' => true,
'edit_others_posts' => true,
'edit_others_products' => true,
'edit_private_pages' => true,
'edit_private_posts' => true,
'edit_private_products' => true,
'edit_product_terms' => true,
'edit_published_pages' => true,
'edit_published_posts' => true,
'edit_published_products' => true,
'edit_theme_options' => true,
'manage_categories' => true,
'manage_options' => true,
'manage_product_terms' => true,
'moderate_comments' => true,
'publish_products' => true,
'read_private_pages' => true,
'read_private_posts' => true,
'read_private_products' => true,
'unfiltered_html' => true,
'disable_module' => true,
'divi_builder_control' => true,
'edit_configuration' => true,
'edit_global_library' => true,
'read_dynamic_content_custom_fields' => true,
'use_visual_builder' => true,
// WooCommerce Capabilities
'manage_woocommerce' => true,
// Divi Support :: Elevated
$elevated_capabilities = array_merge( $standard_capabilities, array(
'activate_plugins' => true,
'delete_plugins' => true,
'install_plugins' => true,
'install_themes' => true,
'update_plugins' => true,
// Filters to allow other code to extend the list of capabilities
$additional_standard = apply_filters( 'add_et_support_standard_capabilities', array() );
$additional_elevated = apply_filters( 'add_et_support_elevated_capabilities', array() );
// Apply filter capabilities to our definitions
$standard_capabilities = array_merge( $additional_standard, $standard_capabilities );
// Just like Elevated gets all of Standard's capabilities, it also inherits Standard's filter caps
$elevated_capabilities = array_merge( $additional_standard, $additional_elevated, $elevated_capabilities );
// Create the standard ET Support role
add_role( 'et_support', 'ET Support', $standard_capabilities );
$et_support_role = get_role( 'et_support' );
foreach ( $standard_capabilities as $cap ) {
$et_support_role->add_cap( $cap );
// Create the elevated ET Support role
add_role( 'et_support_elevated', 'ET Support - Elevated', $elevated_capabilities );
$et_support_elevated_role = get_role( 'et_support_elevated' );
foreach ( $elevated_capabilities as $cap ) {
$et_support_elevated_role->add_cap( $cap );
* Remove our Standard and Elevated Support roles