'em-wcw-layout-preview', 'shortcode' => $preview_shortcode), admin_url('admin.php') ); $page_url = add_query_arg( array( 'post_type' => EM_WCW_EVENT_POST_TYPE, 'page' => 'em-wcw-layouts', 'action' => 'add' ), admin_url('edit.php') ); $wp_7_comp_cls = version_compare( $wp_version, '7.0', '>=' ) ? 'em-wcw-wp-7' : ''; // Compatibility Class // Instantiate the shortcode builder if( ! class_exists( 'EM_WCW_Layout_Builder' ) ) { include_once( EM_WCW_DIR . '/includes/layout-builder/class-em-wcw-layout-builder.php' ); } // Getting layout temp data when we change the shortcode. json_decode() only parses the JSON — it does // not sanitize it, and a malformed/tampered cookie can decode to null or a non-array — so validate the // shape here and sanitize each field we actually read below rather than trusting the decoded value. $layout_temp_data = array(); if( isset( $_COOKIE['em_wcw_layout_temp_data'] ) ) { $decoded_temp_data = json_decode( wp_unslash( $_COOKIE['em_wcw_layout_temp_data'] ), true ); if( is_array( $decoded_temp_data ) ) { $layout_temp_data = $decoded_temp_data; } } $shortcode_val = "[{$preview_shortcode}]"; $layout_title = ''; $layout_desc = ''; $layout_enable = 1; $shortcode_fields = array(); $shortcode_sanitize = str_replace('-', '_', $preview_shortcode); $page_title = __( 'Add New Layout', 'webcodexworld-events-manager' ); $save_btn_text = __('Publish', 'webcodexworld-events-manager'); if( 'edit' == $action ) { $page_title = __( 'Edit Layout', 'webcodexworld-events-manager' ); $save_btn_text = __('Update', 'webcodexworld-events-manager'); $trash_url = add_query_arg( array( 'post_type' => EM_WCW_EVENT_POST_TYPE, 'page' => 'em-wcw-layouts', 'action' => 'delete', 'em_wcw_layout' => $layout_id, '_wpnonce' => wp_create_nonce('bulk-em_wcw_layouts') ), admin_url('edit.php') ); $duplicate_url = add_query_arg( array( 'post_type' => EM_WCW_EVENT_POST_TYPE, 'page' => 'em-wcw-layouts', 'shortcode' => $preview_shortcode, 'action' => 'duplicate_layout', 'id' => $layout_id, '_wpnonce' => wp_create_nonce("em-wcw-duplicate-layout-{$layout_id}") ), admin_url('edit.php') ); } ?>
'; } // Check valid shortcode template is there if( ! empty( $layout_id ) ) { // Get layout post $layout_data = get_post( $layout_id ); if( $layout_data && isset( $layout_data->post_type ) && $layout_data->post_type == EM_WCW_LAYOUT_POST_TYPE ) { $layout_title = $layout_data->post_title; $layout_desc = $layout_data->post_content; $layout_enable = ( 'publish' == $layout_data->post_status ) ? 1 : 0; $layout_shrt_type = get_post_meta( $layout_id, $meta_prefix.'layout_shrt_type', true ); if( $preview_shortcode == $layout_shrt_type ) { $shortcode_val = get_post_meta( $layout_id, $meta_prefix.'layout_shrt', true ); } } else { $valid = false; echo ''.esc_html__('Sorry, No layout found.', 'webcodexworld-events-manager').'
'.esc_html__('Layout saved successfully.', 'webcodexworld-events-manager').'
'.esc_html__('Sorry, Something happened wrong. Layout data has not been saved.', 'webcodexworld-events-manager').'
'.esc_html__('Layout data copied successfully.', 'webcodexworld-events-manager').'