ID, 'box_title', true ); $box_style = get_post_meta( $post->ID, 'box_style', true ); $view_automatically = get_post_meta( $post->ID, 'view_automatically', true ); $box_position = get_post_meta( $post->ID, 'box_position', true ); $position_priority = get_post_meta( $post->ID, 'position_priority', true ); $box_post_type = 'product'; $html_data = get_post_meta( $post->ID, 'html_data', true ); $box_editor = get_post_meta( $post->ID, 'box_editor', true ); wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); wp_enqueue_style( 'awv-admin-style' ); wp_enqueue_script( 'awv-admin-script' ); wp_localize_script( 'awv-admin-script', 'awv_data', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'awv_nonce' ), 'loading_text' => esc_html__( 'Loading...', 'awv-plugin' ), 'box_post_type' => $box_post_type ) ); $box_styles = awv_box_styles(); $pro_version = file_exists( AWV_DIR_PATH . '/pro/awv-pro.php' ); $line_elmns = $box_editor == 'html' ? 'hidden-row' : ''; $html_elmns = $box_editor != 'html' ? 'hidden-row' : ''; // make sure the form request comes from WordPress wp_nonce_field( basename( __FILE__ ), 'awv_box_metabox' ); ?>
class="hidden-row" id="box_position_row"> class="hidden-row" id="box_position_priority_row">
ID ); ?>
ID, 'box_visibility', true ); $box_weight = get_post_meta( $post->ID, 'box_weight', true ); $css_class = get_post_meta( $post->ID, 'css_class', true ); $css_id = get_post_meta( $post->ID, 'css_id', true ); $padding_top = get_post_meta( $post->ID, 'padding_top', true ); $padding_bottom = get_post_meta( $post->ID, 'padding_bottom', true ); ?>

'; } public function awv_build_meta_fields( $post ) { awv_get_fields_table(); } public function awv_save_meta_box_data( $post_id ) { // verify meta box nonce if ( ! isset( $_POST['awv_box_metabox'] ) || ! wp_verify_nonce( $_POST['awv_box_metabox'], basename( __FILE__ ) ) ){ return; } // return if autosave if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Check the user's permissions. if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } // Check if feilds exist and save if ( isset( $_POST['awv_feild_item'] ) ) { $feild_item = $this->sanitize_array( $_POST['awv_feild_item'] ); update_post_meta( $post_id, 'awv_feild_item', $feild_item ); } if ( isset( $_POST['box_title'] ) ) { update_post_meta( $post_id, 'box_title', sanitize_text_field( $_POST['box_title'] ) ); } update_post_meta( $post_id, 'box_style', sanitize_text_field( $_POST['box_style'] ) ); update_post_meta( $post_id, 'box_editor', sanitize_text_field( $_POST['box_editor'] ) ); update_post_meta( $post_id, 'view_automatically', sanitize_text_field( $_POST['view_automatically'] ) ); update_post_meta( $post_id, 'box_post_type', 'product' ); update_post_meta( $post_id, 'position_priority', sanitize_text_field( $_POST['position_priority'] ) ); update_post_meta( $post_id, 'html_data', sanitize_text_field( $_POST['html_data'] ) ); if ( isset( $_POST['box_position'] ) ) { update_post_meta( $post_id, 'box_position', sanitize_text_field( $_POST['box_position'] ) ); } update_post_meta( $post_id, 'box_visibility', sanitize_text_field( $_POST['box_visibility'] ) ); update_post_meta( $post_id, 'box_weight', sanitize_text_field( $_POST['box_weight'] ) ); update_post_meta( $post_id, 'css_class', sanitize_text_field( $_POST['css_class'] ) ); update_post_meta( $post_id, 'css_id', sanitize_text_field( $_POST['css_id'] ) ); update_post_meta( $post_id, 'padding_top', sanitize_text_field( $_POST['padding_top'] ) ); update_post_meta( $post_id, 'padding_bottom', sanitize_text_field( $_POST['padding_bottom'] ) ); } public function enqueue_admin_scripts() { wp_register_style( 'awv-admin-style', AWV_DIR_URL . '/assets/css/admin.css', AWV_VERSION ); wp_register_script( 'awv-admin-script', AWV_DIR_URL . '/assets/js/admin.js', array( 'jquery', 'jquery-ui-sortable', 'wp-util' ), AWV_VERSION, true ); } public function sanitize_array( $data = array() ) { if (!is_array( $data ) || ! count( $data ) ) { return array(); } foreach ($data as $k => $v) { if (!is_array($v) && !is_object($v)) { $data[$k] = sanitize_text_field($v); } if (is_array($v)) { $data[$k] = $this->sanitize_array($v); } } return $data; } } new AWV_Admin();