setting_enabled['toggle-xml-sitemap']) ? $siteseo->setting_enabled['toggle-xml-sitemap'] : ''; $nonce = wp_create_nonce('siteseo_toggle_nonce'); $current_tab = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'tab_sitemap_general'; // Default tab $titles_meta_subtabs = [ 'tab_sitemap_general' => esc_html__('Home', 'siteseo'), 'tab_sitemap_post_types' => esc_html__('Post types', 'siteseo'), 'tab_sitemap_taxonomy ' => esc_html__('Taxonomy', 'siteseo'), 'tab_sitmap_html' => esc_html__('HTML Sitemap', 'siteseo') ]; echo '
'; Util::admin_header(); echo '
'; wp_nonce_field('siteseo_sitemap_settings'); Util::render_toggle('Sitemaps - SiteSEO', 'sitemap_toggle', $sitemap_toggle, $nonce); echo '
'; Util::submit_btn(); echo '
'; } static function general_sitemaps(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } //$options = $siteseo->sitemap_settings; $options = get_option('siteseo_xml_sitemap_option_name', []); $xml_sitemap = !empty($options['xml_sitemap_general_enable']) ? $options['xml_sitemap_general_enable'] : ''; $img_sitemap = !empty($options['xml_sitemap_img_enable']) ? $options['xml_sitemap_img_enable'] : ''; $author_sitemap = !empty($options['xml_sitemap_author_enable']) ? $options['xml_sitemap_author_enable'] : ''; $html_sitemap = !empty($options['xml_sitemap_html_enable']) ? $options['xml_sitemap_html_enable'] : ''; echo '

'.esc_html__('General','siteseo').'

'.esc_html__('Sitemaps are pages which help search engine, know your site better and makes it easier for them to index the pages.','siteseo').'

'.esc_html__('Not having a sitemap does not mean search engines won\'t be able to crawl your website, but sitemaps make it easier for them to discover all the URLs which are needed to be indexed.','siteseo').'

' . esc_url(get_option('home')) . '/sitemaps.xml

'. /* translators: placeholders are just tag */ wp_kses_post(sprintf(__('To view your sitemap, %1$s enable permalinks %2$s (other than the default one) and save the settings to flush them.', 'siteseo'), '', '')).'

'.esc_html__('Enable XML Sitemap','siteseo').'
'.esc_html__('Enable Image Sitemap','siteseo').'

'.esc_html__('Images in XML sitemaps are only visible from the source code.', 'siteseo').'

'.esc_html__('Enable Author Sitemap','siteseo').'

'.esc_html__('Ensure that you enable the author archive from SEO, under the Titles & Metas section, in the Archives tab.','siteseo').'

'.esc_html__('Enable HTML Sitemap','siteseo').'
'; } static function post_types_sitemaps(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } //$options = $siteseo->sitemap_settings; $options = get_option('siteseo_xml_sitemap_option_name', []); $option_sitemap_posts = !empty($options['xml_sitemap_post_types_list']['post']['include']) ? $options['xml_sitemap_post_types_list']['post']['include'] : ''; $option_sitemap_pages = !empty($options['xml_sitemap_post_types_list']['page']['include']) ? $options['xml_sitemap_post_types_list']['page']['include'] : ''; $option_sitemap_media = !empty($options['xml_sitemap_post_types_list']['media']['include']) ? $options['xml_sitemap_post_types_list']['media']['include'] : ''; $post_types = siteseo_post_types(); echo '

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

'.esc_html__('Select Post Types to Include or Exclude', 'siteseo').'

'; foreach($post_types as $post_type){ $post_type_name = $post_type->name; $post_type_label = $post_type->labels->singular_name; $option_sitemap_custom = !empty($options['xml_sitemap_post_types_list'][$post_type_name]['include']) ? 'checked="yes"' : ''; echo ''; } echo '
'; } static function taxonomy_sitemap(){ global $siteseo; if(!empty($_POST['submit'])){ self::save_settings(); } //$options = $siteseo->sitemap_settings; $get_taxonomies = get_taxonomies(['public' => true, 'show_ui' => true], 'objects'); $check_taxonomies = apply_filters('siteseo_sitemaps_tax', $get_taxonomies); $options = get_option('siteseo_xml_sitemap_option_name'); $option_category = isset($options['xml_sitemap_taxonomies_list']['category']['include']) ?? ''; $option_post_tags = isset($options['xml_sitemap_taxonomies_list']['post_tag']['include']) ?? ''; $get_taxonomies = get_taxonomies(); $check_taxomies = apply_filters('siteseo_sitemaps_tax', $get_taxonomies); $excluded_taxonomies = ['post_format', 'category', 'post_tag']; echo '

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

'.esc_html__('Select Taxonomies to Include or Exclude', 'siteseo').'

'; foreach($check_taxonomies as $taxonomy_name => $taxonomy_obj){ if(in_array($taxonomy_name, $excluded_taxonomies)){ continue; } //check selected $is_included = !empty($options['xml_sitemap_taxonomies_list'][$taxonomy_name]['include']); // Generate a row for the taxonomy echo ''; } echo '
'.esc_html__('Select to INCLUDE Taxonomies', 'siteseo').'

'; } static function html_sitemap(){ if(!empty($_POST['submit'])){ self::save_settings(); } //$options = $siteseo->$sitemap_settings; $options = get_option('siteseo_xml_sitemap_option_name', []); $include_pages = !empty($options['xml_sitemap_html_mapping']) ? $options['xml_sitemap_html_mapping'] : ''; $exclude_page = !empty($options['xml_sitemap_html_exclude']) ? $options['xml_sitemap_html_exclude'] : ''; $order = !empty($options['xml_sitemap_html_order']) ? $options['xml_sitemap_html_order'] : ''; $order_by = !empty($options['xml_sitemap_html_orderby']) ? $options['xml_sitemap_html_orderby'] : ''; $disable_date = !empty($options['xml_sitemap_html_date']) ? $options['xml_sitemap_html_date'] : ''; $remove_archive = !empty($options['xml_sitemap_html_archive_links']) ? $options['xml_sitemap_html_archive_links'] : ''; echo '

'.esc_html__('HTML Sitemap', 'siteseo').'

'.esc_html__('Generate an HTML sitemap for your visitors to improve your SEO.','siteseo').'

'.esc_html__('Restricted to 1,000 posts per post type. You can change the order and sorting settings below.','siteseo').'

'.esc_html__('How to make use of the HTML Sitemap?', 'siteseo').'

'.esc_html__('Block Editor', 'siteseo').'

'. /* translators: placeholders are just tag */ wp_kses_post(sprintf(__('Insert the HTML sitemap block via the %1$s Block Editor %2$s.', 'siteseo'), '', '')).'

'.esc_html__('Shortcode', 'siteseo').'

'.esc_html__('You can also insert this shortcode into your content (post, page, custom post type, etc.):', 'siteseo').'

'.esc_attr('[siteseo_html_sitemap]','siteseo').'

'.esc_html__('To include specific custom post types, use the CPT attribute:', 'siteseo') .'

'.esc_attr('[siteseo_html_sitemap cpt="post,product"]','siteseo').'

'.esc_html__('Other', 'siteseo').'

'.esc_html__('Display the sitemap dynamically by entering an ID in the first field below.', 'siteseo').'

'.esc_html__('Post, Page, or Custom Post Type IDs to display:','siteseo').'
'.esc_html__('Exclude Posts, Pages, Custom Post Types or Terms IDs:','siteseo').'
'.esc_html__('Order:','siteseo').'
'.esc_html__('Order By:','siteseo').'
'.esc_html__('Disable Date:','siteseo').'
'.esc_html__('Remove Archive Links:','siteseo').'
'; } static function save_settings(){ global $siteseo; check_admin_referer('siteseo_sitemap_settings'); if(!current_user_can('siteseo_manage') || !is_admin()){ return; } $options = []; if(empty($_POST['siteseo_options'])){ return; } if(isset($_POST['siteseo_options']['general_sitemaps'])){ $options['xml_sitemap_general_enable'] = isset($_POST['siteseo_options']['enable_xml_sitemap']); $options['xml_sitemap_img_enable'] = isset($_POST['siteseo_options']['enable_img_sitemap']); $options['xml_sitemap_author_enable'] = isset($_POST['siteseo_options']['enable_author_sitemap']); $options['xml_sitemap_html_enable'] = isset($_POST['siteseo_options']['enable_html_sitemap']); flush_rewrite_rules(); } if(isset($_POST['siteseo_options']['html_sitemap'])){ $options['xml_sitemap_html_mapping'] = isset($_POST['siteseo_options']['page_numbers']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['page_numbers'])) : ''; $options['xml_sitemap_html_exclude'] = isset($_POST['siteseo_options']['exclude_page']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['exclude_page'])) : ''; $options['xml_sitemap_html_order'] = isset($_POST['siteseo_options']['order'])? sanitize_text_field(wp_unslash($_POST['siteseo_options']['order'])) : ''; $options['xml_sitemap_html_orderby'] = isset($_POST['siteseo_options']['order_by']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['order_by'])) : ''; $options['xml_sitemap_html_date'] = isset($_POST['siteseo_options']['disable_date']); $options['xml_sitemap_html_archive_links'] = isset($_POST['siteseo_options']['remove_links']) ? sanitize_text_field(wp_unslash($_POST['siteseo_options']['remove_links'])) : ''; } // posts if(isset($_POST['siteseo_options']['post_types_tab'])){ if(isset($_POST['siteseo_options']['xml_sitemap_post_types_list'])){ $xml_post_types = map_deep(wp_unslash($_POST['siteseo_options']['xml_sitemap_post_types_list']), 'sanitize_text_field'); foreach($xml_post_types as $posttypes_key => $posttypes_value) { if(isset($posttypes_value['include'])) { $options['xml_sitemap_post_types_list'][$posttypes_key]['include'] = $posttypes_value['include']; } } } } // Taxonomies if(isset($_POST['siteseo_options']['taxonomy_sitemap_tabs'])){ if(isset($_POST['siteseo_options']['xml_sitemap_taxonomies_list'])){ $xml_tax_list = map_deep(wp_unslash($_POST['siteseo_options']['xml_sitemap_taxonomies_list']), 'sanitize_text_field'); foreach($xml_tax_list as $taxonomy_key => $taxonomy_value){ if(isset($taxonomy_value['include'])){ $options['xml_sitemap_taxonomies_list'][$taxonomy_key]['include'] = $taxonomy_value['include']; } } } } update_option('siteseo_xml_sitemap_option_name',$options); } }