"", "asp_suggested_instances" => 0 ); /** * Hook into the appropriate actions when the class is constructed. */ public function __construct() { add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); add_action( 'save_post', array( $this, 'save' ) ); add_action( 'edit_attachment', array( $this, 'save' ) ); } /** * Adds the meta box container. */ public function add_meta_box( $post_type ) { $post_types = wd_asp()->o['asp_compatibility']['meta_box_post_types']; //Allow only for selected post types $post_types = explode('|', $post_types); if ( count($post_types) > 0 && in_array( $post_type, $post_types )) { wp_register_style('wpdreams-style', ASP_URL_NP . 'backend/settings/assets/style.css', array(), ASP_CURR_VER_STRING); wp_enqueue_style('wpdreams-style'); add_meta_box( 'asp_metadata' ,__( 'Ajax Search Pro settings', 'ajax-search-pro' ) ,array( $this, 'render_meta_box_content' ) ,$post_type ,'advanced' ,'high' ); } } /** * Save the meta when the post is saved. * * @param int $post_id The ID of the post being saved. * @return int $post_id */ public function save( $post_id ) { /* * We need to verify this came from the our screen and with proper authorization, * because save_post can be triggered at other times. */ // Check if our nonce is set. if ( ! isset( $_POST['asp_meta_custom_box_nonce'] ) ) return $post_id; $nonce = $_POST['asp_meta_custom_box_nonce']; // Verify that the nonce is valid. if ( ! wp_verify_nonce( $nonce, 'asp_meta_custom_box' ) ) return $post_id; // If this is an autosave, our form has not been submitted, // so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; // Check the user's permissions. if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id; } $posted = array(); // Gather the posted data, but only the ones related to ASP foreach ( $this->asp_default_metadata as $k => $v) { if ( isset($_POST[$k]) ) $posted[$k] = $_POST[$k]; } // If it is the defaults, no need to store it at all. if ($posted == $this->asp_default_metadata) { delete_post_meta($post_id, '_asp_metadata'); } else { update_post_meta( $post_id, '_asp_metadata', $posted ); } if ( isset($_POST['asp_additional_tags']) ) { $blog_id = "x1"; if ( is_multisite() ) $blog_id = "x" . get_current_blog_id(); $add_tags = trim( preg_replace('/\s+/', ' ',$_POST['asp_additional_tags']) ); $add_tags = str_replace(array(',,'), ',', $add_tags); $add_tags = str_replace(array(', ,'), ',', $add_tags); if ( empty($add_tags) ) { delete_post_meta($post_id, '_asp_additional_tags'); foreach (array_keys(wd_asp()->o['asp_glob']['additional_tag_posts'], $post_id.$blog_id, true) as $key) { unset(wd_asp()->o['asp_glob']['additional_tag_posts'][$key]); } } else { update_post_meta($post_id, '_asp_additional_tags', $add_tags); if ( !in_array($post_id.$blog_id, wd_asp()->o['asp_glob']['additional_tag_posts'])) wd_asp()->o['asp_glob']['additional_tag_posts'][] = $post_id.$blog_id; } asp_save_option('asp_glob', true); } if ( isset($_POST['asp_negative_keywords']) ) { $negative_keywords = str_replace(array(', ', ','), ' ', $_POST['asp_negative_keywords']); $negative_keywords = trim( preg_replace('/\s+/', ' ',$negative_keywords) ); if ( empty($negative_keywords) ) { delete_post_meta($post_id, '_asp_negative_keywords'); } else { update_post_meta($post_id, '_asp_negative_keywords', $negative_keywords); } } return $post_id; } /** * Render Meta Box content. * * @param WP_Post $post The post object. */ public function render_meta_box_content( $post ) { // Add an nonce field so we can check for it later. wp_nonce_field( 'asp_meta_custom_box', 'asp_meta_custom_box_nonce' ); // Use get_post_meta to retrieve an existing value from the database. $asp_metadata = get_post_meta( $post->ID, '_asp_metadata', true ); if ( !is_array($asp_metadata) ) $asp_metadata = array(); $asp_metadata = array_merge($this->asp_default_metadata, $asp_metadata); ?>

index table engine!', 'ajax-search-pro'), 'https://documentation.ajaxsearchpro.com/index-table'); ?>  


">