Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: framework.php
// Safe checks bellow
[500] Fix | Delete
if ( empty( $element_data['class'] ) ) {
[501] Fix | Delete
return;
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
// Prevent duplication link options data entries created by global modules
[505] Fix | Delete
if ( in_array( $element_data['class'], $data_classes ) ) {
[506] Fix | Delete
return;
[507] Fix | Delete
}
[508] Fix | Delete
[509] Fix | Delete
$data[] = $element_data;
[510] Fix | Delete
$data_classes[] = $element_data['class'];
[511] Fix | Delete
}
[512] Fix | Delete
[513] Fix | Delete
/**
[514] Fix | Delete
* Get list of concatenated & minified script and their possible alternative name
[515] Fix | Delete
*
[516] Fix | Delete
* @return array
[517] Fix | Delete
*/
[518] Fix | Delete
function et_builder_get_minified_scripts() {
[519] Fix | Delete
$minified_scripts = array(
[520] Fix | Delete
'et-shortcodes-js',
[521] Fix | Delete
'divi-fitvids',
[522] Fix | Delete
'fitvids', // possible alternative name
[523] Fix | Delete
'jquery-fitvids', // possible alternative name
[524] Fix | Delete
'waypoints',
[525] Fix | Delete
'jquery-waypoints', // possible alternative name
[526] Fix | Delete
'magnific-popup',
[527] Fix | Delete
'jquery-magnific-popup', // possible alternative name
[528] Fix | Delete
'hashchange',
[529] Fix | Delete
'jquery-hashchange', // possible alternative name
[530] Fix | Delete
'salvattore',
[531] Fix | Delete
'easypiechart',
[532] Fix | Delete
'jquery-easypiechart', // possible alternative name
[533] Fix | Delete
'et-builder-modules-global-functions-script',
[534] Fix | Delete
'et-jquery-touch-mobile',
[535] Fix | Delete
'et-builder-modules-script',
[536] Fix | Delete
);
[537] Fix | Delete
[538] Fix | Delete
return apply_filters( 'et_builder_get_minified_scripts', $minified_scripts );
[539] Fix | Delete
}
[540] Fix | Delete
[541] Fix | Delete
/**
[542] Fix | Delete
* Get list of concatenated & minified styles (sans style.css)
[543] Fix | Delete
*
[544] Fix | Delete
* @return array
[545] Fix | Delete
*/
[546] Fix | Delete
function et_builder_get_minified_styles() {
[547] Fix | Delete
$minified_styles = array(
[548] Fix | Delete
'et-shortcodes-css',
[549] Fix | Delete
'et-shortcodes-responsive-css',
[550] Fix | Delete
'et-animations',
[551] Fix | Delete
'magnific-popup',
[552] Fix | Delete
);
[553] Fix | Delete
[554] Fix | Delete
return apply_filters( 'et_builder_get_minified_styles', $minified_styles );
[555] Fix | Delete
}
[556] Fix | Delete
[557] Fix | Delete
/**
[558] Fix | Delete
* Re-enqueue listed concatenated & minified scripts (and their possible alternative name) used empty string
[559] Fix | Delete
* to keep its dependency in order but avoiding WordPress to print the script to avoid the same file printed twice
[560] Fix | Delete
* Case in point: salvattore that is being called via builder module's render() method
[561] Fix | Delete
*
[562] Fix | Delete
* @return void
[563] Fix | Delete
*/
[564] Fix | Delete
function et_builder_dequeue_minified_scripts() {
[565] Fix | Delete
if ( ! et_load_unminified_scripts() && ! is_admin() ) {
[566] Fix | Delete
[567] Fix | Delete
/**
[568] Fix | Delete
* Builder script handle name
[569] Fix | Delete
*
[570] Fix | Delete
* @since 3.??
[571] Fix | Delete
*
[572] Fix | Delete
* @param string
[573] Fix | Delete
*/
[574] Fix | Delete
$builder_script_handle = apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' );
[575] Fix | Delete
[576] Fix | Delete
foreach ( et_builder_get_minified_scripts() as $script ) {
[577] Fix | Delete
// Get script's localized data before the script is dequeued
[578] Fix | Delete
$script_data = wp_scripts()->get_data( $script, 'data' );
[579] Fix | Delete
[580] Fix | Delete
// If to-be dequeued script has localized data, get builder script's data and concatenated both to ensure compatibility
[581] Fix | Delete
// Concatenating is needed because script's localize data is saved as string (encoded array concatenated into variable name)
[582] Fix | Delete
if ( $script_data && '' !== trim( $script_data ) ) {
[583] Fix | Delete
[584] Fix | Delete
// If builder script handle localized data returns false/empty, $script_data still need to be added
[585] Fix | Delete
$concatenated_scripts_data = implode(
[586] Fix | Delete
' ',
[587] Fix | Delete
array_filter(
[588] Fix | Delete
array(
[589] Fix | Delete
wp_scripts()->get_data( $builder_script_handle, 'data' ),
[590] Fix | Delete
$script_data,
[591] Fix | Delete
)
[592] Fix | Delete
)
[593] Fix | Delete
);
[594] Fix | Delete
[595] Fix | Delete
// Add concatenated localized data to builder script handle
[596] Fix | Delete
wp_scripts()->add_data( $builder_script_handle, 'data', $concatenated_scripts_data );
[597] Fix | Delete
}
[598] Fix | Delete
[599] Fix | Delete
// If dequeued script has inline script, get it then re-add it to builder script handle using appropriate position
[600] Fix | Delete
$inline_script_positions = array( 'before', 'after' );
[601] Fix | Delete
foreach ( $inline_script_positions as $inline_script_position ) {
[602] Fix | Delete
$inline_script = wp_scripts()->get_data( $script, $inline_script_position );
[603] Fix | Delete
[604] Fix | Delete
// Inline script is saved as array. add_inline_script() method will handle it appending process
[605] Fix | Delete
if ( is_array( $inline_script ) && ! empty( $inline_script ) ) {
[606] Fix | Delete
wp_scripts()->add_inline_script( $builder_script_handle, implode( ' ', $inline_script ), $inline_script_position );
[607] Fix | Delete
}
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
wp_dequeue_script( $script );
[611] Fix | Delete
wp_deregister_script( $script );
[612] Fix | Delete
wp_register_script( $script, '', array(), ET_BUILDER_VERSION, true );
[613] Fix | Delete
}
[614] Fix | Delete
}
[615] Fix | Delete
}
[616] Fix | Delete
add_action( 'wp_print_scripts', 'et_builder_dequeue_minified_scripts', 99999999 ); // <head>
[617] Fix | Delete
add_action( 'wp_print_footer_scripts', 'et_builder_dequeue_minified_scripts', 9 ); // <footer>
[618] Fix | Delete
[619] Fix | Delete
function et_builder_dequeue_minifieds_styles() {
[620] Fix | Delete
if ( ! et_load_unminified_styles() && ! is_admin() ) {
[621] Fix | Delete
// Get builder minified + combined style handle
[622] Fix | Delete
$builder_optimized_style_name = apply_filters( 'et_builder_optimized_style_handle', '' );
[623] Fix | Delete
[624] Fix | Delete
foreach ( et_builder_get_minified_styles() as $style ) {
[625] Fix | Delete
// If dequeued style has inline style, get it then re-add it to minified + combiled style handle
[626] Fix | Delete
// Inline style only has 'after' position
[627] Fix | Delete
$inline_style = wp_styles()->get_data( $style, 'after' );
[628] Fix | Delete
[629] Fix | Delete
// Inline style is saved as array. add_inline_style() method will handle it appending process
[630] Fix | Delete
if ( is_array( $inline_style ) && ! empty( $inline_style ) ) {
[631] Fix | Delete
wp_styles()->add_inline_style( $builder_optimized_style_name, implode( ' ', $inline_style ), 'after' );
[632] Fix | Delete
}
[633] Fix | Delete
[634] Fix | Delete
wp_dequeue_style( $style );
[635] Fix | Delete
wp_deregister_style( $style );
[636] Fix | Delete
wp_register_style( $style, '', array(), ET_BUILDER_VERSION );
[637] Fix | Delete
}
[638] Fix | Delete
} else {
[639] Fix | Delete
// Child theme might manually enqueues parent themes' style.css. When combine + minify CSS file is enabled, this isn't an issue.
[640] Fix | Delete
// However, when combine + minify CSS is disabled, child theme should load style.dev.css (source) instead of style.css (minified).
[641] Fix | Delete
// Child theme might not considering this, which causes minified file + other source files are printed. To fix it, deregister any
[642] Fix | Delete
// style handle that contains parent theme's style.css URL, then re-queue new one with the same name handle + URL to parent theme's style.dev.css
[643] Fix | Delete
// This should be done in theme only. Divi-Builder plugin doesn't need this.
[644] Fix | Delete
if ( ! et_is_builder_plugin_active() && is_child_theme() ) {
[645] Fix | Delete
$template_directory_uri = preg_quote( get_template_directory_uri(), '/' );
[646] Fix | Delete
$optimized_style_src = '/^(' . $template_directory_uri . '\/style)(-cpt)?(\.css)$/';
[647] Fix | Delete
$unoptimized_style_src = '$1$2.dev$3';
[648] Fix | Delete
[649] Fix | Delete
et_core_replace_enqueued_style( $optimized_style_src, $unoptimized_style_src, true );
[650] Fix | Delete
}
[651] Fix | Delete
}
[652] Fix | Delete
}
[653] Fix | Delete
add_action( 'wp_print_styles', 'et_builder_dequeue_minifieds_styles', 99999999 ); // <head>
[654] Fix | Delete
[655] Fix | Delete
/**
[656] Fix | Delete
* Determine whether current theme supports Waypoints or not
[657] Fix | Delete
*
[658] Fix | Delete
* @return bool
[659] Fix | Delete
*/
[660] Fix | Delete
function et_is_ignore_waypoints() {
[661] Fix | Delete
// WPBakery Visual Composer plugin conflicts with waypoints
[662] Fix | Delete
if ( class_exists( 'Vc_Manager' ) ) {
[663] Fix | Delete
return true;
[664] Fix | Delete
}
[665] Fix | Delete
[666] Fix | Delete
// always return false if not in divi plugin
[667] Fix | Delete
if ( ! et_is_builder_plugin_active() ) {
[668] Fix | Delete
return false;
[669] Fix | Delete
}
[670] Fix | Delete
[671] Fix | Delete
$theme_data = wp_get_theme();
[672] Fix | Delete
[673] Fix | Delete
if ( empty( $theme_data ) ) {
[674] Fix | Delete
return false;
[675] Fix | Delete
}
[676] Fix | Delete
[677] Fix | Delete
// list of themes without Waypoints support
[678] Fix | Delete
$no_waypoints_themes = array(
[679] Fix | Delete
'Avada',
[680] Fix | Delete
);
[681] Fix | Delete
$no_waypoints_themes = apply_filters( 'et_pb_no_waypoints_themes', $no_waypoints_themes );
[682] Fix | Delete
[683] Fix | Delete
// return true if current theme doesn't support Waypoints
[684] Fix | Delete
if ( in_array( $theme_data->Name, $no_waypoints_themes, true ) ) {
[685] Fix | Delete
return true;
[686] Fix | Delete
}
[687] Fix | Delete
[688] Fix | Delete
return false;
[689] Fix | Delete
}
[690] Fix | Delete
[691] Fix | Delete
/**
[692] Fix | Delete
* Determine whether current page has enqueued theme's style.css or not
[693] Fix | Delete
* This is mainly used on preview screen to decide to enqueue theme's style nor not
[694] Fix | Delete
*
[695] Fix | Delete
* @return bool
[696] Fix | Delete
*/
[697] Fix | Delete
function et_builder_has_theme_style_enqueued() {
[698] Fix | Delete
global $wp_styles;
[699] Fix | Delete
[700] Fix | Delete
if ( ! empty( $wp_styles->queue ) ) {
[701] Fix | Delete
$theme_style_uri = get_stylesheet_uri();
[702] Fix | Delete
[703] Fix | Delete
foreach ( $wp_styles->queue as $handle ) {
[704] Fix | Delete
if ( isset( $wp_styles->registered[ $handle ]->src ) && $theme_style_uri === $wp_styles->registered[ $handle ]->src ) {
[705] Fix | Delete
return true;
[706] Fix | Delete
}
[707] Fix | Delete
}
[708] Fix | Delete
}
[709] Fix | Delete
[710] Fix | Delete
return false;
[711] Fix | Delete
}
[712] Fix | Delete
[713] Fix | Delete
/**
[714] Fix | Delete
* Added specific body classes for builder related situation
[715] Fix | Delete
* This enables theme to adjust its case independently
[716] Fix | Delete
*
[717] Fix | Delete
* @return array
[718] Fix | Delete
*/
[719] Fix | Delete
function et_builder_body_classes( $classes ) {
[720] Fix | Delete
if ( is_et_pb_preview() ) {
[721] Fix | Delete
$classes[] = 'et-pb-preview';
[722] Fix | Delete
}
[723] Fix | Delete
[724] Fix | Delete
// Minified JS identifier class name
[725] Fix | Delete
if ( ! et_load_unminified_scripts() ) {
[726] Fix | Delete
$classes[] = 'et_minified_js';
[727] Fix | Delete
}
[728] Fix | Delete
[729] Fix | Delete
// Minified CSS identifier class name
[730] Fix | Delete
if ( ! et_load_unminified_styles() ) {
[731] Fix | Delete
$classes[] = 'et_minified_css';
[732] Fix | Delete
}
[733] Fix | Delete
[734] Fix | Delete
$post_id = et_core_page_resource_get_the_ID();
[735] Fix | Delete
$post_type = get_post_type( $post_id );
[736] Fix | Delete
[737] Fix | Delete
// Add layout classes when on library page
[738] Fix | Delete
if ( et_core_is_fb_enabled() && 'et_pb_layout' === $post_type ) {
[739] Fix | Delete
$layout_type = et_fb_get_layout_type( $post_id );
[740] Fix | Delete
$layout_scope = et_fb_get_layout_term_slug( $post_id, 'scope' );
[741] Fix | Delete
[742] Fix | Delete
$classes[] = "et_pb_library_page-${layout_type}";
[743] Fix | Delete
$classes[] = "et_pb_library_page-${layout_scope}";
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
return $classes;
[747] Fix | Delete
}
[748] Fix | Delete
add_filter( 'body_class', 'et_builder_body_classes' );
[749] Fix | Delete
[750] Fix | Delete
if ( ! function_exists( 'et_builder_add_main_elements' ) ) :
[751] Fix | Delete
function et_builder_add_main_elements() {
[752] Fix | Delete
if ( ET_BUILDER_CACHE_MODULES ) {
[753] Fix | Delete
ET_Builder_Element::init_cache();
[754] Fix | Delete
}
[755] Fix | Delete
require_once ET_BUILDER_DIR . 'main-structure-elements.php';
[756] Fix | Delete
require_once ET_BUILDER_DIR . 'main-modules.php';
[757] Fix | Delete
do_action( 'et_builder_ready' );
[758] Fix | Delete
}
[759] Fix | Delete
endif;
[760] Fix | Delete
[761] Fix | Delete
if ( ! function_exists( 'et_builder_load_framework' ) ) :
[762] Fix | Delete
function et_builder_load_framework() {
[763] Fix | Delete
[764] Fix | Delete
require_once ET_BUILDER_DIR . 'functions.php';
[765] Fix | Delete
require_once ET_BUILDER_DIR . 'compat/woocommerce.php';
[766] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-global-settings.php';
[767] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/BlockEditorIntegration.php';
[768] Fix | Delete
[769] Fix | Delete
if ( is_admin() ) {
[770] Fix | Delete
global $pagenow, $et_current_memory_limit;
[771] Fix | Delete
[772] Fix | Delete
if ( ! empty( $pagenow ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
[773] Fix | Delete
$et_current_memory_limit = et_core_get_memory_limit();
[774] Fix | Delete
}
[775] Fix | Delete
}
[776] Fix | Delete
[777] Fix | Delete
/**
[778] Fix | Delete
* Filters builder modules loading hook. Load builder files on front-end and on specific admin pages only by default.
[779] Fix | Delete
*
[780] Fix | Delete
* @since 3.1
[781] Fix | Delete
*
[782] Fix | Delete
* @param string Hook name.
[783] Fix | Delete
*/
[784] Fix | Delete
$action_hook = apply_filters( 'et_builder_modules_load_hook', is_admin() ? 'wp_loaded' : 'wp' );
[785] Fix | Delete
[786] Fix | Delete
if ( et_builder_should_load_framework() ) {
[787] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-value.php';
[788] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-element.php';
[789] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-plugin-compat-base.php';
[790] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-plugin-compat-loader.php';
[791] Fix | Delete
require_once ET_BUILDER_DIR . 'ab-testing.php';
[792] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-settings.php';
[793] Fix | Delete
[794] Fix | Delete
$builder_settings_loaded = true;
[795] Fix | Delete
[796] Fix | Delete
do_action( 'et_builder_framework_loaded' );
[797] Fix | Delete
[798] Fix | Delete
add_action( $action_hook, 'et_builder_init_global_settings', apply_filters( 'et_pb_load_global_settings_priority', 9 ) );
[799] Fix | Delete
add_action( $action_hook, 'et_builder_add_main_elements', apply_filters( 'et_pb_load_main_elements_priority', 10 ) );
[800] Fix | Delete
} elseif ( is_admin() ) {
[801] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-plugin-compat-base.php';
[802] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-plugin-compat-loader.php';
[803] Fix | Delete
require_once ET_BUILDER_DIR . 'class-et-builder-settings.php';
[804] Fix | Delete
$builder_settings_loaded = true;
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
if ( isset( $builder_settings_loaded ) ) {
[808] Fix | Delete
add_action( 'init', 'et_builder_settings_init', 100 );
[809] Fix | Delete
}
[810] Fix | Delete
[811] Fix | Delete
add_action( $action_hook, 'et_builder_load_frontend_builder' );
[812] Fix | Delete
[813] Fix | Delete
if ( isset( $_GET['et_bfb'] ) && is_user_logged_in() ) {
[814] Fix | Delete
add_filter( 'wpe_heartbeat_allowed_pages', 'et_bfb_wpe_heartbeat_allowed_pages' );
[815] Fix | Delete
}
[816] Fix | Delete
}
[817] Fix | Delete
endif;
[818] Fix | Delete
[819] Fix | Delete
/**
[820] Fix | Delete
* Checking whether current page is BFB page based on its query string only; Suitable for basic
[821] Fix | Delete
* early check BEFORE $wp_query global is generated in case builder need to alter query
[822] Fix | Delete
* configuration. This is needed because BFB layout is basically loaded in front-end
[823] Fix | Delete
*
[824] Fix | Delete
* @since 3.19.9
[825] Fix | Delete
*
[826] Fix | Delete
* @return bool
[827] Fix | Delete
*/
[828] Fix | Delete
function et_bfb_maybe_bfb_url() {
[829] Fix | Delete
$has_bfb_query_string = ! empty( $_GET['et_fb'] ) && ! empty( $_GET['et_bfb'] );
[830] Fix | Delete
$has_vb_permission = et_pb_is_allowed( 'use_visual_builder' );
[831] Fix | Delete
[832] Fix | Delete
// This check assumes that $wp_query isn't ready (to be used before query is parsed) so any
[833] Fix | Delete
// query based check such as is_single(), etc don't exist yet. Thus BFB URL might valid if:
[834] Fix | Delete
// 1. not admin page
[835] Fix | Delete
// 2. user has logged in
[836] Fix | Delete
// 3. has `et_fb` & `et_bfb` query string
[837] Fix | Delete
// 4. has visual builder permission
[838] Fix | Delete
return ! is_admin() && is_user_logged_in() && $has_bfb_query_string && $has_vb_permission;
[839] Fix | Delete
}
[840] Fix | Delete
[841] Fix | Delete
/**
[842] Fix | Delete
* Get verified query string value for et_bfb_make_post_type_queryable()
[843] Fix | Delete
*
[844] Fix | Delete
* @since 3.19.9
[845] Fix | Delete
*
[846] Fix | Delete
* @param string $param_name
[847] Fix | Delete
*
[848] Fix | Delete
* @return string|number|bool
[849] Fix | Delete
*/
[850] Fix | Delete
function et_bfb_get_make_queryable_param( $param_name ) {
[851] Fix | Delete
$param = isset( $_GET[ "et_{$param_name}" ] ) ? $_GET[ "et_{$param_name}" ] : false;
[852] Fix | Delete
$param_nonce = isset( $_GET[ "et_{$param_name}_nonce" ] ) ? $_GET[ "et_{$param_name}_nonce" ] : false;
[853] Fix | Delete
$verified_param = $param && $param_nonce && wp_verify_nonce(
[854] Fix | Delete
$param_nonce,
[855] Fix | Delete
"et_{$param_name}_{$param}"
[856] Fix | Delete
);
[857] Fix | Delete
[858] Fix | Delete
return $verified_param ? $param : false;
[859] Fix | Delete
}
[860] Fix | Delete
[861] Fix | Delete
/**
[862] Fix | Delete
* Set builder's registered post type's publicly_queryable property to true (if needed) so publicly
[863] Fix | Delete
* hidden post type can render BFB page on backend edit screen
[864] Fix | Delete
*
[865] Fix | Delete
* @see WP->parse_request() on how request is parsed
[866] Fix | Delete
*
[867] Fix | Delete
* @since 3.19.9
[868] Fix | Delete
*
[869] Fix | Delete
* @return void
[870] Fix | Delete
*/
[871] Fix | Delete
function et_bfb_make_post_type_queryable() {
[872] Fix | Delete
// Valid query isn't available at this point so builder will guess whether current request is
[873] Fix | Delete
// BFB based on available value; Stop if this might not be BFB url
[874] Fix | Delete
if ( ! et_bfb_maybe_bfb_url() ) {
[875] Fix | Delete
return;
[876] Fix | Delete
}
[877] Fix | Delete
[878] Fix | Delete
$get_post_id = absint( et_bfb_get_make_queryable_param( 'post_id' ) );
[879] Fix | Delete
$get_post_type = sanitize_text_field( et_bfb_get_make_queryable_param( 'post_type' ) );
[880] Fix | Delete
[881] Fix | Delete
// Stop if no valid post id / post type for make queryable found on query string
[882] Fix | Delete
if ( ! $get_post_id || ! $get_post_type ) {
[883] Fix | Delete
return;
[884] Fix | Delete
}
[885] Fix | Delete
[886] Fix | Delete
$post_type_object = get_post_type_object( $get_post_type );
[887] Fix | Delete
[888] Fix | Delete
// Stop if requested post type doesn't exist
[889] Fix | Delete
if ( is_null( $post_type_object ) ) {
[890] Fix | Delete
return;
[891] Fix | Delete
}
[892] Fix | Delete
[893] Fix | Delete
$unqueryable_post_type = et_builder_get_third_party_unqueryable_post_types();
[894] Fix | Delete
$is_post_type_unqueryable = in_array( $get_post_type, $unqueryable_post_type );
[895] Fix | Delete
[896] Fix | Delete
// CPT's version of edit_post is always available on cap->edit_post regardless CPT's meta_map_cap
[897] Fix | Delete
// or capability_type setting are set or not. If meta_map_cap is set to true, WordPress
[898] Fix | Delete
// automatically translates it into edit_post. Otherwise, CPT version of edit_post is sent as
[899] Fix | Delete
// it is and it is plugin / post type registrant's responsibility to add the capability to role
[900] Fix | Delete
// and map it into primitive capabilities on map_meta_cap()
[901] Fix | Delete
$capability = isset( $post_type_object->cap->edit_post ) ? $post_type_object->cap->edit_post : 'edit_post';
[902] Fix | Delete
$can_edit_this_post = current_user_can( $capability, $get_post_id );
[903] Fix | Delete
[904] Fix | Delete
// Flip publicly_queryable of current request so BFB layout page can be rendered.
[905] Fix | Delete
// Note: post_type existence have been verified on is_null( $post_type_object ) check above
[906] Fix | Delete
if ( $is_post_type_unqueryable && $can_edit_this_post ) {
[907] Fix | Delete
global $wp_post_types;
[908] Fix | Delete
[909] Fix | Delete
$wp_post_types[ $get_post_type ]->publicly_queryable = true;
[910] Fix | Delete
}
[911] Fix | Delete
}
[912] Fix | Delete
add_action( 'init', 'et_bfb_make_post_type_queryable' );
[913] Fix | Delete
[914] Fix | Delete
/**
[915] Fix | Delete
* Modify rewrite rule's redirect of current BFB request if its post type's `publicly_queryable`
[916] Fix | Delete
* is set to false and its `query_var` is NOT set to `false`. When this situation happens, current
[917] Fix | Delete
* BFB page cannot be rendered because rewrite rule's redirect value doesn't have `post_type`
[918] Fix | Delete
* param which makes page query gets incorrect page value
[919] Fix | Delete
*
[920] Fix | Delete
* @since 3.19.9
[921] Fix | Delete
*
[922] Fix | Delete
* @return void
[923] Fix | Delete
*/
[924] Fix | Delete
function et_bfb_make_cpt_rewrite_rule_queryable( $value ) {
[925] Fix | Delete
// Get verified make queryable post_type param from query string
[926] Fix | Delete
$unqueryable_post_type = et_bfb_get_make_queryable_param( 'post_type' );
[927] Fix | Delete
[928] Fix | Delete
// Make sure that value is array, current request might be BFB, and verified post_type from
[929] Fix | Delete
// query string exist. Note: need to use early return otherwise the rest need multiple stack
[930] Fix | Delete
// if/else condition
[931] Fix | Delete
if ( ! is_array( $value ) || ! et_bfb_maybe_bfb_url() || ! $unqueryable_post_type ) {
[932] Fix | Delete
return $value;
[933] Fix | Delete
}
[934] Fix | Delete
[935] Fix | Delete
$rewrite_regex = $unqueryable_post_type . '/([^/]+)(?:/([0-9]+))?/?$';
[936] Fix | Delete
$rewrite_redirect = isset( $value[ $rewrite_regex ] ) ? $value[ $rewrite_regex ] : false;
[937] Fix | Delete
$has_post_type_substr = $rewrite_redirect && strpos( $rewrite_redirect, '?post_type=' ) !== false;
[938] Fix | Delete
$post_type_object = get_post_type_object( $unqueryable_post_type );
[939] Fix | Delete
[940] Fix | Delete
// If current page's post type object `query_var` isn't falsey and no `post_type=` substring is
[941] Fix | Delete
// found on current page's post type rewrite rule redirect value, modify the rewrite rule
[942] Fix | Delete
// redirect value so it can picks up current post type when query is parsed
[943] Fix | Delete
if ( $post_type_object->query_var && ! $has_post_type_substr ) {
[944] Fix | Delete
$value[ $rewrite_regex ] = 'index.php?post_type=' . $unqueryable_post_type . '&name=$matches[1]&page=$matches[2]';
[945] Fix | Delete
}
[946] Fix | Delete
[947] Fix | Delete
return $value;
[948] Fix | Delete
}
[949] Fix | Delete
add_filter( 'option_rewrite_rules', 'et_bfb_make_cpt_rewrite_rule_queryable' );
[950] Fix | Delete
[951] Fix | Delete
if ( ! function_exists( 'et_bfb_wpe_heartbeat_allowed_pages' ) ) :
[952] Fix | Delete
function et_bfb_wpe_heartbeat_allowed_pages( $pages ) {
[953] Fix | Delete
global $pagenow;
[954] Fix | Delete
[955] Fix | Delete
$pages[] = $pagenow;
[956] Fix | Delete
[957] Fix | Delete
return $pages;
[958] Fix | Delete
}
[959] Fix | Delete
endif;
[960] Fix | Delete
[961] Fix | Delete
function et_builder_load_frontend_builder() {
[962] Fix | Delete
global $et_current_memory_limit;
[963] Fix | Delete
[964] Fix | Delete
$et_current_memory_limit = et_core_get_memory_limit();
[965] Fix | Delete
[966] Fix | Delete
if ( $et_current_memory_limit < 256 ) {
[967] Fix | Delete
@ini_set( 'memory_limit', '256M' );
[968] Fix | Delete
}
[969] Fix | Delete
[970] Fix | Delete
require_once ET_BUILDER_DIR . 'frontend-builder/init.php';
[971] Fix | Delete
}
[972] Fix | Delete
[973] Fix | Delete
if ( ! function_exists( 'et_pb_get_google_api_key' ) ) :
[974] Fix | Delete
function et_pb_get_google_api_key() {
[975] Fix | Delete
$google_api_option = get_option( 'et_google_api_settings' );
[976] Fix | Delete
$google_api_key = isset( $google_api_option['api_key'] ) ? $google_api_option['api_key'] : '';
[977] Fix | Delete
[978] Fix | Delete
return $google_api_key;
[979] Fix | Delete
}
[980] Fix | Delete
endif;
[981] Fix | Delete
[982] Fix | Delete
if ( ! function_exists( 'et_pb_enqueue_google_maps_script' ) ) :
[983] Fix | Delete
function et_pb_enqueue_google_maps_script() {
[984] Fix | Delete
$google_api_option = get_option( 'et_google_api_settings' );
[985] Fix | Delete
$google_maps_script_enqueue = ! $google_api_option || ! isset( $google_api_option['enqueue_google_maps_script'] ) || ( isset( $google_api_option['enqueue_google_maps_script'] ) && 'on' === $google_api_option['enqueue_google_maps_script'] ) ? true : false;
[986] Fix | Delete
[987] Fix | Delete
return apply_filters(
[988] Fix | Delete
'et_pb_enqueue_google_maps_script',
[989] Fix | Delete
$google_maps_script_enqueue
[990] Fix | Delete
);
[991] Fix | Delete
}
[992] Fix | Delete
endif;
[993] Fix | Delete
[994] Fix | Delete
/**
[995] Fix | Delete
* Add pseudo-action via the_content to hook filter/action at the end of main content
[996] Fix | Delete
*
[997] Fix | Delete
* @param string content string
[998] Fix | Delete
* @return string content string
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function