(bool) get_option( 'noindex_seo_error' ), 'archive' => (bool) get_option( 'noindex_seo_archive' ), 'attachment' => (bool) get_option( 'noindex_seo_attachment' ), 'author' => (bool) get_option( 'noindex_seo_author' ), 'category' => (bool) get_option( 'noindex_seo_category' ), 'comment_feed' => (bool) get_option( 'noindex_seo_comment_feed' ), 'customize_preview' => (bool) get_option( 'noindex_seo_customize_preview' ), 'date' => (bool) get_option( 'noindex_seo_date' ), 'day' => (bool) get_option( 'noindex_seo_day' ), 'feed' => (bool) get_option( 'noindex_seo_feed' ), 'front_page' => (bool) get_option( 'noindex_seo_front_page' ), 'home' => (bool) get_option( 'noindex_seo_home' ), 'month' => (bool) get_option( 'noindex_seo_month' ), 'page' => (bool) get_option( 'noindex_seo_page' ), 'paged' => (bool) get_option( 'noindex_seo_paged' ), 'post_type_archive' => (bool) get_option( 'noindex_seo_post_type_archive' ), 'preview' => (bool) get_option( 'noindex_seo_preview' ), 'privacy_policy' => (bool) get_option( 'noindex_seo_privacy_policy' ), 'robots' => (bool) get_option( 'noindex_seo_robots' ), 'search' => (bool) get_option( 'noindex_seo_search' ), 'single' => (bool) get_option( 'noindex_seo_single' ), 'singular' => (bool) get_option( 'noindex_seo_singular' ), 'tag' => (bool) get_option( 'noindex_seo_tag' ), 'time' => (bool) get_option( 'noindex_seo_time' ), 'year' => (bool) get_option( 'noindex_seo_year' ), ); $enter = true; /* GLOBAL IMPORTANT PAGES */ if ( $enter && $noindex_seo_values['front_page'] && function_exists( 'is_front_page' ) && is_front_page() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['home'] && function_exists( 'is_home' ) && is_home() ) { noindex_seo_metarobots(); $enter = false; } /* PAGES / POSTS */ if ( $enter && $noindex_seo_values['page'] && function_exists( 'is_page' ) && is_page() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['privacy_policy'] && function_exists( 'is_privacy_policy' ) && is_privacy_policy() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['single'] && function_exists( 'is_single' ) && is_single() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['singular'] && function_exists( 'is_singular' ) && is_singular() ) { noindex_seo_metarobots(); $enter = false; } /* CATEGORIES / TAGS */ if ( $enter && $noindex_seo_values['category'] && function_exists( 'is_category' ) && is_category() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['tag'] && function_exists( 'is_tag' ) && is_tag() ) { noindex_seo_metarobots(); $enter = false; } /* DATES */ if ( $enter && $noindex_seo_values['date'] && function_exists( 'is_date' ) && is_date() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['day'] && function_exists( 'is_day' ) && is_day() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['month'] && function_exists( 'is_month' ) && is_month() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['time'] && function_exists( 'is_time' ) && is_time() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['year'] && function_exists( 'is_year' ) && is_year() ) { noindex_seo_metarobots(); $enter = false; } /* ARCHIVE */ if ( $enter && $noindex_seo_values['archive'] && function_exists( 'is_archive' ) && is_archive() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['author'] && function_exists( 'is_author' ) && is_author() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['post_type_archive'] && function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) { noindex_seo_metarobots(); $enter = false; } /* PAGINATION */ if ( $enter && $noindex_seo_values['paged'] && function_exists( 'is_paged' ) && is_paged() ) { noindex_seo_metarobots(); $enter = false; } /* SEARCH */ if ( $enter && $noindex_seo_values['search'] && function_exists( 'is_search' ) && is_search() ) { noindex_seo_metarobots(); $enter = false; } /* ATTACHMENT */ if ( $enter && $noindex_seo_values['attachment'] && function_exists( 'is_attachment' ) && is_attachment() ) { noindex_seo_metarobots(); $enter = false; } /* PREVIEW */ if ( $enter && $noindex_seo_values['customize_preview'] && function_exists( 'is_customize_preview' ) && is_customize_preview() ) { noindex_seo_metarobots(); $enter = false; } if ( $enter && $noindex_seo_values['preview'] && function_exists( 'is_preview' ) && is_preview() ) { noindex_seo_metarobots(); $enter = false; } /* ERROR */ if ( $enter && $noindex_seo_values['error'] && function_exists( 'is_404' ) && is_404() ) { noindex_seo_metarobots(); $enter = false; } unset( $enter, $noindex_seo_values ); } /** * Outputs a 'noindex' meta robots tag to the page. * * This function prints the 'noindex' meta robots tag, instructing search engines * not to index the content of the current page. * * @since 1.0.0 * * @return void * * @uses echo Outputs the meta robots tag to the webpage. */ function noindex_seo_metarobots() { echo '' . "\n"; } add_action( 'wp_head', 'noindex_seo_show' ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'noindex_seo_settings_link' ); add_action( 'admin_init', 'noindex_seo_register' ); add_action( 'admin_menu', 'noindex_seo_menu' ); /** * Adds a 'Settings' link to the plugin action links on the plugins page. * * This function appends a direct link to the plugin's settings page within the WordPress admin dashboard, * making it easier for users to access and configure the plugin settings. * * @since 1.0.0 * * @param array $links An array of action links already present for the plugin. * * @return array Returns the updated array of action links including the 'Settings' link. * * @uses get_admin_url() Fetches the admin URL for the current site with optional path attached. * @uses __() Retrieves a translated string. */ function noindex_seo_settings_link( $links ) { $links[] = '' . __( 'Settings' ) . ''; return $links; } /** * Adds a 'noindex SEO' options page to the WordPress admin menu. * * This function creates an options page titled 'noindex SEO' within the WordPress admin dashboard. * The page provides a UI for configuring settings related to the 'noindex SEO' functionality. * * @since 1.0.0 * * @return void * * @uses add_options_page() Adds a new options page to the admin menu. * @uses __() Retrieves a translated string. */ function noindex_seo_menu() { add_options_page( __( 'noindex SEO', 'noindex-seo' ), __( 'noindex SEO', 'noindex-seo' ), 'manage_options', 'noindex_seo', 'noindex_seo_admin' ); } /** * Registers settings for the 'noindex SEO' plugin. * * This function registers a variety of settings associated with the 'noindex SEO' functionality in WordPress. * Each setting determines whether specific pages or post types should be excluded from search engine indexing. * The settings values are integers, with a default value of 0 (which typically represents 'false' or 'off' in boolean context). * * @since 1.0.0 * * @return void * * @uses register_setting() Registers a setting and its data. */ function noindex_seo_register() { register_setting( 'noindexseo', 'noindex_seo_error', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_archive', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_attachment', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_author', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_category', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_comment_feed', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_customize_preview', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_date', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_day', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_feed', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_front_page', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_home', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_month', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_page', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_paged', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_post_type_archive', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_preview', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_privacy_policy', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_robots', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_search', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_single', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_singular', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_tag', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_time', array( 'type' => 'integer', 'default' => 0, ) ); register_setting( 'noindexseo', 'noindex_seo_year', array( 'type' => 'integer', 'default' => 0, ) ); } /** * Displays the administration settings page for the 'noindex SEO' plugin. * * This function provides the markup for the settings page of the plugin in the WordPress admin area. * It shows the header for the settings, followed by the form that contains the settings fields. * Each setting determines if specific pages or post types should be excluded from search engine indexing. * The options are retrieved from the WordPress database and are displayed on the form. * * @since 1.0.0 * * @return void * * @uses settings_fields() Outputs nonce, action, and option_page fields for a settings page in the form. * @uses get_option() Retrieves option value based on option name from WordPress database. */ function noindex_seo_admin() { ?>