esc_html__('Home', 'siteseo'), 'tab_siteseo_post_types' => esc_html__('Post types', 'siteseo'), 'tab_siteseo_archives' => esc_html__('Archives', 'siteseo'), 'tab_siteseo_taxonomies' => esc_html__('Taxonomies', 'siteseo'), 'tab_siteseo_advanced' => esc_html__('Advanced','siteseo') ]; echo '
'; Util::admin_header(); echo '
'; wp_nonce_field('siteseo_title_settings'); $titles_meta_toggle = isset($siteseo->setting_enabled['toggle-titles']) ? $siteseo->setting_enabled['toggle-titles'] : ''; $nonce = wp_create_nonce('siteseo_toggle_nonce'); Util::render_toggle('Titles & Metas - SiteSEO', 'titles_meta_toggle', $titles_meta_toggle, $nonce); echo '
'; self::advanced(); echo '
'; Util::submit_btn(); echo '
'; } static function home(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } $options = get_option('siteseo_titles_option_name'); //$options = $siteseo->titles_settings; $option_separator = !empty($options['titles_sep']) ? $options['titles_sep'] : ''; $option_site_title = !empty($options['titles_home_site_title']) ? $options['titles_home_site_title'] : ''; $option_site_title_alt = !empty($options['titles_home_site_title_alt']) ? $options['titles_home_site_title_alt'] : ''; $option_site_desc = !empty($options['titles_home_site_desc']) ? $options['titles_home_site_desc'] : ''; echo '

'.esc_html__('HOME','siteseo').'

 

'.esc_html__('Search engines use the title and meta description to create a snippet of your site for the search results page.', 'siteseo').'

'.esc_html__('Personalize the title and meta description for your homepage.','siteseo').'

'.esc_html__('Incorrect meta title or description appearing in search results?', 'siteseo').'
'.esc_html__('Separator','siteseo').'

'.esc_attr__('Include this separator using %%sep%% in your title and meta description.','siteseo').'

'.esc_html__('Site title','siteseo').'
'; siteseo_suggestion_button(); echo '
'.esc_html__('Alternative site title','siteseo').'

'.esc_html__('The alternative name of the website (e.g., a commonly recognized acronym or shorter name, if applicable). Ensure the name meets the criteria.', 'siteseo').'

'.esc_html__('Meta description','siteseo').'
'; siteseo_suggestion_button(); echo '
'; } static function advanced(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } //$options = $siteseo->titles_settings; $options = get_option('siteseo_titles_option_name'); $option_noindex = !empty($options['titles_noindex']) ? $options['titles_noindex'] : ''; $option_nofollow = !empty($options['titles_nofollow']) ? $options['titles_nofollow'] : ''; $option_noimage = !empty($options['titles_noimageindex']) ? $options['titles_noimageindex'] : ''; $option_noarchive = !empty($options['titles_noarchive']) ? $options['titles_noarchive'] : ''; $option_nosnippet = !empty($options['titles_nosnippet']) ? $options['titles_nosnippet'] : ''; $option_nositelinkssearchbox = !empty($options['titles_nositelinkssearchbox']) ? $options['titles_nositelinkssearchbox'] : ''; $option_page_rel = !empty($options['titles_paged_rel']) ? $options['titles_paged_rel'] : ''; $option_paged_noindex = !empty($options['titles_paged_noindex']) ? $options['titles_paged_noindex'] : ''; $option_attachments_noindex = !empty($options['titles_attachments_noindex']) ? $options['titles_attachments_noindex'] : ''; echo '

'.esc_html__('Advanced','siteseo').'

'.esc_html__('Customize your metas for all pages','siteseo').'

'.esc_html__('noindex','siteseo').'

'.esc_attr__('Do not show all pages of the site in Google search results and avoid displaying "Cached" links in search results.','siteseo').'

'.wp_kses_post('

Check also the"Search engine visibility" setting from the WordPress Reading page

','siteseo').'
'.esc_html__('nofollow','siteseo').'

'.esc_html__('Do not follow links on all pages.','siteseo').'

'.esc_html__('noimageindex','siteseo').'

'.esc_html__('Do not follow links on any pages.','siteseo').'

'.esc_html__('noarchive','siteseo').'

'.esc_html__('Do not show a "Cached" link in Google search results.','siteseo').'

'.esc_html__('nosnippet','siteseo').'

'.esc_html__('Do not show a description in the Google search results for any pages.','siteseo').'

'.esc_html__('nositelinkssearchbox','siteseo').'

'.esc_html__('Prevents Google from displaying a sitelinks search box in search results. Enabling this option will remove the "Website" schema from your source code.','siteseo') .'

'.esc_html__('Indicate paginated content to Google','siteseo').'

'.esc_html__('eg: https://example.com/category/my-category/page/2/.','siteseo').'

'.esc_html__('noindex on paged archives','siteseo').'

'.esc_html__('eg: https://example.com/category/my-category/page/2/.','siteseo').'

'.esc_html__('noindex on attachment pages','siteseo').'

'.esc_html__('eg: https://example.com/my-media-attachment-page.','siteseo').'

'; } static function archives(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } // $options = $siteseo->titles_settings; $options = get_option('siteseo_titles_option_name'); // Load settings $option_author_title = !empty($options['titles_archives_author_title']) ? $options['titles_archives_author_title'] : ''; $option_author_desc = !empty($options['titles_archives_author_desc']) ? $options['titles_archives_author_desc'] : ''; $option_author_noindex = !empty($options['titles_archives_author_noindex']) ? $options['titles_archives_author_noindex'] : ''; $option_author_disabled = !empty($options['titles_archives_author_disable']) ? $options['titles_archives_author_disable'] : ''; $option_date_title = !empty($options['titles_archives_date_title']) ? $options['titles_archives_date_title'] : ''; $option_date_desc = !empty($options['titles_archives_date_desc']) ? $options['titles_archives_date_desc'] : ''; $option_date_noindex = !empty($options['titles_archives_date_noindex']) ? $options['titles_archives_date_noindex'] : ''; $option_date_disabled = !empty($options['titles_archives_date_disable']) ? $options['titles_archives_date_disable'] : ''; $option_search_title = !empty($options['titles_archives_search_title']) ? $options['titles_archives_search_title'] : ''; $option_search_desc = !empty($options['titles_archives_search_desc']) ? $options['titles_archives_search_desc'] : ''; $option_search_noindex = !empty($options['titles_archives_search_title_noindex']) ? $options['titles_archives_search_title_noindex'] : ''; $option_404_title = !empty($options['titles_archives_404_title']) ? $options['titles_archives_404_title'] : ''; $option_404_desc = !empty($options['titles_archives_404_desc']) ? $options['titles_archives_404_desc'] : ''; $archives_fields = [ 'author-archives' => 'Author archives', 'date-archives' => 'Date archives', 'search-archives' => 'Search archives', '404-archives' => '404 archives' ]; echo '
'; $is_first = true; foreach($archives_fields as $post_key => $post_val){ $active_class = $is_first ? 'active' : ''; echo '' . esc_html($post_val) . ''; $is_first = false; } echo '

'.esc_html__('Archives','siteseo').'

'.esc_html__('Personalize your meta descriptions for all archives.','siteseo').'

'.esc_html__('Author archives','siteseo').'

'.esc_html__('Title template','siteseo').'

'; siteseo_suggestion_button(); echo '

Meta description template


'.esc_html__('Date archives','siteseo').'

'.esc_html__('Title template','siteseo').'

'; siteseo_suggestion_button(); echo '

'.esc_html__('Meta description template','siteseo').'


Search archives

'.esc_html__('Title template','siteseo').'

'; siteseo_suggestion_button(); echo '

'.esc_html__('Meta description template','siteseo').'


404 archives

'.esc_html__('Title template','siteseo').'

'; siteseo_suggestion_button(); echo '

'.esc_html__('Meta description template','siteseo').'


'; } static function post_types(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } $options = get_option('siteseo_titles_option_name'); $post_types = siteseo_post_types(); echo '
'; $is_first = true; foreach($post_types as $post_type => $post_arr){ $active_class = $is_first ? 'active' : ''; echo ''.esc_html($post_arr->labels->name).''; $is_first = false; } echo '

'.esc_html__('Post Types', 'siteseo').'

'.esc_html__('Personalize your titles and meta descriptions for single custom post types.', 'siteseo').'

'; /* if(empty($option_post_title)){ echo '
 

'.wp_kses_post(__('Some Custom Post Types have no meta title set! We strongly encourage you to add one by filling in the fields below.', 'siteseo')).'

  1. '.esc_html__('post_tag', 'siteseo').'
'; } if(empty($option_page_desc)){ echo '
 

'.wp_kses_post(__('Some Custom Post Types have no meta description set! We strongly encourage you to add one by filling in the fields below..', 'siteseo')).'

  1. '.esc_html__('post_tag', 'siteseo').'
'; } */ foreach($post_types as $post_type => $post_arr){ // Load array $post_data = isset($options['titles_single_titles'][$post_type]) ? $options['titles_single_titles'][$post_type] : ''; // Load settings $option_post_disabled = !empty($post_data['disabled']) ? true : false; $option_post_title = !empty($post_data['title']) ? $post_data['title'] : ''; $option_post_desc = !empty($post_data['description']) ? $post_data['description'] : ''; $option_noindex = !empty($post_data['noindex']) ? $post_data['noindex'] : ''; $option_nofollow = !empty($post_data['nofollow']) ? $post_data['nofollow'] : ''; $option_date = !empty($post_data['date']) ? $post_data['date'] : ''; $option_thumb_gcs = !empty($post_data['thumb_gcs']) ? $post_data['thumb_gcs'] : ''; echo '
'; echo '

'.esc_html($post_arr->labels->name.' ['.$post_type.']').'

  

'.(!$option_post_disabled ? ' Click to hide any SEO metaboxes / columns for this post type' : ' Click to show any SEO metaboxes / columns for this post type').'

'.esc_html__('Title template', 'siteseo').'

'; siteseo_suggestion_button(); echo '

'.esc_html__('Meta description template', 'siteseo').'

'; siteseo_suggestion_button(); echo '
'; if(!empty($option_noindex)){ echo '

'.wp_kses_post(__('This custom post type is NOT excluded from your XML sitemaps despite the fact that it is set to NOINDEX.', 'siteseo')).'

'; } echo '

'. esc_html__('Unchecking this does not prevent Google from displaying the post date in search results.', 'siteseo').'

'.esc_html__('This option does not apply to traditional search results.', 'siteseo').'

'; } echo '
'; } static function taxonomies(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } // $options = $siteseo->titles_setting; $options = get_option('siteseo_titles_option_name'); $taxonomies = get_taxonomies(['show_ui' => true, 'public' => true], 'objects', 'and'); echo '
'; $is_first = true; foreach($taxonomies as $fields_key => $fields_val){ $active_class = $is_first ? 'active' : ''; echo ''.esc_html($fields_val->label).''; $is_first = false; } echo '

'.esc_html__('Taxonomies','siteseo').'

'.esc_html__('Personalize your meta descriptions for all taxonomy archives.','siteseo').'

'; // if(empty($option_cat_title)){ // echo '
//
//   //
//

'.wp_kses_post(__('Some Custom Taxonomies have no meta title set! We highly recommend adding one by completing the fields below.', 'siteseo')).'

//
    //
  1. '.esc_html__('post_tag', 'siteseo').'
  2. //
//
//
//
'; // } // if(empty($option_tag_desc)){ // echo '
//   //
//

'.wp_kses_post(__('Some Custom Taxonomies have no meta description set! We highly recommend adding one by filling in the fields below.', 'siteseo')).'

//
    //
  1. '.esc_html__('post_tag', 'siteseo').'
  2. //
//
//
'; // } foreach($taxonomies as $taxonomy => $_tax){ // Load array $options_tax = isset($options['titles_tax_titles'][$taxonomy]) ? $options['titles_tax_titles'][$taxonomy] : ''; // Load settings $option_disabled_category = !empty($options_tax['disabled']) ? $options_tax['disabled'] : ''; $option_cat_title = !empty($options_tax['title']) ? $options_tax['title'] : ''; $option_cat_desc = !empty($options_tax['description']) ? $options_tax['description'] : ''; $option_cat_noindex = !empty($options_tax['noindex']) ? $options_tax['noindex'] : ''; $option_cat_nofollow = !empty($options_tax['nofollow']) ? $options_tax['nofollow'] : ''; $taxonomies_fields = [ 'categories-types' => 'Categories', 'tags-types' => 'Tags', ]; echo '

'.esc_html($_tax->label.'['.$taxonomy.']').'

' .($option_disabled_category ? 'Enable' : 'Disable'). '

'.esc_html__('Title template','siteseo').'

'; siteseo_suggestion_button(); echo '

Meta description template

'; siteseo_suggestion_button(); echo '
'; if(!empty($option_cat_noindex)){ echo '

'.wp_kses_post(__('This custom taxonomy is NOT excluded from your XML sitemaps despite the fact that it is set to NOINDEX. We recommend that you check this out.', 'siteseo')).'

'; } echo '
'; } echo '
'; } static function save_settings(){ global $siteseo; check_admin_referer('siteseo_title_settings'); if(!current_user_can('siteseo_manage') || !is_admin()){ return; } $options = []; if(empty($_POST['siteseo_options'])){ return; } if(isset($_POST['siteseo_options']['home_tab'])){ $options['titles_sep'] = isset($_POST['siteseo_options']['separator']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['separator'])) : ''; $options['titles_home_site_title'] = isset($_POST['siteseo_options']['site_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['site_title'])) : ''; $options['titles_home_site_title_alt'] = isset($_POST['siteseo_options']['alt_site_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['alt_site_title'])) : ''; $options['titles_home_site_desc'] = isset($_POST['siteseo_options']['media_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['media_desc'])) : ''; } if(isset($_POST['siteseo_options']['advanced_tab'])){ $options['titles_noindex'] = isset($_POST['siteseo_options']['noindex']); $options['titles_nofollow'] = isset($_POST['siteseo_options']['no_follow']); $options['titles_noimageindex'] = isset($_POST['siteseo_options']['no_image']); $options['titles_noarchive'] = isset($_POST['siteseo_options']['no_archive']); $options['titles_nosnippet'] = isset($_POST['siteseo_options']['no_snippet']); $options['titles_nositelinkssearchbox'] = isset($_POST['siteseo_options']['no_site_links_searchbox']); $options['titles_paged_rel'] = isset($_POST['siteseo_options']['page_rel']); $options['titles_paged_noindex'] = isset($_POST['siteseo_options']['titles_paged_noindex']); $options['titles_attachments_noindex'] = isset($_POST['siteseo_options']['attachments_noindex']); } if(isset($_POST['siteseo_options']['post_types_tab'])){ $post_types = siteseo_post_types(); $post_types = array_keys($post_types); // Saving Posts foreach($post_types as $post_type){ $options['titles_single_titles'][$post_type]['disabled'] = !empty($_POST['siteseo_options'][$post_type]['disabled']) ? true : false; $options['titles_single_titles'][$post_type]['title'] = isset($_POST['siteseo_options'][$post_type]['title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['title'])) : ''; $options['titles_single_titles'][$post_type]['description'] = isset($_POST['siteseo_options'][$post_type]['desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$post_type]['desc'])) : ''; $options['titles_single_titles'][$post_type]['noindex'] = isset($_POST['siteseo_options'][$post_type]['noindex']); $options['titles_single_titles'][$post_type]['nofollow'] = isset($_POST['siteseo_options'][$post_type]['nofollow']); $options['titles_single_titles'][$post_type]['date'] = isset($_POST['siteseo_options'][$post_type]['date']); $options['titles_single_titles'][$post_type]['thumb_gcs'] = isset($_POST['siteseo_options'][$post_type]['thumb_gcs']); } } if(isset($_POST['siteseo_options']['archives_tab'])){ $options['titles_archives_author_title'] = isset($_POST['siteseo_options']['author_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['author_title'])) : ''; $options['titles_archives_author_desc'] = isset($_POST['siteseo_options']['author_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['author_desc'])) : ''; $options['titles_archives_author_noindex'] = isset($_POST['siteseo_options']['author_noindex']); $options['titles_archives_author_disable'] = isset($_POST['siteseo_options']['author_disable']); $options['titles_archives_date_title'] = isset($_POST['siteseo_options']['date_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['date_title'])) : ''; $options['titles_archives_date_desc'] = isset($_POST['siteseo_options']['date_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['date_desc'])) : ''; $options['titles_archives_date_noindex'] = isset($_POST['siteseo_options']['date_noindex']); $options['titles_archives_date_disable'] = isset($_POST['siteseo_options']['date_disable']); $options['titles_archives_search_title'] = isset($_POST['siteseo_options']['search_title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['search_title'])) : ''; $options['titles_archives_search_desc'] = isset($_POST['siteseo_options']['search_desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['search_desc'])) : ''; $options['titles_archives_search_title_noindex'] = isset($_POST['siteseo_options']['search_noindex']); $options['titles_archives_404_title'] = isset($_POST['siteseo_options']['title_404']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['title_404'])) : ''; $options['titles_archives_404_desc'] = isset($_POST['siteseo_options']['desc_404']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['desc_404'])) : ''; } if(isset($_POST['siteseo_options']['taxonomies_tab'])){ $taxonomies = get_taxonomies(['show_ui' => true, 'public' => true], 'objects', 'and'); $taxonomies = array_keys($taxonomies); foreach($taxonomies as $taxonomy){ $options['titles_tax_titles'][$taxonomy]['disabled'] = !empty($_POST['siteseo_options'][$taxonomy]['disabled']) ? true : false; $options['titles_tax_titles'][$taxonomy]['title'] = isset($_POST['siteseo_options'][$taxonomy]['title']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$taxonomy]['title'])) : ''; $options['titles_tax_titles'][$taxonomy]['description'] = isset($_POST['siteseo_options'][$taxonomy]['desc']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options'][$taxonomy]['desc'])) : ''; $options['titles_tax_titles'][$taxonomy]['noindex'] = isset($_POST['siteseo_options'][$taxonomy]['noindex']); $options['titles_tax_titles'][$taxonomy]['nofollow'] = isset($_POST['siteseo_options'][$taxonomy]['nofollow']); } } update_option('siteseo_titles_option_name', $options); } }