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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder
File: class-et-builder-element.php
// add default toggles
[500] Fix | Delete
$default_general_toggles = array(
[501] Fix | Delete
'admin_label' => array(
[502] Fix | Delete
'title' => et_builder_i18n( 'Admin Label' ),
[503] Fix | Delete
'priority' => 99,
[504] Fix | Delete
),
[505] Fix | Delete
);
[506] Fix | Delete
[507] Fix | Delete
$this->_add_settings_modal_toggles( 'general', $default_general_toggles );
[508] Fix | Delete
}
[509] Fix | Delete
[510] Fix | Delete
$this->_add_settings_modal_toggles( 'custom_css', array(
[511] Fix | Delete
'visibility' => array(
[512] Fix | Delete
'title' => et_builder_i18n( 'Visibility' ),
[513] Fix | Delete
'priority' => 99,
[514] Fix | Delete
),
[515] Fix | Delete
) );
[516] Fix | Delete
[517] Fix | Delete
[518] Fix | Delete
$i18n =& self::$i18n;
[519] Fix | Delete
[520] Fix | Delete
if ( ! isset( $i18n['toggles'] ) ) {
[521] Fix | Delete
// phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
[522] Fix | Delete
$i18n['toggles'] = array(
[523] Fix | Delete
'scroll' => esc_html__( 'Scroll Effects', 'et_builder' ),
[524] Fix | Delete
);
[525] Fix | Delete
// phpcs:enable
[526] Fix | Delete
}
[527] Fix | Delete
[528] Fix | Delete
$this->_add_settings_modal_toggles( 'custom_css', array(
[529] Fix | Delete
'scroll_effects' => array(
[530] Fix | Delete
'title' => $i18n['toggles']['scroll'],
[531] Fix | Delete
'priority' => 200,
[532] Fix | Delete
),
[533] Fix | Delete
) );
[534] Fix | Delete
[535] Fix | Delete
$this->main_tabs = $this->get_main_tabs();
[536] Fix | Delete
[537] Fix | Delete
$this->custom_css_tab = isset( $this->custom_css_tab ) ? $this->custom_css_tab : true;
[538] Fix | Delete
[539] Fix | Delete
self::$modules[ $this->slug ] = $this;
[540] Fix | Delete
[541] Fix | Delete
$post_types = ! empty( $this->post_types ) ? $this->post_types : et_builder_get_builder_post_types();
[542] Fix | Delete
[543] Fix | Delete
// all modules should be assigned for et_pb_layout post type to work in the library
[544] Fix | Delete
if ( ! in_array( 'et_pb_layout', $post_types ) ) {
[545] Fix | Delete
$post_types[] = 'et_pb_layout';
[546] Fix | Delete
}
[547] Fix | Delete
[548] Fix | Delete
$this->post_types = apply_filters( 'et_builder_module_post_types', $post_types, $this->slug, $this->post_types );
[549] Fix | Delete
[550] Fix | Delete
foreach ( $this->post_types as $post_type ) {
[551] Fix | Delete
if ( ! in_array( $post_type, $this->post_types ) ) {
[552] Fix | Delete
$this->register_post_type( $post_type );
[553] Fix | Delete
}
[554] Fix | Delete
[555] Fix | Delete
if ( ! isset( self::$_module_slugs_by_post_type[ $post_type ] ) ) {
[556] Fix | Delete
self::$_module_slugs_by_post_type[ $post_type ] = array();
[557] Fix | Delete
}
[558] Fix | Delete
[559] Fix | Delete
if ( ! in_array( $this->slug, self::$_module_slugs_by_post_type[ $post_type ] ) ) {
[560] Fix | Delete
self::$_module_slugs_by_post_type[ $post_type ][] = $this->slug;
[561] Fix | Delete
}
[562] Fix | Delete
[563] Fix | Delete
if ( isset( $this->additional_shortcode ) && ! in_array( $this->additional_shortcode, self::$_module_slugs_by_post_type[ $post_type ] ) ) {
[564] Fix | Delete
self::$_module_slugs_by_post_type[ $post_type ][] = $this->additional_shortcode;
[565] Fix | Delete
}
[566] Fix | Delete
[567] Fix | Delete
if ( isset( $this->additional_shortcode_slugs ) ) {
[568] Fix | Delete
foreach ( $this->additional_shortcode_slugs as $additional_shortcode_slug ) {
[569] Fix | Delete
if ( ! in_array( $additional_shortcode_slug, self::$_module_slugs_by_post_type[ $post_type ] ) ) {
[570] Fix | Delete
self::$_module_slugs_by_post_type[ $post_type ][] = $additional_shortcode_slug;
[571] Fix | Delete
}
[572] Fix | Delete
}
[573] Fix | Delete
}
[574] Fix | Delete
[575] Fix | Delete
if ( 'child' === $this->type ) {
[576] Fix | Delete
self::$child_modules[ $post_type ][ $this->slug ] = $this;
[577] Fix | Delete
if ( isset( $this->additional_shortcode_slugs ) ) {
[578] Fix | Delete
foreach( $this->additional_shortcode_slugs as $additional_slug ) {
[579] Fix | Delete
self::$child_modules[ $post_type ][ $additional_slug ] = $this;
[580] Fix | Delete
}
[581] Fix | Delete
}
[582] Fix | Delete
} else {
[583] Fix | Delete
self::$parent_modules[ $post_type ][ $this->slug ] = $this;
[584] Fix | Delete
}
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
// WooCommerce modules data only deterimine whether a module is WooCommerce modules or not
[588] Fix | Delete
// it doesn't need to be aware whether it is available in certain CPT or not.
[589] Fix | Delete
if ( $this->_is_woocommerce_module ) {
[590] Fix | Delete
self::$woocommerce_modules[] = $this->slug;
[591] Fix | Delete
}
[592] Fix | Delete
[593] Fix | Delete
if ( ! isset( $this->no_render ) ) {
[594] Fix | Delete
$shortcode_slugs = array( $this->slug );
[595] Fix | Delete
[596] Fix | Delete
if ( ! empty( $this->additional_shortcode_slugs ) ) {
[597] Fix | Delete
$shortcode_slugs = array_merge( $shortcode_slugs, $this->additional_shortcode_slugs );
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
foreach ( $shortcode_slugs as $shortcode_slug ) {
[601] Fix | Delete
add_shortcode( $shortcode_slug, array( $this, '_render' ) );
[602] Fix | Delete
}
[603] Fix | Delete
[604] Fix | Delete
if ( isset( $this->additional_shortcode ) ) {
[605] Fix | Delete
add_shortcode( $this->additional_shortcode, array( $this, 'additional_render' ) );
[606] Fix | Delete
}
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
if ( isset( $this->icon ) ) {
[610] Fix | Delete
self::$_->array_set( self::$module_icons, "{$this->slug}.icon", $this->icon );
[611] Fix | Delete
}
[612] Fix | Delete
[613] Fix | Delete
if ( isset( $this->icon_path ) ) {
[614] Fix | Delete
self::$_->array_set( self::$module_icons, "{$this->slug}.icon_path", $this->icon_path );
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
// Push module's help videos to all help videos array if there's any
[618] Fix | Delete
if ( ! empty( $this->help_videos ) ) {
[619] Fix | Delete
[620] Fix | Delete
// Automatically add design tab and library tutorial. DRY
[621] Fix | Delete
if ( 'et_pb_column' !== $this->slug ) {
[622] Fix | Delete
// Adding next tabs (design & tab) helps
[623] Fix | Delete
$next_tabs_help = array(
[624] Fix | Delete
'id' => '1iqjhnHVA9Y',
[625] Fix | Delete
'name' => esc_html__( 'Design Settings and Advanced Module Settings', 'et_builder' ),
[626] Fix | Delete
);
[627] Fix | Delete
[628] Fix | Delete
// Adjust row name
[629] Fix | Delete
if ( in_array( $this->slug, array( 'et_pb_row', 'et_pb_row_inner' ) ) ) {
[630] Fix | Delete
$next_tabs_help['name'] = esc_html__( 'Design Settings and Advanced Row Settings', 'et_builder' );
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
// Adjust section name
[634] Fix | Delete
if ( 'et_pb_section' === $this->slug ) {
[635] Fix | Delete
$next_tabs_help['name'] = esc_html__( 'Design Settings and Advanced Section Settings', 'et_builder' );
[636] Fix | Delete
}
[637] Fix | Delete
[638] Fix | Delete
$this->help_videos[] = $next_tabs_help;
[639] Fix | Delete
[640] Fix | Delete
// Adding Divi Library helps
[641] Fix | Delete
$this->help_videos[] = array(
[642] Fix | Delete
'id' => 'boNZZ0MYU0E',
[643] Fix | Delete
'name' => esc_html__( 'Saving and loading from the library', 'et_builder' ),
[644] Fix | Delete
);
[645] Fix | Delete
}
[646] Fix | Delete
[647] Fix | Delete
self::$module_help_videos[ $this->slug ] = $this->help_videos;
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
// Push module slug if this module has content option. These modules' content option need
[651] Fix | Delete
// to be autop-ed during saving process to avoid unstyled body content in Divi Builder Plugin due
[652] Fix | Delete
// to content not having <p> tag because it doesn't wrapped by newline during saving process
[653] Fix | Delete
if ( ! $this->use_raw_content && ! $this->child_slug && 'tiny_mce' === self::$_->array_get( $this->get_fields(), 'content.type' ) ) {
[654] Fix | Delete
self::$has_content_modules[] = $this->slug;
[655] Fix | Delete
}
[656] Fix | Delete
[657] Fix | Delete
}
[658] Fix | Delete
[659] Fix | Delete
public function __call( $name, $args ) {
[660] Fix | Delete
$class = get_class( $this );
[661] Fix | Delete
$message = "You're Doing It Wrong!";
[662] Fix | Delete
$is_deprecated = array_key_exists( $name, self::$_deprecations['methods'] );
[663] Fix | Delete
$value = null;
[664] Fix | Delete
$old_method_exists = method_exists( $this, $name );
[665] Fix | Delete
[666] Fix | Delete
if ( $old_method_exists && ! $is_deprecated ) {
[667] Fix | Delete
// Inaccessible method (protected or private) that isn't deprecated
[668] Fix | Delete
et_debug( "{$message} Attempted to call {$class}::{$name}() from out of scope.", 4, false );
[669] Fix | Delete
return $value;
[670] Fix | Delete
}
[671] Fix | Delete
[672] Fix | Delete
$message .= " {$class}::{$name}()";
[673] Fix | Delete
[674] Fix | Delete
if ( ! $is_deprecated ) {
[675] Fix | Delete
$message .= " doesn't exist.";
[676] Fix | Delete
} else {
[677] Fix | Delete
$message .= " is deprecated.";
[678] Fix | Delete
$new_method = self::$_deprecations['methods'][ $name ];
[679] Fix | Delete
[680] Fix | Delete
if ( ! is_string( $new_method ) ) {
[681] Fix | Delete
// Default value for a method that has no replacement.
[682] Fix | Delete
$value = $new_method;
[683] Fix | Delete
[684] Fix | Delete
} else if ( method_exists( $this, $new_method ) && ! $old_method_exists ) {
[685] Fix | Delete
$message .= " Use {$class}::{$new_method}() instead.";
[686] Fix | Delete
// @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
[687] Fix | Delete
$value = call_user_func_array( array( $this, $new_method ), $args );
[688] Fix | Delete
[689] Fix | Delete
} else if ( $old_method_exists && function_exists( $new_method ) ) {
[690] Fix | Delete
// New method is a function
[691] Fix | Delete
$message .= " Use {$new_method}() instead.";
[692] Fix | Delete
// @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
[693] Fix | Delete
$value = call_user_func_array( $new_method, $args );
[694] Fix | Delete
[695] Fix | Delete
} else if ( $old_method_exists ) {
[696] Fix | Delete
// Ensure that our current caller is not the same as the method we're about to call.
[697] Fix | Delete
// as that would cause an infinite recursion situation. It happens when a child class
[698] Fix | Delete
// method which has been deprecated calls itself on the parent class (using parent::)
[699] Fix | Delete
// This also happens when we use $this->__call() to call a deprecated method from its
[700] Fix | Delete
// replacement method so that a deprecation notice will be output.
[701] Fix | Delete
$trace = debug_backtrace();
[702] Fix | Delete
$callers = array(
[703] Fix | Delete
self::$_->array_get( $trace, '1.function' ),
[704] Fix | Delete
self::$_->array_get( $trace, '2.function' ),
[705] Fix | Delete
);
[706] Fix | Delete
[707] Fix | Delete
if ( ! in_array( $name, $callers ) ) {
[708] Fix | Delete
$message .= " Use {$class}::{$new_method}() instead.";
[709] Fix | Delete
// @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
[710] Fix | Delete
$value = call_user_func_array( array( $this, $name ), $args );
[711] Fix | Delete
}
[712] Fix | Delete
}
[713] Fix | Delete
}
[714] Fix | Delete
[715] Fix | Delete
et_debug( $message, 4, false );
[716] Fix | Delete
[717] Fix | Delete
return $value;
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
public function &__get( $name ) {
[721] Fix | Delete
$class = get_class( $this );
[722] Fix | Delete
$message = "You're Doing It Wrong!";
[723] Fix | Delete
$is_deprecated = array_key_exists( $name, self::$_deprecations['properties'] );
[724] Fix | Delete
$value = null;
[725] Fix | Delete
[726] Fix | Delete
if ( property_exists( $this, $name ) && ! $is_deprecated ) {
[727] Fix | Delete
// Inaccessible property (protected or private) that isn't deprecated
[728] Fix | Delete
et_debug( "{$message} Attempted to access {$class}::\${$name} from out of scope.", 4, false );
[729] Fix | Delete
return $value;
[730] Fix | Delete
}
[731] Fix | Delete
[732] Fix | Delete
$message .= " {$class}::\${$name}";
[733] Fix | Delete
[734] Fix | Delete
if ( ! $is_deprecated ) {
[735] Fix | Delete
$message .= " doesn't exist.";
[736] Fix | Delete
$should_set_value = true;
[737] Fix | Delete
} else {
[738] Fix | Delete
$message .= " is deprecated.";
[739] Fix | Delete
$new_prop = self::$_deprecations['properties'][ $name ];
[740] Fix | Delete
[741] Fix | Delete
if ( $new_prop && is_string( $new_prop ) && property_exists( $this, $new_prop ) ) {
[742] Fix | Delete
$message .= " Use {$class}::\${$new_prop} instead.";
[743] Fix | Delete
$value = &$this->$new_prop;
[744] Fix | Delete
} else if ( ! is_string( $new_prop ) || ! $new_prop ) {
[745] Fix | Delete
// Default value
[746] Fix | Delete
$value = $new_prop;
[747] Fix | Delete
$should_set_value = true;
[748] Fix | Delete
}
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
if ( isset( $should_set_value ) ) {
[752] Fix | Delete
// Create the property so we can return a reference to it which allows it to be
[753] Fix | Delete
// used like this: $this->name[] = 'something'
[754] Fix | Delete
$this->$name = $value;
[755] Fix | Delete
$value = &$this->$name;
[756] Fix | Delete
}
[757] Fix | Delete
[758] Fix | Delete
et_debug( $message, 4, false );
[759] Fix | Delete
[760] Fix | Delete
return $value;
[761] Fix | Delete
}
[762] Fix | Delete
[763] Fix | Delete
public function __isset( $name ) {
[764] Fix | Delete
$prop_name = array_key_exists( $name, self::$_deprecations['properties'] ) ? self::$_deprecations['properties'][ $name ] : $name;
[765] Fix | Delete
[766] Fix | Delete
if ( ! $prop_name || ! is_string( $prop_name ) ) {
[767] Fix | Delete
return false;
[768] Fix | Delete
}
[769] Fix | Delete
[770] Fix | Delete
return property_exists( $this, $prop_name );
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
public function __set( $name, $value ) {
[774] Fix | Delete
$class = get_class( $this );
[775] Fix | Delete
$message = "You're Doing It Wrong!";
[776] Fix | Delete
$is_deprecated = array_key_exists( $name, self::$_deprecations['properties'] );
[777] Fix | Delete
$property_exists = property_exists( $this, $name );
[778] Fix | Delete
$has_replacement = $property_exists && is_string( self::$_deprecations['properties'][ $name ] ) && self::$_deprecations['properties'][ $name ];
[779] Fix | Delete
[780] Fix | Delete
if ( $property_exists && ! $is_deprecated ) {
[781] Fix | Delete
// Inaccessible property (protected or private) that isn't deprecated
[782] Fix | Delete
et_debug( "{$message} Attempted to access {$class}::\${$name} from out of scope.", 4, false );
[783] Fix | Delete
return;
[784] Fix | Delete
}
[785] Fix | Delete
[786] Fix | Delete
if ( ( ! $property_exists && ! $is_deprecated ) || ! $has_replacement ) {
[787] Fix | Delete
// Always allow setting values for properties that are undeclared
[788] Fix | Delete
$this->$name = $value;
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
if ( ! $is_deprecated ) {
[792] Fix | Delete
return;
[793] Fix | Delete
}
[794] Fix | Delete
[795] Fix | Delete
$message = " {$class}::\${$name} is deprecated.";
[796] Fix | Delete
$replacement = self::$_deprecations['properties'][ $name ];
[797] Fix | Delete
[798] Fix | Delete
if ( $replacement && is_string( $replacement ) ) {
[799] Fix | Delete
$message .= " Use {$class}::\${$replacement} instead.";
[800] Fix | Delete
[801] Fix | Delete
$this->$replacement = $value;
[802] Fix | Delete
[803] Fix | Delete
// Unset deprecated property so next time it's updated we process it again
[804] Fix | Delete
unset( $this->$name );
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
et_debug( $message, 4, false );
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
private static function _is_official_module( $class_name ) {
[811] Fix | Delete
try {
[812] Fix | Delete
$reflection = new ReflectionClass( $class_name );
[813] Fix | Delete
$is_official = self::$_->includes( $reflection->getFileName(), ET_BUILDER_DIR_RESOLVED_PATH );
[814] Fix | Delete
} catch( Exception $err ) {
[815] Fix | Delete
$is_official = false;
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
return $is_official;
[819] Fix | Delete
}
[820] Fix | Delete
[821] Fix | Delete
private static function _is_woocommerce_module( $class_name ) {
[822] Fix | Delete
try {
[823] Fix | Delete
$reflection = new ReflectionClass( $class_name );
[824] Fix | Delete
$is_woocommerce = self::$_->includes( $reflection->getFileName(), ET_BUILDER_DIR_RESOLVED_PATH . '/module/woocommerce' );
[825] Fix | Delete
} catch( Exception $err ) {
[826] Fix | Delete
$is_woocommerce = false;
[827] Fix | Delete
}
[828] Fix | Delete
[829] Fix | Delete
return $is_woocommerce;
[830] Fix | Delete
}
[831] Fix | Delete
[832] Fix | Delete
protected function _set_advanced_fields_config() {
[833] Fix | Delete
$this->advanced_fields = $this->get_advanced_fields_config();
[834] Fix | Delete
[835] Fix | Delete
// 3rd-Party Backwards Compatability
[836] Fix | Delete
if ( isset( $this->advanced_fields['custom_margin_padding'] ) ) {
[837] Fix | Delete
$this->advanced_fields['margin_padding'] = $this->advanced_fields['custom_margin_padding'];
[838] Fix | Delete
[839] Fix | Delete
unset( $this->advanced_fields['custom_margin_padding'] );
[840] Fix | Delete
}
[841] Fix | Delete
}
[842] Fix | Delete
[843] Fix | Delete
/**
[844] Fix | Delete
* Get whether third party post interference should be respected.
[845] Fix | Delete
* Current use case is for plugins like Toolset that render a
[846] Fix | Delete
* loop within a layout which renders another layout for
[847] Fix | Delete
* each post - in this case we must NOT override the
[848] Fix | Delete
* current post so the loop works as expected.
[849] Fix | Delete
*
[850] Fix | Delete
* @since 4.0.6
[851] Fix | Delete
*
[852] Fix | Delete
* @return boolean
[853] Fix | Delete
*/
[854] Fix | Delete
protected static function _should_respect_post_interference() {
[855] Fix | Delete
$post = ET_Post_Stack::get();
[856] Fix | Delete
[857] Fix | Delete
return null !== $post && get_the_ID() !== $post->ID;
[858] Fix | Delete
}
[859] Fix | Delete
[860] Fix | Delete
/**
[861] Fix | Delete
* Retrieve the main query post id.
[862] Fix | Delete
* Accounts for third party interference with the current post.
[863] Fix | Delete
*
[864] Fix | Delete
* @since 4.0.6
[865] Fix | Delete
*
[866] Fix | Delete
* @return integer|boolean
[867] Fix | Delete
*/
[868] Fix | Delete
protected static function _get_main_post_id() {
[869] Fix | Delete
if ( self::_should_respect_post_interference() ) {
[870] Fix | Delete
return get_the_ID();
[871] Fix | Delete
}
[872] Fix | Delete
[873] Fix | Delete
return ET_Post_Stack::get_main_post_id();
[874] Fix | Delete
}
[875] Fix | Delete
[876] Fix | Delete
/**
[877] Fix | Delete
* Retrieve Post ID from 1 of 4 sources depending on which exists:
[878] Fix | Delete
* - $_POST['current_page']['id']
[879] Fix | Delete
* - $_POST['et_post_id']
[880] Fix | Delete
* - $_GET['post']
[881] Fix | Delete
* - get_the_ID()
[882] Fix | Delete
*
[883] Fix | Delete
* @since 3.17.2
[884] Fix | Delete
*
[885] Fix | Delete
* @return int|bool
[886] Fix | Delete
*/
[887] Fix | Delete
public static function get_current_post_id() {
[888] Fix | Delete
// Getting correct post id in computed_callback request.
[889] Fix | Delete
if ( wp_doing_ajax() && $post_id = self::$_->array_get( $_POST, 'current_page.id' ) ) {
[890] Fix | Delete
return absint( $post_id );
[891] Fix | Delete
}
[892] Fix | Delete
[893] Fix | Delete
if ( wp_doing_ajax() && isset( $_POST['et_post_id'] ) ) {
[894] Fix | Delete
return absint( $_POST['et_post_id'] );
[895] Fix | Delete
}
[896] Fix | Delete
[897] Fix | Delete
if ( isset( $_POST['post'] ) ) {
[898] Fix | Delete
return absint( $_POST['post'] );
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
return self::_get_main_post_id();
[902] Fix | Delete
}
[903] Fix | Delete
[904] Fix | Delete
/**
[905] Fix | Delete
* Retrieve Post ID from 1 of 3 sources depending on which exists:
[906] Fix | Delete
* - get_the_ID()
[907] Fix | Delete
* - $_GET['post']
[908] Fix | Delete
* - $_POST['et_post_id']
[909] Fix | Delete
*
[910] Fix | Delete
* @since 4.0
[911] Fix | Delete
*
[912] Fix | Delete
* @return int|bool
[913] Fix | Delete
*/
[914] Fix | Delete
public static function get_current_post_id_reverse() {
[915] Fix | Delete
$post_id = self::_get_main_post_id();
[916] Fix | Delete
[917] Fix | Delete
// try to get post id from get_post_ID()
[918] Fix | Delete
if ( false !== $post_id ) {
[919] Fix | Delete
return $post_id;
[920] Fix | Delete
}
[921] Fix | Delete
[922] Fix | Delete
if ( wp_doing_ajax() ) {
[923] Fix | Delete
// get the post ID if loading data for VB
[924] Fix | Delete
return isset( $_POST['et_post_id'] ) ? absint( $_POST['et_post_id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
[925] Fix | Delete
}
[926] Fix | Delete
[927] Fix | Delete
// fallback to $_GET['post'] to cover the BB data loading
[928] Fix | Delete
return isset( $_GET['post'] ) ? absint( $_GET['post'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
[929] Fix | Delete
}
[930] Fix | Delete
[931] Fix | Delete
/**
[932] Fix | Delete
* Get the current ID depending on the current request.
[933] Fix | Delete
*
[934] Fix | Delete
* @since 4.0
[935] Fix | Delete
*
[936] Fix | Delete
* @return int|bool
[937] Fix | Delete
*/
[938] Fix | Delete
public function get_the_ID() {
[939] Fix | Delete
return self::get_current_post_id_reverse();
[940] Fix | Delete
}
[941] Fix | Delete
[942] Fix | Delete
/**
[943] Fix | Delete
* Setup the advanced styles manager
[944] Fix | Delete
*
[945] Fix | Delete
* @since 4.0 Made public.
[946] Fix | Delete
*
[947] Fix | Delete
* {@internal
[948] Fix | Delete
* Before the styles manager was implemented, the advanced styles were output inline in the footer.
[949] Fix | Delete
* That resulted in them being the last styles parsed by the browser, thus giving them higher
[950] Fix | Delete
* priority than other styles on the page. With the styles manager, the advanced styles are
[951] Fix | Delete
* enqueued at the very end of the <head>. This is for backwards compatibility (to maintain
[952] Fix | Delete
* the same priority for the styles as before).}}
[953] Fix | Delete
*/
[954] Fix | Delete
public static function setup_advanced_styles_manager( $post_id = 0 ) {
[955] Fix | Delete
if ( 0 === $post_id && et_core_page_resource_is_singular() ) {
[956] Fix | Delete
// It doesn't matter if post id is 0 because we're going to force inline styles.
[957] Fix | Delete
$post_id = et_core_page_resource_get_the_ID();
[958] Fix | Delete
} else {
[959] Fix | Delete
$queried_object = get_queried_object();
[960] Fix | Delete
if ( is_object( $queried_object ) && property_exists( $queried_object , 'term_id' ) ) {
[961] Fix | Delete
$term_id = $queried_object->term_id;
[962] Fix | Delete
$post_id = ! empty( $term_id ) ? $term_id : $post_id;
[963] Fix | Delete
}
[964] Fix | Delete
}
[965] Fix | Delete
[966] Fix | Delete
$is_preview = is_preview() || is_et_pb_preview();
[967] Fix | Delete
$forced_in_footer = $post_id && et_builder_setting_is_on( 'et_pb_css_in_footer', $post_id );
[968] Fix | Delete
$forced_inline = ! $post_id || $is_preview || $forced_in_footer || et_builder_setting_is_off( 'et_pb_static_css_file', $post_id ) || et_core_is_safe_mode_active() || ET_GB_Block_Layout::is_layout_block_preview();
[969] Fix | Delete
$unified_styles = ! $forced_inline && ! $forced_in_footer;
[970] Fix | Delete
[971] Fix | Delete
$resource_owner = $unified_styles ? 'core' : 'builder';
[972] Fix | Delete
$resource_slug = $unified_styles ? 'unified' : 'module-design';
[973] Fix | Delete
$resource_slug .= ! empty( $term_id ) ? '-term' : '';
[974] Fix | Delete
$resource_slug .= empty( $term_id ) && $unified_styles && et_builder_post_is_of_custom_post_type( $post_id ) ? '-cpt' : '';
[975] Fix | Delete
$resource_slug = et_theme_builder_decorate_page_resource_slug( $post_id, $resource_slug );
[976] Fix | Delete
[977] Fix | Delete
// If the post is password protected and a password has not been provided yet,
[978] Fix | Delete
// no content (including any custom style) will be printed.
[979] Fix | Delete
// When static css file option is enabled this will result in missing styles.
[980] Fix | Delete
if ( ! $forced_inline && post_password_required( $post_id ? $post_id : null ) ) {
[981] Fix | Delete
$forced_inline = true;
[982] Fix | Delete
}
[983] Fix | Delete
[984] Fix | Delete
if ( $is_preview ) {
[985] Fix | Delete
// Don't let previews cause existing saved static css files to be modified.
[986] Fix | Delete
$resource_slug .= '-preview';
[987] Fix | Delete
}
[988] Fix | Delete
[989] Fix | Delete
$manager = et_core_page_resource_get( $resource_owner, $resource_slug, $post_id, 40 );
[990] Fix | Delete
[991] Fix | Delete
if ( ! $forced_inline && ! $forced_in_footer && $manager->has_file() ) {
[992] Fix | Delete
// This post currently has a fully configured styles manager.
[993] Fix | Delete
return array(
[994] Fix | Delete
'manager' => $manager,
[995] Fix | Delete
'add_hooks' => false,
[996] Fix | Delete
);
[997] Fix | Delete
}
[998] Fix | Delete
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function