%title% to include the original title or leave empty to keep original title.%title%', 'add-meta-tags' ) ),
'mt_seo_description' => array( __( 'Description (optional) :', 'add-meta-tags' ), 'textarea', __( 'This text will be used as description meta information. Left empty a description is automatically generated%cats% can be used to insert the post\'s categories, add the tag %tags%, to include the post\'s tags.' . $msg . '
'.__('This is where you can configure the Add-Meta-Tags plugin and read about how the plugin adds META tags in the WordPress pages.', 'add-meta-tags').'
'.__('Modifying any of the settings in this page is completely optional, as the plugin will add META tags automatically.', 'add-meta-tags').'
'.__("For more information about the plugin's default behaviour and how you could customize the metatag generation can be found in detail in the sections that follow.", "add-meta-tags").'
'.__('META tags are automatically added to Category Archives, for example when viewing all posts that belong to a specific category. In this case, if you have set a description for that category, then this description is added to a "description" META tag.', 'add-meta-tags').'
'.__('Furthermore, a "keywords" META tag - containing only the category\'s name - is always added to Category Archives.', 'add-meta-tags').'
';
echo '
';
echo $field_data[2] . "
';
echo '
';
echo $field_data[2] . "
' . __( 'No SEO fields were enabled. Please enable post fields in the Meta Tags options page', 'add-meta-tags' ) . '
'; wp_nonce_field( 'mt-seo', 'mt_seo_nonce', false ); } function mt_seo_save_meta( $post_id ) { global $mt_seo_fields; foreach( (array) $mt_seo_fields as $field_name => $field_data ) mt_seo_save_meta_field( $post_id, $field_name ); } function mt_seo_save_meta_field( $post_id, $field_name ) { // Checks to see if we're POSTing if ( 'post' !== strtolower( $_SERVER['REQUEST_METHOD'] ) || !isset($_POST[$field_name]) ) return; if( !isset( $_POST['post_type'] ) || !in_array( $_POST['post_type'], array( 'post', 'page' ) ) ) return; $post_type = $_POST['post_type']; // Checks to make sure we came from the right page if ( !wp_verify_nonce( $_POST['mt_seo_nonce'], 'mt-seo' ) ) return; // Checks user caps if ( !current_user_can( 'edit_' . $post_type, $post_id ) ) return; // Already have data? $old_data = get_post_meta( $post_id, $field_name, true ); // Sanitize if( 'mt_seo_meta' == $field_name ) { if ( preg_match_all( '/<[\s]*meta[\s]*name="?' . '([^>"]*)"?[\s]*' . 'content="?([^>"]*)"?[\s]*[\/]?[\s]*>/si', stripslashes( $_POST[$field_name] ), $matches ) ) { if (isset($matches) && is_array($matches) ) { foreach ( $matches[1] AS $key => $name ) $data .= "\n"; } else { $data = wp_filter_post_kses( $_POST[$field_name] ); $data = trim( stripslashes( $data ) ); } } else { $data = wp_filter_post_kses( $_POST[$field_name] ); $data = trim( stripslashes( $data ) ); } } else { $data = wp_filter_post_kses( $_POST[$field_name] ); $data = trim( stripslashes( $data ) ); } // nothing new, and we're not deleting the old if ( !$data && !$old_data ) return; // Nothing new, and we're deleting the old if ( !$data && $old_data ) { delete_post_meta( $post_id, $field_name ); return; } // Nothing to change if ( $data === $old_data ) return; // Save the data if ( $old_data ) { update_post_meta( $post_id, $field_name, $data ); } else { if ( !add_post_meta( $post_id, $field_name, $data, true ) ) update_post_meta( $post_id, $field_name, $data ); // Just in case it was deleted and saved as "" } } function add_mt_seo_box() { add_meta_box( 'mt_seo', 'SEO Settings', 'mt_seo_meta_box', 'post', 'normal' ); add_meta_box( 'mt_seo', 'SEO Settings', 'mt_seo_meta_box', 'page', 'normal' ); } function mt_seo_style() { ?> post_type ) $cmpvalues = $options['page_options']; elseif ( 'post' == $posts[0]->post_type ) $cmpvalues = $options['post_options']; if ( !is_array( $cmpvalues ) ) $cmpvalues = array( 'mt_seo_title' => 'true', 'mt_seo_description' => 'true', 'mt_seo_keywords' => 'true', 'mt_seo_meta' => 'true' ); if ( 'true' != $cmpvalues['mt_seo_title'] ) return $title; $mt_seo_title = (string) get_post_meta( $posts[0]->ID, 'mt_seo_title', true ); if ( empty( $mt_seo_title ) ) return $title; $mt_seo_title = str_replace("%title%", $title, $mt_seo_title); $mt_seo_title = strip_tags( $mt_seo_title ); return $mt_seo_title; } /* Actions */ add_action( 'save_page', 'mt_seo_save_meta' ); add_action( 'save_post', 'mt_seo_save_meta' ); add_action( 'admin_menu', 'amt_add_pages' ); add_action( 'admin_menu', 'add_mt_seo_box' ); add_action( 'wp_head', 'amt_add_meta_tags', 0 ); add_action( 'admin_head', 'mt_seo_style' ); add_filter( 'wp_title', 'mt_seo_rewrite_title', 9999, 3 ); ?>