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 |
* WordPress Dashboard Widget Administration Screen API |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
10 |
* Registers dashboard widgets. |
|
11 |
* |
|
12 |
* Handles POST data, sets up filters. |
|
13 |
* |
|
14 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @global array $wp_registered_widgets |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
* @global array $wp_registered_widget_controls |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
* @global array $wp_dashboard_control_callbacks |
0 | 19 |
*/ |
20 |
function wp_dashboard_setup() { |
|
21 |
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; |
|
22 |
$wp_dashboard_control_callbacks = array(); |
|
23 |
$screen = get_current_screen(); |
|
24 |
||
25 |
/* Register Widgets and Controls */ |
|
26 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
// Try Gutenberg |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
// If Gutenberg isn't activated, only show the panel to users who can install and activate it. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
$plugins = get_plugins(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'install_plugins' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
// If Gutenberg is activated, only show it to users who can use it. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'edit_posts' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
|
0 | 39 |
$response = wp_check_browser_version(); |
40 |
||
41 |
if ( $response && $response['upgrade'] ) { |
|
42 |
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
|
43 |
if ( $response['insecure'] ) |
|
44 |
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
45 |
else |
|
46 |
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
47 |
} |
|
48 |
||
49 |
// Right Now |
|
50 |
if ( is_blog_admin() && current_user_can('edit_posts') ) |
|
5 | 51 |
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
0 | 52 |
|
53 |
if ( is_network_admin() ) |
|
54 |
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
55 |
||
5 | 56 |
// Activity Widget |
57 |
if ( is_blog_admin() ) { |
|
58 |
wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
|
0 | 59 |
} |
60 |
||
61 |
// QuickPress Widget |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
$quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) ); |
5 | 64 |
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
0 | 65 |
} |
5 | 66 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
// WordPress Events and News |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); |
5 | 69 |
|
70 |
if ( is_network_admin() ) { |
|
0 | 71 |
|
5 | 72 |
/** |
73 |
* Fires after core widgets for the Network Admin dashboard have been registered. |
|
74 |
* |
|
75 |
* @since 3.1.0 |
|
76 |
*/ |
|
77 |
do_action( 'wp_network_dashboard_setup' ); |
|
0 | 78 |
|
5 | 79 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
* Filters the list of widgets to load for the Network Admin dashboard. |
5 | 81 |
* |
82 |
* @since 3.1.0 |
|
83 |
* |
|
84 |
* @param array $dashboard_widgets An array of dashboard widgets. |
|
85 |
*/ |
|
0 | 86 |
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); |
87 |
} elseif ( is_user_admin() ) { |
|
5 | 88 |
|
89 |
/** |
|
90 |
* Fires after core widgets for the User Admin dashboard have been registered. |
|
91 |
* |
|
92 |
* @since 3.1.0 |
|
93 |
*/ |
|
0 | 94 |
do_action( 'wp_user_dashboard_setup' ); |
5 | 95 |
|
96 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* Filters the list of widgets to load for the User Admin dashboard. |
5 | 98 |
* |
99 |
* @since 3.1.0 |
|
100 |
* |
|
101 |
* @param array $dashboard_widgets An array of dashboard widgets. |
|
102 |
*/ |
|
0 | 103 |
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); |
104 |
} else { |
|
5 | 105 |
|
106 |
/** |
|
107 |
* Fires after core widgets for the admin dashboard have been registered. |
|
108 |
* |
|
109 |
* @since 2.5.0 |
|
110 |
*/ |
|
0 | 111 |
do_action( 'wp_dashboard_setup' ); |
5 | 112 |
|
113 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
* Filters the list of widgets to load for the admin dashboard. |
5 | 115 |
* |
116 |
* @since 2.5.0 |
|
117 |
* |
|
118 |
* @param array $dashboard_widgets An array of dashboard widgets. |
|
119 |
*/ |
|
0 | 120 |
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); |
121 |
} |
|
122 |
||
123 |
foreach ( $dashboard_widgets as $widget_id ) { |
|
124 |
$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>'; |
|
125 |
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] ); |
|
126 |
} |
|
127 |
||
128 |
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { |
|
129 |
check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
|
130 |
ob_start(); // hack - but the same hack wp-admin/widgets.php uses |
|
131 |
wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
|
132 |
ob_end_clean(); |
|
133 |
wp_redirect( remove_query_arg( 'edit' ) ); |
|
134 |
exit; |
|
135 |
} |
|
136 |
||
5 | 137 |
/** This action is documented in wp-admin/edit-form-advanced.php */ |
138 |
do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); |
|
0 | 139 |
|
140 |
/** This action is documented in wp-admin/edit-form-advanced.php */ |
|
5 | 141 |
do_action( 'do_meta_boxes', $screen->id, 'side', '' ); |
0 | 142 |
} |
143 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
* Adds a new dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
* @global array $wp_dashboard_control_callbacks |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* @param string $widget_id Widget ID (used in the 'id' attribute for the widget). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
* @param string $widget_name Title of the widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
* @param callable $callback Function that fills the widget with the desired content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
* The function should echo its output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
* @param callable $control_callback Optional. Function that outputs controls for the widget. Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
* @param array $callback_args Optional. Data that should be set as the $args property of the widget array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
* (which is the second parameter passed to your callback). Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
*/ |
0 | 159 |
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { |
160 |
$screen = get_current_screen(); |
|
161 |
global $wp_dashboard_control_callbacks; |
|
162 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
$private_callback_args = array( '__widget_basename' => $widget_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
if ( is_null( $callback_args ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
$callback_args = $private_callback_args; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
} else if ( is_array( $callback_args ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
$callback_args = array_merge( $callback_args, $private_callback_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
|
0 | 171 |
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { |
172 |
$wp_dashboard_control_callbacks[$widget_id] = $control_callback; |
|
173 |
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { |
|
174 |
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); |
|
175 |
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>'; |
|
176 |
$callback = '_wp_dashboard_control_callback'; |
|
177 |
} else { |
|
178 |
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); |
|
179 |
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; |
|
180 |
} |
|
181 |
} |
|
182 |
||
5 | 183 |
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
0 | 184 |
|
185 |
$location = 'normal'; |
|
186 |
if ( in_array($widget_id, $side_widgets) ) |
|
187 |
$location = 'side'; |
|
188 |
||
189 |
$priority = 'core'; |
|
190 |
if ( 'dashboard_browser_nag' === $widget_id ) |
|
191 |
$priority = 'high'; |
|
192 |
||
193 |
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); |
|
194 |
} |
|
195 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* Outputs controls for the current dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
* @param mixed $dashboard |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
* @param array $meta_box |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
*/ |
0 | 205 |
function _wp_dashboard_control_callback( $dashboard, $meta_box ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">'; |
0 | 207 |
wp_dashboard_trigger_widget_control( $meta_box['id'] ); |
208 |
wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); |
|
209 |
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />'; |
|
210 |
submit_button( __('Submit') ); |
|
211 |
echo '</form>'; |
|
212 |
} |
|
213 |
||
214 |
/** |
|
215 |
* Displays the dashboard. |
|
216 |
* |
|
217 |
* @since 2.5.0 |
|
218 |
*/ |
|
219 |
function wp_dashboard() { |
|
220 |
$screen = get_current_screen(); |
|
5 | 221 |
$columns = absint( $screen->get_columns() ); |
222 |
$columns_css = ''; |
|
223 |
if ( $columns ) { |
|
224 |
$columns_css = " columns-$columns"; |
|
225 |
} |
|
0 | 226 |
|
227 |
?> |
|
5 | 228 |
<div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>"> |
229 |
<div id="postbox-container-1" class="postbox-container"> |
|
0 | 230 |
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?> |
231 |
</div> |
|
5 | 232 |
<div id="postbox-container-2" class="postbox-container"> |
0 | 233 |
<?php do_meta_boxes( $screen->id, 'side', '' ); ?> |
234 |
</div> |
|
5 | 235 |
<div id="postbox-container-3" class="postbox-container"> |
0 | 236 |
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?> |
237 |
</div> |
|
5 | 238 |
<div id="postbox-container-4" class="postbox-container"> |
0 | 239 |
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?> |
240 |
</div> |
|
241 |
</div> |
|
242 |
||
243 |
<?php |
|
244 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
245 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
246 |
||
247 |
} |
|
248 |
||
5 | 249 |
// |
250 |
// Dashboard Widgets |
|
251 |
// |
|
0 | 252 |
|
5 | 253 |
/** |
254 |
* Dashboard widget that displays some basic stats about the site. |
|
255 |
* |
|
256 |
* Formerly 'Right Now'. A streamlined 'At a Glance' as of 3.8. |
|
257 |
* |
|
258 |
* @since 2.7.0 |
|
259 |
*/ |
|
260 |
function wp_dashboard_right_now() { |
|
261 |
?> |
|
262 |
<div class="main"> |
|
263 |
<ul> |
|
264 |
<?php |
|
265 |
// Posts and Pages |
|
266 |
foreach ( array( 'post', 'page' ) as $post_type ) { |
|
267 |
$num_posts = wp_count_posts( $post_type ); |
|
268 |
if ( $num_posts && $num_posts->publish ) { |
|
269 |
if ( 'post' == $post_type ) { |
|
270 |
$text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
|
271 |
} else { |
|
272 |
$text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
|
273 |
} |
|
274 |
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
275 |
$post_type_object = get_post_type_object( $post_type ); |
|
276 |
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
|
277 |
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text ); |
|
278 |
} else { |
|
279 |
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
|
280 |
} |
|
0 | 281 |
|
5 | 282 |
} |
0 | 283 |
} |
5 | 284 |
// Comments |
285 |
$num_comm = wp_count_comments(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { |
5 | 287 |
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
288 |
?> |
|
289 |
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li> |
|
290 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
/* translators: %s: number of comments in moderation */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
/* translators: %s: number of comments in moderation */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
<li class="comment-mod-count<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
if ( ! $num_comm->moderated ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
echo ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
<?php |
0 | 303 |
} |
304 |
||
5 | 305 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
* Filters the array of extra elements to list in the 'At a Glance' |
5 | 307 |
* dashboard widget. |
308 |
* |
|
309 |
* Prior to 3.8.0, the widget was named 'Right Now'. Each element |
|
310 |
* is wrapped in list-item tags on output. |
|
311 |
* |
|
312 |
* @since 3.8.0 |
|
313 |
* |
|
314 |
* @param array $items Array of extra 'At a Glance' widget items. |
|
315 |
*/ |
|
316 |
$elements = apply_filters( 'dashboard_glance_items', array() ); |
|
0 | 317 |
|
5 | 318 |
if ( $elements ) { |
319 |
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n"; |
|
320 |
} |
|
0 | 321 |
|
5 | 322 |
?> |
323 |
</ul> |
|
324 |
<?php |
|
325 |
update_right_now_message(); |
|
0 | 326 |
|
327 |
// Check if search engines are asked not to index this site. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) { |
5 | 329 |
|
330 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
* Filters the link title attribute for the 'Search Engines Discouraged' |
5 | 332 |
* message displayed in the 'At a Glance' dashboard widget. |
333 |
* |
|
334 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
335 |
* |
|
336 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
* @since 4.5.0 The default for `$title` was updated to an empty string. |
5 | 338 |
* |
339 |
* @param string $title Default attribute text. |
|
340 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
$title = apply_filters( 'privacy_on_link_title', '' ); |
5 | 342 |
|
343 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* Filters the link label for the 'Search Engines Discouraged' message |
5 | 345 |
* displayed in the 'At a Glance' dashboard widget. |
346 |
* |
|
347 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
348 |
* |
|
349 |
* @since 3.0.0 |
|
350 |
* |
|
351 |
* @param string $content Default text. |
|
352 |
*/ |
|
353 |
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
$title_attr = '' === $title ? '' : " title='$title'"; |
0 | 355 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>"; |
0 | 357 |
} |
5 | 358 |
?> |
359 |
</div> |
|
360 |
<?php |
|
361 |
/* |
|
362 |
* activity_box_end has a core action, but only prints content when multisite. |
|
363 |
* Using an output buffer is the only way to really check if anything's displayed here. |
|
364 |
*/ |
|
365 |
ob_start(); |
|
0 | 366 |
|
5 | 367 |
/** |
368 |
* Fires at the end of the 'At a Glance' dashboard widget. |
|
369 |
* |
|
370 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
371 |
* |
|
372 |
* @since 2.5.0 |
|
373 |
*/ |
|
0 | 374 |
do_action( 'rightnow_end' ); |
5 | 375 |
|
376 |
/** |
|
377 |
* Fires at the end of the 'At a Glance' dashboard widget. |
|
378 |
* |
|
379 |
* Prior to 3.8.0, the widget was named 'Right Now'. |
|
380 |
* |
|
381 |
* @since 2.0.0 |
|
382 |
*/ |
|
0 | 383 |
do_action( 'activity_box_end' ); |
5 | 384 |
|
385 |
$actions = ob_get_clean(); |
|
386 |
||
387 |
if ( !empty( $actions ) ) : ?> |
|
388 |
<div class="sub"> |
|
389 |
<?php echo $actions; ?> |
|
390 |
</div> |
|
391 |
<?php endif; |
|
0 | 392 |
} |
393 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
*/ |
0 | 397 |
function wp_network_dashboard_right_now() { |
398 |
$actions = array(); |
|
399 |
if ( current_user_can('create_sites') ) |
|
400 |
$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
401 |
if ( current_user_can('create_users') ) |
|
402 |
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
403 |
||
404 |
$c_users = get_user_count(); |
|
405 |
$c_blogs = get_blog_count(); |
|
406 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
/* translators: %s: number of users on the network */ |
0 | 408 |
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
/* translators: %s: number of sites on the network */ |
0 | 410 |
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
411 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
/* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */ |
0 | 413 |
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
414 |
||
415 |
if ( $actions ) { |
|
416 |
echo '<ul class="subsubsub">'; |
|
417 |
foreach ( $actions as $class => $action ) { |
|
418 |
$actions[ $class ] = "\t<li class='$class'>$action"; |
|
419 |
} |
|
420 |
echo implode( " |</li>\n", $actions ) . "</li>\n"; |
|
421 |
echo '</ul>'; |
|
422 |
} |
|
423 |
?> |
|
424 |
<br class="clear" /> |
|
425 |
||
426 |
<p class="youhave"><?php echo $sentence; ?></p> |
|
5 | 427 |
|
428 |
||
429 |
<?php |
|
430 |
/** |
|
431 |
* Fires in the Network Admin 'Right Now' dashboard widget |
|
432 |
* just before the user and site search form fields. |
|
433 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
* @since MU (3.0.0) |
5 | 435 |
* |
436 |
* @param null $unused |
|
437 |
*/ |
|
438 |
do_action( 'wpmuadminresult', '' ); |
|
439 |
?> |
|
0 | 440 |
|
441 |
<form action="<?php echo network_admin_url('users.php'); ?>" method="get"> |
|
442 |
<p> |
|
5 | 443 |
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label> |
444 |
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
<?php submit_button( __( 'Search Users' ), '', false, false, array( 'id' => 'submit_users' ) ); ?> |
0 | 446 |
</p> |
447 |
</form> |
|
448 |
||
449 |
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get"> |
|
450 |
<p> |
|
5 | 451 |
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label> |
452 |
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
<?php submit_button( __( 'Search Sites' ), '', false, false, array( 'id' => 'submit_sites' ) ); ?> |
0 | 454 |
</p> |
455 |
</form> |
|
456 |
<?php |
|
5 | 457 |
/** |
458 |
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
|
459 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @since MU (3.0.0) |
5 | 461 |
*/ |
0 | 462 |
do_action( 'mu_rightnow_end' ); |
5 | 463 |
|
464 |
/** |
|
465 |
* Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
|
466 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
* @since MU (3.0.0) |
5 | 468 |
*/ |
0 | 469 |
do_action( 'mu_activity_box_end' ); |
470 |
} |
|
471 |
||
5 | 472 |
/** |
473 |
* The Quick Draft widget display and creation of drafts. |
|
474 |
* |
|
475 |
* @since 3.8.0 |
|
476 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
* @global int $post_ID |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
* |
5 | 479 |
* @param string $error_msg Optional. Error message. Default false. |
480 |
*/ |
|
481 |
function wp_dashboard_quick_press( $error_msg = false ) { |
|
0 | 482 |
global $post_ID; |
483 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
if ( ! current_user_can( 'edit_posts' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
|
0 | 488 |
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ |
489 |
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID |
|
490 |
if ( $last_post_id ) { |
|
491 |
$post = get_post( $last_post_id ); |
|
492 |
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore |
|
5 | 493 |
$post = get_default_post_to_edit( 'post', true ); |
0 | 494 |
update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
495 |
} else { |
|
496 |
$post->post_title = ''; // Remove the auto draft title |
|
497 |
} |
|
498 |
} else { |
|
499 |
$post = get_default_post_to_edit( 'post' , true); |
|
500 |
$user_id = get_current_user_id(); |
|
501 |
// Don't create an option if this is a super admin who does not belong to this site. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) |
0 | 503 |
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
504 |
} |
|
505 |
||
506 |
$post_ID = (int) $post->ID; |
|
507 |
?> |
|
508 |
||
5 | 509 |
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
510 |
||
511 |
<?php if ( $error_msg ) : ?> |
|
512 |
<div class="error"><?php echo $error_msg; ?></div> |
|
513 |
<?php endif; ?> |
|
514 |
||
0 | 515 |
<div class="input-text-wrap" id="title-wrap"> |
5 | 516 |
<label class="screen-reader-text prompt" for="title" id="title-prompt-text"> |
517 |
||
518 |
<?php |
|
519 |
/** This filter is documented in wp-admin/edit-form-advanced.php */ |
|
520 |
echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); |
|
521 |
?> |
|
522 |
</label> |
|
523 |
<input type="text" name="post_title" id="title" autocomplete="off" /> |
|
0 | 524 |
</div> |
525 |
||
5 | 526 |
<div class="textarea-wrap" id="description-wrap"> |
527 |
<label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label> |
|
528 |
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> |
|
0 | 529 |
</div> |
530 |
||
531 |
<p class="submit"> |
|
5 | 532 |
<input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" /> |
0 | 533 |
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> |
534 |
<input type="hidden" name="post_type" value="post" /> |
|
5 | 535 |
<?php wp_nonce_field( 'add-post' ); ?> |
536 |
<?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> |
|
0 | 537 |
<br class="clear" /> |
538 |
</p> |
|
539 |
||
540 |
</form> |
|
5 | 541 |
<?php |
542 |
wp_dashboard_recent_drafts(); |
|
0 | 543 |
} |
544 |
||
545 |
/** |
|
5 | 546 |
* Show recent drafts of the user on the dashboard. |
0 | 547 |
* |
5 | 548 |
* @since 2.7.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
* @param array $drafts |
0 | 551 |
*/ |
5 | 552 |
function wp_dashboard_recent_drafts( $drafts = false ) { |
553 |
if ( ! $drafts ) { |
|
554 |
$query_args = array( |
|
555 |
'post_type' => 'post', |
|
556 |
'post_status' => 'draft', |
|
557 |
'author' => get_current_user_id(), |
|
558 |
'posts_per_page' => 4, |
|
559 |
'orderby' => 'modified', |
|
560 |
'order' => 'DESC' |
|
561 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
* Filters the post query arguments for the 'Recent Drafts' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
* @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
|
5 | 572 |
$drafts = get_posts( $query_args ); |
573 |
if ( ! $drafts ) { |
|
574 |
return; |
|
575 |
} |
|
576 |
} |
|
0 | 577 |
|
5 | 578 |
echo '<div class="drafts">'; |
579 |
if ( count( $drafts ) > 3 ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n"; |
5 | 581 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>"; |
0 | 583 |
|
5 | 584 |
$drafts = array_slice( $drafts, 0, 3 ); |
585 |
foreach ( $drafts as $draft ) { |
|
586 |
$url = get_edit_post_link( $draft->ID ); |
|
587 |
$title = _draft_or_post_title( $draft->ID ); |
|
588 |
echo "<li>\n"; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
/* translators: %s: post title */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>'; |
5 | 592 |
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { |
593 |
echo '<p>' . $the_content . '</p>'; |
|
594 |
} |
|
595 |
echo "</li>\n"; |
|
596 |
} |
|
597 |
echo "</ul>\n</div>"; |
|
0 | 598 |
} |
599 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
* Outputs a row for the Recent Comments widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
* @global WP_Comment $comment |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
* @param WP_Comment $comment The current comment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
* @param bool $show_date Optional. Whether to display the date. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
*/ |
0 | 611 |
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
$GLOBALS['comment'] = clone $comment; |
0 | 613 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
if ( $comment->comment_post_ID > 0 ) { |
5 | 615 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
$comment_post_url = get_the_permalink( $comment->comment_post_ID ); |
5 | 618 |
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>"; |
619 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
$comment_post_link = ''; |
5 | 621 |
} |
622 |
||
0 | 623 |
$actions_string = ''; |
624 |
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
5 | 625 |
// Pre-order it: Approve | Reply | Edit | Spam | Trash. |
0 | 626 |
$actions = array( |
627 |
'approve' => '', 'unapprove' => '', |
|
628 |
'reply' => '', |
|
629 |
'edit' => '', |
|
630 |
'spam' => '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
631 |
'trash' => '', 'delete' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
632 |
'view' => '', |
0 | 633 |
); |
634 |
||
635 |
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
|
636 |
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
|
637 |
||
638 |
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
639 |
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
640 |
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
641 |
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
642 |
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
643 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
if ( ! EMPTY_TRASH_DAYS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
654 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
$actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>'; |
0 | 657 |
|
5 | 658 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
* Filters the action links displayed for each comment in the 'Recent Comments' |
5 | 660 |
* dashboard widget. |
661 |
* |
|
662 |
* @since 2.6.0 |
|
663 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
* @param array $actions An array of comment actions. Default actions include: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
* 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
* 'Delete', and 'Trash'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
* @param WP_Comment $comment The comment object. |
5 | 668 |
*/ |
0 | 669 |
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); |
670 |
||
671 |
$i = 0; |
|
672 |
foreach ( $actions as $action => $link ) { |
|
673 |
++$i; |
|
674 |
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
|
675 |
||
676 |
// Reply and quickedit need a hide-if-no-js span |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
if ( 'reply' == $action || 'quickedit' == $action ) { |
0 | 678 |
$action .= ' hide-if-no-js'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
} |
0 | 680 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
if ( 'view' === $action && '1' !== $comment->comment_approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
$action .= ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
} |
0 | 684 |
$actions_string .= "<span class='$action'>$sep$link</span>"; |
685 |
} |
|
686 |
} |
|
687 |
?> |
|
688 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
<li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>> |
0 | 690 |
|
691 |
<?php echo get_avatar( $comment, 50, 'mystery' ); ?> |
|
692 |
||
5 | 693 |
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?> |
694 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
<div class="dashboard-comment-wrap has-row-actions"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
<p class="comment-meta"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
// Comments might not have a post they relate to, e.g. programmatically created ones. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
if ( $comment_post_link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
__( 'From %1$s on %2$s %3$s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
$comment_post_link, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
/* translators: 1: comment author, 2: notification if the comment is pending */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
__( 'From %1$s %2$s' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
</p> |
0 | 717 |
|
718 |
<?php |
|
719 |
else : |
|
5 | 720 |
switch ( $comment->comment_type ) { |
721 |
case 'pingback' : |
|
722 |
$type = __( 'Pingback' ); |
|
723 |
break; |
|
724 |
case 'trackback' : |
|
725 |
$type = __( 'Trackback' ); |
|
726 |
break; |
|
727 |
default : |
|
728 |
$type = ucwords( $comment->comment_type ); |
|
729 |
} |
|
0 | 730 |
$type = esc_html( $type ); |
731 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
<div class="dashboard-comment-wrap has-row-actions"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
<p class="comment-meta"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
734 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
736 |
if ( $comment_post_link ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
738 |
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
_x( '%1$s on %2$s %3$s', 'dashboard' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
740 |
"<strong>$type</strong>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
$comment_post_link, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
745 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
746 |
/* translators: 1: type of comment, 2: notification if the comment is pending */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
747 |
_x( '%1$s %2$s', 'dashboard' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
"<strong>$type</strong>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
'<span class="approve">' . __( '[Pending]' ) . '</span>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
753 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
<p class="comment-author"><?php comment_author_link( $comment ); ?></p> |
0 | 755 |
|
756 |
<?php endif; // comment_type ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
757 |
<blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
758 |
<?php if ( $actions_string ) : ?> |
0 | 759 |
<p class="row-actions"><?php echo $actions_string; ?></p> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
<?php endif; ?> |
0 | 761 |
</div> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
</li> |
0 | 763 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
$GLOBALS['comment'] = null; |
0 | 765 |
} |
766 |
||
767 |
/** |
|
5 | 768 |
* Callback function for Activity widget. |
0 | 769 |
* |
5 | 770 |
* @since 3.8.0 |
0 | 771 |
*/ |
5 | 772 |
function wp_dashboard_site_activity() { |
773 |
||
774 |
echo '<div id="activity-widget">'; |
|
0 | 775 |
|
5 | 776 |
$future_posts = wp_dashboard_recent_posts( array( |
777 |
'max' => 5, |
|
778 |
'status' => 'future', |
|
779 |
'order' => 'ASC', |
|
780 |
'title' => __( 'Publishing Soon' ), |
|
781 |
'id' => 'future-posts', |
|
782 |
) ); |
|
783 |
$recent_posts = wp_dashboard_recent_posts( array( |
|
784 |
'max' => 5, |
|
785 |
'status' => 'publish', |
|
786 |
'order' => 'DESC', |
|
787 |
'title' => __( 'Recently Published' ), |
|
788 |
'id' => 'published-posts', |
|
789 |
) ); |
|
0 | 790 |
|
5 | 791 |
$recent_comments = wp_dashboard_recent_comments(); |
792 |
||
793 |
if ( !$future_posts && !$recent_posts && !$recent_comments ) { |
|
794 |
echo '<div class="no-activity">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
echo '<p class="smiley" aria-hidden="true"></p>'; |
5 | 796 |
echo '<p>' . __( 'No activity yet!' ) . '</p>'; |
797 |
echo '</div>'; |
|
0 | 798 |
} |
799 |
||
5 | 800 |
echo '</div>'; |
0 | 801 |
} |
802 |
||
803 |
/** |
|
5 | 804 |
* Generates Publishing Soon and Recently Published sections. |
805 |
* |
|
806 |
* @since 3.8.0 |
|
807 |
* |
|
808 |
* @param array $args { |
|
809 |
* An array of query and display arguments. |
|
0 | 810 |
* |
5 | 811 |
* @type int $max Number of posts to display. |
812 |
* @type string $status Post status. |
|
813 |
* @type string $order Designates ascending ('ASC') or descending ('DESC') order. |
|
814 |
* @type string $title Section title. |
|
815 |
* @type string $id The container id. |
|
816 |
* } |
|
817 |
* @return bool False if no posts were found. True otherwise. |
|
0 | 818 |
*/ |
5 | 819 |
function wp_dashboard_recent_posts( $args ) { |
820 |
$query_args = array( |
|
821 |
'post_type' => 'post', |
|
822 |
'post_status' => $args['status'], |
|
823 |
'orderby' => 'date', |
|
824 |
'order' => $args['order'], |
|
825 |
'posts_per_page' => intval( $args['max'] ), |
|
826 |
'no_found_rows' => true, |
|
827 |
'cache_results' => false, |
|
828 |
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', |
|
829 |
); |
|
830 |
||
831 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
* Filters the query arguments used for the Recent Posts widget. |
5 | 833 |
* |
834 |
* @since 4.2.0 |
|
835 |
* |
|
836 |
* @param array $query_args The arguments passed to WP_Query to produce the list of posts. |
|
837 |
*/ |
|
838 |
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); |
|
839 |
$posts = new WP_Query( $query_args ); |
|
0 | 840 |
|
5 | 841 |
if ( $posts->have_posts() ) { |
842 |
||
843 |
echo '<div id="' . $args['id'] . '" class="activity-block">'; |
|
844 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
845 |
echo '<h3>' . $args['title'] . '</h3>'; |
5 | 846 |
|
847 |
echo '<ul>'; |
|
848 |
||
849 |
$today = date( 'Y-m-d', current_time( 'timestamp' ) ); |
|
850 |
$tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); |
|
851 |
||
852 |
while ( $posts->have_posts() ) { |
|
853 |
$posts->the_post(); |
|
854 |
||
855 |
$time = get_the_time( 'U' ); |
|
856 |
if ( date( 'Y-m-d', $time ) == $today ) { |
|
857 |
$relative = __( 'Today' ); |
|
858 |
} elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { |
|
859 |
$relative = __( 'Tomorrow' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
} elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
/* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
$relative = date_i18n( __( 'M jS Y' ), $time ); |
5 | 863 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
/* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */ |
5 | 865 |
$relative = date_i18n( __( 'M jS' ), $time ); |
866 |
} |
|
867 |
||
868 |
// Use the post edit link for those who can edit, the permalink otherwise. |
|
869 |
$recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
|
870 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
$draft_or_post_title = _draft_or_post_title(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
872 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
'<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
/* translators: 1: relative date, 2: time */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
$recent_post_link, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
/* translators: %s: post title */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
878 |
esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
$draft_or_post_title |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
); |
0 | 881 |
} |
882 |
||
5 | 883 |
echo '</ul>'; |
884 |
echo '</div>'; |
|
885 |
||
886 |
} else { |
|
887 |
return false; |
|
0 | 888 |
} |
889 |
||
5 | 890 |
wp_reset_postdata(); |
0 | 891 |
|
5 | 892 |
return true; |
0 | 893 |
} |
894 |
||
895 |
/** |
|
5 | 896 |
* Show Comments section. |
897 |
* |
|
898 |
* @since 3.8.0 |
|
899 |
* |
|
900 |
* @param int $total_items Optional. Number of comments to query. Default 5. |
|
901 |
* @return bool False if no comments were found. True otherwise. |
|
902 |
*/ |
|
903 |
function wp_dashboard_recent_comments( $total_items = 5 ) { |
|
904 |
// Select all comment types and filter out spam later for better query performance. |
|
905 |
$comments = array(); |
|
906 |
||
907 |
$comments_query = array( |
|
908 |
'number' => $total_items * 5, |
|
909 |
'offset' => 0 |
|
910 |
); |
|
911 |
if ( ! current_user_can( 'edit_posts' ) ) |
|
912 |
$comments_query['status'] = 'approve'; |
|
913 |
||
914 |
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
if ( ! is_array( $possible ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
} |
5 | 918 |
foreach ( $possible as $comment ) { |
919 |
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
|
920 |
continue; |
|
921 |
$comments[] = $comment; |
|
922 |
if ( count( $comments ) == $total_items ) |
|
923 |
break 2; |
|
924 |
} |
|
925 |
$comments_query['offset'] += $comments_query['number']; |
|
926 |
$comments_query['number'] = $total_items * 10; |
|
927 |
} |
|
928 |
||
929 |
if ( $comments ) { |
|
930 |
echo '<div id="latest-comments" class="activity-block">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
echo '<h3>' . __( 'Recent Comments' ) . '</h3>'; |
5 | 932 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
933 |
echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; |
5 | 934 |
foreach ( $comments as $comment ) |
935 |
_wp_dashboard_recent_comments_row( $comment ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
echo '</ul>'; |
5 | 937 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
if ( current_user_can( 'edit_posts' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
_get_list_table( 'WP_Comments_List_Table' )->views(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
} |
5 | 942 |
|
943 |
wp_comment_reply( -1, false, 'dashboard', false ); |
|
944 |
wp_comment_trashnotice(); |
|
945 |
||
946 |
echo '</div>'; |
|
947 |
} else { |
|
948 |
return false; |
|
949 |
} |
|
950 |
return true; |
|
951 |
} |
|
952 |
||
953 |
/** |
|
954 |
* Display generic dashboard RSS widget feed. |
|
0 | 955 |
* |
956 |
* @since 2.5.0 |
|
957 |
* |
|
958 |
* @param string $widget_id |
|
959 |
*/ |
|
960 |
function wp_dashboard_rss_output( $widget_id ) { |
|
961 |
$widgets = get_option( 'dashboard_widget_options' ); |
|
962 |
echo '<div class="rss-widget">'; |
|
5 | 963 |
wp_widget_rss_output( $widgets[ $widget_id ] ); |
0 | 964 |
echo "</div>"; |
965 |
} |
|
966 |
||
967 |
/** |
|
968 |
* Checks to see if all of the feed url in $check_urls are cached. |
|
969 |
* |
|
970 |
* If $check_urls is empty, look for the rss feed url found in the dashboard |
|
971 |
* widget options of $widget_id. If cached, call $callback, a function that |
|
972 |
* echoes out output for this widget. If not cache, echo a "Loading..." stub |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
973 |
* which is later replaced by Ajax call (see top of /wp-admin/index.php) |
0 | 974 |
* |
975 |
* @since 2.5.0 |
|
976 |
* |
|
977 |
* @param string $widget_id |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
* @param callable $callback |
0 | 979 |
* @param array $check_urls RSS feeds |
980 |
* @return bool False on failure. True on success. |
|
981 |
*/ |
|
982 |
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
$doing_ajax = wp_doing_ajax(); |
0 | 985 |
|
986 |
if ( empty($check_urls) ) { |
|
987 |
$widgets = get_option( 'dashboard_widget_options' ); |
|
988 |
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) { |
|
989 |
echo $loading; |
|
990 |
return false; |
|
991 |
} |
|
992 |
$check_urls = array( $widgets[$widget_id]['url'] ); |
|
993 |
} |
|
994 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
$locale = get_user_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
0 | 997 |
if ( false !== ( $output = get_transient( $cache_key ) ) ) { |
998 |
echo $output; |
|
999 |
return true; |
|
1000 |
} |
|
1001 |
||
1002 |
if ( ! $doing_ajax ) { |
|
1003 |
echo $loading; |
|
1004 |
return false; |
|
1005 |
} |
|
1006 |
||
1007 |
if ( $callback && is_callable( $callback ) ) { |
|
5 | 1008 |
$args = array_slice( func_get_args(), 3 ); |
1009 |
array_unshift( $args, $widget_id, $check_urls ); |
|
0 | 1010 |
ob_start(); |
1011 |
call_user_func_array( $callback, $args ); |
|
1012 |
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) |
|
1013 |
} |
|
1014 |
||
1015 |
return true; |
|
1016 |
} |
|
1017 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
// |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
// Dashboard Widgets Controls |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
// |
0 | 1021 |
|
1022 |
/** |
|
1023 |
* Calls widget control callback. |
|
1024 |
* |
|
1025 |
* @since 2.5.0 |
|
1026 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
* @global array $wp_dashboard_control_callbacks |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
* |
0 | 1029 |
* @param int $widget_control_id Registered Widget ID. |
1030 |
*/ |
|
1031 |
function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { |
|
1032 |
global $wp_dashboard_control_callbacks; |
|
1033 |
||
1034 |
if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) { |
|
1035 |
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) ); |
|
1036 |
} |
|
1037 |
} |
|
1038 |
||
1039 |
/** |
|
1040 |
* The RSS dashboard widget control. |
|
1041 |
* |
|
1042 |
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data |
|
1043 |
* from RSS-type widgets. |
|
1044 |
* |
|
1045 |
* @since 2.5.0 |
|
1046 |
* |
|
1047 |
* @param string $widget_id |
|
1048 |
* @param array $form_inputs |
|
1049 |
*/ |
|
1050 |
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
|
1051 |
if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) |
|
1052 |
$widget_options = array(); |
|
1053 |
||
1054 |
if ( !isset($widget_options[$widget_id]) ) |
|
1055 |
$widget_options[$widget_id] = array(); |
|
1056 |
||
1057 |
$number = 1; // Hack to use wp_widget_rss_form() |
|
1058 |
$widget_options[$widget_id]['number'] = $number; |
|
1059 |
||
1060 |
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { |
|
1061 |
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); |
|
1062 |
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); |
|
1063 |
$widget_options[$widget_id]['number'] = $number; |
|
5 | 1064 |
|
1065 |
// Title is optional. If black, fill it if possible. |
|
0 | 1066 |
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { |
1067 |
$rss = fetch_feed($widget_options[$widget_id]['url']); |
|
1068 |
if ( is_wp_error($rss) ) { |
|
1069 |
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); |
|
1070 |
} else { |
|
1071 |
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); |
|
1072 |
$rss->__destruct(); |
|
1073 |
unset($rss); |
|
1074 |
} |
|
1075 |
} |
|
1076 |
update_option( 'dashboard_widget_options', $widget_options ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
$locale = get_user_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); |
0 | 1079 |
delete_transient( $cache_key ); |
1080 |
} |
|
1081 |
||
1082 |
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); |
|
1083 |
} |
|
1084 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
* Renders the Events and News dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
function wp_dashboard_events_news() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1092 |
wp_print_community_events_markup(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
<div class="wordpress-news hide-if-no-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
<?php wp_dashboard_primary(); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
<p class="community-events-footer"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1101 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1102 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1103 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
'https://make.wordpress.org/community/meetups-landing-page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
__( 'Meetups' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
/* translators: accessibility text */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
__( '(opens in a new window)' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
| |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
'https://central.wordcamp.org/schedule/', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
__( 'WordCamps' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
/* translators: accessibility text */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
__( '(opens in a new window)' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1120 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1121 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
| |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
__( 'News' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
/* translators: accessibility text */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
__( '(opens in a new window)' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1135 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1139 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
* Prints the markup for the Community Events section of the Events and News Dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
function wp_print_community_events_markup() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1146 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
<div class="community-events-errors notice notice-error inline hide-if-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
<p class="hide-if-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
<?php _e( 'This widget requires JavaScript.' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
<p class="community-events-error-occurred" aria-hidden="true"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
<?php _e( 'An error occurred. Please try again.' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1156 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
<p class="community-events-could-not-locate" aria-hidden="true"></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
<div class="community-events-loading hide-if-no-js"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
<?php _e( 'Loading…' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
* Hide the main element when the page first loads, because the content |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
* won't be ready until wp.communityEvents.renderEventsTemplate() has run. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
<div id="community-events" class="community-events" aria-hidden="true"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1171 |
<div class="activity-block"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
<span id="community-events-location-message"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1174 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
<button class="button-link community-events-toggle-location" aria-label="<?php esc_attr_e( 'Edit city' ); ?>" aria-expanded="false"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
<span class="dashicons dashicons-edit"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
</button> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1178 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
<form class="community-events-form" aria-hidden="true" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" method="post"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
<label for="community-events-location"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
<?php _e( 'City:' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
</label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1184 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
/* translators: Replace with a city related to your locale. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1186 |
* Test that it matches the expected location and has upcoming |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1187 |
* events before including it. If no cities related to your |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1188 |
* locale have events, then use a city related to your locale |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1189 |
* that would be recognizable to most users. Use only the city |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1190 |
* name itself, without any region or country. Use the endonym |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1191 |
* (native locale name) instead of the English name if possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1192 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
<input id="community-events-location" class="regular-text" type="text" name="community-events-location" placeholder="<?php esc_attr_e( 'Cincinnati' ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1195 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1196 |
<?php submit_button( __( 'Submit' ), 'secondary', 'community-events-submit', false ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1197 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1198 |
<button class="community-events-cancel button-link" type="button" aria-expanded="false"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1199 |
<?php _e( 'Cancel' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1200 |
</button> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1201 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
<span class="spinner"></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1203 |
</form> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1204 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1205 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
<ul class="community-events-results activity-block last"></ul> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1207 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1208 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1212 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
* Renders the events templates for the Event and News widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
function wp_print_community_events_templates() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
<script id="tmpl-community-events-attend-event-near" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
<?php printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1222 |
/* translators: %s: the name of a city */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
__( 'Attend an upcoming event near %s.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
'<strong>{{ data.location.description }}</strong>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
<script id="tmpl-community-events-could-not-locate" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
<?php printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
/* translators: %s is the name of the city we couldn't locate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
* Replace the examples with cities in your locale, but test |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
* that they match the expected location before including them. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* Use endonyms (native locale names) whenever possible. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
__( 'We couldn’t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
'<em>{{data.unknownCity}}</em>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
<script id="tmpl-community-events-event-list" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
<# _.each( data.events, function( event ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
<li class="event event-{{ event.type }} wp-clearfix"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
<div class="event-info"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
<div class="dashicons event-icon" aria-hidden="true"></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
<div class="event-info-inner"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
<span class="event-city">{{ event.location.location }}</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1249 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
<div class="event-date-time"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
<span class="event-date">{{ event.formatted_date }}</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
<# if ( 'meetup' === event.type ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
<span class="event-time">{{ event.formatted_time }}</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
<# } ) #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
<script id="tmpl-community-events-no-upcoming-events" type="text/template"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
<li class="event-none"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
<# if ( data.location.description ) { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
<?php printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
__( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
'{{ data.location.description }}', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
<# } else { #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
<?php printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
/* translators: %s: meetup organization documentation URL */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
__( 'There aren’t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
<# } #> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
</li> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
|
0 | 1283 |
/** |
5 | 1284 |
* WordPress News dashboard widget. |
1285 |
* |
|
1286 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
* @since 4.8.0 Removed popular plugins feed. |
5 | 1288 |
*/ |
1289 |
function wp_dashboard_primary() { |
|
1290 |
$feeds = array( |
|
1291 |
'news' => array( |
|
1292 |
||
1293 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
* Filters the primary link URL for the 'WordPress News' dashboard widget. |
5 | 1295 |
* |
1296 |
* @since 2.5.0 |
|
1297 |
* |
|
1298 |
* @param string $link The widget's primary link URL. |
|
1299 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ), |
5 | 1301 |
|
1302 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
* Filters the primary feed URL for the 'WordPress News' dashboard widget. |
5 | 1304 |
* |
1305 |
* @since 2.3.0 |
|
1306 |
* |
|
1307 |
* @param string $url The widget's primary feed URL. |
|
1308 |
*/ |
|
1309 |
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), |
|
1310 |
||
1311 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* Filters the primary link title for the 'WordPress News' dashboard widget. |
5 | 1313 |
* |
1314 |
* @since 2.3.0 |
|
1315 |
* |
|
1316 |
* @param string $title Title attribute for the widget's primary link. |
|
1317 |
*/ |
|
1318 |
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), |
|
1319 |
'items' => 1, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
'show_summary' => 0, |
5 | 1321 |
'show_author' => 0, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
'show_date' => 0, |
5 | 1323 |
), |
1324 |
'planet' => array( |
|
1325 |
||
1326 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
* Filters the secondary link URL for the 'WordPress News' dashboard widget. |
5 | 1328 |
* |
1329 |
* @since 2.3.0 |
|
1330 |
* |
|
1331 |
* @param string $link The widget's secondary link URL. |
|
1332 |
*/ |
|
1333 |
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), |
|
1334 |
||
1335 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
* Filters the secondary feed URL for the 'WordPress News' dashboard widget. |
5 | 1337 |
* |
1338 |
* @since 2.3.0 |
|
1339 |
* |
|
1340 |
* @param string $url The widget's secondary feed URL. |
|
1341 |
*/ |
|
1342 |
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), |
|
1343 |
||
1344 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
* Filters the secondary link title for the 'WordPress News' dashboard widget. |
5 | 1346 |
* |
1347 |
* @since 2.3.0 |
|
1348 |
* |
|
1349 |
* @param string $title Title attribute for the widget's secondary link. |
|
1350 |
*/ |
|
1351 |
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* Filters the number of secondary link items for the 'WordPress News' dashboard widget. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* @param string $items How many items to show in the secondary feed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
'items' => apply_filters( 'dashboard_secondary_items', 3 ), |
5 | 1361 |
'show_summary' => 0, |
1362 |
'show_author' => 0, |
|
1363 |
'show_date' => 0, |
|
1364 |
) |
|
1365 |
); |
|
1366 |
||
1367 |
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds ); |
|
1368 |
} |
|
1369 |
||
1370 |
/** |
|
1371 |
* Display the WordPress news feeds. |
|
1372 |
* |
|
1373 |
* @since 3.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
* @since 4.8.0 Removed popular plugins feed. |
5 | 1375 |
* |
1376 |
* @param string $widget_id Widget ID. |
|
1377 |
* @param array $feeds Array of RSS feeds. |
|
1378 |
*/ |
|
1379 |
function wp_dashboard_primary_output( $widget_id, $feeds ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
foreach ( $feeds as $type => $args ) { |
5 | 1381 |
$args['type'] = $type; |
1382 |
echo '<div class="rss-widget">'; |
|
1383 |
wp_widget_rss_output( $args['url'], $args ); |
|
1384 |
echo "</div>"; |
|
1385 |
} |
|
1386 |
} |
|
1387 |
||
1388 |
/** |
|
0 | 1389 |
* Display file upload quota on dashboard. |
1390 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* Runs on the {@see 'activity_box_end'} hook in wp_dashboard_right_now(). |
0 | 1392 |
* |
1393 |
* @since 3.0.0 |
|
1394 |
* |
|
5 | 1395 |
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
*/ |
0 | 1397 |
function wp_dashboard_quota() { |
5 | 1398 |
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) |
0 | 1399 |
return true; |
1400 |
||
1401 |
$quota = get_space_allowed(); |
|
1402 |
$used = get_space_used(); |
|
1403 |
||
1404 |
if ( $used > $quota ) |
|
1405 |
$percentused = '100'; |
|
1406 |
else |
|
1407 |
$percentused = ( $used / $quota ) * 100; |
|
5 | 1408 |
$used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
0 | 1409 |
$used = round( $used, 2 ); |
1410 |
$percentused = number_format( $percentused ); |
|
1411 |
||
1412 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3> |
5 | 1414 |
<div class="mu-storage"> |
1415 |
<ul> |
|
1416 |
<li class="storage-count"> |
|
1417 |
<?php $text = sprintf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1418 |
/* translators: %s: number of megabytes */ |
5 | 1419 |
__( '%s MB Space Allowed' ), |
1420 |
number_format_i18n( $quota ) |
|
1421 |
); |
|
1422 |
printf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>', |
5 | 1424 |
esc_url( admin_url( 'upload.php' ) ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
$text, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
__( 'Manage Uploads' ) |
5 | 1427 |
); ?> |
1428 |
</li><li class="storage-count <?php echo $used_class; ?>"> |
|
1429 |
<?php $text = sprintf( |
|
1430 |
/* translators: 1: number of megabytes, 2: percentage */ |
|
1431 |
__( '%1$s MB (%2$s%%) Space Used' ), |
|
1432 |
number_format_i18n( $used, 2 ), |
|
1433 |
$percentused |
|
1434 |
); |
|
1435 |
printf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1436 |
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>', |
5 | 1437 |
esc_url( admin_url( 'upload.php' ) ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
$text, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
__( 'Manage Uploads' ) |
5 | 1440 |
); ?> |
1441 |
</li> |
|
1442 |
</ul> |
|
0 | 1443 |
</div> |
1444 |
<?php |
|
1445 |
} |
|
1446 |
||
1447 |
// Display Browser Nag Meta Box |
|
1448 |
function wp_dashboard_browser_nag() { |
|
1449 |
$notice = ''; |
|
1450 |
$response = wp_check_browser_version(); |
|
1451 |
||
1452 |
if ( $response ) { |
|
1453 |
if ( $response['insecure'] ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
/* translators: %s: browser name and link */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
$msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1456 |
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
); |
0 | 1458 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
/* translators: %s: browser name and link */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
$msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
); |
0 | 1463 |
} |
1464 |
||
1465 |
$browser_nag_class = ''; |
|
1466 |
if ( !empty( $response['img_src'] ) ) { |
|
1467 |
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; |
|
1468 |
||
1469 |
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; |
|
1470 |
$browser_nag_class = ' has-browser-icon'; |
|
1471 |
} |
|
1472 |
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; |
|
1473 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
$browsehappy = 'https://browsehappy.com/'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
$locale = get_user_locale(); |
0 | 1476 |
if ( 'en_US' !== $locale ) |
1477 |
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
1478 |
||
1479 |
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
0 | 1481 |
$notice .= '<div class="clear"></div>'; |
1482 |
} |
|
1483 |
||
5 | 1484 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1485 |
* Filters the notice output for the 'Browse Happy' nag meta box. |
5 | 1486 |
* |
1487 |
* @since 3.2.0 |
|
1488 |
* |
|
1489 |
* @param string $notice The notice content. |
|
1490 |
* @param array $response An array containing web browser information. |
|
1491 |
*/ |
|
0 | 1492 |
echo apply_filters( 'browse-happy-notice', $notice, $response ); |
1493 |
} |
|
1494 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1495 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1496 |
* @since 3.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1497 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1498 |
* @param array $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1500 |
*/ |
0 | 1501 |
function dashboard_browser_nag_class( $classes ) { |
1502 |
$response = wp_check_browser_version(); |
|
1503 |
||
1504 |
if ( $response && $response['insecure'] ) |
|
1505 |
$classes[] = 'browser-insecure'; |
|
1506 |
||
1507 |
return $classes; |
|
1508 |
} |
|
1509 |
||
1510 |
/** |
|
1511 |
* Check if the user needs a browser update |
|
1512 |
* |
|
1513 |
* @since 3.2.0 |
|
1514 |
* |
|
1515 |
* @return array|bool False on failure, array of browser data on success. |
|
1516 |
*/ |
|
1517 |
function wp_check_browser_version() { |
|
1518 |
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
|
1519 |
return false; |
|
1520 |
||
1521 |
$key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
|
1522 |
||
1523 |
if ( false === ($response = get_site_transient('browser_' . $key) ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
// include an unmodified $wp_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
include( ABSPATH . WPINC . '/version.php' ); |
0 | 1526 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1527 |
$url = 'http://api.wordpress.org/core/browse-happy/1.1/'; |
0 | 1528 |
$options = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) |
0 | 1531 |
); |
1532 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1533 |
if ( wp_http_supports( array( 'ssl' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1534 |
$url = set_url_scheme( $url, 'https' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
$response = wp_remote_post( $url, $options ); |
0 | 1538 |
|
1539 |
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
1540 |
return false; |
|
1541 |
||
1542 |
/** |
|
1543 |
* Response should be an array with: |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1544 |
* 'platform' - string - A user-friendly platform name, if it can be determined |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1545 |
* 'name' - string - A user-friendly browser name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
* 'version' - string - The version of the browser the user is using |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
* 'current_version' - string - The most recent version of the browser |
0 | 1548 |
* 'upgrade' - boolean - Whether the browser needs an upgrade |
1549 |
* 'insecure' - boolean - Whether the browser is deemed insecure |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
* 'update_url' - string - The url to visit to upgrade |
0 | 1551 |
* 'img_src' - string - An image representing the browser |
1552 |
* 'img_src_ssl' - string - An image (over SSL) representing the browser |
|
1553 |
*/ |
|
1554 |
$response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
1555 |
||
1556 |
if ( ! is_array( $response ) ) |
|
1557 |
return false; |
|
1558 |
||
1559 |
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
|
1560 |
} |
|
1561 |
||
1562 |
return $response; |
|
1563 |
} |
|
1564 |
||
1565 |
/** |
|
1566 |
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS). |
|
1567 |
*/ |
|
1568 |
function wp_dashboard_empty() {} |
|
1569 |
||
1570 |
/** |
|
1571 |
* Displays a welcome panel to introduce users to WordPress. |
|
1572 |
* |
|
1573 |
* @since 3.3.0 |
|
1574 |
*/ |
|
1575 |
function wp_welcome_panel() { |
|
1576 |
?> |
|
1577 |
<div class="welcome-panel-content"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
<h2><?php _e( 'Welcome to WordPress!' ); ?></h2> |
0 | 1579 |
<p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p> |
1580 |
<div class="welcome-panel-column-container"> |
|
1581 |
<div class="welcome-panel-column"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
<?php if ( current_user_can( 'customize' ) ) : ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1583 |
<h3><?php _e( 'Get Started' ); ?></h3> |
5 | 1584 |
<a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
1585 |
<?php endif; ?> |
|
0 | 1586 |
<a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
1587 |
<?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1588 |
<?php $themes_link = current_user_can( 'customize' ) ? add_query_arg( 'autofocus[panel]', 'themes', admin_url( 'customize.php' ) ) : admin_url( 'themes.php' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1589 |
<p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), $themes_link ); ?></p> |
0 | 1590 |
<?php endif; ?> |
1591 |
</div> |
|
1592 |
<div class="welcome-panel-column"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1593 |
<h3><?php _e( 'Next Steps' ); ?></h3> |
0 | 1594 |
<ul> |
1595 |
<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> |
|
1596 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
1597 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1598 |
<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?> |
|
1599 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
1600 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1601 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
1602 |
<?php else : ?> |
|
1603 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
1604 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1605 |
<?php endif; ?> |
|
1606 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li> |
|
1607 |
</ul> |
|
1608 |
</div> |
|
1609 |
<div class="welcome-panel-column welcome-panel-last"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1610 |
<h3><?php _e( 'More Actions' ); ?></h3> |
0 | 1611 |
<ul> |
5 | 1612 |
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?> |
1613 |
<li><div class="welcome-icon welcome-widgets-menus"><?php |
|
1614 |
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) { |
|
1615 |
printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ), |
|
1616 |
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); |
|
1617 |
} elseif ( current_theme_supports( 'widgets' ) ) { |
|
1618 |
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>'; |
|
1619 |
} else { |
|
1620 |
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>'; |
|
1621 |
} |
|
1622 |
?></div></li> |
|
1623 |
<?php endif; ?> |
|
1624 |
<?php if ( current_user_can( 'manage_options' ) ) : ?> |
|
0 | 1625 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li> |
5 | 1626 |
<?php endif; ?> |
1627 |
<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li> |
|
0 | 1628 |
</ul> |
1629 |
</div> |
|
1630 |
</div> |
|
1631 |
</div> |
|
1632 |
<?php |
|
1633 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1634 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1635 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1636 |
* Displays a Try Gutenberg Panel, to introduce people to Gutenberg |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1637 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1638 |
* @since 4.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1639 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1640 |
function wp_try_gutenberg_panel() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1641 |
$plugins = get_plugins(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1642 |
$action = $url = $classes = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1643 |
$classic_action = $classic_url = $classic_classes = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1644 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1645 |
if ( current_user_can( 'install_plugins' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1646 |
if ( empty( $plugins['gutenberg/gutenberg.php'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1647 |
if ( get_filesystem_method( array(), WP_PLUGIN_DIR ) === 'direct' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1648 |
$action = __( 'Install Gutenberg' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1649 |
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=gutenberg' ), 'install-plugin_gutenberg' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1650 |
$classes = ' install-now'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1651 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1652 |
} else if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1653 |
$action = __( 'Activate Gutenberg' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1654 |
$url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=gutenberg/gutenberg.php&from=try-gutenberg' ), 'activate-plugin_gutenberg/gutenberg.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1655 |
$classes = ' activate-now'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1656 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1657 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1658 |
if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1659 |
if ( get_filesystem_method( array(), WP_PLUGIN_DIR ) === 'direct' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1660 |
$classic_action = __( 'Install the Classic Editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1661 |
$classic_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=classic-editor' ), 'install-plugin_classic-editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1662 |
$classic_classes = ' install-now'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1663 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1664 |
} else if ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1665 |
$classic_action = __( 'Activate the Classic Editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1666 |
$classic_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php&from=try-gutenberg' ), 'activate-plugin_classic-editor/classic-editor.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1667 |
$classic_classes = ' activate-now'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1668 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1669 |
$classic_action = __( 'The Classic Editor is activated' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1670 |
$classic_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php&from=try-gutenberg' ), 'activate-plugin_classic-editor/classic-editor.php' );; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1671 |
$classic_classes = ' button-disabled install-now updated-message'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1672 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1673 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1674 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1675 |
if ( current_user_can( 'edit_posts' ) && is_plugin_active( 'gutenberg/gutenberg.php' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1676 |
$action = __( 'Try Gutenberg' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1677 |
$url = admin_url( 'admin.php?page=gutenberg' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1678 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1679 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1680 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1681 |
<div class="try-gutenberg-panel-content"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1682 |
<h2><?php _e( 'A new, modern publishing experience is coming soon.' ); ?></h2> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1683 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1684 |
<p class="about-description"><?php _e( "Take your words, media, and layout in new directions with Gutenberg, the WordPress editor we're currently building." ); ?></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1685 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1686 |
<hr /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1687 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1688 |
<div class="try-gutenberg-panel-column-container"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1689 |
<div class="try-gutenberg-panel-column try-gutenberg-panel-image-column"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1690 |
<picture> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1691 |
<source srcset="about:blank" media="(max-width: 1024px)"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1692 |
<img src="https://s.w.org/images/core/gutenberg-screenshot.png?<?php echo date( 'Ymd' ); ?>" alt="<?php esc_attr_e( 'Screenshot from the Gutenberg interface' ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1693 |
</picture> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1694 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1695 |
<div class="try-gutenberg-panel-column plugin-card-gutenberg"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1697 |
<div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1698 |
<h3><?php _e( 'Test the new editor today.' ); ?></h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1699 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1700 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1701 |
<?php _e( "You can take Gutenberg for a spin (and share your feedback, if you’d like) before we officially release it, by installing it as a plugin." ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1702 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1703 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1704 |
/* translators: 1: Gutenberg call for testing handbook link, 2: Gutenberg GitHub repository issues link, 3: Gutenberg GitHub repository CONTRIBUTING.md link */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1705 |
__( 'You can help by <a href="%1$s">testing</a>, <a href="%2$s">filing bugs</a>, or contributing on the <a href="%3$s">GitHub repository</a>.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1706 |
'https://make.wordpress.org/test/handbook/call-for-testing/gutenberg-testing/', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1707 |
'https://github.com/WordPress/gutenberg/issues', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1708 |
'https://github.com/WordPress/gutenberg/blob/master/CONTRIBUTING.md' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1709 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1710 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1711 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1712 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1713 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1714 |
<div class="try-gutenberg-action"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1715 |
<?php if ( $action ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1716 |
<p><a class="button button-primary button-hero<?php echo $classes; ?>" href="<?php echo esc_url( $url ); ?>" data-name="<?php esc_attr_e( 'Gutenberg' ); ?>" data-slug="gutenberg"><?php echo $action; ?></a></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1717 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1718 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1719 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1720 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1721 |
$learnmore = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1722 |
/* translators: Link to https://wordpress.org/gutenberg/ */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1723 |
__( '<a href="%s">Learn more about Gutenberg</a>' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1724 |
__( 'https://wordpress.org/gutenberg/' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1725 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1726 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1727 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1728 |
* Filters the "Learn more" link in the Try Gutenberg panel. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1729 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1730 |
* It allows hosts or site owners to change the link, to provide extra |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1731 |
* information about Gutenberg, specific to their service. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1732 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1733 |
* WARNING: This filter will only exist in the 4.9.x series, it will not be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1734 |
* added to WordPress 5.0 and later. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1735 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1736 |
* @since 4.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1737 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1738 |
echo apply_filters( 'try_gutenberg_learn_more_link', $learnmore ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1739 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1740 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1741 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1742 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1743 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1744 |
<div class="try-gutenberg-panel-column plugin-card-classic-editor"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1745 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1746 |
<div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1747 |
<h3><?php _e( 'Not quite ready?' ); ?></h3> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1748 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1749 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1750 |
<?php _e( 'The new editor will be enabled by default in the next major release of WordPress. If you’re not sure how compatible your current themes and plugins are, we’ve got you covered.' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1751 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1752 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1753 |
/* translators: Link to the Classic Editor plugin page */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1754 |
__( 'Install the <a href="%s">Classic Editor plugin</a> to keep using the current editor until you’re ready to make the switch.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1755 |
__( 'https://wordpress.org/plugins/classic-editor' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1756 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1757 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1758 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1759 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1760 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1761 |
<?php if ( $classic_action ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1762 |
<div class="try-gutenberg-action"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1763 |
<p><a class="button button-secondary button-hero<?php echo $classic_classes; ?>" href="<?php echo esc_url( $classic_url ); ?>" data-name="<?php esc_attr_e( 'Classic Editor' ); ?>" data-slug="classic-editor"><?php echo $classic_action; ?></a></p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1764 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1765 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1766 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1767 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1768 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1769 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1770 |
} |