post_type != 'awl-labels' ) { return $post_id; } if ( ! isset( $_POST['awl_label_params'] ) ) { return $post_id; } $label = $_POST['awl_label_params']; //$label['conditions'] = wpc_sanitize_conditions( $_POST['conditions'] ); if ( isset( $label['awl_label_priority'] ) ) { update_post_meta( $post_id, '_awl_label_priority', sanitize_text_field( $label['awl_label_priority']['priority'] ) ); } if ( ! isset( $label['awl_label_status'] ) ) { $label['awl_label_status']['status'] = '0'; } update_post_meta( $post_id, '_awl_label', $label ); } /* * Meta box settings for labels rules */ public function metabox_show_rules() { global $post; wp_nonce_field( 'awl_label_meta_box', 'awl_label_meta_box_nonce' ); $label = get_post_meta( $post->ID, '_awl_label', true ); $html = AWL_Admin_Meta_Boxes::get_rules_meta_box( $label ); echo $html; } /* * Meta box settings for labels */ public function metabox_show_settings() { global $post; $label = get_post_meta( $post->ID, '_awl_label', true ); $html = AWL_Admin_Meta_Boxes::get_settings_meta_box( $label ); echo $html; } /* * Meta box status for labels */ public function metabox_show_status() { global $post; $label = get_post_meta( $post->ID, '_awl_label', true ); $html = AWL_Admin_Meta_Boxes::get_status_meta_box( $label ); echo $html; } /* * Meta box priority for labels */ public function metabox_show_priority() { global $post; $label = get_post_meta( $post->ID, '_awl_label', true ); $html = AWL_Admin_Meta_Boxes::get_priority_meta_box( $post->ID ); echo $html; } /** * Generate and display options page */ public function display_admin_page() { $options = AWL_Admin_Options::options_array(); $nonce = wp_create_nonce( 'plugin-settings' ); $admin_page = new AWL_Admin_Page( $options, $nonce ); $admin_page->generate_page(); } /* * Register plugin settings */ public function register_settings() { register_setting( 'awl_settings', 'awl_settings' ); } /* * Enqueue admin scripts and styles */ public function admin_enqueue_scripts() { $screen = get_current_screen(); if ( ( isset( $_GET['page'] ) && $_GET['page'] == 'awl-options' ) || ( $screen && $screen->post_type && $screen->post_type === 'awl-labels' ) ) { wp_register_script( 'jquery-tiptip', AWL_URL . '/assets/js/jquery.tipTip.js', array( 'jquery' ), AWL_VERSION, true ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_style( 'awl-admin-style', AWL_URL . '/assets/css/admin.css', array(), AWL_VERSION ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-tiptip' ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker-alpha', AWL_URL . '/assets/js/wp-color-picker-alpha.js', array('jquery', 'wp-color-picker' ), AWL_VERSION ); wp_enqueue_script( 'awl-admin-scripts', AWL_URL . '/assets/js/admin.js', array('jquery', 'wp-color-picker' ), AWL_VERSION ); wp_enqueue_script( 'awl-admin-preview', AWL_URL . '/assets/js/admin-preview.js', array('jquery', 'wp-color-picker' ), AWL_VERSION ); wp_localize_script( 'awl-admin-scripts', 'awl_vars', array( 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 'ajax_nonce' => wp_create_nonce( 'awl_admin_ajax_nonce' ), 'img_url' => AWL_IMG ) ); } } } endif; add_action( 'init', 'AWL_Admin::instance' );