author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Sets up the default filters and actions for Multisite. |
|
4 |
* |
|
5 |
* If you need to remove a default hook, this file will give you the priority |
|
6 |
* for which to use to remove the hook. |
|
7 |
* |
|
8 |
* Not all of the Multisite default hooks are found in ms-default-filters.php |
|
9 |
* |
|
10 |
* @package WordPress |
|
11 |
* @subpackage Multisite |
|
12 |
* @see default-filters.php |
|
13 |
* @since 3.0.0 |
|
14 |
*/ |
|
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 |
|
5 | 18 |
// Functions |
19 |
add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 ); |
|
20 |
add_filter( 'option_users_can_register', 'users_can_register_signup_filter' ); |
|
21 |
add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); |
|
22 |
||
0 | 23 |
// Users |
24 |
add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' ); |
|
25 |
add_action( 'init', 'maybe_add_existing_user_to_blog' ); |
|
26 |
add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' ); |
|
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 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
add_action( 'network_site_new_created_user', 'wp_send_new_user_notifications' ); |
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' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' ); |
0 | 33 |
add_filter( 'sanitize_user', 'strtolower' ); |
34 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
// Roles |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
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
|
37 |
|
0 | 38 |
// Blogs |
39 |
add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' ); |
|
40 |
add_action( 'wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2 ); |
|
41 |
add_action( 'wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
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
|
43 |
add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 ); |
0 | 44 |
|
45 |
// Register Nonce |
|
46 |
add_action( 'signup_hidden_fields', 'signup_nonce_fields' ); |
|
47 |
||
48 |
// Template |
|
49 |
add_action( 'template_redirect', 'maybe_redirect_404' ); |
|
50 |
add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); |
|
51 |
||
52 |
// Administration |
|
53 |
add_filter( 'term_id_filter', 'global_terms', 10, 2 ); |
|
5 | 54 |
add_action( 'delete_post', '_update_posts_count_on_delete' ); |
0 | 55 |
add_action( 'delete_post', '_update_blog_date_on_post_delete' ); |
56 |
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
|
57 |
add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 ); |
0 | 58 |
|
59 |
// Counts |
|
60 |
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
|
61 |
add_action( 'update_network_counts', 'wp_update_network_counts', 10, 0 ); |
0 | 62 |
foreach ( array( 'user_register', 'deleted_user', '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
|
63 |
add_action( $action, 'wp_maybe_update_network_user_counts', 10, 0 ); |
0 | 64 |
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
|
65 |
add_action( $action, 'wp_maybe_update_network_site_counts', 10, 0 ); |
0 | 66 |
unset( $action ); |
67 |
||
68 |
// Files |
|
69 |
add_filter( 'wp_upload_bits', 'upload_is_file_too_big' ); |
|
70 |
add_filter( 'import_upload_size_limit', 'fix_import_form_size' ); |
|
71 |
add_filter( 'upload_mimes', 'check_upload_mimes' ); |
|
72 |
add_filter( 'upload_size_limit', 'upload_size_limit_filter' ); |
|
73 |
add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' ); |
|
74 |
||
75 |
// Mail |
|
76 |
add_action( 'phpmailer_init', 'fix_phpmailer_messageid' ); |
|
77 |
||
78 |
// Disable somethings by default for multisite |
|
79 |
add_filter( 'enable_update_services_configuration', '__return_false' ); |
|
80 |
if ( ! defined('POST_BY_EMAIL') || ! POST_BY_EMAIL ) // back compat constant. |
|
81 |
add_filter( 'enable_post_by_email_configuration', '__return_false' ); |
|
82 |
if ( ! defined('EDIT_ANY_USER') || ! EDIT_ANY_USER ) // back compat constant. |
|
83 |
add_filter( 'enable_edit_any_user_configuration', '__return_false' ); |
|
84 |
add_filter( 'force_filtered_html_on_import', '__return_true' ); |
|
85 |
||
86 |
// WP_HOME and WP_SITEURL should not have any effect in MS |
|
87 |
remove_filter( 'option_siteurl', '_config_wp_siteurl' ); |
|
88 |
remove_filter( 'option_home', '_config_wp_home' ); |
|
89 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
// Some options changes should trigger site details refresh. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
add_action( 'update_option_blogname', 'clean_site_details_cache', 10, 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
add_action( 'update_option_siteurl', 'clean_site_details_cache', 10, 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
add_action( 'update_option_post_count', 'clean_site_details_cache', 10, 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
add_action( 'update_option_home', 'clean_site_details_cache', 10, 0 ); |
5 | 95 |
|
0 | 96 |
// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used. |
97 |
add_filter( 'default_site_option_ms_files_rewriting', '__return_true' ); |
|
98 |
||
99 |
// Whitelist multisite domains for HTTP requests |
|
100 |
add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 ); |