Make WordPress Core

Ticket #41699: 41699.2.diff

File 41699.2.diff, 9.6 KB (added by dd32, 8 years ago)
  • src/wp-includes/default-filters.php

    add_action( 'sanitize_comment_cookies',  
    305305add_action( 'admin_print_scripts',        'print_emoji_detection_script'                   );
    306306add_action( 'admin_print_scripts',        'print_head_scripts',                      20    );
    307307add_action( 'admin_print_footer_scripts', '_wp_footer_scripts'                             );
    308308add_action( 'admin_print_styles',         'print_emoji_styles'                             );
    309309add_action( 'admin_print_styles',         'print_admin_styles',                      20    );
    310310add_action( 'init',                       'smilies_init',                             5    );
    311311add_action( 'plugins_loaded',             'wp_maybe_load_widgets',                    0    );
    312312add_action( 'plugins_loaded',             'wp_maybe_load_embeds',                     0    );
    313313add_action( 'shutdown',                   'wp_ob_end_flush_all',                      1    );
    314314// Create a revision whenever a post is updated.
    315315add_action( 'post_updated',               'wp_save_post_revision',                   10, 1 );
    316316add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
    317317add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
    318318add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status', 10, 3 );
    319319add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
     320add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
     321add_action( 'welcome_panel',              'wp_welcome_panel'                               );
     322
     323// Cron tasks
    320324add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            );
    321325add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'                      );
    322 add_action( 'admin_init',                 'send_frame_options_header',               10, 0 );
    323326add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'                           );
    324327add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment'                           );
    325 add_action( 'welcome_panel',              'wp_welcome_panel'                               );
     328add_action( 'delete_expired_transients',  'delete_expired_transients'                      );
    326329
    327330// Navigation menu actions
    328331add_action( 'delete_post',                '_wp_delete_post_menu_item'         );
    329332add_action( 'delete_term',                '_wp_delete_tax_menu_item',   10, 3 );
    330333add_action( 'transition_post_status',     '_wp_auto_add_pages_to_menu', 10, 3 );
    331334add_action( 'delete_post',                '_wp_delete_customize_changeset_dependent_auto_drafts' );
    332335
    333336// Post Thumbnail CSS class filtering
    334337add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
    335338add_action( 'end_fetch_post_thumbnail_html',   '_wp_post_thumbnail_class_filter_remove' );
    336339
    337340// Redirect Old Slugs
    338341add_action( 'template_redirect',  'wp_old_slug_redirect'              );
    339342add_action( 'post_updated',       'wp_check_for_changed_slugs', 12, 3 );
    340343add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 );
  • src/wp-includes/option.php

    function set_transient( $transient, $val 
    785785                 * Fires after the value for a transient has been set.
    786786                 *
    787787                 * @since 3.0.0
    788788                 * @since 3.6.0 The `$value` and `$expiration` parameters were added.
    789789                 *
    790790                 * @param string $transient  The name of the transient.
    791791                 * @param mixed  $value      Transient value.
    792792                 * @param int    $expiration Time until expiration in seconds.
    793793                 */
    794794                do_action( 'setted_transient', $transient, $value, $expiration );
    795795        }
    796796        return $result;
    797797}
    798798
    799799/**
     800 * Deletes all expired transients.
     801 *
     802 * The multi-table delete syntax is used to delete the transient record
     803 * from table a, and the corresponding transient_timeout record from table b.                           +
     804 *
     805 * @since 4.9.0
     806 */
     807function delete_expired_transients() {
     808        global $wpdb;
     809
     810        $time = time();
     811
     812        $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b
     813                WHERE a.option_name LIKE %s
     814                AND a.option_name NOT LIKE %s
     815                AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
     816                AND b.option_value < %d";
     817
     818        $wpdb->query( $wpdb->prepare(
     819                $sql,
     820                $wpdb->esc_like( '_transient_' ) . '%',
     821                $wpdb->esc_like( '_transient_timeout_' ) . '%',
     822                $time
     823        ) );
     824
     825        if ( is_main_site() && is_main_network() ) {
     826                $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b
     827                        WHERE a.option_name LIKE %s
     828                        AND a.option_name NOT LIKE %s
     829                        AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
     830                        AND b.option_value < %d";
     831
     832                $wpdb->query( $wpdb->prepare(
     833                        $sql,
     834                        $wpdb->esc_like( '_site_transient_' ) . '%',
     835                        $wpdb->esc_like( '_site_transient_timeout_' ) . '%',
     836                        $time
     837                ) );
     838        }
     839}
     840
     841/**
    800842 * Saves and restores user interface settings stored in a cookie.
    801843 *
    802844 * Checks if the current user-settings cookie is updated and stores it. When no
    803845 * cookie exists (different browser used), adds the last saved cookie restoring
    804846 * the settings.
    805847 *
    806848 * @since 2.7.0
    807849 */
    808850function wp_user_settings() {
    809851
    810852        if ( ! is_admin() || wp_doing_ajax() ) {
    811853                return;
    812854        }
    813855
    814856        if ( ! $user_id = get_current_user_id() ) {
  • src/wp-admin/admin.php

    if ( get_option('db_upgraded') ) { 
    7474                        /** This action is documented in wp-admin/network/upgrade.php */
    7575                        do_action( 'after_mu_upgrade', $response );
    7676                        unset($response);
    7777                }
    7878                unset($c);
    7979        }
    8080}
    8181
    8282require_once(ABSPATH . 'wp-admin/includes/admin.php');
    8383
    8484auth_redirect();
    8585
    8686// Schedule trash collection
    8787if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() )
    8888        wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
     89// Schedule Transient cleanup
     90if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() )
     91        wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
    8992
    9093set_screen_options();
    9194
    9295$date_format = __( 'F j, Y' );
    9396$time_format = __( 'g:i a' );
    9497
    9598wp_enqueue_script( 'common' );
    9699
    97 
    98 
    99 
    100100/**
    101101 * $pagenow is set in vars.php
    102102 * $wp_importers is sometimes set in wp-admin/includes/import.php
    103103 * The remaining variables are imported as globals elsewhere, declared as globals here
    104104 *
    105105 * @global string $pagenow
    106106 * @global array  $wp_importers
    107107 * @global string $hook_suffix
    108108 * @global string $plugin_page
    109109 * @global string $typenow
    110110 * @global string $taxnow
    111111 */
    112112global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
    113113
    114114$page_hook = null;
  • src/wp-admin/includes/schema.php

    function populate_options() { 
    572572                'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append',
    573573                'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat',
    574574                'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce',
    575575                '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins',
    576576                'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
    577577                'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
    578578                'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
    579579                'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit'
    580580        );
    581581        foreach ( $unusedoptions as $option )
    582582                delete_option($option);
    583583
    584584        // Delete obsolete magpie stuff.
    585585        $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
    586586
    587         /*
    588          * Deletes all expired transients. The multi-table delete syntax is used
    589          * to delete the transient record from table a, and the corresponding
    590          * transient_timeout record from table b.
    591          */
    592         $time = time();
    593         $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
    594                 WHERE a.option_name LIKE %s
    595                 AND a.option_name NOT LIKE %s
    596                 AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
    597                 AND b.option_value < %d";
    598         $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', $time ) );
    599 
    600         if ( is_main_site() && is_main_network() ) {
    601                 $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
    602                         WHERE a.option_name LIKE %s
    603                         AND a.option_name NOT LIKE %s
    604                         AND b.option_name = CONCAT( '_site_transient_timeout_', SUBSTRING( a.option_name, 17 ) )
    605                         AND b.option_value < %d";
    606                 $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like( '_site_transient_timeout_' ) . '%', $time ) );
    607         }
     587        delete_expired_transients();
    608588}
    609589
    610590/**
    611591 * Execute WordPress role creation for the various WordPress versions.
    612592 *
    613593 * @since 2.0.0
    614594 */
    615595function populate_roles() {
    616596        populate_roles_160();
    617597        populate_roles_210();
    618598        populate_roles_230();
    619599        populate_roles_250();
    620600        populate_roles_260();
    621601        populate_roles_270();
    622602        populate_roles_280();