the post ID for redirecting an old slug. * * @since 4.9.3 * @access private * * @see wp_old_slug_redirect() * @global wpdb $wpdb WordPress database abstraction object. * * @param string $post_type The current post type based on the query vars. * @return int The Post ID. */ function _find_post_by_old_slug( $post_type ) { global $wpdb; $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var( 'name' ) ); /* * If year, monthnum, or day have been specified, make our query more precise * just in case there are multiple identical _wp_old_slug values. */ if ( get_query_var( 'year' ) ) { $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', get_query_var( 'year' ) ); } if ( get_query_var( 'monthnum' ) ) { $query .= $wpdb->prepare( ' AND MONTH(post_date) = %d', get_query_var( 'monthnum' ) ); } if ( get_query_var( 'day' ) ) { $query .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) ); } $key = md5( $query ); $last_changed = wp_cache_get_last_changed( 'posts' ); $cache_key = "find_post_by_old_slug:$key:$last_changed"; $cache = wp_cache_get( $cache_key, 'post-queries' ); if ( false !== $cache ) { $id = $cache; } else { $id = (int) $wpdb->get_var( $query ); wp_cache_set( $cache_key, $id, 'post-queries' ); } return $id; } /** * Find the post ID for redirecting an old date. * * @since 4.9.3 * @access private * * @see wp_old_slug_redirect() * @global wpdb $wpdb WordPress database abstraction object. * * @param string $post_type The current post type based on the query vars. * @return int The Post ID. */ function _find_post_by_old_date( $post_type ) { global $wpdb; $date_query = ''; if ( get_query_var( 'year' ) ) { $date_query .= $wpdb->prepare( ' AND YEAR(pm_date.meta_value) = %d', get_query_var( 'year' ) ); } if ( get_query_var( 'monthnum' ) ) { $date_query .= $wpdb->prepare( ' AND MONTH(pm_date.meta_value) = %d', get_query_var( 'monthnum' ) ); } if ( get_query_var( 'day' ) ) { $date_query .= $wpdb->prepare( ' AND DAYOFMONTH(pm_date.meta_value) = %d', get_query_var( 'day' ) ); } $id = 0; if ( $date_query ) { $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta AS pm_date, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_date' AND post_name = %s" . $date_query, $post_type, get_query_var( 'name' ) ); $key = md5( $query ); $last_changed = wp_cache_get_last_changed( 'posts' ); $cache_key = "find_post_by_old_date:$key:$last_changed"; $cache = wp_cache_get( $cache_key, 'post-queries' ); if ( false !== $cache ) { $id = $cache; } else { $id = (int) $wpdb->get_var( $query ); if ( ! $id ) { // Check to see if an old slug matches the old date. $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); } wp_cache_set( $cache_key, $id, 'post-queries' ); } } return $id; } /** * Set up global post data. * * @since 1.5.0 * @since 4.4.0 Added the ability to pass a post ID to `$post`. * * @global WP_Query $wp_query WordPress Query object. * * @param WP_Post|object|int $post WP_Post instance or Post ID/object. * @return bool True when finished. */ function setup_postdata( $post ) { global $wp_query; if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) { return $wp_query->setup_postdata( $post ); } return false; } /** * Generates post data. * * @since 5.2.0 * * @global WP_Query $wp_query WordPress Query object. * * @param WP_Post|object|int $post WP_Post instance or Post ID/object. * @return array|false Elements of post, or false on failure. */ function generate_postdata( $post ) { global $wp_query; if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) { return $wp_query->generate_postdata( $post ); } return false; } t' => $baseDir . '/Core/User_Input/User_Input.php', 'Google\\Site_Kit\\Core\\User_Input\\User_Specific_Answers' => $baseDir . '/Core/User_Input/User_Specific_Answers.php', 'Google\\Site_Kit\\Core\\User_Surveys\\REST_User_Surveys_Controller' => $baseDir . '/Core/User_Surveys/REST_User_Surveys_Controller.php', 'Google\\Site_Kit\\Core\\User_Surveys\\Survey_Queue' => $baseDir . '/Core/User_Surveys/Survey_Queue.php', 'Google\\Site_Kit\\Core\\User_Surveys\\Survey_Timeouts' => $baseDir . '/Core/User_Surveys/Survey_Timeouts.php', 'Google\\Site_Kit\\Core\\User_Surveys\\User_Surveys' => $baseDir . '/Core/User_Surveys/User_Surveys.php', 'Google\\Site_Kit\\Core\\Util\\Activation_Flag' => $baseDir . '/Core/Util/Activation_Flag.php', 'Google\\Site_Kit\\Core\\Util\\Activation_Notice' => $baseDir . '/Core/Util/Activation_Notice.php', 'Google\\Site_Kit\\Core\\Util\\Auto_Updates' => $baseDir . '/Core/Util/Auto_Updates.php', 'Google\\Site_Kit\\Core\\Util\\BC_Functions' => $baseDir . '/Core/Util/BC_Functions.php', 'Google\\Site_Kit\\Core\\Util\\Collection_Key_Cap_Filter' => $baseDir . '/Core/Util/Collection_Key_Cap_Filter.php', 'Google\\Site_Kit\\Core\\Util\\Date' => $baseDir . '/Core/Util/Date.php', 'Google\\Site_Kit\\Core\\Util\\Developer_Plugin_Installer' => $baseDir . '/Core/Util/Developer_Plugin_Installer.php', 'Google\\Site_Kit\\Core\\Util\\Entity' => $baseDir . '/Core/Util/Entity.php', 'Google\\Site_Kit\\Core\\Util\\Entity_Factory' => $baseDir . '/Core/Util/Entity_Factory.php', 'Google\\Site_Kit\\Core\\Util\\Exit_Handler' => $baseDir . '/Core/Util/Exit_Handler.php', 'Google\\Site_Kit\\Core\\Util\\Feature_Flags' => $baseDir . '/Core/Util/Feature_Flags.php', 'Google\\Site_Kit\\Core\\Util\\Google_Icon' => $baseDir . '/Core/Util/Google_Icon.php', 'Google\\Site_Kit\\Core\\Util\\Google_URL_Matcher_Trait' => $baseDir . '/Core/Util/Google_URL_Matcher_Trait.php', 'Google\\Site_Kit\\Core\\Util\\Google_URL_Normalizer' => $baseDir . '/Core/Util/Google_URL_Normalizer.php', 'Google\\Site_Kit\\Core\\Util\\Health_Checks' => $baseDir . '/Core/Util/Health_Checks.php', 'Google\\Site_Kit\\Core\\Util\\Input' => $baseDir . '/Core/Util/Input.php', 'Google\\Site_Kit\\Core\\Util\\Method_Proxy_Trait' => $baseDir . '/Core/Util/Method_Proxy_Trait.php', 'Google\\Site_Kit\\Core\\Util\\Migrate_Legacy_Keys' => $baseDir . '/Core/Util/Migrate_Legacy_Keys.php', 'Google\\Site_Kit\\Core\\Util\\Migration_1_123_0' => $baseDir . '/Core/Util/Migration_1_123_0.php', 'Google\\Site_Kit\\Core\\Util\\Migration_1_3_0' => $baseDir . '/Core/Util/Migration_1_3_0.php', 'Google\\Site_Kit\\Core\\Util\\Migration_1_8_1' => $baseDir . '/Core/Util/Migration_1_8_1.php', 'Google\\Site_Kit\\Core\\Util\\REST_Entity_Search_Controller' => $baseDir . '/Core/Util/REST_Entity_Search_Controller.php', 'Google\\Site_Kit\\Core\\Util\\Remote_Features' => $baseDir . '/Core/Util/Remote_Features.php', 'Google\\Site_Kit\\Core\\Util\\Requires_Javascript_Trait' => $baseDir . '/Core/Util/Requires_Javascript_Trait.php', 'Google\\Site_Kit\\Core\\Util\\Reset' => $baseDir . '/Core/Util/Reset.php', 'Google\\Site_Kit\\Core\\Util\\Reset_Persistent' => $baseDir . '/Core/Util/Reset_Persistent.php', 'Google\\Site_Kit\\Core\\Util\\Sanitize' => $baseDir . '/Core/Util/Sanitize.php', 'Google\\Site_Kit\\Core\\Util\\Scopes' => $baseDir . '/Core/Util/Scopes.php', 'Google\\Site_Kit\\Core\\Util\\Sort' => $baseDir . '/Core/Util/Sort.php', 'Google\\Site_Kit\\Core\\Util\\Synthetic_WP_Query' => $baseDir . '/Core/Util/Synthetic_WP_Query.php', 'Google\\Site_Kit\\Core\\Util\\URL' => $baseDir . '/Core/Util/URL.php', 'Google\\Site_Kit\\Core\\Util\\Uninstallation' => $baseDir . '/Core/Util/Uninstallation.php', 'Google\\Site_Kit\\Core\\Util\\WP_Context_Switcher_Trait' => $baseDir . '/Core/Util/WP_Context_Switcher_Trait.php', 'Google\\Site_Kit\\Core\\Util\\WP_Query_Factory' => $baseDir . '/Core/Util/WP_Query_Factory.php', 'Google\\Site_Kit\\Core\\Validation\\Exception\\Invalid_Report_Dimensions_Exception' => $baseDir . '/Core/Validation/Exception/Invalid_Report_Dimensions_Exception.php', 'Google\\Site_Kit\\Core\\Validation\\Exception\\Invalid_Report_Metrics_Exception' => $baseDir . '/Core/Validation/Exception/Invalid_Report_Metrics_Exception.php', 'Google\\Site_Kit\\Modules\\AdSense' => $baseDir . '/Modules/AdSense.php', 'Google\\Site_Kit\\Modules\\AdSense\\AMP_Tag' => $baseDir . '/Modules/AdSense/AMP_Tag.php', 'Google\\Site_Kit\\Modules\\AdSense\\Ad_Blocking_Recovery_Tag' => $baseDir . '/Modules/AdSense/Ad_Blocking_Recovery_Tag.php', 'Google\\Site_Kit\\Modules\\AdSense\\Ad_Blocking_Recovery_Tag_Guard' => $baseDir . '/Modules/AdSense/Ad_Blocking_Recovery_Tag_Guard.php', 'Google\\Site_Kit\\Modules\\AdSense\\Ad_Blocking_Recovery_Web_Tag' => $baseDir . '/Modules/AdSense/Ad_Blocking_Recovery_Web_Tag.php', 'Google\\Site_Kit\\Modules\\AdSense\\Auto_Ad_Guard' => $baseDir . '/Modules/AdSense/Auto_Ad_Guard.php', 'Google\\Site_Kit\\Modules\\AdSense\\Settings' => $baseDir . '/Modules/AdSense/Settings.php', 'Google\\Site_Kit\\Modules\\AdSense\\Tag_Guard' => $baseDir . '/Modules/AdSense/Tag_Guard.php', 'Google\\Site_Kit\\Modules\\AdSense\\Web_Tag' => $baseDir . '/Modules/AdSense/Web_Tag.php', 'Google\\Site_Kit\\Modules\\Ads' => $baseDir . '/Modules/Ads.php', 'Google\\Site_Kit\\Modules\\Ads\\AMP_Tag' => $baseDir . '/Modules/Ads/AMP_Tag.php', 'Google\\Site_Kit\\Modules\\Ads\\Settings' => $baseDir . '/Modules/Ads/Settings.php', 'Google\\Site_Kit\\Modules\\Ads\\Tag_Guard' => $baseDir . '/Modules/Ads/Tag_Guard.php', 'Google\\Site_Kit\\Modules\\Ads\\Tag_Matchers' => $baseDir . '/Modules/Ads/Tag_Matchers.php', 'Google\\Site_Kit\\Modules\\Ads\\Web_Tag' => $baseDir . '/Modules/Ads/Web_Tag.php', 'Google\\Site_Kit\\Modules\\Analytics_4' => $baseDir . '/Modules/Analytics_4.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\AMP_Tag' => $baseDir . '/Modules/Analytics_4/AMP_Tag.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Account_Ticket' => $baseDir . '/Modules/Analytics_4/Account_Ticket.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking\\AMP_Config_Injector' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking/AMP_Config_Injector.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking\\Event' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking/Event.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking\\Event_List' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking/Event_List.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking\\Event_List_Registry' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking/Event_List_Registry.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Advanced_Tracking\\Script_Injector' => $baseDir . '/Modules/Analytics_4/Advanced_Tracking/Script_Injector.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Audience_Settings' => $baseDir . '/Modules/Analytics_4/Audience_Settings.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Custom_Dimensions_Data_Available' => $baseDir . '/Modules/Analytics_4/Custom_Dimensions_Data_Available.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\AccountProvisioningService' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/AccountProvisioningService.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\AccountsResource' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/AccountsResource.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\EnhancedMeasurementSettingsModel' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/EnhancedMeasurementSettingsModel.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\PropertiesAdSenseLinksService' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/PropertiesAdSenseLinksService.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\PropertiesAudiencesService' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/PropertiesAudiencesService.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\PropertiesEnhancedMeasurementResource' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/PropertiesEnhancedMeasurementResource.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\PropertiesEnhancedMeasurementService' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/PropertiesEnhancedMeasurementService.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\GoogleAnalyticsAdmin\\Proxy_GoogleAnalyticsAdminProvisionAccountTicketRequest' => $baseDir . '/Modules/Analytics_4/GoogleAnalyticsAdmin/Proxy_GoogleAnalyticsAdminProvisionAccountTicketRequest.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report' => $baseDir . '/Modules/Analytics_4/Report.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Dimension_Filter\\Filter' => $baseDir . '/Modules/Analytics_4/Report/Dimension_Filter/Filter.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Dimension_Filter\\In_List_Filter' => $baseDir . '/Modules/Analytics_4/Report/Dimension_Filter/In_List_Filter.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Dimension_Filter\\String_Filter' => $baseDir . '/Modules/Analytics_4/Report/Dimension_Filter/String_Filter.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Filters\\Between_Filter' => $baseDir . '/Modules/Analytics_4/Report/Filters/Between_Filter.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Filters\\Numeric_Filter' => $baseDir . '/Modules/Analytics_4/Report/Filters/Numeric_Filter.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Request' => $baseDir . '/Modules/Analytics_4/Report/Request.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Response' => $baseDir . '/Modules/Analytics_4/Report/Response.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Report\\Row_Trait' => $baseDir . '/Modules/Analytics_4/Report/Row_Trait.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Resource_Data_Availability_Date' => $baseDir . '/Modules/Analytics_4/Resource_Data_Availability_Date.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Settings' => $baseDir . '/Modules/Analytics_4/Settings.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Synchronize_AdSenseLinked' => $baseDir . '/Modules/Analytics_4/Synchronize_AdSenseLinked.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Synchronize_AdsLinked' => $baseDir . '/Modules/Analytics_4/Synchronize_AdsLinked.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Synchronize_Property' => $baseDir . '/Modules/Analytics_4/Synchronize_Property.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Tag_Guard' => $baseDir . '/Modules/Analytics_4/Tag_Guard.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Tag_Interface' => $baseDir . '/Modules/Analytics_4/Tag_Interface.php', 'Google\\Site_Kit\\Modules\\Analytics_4\\Web_Tag' => $baseDir . '/Modules/Analytics_4/Web_Tag.php', 'Google\\Site_Kit\\Modules\\PageSpeed_Insights' => $baseDir . '/Modules/PageSpeed_Insights.php', 'Google\\Site_Kit\\Modules\\PageSpeed_Insights\\Settings' => $baseDir . '/Modules/PageSpeed_Insights/Settings.php', 'Google\\Site_Kit\\Modules\\Search_Console' => $baseDir . '/Modules/Search_Console.php', 'Google\\Site_Kit\\Modules\\Search_Console\\Settings' => $baseDir . '/Modules/Search_Console/Settings.php', 'Google\\Site_Kit\\Modules\\Site_Verification' => $baseDir . '/Modules/Site_Verification.php', 'Google\\Site_Kit\\Modules\\Tag_Manager' => $baseDir . '/Modules/Tag_Manager.php', 'Google\\Site_Kit\\Modules\\Tag_Manager\\AMP_Tag' => $baseDir . '/Modules/Tag_Manager/AMP_Tag.php', 'Google\\Site_Kit\\Modules\\Tag_Manager\\Settings' => $baseDir . '/Modules/Tag_Manager/Settings.php', 'Google\\Site_Kit\\Modules\\Tag_Manager\\Tag_Guard' => $baseDir . '/Modules/Tag_Manager/Tag_Guard.php', 'Google\\Site_Kit\\Modules\\Tag_Manager\\Web_Tag' => $baseDir . '/Modules/Tag_Manager/Web_Tag.php', 'Google\\Site_Kit\\Plugin' => $baseDir . '/Plugin.php', );