plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Plugin_Name_Loader as all of the hooks are defined * in that particular class. * * The Plugin_Name_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/add-meta-tag-for-wordpress-admin.css', array(), $this->version, 'all'); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Plugin_Name_Loader as all of the hooks are defined * in that particular class. * * The Plugin_Name_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/add-meta-tag-for-wordpress-admin.js', array('jquery'), $this->version, false); wp_enqueue_script($this->plugin_name . 'charcounter', plugin_dir_url(__FILE__) . 'js/jquery.charcounter.js', array('jquery'), $this->version, false); } public function registermetaboxpostpage($post_type, $post) { $is_enable = get_option('enable_tag'); $is_page = get_option('enable_page_tag'); $is_post = get_option('enable_post_tag'); $screen = get_current_screen(); if ($is_enable == "yes") { if ((strtolower(trim($screen->id)) == "page") && ($is_page == "yes")) { add_meta_box( 'my-meta-box', __('Metadata(by Add-Meta-Tag-For-WordPress)'), array($this, 'render_add_meta_tag_for_wordpress'), $post_type, 'normal', 'default' ); } if ((strtolower(trim($screen->id)) == "post") && ($is_post == "yes")) { add_meta_box( 'my-meta-box', __('Metadata(by Add-Meta-Tag-For-WordPress)'), array($this, 'render_add_meta_tag_for_wordpress'), $post_type, 'normal', 'default' ); } } } /* Add fied in meta box */ public function render_add_meta_tag_for_wordpress($post_type) { global $post; $meta = get_post_meta($post->ID, 'add_meta_tag_for_wordpress', TRUE); $title_field_value = ''; $meta_keyword_value = ''; $meta_description_value = ''; if (is_array($meta)) { $title_field_value = ($meta['meta_title']) ? $meta['meta_title'] : ''; $meta_keyword_value = ($meta['meta_keyword']) ? $meta['meta_keyword'] : ''; $meta_description_value = ($meta['meta_description']) ? $meta['meta_description'] : ''; } print('


' . __('Enter a custom title to be used in the title HTML element of the page', 'add-meta-tag-for-wordpress') . '


' . __('Enter keywords separated with commas.', 'add-meta-tag-for-wordpress') . '


' . __('Enter a custom description.', 'add-meta-tag-for-wordpress') . '

'); } /* save meta box */ public function save_meta_tag_for_wordpress($post_id) { $drafts = array( 'meta_title' => $_POST['meta_title'], 'meta_keyword' => $_POST['meta_keyword'], 'meta_description' => $_POST['meta_description'] ); update_post_meta($post_id, 'add_meta_tag_for_wordpress', $drafts); } }