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: core.php
* @return boolean
[500] Fix | Delete
*/
[501] Fix | Delete
function et_builder_is_post_type_custom( $post_type ) {
[502] Fix | Delete
return $post_type && ( ! in_array( $post_type, et_builder_get_default_post_types() ) || et_theme_builder_is_layout_post_type( $post_type ) );
[503] Fix | Delete
}
[504] Fix | Delete
[505] Fix | Delete
/**
[506] Fix | Delete
* Check whether the supplied post is of a custom post type as far as the builder is concerned.
[507] Fix | Delete
* If no post id is supplied, checks whether the current page is the singular view of a custom post type.
[508] Fix | Delete
*
[509] Fix | Delete
* @since 3.10
[510] Fix | Delete
*
[511] Fix | Delete
* @param integer $post_id
[512] Fix | Delete
*
[513] Fix | Delete
* @return boolean
[514] Fix | Delete
*/
[515] Fix | Delete
function et_builder_post_is_of_custom_post_type( $post_id = 0 ) {
[516] Fix | Delete
$post_types = et_builder_get_default_post_types();
[517] Fix | Delete
[518] Fix | Delete
if ( $post_id === 0 ) {
[519] Fix | Delete
return is_singular() && ! in_array( get_post_type( get_the_ID() ), $post_types );
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
return et_builder_is_post_type_custom( get_post_type( $post_id ) );
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
/**
[526] Fix | Delete
* Check whether the current request is for a custom post type archive.
[527] Fix | Delete
*
[528] Fix | Delete
* @since 4.0.5
[529] Fix | Delete
*
[530] Fix | Delete
* @return boolean
[531] Fix | Delete
*/
[532] Fix | Delete
function et_builder_is_custom_post_type_archive() {
[533] Fix | Delete
// Use get_the_ID() explicitly so we decide based on the first post of an archive page.
[534] Fix | Delete
return is_archive() && et_builder_post_is_of_custom_post_type( get_the_ID() );
[535] Fix | Delete
}
[536] Fix | Delete
[537] Fix | Delete
/**
[538] Fix | Delete
* Get an array of post types the Divi Builder is enabled on.
[539] Fix | Delete
*
[540] Fix | Delete
* @since 3.10
[541] Fix | Delete
*
[542] Fix | Delete
* @return string[]
[543] Fix | Delete
*/
[544] Fix | Delete
function et_builder_get_enabled_builder_post_types() {
[545] Fix | Delete
$default = array_merge(
[546] Fix | Delete
et_builder_get_default_post_types(),
[547] Fix | Delete
et_builder_get_third_party_post_types()
[548] Fix | Delete
);
[549] Fix | Delete
[550] Fix | Delete
/**
[551] Fix | Delete
* Filter the array of enabled post type options.
[552] Fix | Delete
* Allows Divi/Extra/DBP to only supply their option value in order to reduce code duplication.
[553] Fix | Delete
*
[554] Fix | Delete
* Schema:
[555] Fix | Delete
* array(
[556] Fix | Delete
* 'post_type_name' => <'on' or 'off'>,
[557] Fix | Delete
* // ...
[558] Fix | Delete
* )
[559] Fix | Delete
*
[560] Fix | Delete
* @since 3.10
[561] Fix | Delete
*
[562] Fix | Delete
* @param string[] $options
[563] Fix | Delete
*
[564] Fix | Delete
* @return string[]
[565] Fix | Delete
*/
[566] Fix | Delete
$options = apply_filters( 'et_builder_enabled_builder_post_type_options', array() );
[567] Fix | Delete
[568] Fix | Delete
foreach ( $default as $post_type ) {
[569] Fix | Delete
if ( ! isset( $options[ $post_type ] ) ) {
[570] Fix | Delete
$options[ $post_type ] = 'on';
[571] Fix | Delete
}
[572] Fix | Delete
}
[573] Fix | Delete
[574] Fix | Delete
$filtered = array();
[575] Fix | Delete
[576] Fix | Delete
foreach ( $options as $post_type => $state ) {
[577] Fix | Delete
if ( 'on' === $state && array_key_exists( $post_type, et_get_registered_post_type_options() ) && ! in_array( $post_type, et_builder_get_blocklisted_post_types() ) ) {
[578] Fix | Delete
$filtered[] = $post_type;
[579] Fix | Delete
}
[580] Fix | Delete
}
[581] Fix | Delete
[582] Fix | Delete
return $filtered;
[583] Fix | Delete
}
[584] Fix | Delete
[585] Fix | Delete
function et_builder_get_builder_post_types() {
[586] Fix | Delete
/**
[587] Fix | Delete
* Array of post types which have the builder enabled.
[588] Fix | Delete
*
[589] Fix | Delete
* @since 3.10
[590] Fix | Delete
*
[591] Fix | Delete
* @param string[]
[592] Fix | Delete
*/
[593] Fix | Delete
return apply_filters( 'et_builder_post_types', et_builder_get_enabled_builder_post_types() );
[594] Fix | Delete
}
[595] Fix | Delete
[596] Fix | Delete
function et_builder_get_fb_post_types() {
[597] Fix | Delete
/**
[598] Fix | Delete
* Array of post types which have the frontend builder enabled.
[599] Fix | Delete
*
[600] Fix | Delete
* @since 3.10
[601] Fix | Delete
*
[602] Fix | Delete
* @param string[]
[603] Fix | Delete
*/
[604] Fix | Delete
return apply_filters( 'et_fb_post_types', et_builder_get_enabled_builder_post_types() );
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
/**
[608] Fix | Delete
* Check whether the specified post can have the builder enabled.
[609] Fix | Delete
*
[610] Fix | Delete
* @since 3.10
[611] Fix | Delete
*
[612] Fix | Delete
* @param integer $post_id
[613] Fix | Delete
*
[614] Fix | Delete
* @return boolean
[615] Fix | Delete
*/
[616] Fix | Delete
function et_builder_enabled_for_post( $post_id ) {
[617] Fix | Delete
if ( et_pb_is_pagebuilder_used( $post_id ) ) {
[618] Fix | Delete
return true;
[619] Fix | Delete
}
[620] Fix | Delete
[621] Fix | Delete
return et_builder_enabled_for_post_type( get_post_type( $post_id ) );
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
/**
[625] Fix | Delete
* Check whether the specified post type can have the builder enabled.
[626] Fix | Delete
*
[627] Fix | Delete
* @since 3.10
[628] Fix | Delete
*
[629] Fix | Delete
* @param string $post_type
[630] Fix | Delete
*
[631] Fix | Delete
* @return boolean
[632] Fix | Delete
*/
[633] Fix | Delete
function et_builder_enabled_for_post_type( $post_type ) {
[634] Fix | Delete
return in_array( $post_type, et_builder_get_builder_post_types() );
[635] Fix | Delete
}
[636] Fix | Delete
[637] Fix | Delete
/**
[638] Fix | Delete
* Check whether the specified post can have the FB enabled.
[639] Fix | Delete
*
[640] Fix | Delete
* @since 3.10
[641] Fix | Delete
*
[642] Fix | Delete
* @param string $post_type
[643] Fix | Delete
*
[644] Fix | Delete
* @return boolean
[645] Fix | Delete
*/
[646] Fix | Delete
function et_builder_fb_enabled_for_post( $post_id ) {
[647] Fix | Delete
$post_type = get_post_type( $post_id );
[648] Fix | Delete
$enabled = false;
[649] Fix | Delete
$pto = get_post_type_object( $post_type );
[650] Fix | Delete
$is_default_post_type = in_array( $post_type, et_builder_get_default_post_types() );
[651] Fix | Delete
$is_public_post_type = et_builder_is_post_type_public( $post_type );
[652] Fix | Delete
[653] Fix | Delete
if ( $pto && ( $is_default_post_type || $is_public_post_type ) ) {
[654] Fix | Delete
$enabled = et_builder_enabled_for_post( $post_id );
[655] Fix | Delete
}
[656] Fix | Delete
[657] Fix | Delete
/**
[658] Fix | Delete
* Filter whether the FB is enabled for a given post.
[659] Fix | Delete
*
[660] Fix | Delete
* @since 3.10
[661] Fix | Delete
*
[662] Fix | Delete
* @param boolean $enabled
[663] Fix | Delete
* @param integer $post_id
[664] Fix | Delete
*/
[665] Fix | Delete
$enabled = apply_filters( 'et_builder_fb_enabled_for_post', $enabled, $post_id );
[666] Fix | Delete
[667] Fix | Delete
return $enabled;
[668] Fix | Delete
}
[669] Fix | Delete
[670] Fix | Delete
/**
[671] Fix | Delete
* Check whether the specified post type is public.
[672] Fix | Delete
*
[673] Fix | Delete
* @since 3.10
[674] Fix | Delete
*
[675] Fix | Delete
* @param string $post_type
[676] Fix | Delete
*
[677] Fix | Delete
* @return boolean
[678] Fix | Delete
*/
[679] Fix | Delete
function et_builder_is_post_type_public( $post_type ) {
[680] Fix | Delete
$pto = get_post_type_object( $post_type );
[681] Fix | Delete
[682] Fix | Delete
// Note: the page post type is not publicly_queryable but we should treat it as such.
[683] Fix | Delete
return ( $pto && ( $pto->publicly_queryable || $pto->name === 'page' ) );
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
function et_is_extra_library_layout( $post_id ) {
[687] Fix | Delete
return 'layout' === get_post_type( $post_id );
[688] Fix | Delete
}
[689] Fix | Delete
[690] Fix | Delete
/**
[691] Fix | Delete
* Check whether the specified capability allowed for the user
[692] Fix | Delete
*
[693] Fix | Delete
* @param array|string $capabilities
[694] Fix | Delete
* @param string $role - The user role. If empty the role of the current user is used
[695] Fix | Delete
*
[696] Fix | Delete
* @return bool
[697] Fix | Delete
*/
[698] Fix | Delete
function et_pb_is_allowed( $capabilities, $role = '' ) {
[699] Fix | Delete
$saved_capabilities = et_pb_get_role_settings();
[700] Fix | Delete
$test_current_user = '' === $role;
[701] Fix | Delete
$role = $test_current_user ? et_pb_get_current_user_role() : $role;
[702] Fix | Delete
[703] Fix | Delete
if ( ! $role ) {
[704] Fix | Delete
return false;
[705] Fix | Delete
}
[706] Fix | Delete
[707] Fix | Delete
// Disable certain capabilities for non-allowlisted roles by default.
[708] Fix | Delete
$dangerous = array( 'theme_builder', 'read_dynamic_content_custom_fields' );
[709] Fix | Delete
$roles_allowlist = array( 'administrator', 'et_support_elevated', 'et_support' );
[710] Fix | Delete
[711] Fix | Delete
foreach ( (array) $capabilities as $capability ) {
[712] Fix | Delete
$is_dangerous = in_array( $capability, $dangerous, true );
[713] Fix | Delete
$role_not_allowlisted = ! in_array( $role, $roles_allowlist, true );
[714] Fix | Delete
[715] Fix | Delete
if ( $test_current_user && $is_dangerous && is_multisite() && is_super_admin() ) {
[716] Fix | Delete
// Super admins always have access to dangerous capabilities and that cannot be
[717] Fix | Delete
// changed in the role editor.
[718] Fix | Delete
return true;
[719] Fix | Delete
}
[720] Fix | Delete
[721] Fix | Delete
if ( ! empty( $saved_capabilities[ $role ][ $capability ] ) ) {
[722] Fix | Delete
return 'on' === $saved_capabilities[ $role ][ $capability ];
[723] Fix | Delete
}
[724] Fix | Delete
[725] Fix | Delete
if ( $is_dangerous && $role_not_allowlisted ) {
[726] Fix | Delete
// Allowlisted roles have access to dangerous capabilities by default,
[727] Fix | Delete
// but that can be changed in the role editor.
[728] Fix | Delete
return false;
[729] Fix | Delete
}
[730] Fix | Delete
}
[731] Fix | Delete
[732] Fix | Delete
return true;
[733] Fix | Delete
}
[734] Fix | Delete
[735] Fix | Delete
/**
[736] Fix | Delete
* Performs a check against ET capabilities before passing on to {@see et_core_security_check()}.
[737] Fix | Delete
*
[738] Fix | Delete
* @since 4.0
[739] Fix | Delete
*
[740] Fix | Delete
* @param string $et_capability
[741] Fix | Delete
* @param string $wp_capability
[742] Fix | Delete
* @param string $nonce_action
[743] Fix | Delete
* @param string $nonce_key
[744] Fix | Delete
* @param string $nonce_location
[745] Fix | Delete
* @param bool $die
[746] Fix | Delete
*
[747] Fix | Delete
* @return bool
[748] Fix | Delete
*/
[749] Fix | Delete
function et_builder_security_check( $et_capability, $wp_capability = 'manage_options', $nonce_action = '', $nonce_key = '', $nonce_location = '_POST', $die = true ) {
[750] Fix | Delete
if ( ! et_pb_is_allowed( $et_capability ) ) {
[751] Fix | Delete
if ( $die ) {
[752] Fix | Delete
et_core_die();
[753] Fix | Delete
}
[754] Fix | Delete
return false;
[755] Fix | Delete
}
[756] Fix | Delete
[757] Fix | Delete
return et_core_security_check( $wp_capability, $nonce_action, $nonce_key, $nonce_location, $die );
[758] Fix | Delete
}
[759] Fix | Delete
[760] Fix | Delete
/**
[761] Fix | Delete
* Gets the array of role settings
[762] Fix | Delete
* @return array
[763] Fix | Delete
*/
[764] Fix | Delete
function et_pb_get_role_settings() {
[765] Fix | Delete
global $et_pb_role_settings;
[766] Fix | Delete
[767] Fix | Delete
// if we don't have saved global variable, then get the value from WPDB
[768] Fix | Delete
$et_pb_role_settings = isset( $et_pb_role_settings ) ? $et_pb_role_settings : get_option( 'et_pb_role_settings', array() );
[769] Fix | Delete
[770] Fix | Delete
return $et_pb_role_settings;
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
/**
[774] Fix | Delete
* Determines the current user role
[775] Fix | Delete
* @return string
[776] Fix | Delete
*/
[777] Fix | Delete
function et_pb_get_current_user_role() {
[778] Fix | Delete
$current_user = wp_get_current_user();
[779] Fix | Delete
$user_roles = $current_user->roles;
[780] Fix | Delete
[781] Fix | Delete
// retrieve the role from array if exists or determine it using custom mechanism
[782] Fix | Delete
// $user_roles array may start not from 0 index. Use reset() to retrieve the first value from array regardless its index
[783] Fix | Delete
$role = ! empty( $user_roles ) ? reset( $user_roles ) : et_pb_determine_current_user_role();
[784] Fix | Delete
[785] Fix | Delete
return $role;
[786] Fix | Delete
}
[787] Fix | Delete
[788] Fix | Delete
/**
[789] Fix | Delete
* Generate the list of all roles ( with editing permissions ) registered in current WP
[790] Fix | Delete
* @return array
[791] Fix | Delete
*/
[792] Fix | Delete
function et_pb_get_all_roles_list() {
[793] Fix | Delete
// get all roles registered in current WP
[794] Fix | Delete
if ( ! function_exists( 'get_editable_roles' ) ) {
[795] Fix | Delete
require_once( ABSPATH . 'wp-admin/includes/user.php' );
[796] Fix | Delete
}
[797] Fix | Delete
[798] Fix | Delete
$all_roles = get_editable_roles();
[799] Fix | Delete
$builder_roles_array = array();
[800] Fix | Delete
[801] Fix | Delete
if ( ! empty( $all_roles ) ) {
[802] Fix | Delete
foreach( $all_roles as $role => $role_data ) {
[803] Fix | Delete
// add roles with edit_posts capability into $builder_roles_array (but not Support)
[804] Fix | Delete
if (
[805] Fix | Delete
! empty( $role_data['capabilities']['edit_posts'] )
[806] Fix | Delete
&&
[807] Fix | Delete
1 === (int) $role_data['capabilities']['edit_posts']
[808] Fix | Delete
&&
[809] Fix | Delete
! in_array( $role_data['name'], array( "ET Support", "ET Support - Elevated" ) )
[810] Fix | Delete
) {
[811] Fix | Delete
$builder_roles_array[ $role ] = $role_data['name'];
[812] Fix | Delete
}
[813] Fix | Delete
}
[814] Fix | Delete
}
[815] Fix | Delete
[816] Fix | Delete
// fill the builder roles array with default roles if it's empty
[817] Fix | Delete
if ( empty( $builder_roles_array ) ) {
[818] Fix | Delete
$builder_roles_array = array(
[819] Fix | Delete
'administrator' => esc_html__( 'Administrator', 'et_builder' ),
[820] Fix | Delete
'editor' => esc_html__( 'Editor', 'et_builder' ),
[821] Fix | Delete
'author' => esc_html__( 'Author', 'et_builder' ),
[822] Fix | Delete
'contributor' => esc_html__( 'Contributor', 'et_builder' ),
[823] Fix | Delete
);
[824] Fix | Delete
}
[825] Fix | Delete
[826] Fix | Delete
return $builder_roles_array;
[827] Fix | Delete
}
[828] Fix | Delete
[829] Fix | Delete
/**
[830] Fix | Delete
* Determine the current user role by checking every single registered role via current_user_can()
[831] Fix | Delete
* @return string
[832] Fix | Delete
*/
[833] Fix | Delete
function et_pb_determine_current_user_role() {
[834] Fix | Delete
$all_roles = et_pb_get_all_roles_list();
[835] Fix | Delete
[836] Fix | Delete
// go through all the registered roles and return the one current user have
[837] Fix | Delete
foreach( $all_roles as $role => $role_data ) {
[838] Fix | Delete
if ( current_user_can( $role ) ) {
[839] Fix | Delete
return $role;
[840] Fix | Delete
}
[841] Fix | Delete
}
[842] Fix | Delete
}
[843] Fix | Delete
[844] Fix | Delete
function et_pb_show_all_layouts_built_for_post_type( $post_type ) {
[845] Fix | Delete
$similar_post_types = array(
[846] Fix | Delete
'post',
[847] Fix | Delete
'page',
[848] Fix | Delete
'project',
[849] Fix | Delete
);
[850] Fix | Delete
[851] Fix | Delete
if ( in_array( $post_type, $similar_post_types ) ) {
[852] Fix | Delete
return $similar_post_types;
[853] Fix | Delete
}
[854] Fix | Delete
[855] Fix | Delete
return $post_type;
[856] Fix | Delete
}
[857] Fix | Delete
add_filter( 'et_pb_show_all_layouts_built_for_post_type', 'et_pb_show_all_layouts_built_for_post_type' );
[858] Fix | Delete
[859] Fix | Delete
function et_pb_show_all_layouts() {
[860] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[861] Fix | Delete
die( -1 );
[862] Fix | Delete
}
[863] Fix | Delete
[864] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[865] Fix | Delete
die( -1 );
[866] Fix | Delete
}
[867] Fix | Delete
[868] Fix | Delete
printf( '
[869] Fix | Delete
<label for="et_pb_load_layout_replace">
[870] Fix | Delete
<input name="et_pb_load_layout_replace" type="checkbox" id="et_pb_load_layout_replace" %2$s/>
[871] Fix | Delete
<span>%1$s</span>
[872] Fix | Delete
</label>',
[873] Fix | Delete
esc_html__( 'Replace the existing content with loaded layout', 'et_builder' ),
[874] Fix | Delete
checked( get_theme_mod( 'et_pb_replace_content', 'on' ), 'on', false )
[875] Fix | Delete
);
[876] Fix | Delete
[877] Fix | Delete
$post_type = ! empty( $_POST['et_layouts_built_for_post_type'] ) ? sanitize_text_field( $_POST['et_layouts_built_for_post_type'] ) : 'post';
[878] Fix | Delete
$layouts_type = ! empty( $_POST['et_load_layouts_type'] ) ? sanitize_text_field( $_POST['et_load_layouts_type'] ) : 'predefined';
[879] Fix | Delete
[880] Fix | Delete
$predefined_operator = 'predefined' === $layouts_type ? 'EXISTS' : 'NOT EXISTS';
[881] Fix | Delete
[882] Fix | Delete
$post_type = apply_filters( 'et_pb_show_all_layouts_built_for_post_type', $post_type, $layouts_type );
[883] Fix | Delete
[884] Fix | Delete
$query_args = array(
[885] Fix | Delete
'meta_query' => array(
[886] Fix | Delete
'relation' => 'AND',
[887] Fix | Delete
array(
[888] Fix | Delete
'key' => '_et_pb_predefined_layout',
[889] Fix | Delete
'value' => 'on',
[890] Fix | Delete
'compare' => $predefined_operator,
[891] Fix | Delete
),
[892] Fix | Delete
array(
[893] Fix | Delete
'key' => '_et_pb_built_for_post_type',
[894] Fix | Delete
'value' => $post_type,
[895] Fix | Delete
'compare' => 'IN',
[896] Fix | Delete
),
[897] Fix | Delete
array(
[898] Fix | Delete
'key' => '_et_pb_layout_applicability',
[899] Fix | Delete
'value' => 'product_tour',
[900] Fix | Delete
'compare' => 'NOT EXISTS',
[901] Fix | Delete
),
[902] Fix | Delete
),
[903] Fix | Delete
'tax_query' => array(
[904] Fix | Delete
array(
[905] Fix | Delete
'taxonomy' => 'layout_type',
[906] Fix | Delete
'field' => 'slug',
[907] Fix | Delete
'terms' => array( 'section', 'row', 'module', 'fullwidth_section', 'specialty_section', 'fullwidth_module' ),
[908] Fix | Delete
'operator' => 'NOT IN',
[909] Fix | Delete
),
[910] Fix | Delete
),
[911] Fix | Delete
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
[912] Fix | Delete
'posts_per_page' => '-1',
[913] Fix | Delete
'suppress_filters' => 'predefined' === $layouts_type,
[914] Fix | Delete
);
[915] Fix | Delete
[916] Fix | Delete
$query = new WP_Query( $query_args );
[917] Fix | Delete
[918] Fix | Delete
if ( $query->have_posts() ) :
[919] Fix | Delete
[920] Fix | Delete
echo '<ul class="et-pb-all-modules et-pb-load-layouts">';
[921] Fix | Delete
[922] Fix | Delete
while ( $query->have_posts() ) : $query->the_post();
[923] Fix | Delete
[924] Fix | Delete
$button_html = 'predefined' !== $layouts_type ?
[925] Fix | Delete
sprintf( '<a href="#" class="button et_pb_layout_button_delete">%1$s</a>',
[926] Fix | Delete
esc_html__( 'Delete', 'et_builder' )
[927] Fix | Delete
)
[928] Fix | Delete
: '';
[929] Fix | Delete
[930] Fix | Delete
printf( '<li class="et_pb_text" data-layout_id="%2$s">%1$s<span class="et_pb_layout_buttons"><a href="#" class="button-primary et_pb_layout_button_load">%3$s</a>%4$s</span></li>',
[931] Fix | Delete
esc_html( get_the_title() ),
[932] Fix | Delete
esc_attr( get_the_ID() ),
[933] Fix | Delete
esc_html__( 'Load', 'et_builder' ),
[934] Fix | Delete
et_core_esc_previously( $button_html )
[935] Fix | Delete
);
[936] Fix | Delete
[937] Fix | Delete
endwhile;
[938] Fix | Delete
[939] Fix | Delete
echo '</ul>';
[940] Fix | Delete
endif;
[941] Fix | Delete
[942] Fix | Delete
wp_reset_postdata();
[943] Fix | Delete
[944] Fix | Delete
die();
[945] Fix | Delete
}
[946] Fix | Delete
add_action( 'wp_ajax_et_pb_show_all_layouts', 'et_pb_show_all_layouts' );
[947] Fix | Delete
[948] Fix | Delete
function et_pb_get_saved_templates() {
[949] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[950] Fix | Delete
die( -1 );
[951] Fix | Delete
}
[952] Fix | Delete
[953] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[954] Fix | Delete
die( -1 );
[955] Fix | Delete
}
[956] Fix | Delete
[957] Fix | Delete
$layout_type = ! empty( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : 'layout';
[958] Fix | Delete
$module_width = ! empty( $_POST['et_module_width'] ) && 'module' === $layout_type ? sanitize_text_field( $_POST['et_module_width'] ) : '';
[959] Fix | Delete
$is_global = ! empty( $_POST['et_is_global'] ) ? sanitize_text_field( $_POST['et_is_global'] ) : 'false';
[960] Fix | Delete
$specialty_query = ! empty( $_POST['et_specialty_columns'] ) && 'row' === $layout_type ? sanitize_text_field( $_POST['et_specialty_columns'] ) : '0';
[961] Fix | Delete
$post_type = ! empty( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : 'post';
[962] Fix | Delete
[963] Fix | Delete
$templates_data = et_pb_retrieve_templates( $layout_type, $module_width, $is_global, $specialty_query, $post_type );
[964] Fix | Delete
[965] Fix | Delete
if ( empty( $templates_data ) ) {
[966] Fix | Delete
$templates_data = array( 'error' => esc_html__( 'You have not saved any items to your Divi Library yet. Once an item has been saved to your library, it will appear here for easy use.', 'et_builder' ) );
[967] Fix | Delete
}
[968] Fix | Delete
[969] Fix | Delete
$json_templates = wp_json_encode( $templates_data );
[970] Fix | Delete
[971] Fix | Delete
die( et_core_esc_previously( $json_templates ) );
[972] Fix | Delete
}
[973] Fix | Delete
add_action( 'wp_ajax_et_pb_get_saved_templates', 'et_pb_get_saved_templates' );
[974] Fix | Delete
[975] Fix | Delete
/**
[976] Fix | Delete
* Retrieves saved builder layouts.
[977] Fix | Delete
*
[978] Fix | Delete
* @since 2.0
[979] Fix | Delete
*
[980] Fix | Delete
* @param string $layout_type Accepts 'section', 'row', 'module', 'fullwidth_section',
[981] Fix | Delete
* 'specialty_section', 'fullwidth_module'.
[982] Fix | Delete
* @param string $module_width Accepts 'regular', 'fullwidth'.
[983] Fix | Delete
* @param string $is_global Filter layouts based on their scope. Accepts 'global' to include
[984] Fix | Delete
* only global layouts, 'false' to include only non-global layouts,
[985] Fix | Delete
* or 'all' to include both global and non-global layouts.
[986] Fix | Delete
* @param string $specialty_query Limit results to layouts of type 'row' that can be put inside
[987] Fix | Delete
* specialty sections. Accepts '3' to include only 3-column rows,
[988] Fix | Delete
* '2' for 2-column rows, or '0' to disable the specialty query. Default '0'.
[989] Fix | Delete
* @param string $post_type Limit results to layouts built for this post type.
[990] Fix | Delete
* @param string $deprecated Deprecated.
[991] Fix | Delete
* @param array $boundaries {
[992] Fix | Delete
*
[993] Fix | Delete
* Return a subset of the total results.
[994] Fix | Delete
*
[995] Fix | Delete
* @type int $offset Start from this point in the results. Default `0`.
[996] Fix | Delete
* @type int $limit Maximum number of results to return. Default `-1`.
[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