$resp, 'time' => $now, ); if ( is_wp_error( $resp ) ) { do_action( 'wds_after_search_engine_update', 'google', false, $resp ); } else { do_action( 'wds_after_search_engine_update', 'google', (bool) ( 200 === (int) wp_remote_retrieve_response_code( $resp ) ), $resp ); } } if ( $forced || ! empty( $smartcrawl_options['ping-bing'] ) ) { do_action( 'wds_before_search_engine_update', 'bing' ); $resp = wp_remote_get( 'http://www.bing.com/webmaster/ping.aspx?sitemap=' . esc_url( smartcrawl_get_sitemap_url() ) ); $result['bing'] = array( 'response' => $resp, 'time' => $now, ); if ( is_wp_error( $resp ) ) { do_action( 'wds_after_search_engine_update', 'bing', false, $resp ); } else { do_action( 'wds_after_search_engine_update', 'bing', (bool) ( 200 === (int) wp_remote_retrieve_response_code( $resp ) ), $resp ); } } update_option( self::ENGINE_NOTIFICATION_OPTION_ID, $result ); return true; } public static function update_meta_data( $item_count ) { update_option( self::SITEMAP_META_OPTION_ID, array( 'items' => $item_count, 'time' => time(), ) ); } /** * Gets sitemap stat options * * @return array */ public static function get_meta_data() { $opts = get_option( self::SITEMAP_META_OPTION_ID ); return is_array( $opts ) ? $opts : array(); } public static function sitemap_enabled() { return Smartcrawl_Settings::get_setting( 'sitemap' ) && smartcrawl_is_allowed_tab( Smartcrawl_Settings::TAB_SITEMAP ); } public static function sitemap_images_enabled() { return (boolean) self::get_sitemap_option( 'sitemap-images' ) && ! smartcrawl_is_switch_active( 'SMARTCRAWL_SITEMAP_SKIP_IMAGES' ); } public static function stylesheet_enabled() { return (boolean) self::get_sitemap_option( 'sitemap-stylesheet' ); } public static function native_sitemap_available() { return function_exists( 'wp_sitemaps_get_server' ) && is_a( wp_sitemaps_get_server(), 'WP_Sitemaps' ) && wp_sitemaps_get_server()->sitemaps_enabled(); } public static function override_native() { return (boolean) self::get_sitemap_option( 'override-native' ); } public static function get_items_per_sitemap() { $items_per_sitemap = self::get_sitemap_option( 'items-per-sitemap' ); return is_numeric( $items_per_sitemap ) ? intval( $items_per_sitemap ) : Smartcrawl_Sitemap_Utils::DEFAULT_ITEMS_PER_SITEMAP; } public static function get_max_items_per_sitemap() { return Smartcrawl_Sitemap_Utils::DEFAULT_ITEMS_PER_SITEMAP; } public static function split_sitemaps_enabled() { return (boolean) self::get_sitemap_option( 'split-sitemap' ); } public static function set_split_sitemap( $is_split ) { return self::set_sitemap_option( 'split-sitemap', $is_split ); } public static function get_sitemap_option( $key ) { $options = Smartcrawl_Settings::get_component_options( Smartcrawl_Settings::COMP_SITEMAP ); return smartcrawl_get_array_value( $options, $key ); } public static function set_sitemap_option( $key, $value ) { $options = Smartcrawl_Settings::get_component_options( Smartcrawl_Settings::COMP_SITEMAP ); $options[ $key ] = $value; return Smartcrawl_Settings::update_component_options( Smartcrawl_Settings::COMP_SITEMAP, $options ); } public static function auto_regeneration_enabled() { return ! self::get_sitemap_option( 'sitemap-disable-automatic-regeneration' ); } public static function is_url_ignored( $url ) { $ignore_urls = self::get_ignore_urls(); if ( ! empty( $ignore_urls ) ) { if ( preg_match( smartcrawl_get_relative_urls_regex( $ignore_urls ), $url ) || in_array( $url, $ignore_urls, true ) ) { return true; } } return false; } /** * @param $post WP_Post * * @return bool */ public static function is_post_included( $post ) { $query = new Smartcrawl_Sitemap_Posts_Query(); return $query->is_post_included( $post ); } /** * @param $post_type * * @return bool */ public static function is_post_type_included( $post_type ) { $query = new Smartcrawl_Sitemap_Posts_Query(); return in_array( $post_type, $query->get_supported_types(), true ); } public static function is_taxonomy_included( $taxonomy ) { $query = new Smartcrawl_Sitemap_Terms_Query(); return in_array( $taxonomy, $query->get_supported_types(), true ); } /** * @param $term WP_Term * * @return bool */ public static function is_term_included( $term ) { $query = new Smartcrawl_Sitemap_Terms_Query(); return $query->is_term_included( $term ); } public static function prime_cache( $blocking ) { wp_remote_get( smartcrawl_get_sitemap_url(), array( 'blocking' => $blocking ) ); } }