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 array[] $layouts {
[1000] Fix | Delete
*
[1001] Fix | Delete
* @type mixed[] {
[1002] Fix | Delete
*
[1003] Fix | Delete
* Layout Data
[1004] Fix | Delete
*
[1005] Fix | Delete
* @type int $ID The layout's post id.
[1006] Fix | Delete
* @type string $title The layout's title/name.
[1007] Fix | Delete
* @type string $shortcode The layout's shortcode content.
[1008] Fix | Delete
* @type string $is_global The layout's scope. Accepts 'global', 'non_global'.
[1009] Fix | Delete
* @type string $layout_type The layout's type. See {@see self::$layout_type} param for accepted values.
[1010] Fix | Delete
* @type string $applicability The layout's applicability.
[1011] Fix | Delete
* @type string $layouts_type Deprecated. Will always be 'library'.
[1012] Fix | Delete
* @type string $module_type For layouts of type 'module', the module type/slug (eg. et_pb_blog).
[1013] Fix | Delete
* @type string[] $categories This layout's assigned categories (slugs).
[1014] Fix | Delete
* @type string $row_layout For layout's of type 'row', the row layout type (eg. 4_4).
[1015] Fix | Delete
* @type mixed[] $unsynced_options For global layouts, the layout's unsynced settings.
[1016] Fix | Delete
* }
[1017] Fix | Delete
* ...
[1018] Fix | Delete
* }
[1019] Fix | Delete
*/
[1020] Fix | Delete
function et_pb_retrieve_templates( $layout_type = 'layout', $module_width = '', $is_global = 'false', $specialty_query = '0', $post_type = 'post', $deprecated = '', $boundaries = array() ) {
[1021] Fix | Delete
$templates_data = array();
[1022] Fix | Delete
$suppress_filters = false;
[1023] Fix | Delete
$extra_layout_post_type = 'layout';
[1024] Fix | Delete
$module_icons = ET_Builder_Element::get_module_icons();
[1025] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[1026] Fix | Delete
$similar_post_types = array_keys(ET_Builder_Settings::get_registered_post_type_options());
[1027] Fix | Delete
[1028] Fix | Delete
// All default and 3rd party post types considered similar and share the same library items, so retrieve all items for any post type from the list
[1029] Fix | Delete
$post_type = in_array($post_type, $similar_post_types) ? $similar_post_types : $post_type;
[1030] Fix | Delete
[1031] Fix | Delete
// need specific query for the layouts
[1032] Fix | Delete
if ( 'layout' === $layout_type ) {
[1033] Fix | Delete
[1034] Fix | Delete
if ( 'all' === $post_type ) {
[1035] Fix | Delete
$meta_query = array(
[1036] Fix | Delete
'relation' => 'AND',
[1037] Fix | Delete
array(
[1038] Fix | Delete
'key' => '_et_pb_built_for_post_type',
[1039] Fix | Delete
'value' => $extra_layout_post_type,
[1040] Fix | Delete
'compare' => 'NOT IN',
[1041] Fix | Delete
),
[1042] Fix | Delete
);
[1043] Fix | Delete
} else {
[1044] Fix | Delete
$meta_query = array(
[1045] Fix | Delete
'relation' => 'AND',
[1046] Fix | Delete
array(
[1047] Fix | Delete
'key' => '_et_pb_built_for_post_type',
[1048] Fix | Delete
'value' => $post_type,
[1049] Fix | Delete
'compare' => 'IN',
[1050] Fix | Delete
),
[1051] Fix | Delete
);
[1052] Fix | Delete
}
[1053] Fix | Delete
[1054] Fix | Delete
$tax_query = array(
[1055] Fix | Delete
array(
[1056] Fix | Delete
'taxonomy' => 'layout_type',
[1057] Fix | Delete
'field' => 'slug',
[1058] Fix | Delete
'terms' => array( 'section', 'row', 'module', 'fullwidth_section', 'specialty_section', 'fullwidth_module' ),
[1059] Fix | Delete
'operator' => 'NOT IN',
[1060] Fix | Delete
),
[1061] Fix | Delete
);
[1062] Fix | Delete
$suppress_filters = 'predefined' === $layout_type;
[1063] Fix | Delete
} else {
[1064] Fix | Delete
$additional_condition = '' !== $module_width ?
[1065] Fix | Delete
array(
[1066] Fix | Delete
'taxonomy' => 'module_width',
[1067] Fix | Delete
'field' => 'slug',
[1068] Fix | Delete
'terms' => $module_width,
[1069] Fix | Delete
) : '';
[1070] Fix | Delete
[1071] Fix | Delete
$meta_query = array();
[1072] Fix | Delete
[1073] Fix | Delete
if ( '0' !== $specialty_query ) {
[1074] Fix | Delete
$columns_val = '3' === $specialty_query ? array( '4_4', '1_2,1_2', '1_3,1_3,1_3' ) : array( '4_4', '1_2,1_2' );
[1075] Fix | Delete
$meta_query[] = array(
[1076] Fix | Delete
'key' => '_et_pb_row_layout',
[1077] Fix | Delete
'value' => $columns_val,
[1078] Fix | Delete
'compare' => 'IN',
[1079] Fix | Delete
);
[1080] Fix | Delete
}
[1081] Fix | Delete
[1082] Fix | Delete
$post_type = apply_filters( 'et_pb_show_all_layouts_built_for_post_type', $post_type, $layout_type );
[1083] Fix | Delete
$meta_query[] = array(
[1084] Fix | Delete
'key' => '_et_pb_built_for_post_type',
[1085] Fix | Delete
'value' => $post_type,
[1086] Fix | Delete
'compare' => 'IN',
[1087] Fix | Delete
);
[1088] Fix | Delete
[1089] Fix | Delete
$tax_query = array(
[1090] Fix | Delete
'relation' => 'AND',
[1091] Fix | Delete
array(
[1092] Fix | Delete
'taxonomy' => 'layout_type',
[1093] Fix | Delete
'field' => 'slug',
[1094] Fix | Delete
'terms' => $layout_type,
[1095] Fix | Delete
),
[1096] Fix | Delete
$additional_condition,
[1097] Fix | Delete
);
[1098] Fix | Delete
[1099] Fix | Delete
if ( 'all' !== $is_global ) {
[1100] Fix | Delete
$global_operator = 'global' === $is_global ? 'IN' : 'NOT IN';
[1101] Fix | Delete
$tax_query[] = array(
[1102] Fix | Delete
'taxonomy' => 'scope',
[1103] Fix | Delete
'field' => 'slug',
[1104] Fix | Delete
'terms' => array( 'global' ),
[1105] Fix | Delete
'operator' => $global_operator,
[1106] Fix | Delete
);
[1107] Fix | Delete
}
[1108] Fix | Delete
}
[1109] Fix | Delete
[1110] Fix | Delete
$start_from = 0;
[1111] Fix | Delete
$limit_to = '-1';
[1112] Fix | Delete
[1113] Fix | Delete
if ( ! empty( $boundaries ) ) {
[1114] Fix | Delete
$start_from = $boundaries[0];
[1115] Fix | Delete
$limit_to = $boundaries[1];
[1116] Fix | Delete
}
[1117] Fix | Delete
[1118] Fix | Delete
/**
[1119] Fix | Delete
* Filter suppress_filters argument.
[1120] Fix | Delete
*
[1121] Fix | Delete
* @since 4.4.5
[1122] Fix | Delete
*
[1123] Fix | Delete
* @param boolean $suppress_filters
[1124] Fix | Delete
*/
[1125] Fix | Delete
$suppress_filters = wp_validate_boolean( apply_filters( 'et_pb_show_all_layouts_suppress_filters', $suppress_filters ) );
[1126] Fix | Delete
[1127] Fix | Delete
$query = new WP_Query( array(
[1128] Fix | Delete
'tax_query' => $tax_query,
[1129] Fix | Delete
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
[1130] Fix | Delete
'posts_per_page' => $limit_to,
[1131] Fix | Delete
'meta_query' => $meta_query,
[1132] Fix | Delete
'offset' => $start_from,
[1133] Fix | Delete
'suppress_filters' => $suppress_filters,
[1134] Fix | Delete
) );
[1135] Fix | Delete
[1136] Fix | Delete
wp_reset_postdata();
[1137] Fix | Delete
[1138] Fix | Delete
if ( ! empty ( $query->posts ) ) {
[1139] Fix | Delete
foreach( $query->posts as $single_post ) {
[1140] Fix | Delete
[1141] Fix | Delete
if ( 'module' === $layout_type ) {
[1142] Fix | Delete
$module_type = get_post_meta( $single_post->ID, '_et_pb_module_type', true );
[1143] Fix | Delete
} else {
[1144] Fix | Delete
$module_type = '';
[1145] Fix | Delete
}
[1146] Fix | Delete
[1147] Fix | Delete
// add only modules allowed for current user
[1148] Fix | Delete
if ( '' === $module_type || et_pb_is_allowed( $module_type ) ) {
[1149] Fix | Delete
$categories = wp_get_post_terms( $single_post->ID, 'layout_category' );
[1150] Fix | Delete
$scope = wp_get_post_terms( $single_post->ID, 'scope' );
[1151] Fix | Delete
$global_scope = isset( $scope[0] ) ? $scope[0]->slug : 'non_global';
[1152] Fix | Delete
$categories_processed = array();
[1153] Fix | Delete
$row_layout = '';
[1154] Fix | Delete
$this_layout_type = '';
[1155] Fix | Delete
$this_layout_applicability = '';
[1156] Fix | Delete
[1157] Fix | Delete
if ( ! empty( $categories ) ) {
[1158] Fix | Delete
foreach( $categories as $category_data ) {
[1159] Fix | Delete
$categories_processed[] = esc_html( $category_data->slug );
[1160] Fix | Delete
}
[1161] Fix | Delete
}
[1162] Fix | Delete
[1163] Fix | Delete
if ( 'row' === $layout_type ) {
[1164] Fix | Delete
$row_layout = get_post_meta( $single_post->ID, '_et_pb_row_layout', true );
[1165] Fix | Delete
}
[1166] Fix | Delete
[1167] Fix | Delete
if ( 'layout' === $layout_type ) {
[1168] Fix | Delete
$this_layout_type = 'on' === get_post_meta( $single_post->ID, '_et_pb_predefined_layout', true ) ? 'predefined' : 'library';
[1169] Fix | Delete
$this_layout_applicability = get_post_meta( $single_post->ID, '_et_pb_layout_applicability', true );
[1170] Fix | Delete
}
[1171] Fix | Delete
[1172] Fix | Delete
// get unsynced global options for module
[1173] Fix | Delete
if ( 'module' === $layout_type && 'false' !== $is_global ) {
[1174] Fix | Delete
$unsynced_options = get_post_meta( $single_post->ID, '_et_pb_excluded_global_options' );
[1175] Fix | Delete
}
[1176] Fix | Delete
[1177] Fix | Delete
$templates_datum = array(
[1178] Fix | Delete
'ID' => (int) $single_post->ID,
[1179] Fix | Delete
'title' => esc_html( $single_post->post_title ),
[1180] Fix | Delete
'shortcode' => et_core_intentionally_unescaped( $single_post->post_content, 'html' ),
[1181] Fix | Delete
'is_global' => esc_html( $global_scope ),
[1182] Fix | Delete
'layout_type' => esc_html( $layout_type ),
[1183] Fix | Delete
'applicability' => esc_html( $this_layout_applicability ),
[1184] Fix | Delete
'layouts_type' => esc_html( $this_layout_type ),
[1185] Fix | Delete
'module_type' => esc_html( $module_type ),
[1186] Fix | Delete
'categories' => et_core_esc_previously( $categories_processed ),
[1187] Fix | Delete
'row_layout' => esc_html( $row_layout ),
[1188] Fix | Delete
'unsynced_options' => ! empty( $unsynced_options ) ? $utils->esc_array( json_decode( $unsynced_options[0], true ), 'sanitize_text_field' ) : array(),
[1189] Fix | Delete
);
[1190] Fix | Delete
[1191] Fix | Delete
// Append icon if there's any
[1192] Fix | Delete
if ( $module_type && $template_icon = $utils->array_get( $module_icons, "{$module_type}.icon", false ) ) {
[1193] Fix | Delete
$templates_datum['icon'] = $template_icon;
[1194] Fix | Delete
}
[1195] Fix | Delete
[1196] Fix | Delete
// Append svg icon if there's any
[1197] Fix | Delete
if ( $module_type && $template_icon_svg = $utils->array_get( $module_icons, "{$module_type}.icon_svg", false ) ) {
[1198] Fix | Delete
$templates_datum['icon_svg'] = $template_icon_svg;
[1199] Fix | Delete
}
[1200] Fix | Delete
[1201] Fix | Delete
$templates_data[] = $templates_datum;
[1202] Fix | Delete
}
[1203] Fix | Delete
}
[1204] Fix | Delete
}
[1205] Fix | Delete
[1206] Fix | Delete
return $templates_data;
[1207] Fix | Delete
}
[1208] Fix | Delete
[1209] Fix | Delete
[1210] Fix | Delete
function et_pb_add_template_meta() {
[1211] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1212] Fix | Delete
die( -1 );
[1213] Fix | Delete
}
[1214] Fix | Delete
[1215] Fix | Delete
$post_id = ! empty( $_POST['et_post_id'] ) ? sanitize_text_field( $_POST['et_post_id'] ) : '';
[1216] Fix | Delete
[1217] Fix | Delete
if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
[1218] Fix | Delete
die( -1 );
[1219] Fix | Delete
}
[1220] Fix | Delete
[1221] Fix | Delete
$value = ! empty( $_POST['et_meta_value'] ) ? sanitize_text_field( $_POST['et_meta_value'] ) : '';
[1222] Fix | Delete
$custom_field = ! empty( $_POST['et_custom_field'] ) ? sanitize_text_field( $_POST['et_custom_field'] ) : '';
[1223] Fix | Delete
[1224] Fix | Delete
$allowlisted_meta_keys = array(
[1225] Fix | Delete
'_et_pb_row_layout',
[1226] Fix | Delete
'_et_pb_module_type',
[1227] Fix | Delete
);
[1228] Fix | Delete
[1229] Fix | Delete
if ( in_array( $custom_field, $allowlisted_meta_keys ) ) {
[1230] Fix | Delete
update_post_meta( $post_id, $custom_field, $value );
[1231] Fix | Delete
}
[1232] Fix | Delete
}
[1233] Fix | Delete
add_action( 'wp_ajax_et_pb_add_template_meta', 'et_pb_add_template_meta' );
[1234] Fix | Delete
[1235] Fix | Delete
if ( ! function_exists( 'et_pb_add_new_layout' ) ) {
[1236] Fix | Delete
function et_pb_add_new_layout() {
[1237] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1238] Fix | Delete
die( -1 );
[1239] Fix | Delete
}
[1240] Fix | Delete
[1241] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1242] Fix | Delete
die( -1 );
[1243] Fix | Delete
}
[1244] Fix | Delete
[1245] Fix | Delete
$fields_data = isset( $_POST['et_layout_options'] ) ? trim( $_POST['et_layout_options'] ) : '';
[1246] Fix | Delete
[1247] Fix | Delete
if ( empty( $fields_data ) ) {
[1248] Fix | Delete
die();
[1249] Fix | Delete
}
[1250] Fix | Delete
[1251] Fix | Delete
$fields_data_json = str_replace( '\\', '', $fields_data );
[1252] Fix | Delete
$fields_data_array = json_decode( $fields_data_json, true );
[1253] Fix | Delete
$processed_data_array = array();
[1254] Fix | Delete
[1255] Fix | Delete
// prepare array with fields data in convenient format
[1256] Fix | Delete
if ( ! empty( $fields_data_array ) ) {
[1257] Fix | Delete
foreach ( $fields_data_array as $index => $field_data ) {
[1258] Fix | Delete
$processed_data_array[ $field_data['field_id'] ] = $field_data['field_val'];
[1259] Fix | Delete
}
[1260] Fix | Delete
}
[1261] Fix | Delete
[1262] Fix | Delete
$processed_data_array = apply_filters( 'et_pb_new_layout_data_from_form', $processed_data_array, $fields_data_array );
[1263] Fix | Delete
[1264] Fix | Delete
if ( empty( $processed_data_array ) ) {
[1265] Fix | Delete
die();
[1266] Fix | Delete
}
[1267] Fix | Delete
[1268] Fix | Delete
$layout_type = et_()->array_get_sanitized( $processed_data_array, 'new_template_type', 'layout' );
[1269] Fix | Delete
$layout_is_global = 'global' === et_()->array_get( $processed_data_array, 'et_pb_template_global', 'not_global' );
[1270] Fix | Delete
if ( 'layout' === $layout_type ) {
[1271] Fix | Delete
// Layouts of type 'layout' are not allowed to be global.
[1272] Fix | Delete
$layout_is_global = false;
[1273] Fix | Delete
}
[1274] Fix | Delete
[1275] Fix | Delete
$args = array(
[1276] Fix | Delete
'layout_type' => $layout_type,
[1277] Fix | Delete
'layout_selected_cats' => ! empty( $processed_data_array['selected_cats'] ) ? sanitize_text_field( $processed_data_array['selected_cats'] ) : '',
[1278] Fix | Delete
'built_for_post_type' => ! empty( $processed_data_array['et_builder_layout_built_for_post_type'] ) ? sanitize_text_field( $processed_data_array['et_builder_layout_built_for_post_type'] ) : 'page',
[1279] Fix | Delete
'layout_new_cat' => ! empty( $processed_data_array['et_pb_new_cat_name'] ) ? sanitize_text_field( $processed_data_array['et_pb_new_cat_name'] ) : '',
[1280] Fix | Delete
'columns_layout' => ! empty( $processed_data_array['et_columns_layout'] ) ? sanitize_text_field( $processed_data_array['et_columns_layout'] ) : '0',
[1281] Fix | Delete
'module_type' => ! empty( $processed_data_array['et_module_type'] ) ? sanitize_text_field( $processed_data_array['et_module_type'] ) : 'et_pb_unknown',
[1282] Fix | Delete
'layout_scope' => $layout_is_global ? 'global' : 'not_global',
[1283] Fix | Delete
'module_width' => 'regular',
[1284] Fix | Delete
'layout_content' => ! empty( $processed_data_array['template_shortcode'] ) ? $processed_data_array['template_shortcode'] : '',
[1285] Fix | Delete
'layout_name' => ! empty( $processed_data_array['et_pb_new_template_name'] ) ? sanitize_text_field( $processed_data_array['et_pb_new_template_name'] ) : '',
[1286] Fix | Delete
);
[1287] Fix | Delete
[1288] Fix | Delete
// construct the initial shortcode for new layout
[1289] Fix | Delete
switch ( $args['layout_type'] ) {
[1290] Fix | Delete
case 'row' :
[1291] Fix | Delete
$args['layout_content'] = '[et_pb_row template_type="row"][/et_pb_row]';
[1292] Fix | Delete
break;
[1293] Fix | Delete
case 'section' :
[1294] Fix | Delete
$args['layout_content'] = '[et_pb_section template_type="section"][et_pb_row][/et_pb_row][/et_pb_section]';
[1295] Fix | Delete
break;
[1296] Fix | Delete
case 'module' :
[1297] Fix | Delete
$args['layout_content'] = '[et_pb_module_placeholder selected_tabs="all"]';
[1298] Fix | Delete
break;
[1299] Fix | Delete
case 'fullwidth_module' :
[1300] Fix | Delete
$args['layout_content'] = '[et_pb_fullwidth_module_placeholder selected_tabs="all"]';
[1301] Fix | Delete
$args['module_width'] = 'fullwidth';
[1302] Fix | Delete
$args['layout_type'] = 'module';
[1303] Fix | Delete
break;
[1304] Fix | Delete
case 'fullwidth_section' :
[1305] Fix | Delete
$args['layout_content'] = '[et_pb_section template_type="section" fullwidth="on"][/et_pb_section]';
[1306] Fix | Delete
$args['layout_type'] = 'section';
[1307] Fix | Delete
break;
[1308] Fix | Delete
case 'specialty_section' :
[1309] Fix | Delete
$args['layout_content'] = '[et_pb_section template_type="section" specialty="on" skip_module="true" specialty_placeholder="true"][/et_pb_section]';
[1310] Fix | Delete
$args['layout_type'] = 'section';
[1311] Fix | Delete
break;
[1312] Fix | Delete
}
[1313] Fix | Delete
[1314] Fix | Delete
$new_layout_meta = et_pb_submit_layout( apply_filters( 'et_pb_new_layout_args', $args ) );
[1315] Fix | Delete
die( et_core_esc_previously( $new_layout_meta ) );
[1316] Fix | Delete
}
[1317] Fix | Delete
}
[1318] Fix | Delete
add_action( 'wp_ajax_et_pb_add_new_layout', 'et_pb_add_new_layout' );
[1319] Fix | Delete
[1320] Fix | Delete
if ( ! function_exists( 'et_pb_submit_layout' ) ):
[1321] Fix | Delete
/**
[1322] Fix | Delete
* Handles saving layouts to the database for the builder. Essentially just a wrapper for
[1323] Fix | Delete
* {@see et_pb_create_layout()} that processes the data from the builder before passing it on.
[1324] Fix | Delete
*
[1325] Fix | Delete
* @since 1.0
[1326] Fix | Delete
*
[1327] Fix | Delete
* @param string[] $args {
[1328] Fix | Delete
* Layout Data
[1329] Fix | Delete
*
[1330] Fix | Delete
* @type string $layout_type Accepts 'layout', 'section', 'row', 'module'.
[1331] Fix | Delete
* @type string $layout_selected_cats Categories to which the layout should be added. This should
[1332] Fix | Delete
* be one or more IDs separated by pipe symbols. Example: '1|2|3'.
[1333] Fix | Delete
* @type string $built_for_post_type The post type for which the layout was built.
[1334] Fix | Delete
* @type string $layout_new_cat Name of a new category to which the layout should be added.
[1335] Fix | Delete
* @type string $columns_layout When 'layout_type' is 'row', the row's columns structure. Example: '1_4'.
[1336] Fix | Delete
* @type string $module_type When 'layout_type' is 'module', the module type. Example: 'et_pb_blurb'.
[1337] Fix | Delete
* @type string $layout_scope Optional. The layout's scope. Accepts: 'global', 'not_global'.
[1338] Fix | Delete
* @type string $module_width When 'layout_type' is 'module', the module's width. Accepts: 'regular', 'fullwidth'.
[1339] Fix | Delete
* @type string $layout_content The layout's content (unprocessed shortcodes).
[1340] Fix | Delete
* @type string $layout_name The layout's name.
[1341] Fix | Delete
* }
[1342] Fix | Delete
*
[1343] Fix | Delete
* @return string $layout_data The 'post_id' and 'edit_link' for the saved layout (JSON encoded).
[1344] Fix | Delete
*/
[1345] Fix | Delete
function et_pb_submit_layout( $args ) {
[1346] Fix | Delete
/**
[1347] Fix | Delete
* Filters the layout data passed to {@see et_pb_submit_layout()}.
[1348] Fix | Delete
*
[1349] Fix | Delete
* @since 3.0.99
[1350] Fix | Delete
*
[1351] Fix | Delete
* @param string[] $args See {@see et_pb_submit_layout()} for array structure definition.
[1352] Fix | Delete
*/
[1353] Fix | Delete
$args = apply_filters( 'et_pb_submit_layout_args', $args );
[1354] Fix | Delete
[1355] Fix | Delete
if ( empty( $args ) ) {
[1356] Fix | Delete
return '';
[1357] Fix | Delete
}
[1358] Fix | Delete
[1359] Fix | Delete
$layout_cats_processed = array();
[1360] Fix | Delete
[1361] Fix | Delete
if ( '' !== $args['layout_selected_cats'] ) {
[1362] Fix | Delete
$layout_cats_array = explode( ',', $args['layout_selected_cats'] );
[1363] Fix | Delete
$layout_cats_processed = array_map( 'intval', $layout_cats_array );
[1364] Fix | Delete
}
[1365] Fix | Delete
[1366] Fix | Delete
$meta = array();
[1367] Fix | Delete
[1368] Fix | Delete
if ( 'row' === $args['layout_type'] && '0' !== $args['columns_layout'] ) {
[1369] Fix | Delete
$meta = array_merge( $meta, array( '_et_pb_row_layout' => $args['columns_layout'] ) );
[1370] Fix | Delete
}
[1371] Fix | Delete
[1372] Fix | Delete
if ( 'module' === $args['layout_type'] ) {
[1373] Fix | Delete
$meta = array_merge( $meta, array( '_et_pb_module_type' => $args['module_type'] ) );
[1374] Fix | Delete
[1375] Fix | Delete
// save unsynced options for global modules. Always empty for new modules.
[1376] Fix | Delete
if ( 'global' === $args['layout_scope'] ) {
[1377] Fix | Delete
$meta = array_merge( $meta, array( '_et_pb_excluded_global_options' => wp_json_encode( array() ) ) );
[1378] Fix | Delete
}
[1379] Fix | Delete
}
[1380] Fix | Delete
[1381] Fix | Delete
//et_layouts_built_for_post_type
[1382] Fix | Delete
$meta = array_merge( $meta, array( '_et_pb_built_for_post_type' => $args['built_for_post_type'] ) );
[1383] Fix | Delete
[1384] Fix | Delete
$tax_input = array(
[1385] Fix | Delete
'scope' => $args['layout_scope'],
[1386] Fix | Delete
'layout_type' => $args['layout_type'],
[1387] Fix | Delete
'module_width' => $args['module_width'],
[1388] Fix | Delete
'layout_category' => $layout_cats_processed,
[1389] Fix | Delete
);
[1390] Fix | Delete
[1391] Fix | Delete
$new_layout_id = et_pb_create_layout( $args['layout_name'], $args['layout_content'], $meta, $tax_input, $args['layout_new_cat'] );
[1392] Fix | Delete
$new_post_data['post_id'] = (int) $new_layout_id;
[1393] Fix | Delete
[1394] Fix | Delete
$new_post_data['edit_link'] = htmlspecialchars_decode( get_edit_post_link( $new_layout_id ) );
[1395] Fix | Delete
$json_post_data = wp_json_encode( $new_post_data );
[1396] Fix | Delete
[1397] Fix | Delete
return $json_post_data;
[1398] Fix | Delete
}
[1399] Fix | Delete
endif;
[1400] Fix | Delete
[1401] Fix | Delete
if ( ! function_exists( 'et_pb_create_layout' ) ) :
[1402] Fix | Delete
function et_pb_create_layout( $name, $content, $meta = array(), $tax_input = array(), $new_category = '' ) {
[1403] Fix | Delete
$layout = array(
[1404] Fix | Delete
'post_title' => sanitize_text_field( $name ),
[1405] Fix | Delete
'post_content' => $content,
[1406] Fix | Delete
'post_status' => 'publish',
[1407] Fix | Delete
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
[1408] Fix | Delete
);
[1409] Fix | Delete
[1410] Fix | Delete
$layout_id = wp_insert_post( $layout );
[1411] Fix | Delete
[1412] Fix | Delete
if ( !empty( $meta ) ) {
[1413] Fix | Delete
foreach ( $meta as $meta_key => $meta_value ) {
[1414] Fix | Delete
add_post_meta( $layout_id, $meta_key, sanitize_text_field( $meta_value ) );
[1415] Fix | Delete
}
[1416] Fix | Delete
}
[1417] Fix | Delete
if ( '' !== $new_category ) {
[1418] Fix | Delete
$new_term_id = wp_insert_term( $new_category, 'layout_category' );
[1419] Fix | Delete
$tax_input['layout_category'][] = (int) $new_term_id['term_id'];
[1420] Fix | Delete
}
[1421] Fix | Delete
[1422] Fix | Delete
if ( ! empty( $tax_input ) ) {
[1423] Fix | Delete
foreach( $tax_input as $taxonomy => $terms ) {
[1424] Fix | Delete
wp_set_post_terms( $layout_id, $terms, $taxonomy );
[1425] Fix | Delete
}
[1426] Fix | Delete
}
[1427] Fix | Delete
[1428] Fix | Delete
return $layout_id;
[1429] Fix | Delete
}
[1430] Fix | Delete
endif;
[1431] Fix | Delete
[1432] Fix | Delete
function et_pb_save_layout() {
[1433] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1434] Fix | Delete
die( -1 );
[1435] Fix | Delete
}
[1436] Fix | Delete
[1437] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1438] Fix | Delete
die( -1 );
[1439] Fix | Delete
}
[1440] Fix | Delete
[1441] Fix | Delete
if ( empty( $_POST['et_layout_name'] ) ) {
[1442] Fix | Delete
die();
[1443] Fix | Delete
}
[1444] Fix | Delete
[1445] Fix | Delete
$args = array(
[1446] Fix | Delete
'layout_type' => isset( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : 'layout',
[1447] Fix | Delete
'layout_selected_cats' => isset( $_POST['et_layout_cats'] ) ? sanitize_text_field( $_POST['et_layout_cats'] ) : '',
[1448] Fix | Delete
'built_for_post_type' => isset( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : 'page',
[1449] Fix | Delete
'layout_new_cat' => isset( $_POST['et_layout_new_cat'] ) ? sanitize_text_field( $_POST['et_layout_new_cat'] ) : '',
[1450] Fix | Delete
'columns_layout' => isset( $_POST['et_columns_layout'] ) ? sanitize_text_field( $_POST['et_columns_layout'] ) : '0',
[1451] Fix | Delete
'module_type' => isset( $_POST['et_module_type'] ) ? sanitize_text_field( $_POST['et_module_type'] ) : 'et_pb_unknown',
[1452] Fix | Delete
'layout_scope' => isset( $_POST['et_layout_scope'] ) ? sanitize_text_field( $_POST['et_layout_scope'] ) : 'not_global',
[1453] Fix | Delete
'module_width' => isset( $_POST['et_module_width'] ) ? sanitize_text_field( $_POST['et_module_width'] ) : 'regular',
[1454] Fix | Delete
'layout_content' => isset( $_POST['et_layout_content'] ) ? $_POST['et_layout_content'] : '',
[1455] Fix | Delete
'layout_name' => isset( $_POST['et_layout_name'] ) ? sanitize_text_field( $_POST['et_layout_name'] ) : '',
[1456] Fix | Delete
);
[1457] Fix | Delete
[1458] Fix | Delete
$new_layout_meta = et_pb_submit_layout( $args );
[1459] Fix | Delete
die( et_core_esc_previously( $new_layout_meta ) );
[1460] Fix | Delete
}
[1461] Fix | Delete
add_action( 'wp_ajax_et_pb_save_layout', 'et_pb_save_layout' );
[1462] Fix | Delete
[1463] Fix | Delete
function et_pb_get_global_module() {
[1464] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1465] Fix | Delete
die( -1 );
[1466] Fix | Delete
}
[1467] Fix | Delete
[1468] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1469] Fix | Delete
die( -1 );
[1470] Fix | Delete
}
[1471] Fix | Delete
[1472] Fix | Delete
$global_shortcode = array();
[1473] Fix | Delete
[1474] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[1475] Fix | Delete
[1476] Fix | Delete
$post_id = isset( $_POST['et_global_id'] ) ? (int) $_POST['et_global_id'] : '';
[1477] Fix | Delete
[1478] Fix | Delete
if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
[1479] Fix | Delete
die( -1 );
[1480] Fix | Delete
}
[1481] Fix | Delete
[1482] Fix | Delete
$global_autop = isset( $_POST['et_global_autop'] ) ? sanitize_text_field( $_POST['et_global_autop'] ) : 'apply';
[1483] Fix | Delete
[1484] Fix | Delete
if ( ! empty( $post_id ) ) {
[1485] Fix | Delete
$query = new WP_Query( array(
[1486] Fix | Delete
'p' => $post_id,
[1487] Fix | Delete
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
[1488] Fix | Delete
) );
[1489] Fix | Delete
[1490] Fix | Delete
wp_reset_postdata();
[1491] Fix | Delete
[1492] Fix | Delete
if ( !empty( $query->post ) ) {
[1493] Fix | Delete
if ( 'skip' === $global_autop ) {
[1494] Fix | Delete
$post_content = $query->post->post_content;
[1495] Fix | Delete
} else {
[1496] Fix | Delete
$post_content = $query->post->post_content;
[1497] Fix | Delete
// do prep
[1498] Fix | Delete
$post_content = et_pb_prep_code_module_for_wpautop( $post_content );
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function