author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* My Sites dashboard. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Multisite |
|
7 |
* @since 3.0.0 |
|
8 |
*/ |
|
9 |
||
16 | 10 |
require_once __DIR__ . '/admin.php'; |
0 | 11 |
|
9 | 12 |
if ( ! is_multisite() ) { |
0 | 13 |
wp_die( __( 'Multisite support is not enabled.' ) ); |
9 | 14 |
} |
0 | 15 |
|
9 | 16 |
if ( ! current_user_can( 'read' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
wp_die( __( 'Sorry, you are not allowed to access this page.' ) ); |
9 | 18 |
} |
0 | 19 |
|
20 |
$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash'; |
|
21 |
||
22 |
$blogs = get_blogs_of_user( $current_user->ID ); |
|
23 |
||
24 |
$updated = false; |
|
16 | 25 |
if ( 'updateblogsettings' === $action && isset( $_POST['primary_blog'] ) ) { |
0 | 26 |
check_admin_referer( 'update-my-sites' ); |
27 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
$blog = get_site( (int) $_POST['primary_blog'] ); |
0 | 29 |
if ( $blog && isset( $blog->domain ) ) { |
18 | 30 |
update_user_meta( $current_user->ID, 'primary_blog', (int) $_POST['primary_blog'] ); |
0 | 31 |
$updated = true; |
32 |
} else { |
|
33 |
wp_die( __( 'The primary site you chose does not exist.' ) ); |
|
34 |
} |
|
35 |
} |
|
36 |
||
19 | 37 |
// Used in the HTML title tag. |
9 | 38 |
$title = __( 'My Sites' ); |
0 | 39 |
$parent_file = 'index.php'; |
40 |
||
9 | 41 |
get_current_screen()->add_help_tab( |
42 |
array( |
|
43 |
'id' => 'overview', |
|
44 |
'title' => __( 'Overview' ), |
|
45 |
'content' => |
|
46 |
'<p>' . __( 'This screen shows an individual user all of their sites in this network, and also allows that user to set a primary site. They can use the links under each site to visit either the front end or the dashboard for that site.' ) . '</p>', |
|
47 |
) |
|
48 |
); |
|
0 | 49 |
|
50 |
get_current_screen()->set_help_sidebar( |
|
9 | 51 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
52 |
'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_My_Sites_Screen">Documentation on My Sites</a>' ) . '</p>' . |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
53 |
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' |
0 | 54 |
); |
55 |
||
16 | 56 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 57 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
58 |
if ( $updated ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
'<strong>' . __( 'Settings saved.' ) . '</strong>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
'type' => 'success', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
64 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
65 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
?> |
0 | 69 |
|
70 |
<div class="wrap"> |
|
9 | 71 |
<h1 class="wp-heading-inline"> |
72 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
echo esc_html( $title ); |
9 | 74 |
?> |
75 |
</h1> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
|
0 | 77 |
<?php |
16 | 78 |
if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
/** This filter is documented in wp-login.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
$sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
81 |
printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html__( 'Add New Site' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
|
0 | 84 |
if ( empty( $blogs ) ) : |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
85 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
86 |
'<strong>' . __( 'You must be a member of at least one site to use this page.' ) . '</strong>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
87 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
88 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
89 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
90 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
91 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
92 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
93 |
<?php |
0 | 94 |
else : |
9 | 95 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
<hr class="wp-header-end"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
|
5 | 99 |
<form id="myblogs" method="post"> |
0 | 100 |
<?php |
101 |
choose_primary_blog(); |
|
5 | 102 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
* Fires before the sites list on the My Sites screen. |
5 | 104 |
* |
105 |
* @since 3.0.0 |
|
106 |
*/ |
|
0 | 107 |
do_action( 'myblogs_allblogs_options' ); |
108 |
?> |
|
109 |
<br clear="all" /> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
<ul class="my-sites striped"> |
0 | 111 |
<?php |
5 | 112 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
113 |
* Filters the settings HTML markup in the Global Settings section on the My Sites screen. |
5 | 114 |
* |
115 |
* By default, the Global Settings section is hidden. Passing a non-empty |
|
116 |
* string to this filter will enable the section, and allow new settings |
|
117 |
* to be added, either globally or for specific sites. |
|
118 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
* @since MU (3.0.0) |
5 | 120 |
* |
121 |
* @param string $settings_html The settings HTML markup. Default empty. |
|
16 | 122 |
* @param string $context Context of the setting (global or site-specific). Default 'global'. |
5 | 123 |
*/ |
0 | 124 |
$settings_html = apply_filters( 'myblogs_options', '', 'global' ); |
16 | 125 |
|
126 |
if ( $settings_html ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
echo '<h3>' . __( 'Global Settings' ) . '</h3>'; |
0 | 128 |
echo $settings_html; |
129 |
} |
|
16 | 130 |
|
0 | 131 |
reset( $blogs ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
foreach ( $blogs as $user_blog ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
switch_to_blog( $user_blog->userblog_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
|
9 | 136 |
echo '<li>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
echo "<h3>{$user_blog->blogname}</h3>"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
|
9 | 139 |
$actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
if ( current_user_can( 'read' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
$actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
} |
0 | 144 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* Filters the row links displayed for each site on the My Sites screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* @since MU (3.0.0) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* @param string $actions The HTML site link markup. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* @param object $user_blog An object containing the site data. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
$actions = apply_filters( 'myblogs_blog_actions', $actions, $user_blog ); |
16 | 154 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
echo "<p class='my-sites-actions'>" . $actions . '</p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
/** This filter is documented in wp-admin/my-sites.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
echo apply_filters( 'myblogs_options', '', $user_blog ); |
16 | 159 |
|
9 | 160 |
echo '</li>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
restore_current_blog(); |
9 | 163 |
} |
164 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
</ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
if ( count( $blogs ) > 1 || has_action( 'myblogs_allblogs_options' ) || has_filter( 'myblogs_options' ) ) { |
9 | 168 |
?> |
169 |
<input type="hidden" name="action" value="updateblogsettings" /> |
|
170 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
wp_nonce_field( 'update-my-sites' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
submit_button(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
?> |
0 | 175 |
</form> |
176 |
<?php endif; ?> |
|
177 |
</div> |
|
178 |
<?php |
|
16 | 179 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |