wp/wp-includes/ms-default-filters.php
author ymh <ymh.work@gmail.com>
Fri, 05 Sep 2025 18:40:08 +0200
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
permissions -rw-r--r--
Add CLAUDE.md documentation and sync WordPress core files - Add comprehensive CLAUDE.md documentation file with project architecture, development setup, database operations, WordPress CLI usage, file sync procedures, and Mercurial commands - Update WordPress core files from wordpress/ to wp/ directory - Sync latest WordPress admin interface, includes, and core functionality - Update plugins: portfolio plugin with latest BWS framework and fancybox integration - Maintain custom configuration and theme files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Sets up the default filters and actions for Multisite.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * If you need to remove a default hook, this file will give you the priority
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * for which to use to remove the hook.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * Not all of the Multisite default hooks are found in ms-default-filters.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * @see default-filters.php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    16
add_action( 'init', 'ms_subdomain_constants' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    18
// Functions.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
add_filter( 'option_users_can_register', 'users_can_register_signup_filter' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    23
// Users.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
add_action( 'init', 'maybe_add_existing_user_to_blog' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
add_action( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
add_action( 'wpmu_activate_user', 'wpmu_welcome_user_notification', 10, 3 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    29
add_action( 'after_signup_user', 'wpmu_signup_user_notification', 10, 4 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    30
add_action( 'network_site_new_created_user', 'wp_send_new_user_notifications' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
add_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    32
add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
add_filter( 'sanitize_user', 'strtolower' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    34
add_action( 'deleted_user', 'wp_delete_signup_on_user_delete', 10, 3 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    36
// Roles.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    37
add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    39
// Blogs.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    42
add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    43
add_filter( 'wp_normalize_site_data', 'wp_normalize_site_data', 10, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    44
add_action( 'wp_validate_site_data', 'wp_validate_site_data', 10, 3 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
add_action( 'wp_insert_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    46
add_action( 'wp_update_site', 'wp_maybe_update_network_site_counts_on_update', 10, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    47
add_action( 'wp_delete_site', 'wp_maybe_update_network_site_counts_on_update', 10, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    48
add_action( 'wp_insert_site', 'wp_maybe_transition_site_statuses_on_update', 10, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
add_action( 'wp_update_site', 'wp_maybe_transition_site_statuses_on_update', 10, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    50
add_action( 'wp_update_site', 'wp_maybe_clean_new_site_cache_on_update', 10, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    52
add_action( 'wp_initialize_site', 'wpmu_log_new_registrations', 100, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
add_action( 'wp_initialize_site', 'newblog_notify_siteadmin', 100, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
add_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10, 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    55
add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    57
// Site meta.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    58
add_action( 'added_blog_meta', 'wp_cache_set_sites_last_changed' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    59
add_action( 'updated_blog_meta', 'wp_cache_set_sites_last_changed' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    60
add_action( 'deleted_blog_meta', 'wp_cache_set_sites_last_changed' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    61
add_filter( 'get_blog_metadata', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    62
add_filter( 'add_blog_metadata', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    63
add_filter( 'update_blog_metadata', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    64
add_filter( 'delete_blog_metadata', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    65
add_filter( 'get_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    66
add_filter( 'update_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    67
add_filter( 'delete_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    68
add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    70
// Register nonce.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
add_action( 'signup_hidden_fields', 'signup_nonce_fields' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    73
// Template.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
add_action( 'template_redirect', 'maybe_redirect_404' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    77
// Administration.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    78
add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
add_action( 'delete_post', '_update_blog_date_on_post_delete' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    81
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    83
// Counts.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
add_action( 'admin_init', 'wp_schedule_update_network_counts' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    85
add_action( 'update_network_counts', 'wp_update_network_counts', 10, 0 );
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    86
foreach ( array( 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    87
	add_action( $action, 'wp_maybe_update_network_user_counts', 10, 0 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    88
}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    89
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    90
// These counts are handled by wp_update_network_counts() on Multisite:
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    91
remove_action( 'admin_init', 'wp_schedule_update_user_counts' );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    92
remove_action( 'wp_update_user_counts', 'wp_schedule_update_user_counts' );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    93
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_blog', 'make_delete_blog', 'make_undelete_blog' ) as $action ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    95
	add_action( $action, 'wp_maybe_update_network_site_counts', 10, 0 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    96
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
unset( $action );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    99
// Files.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
add_filter( 'import_upload_size_limit', 'fix_import_form_size' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
add_filter( 'upload_mimes', 'check_upload_mimes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
add_filter( 'upload_size_limit', 'upload_size_limit_filter' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   106
// Mail.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
add_action( 'phpmailer_init', 'fix_phpmailer_messageid' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   109
// Disable somethings by default for multisite.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
add_filter( 'enable_update_services_configuration', '__return_false' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   111
if ( ! defined( 'POST_BY_EMAIL' ) || ! POST_BY_EMAIL ) { // Back compat constant.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
	add_filter( 'enable_post_by_email_configuration', '__return_false' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   113
}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   114
if ( ! defined( 'EDIT_ANY_USER' ) || ! EDIT_ANY_USER ) { // Back compat constant.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
	add_filter( 'enable_edit_any_user_configuration', '__return_false' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
add_filter( 'force_filtered_html_on_import', '__return_true' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   119
// WP_HOME and WP_SITEURL should not have any effect in MS.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
remove_filter( 'option_siteurl', '_config_wp_siteurl' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
remove_filter( 'option_home', '_config_wp_home' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   123
// Some options changes should trigger site details refresh.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
add_action( 'update_option_blogname', 'clean_site_details_cache', 10, 0 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
add_action( 'update_option_siteurl', 'clean_site_details_cache', 10, 0 );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   126
add_action( 'update_option_post_count', 'clean_site_details_cache', 10, 0 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
add_action( 'update_option_home', 'clean_site_details_cache', 10, 0 );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   128
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   132
// Allow multisite domains for HTTP requests.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 );