changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
child 204 | 09a1c134465b |
193:2f6f6f7551ca | 194:32102edaa81b |
---|---|
5 * A Big Mess. Also some neat functions that are nicely written. |
5 * A Big Mess. Also some neat functions that are nicely written. |
6 * |
6 * |
7 * @package WordPress |
7 * @package WordPress |
8 * @subpackage Administration |
8 * @subpackage Administration |
9 */ |
9 */ |
10 |
|
11 // Ugly recursive category stuff. |
|
12 /** |
|
13 * {@internal Missing Short Description}} |
|
14 * |
|
15 * @since unknown |
|
16 * |
|
17 * @param unknown_type $parent |
|
18 * @param unknown_type $level |
|
19 * @param unknown_type $categories |
|
20 * @param unknown_type $page |
|
21 * @param unknown_type $per_page |
|
22 */ |
|
23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) { |
|
24 |
|
25 $count = 0; |
|
26 |
|
27 if ( empty($categories) ) { |
|
28 |
|
29 $args = array('hide_empty' => 0); |
|
30 if ( !empty($_GET['s']) ) |
|
31 $args['search'] = $_GET['s']; |
|
32 |
|
33 $categories = get_categories( $args ); |
|
34 |
|
35 if ( empty($categories) ) |
|
36 return false; |
|
37 } |
|
38 |
|
39 $children = _get_term_hierarchy('category'); |
|
40 |
|
41 _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count ); |
|
42 |
|
43 } |
|
44 |
|
45 /** |
|
46 * {@internal Missing Short Description}} |
|
47 * |
|
48 * @since unknown |
|
49 * |
|
50 * @param unknown_type $categories |
|
51 * @param unknown_type $count |
|
52 * @param unknown_type $parent |
|
53 * @param unknown_type $level |
|
54 * @param unknown_type $page |
|
55 * @param unknown_type $per_page |
|
56 * @return unknown |
|
57 */ |
|
58 function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) { |
|
59 |
|
60 $start = ($page - 1) * $per_page; |
|
61 $end = $start + $per_page; |
|
62 ob_start(); |
|
63 |
|
64 foreach ( $categories as $key => $category ) { |
|
65 if ( $count >= $end ) |
|
66 break; |
|
67 |
|
68 if ( $category->parent != $parent && empty($_GET['s']) ) |
|
69 continue; |
|
70 |
|
71 // If the page starts in a subtree, print the parents. |
|
72 if ( $count == $start && $category->parent > 0 ) { |
|
73 |
|
74 $my_parents = array(); |
|
75 $p = $category->parent; |
|
76 while ( $p ) { |
|
77 $my_parent = get_category( $p ); |
|
78 $my_parents[] = $my_parent; |
|
79 if ( $my_parent->parent == 0 ) |
|
80 break; |
|
81 $p = $my_parent->parent; |
|
82 } |
|
83 |
|
84 $num_parents = count($my_parents); |
|
85 while( $my_parent = array_pop($my_parents) ) { |
|
86 echo "\t" . _cat_row( $my_parent, $level - $num_parents ); |
|
87 $num_parents--; |
|
88 } |
|
89 } |
|
90 |
|
91 if ( $count >= $start ) |
|
92 echo "\t" . _cat_row( $category, $level ); |
|
93 |
|
94 unset( $categories[ $key ] ); |
|
95 |
|
96 $count++; |
|
97 |
|
98 if ( isset($children[$category->term_id]) ) |
|
99 _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count ); |
|
100 } |
|
101 |
|
102 $output = ob_get_contents(); |
|
103 ob_end_clean(); |
|
104 |
|
105 echo $output; |
|
106 } |
|
107 |
|
108 /** |
|
109 * {@internal Missing Short Description}} |
|
110 * |
|
111 * @since unknown |
|
112 * |
|
113 * @param unknown_type $category |
|
114 * @param unknown_type $level |
|
115 * @param unknown_type $name_override |
|
116 * @return unknown |
|
117 */ |
|
118 function _cat_row( $category, $level, $name_override = false ) { |
|
119 static $row_class = ''; |
|
120 |
|
121 $category = get_category( $category, OBJECT, 'display' ); |
|
122 |
|
123 $default_cat_id = (int) get_option( 'default_category' ); |
|
124 $pad = str_repeat( '— ', max(0, $level) ); |
|
125 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); |
|
126 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; |
|
127 if ( current_user_can( 'manage_categories' ) ) { |
|
128 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>" . esc_attr( $name ) . '</a><br />'; |
|
129 $actions = array(); |
|
130 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
131 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; |
|
132 if ( $default_cat_id != $category->term_id ) |
|
133 $actions['delete'] = "<a class='delete:the-list:cat-$category->term_id submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>"; |
|
134 $actions = apply_filters('cat_row_actions', $actions, $category); |
|
135 $action_count = count($actions); |
|
136 $i = 0; |
|
137 $edit .= '<div class="row-actions">'; |
|
138 foreach ( $actions as $action => $link ) { |
|
139 ++$i; |
|
140 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
141 $edit .= "<span class='$action'>$link$sep</span>"; |
|
142 } |
|
143 $edit .= '</div>'; |
|
144 } else { |
|
145 $edit = $name; |
|
146 } |
|
147 |
|
148 $row_class = 'alternate' == $row_class ? '' : 'alternate'; |
|
149 $qe_data = get_category_to_edit($category->term_id); |
|
150 |
|
151 $category->count = number_format_i18n( $category->count ); |
|
152 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count; |
|
153 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>"; |
|
154 |
|
155 $columns = get_column_headers('categories'); |
|
156 $hidden = get_hidden_columns('categories'); |
|
157 foreach ( $columns as $column_name => $column_display_name ) { |
|
158 $class = "class=\"$column_name column-$column_name\""; |
|
159 |
|
160 $style = ''; |
|
161 if ( in_array($column_name, $hidden) ) |
|
162 $style = ' style="display:none;"'; |
|
163 |
|
164 $attributes = "$class$style"; |
|
165 |
|
166 switch ($column_name) { |
|
167 case 'cb': |
|
168 $output .= "<th scope='row' class='check-column'>"; |
|
169 if ( $default_cat_id != $category->term_id ) { |
|
170 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />"; |
|
171 } else { |
|
172 $output .= " "; |
|
173 } |
|
174 $output .= '</th>'; |
|
175 break; |
|
176 case 'name': |
|
177 $output .= "<td $attributes>$edit"; |
|
178 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
179 $output .= '<div class="name">' . $qe_data->name . '</div>'; |
|
180 $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>'; |
|
181 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>'; |
|
182 break; |
|
183 case 'description': |
|
184 $output .= "<td $attributes>$category->description</td>"; |
|
185 break; |
|
186 case 'slug': |
|
187 $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>"; |
|
188 break; |
|
189 case 'posts': |
|
190 $attributes = 'class="posts column-posts num"' . $style; |
|
191 $output .= "<td $attributes>$posts_count</td>\n"; |
|
192 break; |
|
193 default: |
|
194 $output .= "<td $attributes>"; |
|
195 $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id); |
|
196 $output .= "</td>"; |
|
197 } |
|
198 } |
|
199 $output .= '</tr>'; |
|
200 |
|
201 return $output; |
|
202 } |
|
203 |
|
204 /** |
|
205 * {@internal Missing Short Description}} |
|
206 * |
|
207 * @since 2.7 |
|
208 * |
|
209 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. |
|
210 * |
|
211 * @param string $type "tag", "category" or "link-category" |
|
212 * @return |
|
213 */ |
|
214 function inline_edit_term_row($type) { |
|
215 |
|
216 if ( ! current_user_can( 'manage_categories' ) ) |
|
217 return; |
|
218 |
|
219 $is_tag = $type == 'edit-tags'; |
|
220 $columns = get_column_headers($type); |
|
221 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); |
|
222 $col_count = count($columns) - count($hidden); |
|
223 ?> |
|
224 |
|
225 <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> |
|
226 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>"> |
|
227 |
|
228 <fieldset><div class="inline-edit-col"> |
|
229 <h4><?php _e( 'Quick Edit' ); ?></h4> |
|
230 |
|
231 <label> |
|
232 <span class="title"><?php _e( 'Name' ); ?></span> |
|
233 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
|
234 </label> |
|
235 |
|
236 <label> |
|
237 <span class="title"><?php _e( 'Slug' ); ?></span> |
|
238 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
|
239 </label> |
|
240 |
|
241 <?php if ( 'category' == $type ) : ?> |
|
242 |
|
243 <label> |
|
244 <span class="title"><?php _e( 'Parent' ); ?></span> |
|
245 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?> |
|
246 </label> |
|
247 |
|
248 <?php endif; // $type ?> |
|
249 |
|
250 </div></fieldset> |
|
251 |
|
252 <?php |
|
253 |
|
254 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); |
|
255 |
|
256 foreach ( $columns as $column_name => $column_display_name ) { |
|
257 if ( isset( $core_columns[$column_name] ) ) |
|
258 continue; |
|
259 do_action( 'quick_edit_custom_box', $column_name, $type ); |
|
260 } |
|
261 |
|
262 ?> |
|
263 |
|
264 <p class="inline-edit-save submit"> |
|
265 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a> |
|
266 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?> |
|
267 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a> |
|
268 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /> |
|
269 <span class="error" style="display:none;"></span> |
|
270 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
271 <br class="clear" /> |
|
272 </p> |
|
273 </td></tr> |
|
274 </tbody></table></form> |
|
275 <?php |
|
276 } |
|
277 |
|
278 /** |
|
279 * {@internal Missing Short Description}} |
|
280 * |
|
281 * @since unknown |
|
282 * |
|
283 * @param unknown_type $category |
|
284 * @param unknown_type $name_override |
|
285 * @return unknown |
|
286 */ |
|
287 function link_cat_row( $category, $name_override = false ) { |
|
288 static $row_class = ''; |
|
289 |
|
290 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) ) |
|
291 return false; |
|
292 if ( is_wp_error( $category ) ) |
|
293 return $category; |
|
294 |
|
295 $default_cat_id = (int) get_option( 'default_link_category' ); |
|
296 $name = ( $name_override ? $name_override : $category->name ); |
|
297 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; |
|
298 if ( current_user_can( 'manage_categories' ) ) { |
|
299 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>$name</a><br />"; |
|
300 $actions = array(); |
|
301 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
302 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; |
|
303 if ( $default_cat_id != $category->term_id ) |
|
304 $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>"; |
|
305 $actions = apply_filters('link_cat_row_actions', $actions, $category); |
|
306 $action_count = count($actions); |
|
307 $i = 0; |
|
308 $edit .= '<div class="row-actions">'; |
|
309 foreach ( $actions as $action => $link ) { |
|
310 ++$i; |
|
311 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
312 $edit .= "<span class='$action'>$link$sep</span>"; |
|
313 } |
|
314 $edit .= '</div>'; |
|
315 } else { |
|
316 $edit = $name; |
|
317 } |
|
318 |
|
319 $row_class = 'alternate' == $row_class ? '' : 'alternate'; |
|
320 $qe_data = get_term_to_edit($category->term_id, 'link_category'); |
|
321 |
|
322 $category->count = number_format_i18n( $category->count ); |
|
323 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; |
|
324 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>"; |
|
325 $columns = get_column_headers('edit-link-categories'); |
|
326 $hidden = get_hidden_columns('edit-link-categories'); |
|
327 foreach ( $columns as $column_name => $column_display_name ) { |
|
328 $class = "class=\"$column_name column-$column_name\""; |
|
329 |
|
330 $style = ''; |
|
331 if ( in_array($column_name, $hidden) ) |
|
332 $style = ' style="display:none;"'; |
|
333 |
|
334 $attributes = "$class$style"; |
|
335 |
|
336 switch ($column_name) { |
|
337 case 'cb': |
|
338 $output .= "<th scope='row' class='check-column'>"; |
|
339 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { |
|
340 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />"; |
|
341 } else { |
|
342 $output .= " "; |
|
343 } |
|
344 $output .= "</th>"; |
|
345 break; |
|
346 case 'name': |
|
347 $output .= "<td $attributes>$edit"; |
|
348 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
349 $output .= '<div class="name">' . $qe_data->name . '</div>'; |
|
350 $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>'; |
|
351 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>'; |
|
352 break; |
|
353 case 'description': |
|
354 $output .= "<td $attributes>$category->description</td>"; |
|
355 break; |
|
356 case 'slug': |
|
357 $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>"; |
|
358 break; |
|
359 case 'links': |
|
360 $attributes = 'class="links column-links num"' . $style; |
|
361 $output .= "<td $attributes>$count</td>"; |
|
362 break; |
|
363 default: |
|
364 $output .= "<td $attributes>"; |
|
365 $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id); |
|
366 $output .= "</td>"; |
|
367 } |
|
368 } |
|
369 $output .= '</tr>'; |
|
370 |
|
371 return $output; |
|
372 } |
|
373 |
|
374 /** |
|
375 * Outputs the html checked attribute. |
|
376 * |
|
377 * Compares the first two arguments and if identical marks as checked |
|
378 * |
|
379 * @since 1.0 |
|
380 * |
|
381 * @param any $checked One of the values to compare |
|
382 * @param any $current (true) The other value to compare if not just true |
|
383 * @param bool $echo Whether or not to echo or just return the string |
|
384 */ |
|
385 function checked( $checked, $current = true, $echo = true) { |
|
386 return __checked_selected_helper( $checked, $current, $echo, 'checked' ); |
|
387 } |
|
388 |
|
389 /** |
|
390 * Outputs the html selected attribute. |
|
391 * |
|
392 * Compares the first two arguments and if identical marks as selected |
|
393 * |
|
394 * @since 1.0 |
|
395 * |
|
396 * @param any selected One of the values to compare |
|
397 * @param any $current (true) The other value to compare if not just true |
|
398 * @param bool $echo Whether or not to echo or just return the string |
|
399 */ |
|
400 function selected( $selected, $current = true, $echo = true) { |
|
401 return __checked_selected_helper( $selected, $current, $echo, 'selected' ); |
|
402 } |
|
403 |
|
404 /** |
|
405 * Private helper function for checked and selected. |
|
406 * |
|
407 * Compares the first two arguments and if identical marks as $type |
|
408 * |
|
409 * @since 2.8 |
|
410 * @access private |
|
411 * |
|
412 * @param any $helper One of the values to compare |
|
413 * @param any $current (true) The other value to compare if not just true |
|
414 * @param bool $echo Whether or not to echo or just return the string |
|
415 * @param string $type The type of checked|selected we are doing. |
|
416 */ |
|
417 function __checked_selected_helper( $helper, $current, $echo, $type) { |
|
418 if ( (string) $helper === (string) $current) |
|
419 $result = " $type='$type'"; |
|
420 else |
|
421 $result = ''; |
|
422 |
|
423 if ($echo) |
|
424 echo $result; |
|
425 |
|
426 return $result; |
|
427 } |
|
428 |
10 |
429 // |
11 // |
430 // Category Checklists |
12 // Category Checklists |
431 // |
13 // |
432 |
14 |
433 /** |
15 /** |
434 * {@internal Missing Short Description}} |
16 * Walker to output an unordered list of category checkbox <input> elements. |
435 * |
17 * |
436 * @since unknown |
18 * @see Walker |
437 * @deprecated Use {@link wp_link_category_checklist()} |
19 * @see wp_category_checklist() |
438 * @see wp_link_category_checklist() |
20 * @see wp_terms_checklist() |
439 * |
21 * @since 2.5.1 |
440 * @param unknown_type $default |
|
441 * @param unknown_type $parent |
|
442 * @param unknown_type $popular_ids |
|
443 */ |
|
444 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { |
|
445 global $post_ID; |
|
446 wp_category_checklist($post_ID); |
|
447 } |
|
448 |
|
449 /** |
|
450 * {@internal Missing Short Description}} |
|
451 * |
|
452 * @since unknown |
|
453 */ |
22 */ |
454 class Walker_Category_Checklist extends Walker { |
23 class Walker_Category_Checklist extends Walker { |
455 var $tree_type = 'category'; |
24 var $tree_type = 'category'; |
456 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this |
25 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this |
457 |
26 |
458 function start_lvl(&$output, $depth, $args) { |
27 function start_lvl( &$output, $depth = 0, $args = array() ) { |
459 $indent = str_repeat("\t", $depth); |
28 $indent = str_repeat("\t", $depth); |
460 $output .= "$indent<ul class='children'>\n"; |
29 $output .= "$indent<ul class='children'>\n"; |
461 } |
30 } |
462 |
31 |
463 function end_lvl(&$output, $depth, $args) { |
32 function end_lvl( &$output, $depth = 0, $args = array() ) { |
464 $indent = str_repeat("\t", $depth); |
33 $indent = str_repeat("\t", $depth); |
465 $output .= "$indent</ul>\n"; |
34 $output .= "$indent</ul>\n"; |
466 } |
35 } |
467 |
36 |
468 function start_el(&$output, $category, $depth, $args) { |
37 function start_el( &$output, $category, $depth, $args, $id = 0 ) { |
469 extract($args); |
38 extract($args); |
39 if ( empty($taxonomy) ) |
|
40 $taxonomy = 'category'; |
|
41 |
|
42 if ( $taxonomy == 'category' ) |
|
43 $name = 'post_category'; |
|
44 else |
|
45 $name = 'tax_input['.$taxonomy.']'; |
|
470 |
46 |
471 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; |
47 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; |
472 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; |
48 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; |
473 } |
49 } |
474 |
50 |
475 function end_el(&$output, $category, $depth, $args) { |
51 function end_el( &$output, $category, $depth = 0, $args = array() ) { |
476 $output .= "</li>\n"; |
52 $output .= "</li>\n"; |
477 } |
53 } |
478 } |
54 } |
479 |
55 |
480 /** |
56 /** |
481 * {@internal Missing Short Description}} |
57 * Output an unordered list of checkbox <input> elements labelled |
482 * |
58 * with category names. |
483 * @since unknown |
59 * |
484 * |
60 * @see wp_terms_checklist() |
485 * @param unknown_type $post_id |
61 * @since 2.5.1 |
486 * @param unknown_type $descendants_and_self |
62 * |
487 * @param unknown_type $selected_cats |
63 * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array. |
488 * @param unknown_type $popular_cats |
64 * @param int $descendants_and_self ID of the category to output along with its descendents. |
65 * @param bool|array $selected_cats List of categories to mark as checked. |
|
66 * @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class. |
|
67 * @param object $walker Walker object to use to build the output. |
|
68 * @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list. |
|
489 */ |
69 */ |
490 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { |
70 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { |
71 wp_terms_checklist( $post_id, array( |
|
72 'taxonomy' => 'category', |
|
73 'descendants_and_self' => $descendants_and_self, |
|
74 'selected_cats' => $selected_cats, |
|
75 'popular_cats' => $popular_cats, |
|
76 'walker' => $walker, |
|
77 'checked_ontop' => $checked_ontop |
|
78 ) ); |
|
79 } |
|
80 |
|
81 /** |
|
82 * Output an unordered list of checkbox <input> elements labelled |
|
83 * with term names. Taxonomy independent version of wp_category_checklist(). |
|
84 * |
|
85 * @since 3.0.0 |
|
86 * |
|
87 * @param int $post_id |
|
88 * @param array $args |
|
89 */ |
|
90 function wp_terms_checklist($post_id = 0, $args = array()) { |
|
91 $defaults = array( |
|
92 'descendants_and_self' => 0, |
|
93 'selected_cats' => false, |
|
94 'popular_cats' => false, |
|
95 'walker' => null, |
|
96 'taxonomy' => 'category', |
|
97 'checked_ontop' => true |
|
98 ); |
|
99 $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); |
|
100 |
|
101 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); |
|
102 |
|
491 if ( empty($walker) || !is_a($walker, 'Walker') ) |
103 if ( empty($walker) || !is_a($walker, 'Walker') ) |
492 $walker = new Walker_Category_Checklist; |
104 $walker = new Walker_Category_Checklist; |
493 |
105 |
494 $descendants_and_self = (int) $descendants_and_self; |
106 $descendants_and_self = (int) $descendants_and_self; |
495 |
107 |
496 $args = array(); |
108 $args = array('taxonomy' => $taxonomy); |
109 |
|
110 $tax = get_taxonomy($taxonomy); |
|
111 $args['disabled'] = !current_user_can($tax->cap->assign_terms); |
|
497 |
112 |
498 if ( is_array( $selected_cats ) ) |
113 if ( is_array( $selected_cats ) ) |
499 $args['selected_cats'] = $selected_cats; |
114 $args['selected_cats'] = $selected_cats; |
500 elseif ( $post_id ) |
115 elseif ( $post_id ) |
501 $args['selected_cats'] = wp_get_post_categories($post_id); |
116 $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); |
502 else |
117 else |
503 $args['selected_cats'] = array(); |
118 $args['selected_cats'] = array(); |
504 |
119 |
505 if ( is_array( $popular_cats ) ) |
120 if ( is_array( $popular_cats ) ) |
506 $args['popular_cats'] = $popular_cats; |
121 $args['popular_cats'] = $popular_cats; |
507 else |
122 else |
508 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
123 $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
509 |
124 |
510 if ( $descendants_and_self ) { |
125 if ( $descendants_and_self ) { |
511 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" ); |
126 $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); |
512 $self = get_category( $descendants_and_self ); |
127 $self = get_term( $descendants_and_self, $taxonomy ); |
513 array_unshift( $categories, $self ); |
128 array_unshift( $categories, $self ); |
514 } else { |
129 } else { |
515 $categories = get_categories('get=all'); |
130 $categories = (array) get_terms($taxonomy, array('get' => 'all')); |
516 } |
131 } |
517 |
132 |
518 if ( $checked_ontop ) { |
133 if ( $checked_ontop ) { |
519 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
134 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) |
520 $checked_categories = array(); |
135 $checked_categories = array(); |
533 // Then the rest of them |
148 // Then the rest of them |
534 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); |
149 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); |
535 } |
150 } |
536 |
151 |
537 /** |
152 /** |
538 * {@internal Missing Short Description}} |
153 * Retrieve a list of the most popular terms from the specified taxonomy. |
539 * |
154 * |
540 * @since unknown |
155 * If the $echo argument is true then the elements for a list of checkbox |
541 * |
156 * <input> elements labelled with the names of the selected terms is output. |
542 * @param unknown_type $taxonomy |
157 * If the $post_ID global isn't empty then the terms associated with that |
543 * @param unknown_type $default |
158 * post will be marked as checked. |
544 * @param unknown_type $number |
159 * |
545 * @param unknown_type $echo |
160 * @since 2.5.0 |
546 * @return unknown |
161 * |
162 * @param string $taxonomy Taxonomy to retrieve terms from. |
|
163 * @param int $default Unused. |
|
164 * @param int $number Number of terms to retrieve. Defaults to 10. |
|
165 * @param bool $echo Optionally output the list as well. Defaults to true. |
|
166 * @return array List of popular term IDs. |
|
547 */ |
167 */ |
548 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
168 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { |
549 global $post_ID; |
169 global $post_ID; |
550 |
170 |
551 if ( $post_ID ) |
171 if ( $post_ID ) |
552 $checked_categories = wp_get_post_categories($post_ID); |
172 $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); |
553 else |
173 else |
554 $checked_categories = array(); |
174 $checked_terms = array(); |
555 |
175 |
556 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
176 $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); |
177 |
|
178 $tax = get_taxonomy($taxonomy); |
|
179 if ( ! current_user_can($tax->cap->assign_terms) ) |
|
180 $disabled = 'disabled="disabled"'; |
|
181 else |
|
182 $disabled = ''; |
|
557 |
183 |
558 $popular_ids = array(); |
184 $popular_ids = array(); |
559 foreach ( (array) $categories as $category ) { |
185 foreach ( (array) $terms as $term ) { |
560 $popular_ids[] = $category->term_id; |
186 $popular_ids[] = $term->term_id; |
561 if ( !$echo ) // hack for AJAX use |
187 if ( !$echo ) // hack for AJAX use |
562 continue; |
188 continue; |
563 $id = "popular-category-$category->term_id"; |
189 $id = "popular-$taxonomy-$term->term_id"; |
564 $checked = in_array( $category->term_id, $checked_categories ) ? 'checked="checked"' : ''; |
190 $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : ''; |
565 ?> |
191 ?> |
566 |
192 |
567 <li id="<?php echo $id; ?>" class="popular-category"> |
193 <li id="<?php echo $id; ?>" class="popular-category"> |
568 <label class="selectit"> |
194 <label class="selectit"> |
569 <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $category->term_id; ?>" /> |
195 <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/> |
570 <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?> |
196 <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?> |
571 </label> |
197 </label> |
572 </li> |
198 </li> |
573 |
199 |
574 <?php |
200 <?php |
575 } |
201 } |
577 } |
203 } |
578 |
204 |
579 /** |
205 /** |
580 * {@internal Missing Short Description}} |
206 * {@internal Missing Short Description}} |
581 * |
207 * |
582 * @since unknown |
208 * @since 2.5.1 |
583 * @deprecated Use {@link wp_link_category_checklist()} |
|
584 * @see wp_link_category_checklist() |
|
585 * |
|
586 * @param unknown_type $default |
|
587 */ |
|
588 function dropdown_link_categories( $default = 0 ) { |
|
589 global $link_id; |
|
590 |
|
591 wp_link_category_checklist($link_id); |
|
592 } |
|
593 |
|
594 /** |
|
595 * {@internal Missing Short Description}} |
|
596 * |
|
597 * @since unknown |
|
598 * |
209 * |
599 * @param unknown_type $link_id |
210 * @param unknown_type $link_id |
600 */ |
211 */ |
601 function wp_link_category_checklist( $link_id = 0 ) { |
212 function wp_link_category_checklist( $link_id = 0 ) { |
602 $default = 1; |
213 $default = 1; |
603 |
214 |
604 if ( $link_id ) { |
215 if ( $link_id ) { |
605 $checked_categories = wp_get_link_cats($link_id); |
216 $checked_categories = wp_get_link_cats( $link_id ); |
606 |
217 // No selected categories, strange |
607 if ( count( $checked_categories ) == 0 ) { |
218 if ( ! count( $checked_categories ) ) |
608 // No selected categories, strange |
|
609 $checked_categories[] = $default; |
219 $checked_categories[] = $default; |
610 } |
|
611 } else { |
220 } else { |
612 $checked_categories[] = $default; |
221 $checked_categories[] = $default; |
613 } |
222 } |
614 |
223 |
615 $categories = get_terms('link_category', 'orderby=count&hide_empty=0'); |
224 $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) ); |
616 |
225 |
617 if ( empty($categories) ) |
226 if ( empty( $categories ) ) |
618 return; |
227 return; |
619 |
228 |
620 foreach ( $categories as $category ) { |
229 foreach ( $categories as $category ) { |
621 $cat_id = $category->term_id; |
230 $cat_id = $category->term_id; |
622 $name = esc_html( apply_filters('the_category', $category->name)); |
231 $name = esc_html( apply_filters( 'the_category', $category->name ) ); |
623 $checked = in_array( $cat_id, $checked_categories ); |
232 $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; |
624 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>"; |
233 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>"; |
625 } |
234 } |
626 } |
235 } |
627 |
236 |
628 // Tag stuff |
237 // adds hidden fields with the data for use in the inline editor for posts and pages |
629 |
|
630 // Returns a single tag row (see tag_rows below) |
|
631 // Note: this is also used in admin-ajax.php! |
|
632 /** |
238 /** |
633 * {@internal Missing Short Description}} |
239 * {@internal Missing Short Description}} |
634 * |
240 * |
635 * @since unknown |
|
636 * |
|
637 * @param unknown_type $tag |
|
638 * @param unknown_type $class |
|
639 * @return unknown |
|
640 */ |
|
641 function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) { |
|
642 $count = number_format_i18n( $tag->count ); |
|
643 $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy); |
|
644 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count; |
|
645 |
|
646 $name = apply_filters( 'term_name', $tag->name ); |
|
647 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit'); |
|
648 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id"; |
|
649 $out = ''; |
|
650 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; |
|
651 $columns = get_column_headers('edit-tags'); |
|
652 $hidden = get_hidden_columns('edit-tags'); |
|
653 foreach ( $columns as $column_name => $column_display_name ) { |
|
654 $class = "class=\"$column_name column-$column_name\""; |
|
655 |
|
656 $style = ''; |
|
657 if ( in_array($column_name, $hidden) ) |
|
658 $style = ' style="display:none;"'; |
|
659 |
|
660 $attributes = "$class$style"; |
|
661 |
|
662 switch ($column_name) { |
|
663 case 'cb': |
|
664 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>'; |
|
665 break; |
|
666 case 'name': |
|
667 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />'; |
|
668 $actions = array(); |
|
669 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
670 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; |
|
671 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>"; |
|
672 $actions = apply_filters('tag_row_actions', $actions, $tag); |
|
673 $action_count = count($actions); |
|
674 $i = 0; |
|
675 $out .= '<div class="row-actions">'; |
|
676 foreach ( $actions as $action => $link ) { |
|
677 ++$i; |
|
678 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
679 $out .= "<span class='$action'>$link$sep</span>"; |
|
680 } |
|
681 $out .= '</div>'; |
|
682 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
683 $out .= '<div class="name">' . $qe_data->name . '</div>'; |
|
684 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div></div></td>'; |
|
685 break; |
|
686 case 'description': |
|
687 $out .= "<td $attributes>$tag->description</td>"; |
|
688 break; |
|
689 case 'slug': |
|
690 $out .= "<td $attributes>" . apply_filters('editable_slug', $tag->slug) . "</td>"; |
|
691 break; |
|
692 case 'posts': |
|
693 $attributes = 'class="posts column-posts num"' . $style; |
|
694 $out .= "<td $attributes>$count</td>"; |
|
695 break; |
|
696 default: |
|
697 $out .= "<td $attributes>"; |
|
698 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id); |
|
699 $out .= "</td>"; |
|
700 } |
|
701 } |
|
702 |
|
703 $out .= '</tr>'; |
|
704 |
|
705 return $out; |
|
706 } |
|
707 |
|
708 // Outputs appropriate rows for the Nth page of the Tag Management screen, |
|
709 // assuming M tags displayed at a time on the page |
|
710 // Returns the number of tags displayed |
|
711 /** |
|
712 * {@internal Missing Short Description}} |
|
713 * |
|
714 * @since unknown |
|
715 * |
|
716 * @param unknown_type $page |
|
717 * @param unknown_type $pagesize |
|
718 * @param unknown_type $searchterms |
|
719 * @return unknown |
|
720 */ |
|
721 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) { |
|
722 |
|
723 // Get a page worth of tags |
|
724 $start = ($page - 1) * $pagesize; |
|
725 |
|
726 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0); |
|
727 |
|
728 if ( !empty( $searchterms ) ) { |
|
729 $args['search'] = $searchterms; |
|
730 } |
|
731 |
|
732 $tags = get_terms( $taxonomy, $args ); |
|
733 |
|
734 // convert it to table rows |
|
735 $out = ''; |
|
736 $count = 0; |
|
737 foreach( $tags as $tag ) |
|
738 $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '', $taxonomy ); |
|
739 |
|
740 // filter and send to screen |
|
741 echo $out; |
|
742 return $count; |
|
743 } |
|
744 |
|
745 // define the columns to display, the syntax is 'internal name' => 'display name' |
|
746 /** |
|
747 * {@internal Missing Short Description}} |
|
748 * |
|
749 * @since unknown |
|
750 * |
|
751 * @return unknown |
|
752 */ |
|
753 function wp_manage_posts_columns() { |
|
754 $posts_columns = array(); |
|
755 $posts_columns['cb'] = '<input type="checkbox" />'; |
|
756 /* translators: manage posts column name */ |
|
757 $posts_columns['title'] = _x('Post', 'column name'); |
|
758 $posts_columns['author'] = __('Author'); |
|
759 $posts_columns['categories'] = __('Categories'); |
|
760 $posts_columns['tags'] = __('Tags'); |
|
761 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; |
|
762 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) ) |
|
763 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; |
|
764 $posts_columns['date'] = __('Date'); |
|
765 $posts_columns = apply_filters('manage_posts_columns', $posts_columns); |
|
766 |
|
767 return $posts_columns; |
|
768 } |
|
769 |
|
770 // define the columns to display, the syntax is 'internal name' => 'display name' |
|
771 /** |
|
772 * {@internal Missing Short Description}} |
|
773 * |
|
774 * @since unknown |
|
775 * |
|
776 * @return unknown |
|
777 */ |
|
778 function wp_manage_media_columns() { |
|
779 $posts_columns = array(); |
|
780 $posts_columns['cb'] = '<input type="checkbox" />'; |
|
781 $posts_columns['icon'] = ''; |
|
782 /* translators: column name */ |
|
783 $posts_columns['media'] = _x('File', 'column name'); |
|
784 $posts_columns['author'] = __('Author'); |
|
785 //$posts_columns['tags'] = _x('Tags', 'column name'); |
|
786 /* translators: column name */ |
|
787 $posts_columns['parent'] = _x('Attached to', 'column name'); |
|
788 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>'; |
|
789 //$posts_columns['comments'] = __('Comments'); |
|
790 /* translators: column name */ |
|
791 $posts_columns['date'] = _x('Date', 'column name'); |
|
792 $posts_columns = apply_filters('manage_media_columns', $posts_columns); |
|
793 |
|
794 return $posts_columns; |
|
795 } |
|
796 |
|
797 /** |
|
798 * {@internal Missing Short Description}} |
|
799 * |
|
800 * @since unknown |
|
801 * |
|
802 * @return unknown |
|
803 */ |
|
804 function wp_manage_pages_columns() { |
|
805 $posts_columns = array(); |
|
806 $posts_columns['cb'] = '<input type="checkbox" />'; |
|
807 $posts_columns['title'] = __('Title'); |
|
808 $posts_columns['author'] = __('Author'); |
|
809 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all'; |
|
810 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) ) |
|
811 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>'; |
|
812 $posts_columns['date'] = __('Date'); |
|
813 $posts_columns = apply_filters('manage_pages_columns', $posts_columns); |
|
814 |
|
815 return $posts_columns; |
|
816 } |
|
817 |
|
818 /** |
|
819 * {@internal Missing Short Description}} |
|
820 * |
|
821 * @since unknown |
|
822 * |
|
823 * @param unknown_type $page |
|
824 * @return unknown |
|
825 */ |
|
826 function get_column_headers($page) { |
|
827 global $_wp_column_headers; |
|
828 |
|
829 if ( !isset($_wp_column_headers) ) |
|
830 $_wp_column_headers = array(); |
|
831 |
|
832 // Store in static to avoid running filters on each call |
|
833 if ( isset($_wp_column_headers[$page]) ) |
|
834 return $_wp_column_headers[$page]; |
|
835 |
|
836 switch ($page) { |
|
837 case 'edit': |
|
838 $_wp_column_headers[$page] = wp_manage_posts_columns(); |
|
839 break; |
|
840 case 'edit-pages': |
|
841 $_wp_column_headers[$page] = wp_manage_pages_columns(); |
|
842 break; |
|
843 case 'edit-comments': |
|
844 $_wp_column_headers[$page] = array( |
|
845 'cb' => '<input type="checkbox" />', |
|
846 'author' => __('Author'), |
|
847 /* translators: column name */ |
|
848 'comment' => _x('Comment', 'column name'), |
|
849 //'date' => __('Submitted'), |
|
850 'response' => __('In Response To') |
|
851 ); |
|
852 |
|
853 break; |
|
854 case 'link-manager': |
|
855 $_wp_column_headers[$page] = array( |
|
856 'cb' => '<input type="checkbox" />', |
|
857 'name' => __('Name'), |
|
858 'url' => __('URL'), |
|
859 'categories' => __('Categories'), |
|
860 'rel' => __('Relationship'), |
|
861 'visible' => __('Visible'), |
|
862 'rating' => __('Rating') |
|
863 ); |
|
864 |
|
865 break; |
|
866 case 'upload': |
|
867 $_wp_column_headers[$page] = wp_manage_media_columns(); |
|
868 break; |
|
869 case 'categories': |
|
870 $_wp_column_headers[$page] = array( |
|
871 'cb' => '<input type="checkbox" />', |
|
872 'name' => __('Name'), |
|
873 'description' => __('Description'), |
|
874 'slug' => __('Slug'), |
|
875 'posts' => __('Posts') |
|
876 ); |
|
877 |
|
878 break; |
|
879 case 'edit-link-categories': |
|
880 $_wp_column_headers[$page] = array( |
|
881 'cb' => '<input type="checkbox" />', |
|
882 'name' => __('Name'), |
|
883 'description' => __('Description'), |
|
884 'slug' => __('Slug'), |
|
885 'links' => __('Links') |
|
886 ); |
|
887 |
|
888 break; |
|
889 case 'edit-tags': |
|
890 $_wp_column_headers[$page] = array( |
|
891 'cb' => '<input type="checkbox" />', |
|
892 'name' => __('Name'), |
|
893 'description' => __('Description'), |
|
894 'slug' => __('Slug'), |
|
895 'posts' => __('Posts') |
|
896 ); |
|
897 |
|
898 break; |
|
899 case 'users': |
|
900 $_wp_column_headers[$page] = array( |
|
901 'cb' => '<input type="checkbox" />', |
|
902 'username' => __('Username'), |
|
903 'name' => __('Name'), |
|
904 'email' => __('E-mail'), |
|
905 'role' => __('Role'), |
|
906 'posts' => __('Posts') |
|
907 ); |
|
908 break; |
|
909 default : |
|
910 $_wp_column_headers[$page] = array(); |
|
911 } |
|
912 |
|
913 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]); |
|
914 return $_wp_column_headers[$page]; |
|
915 } |
|
916 |
|
917 /** |
|
918 * {@internal Missing Short Description}} |
|
919 * |
|
920 * @since unknown |
|
921 * |
|
922 * @param unknown_type $type |
|
923 * @param unknown_type $id |
|
924 */ |
|
925 function print_column_headers( $type, $id = true ) { |
|
926 $type = str_replace('.php', '', $type); |
|
927 $columns = get_column_headers( $type ); |
|
928 $hidden = get_hidden_columns($type); |
|
929 $styles = array(); |
|
930 // $styles['tag']['posts'] = 'width: 90px;'; |
|
931 // $styles['link-category']['links'] = 'width: 90px;'; |
|
932 // $styles['category']['posts'] = 'width: 90px;'; |
|
933 // $styles['link']['visible'] = 'text-align: center;'; |
|
934 |
|
935 foreach ( $columns as $column_key => $column_display_name ) { |
|
936 $class = ' class="manage-column'; |
|
937 |
|
938 $class .= " column-$column_key"; |
|
939 |
|
940 if ( 'cb' == $column_key ) |
|
941 $class .= ' check-column'; |
|
942 elseif ( in_array($column_key, array('posts', 'comments', 'links')) ) |
|
943 $class .= ' num'; |
|
944 |
|
945 $class .= '"'; |
|
946 |
|
947 $style = ''; |
|
948 if ( in_array($column_key, $hidden) ) |
|
949 $style = 'display:none;'; |
|
950 |
|
951 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) ) |
|
952 $style .= ' ' . $styles[$type][$column_key]; |
|
953 $style = ' style="' . $style . '"'; |
|
954 ?> |
|
955 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th> |
|
956 <?php } |
|
957 } |
|
958 |
|
959 /** |
|
960 * Register column headers for a particular screen. The header names will be listed in the Screen Options. |
|
961 * |
|
962 * @since 2.7.0 |
241 * @since 2.7.0 |
963 * |
242 * |
964 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. |
|
965 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values |
|
966 * @see get_column_headers(), print_column_headers(), get_hidden_columns() |
|
967 */ |
|
968 function register_column_headers($screen, $columns) { |
|
969 global $_wp_column_headers; |
|
970 |
|
971 if ( !isset($_wp_column_headers) ) |
|
972 $_wp_column_headers = array(); |
|
973 |
|
974 $_wp_column_headers[$screen] = $columns; |
|
975 } |
|
976 |
|
977 /** |
|
978 * {@internal Missing Short Description}} |
|
979 * |
|
980 * @since unknown |
|
981 * |
|
982 * @param unknown_type $page |
|
983 */ |
|
984 function get_hidden_columns($page) { |
|
985 $page = str_replace('.php', '', $page); |
|
986 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false ); |
|
987 } |
|
988 |
|
989 /** |
|
990 * {@internal Missing Short Description}} |
|
991 * |
|
992 * Outputs the quick edit and bulk edit table rows for posts and pages |
|
993 * |
|
994 * @since 2.7 |
|
995 * |
|
996 * @param string $type 'post' or 'page' |
|
997 */ |
|
998 function inline_edit_row( $type ) { |
|
999 global $current_user, $mode; |
|
1000 |
|
1001 $is_page = 'page' == $type; |
|
1002 if ( $is_page ) { |
|
1003 $screen = 'edit-pages'; |
|
1004 $post = get_default_page_to_edit(); |
|
1005 } else { |
|
1006 $screen = 'edit'; |
|
1007 $post = get_default_post_to_edit(); |
|
1008 } |
|
1009 |
|
1010 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns(); |
|
1011 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) ); |
|
1012 $col_count = count($columns) - count($hidden); |
|
1013 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; |
|
1014 $can_publish = current_user_can("publish_{$type}s"); |
|
1015 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); |
|
1016 |
|
1017 ?> |
|
1018 |
|
1019 <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> |
|
1020 <?php |
|
1021 $bulk = 0; |
|
1022 while ( $bulk < 2 ) { ?> |
|
1023 |
|
1024 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type "; |
|
1025 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type"; |
|
1026 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>"> |
|
1027 |
|
1028 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> |
|
1029 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4> |
|
1030 |
|
1031 |
|
1032 <?php if ( $bulk ) : ?> |
|
1033 <div id="bulk-title-div"> |
|
1034 <div id="bulk-titles"></div> |
|
1035 </div> |
|
1036 |
|
1037 <?php else : // $bulk ?> |
|
1038 |
|
1039 <label> |
|
1040 <span class="title"><?php _e( 'Title' ); ?></span> |
|
1041 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
|
1042 </label> |
|
1043 |
|
1044 <?php endif; // $bulk ?> |
|
1045 |
|
1046 |
|
1047 <?php if ( !$bulk ) : ?> |
|
1048 |
|
1049 <label> |
|
1050 <span class="title"><?php _e( 'Slug' ); ?></span> |
|
1051 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> |
|
1052 </label> |
|
1053 |
|
1054 <label><span class="title"><?php _e( 'Date' ); ?></span></label> |
|
1055 <div class="inline-edit-date"> |
|
1056 <?php touch_time(1, 1, 4, 1); ?> |
|
1057 </div> |
|
1058 <br class="clear" /> |
|
1059 |
|
1060 <?php endif; // $bulk |
|
1061 |
|
1062 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM |
|
1063 $authors_dropdown = ''; |
|
1064 if ( $authors && count( $authors ) > 1 ) : |
|
1065 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0); |
|
1066 if ( $bulk ) |
|
1067 $users_opt['show_option_none'] = __('- No Change -'); |
|
1068 $authors_dropdown = '<label>'; |
|
1069 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
1070 $authors_dropdown .= wp_dropdown_users( $users_opt ); |
|
1071 $authors_dropdown .= '</label>'; |
|
1072 |
|
1073 endif; // authors |
|
1074 ?> |
|
1075 |
|
1076 <?php if ( !$bulk ) : echo $authors_dropdown; ?> |
|
1077 |
|
1078 <div class="inline-edit-group"> |
|
1079 <label class="alignleft"> |
|
1080 <span class="title"><?php _e( 'Password' ); ?></span> |
|
1081 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
|
1082 </label> |
|
1083 |
|
1084 <em style="margin:5px 10px 0 0" class="alignleft"> |
|
1085 <?php |
|
1086 /* translators: Between password field and private checkbox on post quick edit interface */ |
|
1087 echo __( '–OR–' ); |
|
1088 ?> |
|
1089 </em> |
|
1090 <label class="alignleft inline-edit-private"> |
|
1091 <input type="checkbox" name="keep_private" value="private" /> |
|
1092 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span> |
|
1093 </label> |
|
1094 </div> |
|
1095 |
|
1096 <?php endif; ?> |
|
1097 |
|
1098 </div></fieldset> |
|
1099 |
|
1100 <?php if ( !$is_page && !$bulk ) : ?> |
|
1101 |
|
1102 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> |
|
1103 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?> |
|
1104 <span class="catshow"><?php _e('[more]'); ?></span> |
|
1105 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span> |
|
1106 </span> |
|
1107 <ul class="cat-checklist"> |
|
1108 <?php wp_category_checklist(); ?> |
|
1109 </ul> |
|
1110 </div></fieldset> |
|
1111 |
|
1112 <?php endif; // !$is_page && !$bulk ?> |
|
1113 |
|
1114 <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> |
|
1115 |
|
1116 <?php |
|
1117 if ( $bulk ) |
|
1118 echo $authors_dropdown; |
|
1119 ?> |
|
1120 |
|
1121 <?php if ( $is_page ) : ?> |
|
1122 |
|
1123 <label> |
|
1124 <span class="title"><?php _e( 'Parent' ); ?></span> |
|
1125 <?php |
|
1126 $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title'); |
|
1127 if ( $bulk ) |
|
1128 $dropdown_args['show_option_no_change'] = __('- No Change -'); |
|
1129 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); |
|
1130 wp_dropdown_pages($dropdown_args); |
|
1131 ?> |
|
1132 </label> |
|
1133 |
|
1134 <?php if ( !$bulk ) : ?> |
|
1135 |
|
1136 <label> |
|
1137 <span class="title"><?php _e( 'Order' ); ?></span> |
|
1138 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> |
|
1139 </label> |
|
1140 |
|
1141 <?php endif; // !$bulk ?> |
|
1142 |
|
1143 <label> |
|
1144 <span class="title"><?php _e( 'Template' ); ?></span> |
|
1145 <select name="page_template"> |
|
1146 <?php if ( $bulk ) : ?> |
|
1147 <option value="-1"><?php _e('- No Change -'); ?></option> |
|
1148 <?php endif; // $bulk ?> |
|
1149 <option value="default"><?php _e( 'Default Template' ); ?></option> |
|
1150 <?php page_template_dropdown() ?> |
|
1151 </select> |
|
1152 </label> |
|
1153 |
|
1154 <?php elseif ( !$bulk ) : // $is_page ?> |
|
1155 |
|
1156 <label class="inline-edit-tags"> |
|
1157 <span class="title"><?php _e( 'Tags' ); ?></span> |
|
1158 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea> |
|
1159 </label> |
|
1160 |
|
1161 <?php endif; // $is_page ?> |
|
1162 |
|
1163 <?php if ( $bulk ) : ?> |
|
1164 |
|
1165 <div class="inline-edit-group"> |
|
1166 <label class="alignleft"> |
|
1167 <span class="title"><?php _e( 'Comments' ); ?></span> |
|
1168 <select name="comment_status"> |
|
1169 <option value=""><?php _e('- No Change -'); ?></option> |
|
1170 <option value="open"><?php _e('Allow'); ?></option> |
|
1171 <option value="closed"><?php _e('Do not allow'); ?></option> |
|
1172 </select> |
|
1173 </label> |
|
1174 |
|
1175 <label class="alignright"> |
|
1176 <span class="title"><?php _e( 'Pings' ); ?></span> |
|
1177 <select name="ping_status"> |
|
1178 <option value=""><?php _e('- No Change -'); ?></option> |
|
1179 <option value="open"><?php _e('Allow'); ?></option> |
|
1180 <option value="closed"><?php _e('Do not allow'); ?></option> |
|
1181 </select> |
|
1182 </label> |
|
1183 </div> |
|
1184 |
|
1185 <?php else : // $bulk ?> |
|
1186 |
|
1187 <div class="inline-edit-group"> |
|
1188 <label class="alignleft"> |
|
1189 <input type="checkbox" name="comment_status" value="open" /> |
|
1190 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
1191 </label> |
|
1192 |
|
1193 <label class="alignleft"> |
|
1194 <input type="checkbox" name="ping_status" value="open" /> |
|
1195 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
1196 </label> |
|
1197 </div> |
|
1198 |
|
1199 <?php endif; // $bulk ?> |
|
1200 |
|
1201 |
|
1202 <div class="inline-edit-group"> |
|
1203 <label class="inline-edit-status alignleft"> |
|
1204 <span class="title"><?php _e( 'Status' ); ?></span> |
|
1205 <select name="_status"> |
|
1206 <?php if ( $bulk ) : ?> |
|
1207 <option value="-1"><?php _e('- No Change -'); ?></option> |
|
1208 <?php endif; // $bulk ?> |
|
1209 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?> |
|
1210 <option value="publish"><?php _e( 'Published' ); ?></option> |
|
1211 <option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
1212 <?php if ( $bulk ) : ?> |
|
1213 <option value="private"><?php _e('Private') ?></option> |
|
1214 <?php endif; // $bulk ?> |
|
1215 <?php endif; ?> |
|
1216 <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
1217 <option value="draft"><?php _e( 'Draft' ); ?></option> |
|
1218 </select> |
|
1219 </label> |
|
1220 |
|
1221 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?> |
|
1222 |
|
1223 <?php if ( $bulk ) : ?> |
|
1224 |
|
1225 <label class="alignright"> |
|
1226 <span class="title"><?php _e( 'Sticky' ); ?></span> |
|
1227 <select name="sticky"> |
|
1228 <option value="-1"><?php _e( '- No Change -' ); ?></option> |
|
1229 <option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
1230 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
1231 </select> |
|
1232 </label> |
|
1233 |
|
1234 <?php else : // $bulk ?> |
|
1235 |
|
1236 <label class="alignleft"> |
|
1237 <input type="checkbox" name="sticky" value="sticky" /> |
|
1238 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
1239 </label> |
|
1240 |
|
1241 <?php endif; // $bulk ?> |
|
1242 |
|
1243 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?> |
|
1244 |
|
1245 </div> |
|
1246 |
|
1247 </div></fieldset> |
|
1248 |
|
1249 <?php |
|
1250 foreach ( $columns as $column_name => $column_display_name ) { |
|
1251 if ( isset( $core_columns[$column_name] ) ) |
|
1252 continue; |
|
1253 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type); |
|
1254 } |
|
1255 ?> |
|
1256 <p class="submit inline-edit-save"> |
|
1257 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a> |
|
1258 <?php if ( ! $bulk ) { |
|
1259 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
|
1260 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' ); |
|
1261 ?> |
|
1262 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a> |
|
1263 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /> |
|
1264 <?php } else { |
|
1265 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' ); |
|
1266 ?> |
|
1267 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" /> |
|
1268 <?php } ?> |
|
1269 <input type="hidden" name="post_view" value="<?php echo $m; ?>" /> |
|
1270 <br class="clear" /> |
|
1271 </p> |
|
1272 </td></tr> |
|
1273 <?php |
|
1274 $bulk++; |
|
1275 } ?> |
|
1276 </tbody></table></form> |
|
1277 <?php |
|
1278 } |
|
1279 |
|
1280 // adds hidden fields with the data for use in the inline editor for posts and pages |
|
1281 /** |
|
1282 * {@internal Missing Short Description}} |
|
1283 * |
|
1284 * @since unknown |
|
1285 * |
|
1286 * @param unknown_type $post |
243 * @param unknown_type $post |
1287 */ |
244 */ |
1288 function get_inline_data($post) { |
245 function get_inline_data($post) { |
1289 |
246 $post_type_object = get_post_type_object($post->post_type); |
1290 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) ) |
247 if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) |
1291 return; |
248 return; |
1292 |
249 |
1293 $title = esc_attr($post->post_title); |
250 $title = esc_textarea( trim( $post->post_title ) ); |
1294 |
251 |
1295 echo ' |
252 echo ' |
1296 <div class="hidden" id="inline_' . $post->ID . '"> |
253 <div class="hidden" id="inline_' . $post->ID . '"> |
1297 <div class="post_title">' . $title . '</div> |
254 <div class="post_title">' . $title . '</div> |
1298 <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div> |
255 <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div> |
1299 <div class="post_author">' . $post->post_author . '</div> |
256 <div class="post_author">' . $post->post_author . '</div> |
1300 <div class="comment_status">' . $post->comment_status . '</div> |
257 <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> |
1301 <div class="ping_status">' . $post->ping_status . '</div> |
258 <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> |
1302 <div class="_status">' . $post->post_status . '</div> |
259 <div class="_status">' . esc_html( $post->post_status ) . '</div> |
1303 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> |
260 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> |
1304 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> |
261 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> |
1305 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> |
262 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> |
1306 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> |
263 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> |
1307 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> |
264 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> |
1308 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> |
265 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> |
1309 <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; |
266 <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; |
1310 |
267 |
1311 if( $post->post_type == 'page' ) |
268 if ( $post_type_object->hierarchical ) |
1312 echo ' |
269 echo '<div class="post_parent">' . $post->post_parent . '</div>'; |
1313 <div class="post_parent">' . $post->post_parent . '</div> |
270 |
1314 <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div> |
271 if ( $post->post_type == 'page' ) |
1315 <div class="menu_order">' . $post->menu_order . '</div>'; |
272 echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>'; |
1316 |
273 |
1317 if( $post->post_type == 'post' ) |
274 if ( post_type_supports( $post->post_type, 'page-attributes' ) ) |
1318 echo ' |
275 echo '<div class="menu_order">' . $post->menu_order . '</div>'; |
1319 <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div> |
276 |
1320 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div> |
277 $taxonomy_names = get_object_taxonomies( $post->post_type ); |
1321 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; |
278 foreach ( $taxonomy_names as $taxonomy_name) { |
279 $taxonomy = get_taxonomy( $taxonomy_name ); |
|
280 |
|
281 if ( $taxonomy->hierarchical && $taxonomy->show_ui ) { |
|
282 echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' |
|
283 . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>'; |
|
284 } elseif ( $taxonomy->show_ui ) { |
|
285 echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' |
|
286 . esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>'; |
|
287 } |
|
288 } |
|
289 |
|
290 if ( !$post_type_object->hierarchical ) |
|
291 echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>'; |
|
292 |
|
293 if ( post_type_supports( $post->post_type, 'post-formats' ) ) |
|
294 echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>'; |
|
1322 |
295 |
1323 echo '</div>'; |
296 echo '</div>'; |
1324 } |
297 } |
1325 |
298 |
1326 /** |
299 /** |
1327 * {@internal Missing Short Description}} |
300 * {@internal Missing Short Description}} |
1328 * |
301 * |
1329 * @since unknown |
302 * @since 2.7.0 |
1330 * |
|
1331 * @param unknown_type $posts |
|
1332 */ |
|
1333 function post_rows( $posts = array() ) { |
|
1334 global $wp_query, $post, $mode; |
|
1335 |
|
1336 add_filter('the_title','esc_html'); |
|
1337 |
|
1338 // Create array of post IDs. |
|
1339 $post_ids = array(); |
|
1340 |
|
1341 if ( empty($posts) ) |
|
1342 $posts = &$wp_query->posts; |
|
1343 |
|
1344 foreach ( $posts as $a_post ) |
|
1345 $post_ids[] = $a_post->ID; |
|
1346 |
|
1347 $comment_pending_count = get_pending_comments_num($post_ids); |
|
1348 if ( empty($comment_pending_count) ) |
|
1349 $comment_pending_count = array(); |
|
1350 |
|
1351 foreach ( $posts as $post ) { |
|
1352 if ( empty($comment_pending_count[$post->ID]) ) |
|
1353 $comment_pending_count[$post->ID] = 0; |
|
1354 |
|
1355 _post_row($post, $comment_pending_count[$post->ID], $mode); |
|
1356 } |
|
1357 } |
|
1358 |
|
1359 /** |
|
1360 * {@internal Missing Short Description}} |
|
1361 * |
|
1362 * @since unknown |
|
1363 * |
|
1364 * @param unknown_type $a_post |
|
1365 * @param unknown_type $pending_comments |
|
1366 * @param unknown_type $mode |
|
1367 */ |
|
1368 function _post_row($a_post, $pending_comments, $mode) { |
|
1369 global $post, $current_user; |
|
1370 static $rowclass; |
|
1371 |
|
1372 $global_post = $post; |
|
1373 $post = $a_post; |
|
1374 setup_postdata($post); |
|
1375 |
|
1376 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; |
|
1377 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); |
|
1378 $edit_link = get_edit_post_link( $post->ID ); |
|
1379 $title = _draft_or_post_title(); |
|
1380 ?> |
|
1381 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top"> |
|
1382 <?php |
|
1383 $posts_columns = get_column_headers('edit'); |
|
1384 $hidden = get_hidden_columns('edit'); |
|
1385 foreach ( $posts_columns as $column_name=>$column_display_name ) { |
|
1386 $class = "class=\"$column_name column-$column_name\""; |
|
1387 |
|
1388 $style = ''; |
|
1389 if ( in_array($column_name, $hidden) ) |
|
1390 $style = ' style="display:none;"'; |
|
1391 |
|
1392 $attributes = "$class$style"; |
|
1393 |
|
1394 switch ($column_name) { |
|
1395 |
|
1396 case 'cb': |
|
1397 ?> |
|
1398 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th> |
|
1399 <?php |
|
1400 break; |
|
1401 |
|
1402 case 'date': |
|
1403 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) { |
|
1404 $t_time = $h_time = __('Unpublished'); |
|
1405 $time_diff = 0; |
|
1406 } else { |
|
1407 $t_time = get_the_time(__('Y/m/d g:i:s A')); |
|
1408 $m_time = $post->post_date; |
|
1409 $time = get_post_time('G', true, $post); |
|
1410 |
|
1411 $time_diff = time() - $time; |
|
1412 |
|
1413 if ( $time_diff > 0 && $time_diff < 24*60*60 ) |
|
1414 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); |
|
1415 else |
|
1416 $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
1417 } |
|
1418 |
|
1419 echo '<td ' . $attributes . '>'; |
|
1420 if ( 'excerpt' == $mode ) |
|
1421 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); |
|
1422 else |
|
1423 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; |
|
1424 echo '<br />'; |
|
1425 if ( 'publish' == $post->post_status ) { |
|
1426 _e('Published'); |
|
1427 } elseif ( 'future' == $post->post_status ) { |
|
1428 if ( $time_diff > 0 ) |
|
1429 echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; |
|
1430 else |
|
1431 _e('Scheduled'); |
|
1432 } else { |
|
1433 _e('Last Modified'); |
|
1434 } |
|
1435 echo '</td>'; |
|
1436 break; |
|
1437 |
|
1438 case 'title': |
|
1439 $attributes = 'class="post-title column-title"' . $style; |
|
1440 ?> |
|
1441 <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_post', $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong> |
|
1442 <?php |
|
1443 if ( 'excerpt' == $mode ) |
|
1444 the_excerpt(); |
|
1445 |
|
1446 $actions = array(); |
|
1447 if ( current_user_can('edit_post', $post->ID) && 'trash' != $post->post_status ) { |
|
1448 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; |
|
1449 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; |
|
1450 } |
|
1451 if ( current_user_can('delete_post', $post->ID) ) { |
|
1452 if ( 'trash' == $post->post_status ) |
|
1453 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; |
|
1454 elseif ( EMPTY_TRASH_DAYS ) |
|
1455 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>"; |
|
1456 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
|
1457 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; |
|
1458 } |
|
1459 if ( in_array($post->post_status, array('pending', 'draft')) ) { |
|
1460 if ( current_user_can('edit_post', $post->ID) ) |
|
1461 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; |
|
1462 } elseif ( 'trash' != $post->post_status ) { |
|
1463 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; |
|
1464 } |
|
1465 $actions = apply_filters('post_row_actions', $actions, $post); |
|
1466 $action_count = count($actions); |
|
1467 $i = 0; |
|
1468 echo '<div class="row-actions">'; |
|
1469 foreach ( $actions as $action => $link ) { |
|
1470 ++$i; |
|
1471 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
1472 echo "<span class='$action'>$link$sep</span>"; |
|
1473 } |
|
1474 echo '</div>'; |
|
1475 |
|
1476 get_inline_data($post); |
|
1477 ?> |
|
1478 </td> |
|
1479 <?php |
|
1480 break; |
|
1481 |
|
1482 case 'categories': |
|
1483 ?> |
|
1484 <td <?php echo $attributes ?>><?php |
|
1485 $categories = get_the_category(); |
|
1486 if ( !empty( $categories ) ) { |
|
1487 $out = array(); |
|
1488 foreach ( $categories as $c ) |
|
1489 $out[] = "<a href='edit.php?category_name=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; |
|
1490 echo join( ', ', $out ); |
|
1491 } else { |
|
1492 _e('Uncategorized'); |
|
1493 } |
|
1494 ?></td> |
|
1495 <?php |
|
1496 break; |
|
1497 |
|
1498 case 'tags': |
|
1499 ?> |
|
1500 <td <?php echo $attributes ?>><?php |
|
1501 $tags = get_the_tags($post->ID); |
|
1502 if ( !empty( $tags ) ) { |
|
1503 $out = array(); |
|
1504 foreach ( $tags as $c ) |
|
1505 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; |
|
1506 echo join( ', ', $out ); |
|
1507 } else { |
|
1508 _e('No Tags'); |
|
1509 } |
|
1510 ?></td> |
|
1511 <?php |
|
1512 break; |
|
1513 |
|
1514 case 'comments': |
|
1515 ?> |
|
1516 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
|
1517 <?php |
|
1518 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) ); |
|
1519 if ( $pending_comments ) |
|
1520 echo '<strong>'; |
|
1521 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); |
|
1522 if ( $pending_comments ) |
|
1523 echo '</strong>'; |
|
1524 ?> |
|
1525 </div></td> |
|
1526 <?php |
|
1527 break; |
|
1528 |
|
1529 case 'author': |
|
1530 ?> |
|
1531 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td> |
|
1532 <?php |
|
1533 break; |
|
1534 |
|
1535 case 'control_view': |
|
1536 ?> |
|
1537 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td> |
|
1538 <?php |
|
1539 break; |
|
1540 |
|
1541 case 'control_edit': |
|
1542 ?> |
|
1543 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td> |
|
1544 <?php |
|
1545 break; |
|
1546 |
|
1547 case 'control_delete': |
|
1548 ?> |
|
1549 <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td> |
|
1550 <?php |
|
1551 break; |
|
1552 |
|
1553 default: |
|
1554 ?> |
|
1555 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td> |
|
1556 <?php |
|
1557 break; |
|
1558 } |
|
1559 } |
|
1560 ?> |
|
1561 </tr> |
|
1562 <?php |
|
1563 $post = $global_post; |
|
1564 } |
|
1565 |
|
1566 /* |
|
1567 * display one row if the page doesn't have any children |
|
1568 * otherwise, display the row and its children in subsequent rows |
|
1569 */ |
|
1570 /** |
|
1571 * {@internal Missing Short Description}} |
|
1572 * |
|
1573 * @since unknown |
|
1574 * |
|
1575 * @param unknown_type $page |
|
1576 * @param unknown_type $level |
|
1577 */ |
|
1578 function display_page_row( $page, $level = 0 ) { |
|
1579 global $post; |
|
1580 static $rowclass; |
|
1581 |
|
1582 $post = $page; |
|
1583 setup_postdata($page); |
|
1584 |
|
1585 if ( 0 == $level && (int)$page->post_parent > 0 ) { |
|
1586 //sent level 0 by accident, by default, or because we don't know the actual level |
|
1587 $find_main_page = (int)$page->post_parent; |
|
1588 while ( $find_main_page > 0 ) { |
|
1589 $parent = get_page($find_main_page); |
|
1590 |
|
1591 if ( is_null($parent) ) |
|
1592 break; |
|
1593 |
|
1594 $level++; |
|
1595 $find_main_page = (int)$parent->post_parent; |
|
1596 |
|
1597 if ( !isset($parent_name) ) |
|
1598 $parent_name = $parent->post_title; |
|
1599 } |
|
1600 } |
|
1601 |
|
1602 $page->post_title = esc_html( $page->post_title ); |
|
1603 $pad = str_repeat( '— ', $level ); |
|
1604 $id = (int) $page->ID; |
|
1605 $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; |
|
1606 $posts_columns = get_column_headers('edit-pages'); |
|
1607 $hidden = get_hidden_columns('edit-pages'); |
|
1608 $title = _draft_or_post_title(); |
|
1609 ?> |
|
1610 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit"> |
|
1611 <?php |
|
1612 |
|
1613 foreach ($posts_columns as $column_name=>$column_display_name) { |
|
1614 $class = "class=\"$column_name column-$column_name\""; |
|
1615 |
|
1616 $style = ''; |
|
1617 if ( in_array($column_name, $hidden) ) |
|
1618 $style = ' style="display:none;"'; |
|
1619 |
|
1620 $attributes = "$class$style"; |
|
1621 |
|
1622 switch ($column_name) { |
|
1623 |
|
1624 case 'cb': |
|
1625 ?> |
|
1626 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th> |
|
1627 <?php |
|
1628 break; |
|
1629 case 'date': |
|
1630 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) { |
|
1631 $t_time = $h_time = __('Unpublished'); |
|
1632 $time_diff = 0; |
|
1633 } else { |
|
1634 $t_time = get_the_time(__('Y/m/d g:i:s A')); |
|
1635 $m_time = $page->post_date; |
|
1636 $time = get_post_time('G', true); |
|
1637 |
|
1638 $time_diff = time() - $time; |
|
1639 |
|
1640 if ( $time_diff > 0 && $time_diff < 24*60*60 ) |
|
1641 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) ); |
|
1642 else |
|
1643 $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
1644 } |
|
1645 echo '<td ' . $attributes . '>'; |
|
1646 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>'; |
|
1647 echo '<br />'; |
|
1648 if ( 'publish' == $page->post_status ) { |
|
1649 _e('Published'); |
|
1650 } elseif ( 'future' == $page->post_status ) { |
|
1651 if ( $time_diff > 0 ) |
|
1652 echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; |
|
1653 else |
|
1654 _e('Scheduled'); |
|
1655 } else { |
|
1656 _e('Last Modified'); |
|
1657 } |
|
1658 echo '</td>'; |
|
1659 break; |
|
1660 case 'title': |
|
1661 $attributes = 'class="post-title page-title column-title"' . $style; |
|
1662 $edit_link = get_edit_post_link( $page->ID ); |
|
1663 ?> |
|
1664 <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong> |
|
1665 <?php |
|
1666 $actions = array(); |
|
1667 if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) { |
|
1668 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; |
|
1669 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>'; |
|
1670 } |
|
1671 if ( current_user_can('delete_page', $page->ID) ) { |
|
1672 if ( $post->post_status == 'trash' ) |
|
1673 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>"; |
|
1674 elseif ( EMPTY_TRASH_DAYS ) |
|
1675 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>"; |
|
1676 if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS ) |
|
1677 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>"; |
|
1678 } |
|
1679 if ( in_array($post->post_status, array('pending', 'draft')) ) { |
|
1680 if ( current_user_can('edit_page', $page->ID) ) |
|
1681 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; |
|
1682 } elseif ( $post->post_status != 'trash' ) { |
|
1683 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; |
|
1684 } |
|
1685 $actions = apply_filters('page_row_actions', $actions, $page); |
|
1686 $action_count = count($actions); |
|
1687 |
|
1688 $i = 0; |
|
1689 echo '<div class="row-actions">'; |
|
1690 foreach ( $actions as $action => $link ) { |
|
1691 ++$i; |
|
1692 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
1693 echo "<span class='$action'>$link$sep</span>"; |
|
1694 } |
|
1695 echo '</div>'; |
|
1696 |
|
1697 get_inline_data($post); |
|
1698 echo '</td>'; |
|
1699 break; |
|
1700 |
|
1701 case 'comments': |
|
1702 ?> |
|
1703 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
|
1704 <?php |
|
1705 $left = get_pending_comments_num( $page->ID ); |
|
1706 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) ); |
|
1707 if ( $left ) |
|
1708 echo '<strong>'; |
|
1709 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); |
|
1710 if ( $left ) |
|
1711 echo '</strong>'; |
|
1712 ?> |
|
1713 </div></td> |
|
1714 <?php |
|
1715 break; |
|
1716 |
|
1717 case 'author': |
|
1718 ?> |
|
1719 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td> |
|
1720 <?php |
|
1721 break; |
|
1722 |
|
1723 default: |
|
1724 ?> |
|
1725 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td> |
|
1726 <?php |
|
1727 break; |
|
1728 } |
|
1729 } |
|
1730 ?> |
|
1731 |
|
1732 </tr> |
|
1733 |
|
1734 <?php |
|
1735 } |
|
1736 |
|
1737 /* |
|
1738 * displays pages in hierarchical order with paging support |
|
1739 */ |
|
1740 /** |
|
1741 * {@internal Missing Short Description}} |
|
1742 * |
|
1743 * @since unknown |
|
1744 * |
|
1745 * @param unknown_type $pages |
|
1746 * @param unknown_type $pagenum |
|
1747 * @param unknown_type $per_page |
|
1748 * @return unknown |
|
1749 */ |
|
1750 function page_rows($pages, $pagenum = 1, $per_page = 20) { |
|
1751 global $wpdb; |
|
1752 |
|
1753 $level = 0; |
|
1754 |
|
1755 if ( ! $pages ) { |
|
1756 $pages = get_pages( array('sort_column' => 'menu_order') ); |
|
1757 |
|
1758 if ( ! $pages ) |
|
1759 return false; |
|
1760 } |
|
1761 |
|
1762 /* |
|
1763 * arrange pages into two parts: top level pages and children_pages |
|
1764 * children_pages is two dimensional array, eg. |
|
1765 * children_pages[10][] contains all sub-pages whose parent is 10. |
|
1766 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations |
|
1767 * If searching, ignore hierarchy and treat everything as top level |
|
1768 */ |
|
1769 if ( empty($_GET['s']) ) { |
|
1770 |
|
1771 $top_level_pages = array(); |
|
1772 $children_pages = array(); |
|
1773 |
|
1774 foreach ( $pages as $page ) { |
|
1775 |
|
1776 // catch and repair bad pages |
|
1777 if ( $page->post_parent == $page->ID ) { |
|
1778 $page->post_parent = 0; |
|
1779 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) ); |
|
1780 clean_page_cache( $page->ID ); |
|
1781 } |
|
1782 |
|
1783 if ( 0 == $page->post_parent ) |
|
1784 $top_level_pages[] = $page; |
|
1785 else |
|
1786 $children_pages[ $page->post_parent ][] = $page; |
|
1787 } |
|
1788 |
|
1789 $pages = &$top_level_pages; |
|
1790 } |
|
1791 |
|
1792 $count = 0; |
|
1793 $start = ($pagenum - 1) * $per_page; |
|
1794 $end = $start + $per_page; |
|
1795 |
|
1796 foreach ( $pages as $page ) { |
|
1797 if ( $count >= $end ) |
|
1798 break; |
|
1799 |
|
1800 if ( $count >= $start ) |
|
1801 echo "\t" . display_page_row( $page, $level ); |
|
1802 |
|
1803 $count++; |
|
1804 |
|
1805 if ( isset($children_pages) ) |
|
1806 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); |
|
1807 } |
|
1808 |
|
1809 // if it is the last pagenum and there are orphaned pages, display them with paging as well |
|
1810 if ( isset($children_pages) && $count < $end ){ |
|
1811 foreach( $children_pages as $orphans ){ |
|
1812 foreach ( $orphans as $op ) { |
|
1813 if ( $count >= $end ) |
|
1814 break; |
|
1815 if ( $count >= $start ) |
|
1816 echo "\t" . display_page_row( $op, 0 ); |
|
1817 $count++; |
|
1818 } |
|
1819 } |
|
1820 } |
|
1821 } |
|
1822 |
|
1823 /* |
|
1824 * Given a top level page ID, display the nested hierarchy of sub-pages |
|
1825 * together with paging support |
|
1826 */ |
|
1827 /** |
|
1828 * {@internal Missing Short Description}} |
|
1829 * |
|
1830 * @since unknown |
|
1831 * |
|
1832 * @param unknown_type $children_pages |
|
1833 * @param unknown_type $count |
|
1834 * @param unknown_type $parent |
|
1835 * @param unknown_type $level |
|
1836 * @param unknown_type $pagenum |
|
1837 * @param unknown_type $per_page |
|
1838 */ |
|
1839 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) { |
|
1840 |
|
1841 if ( ! isset( $children_pages[$parent] ) ) |
|
1842 return; |
|
1843 |
|
1844 $start = ($pagenum - 1) * $per_page; |
|
1845 $end = $start + $per_page; |
|
1846 |
|
1847 foreach ( $children_pages[$parent] as $page ) { |
|
1848 |
|
1849 if ( $count >= $end ) |
|
1850 break; |
|
1851 |
|
1852 // If the page starts in a subtree, print the parents. |
|
1853 if ( $count == $start && $page->post_parent > 0 ) { |
|
1854 $my_parents = array(); |
|
1855 $my_parent = $page->post_parent; |
|
1856 while ( $my_parent) { |
|
1857 $my_parent = get_post($my_parent); |
|
1858 $my_parents[] = $my_parent; |
|
1859 if ( !$my_parent->post_parent ) |
|
1860 break; |
|
1861 $my_parent = $my_parent->post_parent; |
|
1862 } |
|
1863 $num_parents = count($my_parents); |
|
1864 while( $my_parent = array_pop($my_parents) ) { |
|
1865 echo "\t" . display_page_row( $my_parent, $level - $num_parents ); |
|
1866 $num_parents--; |
|
1867 } |
|
1868 } |
|
1869 |
|
1870 if ( $count >= $start ) |
|
1871 echo "\t" . display_page_row( $page, $level ); |
|
1872 |
|
1873 $count++; |
|
1874 |
|
1875 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page ); |
|
1876 } |
|
1877 |
|
1878 unset( $children_pages[$parent] ); //required in order to keep track of orphans |
|
1879 } |
|
1880 |
|
1881 /** |
|
1882 * {@internal Missing Short Description}} |
|
1883 * |
|
1884 * @since unknown |
|
1885 * |
|
1886 * @param unknown_type $user_object |
|
1887 * @param unknown_type $style |
|
1888 * @param unknown_type $role |
|
1889 * @return unknown |
|
1890 */ |
|
1891 function user_row( $user_object, $style = '', $role = '' ) { |
|
1892 global $wp_roles; |
|
1893 |
|
1894 $current_user = wp_get_current_user(); |
|
1895 |
|
1896 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) |
|
1897 $user_object = new WP_User( (int) $user_object ); |
|
1898 $user_object = sanitize_user_object($user_object, 'display'); |
|
1899 $email = $user_object->user_email; |
|
1900 $url = $user_object->user_url; |
|
1901 $short_url = str_replace( 'http://', '', $url ); |
|
1902 $short_url = str_replace( 'www.', '', $short_url ); |
|
1903 if ('/' == substr( $short_url, -1 )) |
|
1904 $short_url = substr( $short_url, 0, -1 ); |
|
1905 if ( strlen( $short_url ) > 35 ) |
|
1906 $short_url = substr( $short_url, 0, 32 ).'...'; |
|
1907 $numposts = get_usernumposts( $user_object->ID ); |
|
1908 $checkbox = ''; |
|
1909 // Check if the user for this row is editable |
|
1910 if ( current_user_can( 'edit_user', $user_object->ID ) ) { |
|
1911 // Set up the user editing link |
|
1912 // TODO: make profile/user-edit determination a seperate function |
|
1913 if ($current_user->ID == $user_object->ID) { |
|
1914 $edit_link = 'profile.php'; |
|
1915 } else { |
|
1916 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) ); |
|
1917 } |
|
1918 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />"; |
|
1919 |
|
1920 // Set up the hover actions for this user |
|
1921 $actions = array(); |
|
1922 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
1923 if ( $current_user->ID != $user_object->ID ) |
|
1924 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>"; |
|
1925 $actions = apply_filters('user_row_actions', $actions, $user_object); |
|
1926 $action_count = count($actions); |
|
1927 $i = 0; |
|
1928 $edit .= '<div class="row-actions">'; |
|
1929 foreach ( $actions as $action => $link ) { |
|
1930 ++$i; |
|
1931 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
|
1932 $edit .= "<span class='$action'>$link$sep</span>"; |
|
1933 } |
|
1934 $edit .= '</div>'; |
|
1935 |
|
1936 // Set up the checkbox (because the user is editable, otherwise its empty) |
|
1937 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />"; |
|
1938 |
|
1939 } else { |
|
1940 $edit = '<strong>' . $user_object->user_login . '</strong>'; |
|
1941 } |
|
1942 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None'); |
|
1943 $r = "<tr id='user-$user_object->ID'$style>"; |
|
1944 $columns = get_column_headers('users'); |
|
1945 $hidden = get_hidden_columns('users'); |
|
1946 $avatar = get_avatar( $user_object->ID, 32 ); |
|
1947 foreach ( $columns as $column_name => $column_display_name ) { |
|
1948 $class = "class=\"$column_name column-$column_name\""; |
|
1949 |
|
1950 $style = ''; |
|
1951 if ( in_array($column_name, $hidden) ) |
|
1952 $style = ' style="display:none;"'; |
|
1953 |
|
1954 $attributes = "$class$style"; |
|
1955 |
|
1956 switch ($column_name) { |
|
1957 case 'cb': |
|
1958 $r .= "<th scope='row' class='check-column'>$checkbox</th>"; |
|
1959 break; |
|
1960 case 'username': |
|
1961 $r .= "<td $attributes>$avatar $edit</td>"; |
|
1962 break; |
|
1963 case 'name': |
|
1964 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>"; |
|
1965 break; |
|
1966 case 'email': |
|
1967 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>"; |
|
1968 break; |
|
1969 case 'role': |
|
1970 $r .= "<td $attributes>$role_name</td>"; |
|
1971 break; |
|
1972 case 'posts': |
|
1973 $attributes = 'class="posts column-posts num"' . $style; |
|
1974 $r .= "<td $attributes>"; |
|
1975 if ( $numposts > 0 ) { |
|
1976 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; |
|
1977 $r .= $numposts; |
|
1978 $r .= '</a>'; |
|
1979 } else { |
|
1980 $r .= 0; |
|
1981 } |
|
1982 $r .= "</td>"; |
|
1983 break; |
|
1984 default: |
|
1985 $r .= "<td $attributes>"; |
|
1986 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID); |
|
1987 $r .= "</td>"; |
|
1988 } |
|
1989 } |
|
1990 $r .= '</tr>'; |
|
1991 |
|
1992 return $r; |
|
1993 } |
|
1994 |
|
1995 /** |
|
1996 * {@internal Missing Short Description}} |
|
1997 * |
|
1998 * @since unknown |
|
1999 * |
|
2000 * @param string $status Comment status (approved, spam, trash, etc) |
|
2001 * @param string $s Term to search for |
|
2002 * @param int $start Offset to start at for pagination |
|
2003 * @param int $num Maximum number of comments to return |
|
2004 * @param int $post Post ID or 0 to return all comments |
|
2005 * @param string $type Comment type (comment, trackback, pingback, etc) |
|
2006 * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num) |
|
2007 */ |
|
2008 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) { |
|
2009 global $wpdb; |
|
2010 |
|
2011 $start = abs( (int) $start ); |
|
2012 $num = (int) $num; |
|
2013 $post = (int) $post; |
|
2014 $count = wp_count_comments(); |
|
2015 $index = ''; |
|
2016 |
|
2017 if ( 'moderated' == $status ) { |
|
2018 $approved = "c.comment_approved = '0'"; |
|
2019 $total = $count->moderated; |
|
2020 } elseif ( 'approved' == $status ) { |
|
2021 $approved = "c.comment_approved = '1'"; |
|
2022 $total = $count->approved; |
|
2023 } elseif ( 'spam' == $status ) { |
|
2024 $approved = "c.comment_approved = 'spam'"; |
|
2025 $total = $count->spam; |
|
2026 } elseif ( 'trash' == $status ) { |
|
2027 $approved = "c.comment_approved = 'trash'"; |
|
2028 $total = $count->trash; |
|
2029 } else { |
|
2030 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; |
|
2031 $total = $count->moderated + $count->approved; |
|
2032 $index = 'USE INDEX (c.comment_date_gmt)'; |
|
2033 } |
|
2034 |
|
2035 if ( $post ) { |
|
2036 $total = ''; |
|
2037 $post = " AND c.comment_post_ID = '$post'"; |
|
2038 } else { |
|
2039 $post = ''; |
|
2040 } |
|
2041 |
|
2042 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; |
|
2043 |
|
2044 if ( 'comment' == $type ) |
|
2045 $typesql = "AND c.comment_type = ''"; |
|
2046 elseif ( 'pings' == $type ) |
|
2047 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; |
|
2048 elseif ( 'all' == $type ) |
|
2049 $typesql = ''; |
|
2050 elseif ( !empty($type) ) |
|
2051 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type); |
|
2052 else |
|
2053 $typesql = ''; |
|
2054 |
|
2055 if ( !empty($type) ) |
|
2056 $total = ''; |
|
2057 |
|
2058 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' "; |
|
2059 if ( $s ) { |
|
2060 $total = ''; |
|
2061 $s = $wpdb->escape($s); |
|
2062 $query .= "AND |
|
2063 (c.comment_author LIKE '%$s%' OR |
|
2064 c.comment_author_email LIKE '%$s%' OR |
|
2065 c.comment_author_url LIKE ('%$s%') OR |
|
2066 c.comment_author_IP LIKE ('%$s%') OR |
|
2067 c.comment_content LIKE ('%$s%') ) AND |
|
2068 $approved |
|
2069 $typesql"; |
|
2070 } else { |
|
2071 $query .= "AND $approved $post $typesql"; |
|
2072 } |
|
2073 |
|
2074 $comments = $wpdb->get_results("SELECT * $query $orderby"); |
|
2075 if ( '' === $total ) |
|
2076 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); |
|
2077 |
|
2078 update_comment_cache($comments); |
|
2079 |
|
2080 return array($comments, $total); |
|
2081 } |
|
2082 |
|
2083 /** |
|
2084 * {@internal Missing Short Description}} |
|
2085 * |
|
2086 * @since unknown |
|
2087 * |
|
2088 * @param unknown_type $comment_id |
|
2089 * @param unknown_type $mode |
|
2090 * @param unknown_type $comment_status |
|
2091 * @param unknown_type $checkbox |
|
2092 */ |
|
2093 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) { |
|
2094 global $comment, $post, $_comment_pending_count; |
|
2095 $comment = get_comment( $comment_id ); |
|
2096 $post = get_post($comment->comment_post_ID); |
|
2097 $the_comment_status = wp_get_comment_status($comment->comment_ID); |
|
2098 $user_can = current_user_can('edit_post', $post->ID); |
|
2099 |
|
2100 $author_url = get_comment_author_url(); |
|
2101 if ( 'http://' == $author_url ) |
|
2102 $author_url = ''; |
|
2103 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url); |
|
2104 if ( strlen($author_url_display) > 50 ) |
|
2105 $author_url_display = substr($author_url_display, 0, 49) . '...'; |
|
2106 |
|
2107 $ptime = date('G', strtotime( $comment->comment_date ) ); |
|
2108 if ( ( abs(time() - $ptime) ) < 86400 ) |
|
2109 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) ); |
|
2110 else |
|
2111 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date ); |
|
2112 |
|
2113 if ( $user_can ) { |
|
2114 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
|
2115 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
|
2116 |
|
2117 $comment_url = esc_url(get_comment_link($comment->comment_ID)); |
|
2118 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); |
|
2119 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" ); |
|
2120 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); |
|
2121 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); |
|
2122 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); |
|
2123 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); |
|
2124 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" ); |
|
2125 } |
|
2126 |
|
2127 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>"; |
|
2128 $columns = get_column_headers('edit-comments'); |
|
2129 $hidden = get_hidden_columns('edit-comments'); |
|
2130 foreach ( $columns as $column_name => $column_display_name ) { |
|
2131 $class = "class=\"$column_name column-$column_name\""; |
|
2132 |
|
2133 $style = ''; |
|
2134 if ( in_array($column_name, $hidden) ) |
|
2135 $style = ' style="display:none;"'; |
|
2136 |
|
2137 $attributes = "$class$style"; |
|
2138 |
|
2139 switch ($column_name) { |
|
2140 case 'cb': |
|
2141 if ( !$checkbox ) break; |
|
2142 echo '<th scope="row" class="check-column">'; |
|
2143 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />"; |
|
2144 echo '</th>'; |
|
2145 break; |
|
2146 case 'comment': |
|
2147 echo "<td $attributes>"; |
|
2148 echo '<div id="submitted-on">'; |
|
2149 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), $comment_url, get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia'))); |
|
2150 echo '</div>'; |
|
2151 comment_text(); |
|
2152 if ( $user_can ) { ?> |
|
2153 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden"> |
|
2154 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea> |
|
2155 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div> |
|
2156 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div> |
|
2157 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div> |
|
2158 <div class="comment_status"><?php echo $comment->comment_approved; ?></div> |
|
2159 </div> |
|
2160 <?php |
|
2161 } |
|
2162 |
|
2163 if ( $user_can ) { |
|
2164 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash |
|
2165 $actions = array( |
|
2166 'approve' => '', 'unapprove' => '', |
|
2167 'reply' => '', |
|
2168 'quickedit' => '', |
|
2169 'edit' => '', |
|
2170 'spam' => '', 'unspam' => '', |
|
2171 'trash' => '', 'untrash' => '', 'delete' => '' |
|
2172 ); |
|
2173 |
|
2174 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments |
|
2175 if ( 'approved' == $the_comment_status ) |
|
2176 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
2177 else if ( 'unapproved' == $the_comment_status ) |
|
2178 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
2179 } else { |
|
2180 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
2181 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
2182 } |
|
2183 |
|
2184 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { |
|
2185 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
|
2186 } elseif ( 'spam' == $the_comment_status ) { |
|
2187 $actions['unspam'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . __( 'Not Spam' ) . '</a>'; |
|
2188 } elseif ( 'trash' == $the_comment_status ) { |
|
2189 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>'; |
|
2190 } |
|
2191 |
|
2192 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) { |
|
2193 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; |
|
2194 } else { |
|
2195 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; |
|
2196 } |
|
2197 |
|
2198 if ( 'trash' != $the_comment_status ) { |
|
2199 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>'; |
|
2200 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>'; |
|
2201 if ( 'spam' != $the_comment_status ) |
|
2202 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; |
|
2203 } |
|
2204 |
|
2205 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); |
|
2206 |
|
2207 $i = 0; |
|
2208 echo '<div class="row-actions">'; |
|
2209 foreach ( $actions as $action => $link ) { |
|
2210 ++$i; |
|
2211 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
|
2212 |
|
2213 // Reply and quickedit need a hide-if-no-js span when not added with ajax |
|
2214 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax ) |
|
2215 $action .= ' hide-if-no-js'; |
|
2216 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) { |
|
2217 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) |
|
2218 $action .= ' approve'; |
|
2219 else |
|
2220 $action .= ' unapprove'; |
|
2221 } |
|
2222 |
|
2223 echo "<span class='$action'>$sep$link</span>"; |
|
2224 } |
|
2225 echo '</div>'; |
|
2226 } |
|
2227 |
|
2228 echo '</td>'; |
|
2229 break; |
|
2230 case 'author': |
|
2231 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />'; |
|
2232 if ( !empty($author_url) ) |
|
2233 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />"; |
|
2234 if ( $user_can ) { |
|
2235 if ( !empty($comment->comment_author_email) ) { |
|
2236 comment_author_email_link(); |
|
2237 echo '<br />'; |
|
2238 } |
|
2239 echo '<a href="edit-comments.php?s='; |
|
2240 comment_author_IP(); |
|
2241 echo '&mode=detail'; |
|
2242 if ( 'spam' == $comment_status ) |
|
2243 echo '&comment_status=spam'; |
|
2244 echo '">'; |
|
2245 comment_author_IP(); |
|
2246 echo '</a>'; |
|
2247 } //current_user_can |
|
2248 echo '</td>'; |
|
2249 break; |
|
2250 case 'date': |
|
2251 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>'; |
|
2252 break; |
|
2253 case 'response': |
|
2254 if ( 'single' !== $mode ) { |
|
2255 if ( isset( $_comment_pending_count[$post->ID] ) ) { |
|
2256 $pending_comments = absint( $_comment_pending_count[$post->ID] ); |
|
2257 } else { |
|
2258 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) ); |
|
2259 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID]; |
|
2260 } |
|
2261 if ( $user_can ) { |
|
2262 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>"; |
|
2263 $post_link .= get_the_title($post->ID) . '</a>'; |
|
2264 } else { |
|
2265 $post_link = get_the_title($post->ID); |
|
2266 } |
|
2267 echo "<td $attributes>\n"; |
|
2268 echo '<div class="response-links"><span class="post-com-count-wrapper">'; |
|
2269 echo $post_link . '<br />'; |
|
2270 $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) )); |
|
2271 if ( $pending_comments ) |
|
2272 echo '<strong>'; |
|
2273 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>'); |
|
2274 if ( $pending_comments ) |
|
2275 echo '</strong>'; |
|
2276 echo '</span> '; |
|
2277 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>"; |
|
2278 echo '</div>'; |
|
2279 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) ) |
|
2280 echo $thumb; |
|
2281 echo '</td>'; |
|
2282 } |
|
2283 break; |
|
2284 default: |
|
2285 echo "<td $attributes>\n"; |
|
2286 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID ); |
|
2287 echo "</td>\n"; |
|
2288 break; |
|
2289 } |
|
2290 } |
|
2291 echo "</tr>\n"; |
|
2292 } |
|
2293 |
|
2294 /** |
|
2295 * {@internal Missing Short Description}} |
|
2296 * |
|
2297 * @since unknown |
|
2298 * |
303 * |
2299 * @param unknown_type $position |
304 * @param unknown_type $position |
2300 * @param unknown_type $checkbox |
305 * @param unknown_type $checkbox |
2301 * @param unknown_type $mode |
306 * @param unknown_type $mode |
2302 */ |
307 */ |
2303 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { |
308 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { |
2304 global $current_user; |
|
2305 |
|
2306 // allow plugin to replace the popup content |
309 // allow plugin to replace the popup content |
2307 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); |
310 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) ); |
2308 |
311 |
2309 if ( ! empty($content) ) { |
312 if ( ! empty($content) ) { |
2310 echo $content; |
313 echo $content; |
2311 return; |
314 return; |
2312 } |
315 } |
2313 |
316 |
2314 $columns = get_column_headers('edit-comments'); |
317 if ( $mode == 'single' ) { |
2315 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); |
318 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); |
2316 $col_count = count($columns) - count($hidden); |
319 } else { |
320 $wp_list_table = _get_list_table('WP_Comments_List_Table'); |
|
321 } |
|
2317 |
322 |
2318 ?> |
323 ?> |
2319 <form method="get" action=""> |
324 <form method="get" action=""> |
2320 <?php if ( $table_row ) : ?> |
325 <?php if ( $table_row ) : ?> |
2321 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>"> |
326 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange"> |
2322 <?php else : ?> |
327 <?php else : ?> |
2323 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> |
328 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;"> |
2324 <?php endif; ?> |
329 <?php endif; ?> |
2325 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div> |
330 <div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div> |
2326 |
331 <div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div> |
2327 <div id="edithead" style="display:none;"> |
332 <div id="edithead" style="display:none;"> |
2328 <div class="inside"> |
333 <div class="inside"> |
2329 <label for="author"><?php _e('Name') ?></label> |
334 <label for="author"><?php _e('Name') ?></label> |
2330 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" /> |
335 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" /> |
2331 </div> |
336 </div> |
2340 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" /> |
345 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" /> |
2341 </div> |
346 </div> |
2342 <div style="clear:both;"></div> |
347 <div style="clear:both;"></div> |
2343 </div> |
348 </div> |
2344 |
349 |
2345 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div> |
350 <div id="replycontainer"> |
351 <?php |
|
352 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); |
|
353 wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, 'tabindex' => 104 ) ); |
|
354 ?> |
|
355 </div> |
|
2346 |
356 |
2347 <p id="replysubmit" class="submit"> |
357 <p id="replysubmit" class="submit"> |
2348 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> |
358 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a> |
2349 <a href="#comments-form" class="save button-primary alignright" tabindex="104"> |
359 <a href="#comments-form" class="save button-primary alignright" tabindex="104"> |
360 <span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span> |
|
2350 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> |
361 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span> |
2351 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> |
362 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a> |
2352 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" /> |
363 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
2353 <span class="error" style="display:none;"></span> |
364 <span class="error" style="display:none;"></span> |
2354 <br class="clear" /> |
365 <br class="clear" /> |
2355 </p> |
366 </p> |
2356 |
367 |
2357 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" /> |
368 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" /> |
2358 <input type="hidden" name="action" id="action" value="" /> |
369 <input type="hidden" name="action" id="action" value="" /> |
2359 <input type="hidden" name="comment_ID" id="comment_ID" value="" /> |
370 <input type="hidden" name="comment_ID" id="comment_ID" value="" /> |
2360 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" /> |
371 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" /> |
2361 <input type="hidden" name="status" id="status" value="" /> |
372 <input type="hidden" name="status" id="status" value="" /> |
2362 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" /> |
373 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" /> |
2363 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" /> |
374 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" /> |
2364 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" /> |
375 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" /> |
2365 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?> |
376 <?php |
2366 <?php wp_comment_form_unfiltered_html_nonce(); ?> |
377 wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); |
378 if ( current_user_can( 'unfiltered_html' ) ) |
|
379 wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false ); |
|
380 ?> |
|
2367 <?php if ( $table_row ) : ?> |
381 <?php if ( $table_row ) : ?> |
2368 </td></tr></tbody></table> |
382 </td></tr></tbody></table> |
2369 <?php else : ?> |
383 <?php else : ?> |
2370 </div></div> |
384 </div></div> |
2371 <?php endif; ?> |
385 <?php endif; ?> |
2390 } |
404 } |
2391 |
405 |
2392 /** |
406 /** |
2393 * {@internal Missing Short Description}} |
407 * {@internal Missing Short Description}} |
2394 * |
408 * |
2395 * @since unknown |
409 * @since 1.2.0 |
2396 * |
|
2397 * @param unknown_type $currentcat |
|
2398 * @param unknown_type $currentparent |
|
2399 * @param unknown_type $parent |
|
2400 * @param unknown_type $level |
|
2401 * @param unknown_type $categories |
|
2402 * @return unknown |
|
2403 */ |
|
2404 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { |
|
2405 if (!$categories ) |
|
2406 $categories = get_categories( array('hide_empty' => 0) ); |
|
2407 |
|
2408 if ( $categories ) { |
|
2409 foreach ( $categories as $category ) { |
|
2410 if ( $currentcat != $category->term_id && $parent == $category->parent) { |
|
2411 $pad = str_repeat( '– ', $level ); |
|
2412 $category->name = esc_html( $category->name ); |
|
2413 echo "\n\t<option value='$category->term_id'"; |
|
2414 if ( $currentparent == $category->term_id ) |
|
2415 echo " selected='selected'"; |
|
2416 echo ">$pad$category->name</option>"; |
|
2417 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); |
|
2418 } |
|
2419 } |
|
2420 } else { |
|
2421 return false; |
|
2422 } |
|
2423 } |
|
2424 |
|
2425 /** |
|
2426 * {@internal Missing Short Description}} |
|
2427 * |
|
2428 * @since unknown |
|
2429 * |
410 * |
2430 * @param unknown_type $meta |
411 * @param unknown_type $meta |
2431 */ |
412 */ |
2432 function list_meta( $meta ) { |
413 function list_meta( $meta ) { |
2433 // Exit if no meta |
414 // Exit if no meta |
2434 if ( ! $meta ) { |
415 if ( ! $meta ) { |
2435 echo ' |
416 echo ' |
2436 <table id="list-table" style="display: none;"> |
417 <table id="list-table" style="display: none;"> |
2437 <thead> |
418 <thead> |
2438 <tr> |
419 <tr> |
2439 <th class="left">' . __( 'Name' ) . '</th> |
420 <th class="left">' . _x( 'Name', 'meta name' ) . '</th> |
2440 <th>' . __( 'Value' ) . '</th> |
421 <th>' . __( 'Value' ) . '</th> |
2441 </tr> |
422 </tr> |
2442 </thead> |
423 </thead> |
2443 <tbody id="the-list" class="list:meta"> |
424 <tbody id="the-list" class="list:meta"> |
2444 <tr><td></td></tr> |
425 <tr><td></td></tr> |
2449 $count = 0; |
430 $count = 0; |
2450 ?> |
431 ?> |
2451 <table id="list-table"> |
432 <table id="list-table"> |
2452 <thead> |
433 <thead> |
2453 <tr> |
434 <tr> |
2454 <th class="left"><?php _e( 'Name' ) ?></th> |
435 <th class="left"><?php _ex( 'Name', 'meta name' ) ?></th> |
2455 <th><?php _e( 'Value' ) ?></th> |
436 <th><?php _e( 'Value' ) ?></th> |
2456 </tr> |
437 </tr> |
2457 </thead> |
438 </thead> |
2458 <tbody id='the-list' class='list:meta'> |
439 <tbody id='the-list' class='list:meta'> |
2459 <?php |
440 <?php |
2466 } |
447 } |
2467 |
448 |
2468 /** |
449 /** |
2469 * {@internal Missing Short Description}} |
450 * {@internal Missing Short Description}} |
2470 * |
451 * |
2471 * @since unknown |
452 * @since 2.5.0 |
2472 * |
453 * |
2473 * @param unknown_type $entry |
454 * @param unknown_type $entry |
2474 * @param unknown_type $count |
455 * @param unknown_type $count |
2475 * @return unknown |
456 * @return unknown |
2476 */ |
457 */ |
2477 function _list_meta_row( $entry, &$count ) { |
458 function _list_meta_row( $entry, &$count ) { |
2478 static $update_nonce = false; |
459 static $update_nonce = false; |
460 |
|
461 if ( is_protected_meta( $entry['meta_key'], 'post' ) ) |
|
462 return; |
|
463 |
|
2479 if ( !$update_nonce ) |
464 if ( !$update_nonce ) |
2480 $update_nonce = wp_create_nonce( 'add-meta' ); |
465 $update_nonce = wp_create_nonce( 'add-meta' ); |
2481 |
466 |
2482 $r = ''; |
467 $r = ''; |
2483 ++ $count; |
468 ++ $count; |
2484 if ( $count % 2 ) |
469 if ( $count % 2 ) |
2485 $style = 'alternate'; |
470 $style = 'alternate'; |
2486 else |
471 else |
2487 $style = ''; |
472 $style = ''; |
2488 if ('_' == $entry['meta_key'] { 0 } ) |
|
2489 $style .= ' hidden'; |
|
2490 |
473 |
2491 if ( is_serialized( $entry['meta_value'] ) ) { |
474 if ( is_serialized( $entry['meta_value'] ) ) { |
2492 if ( is_serialized_string( $entry['meta_value'] ) ) { |
475 if ( is_serialized_string( $entry['meta_value'] ) ) { |
2493 // this is a serialized string, so we should display it |
476 // this is a serialized string, so we should display it |
2494 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); |
477 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); |
2498 return; |
481 return; |
2499 } |
482 } |
2500 } |
483 } |
2501 |
484 |
2502 $entry['meta_key'] = esc_attr($entry['meta_key']); |
485 $entry['meta_key'] = esc_attr($entry['meta_key']); |
2503 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea /> |
486 $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea /> |
2504 $entry['meta_id'] = (int) $entry['meta_id']; |
487 $entry['meta_id'] = (int) $entry['meta_id']; |
2505 |
488 |
2506 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
489 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
2507 |
490 |
2508 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; |
491 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; |
2509 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />"; |
492 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />"; |
2510 |
493 |
2511 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' "; |
494 $r .= "\n\t\t<div class='submit'>"; |
2512 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />"; |
495 $r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) ); |
2513 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>"; |
496 $r .= "\n\t\t"; |
497 $r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) ); |
|
498 $r .= "</div>"; |
|
2514 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
499 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
2515 $r .= "</td>"; |
500 $r .= "</td>"; |
2516 |
501 |
2517 $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
502 $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
2518 return $r; |
503 return $r; |
2519 } |
504 } |
2520 |
505 |
2521 /** |
506 /** |
2522 * {@internal Missing Short Description}} |
507 * {@internal Missing Short Description}} |
2523 * |
508 * |
2524 * @since unknown |
509 * @since 1.2.0 |
2525 */ |
510 */ |
2526 function meta_form() { |
511 function meta_form() { |
2527 global $wpdb; |
512 global $wpdb; |
2528 $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); |
513 $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); |
2529 $keys = $wpdb->get_col( " |
514 $keys = $wpdb->get_col( " |
2530 SELECT meta_key |
515 SELECT meta_key |
2531 FROM $wpdb->postmeta |
516 FROM $wpdb->postmeta |
2532 GROUP BY meta_key |
517 GROUP BY meta_key |
2533 HAVING meta_key NOT LIKE '\_%' |
518 HAVING meta_key NOT LIKE '\_%' |
2534 ORDER BY LOWER(meta_key) |
519 ORDER BY meta_key |
2535 LIMIT $limit" ); |
520 LIMIT $limit" ); |
2536 if ( $keys ) |
521 if ( $keys ) |
2537 natcasesort($keys); |
522 natcasesort($keys); |
2538 ?> |
523 ?> |
2539 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p> |
524 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p> |
2540 <table id="newmeta"> |
525 <table id="newmeta"> |
2541 <thead> |
526 <thead> |
2542 <tr> |
527 <tr> |
2543 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th> |
528 <th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ) ?></label></th> |
2544 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> |
529 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th> |
2545 </tr> |
530 </tr> |
2546 </thead> |
531 </thead> |
2547 |
532 |
2548 <tbody> |
533 <tbody> |
2549 <tr> |
534 <tr> |
2550 <td id="newmetaleft" class="left"> |
535 <td id="newmetaleft" class="left"> |
2551 <?php if ( $keys ) { ?> |
536 <?php if ( $keys ) { ?> |
2552 <select id="metakeyselect" name="metakeyselect" tabindex="7"> |
537 <select id="metakeyselect" name="metakeyselect" tabindex="7"> |
2553 <option value="#NONE#"><?php _e( '- Select -' ); ?></option> |
538 <option value="#NONE#"><?php _e( '— Select —' ); ?></option> |
2554 <?php |
539 <?php |
2555 |
540 |
2556 foreach ( $keys as $key ) { |
541 foreach ( $keys as $key ) { |
2557 $key = esc_attr( $key ); |
542 echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>"; |
2558 echo "\n<option value='" . esc_attr($key) . "'>$key</option>"; |
|
2559 } |
543 } |
2560 ?> |
544 ?> |
2561 </select> |
545 </select> |
2562 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> |
546 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> |
2563 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
547 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
2569 </td> |
553 </td> |
2570 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td> |
554 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td> |
2571 </tr> |
555 </tr> |
2572 |
556 |
2573 <tr><td colspan="2" class="submit"> |
557 <tr><td colspan="2" class="submit"> |
2574 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" /> |
558 <?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?> |
2575 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?> |
559 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> |
2576 </td></tr> |
560 </td></tr> |
2577 </tbody> |
561 </tbody> |
2578 </table> |
562 </table> |
2579 <?php |
563 <?php |
2580 |
564 |
2581 } |
565 } |
2582 |
566 |
2583 /** |
567 /** |
2584 * {@internal Missing Short Description}} |
568 * {@internal Missing Short Description}} |
2585 * |
569 * |
2586 * @since unknown |
570 * @since 0.71 |
2587 * |
571 * |
2588 * @param unknown_type $edit |
572 * @param unknown_type $edit |
2589 * @param unknown_type $for_post |
573 * @param unknown_type $for_post |
2590 * @param unknown_type $tab_index |
574 * @param unknown_type $tab_index |
2591 * @param unknown_type $multi |
575 * @param unknown_type $multi |
2592 */ |
576 */ |
2593 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
577 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { |
2594 global $wp_locale, $post, $comment; |
578 global $wp_locale, $post, $comment; |
2595 |
579 |
2596 if ( $for_post ) |
580 if ( $for_post ) |
2597 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true; |
581 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); |
2598 |
582 |
2599 $tab_index_attribute = ''; |
583 $tab_index_attribute = ''; |
2600 if ( (int) $tab_index > 0 ) |
584 if ( (int) $tab_index > 0 ) |
2601 $tab_index_attribute = " tabindex=\"$tab_index\""; |
585 $tab_index_attribute = " tabindex=\"$tab_index\""; |
2602 |
586 |
2603 // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; |
587 // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; |
2604 |
588 |
2605 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); |
589 $time_adj = current_time('timestamp'); |
2606 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; |
590 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; |
2607 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); |
591 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); |
2608 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); |
592 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); |
2609 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); |
593 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); |
2610 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); |
594 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); |
2617 $cur_hh = gmdate( 'H', $time_adj ); |
601 $cur_hh = gmdate( 'H', $time_adj ); |
2618 $cur_mn = gmdate( 'i', $time_adj ); |
602 $cur_mn = gmdate( 'i', $time_adj ); |
2619 |
603 |
2620 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n"; |
604 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n"; |
2621 for ( $i = 1; $i < 13; $i = $i +1 ) { |
605 for ( $i = 1; $i < 13; $i = $i +1 ) { |
2622 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; |
606 $monthnum = zeroise($i, 2); |
607 $month .= "\t\t\t" . '<option value="' . $monthnum . '"'; |
|
2623 if ( $i == $mm ) |
608 if ( $i == $mm ) |
2624 $month .= ' selected="selected"'; |
609 $month .= ' selected="selected"'; |
2625 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n"; |
610 /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ |
611 $month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n"; |
|
2626 } |
612 } |
2627 $month .= '</select>'; |
613 $month .= '</select>'; |
2628 |
614 |
2629 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; |
615 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; |
2630 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />'; |
616 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />'; |
2655 } |
641 } |
2656 |
642 |
2657 /** |
643 /** |
2658 * {@internal Missing Short Description}} |
644 * {@internal Missing Short Description}} |
2659 * |
645 * |
2660 * @since unknown |
646 * @since 1.5.0 |
2661 * |
647 * |
2662 * @param unknown_type $default |
648 * @param unknown_type $default |
2663 */ |
649 */ |
2664 function page_template_dropdown( $default = '' ) { |
650 function page_template_dropdown( $default = '' ) { |
2665 $templates = get_page_templates(); |
651 $templates = get_page_templates(); |
2674 } |
660 } |
2675 |
661 |
2676 /** |
662 /** |
2677 * {@internal Missing Short Description}} |
663 * {@internal Missing Short Description}} |
2678 * |
664 * |
2679 * @since unknown |
665 * @since 1.5.0 |
2680 * |
666 * |
2681 * @param unknown_type $default |
667 * @param unknown_type $default |
2682 * @param unknown_type $parent |
668 * @param unknown_type $parent |
2683 * @param unknown_type $level |
669 * @param unknown_type $level |
2684 * @return unknown |
670 * @return unknown |
2710 } |
696 } |
2711 |
697 |
2712 /** |
698 /** |
2713 * {@internal Missing Short Description}} |
699 * {@internal Missing Short Description}} |
2714 * |
700 * |
2715 * @since unknown |
701 * @since 2.0.0 |
2716 */ |
|
2717 function browse_happy() { |
|
2718 $getit = __( 'WordPress recommends a better browser' ); |
|
2719 echo ' |
|
2720 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div> |
|
2721 '; |
|
2722 } |
|
2723 |
|
2724 /** |
|
2725 * {@internal Missing Short Description}} |
|
2726 * |
|
2727 * @since unknown |
|
2728 * |
702 * |
2729 * @param unknown_type $id |
703 * @param unknown_type $id |
2730 * @return unknown |
704 * @return unknown |
2731 */ |
705 */ |
2732 function the_attachment_links( $id = false ) { |
706 function the_attachment_links( $id = false ) { |
2734 $post = & get_post( $id ); |
708 $post = & get_post( $id ); |
2735 |
709 |
2736 if ( $post->post_type != 'attachment' ) |
710 if ( $post->post_type != 'attachment' ) |
2737 return false; |
711 return false; |
2738 |
712 |
2739 $icon = get_attachment_icon( $post->ID ); |
713 $icon = wp_get_attachment_image( $post->ID, 'thumbnail', true ); |
2740 $attachment_data = wp_get_attachment_metadata( $id ); |
714 $attachment_data = wp_get_attachment_metadata( $id ); |
2741 $thumb = isset( $attachment_data['thumb'] ); |
715 $thumb = isset( $attachment_data['thumb'] ); |
2742 ?> |
716 ?> |
2743 <form id="the-attachment-links"> |
717 <form id="the-attachment-links"> |
2744 <table> |
718 <table> |
2745 <col /> |
719 <col /> |
2746 <col class="widefat" /> |
720 <col class="widefat" /> |
2747 <tr> |
721 <tr> |
2748 <th scope="row"><?php _e( 'URL' ) ?></th> |
722 <th scope="row"><?php _e( 'URL' ) ?></th> |
2749 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td> |
723 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td> |
2750 </tr> |
724 </tr> |
2751 <?php if ( $icon ) : ?> |
725 <?php if ( $icon ) : ?> |
2752 <tr> |
726 <tr> |
2753 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th> |
727 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th> |
2754 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td> |
728 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td> |
2770 </table> |
744 </table> |
2771 </form> |
745 </form> |
2772 <?php |
746 <?php |
2773 } |
747 } |
2774 |
748 |
2775 |
749 /** |
2776 /** |
750 * Print out <option> html elements for role selectors |
2777 * Print out <option> html elements for role selectors based on $wp_roles |
751 * |
2778 * |
752 * @since 2.1.0 |
2779 * @package WordPress |
753 * |
2780 * @subpackage Administration |
754 * @param string $selected slug for the role that should be already selected |
2781 * @since 2.1 |
|
2782 * |
|
2783 * @uses $wp_roles |
|
2784 * @param string $default slug for the role that should be already selected |
|
2785 */ |
755 */ |
2786 function wp_dropdown_roles( $selected = false ) { |
756 function wp_dropdown_roles( $selected = false ) { |
2787 global $wp_roles; |
|
2788 $p = ''; |
757 $p = ''; |
2789 $r = ''; |
758 $r = ''; |
2790 |
759 |
2791 $editable_roles = get_editable_roles(); |
760 $editable_roles = get_editable_roles(); |
2792 |
761 |
2793 foreach( $editable_roles as $role => $details ) { |
762 foreach ( $editable_roles as $role => $details ) { |
2794 $name = translate_user_role($details['name'] ); |
763 $name = translate_user_role($details['name'] ); |
2795 if ( $selected == $role ) // Make default first in list |
764 if ( $selected == $role ) // preselect specified role |
2796 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
765 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
2797 else |
766 else |
2798 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
767 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
2799 } |
768 } |
2800 echo $p . $r; |
769 echo $p . $r; |
2801 } |
770 } |
2802 |
771 |
2803 /** |
772 /** |
2804 * {@internal Missing Short Description}} |
773 * {@internal Missing Short Description}} |
2805 * |
774 * |
2806 * @since unknown |
775 * @since 2.3.0 |
2807 * |
776 * |
2808 * @param unknown_type $size |
777 * @param unknown_type $size |
2809 * @return unknown |
778 * @return unknown |
2810 */ |
779 */ |
2811 function wp_convert_hr_to_bytes( $size ) { |
780 function wp_convert_hr_to_bytes( $size ) { |
2821 } |
790 } |
2822 |
791 |
2823 /** |
792 /** |
2824 * {@internal Missing Short Description}} |
793 * {@internal Missing Short Description}} |
2825 * |
794 * |
2826 * @since unknown |
795 * @since 2.3.0 |
2827 * |
796 * |
2828 * @param unknown_type $bytes |
797 * @param unknown_type $bytes |
2829 * @return unknown |
798 * @return unknown |
2830 */ |
799 */ |
2831 function wp_convert_bytes_to_hr( $bytes ) { |
800 function wp_convert_bytes_to_hr( $bytes ) { |
2837 } |
806 } |
2838 |
807 |
2839 /** |
808 /** |
2840 * {@internal Missing Short Description}} |
809 * {@internal Missing Short Description}} |
2841 * |
810 * |
2842 * @since unknown |
811 * @since 2.5.0 |
2843 * |
812 * |
2844 * @return unknown |
813 * @return unknown |
2845 */ |
814 */ |
2846 function wp_max_upload_size() { |
815 function wp_max_upload_size() { |
2847 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
816 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
2851 } |
820 } |
2852 |
821 |
2853 /** |
822 /** |
2854 * Outputs the form used by the importers to accept the data to be imported |
823 * Outputs the form used by the importers to accept the data to be imported |
2855 * |
824 * |
2856 * @since 2.0 |
825 * @since 2.0.0 |
2857 * |
826 * |
2858 * @param string $action The action attribute for the form. |
827 * @param string $action The action attribute for the form. |
2859 */ |
828 */ |
2860 function wp_import_upload_form( $action ) { |
829 function wp_import_upload_form( $action ) { |
2861 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
830 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
2871 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
840 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) |
2872 <input type="file" id="upload" name="import" size="25" /> |
841 <input type="file" id="upload" name="import" size="25" /> |
2873 <input type="hidden" name="action" value="save" /> |
842 <input type="hidden" name="action" value="save" /> |
2874 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
843 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> |
2875 </p> |
844 </p> |
2876 <p class="submit"> |
845 <?php submit_button( __('Upload file and import'), 'button' ); ?> |
2877 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" /> |
|
2878 </p> |
|
2879 </form> |
846 </form> |
2880 <?php |
847 <?php |
2881 endif; |
848 endif; |
2882 } |
849 } |
2883 |
850 |
2884 /** |
851 /** |
2885 * {@internal Missing Short Description}} |
|
2886 * |
|
2887 * @since unknown |
|
2888 */ |
|
2889 function wp_remember_old_slug() { |
|
2890 global $post; |
|
2891 $name = esc_attr($post->post_name); // just in case |
|
2892 if ( strlen($name) ) |
|
2893 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />'; |
|
2894 } |
|
2895 |
|
2896 /** |
|
2897 * Add a meta box to an edit form. |
852 * Add a meta box to an edit form. |
2898 * |
853 * |
2899 * @since 2.5.0 |
854 * @since 2.5.0 |
2900 * |
855 * |
2901 * @param string $id String for use in the 'id' attribute of tags. |
856 * @param string $id String for use in the 'id' attribute of tags. |
2902 * @param string $title Title of the meta box. |
857 * @param string $title Title of the meta box. |
2903 * @param string $callback Function that fills the box with the desired content. The function should echo its output. |
858 * @param string $callback Function that fills the box with the desired content. The function should echo its output. |
2904 * @param string $page The type of edit page on which to show the box (post, page, link). |
859 * @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen. |
2905 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). |
860 * @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced'). |
2906 * @param string $priority The priority within the context where the boxes should show ('high', 'low'). |
861 * @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low'). |
2907 */ |
862 */ |
2908 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) { |
863 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { |
2909 global $wp_meta_boxes; |
864 global $wp_meta_boxes; |
865 |
|
866 if ( empty( $screen ) ) |
|
867 $screen = get_current_screen(); |
|
868 elseif ( is_string( $screen ) ) |
|
869 $screen = convert_to_screen( $screen ); |
|
870 |
|
871 $page = $screen->id; |
|
2910 |
872 |
2911 if ( !isset($wp_meta_boxes) ) |
873 if ( !isset($wp_meta_boxes) ) |
2912 $wp_meta_boxes = array(); |
874 $wp_meta_boxes = array(); |
2913 if ( !isset($wp_meta_boxes[$page]) ) |
875 if ( !isset($wp_meta_boxes[$page]) ) |
2914 $wp_meta_boxes[$page] = array(); |
876 $wp_meta_boxes[$page] = array(); |
2915 if ( !isset($wp_meta_boxes[$page][$context]) ) |
877 if ( !isset($wp_meta_boxes[$page][$context]) ) |
2916 $wp_meta_boxes[$page][$context] = array(); |
878 $wp_meta_boxes[$page][$context] = array(); |
2917 |
879 |
2918 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { |
880 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) { |
2919 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { |
881 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) { |
2920 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) |
882 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) ) |
2921 continue; |
883 continue; |
2922 |
884 |
2923 // If a core box was previously added or removed by a plugin, don't add. |
885 // If a core box was previously added or removed by a plugin, don't add. |
2924 if ( 'core' == $priority ) { |
886 if ( 'core' == $priority ) { |
2925 // If core box previously deleted, don't add |
887 // If core box previously deleted, don't add |
2926 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) |
888 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) |
889 return; |
|
890 // If box was added with default priority, give it core priority to maintain sort order |
|
891 if ( 'default' == $a_priority ) { |
|
892 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; |
|
893 unset($wp_meta_boxes[$page][$a_context]['default'][$id]); |
|
894 } |
|
2927 return; |
895 return; |
2928 // If box was added with default priority, give it core priority to maintain sort order |
|
2929 if ( 'default' == $a_priority ) { |
|
2930 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; |
|
2931 unset($wp_meta_boxes[$page][$a_context]['default'][$id]); |
|
2932 } |
896 } |
2933 return; |
897 // If no priority given and id already present, use existing priority |
898 if ( empty($priority) ) { |
|
899 $priority = $a_priority; |
|
900 // else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority. |
|
901 } elseif ( 'sorted' == $priority ) { |
|
902 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; |
|
903 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; |
|
904 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; |
|
905 } |
|
906 // An id can be in only one priority and one context |
|
907 if ( $priority != $a_priority || $context != $a_context ) |
|
908 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); |
|
2934 } |
909 } |
2935 // If no priority given and id already present, use existing priority |
|
2936 if ( empty($priority) ) { |
|
2937 $priority = $a_priority; |
|
2938 // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority. |
|
2939 } elseif ( 'sorted' == $priority ) { |
|
2940 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; |
|
2941 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; |
|
2942 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; |
|
2943 } |
|
2944 // An id can be in only one priority and one context |
|
2945 if ( $priority != $a_priority || $context != $a_context ) |
|
2946 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); |
|
2947 } |
|
2948 } |
910 } |
2949 |
911 |
2950 if ( empty($priority) ) |
912 if ( empty($priority) ) |
2951 $priority = 'low'; |
913 $priority = 'low'; |
2952 |
914 |
2955 |
917 |
2956 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); |
918 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); |
2957 } |
919 } |
2958 |
920 |
2959 /** |
921 /** |
2960 * {@internal Missing Short Description}} |
922 * Meta-Box template function |
2961 * |
923 * |
2962 * @since unknown |
924 * @since 2.5.0 |
2963 * |
925 * |
2964 * @param unknown_type $page |
926 * @param string|object $screen Screen identifier |
2965 * @param unknown_type $context |
927 * @param string $context box context |
2966 * @param unknown_type $object |
928 * @param mixed $object gets passed to the box callback function as first parameter |
2967 * @return int number of meta_boxes |
929 * @return int number of meta_boxes |
2968 */ |
930 */ |
2969 function do_meta_boxes($page, $context, $object) { |
931 function do_meta_boxes( $screen, $context, $object ) { |
2970 global $wp_meta_boxes; |
932 global $wp_meta_boxes; |
2971 static $already_sorted = false; |
933 static $already_sorted = false; |
2972 |
934 |
2973 //do_action('do_meta_boxes', $page, $context, $object); |
935 if ( empty( $screen ) ) |
2974 |
936 $screen = get_current_screen(); |
2975 $hidden = get_hidden_meta_boxes($page); |
937 elseif ( is_string( $screen ) ) |
2976 |
938 $screen = convert_to_screen( $screen ); |
2977 echo "<div id='$context-sortables' class='meta-box-sortables'>\n"; |
939 |
940 $page = $screen->id; |
|
941 |
|
942 $hidden = get_hidden_meta_boxes( $screen ); |
|
943 |
|
944 printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context)); |
|
2978 |
945 |
2979 $i = 0; |
946 $i = 0; |
2980 do { |
947 do { |
2981 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose |
948 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose |
2982 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) { |
949 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { |
2983 foreach ( $sorted as $box_context => $ids ) |
950 foreach ( $sorted as $box_context => $ids ) { |
2984 foreach ( explode(',', $ids) as $id ) |
951 foreach ( explode(',', $ids ) as $id ) { |
2985 if ( $id ) |
952 if ( $id && 'dashboard_browser_nag' !== $id ) |
2986 add_meta_box( $id, null, null, $page, $box_context, 'sorted' ); |
953 add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); |
954 } |
|
955 } |
|
2987 } |
956 } |
2988 $already_sorted = true; |
957 $already_sorted = true; |
2989 |
958 |
2990 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) |
959 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) |
2991 break; |
960 break; |
2995 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { |
964 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { |
2996 if ( false == $box || ! $box['title'] ) |
965 if ( false == $box || ! $box['title'] ) |
2997 continue; |
966 continue; |
2998 $i++; |
967 $i++; |
2999 $style = ''; |
968 $style = ''; |
3000 if ( in_array($box['id'], $hidden) ) |
969 $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; |
3001 $style = 'style="display:none;"'; |
970 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n"; |
3002 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n"; |
971 if ( 'dashboard_browser_nag' != $box['id'] ) |
3003 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>'; |
972 echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>'; |
3004 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; |
973 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n"; |
3005 echo '<div class="inside">' . "\n"; |
974 echo '<div class="inside">' . "\n"; |
3006 call_user_func($box['callback'], $object, $box); |
975 call_user_func($box['callback'], $object, $box); |
3007 echo "</div>\n"; |
976 echo "</div>\n"; |
3008 echo "</div>\n"; |
977 echo "</div>\n"; |
3021 * Remove a meta box from an edit form. |
990 * Remove a meta box from an edit form. |
3022 * |
991 * |
3023 * @since 2.6.0 |
992 * @since 2.6.0 |
3024 * |
993 * |
3025 * @param string $id String for use in the 'id' attribute of tags. |
994 * @param string $id String for use in the 'id' attribute of tags. |
3026 * @param string $page The type of edit page on which to show the box (post, page, link). |
995 * @param string|object $screen The screen on which to show the box (post, page, link). |
3027 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). |
996 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). |
3028 */ |
997 */ |
3029 function remove_meta_box($id, $page, $context) { |
998 function remove_meta_box($id, $screen, $context) { |
3030 global $wp_meta_boxes; |
999 global $wp_meta_boxes; |
1000 |
|
1001 if ( empty( $screen ) ) |
|
1002 $screen = get_current_screen(); |
|
1003 elseif ( is_string( $screen ) ) |
|
1004 $screen = convert_to_screen( $screen ); |
|
1005 |
|
1006 $page = $screen->id; |
|
3031 |
1007 |
3032 if ( !isset($wp_meta_boxes) ) |
1008 if ( !isset($wp_meta_boxes) ) |
3033 $wp_meta_boxes = array(); |
1009 $wp_meta_boxes = array(); |
3034 if ( !isset($wp_meta_boxes[$page]) ) |
1010 if ( !isset($wp_meta_boxes[$page]) ) |
3035 $wp_meta_boxes[$page] = array(); |
1011 $wp_meta_boxes[$page] = array(); |
3039 foreach ( array('high', 'core', 'default', 'low') as $priority ) |
1015 foreach ( array('high', 'core', 'default', 'low') as $priority ) |
3040 $wp_meta_boxes[$page][$context][$priority][$id] = false; |
1016 $wp_meta_boxes[$page][$context][$priority][$id] = false; |
3041 } |
1017 } |
3042 |
1018 |
3043 /** |
1019 /** |
3044 * {@internal Missing Short Description}} |
|
3045 * |
|
3046 * @since unknown |
|
3047 * |
|
3048 * @param unknown_type $page |
|
3049 */ |
|
3050 function meta_box_prefs($page) { |
|
3051 global $wp_meta_boxes; |
|
3052 |
|
3053 if ( empty($wp_meta_boxes[$page]) ) |
|
3054 return; |
|
3055 |
|
3056 $hidden = get_hidden_meta_boxes($page); |
|
3057 |
|
3058 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) { |
|
3059 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) { |
|
3060 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
3061 if ( false == $box || ! $box['title'] ) |
|
3062 continue; |
|
3063 // Submit box cannot be hidden |
|
3064 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) |
|
3065 continue; |
|
3066 $box_id = $box['id']; |
|
3067 echo '<label for="' . $box_id . '-hide">'; |
|
3068 echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />'; |
|
3069 echo "{$box['title']}</label>\n"; |
|
3070 } |
|
3071 } |
|
3072 } |
|
3073 } |
|
3074 |
|
3075 function get_hidden_meta_boxes($page) { |
|
3076 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false ); |
|
3077 |
|
3078 // Hide slug boxes by default |
|
3079 if ( empty($hidden[0]) ) { |
|
3080 $hidden = array('slugdiv'); |
|
3081 } |
|
3082 |
|
3083 return $hidden; |
|
3084 } |
|
3085 |
|
3086 /** |
|
3087 * Add a new section to a settings page. |
1020 * Add a new section to a settings page. |
3088 * |
1021 * |
1022 * Part of the Settings API. Use this to define new settings sections for an admin page. |
|
1023 * Show settings sections in your admin page callback function with do_settings_sections(). |
|
1024 * Add settings fields to your section with add_settings_field() |
|
1025 * |
|
1026 * The $callback argument should be the name of a function that echoes out any |
|
1027 * content you want to show at the top of the settings section before the actual |
|
1028 * fields. It can output nothing if you want. |
|
1029 * |
|
3089 * @since 2.7.0 |
1030 * @since 2.7.0 |
3090 * |
1031 * |
3091 * @param string $id String for use in the 'id' attribute of tags. |
1032 * @global $wp_settings_sections Storage array of all settings sections added to admin pages |
3092 * @param string $title Title of the section. |
1033 * |
3093 * @param string $callback Function that fills the section with the desired content. The function should echo its output. |
1034 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags. |
3094 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...). |
1035 * @param string $title Formatted title of the section. Shown as the heading for the section. |
1036 * @param string $callback Function that echos out any content at the top of the section (between heading and fields). |
|
1037 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page(); |
|
3095 */ |
1038 */ |
3096 function add_settings_section($id, $title, $callback, $page) { |
1039 function add_settings_section($id, $title, $callback, $page) { |
3097 global $wp_settings_sections; |
1040 global $wp_settings_sections; |
1041 |
|
1042 if ( 'misc' == $page ) { |
|
1043 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
|
1044 $page = 'general'; |
|
1045 } |
|
3098 |
1046 |
3099 if ( !isset($wp_settings_sections) ) |
1047 if ( !isset($wp_settings_sections) ) |
3100 $wp_settings_sections = array(); |
1048 $wp_settings_sections = array(); |
3101 if ( !isset($wp_settings_sections[$page]) ) |
1049 if ( !isset($wp_settings_sections[$page]) ) |
3102 $wp_settings_sections[$page] = array(); |
1050 $wp_settings_sections[$page] = array(); |
3105 |
1053 |
3106 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); |
1054 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback); |
3107 } |
1055 } |
3108 |
1056 |
3109 /** |
1057 /** |
3110 * Add a new field to a settings page. |
1058 * Add a new field to a section of a settings page |
1059 * |
|
1060 * Part of the Settings API. Use this to define a settings field that will show |
|
1061 * as part of a settings section inside a settings page. The fields are shown using |
|
1062 * do_settings_fields() in do_settings-sections() |
|
1063 * |
|
1064 * The $callback argument should be the name of a function that echoes out the |
|
1065 * html input tags for this setting field. Use get_option() to retrieve existing |
|
1066 * values to show. |
|
3111 * |
1067 * |
3112 * @since 2.7.0 |
1068 * @since 2.7.0 |
3113 * |
1069 * |
3114 * @param string $id String for use in the 'id' attribute of tags. |
1070 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections |
3115 * @param string $title Title of the field. |
1071 * |
3116 * @param string $callback Function that fills the field with the desired content. The function should echo its output. |
1072 * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags. |
3117 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...). |
1073 * @param string $title Formatted title of the field. Shown as the label for the field during output. |
3118 * @param string $section The section of the settingss page in which to show the box (default, ...). |
1074 * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output. |
1075 * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...). |
|
1076 * @param string $section The slug-name of the section of the settings page in which to show the box (default, ...). |
|
3119 * @param array $args Additional arguments |
1077 * @param array $args Additional arguments |
3120 */ |
1078 */ |
3121 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { |
1079 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { |
3122 global $wp_settings_fields; |
1080 global $wp_settings_fields; |
1081 |
|
1082 if ( 'misc' == $page ) { |
|
1083 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) ); |
|
1084 $page = 'general'; |
|
1085 } |
|
3123 |
1086 |
3124 if ( !isset($wp_settings_fields) ) |
1087 if ( !isset($wp_settings_fields) ) |
3125 $wp_settings_fields = array(); |
1088 $wp_settings_fields = array(); |
3126 if ( !isset($wp_settings_fields[$page]) ) |
1089 if ( !isset($wp_settings_fields[$page]) ) |
3127 $wp_settings_fields[$page] = array(); |
1090 $wp_settings_fields[$page] = array(); |
3130 |
1093 |
3131 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); |
1094 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); |
3132 } |
1095 } |
3133 |
1096 |
3134 /** |
1097 /** |
3135 * {@internal Missing Short Description}} |
1098 * Prints out all settings sections added to a particular settings page |
3136 * |
1099 * |
3137 * @since unknown |
1100 * Part of the Settings API. Use this in a settings page callback function |
3138 * |
1101 * to output all the sections and fields that were added to that $page with |
3139 * @param unknown_type $page |
1102 * add_settings_section() and add_settings_field() |
1103 * |
|
1104 * @global $wp_settings_sections Storage array of all settings sections added to admin pages |
|
1105 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections |
|
1106 * @since 2.7.0 |
|
1107 * |
|
1108 * @param string $page The slug name of the page whos settings sections you want to output |
|
3140 */ |
1109 */ |
3141 function do_settings_sections($page) { |
1110 function do_settings_sections($page) { |
3142 global $wp_settings_sections, $wp_settings_fields; |
1111 global $wp_settings_sections, $wp_settings_fields; |
3143 |
1112 |
3144 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) |
1113 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) ) |
3145 return; |
1114 return; |
3146 |
1115 |
3147 foreach ( (array) $wp_settings_sections[$page] as $section ) { |
1116 foreach ( (array) $wp_settings_sections[$page] as $section ) { |
3148 echo "<h3>{$section['title']}</h3>\n"; |
1117 if ( $section['title'] ) |
1118 echo "<h3>{$section['title']}</h3>\n"; |
|
3149 call_user_func($section['callback'], $section); |
1119 call_user_func($section['callback'], $section); |
3150 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) |
1120 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) ) |
3151 continue; |
1121 continue; |
3152 echo '<table class="form-table">'; |
1122 echo '<table class="form-table">'; |
3153 do_settings_fields($page, $section['id']); |
1123 do_settings_fields($page, $section['id']); |
3154 echo '</table>'; |
1124 echo '</table>'; |
3155 } |
1125 } |
3156 } |
1126 } |
3157 |
1127 |
3158 /** |
1128 /** |
3159 * {@internal Missing Short Description}} |
1129 * Print out the settings fields for a particular settings section |
3160 * |
1130 * |
3161 * @since unknown |
1131 * Part of the Settings API. Use this in a settings page to output |
3162 * |
1132 * a specific section. Should normally be called by do_settings_sections() |
3163 * @param unknown_type $page |
1133 * rather than directly. |
3164 * @param unknown_type $section |
1134 * |
1135 * @global $wp_settings_fields Storage array of settings fields and their pages/sections |
|
1136 * |
|
1137 * @since 2.7.0 |
|
1138 * |
|
1139 * @param string $page Slug title of the admin page who's settings fields you want to show. |
|
1140 * @param section $section Slug title of the settings section who's fields you want to show. |
|
3165 */ |
1141 */ |
3166 function do_settings_fields($page, $section) { |
1142 function do_settings_fields($page, $section) { |
3167 global $wp_settings_fields; |
1143 global $wp_settings_fields; |
3168 |
1144 |
3169 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) |
1145 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) |
3181 echo '</tr>'; |
1157 echo '</tr>'; |
3182 } |
1158 } |
3183 } |
1159 } |
3184 |
1160 |
3185 /** |
1161 /** |
1162 * Register a settings error to be displayed to the user |
|
1163 * |
|
1164 * Part of the Settings API. Use this to show messages to users about settings validation |
|
1165 * problems, missing settings or anything else. |
|
1166 * |
|
1167 * Settings errors should be added inside the $sanitize_callback function defined in |
|
1168 * register_setting() for a given setting to give feedback about the submission. |
|
1169 * |
|
1170 * By default messages will show immediately after the submission that generated the error. |
|
1171 * Additional calls to settings_errors() can be used to show errors even when the settings |
|
1172 * page is first accessed. |
|
1173 * |
|
1174 * @since 3.0.0 |
|
1175 * |
|
1176 * @global array $wp_settings_errors Storage array of errors registered during this pageload |
|
1177 * |
|
1178 * @param string $setting Slug title of the setting to which this error applies |
|
1179 * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. |
|
1180 * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>) |
|
1181 * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'. |
|
1182 */ |
|
1183 function add_settings_error( $setting, $code, $message, $type = 'error' ) { |
|
1184 global $wp_settings_errors; |
|
1185 |
|
1186 if ( !isset($wp_settings_errors) ) |
|
1187 $wp_settings_errors = array(); |
|
1188 |
|
1189 $new_error = array( |
|
1190 'setting' => $setting, |
|
1191 'code' => $code, |
|
1192 'message' => $message, |
|
1193 'type' => $type |
|
1194 ); |
|
1195 $wp_settings_errors[] = $new_error; |
|
1196 } |
|
1197 |
|
1198 /** |
|
1199 * Fetch settings errors registered by add_settings_error() |
|
1200 * |
|
1201 * Checks the $wp_settings_errors array for any errors declared during the current |
|
1202 * pageload and returns them. |
|
1203 * |
|
1204 * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved |
|
1205 * to the 'settings_errors' transient then those errors will be returned instead. This |
|
1206 * is used to pass errors back across pageloads. |
|
1207 * |
|
1208 * Use the $sanitize argument to manually re-sanitize the option before returning errors. |
|
1209 * This is useful if you have errors or notices you want to show even when the user |
|
1210 * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook) |
|
1211 * |
|
1212 * @since 3.0.0 |
|
1213 * |
|
1214 * @global array $wp_settings_errors Storage array of errors registered during this pageload |
|
1215 * |
|
1216 * @param string $setting Optional slug title of a specific setting who's errors you want. |
|
1217 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. |
|
1218 * @return array Array of settings errors |
|
1219 */ |
|
1220 function get_settings_errors( $setting = '', $sanitize = false ) { |
|
1221 global $wp_settings_errors; |
|
1222 |
|
1223 // If $sanitize is true, manually re-run the sanitizisation for this option |
|
1224 // This allows the $sanitize_callback from register_setting() to run, adding |
|
1225 // any settings errors you want to show by default. |
|
1226 if ( $sanitize ) |
|
1227 sanitize_option( $setting, get_option($setting)); |
|
1228 |
|
1229 // If settings were passed back from options.php then use them |
|
1230 // Ignore transients if $sanitize is true, we don't want the old values anyway |
|
1231 if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) { |
|
1232 $settings_errors = get_transient('settings_errors'); |
|
1233 delete_transient('settings_errors'); |
|
1234 // Otherwise check global in case validation has been run on this pageload |
|
1235 } elseif ( count( $wp_settings_errors ) ) { |
|
1236 $settings_errors = $wp_settings_errors; |
|
1237 } else { |
|
1238 return; |
|
1239 } |
|
1240 |
|
1241 // Filter the results to those of a specific setting if one was set |
|
1242 if ( $setting ) { |
|
1243 foreach ( (array) $settings_errors as $key => $details ) |
|
1244 if ( $setting != $details['setting'] ) |
|
1245 unset( $settings_errors[$key] ); |
|
1246 } |
|
1247 return $settings_errors; |
|
1248 } |
|
1249 |
|
1250 /** |
|
1251 * Display settings errors registered by add_settings_error() |
|
1252 * |
|
1253 * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors(). |
|
1254 * |
|
1255 * This is called automatically after a settings page based on the Settings API is submitted. |
|
1256 * Errors should be added during the validation callback function for a setting defined in register_setting() |
|
1257 * |
|
1258 * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization |
|
1259 * on its current value. |
|
1260 * |
|
1261 * The $hide_on_update option will cause errors to only show when the settings page is first loaded. |
|
1262 * if the user has already saved new values it will be hidden to avoid repeating messages already |
|
1263 * shown in the default error reporting after submission. This is useful to show general errors like missing |
|
1264 * settings when the user arrives at the settings page. |
|
1265 * |
|
1266 * @since 3.0.0 |
|
1267 * |
|
1268 * @param string $setting Optional slug title of a specific setting who's errors you want. |
|
1269 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors. |
|
1270 * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted. |
|
1271 */ |
|
1272 function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) { |
|
1273 |
|
1274 if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) |
|
1275 return; |
|
1276 |
|
1277 $settings_errors = get_settings_errors( $setting, $sanitize ); |
|
1278 |
|
1279 if ( ! is_array( $settings_errors ) ) |
|
1280 return; |
|
1281 |
|
1282 $output = ''; |
|
1283 foreach ( $settings_errors as $key => $details ) { |
|
1284 $css_id = 'setting-error-' . $details['code']; |
|
1285 $css_class = $details['type'] . ' settings-error'; |
|
1286 $output .= "<div id='$css_id' class='$css_class'> \n"; |
|
1287 $output .= "<p><strong>{$details['message']}</strong></p>"; |
|
1288 $output .= "</div> \n"; |
|
1289 } |
|
1290 echo $output; |
|
1291 } |
|
1292 |
|
1293 /** |
|
3186 * {@internal Missing Short Description}} |
1294 * {@internal Missing Short Description}} |
3187 * |
1295 * |
3188 * @since unknown |
1296 * @since 2.7.0 |
3189 * |
|
3190 * @param unknown_type $page |
|
3191 */ |
|
3192 function manage_columns_prefs($page) { |
|
3193 $columns = get_column_headers($page); |
|
3194 |
|
3195 $hidden = get_hidden_columns($page); |
|
3196 |
|
3197 foreach ( $columns as $column => $title ) { |
|
3198 // Can't hide these |
|
3199 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column ) |
|
3200 continue; |
|
3201 if ( empty($title) ) |
|
3202 continue; |
|
3203 |
|
3204 if ( 'comments' == $column ) |
|
3205 $title = __('Comments'); |
|
3206 $id = "$column-hide"; |
|
3207 echo '<label for="' . $id . '">'; |
|
3208 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />'; |
|
3209 echo "$title</label>\n"; |
|
3210 } |
|
3211 } |
|
3212 |
|
3213 /** |
|
3214 * {@internal Missing Short Description}} |
|
3215 * |
|
3216 * @since unknown |
|
3217 * |
1297 * |
3218 * @param unknown_type $found_action |
1298 * @param unknown_type $found_action |
3219 */ |
1299 */ |
3220 function find_posts_div($found_action = '') { |
1300 function find_posts_div($found_action = '') { |
3221 ?> |
1301 ?> |
3229 |
1309 |
3230 <input type="hidden" name="affected" id="affected" value="" /> |
1310 <input type="hidden" name="affected" id="affected" value="" /> |
3231 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
1311 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
3232 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
1312 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
3233 <input type="text" id="find-posts-input" name="ps" value="" /> |
1313 <input type="text" id="find-posts-input" name="ps" value="" /> |
3234 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
1314 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
3235 |
1315 |
3236 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> |
1316 <?php |
3237 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label> |
1317 $post_types = get_post_types( array('public' => true), 'objects' ); |
3238 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" /> |
1318 foreach ( $post_types as $post ) { |
3239 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label> |
1319 if ( 'attachment' == $post->name ) |
1320 continue; |
|
1321 ?> |
|
1322 <input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name, 'post'); ?> /> |
|
1323 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label> |
|
1324 <?php |
|
1325 } ?> |
|
3240 </div> |
1326 </div> |
3241 <div id="find-posts-response"></div> |
1327 <div id="find-posts-response"></div> |
3242 </div> |
1328 </div> |
3243 <div class="find-box-buttons"> |
1329 <div class="find-box-buttons"> |
3244 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> |
1330 <input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" /> |
3245 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" /> |
1331 <?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?> |
3246 </div> |
1332 </div> |
3247 </div> |
1333 </div> |
3248 <?php |
1334 <?php |
3249 } |
1335 } |
3250 |
1336 |
3261 global $post; |
1347 global $post; |
3262 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); |
1348 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); |
3263 } |
1349 } |
3264 |
1350 |
3265 /** |
1351 /** |
3266 * {@internal Missing Short Description}} |
|
3267 * |
|
3268 * @since unknown |
|
3269 */ |
|
3270 function favorite_actions( $screen = null ) { |
|
3271 switch ( $screen ) { |
|
3272 case 'post-new.php': |
|
3273 $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts')); |
|
3274 break; |
|
3275 case 'edit-pages.php': |
|
3276 $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages')); |
|
3277 break; |
|
3278 case 'page-new.php': |
|
3279 $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages')); |
|
3280 break; |
|
3281 case 'upload.php': |
|
3282 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files')); |
|
3283 break; |
|
3284 case 'media-new.php': |
|
3285 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files')); |
|
3286 break; |
|
3287 case 'link-manager.php': |
|
3288 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links')); |
|
3289 break; |
|
3290 case 'link-add.php': |
|
3291 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links')); |
|
3292 break; |
|
3293 case 'users.php': |
|
3294 $default_action = array('user-new.php' => array(__('New User'), 'create_users')); |
|
3295 break; |
|
3296 case 'user-new.php': |
|
3297 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users')); |
|
3298 break; |
|
3299 case 'plugins.php': |
|
3300 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins')); |
|
3301 break; |
|
3302 case 'plugin-install.php': |
|
3303 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins')); |
|
3304 break; |
|
3305 case 'themes.php': |
|
3306 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes')); |
|
3307 break; |
|
3308 case 'theme-install.php': |
|
3309 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes')); |
|
3310 break; |
|
3311 default: |
|
3312 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts')); |
|
3313 break; |
|
3314 } |
|
3315 |
|
3316 $actions = array( |
|
3317 'post-new.php' => array(__('New Post'), 'edit_posts'), |
|
3318 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'), |
|
3319 'page-new.php' => array(__('New Page'), 'edit_pages'), |
|
3320 'media-new.php' => array(__('Upload'), 'upload_files'), |
|
3321 'edit-comments.php' => array(__('Comments'), 'moderate_comments') |
|
3322 ); |
|
3323 |
|
3324 $default_key = array_keys($default_action); |
|
3325 $default_key = $default_key[0]; |
|
3326 if ( isset($actions[$default_key]) ) |
|
3327 unset($actions[$default_key]); |
|
3328 $actions = array_merge($default_action, $actions); |
|
3329 $actions = apply_filters('favorite_actions', $actions); |
|
3330 |
|
3331 $allowed_actions = array(); |
|
3332 foreach ( $actions as $action => $data ) { |
|
3333 if ( current_user_can($data[1]) ) |
|
3334 $allowed_actions[$action] = $data[0]; |
|
3335 } |
|
3336 |
|
3337 if ( empty($allowed_actions) ) |
|
3338 return; |
|
3339 |
|
3340 $first = array_keys($allowed_actions); |
|
3341 $first = $first[0]; |
|
3342 echo '<div id="favorite-actions">'; |
|
3343 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>'; |
|
3344 echo '<div id="favorite-inside">'; |
|
3345 |
|
3346 array_shift($allowed_actions); |
|
3347 |
|
3348 foreach ( $allowed_actions as $action => $label) { |
|
3349 echo "<div class='favorite-action'><a href='$action'>"; |
|
3350 echo $label; |
|
3351 echo "</a></div>\n"; |
|
3352 } |
|
3353 echo "</div></div>\n"; |
|
3354 } |
|
3355 |
|
3356 /** |
|
3357 * Get the post title. |
1352 * Get the post title. |
3358 * |
1353 * |
3359 * The post title is fetched and if it is blank then a default string is |
1354 * The post title is fetched and if it is blank then a default string is |
3360 * returned. |
1355 * returned. |
3361 * |
1356 * |
3362 * @since 2.7.0 |
1357 * @since 2.7.0 |
3363 * @param int $id The post id. If not supplied the global $post is used. |
1358 * @param int $post_id The post id. If not supplied the global $post is used. |
3364 * |
1359 * @return string The post title if set |
3365 */ |
1360 */ |
3366 function _draft_or_post_title($post_id = 0) |
1361 function _draft_or_post_title( $post_id = 0 ) { |
3367 { |
|
3368 $title = get_the_title($post_id); |
1362 $title = get_the_title($post_id); |
3369 if ( empty($title) ) |
1363 if ( empty($title) ) |
3370 $title = __('(no title)'); |
1364 $title = __('(no title)'); |
3371 return $title; |
1365 return $title; |
3372 } |
1366 } |
3380 * @uses attr |
1374 * @uses attr |
3381 * @since 2.7.0 |
1375 * @since 2.7.0 |
3382 * |
1376 * |
3383 */ |
1377 */ |
3384 function _admin_search_query() { |
1378 function _admin_search_query() { |
3385 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : ''; |
1379 echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : ''; |
3386 } |
1380 } |
3387 |
1381 |
3388 /** |
1382 /** |
3389 * Generic Iframe header for use with Thickbox |
1383 * Generic Iframe header for use with Thickbox |
3390 * |
1384 * |
3392 * @param string $title Title of the Iframe page. |
1386 * @param string $title Title of the Iframe page. |
3393 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). |
1387 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued). |
3394 * |
1388 * |
3395 */ |
1389 */ |
3396 function iframe_header( $title = '', $limit_styles = false ) { |
1390 function iframe_header( $title = '', $limit_styles = false ) { |
3397 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
1391 show_admin_bar( false ); |
3398 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
1392 global $hook_suffix, $current_user, $admin_body_class, $wp_locale; |
3399 <head> |
1393 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); |
3400 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
1394 |
1395 $current_screen = get_current_screen(); |
|
1396 |
|
1397 _wp_admin_html_begin(); |
|
1398 ?> |
|
3401 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> |
1399 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title> |
3402 <?php |
1400 <?php |
3403 wp_enqueue_style( 'global' ); |
|
3404 if ( ! $limit_styles ) |
|
3405 wp_enqueue_style( 'wp-admin' ); |
|
3406 wp_enqueue_style( 'colors' ); |
1401 wp_enqueue_style( 'colors' ); |
3407 ?> |
1402 ?> |
3408 <script type="text/javascript"> |
1403 <script type="text/javascript"> |
3409 //<![CDATA[ |
1404 //<![CDATA[ |
3410 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
1405 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
3411 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} |
1406 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();} |
1407 var userSettings = { |
|
1408 'url': '<?php echo SITECOOKIEPATH; ?>', |
|
1409 'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>', |
|
1410 'time':'<?php echo time() ?>' |
|
1411 }, |
|
1412 ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', |
|
1413 pagenow = '<?php echo $current_screen->id; ?>', |
|
1414 typenow = '<?php echo $current_screen->post_type; ?>', |
|
1415 adminpage = '<?php echo $admin_body_class; ?>', |
|
1416 thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>', |
|
1417 decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>', |
|
1418 isRtl = <?php echo (int) is_rtl(); ?>; |
|
3412 //]]> |
1419 //]]> |
3413 </script> |
1420 </script> |
3414 <?php |
1421 <?php |
1422 do_action('admin_enqueue_scripts', $hook_suffix); |
|
1423 do_action("admin_print_styles-$hook_suffix"); |
|
3415 do_action('admin_print_styles'); |
1424 do_action('admin_print_styles'); |
1425 do_action("admin_print_scripts-$hook_suffix"); |
|
3416 do_action('admin_print_scripts'); |
1426 do_action('admin_print_scripts'); |
1427 do_action("admin_head-$hook_suffix"); |
|
3417 do_action('admin_head'); |
1428 do_action('admin_head'); |
1429 |
|
1430 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); |
|
3418 ?> |
1431 ?> |
3419 </head> |
1432 </head> |
3420 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>> |
1433 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>"> |
1434 <script type="text/javascript"> |
|
1435 //<![CDATA[ |
|
1436 (function(){ |
|
1437 var c = document.body.className; |
|
1438 c = c.replace(/no-js/, 'js'); |
|
1439 document.body.className = c; |
|
1440 })(); |
|
1441 //]]> |
|
1442 </script> |
|
3421 <?php |
1443 <?php |
3422 } |
1444 } |
3423 |
1445 |
3424 /** |
1446 /** |
3425 * Generic Iframe footer for use with Thickbox |
1447 * Generic Iframe footer for use with Thickbox |
3440 <?php |
1462 <?php |
3441 } |
1463 } |
3442 |
1464 |
3443 function _post_states($post) { |
1465 function _post_states($post) { |
3444 $post_states = array(); |
1466 $post_states = array(); |
3445 if ( isset($_GET['post_status']) ) |
1467 if ( isset( $_REQUEST['post_status'] ) ) |
3446 $post_status = $_GET['post_status']; |
1468 $post_status = $_REQUEST['post_status']; |
3447 else |
1469 else |
3448 $post_status = ''; |
1470 $post_status = ''; |
3449 |
1471 |
3450 if ( !empty($post->post_password) ) |
1472 if ( !empty($post->post_password) ) |
3451 $post_states[] = __('Password protected'); |
1473 $post_states['protected'] = __('Password protected'); |
3452 if ( 'private' == $post->post_status && 'private' != $post_status ) |
1474 if ( 'private' == $post->post_status && 'private' != $post_status ) |
3453 $post_states[] = __('Private'); |
1475 $post_states['private'] = __('Private'); |
3454 if ( 'draft' == $post->post_status && 'draft' != $post_status ) |
1476 if ( 'draft' == $post->post_status && 'draft' != $post_status ) |
3455 $post_states[] = __('Draft'); |
1477 $post_states['draft'] = __('Draft'); |
3456 if ( 'pending' == $post->post_status && 'pending' != $post_status ) |
1478 if ( 'pending' == $post->post_status && 'pending' != $post_status ) |
3457 /* translators: post state */ |
1479 /* translators: post state */ |
3458 $post_states[] = _x('Pending', 'post state'); |
1480 $post_states['pending'] = _x('Pending', 'post state'); |
3459 if ( is_sticky($post->ID) ) |
1481 if ( is_sticky($post->ID) ) |
3460 $post_states[] = __('Sticky'); |
1482 $post_states['sticky'] = __('Sticky'); |
3461 |
1483 |
3462 $post_states = apply_filters( 'display_post_states', $post_states ); |
1484 $post_states = apply_filters( 'display_post_states', $post_states ); |
3463 |
1485 |
3464 if ( ! empty($post_states) ) { |
1486 if ( ! empty($post_states) ) { |
3465 $state_count = count($post_states); |
1487 $state_count = count($post_states); |
3469 ++$i; |
1491 ++$i; |
3470 ( $i == $state_count ) ? $sep = '' : $sep = ', '; |
1492 ( $i == $state_count ) ? $sep = '' : $sep = ', '; |
3471 echo "<span class='post-state'>$state$sep</span>"; |
1493 echo "<span class='post-state'>$state$sep</span>"; |
3472 } |
1494 } |
3473 } |
1495 } |
3474 } |
1496 |
3475 |
1497 if ( get_post_format( $post->ID ) ) |
3476 function screen_meta($screen) { |
1498 echo ' - <span class="post-state-format">' . get_post_format_string( get_post_format( $post->ID ) ) . '</span>'; |
3477 global $wp_meta_boxes, $_wp_contextual_help; |
1499 } |
3478 |
1500 |
3479 $screen = str_replace('.php', '', $screen); |
1501 function _media_states( $post ) { |
3480 $screen = str_replace('-new', '', $screen); |
1502 $media_states = array(); |
3481 $screen = str_replace('-add', '', $screen); |
1503 $stylesheet = get_option('stylesheet'); |
3482 $screen = apply_filters('screen_meta_screen', $screen); |
1504 |
3483 |
1505 if ( current_theme_supports( 'custom-header') ) { |
3484 $column_screens = get_column_headers($screen); |
1506 $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true ); |
3485 $meta_screens = array('index' => 'dashboard'); |
1507 if ( ! empty( $meta_header ) && $meta_header == $stylesheet ) |
3486 |
1508 $media_states[] = __( 'Header Image' ); |
3487 if ( isset($meta_screens[$screen]) ) |
1509 } |
3488 $screen = $meta_screens[$screen]; |
1510 |
3489 $show_screen = false; |
1511 if ( current_theme_supports( 'custom-background') ) { |
3490 $show_on_screen = false; |
1512 $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true ); |
3491 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) { |
1513 if ( ! empty( $meta_background ) && $meta_background == $stylesheet ) |
3492 $show_screen = true; |
1514 $media_states[] = __( 'Background Image' ); |
3493 $show_on_screen = true; |
1515 } |
3494 } |
1516 |
3495 |
1517 $media_states = apply_filters( 'display_media_states', $media_states ); |
3496 $screen_options = screen_options($screen); |
1518 |
3497 if ( $screen_options ) |
1519 if ( ! empty( $media_states ) ) { |
3498 $show_screen = true; |
1520 $state_count = count( $media_states ); |
3499 |
1521 $i = 0; |
3500 if ( !isset($_wp_contextual_help) ) |
1522 echo ' - '; |
3501 $_wp_contextual_help = array(); |
1523 foreach ( $media_states as $state ) { |
3502 |
1524 ++$i; |
3503 $settings = ''; |
1525 ( $i == $state_count ) ? $sep = '' : $sep = ', '; |
3504 |
1526 echo "<span class='post-state'>$state$sep</span>"; |
3505 switch ( $screen ) { |
1527 } |
3506 case 'post': |
1528 } |
3507 if ( !isset($_wp_contextual_help['post']) ) { |
|
3508 $help = drag_drop_help(); |
|
3509 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>'; |
|
3510 $_wp_contextual_help['post'] = $help; |
|
3511 } |
|
3512 break; |
|
3513 case 'page': |
|
3514 if ( !isset($_wp_contextual_help['page']) ) { |
|
3515 $help = drag_drop_help(); |
|
3516 $_wp_contextual_help['page'] = $help; |
|
3517 } |
|
3518 break; |
|
3519 case 'dashboard': |
|
3520 if ( !isset($_wp_contextual_help['dashboard']) ) { |
|
3521 $help = '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n"; |
|
3522 $help .= drag_drop_help(); |
|
3523 $_wp_contextual_help['dashboard'] = $help; |
|
3524 } |
|
3525 break; |
|
3526 case 'link': |
|
3527 if ( !isset($_wp_contextual_help['link']) ) { |
|
3528 $help = drag_drop_help(); |
|
3529 $_wp_contextual_help['link'] = $help; |
|
3530 } |
|
3531 break; |
|
3532 case 'options-general': |
|
3533 if ( !isset($_wp_contextual_help['options-general']) ) |
|
3534 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>'); |
|
3535 break; |
|
3536 case 'theme-install': |
|
3537 case 'plugin-install': |
|
3538 if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) { |
|
3539 $help = plugins_search_help(); |
|
3540 $_wp_contextual_help[$screen] = $help; |
|
3541 } |
|
3542 break; |
|
3543 case 'widgets': |
|
3544 if ( !isset($_wp_contextual_help['widgets']) ) { |
|
3545 $help = widgets_help(); |
|
3546 $_wp_contextual_help['widgets'] = $help; |
|
3547 } |
|
3548 $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; |
|
3549 $show_screen = true; |
|
3550 break; |
|
3551 } |
|
3552 ?> |
|
3553 <div id="screen-meta"> |
|
3554 <?php |
|
3555 if ( $show_screen ) : |
|
3556 ?> |
|
3557 <div id="screen-options-wrap" class="hidden"> |
|
3558 <form id="adv-settings" action="" method="post"> |
|
3559 <?php if ( $show_on_screen ) : ?> |
|
3560 <h5><?php _e('Show on screen') ?></h5> |
|
3561 <div class="metabox-prefs"> |
|
3562 <?php |
|
3563 if ( !meta_box_prefs($screen) && isset($column_screens) ) { |
|
3564 manage_columns_prefs($screen); |
|
3565 } |
|
3566 ?> |
|
3567 <br class="clear" /> |
|
3568 </div> |
|
3569 <?php endif; ?> |
|
3570 <?php echo screen_layout($screen); ?> |
|
3571 <?php echo $screen_options; ?> |
|
3572 <?php echo $settings; ?> |
|
3573 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> |
|
3574 </form> |
|
3575 </div> |
|
3576 |
|
3577 <?php |
|
3578 endif; |
|
3579 |
|
3580 global $title; |
|
3581 |
|
3582 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); |
|
3583 ?> |
|
3584 <div id="contextual-help-wrap" class="hidden"> |
|
3585 <?php |
|
3586 $contextual_help = ''; |
|
3587 if ( isset($_wp_contextual_help[$screen]) ) { |
|
3588 if ( !empty($title) ) |
|
3589 $contextual_help .= '<h5>' . sprintf(__('Get help with “%s”'), $title) . '</h5>'; |
|
3590 else |
|
3591 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>'; |
|
3592 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n"; |
|
3593 |
|
3594 $contextual_help .= '<h5>' . __('Other Help') . '</h5>'; |
|
3595 } else { |
|
3596 $contextual_help .= '<h5>' . __('Help') . '</h5>'; |
|
3597 } |
|
3598 |
|
3599 $contextual_help .= '<div class="metabox-prefs">'; |
|
3600 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>'); |
|
3601 $default_help .= '<br />'; |
|
3602 $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>'); |
|
3603 $contextual_help .= apply_filters('default_contextual_help', $default_help); |
|
3604 $contextual_help .= "</div>\n"; |
|
3605 echo apply_filters('contextual_help', $contextual_help, $screen); |
|
3606 ?> |
|
3607 </div> |
|
3608 |
|
3609 <div id="screen-meta-links"> |
|
3610 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
3611 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a> |
|
3612 </div> |
|
3613 <?php if ( $show_screen ) { ?> |
|
3614 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
3615 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a> |
|
3616 </div> |
|
3617 <?php } ?> |
|
3618 </div> |
|
3619 </div> |
|
3620 <?php |
|
3621 } |
|
3622 |
|
3623 /** |
|
3624 * Add contextual help text for a page |
|
3625 * |
|
3626 * @since 2.7.0 |
|
3627 * |
|
3628 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions. |
|
3629 * @param string $help Arbitrary help text |
|
3630 */ |
|
3631 function add_contextual_help($screen, $help) { |
|
3632 global $_wp_contextual_help; |
|
3633 |
|
3634 if ( !isset($_wp_contextual_help) ) |
|
3635 $_wp_contextual_help = array(); |
|
3636 |
|
3637 $_wp_contextual_help[$screen] = $help; |
|
3638 } |
|
3639 |
|
3640 function drag_drop_help() { |
|
3641 return ' |
|
3642 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p> |
|
3643 <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p> |
|
3644 '; |
|
3645 } |
|
3646 |
|
3647 function plugins_search_help() { |
|
3648 return ' |
|
3649 <p><strong>' . __('Search help') . '</strong></p>' . |
|
3650 '<p>' . __('You may search based on 3 criteria:') . '<br />' . |
|
3651 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' . |
|
3652 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' . |
|
3653 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p> |
|
3654 '; |
|
3655 } |
|
3656 |
|
3657 function widgets_help() { |
|
3658 return ' |
|
3659 <p>' . __('Widgets are added and arranged by simple drag ’n’ drop. If you hover your mouse over the titlebar of a widget, you’ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you’ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p> |
|
3660 <p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p> |
|
3661 <p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p> |
|
3662 <p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p> |
|
3663 '; |
|
3664 } |
|
3665 |
|
3666 function screen_layout($screen) { |
|
3667 global $screen_layout_columns; |
|
3668 |
|
3669 $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2); |
|
3670 $columns = apply_filters('screen_layout_columns', $columns, $screen); |
|
3671 |
|
3672 if ( !isset($columns[$screen]) ) { |
|
3673 $screen_layout_columns = 0; |
|
3674 return ''; |
|
3675 } |
|
3676 |
|
3677 $screen_layout_columns = get_user_option("screen_layout_$screen"); |
|
3678 $num = $columns[$screen]; |
|
3679 |
|
3680 if ( ! $screen_layout_columns ) |
|
3681 $screen_layout_columns = 2; |
|
3682 |
|
3683 $i = 1; |
|
3684 $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n"; |
|
3685 while ( $i <= $num ) { |
|
3686 $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n"; |
|
3687 ++$i; |
|
3688 } |
|
3689 $return .= "</div>\n"; |
|
3690 return $return; |
|
3691 } |
|
3692 |
|
3693 function screen_options($screen) { |
|
3694 switch ( $screen ) { |
|
3695 case 'edit': |
|
3696 $per_page_label = __('Posts per page:'); |
|
3697 break; |
|
3698 case 'edit-pages': |
|
3699 $per_page_label = __('Pages per page:'); |
|
3700 break; |
|
3701 case 'edit-comments': |
|
3702 $per_page_label = __('Comments per page:'); |
|
3703 break; |
|
3704 case 'upload': |
|
3705 $per_page_label = __('Media items per page:'); |
|
3706 break; |
|
3707 case 'categories': |
|
3708 $per_page_label = __('Categories per page:'); |
|
3709 break; |
|
3710 case 'edit-tags': |
|
3711 $per_page_label = __('Tags per page:'); |
|
3712 break; |
|
3713 case 'plugins': |
|
3714 $per_page_label = __('Plugins per page:'); |
|
3715 break; |
|
3716 default: |
|
3717 return ''; |
|
3718 } |
|
3719 |
|
3720 $option = str_replace( '-', '_', "${screen}_per_page" ); |
|
3721 $per_page = (int) get_user_option( $option, 0, false ); |
|
3722 if ( empty( $per_page ) || $per_page < 1 ) { |
|
3723 if ( 'plugins' == $screen ) |
|
3724 $per_page = 999; |
|
3725 else |
|
3726 $per_page = 20; |
|
3727 } |
|
3728 if ( 'edit_comments_per_page' == $option ) |
|
3729 $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' ); |
|
3730 elseif ( 'categories' == $option ) |
|
3731 $per_page = apply_filters( 'edit_categories_per_page', $per_page ); |
|
3732 else |
|
3733 $per_page = apply_filters( $option, $per_page ); |
|
3734 |
|
3735 $return = '<h5>' . __('Options') . "</h5>\n"; |
|
3736 $return .= "<div class='screen-options'>\n"; |
|
3737 if ( !empty($per_page_label) ) |
|
3738 $return .= "<label for='$option'>$per_page_label</label> <input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' />\n"; |
|
3739 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />"; |
|
3740 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />"; |
|
3741 $return .= "</div>\n"; |
|
3742 return $return; |
|
3743 } |
|
3744 |
|
3745 function screen_icon($name = '') { |
|
3746 global $parent_file, $hook_suffix; |
|
3747 |
|
3748 if ( empty($name) ) { |
|
3749 if ( isset($parent_file) && !empty($parent_file) ) |
|
3750 $name = substr($parent_file, 0, -4); |
|
3751 else |
|
3752 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix); |
|
3753 } |
|
3754 ?> |
|
3755 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div> |
|
3756 <?php |
|
3757 } |
1529 } |
3758 |
1530 |
3759 /** |
1531 /** |
3760 * Test support for compressing JavaScript from PHP |
1532 * Test support for compressing JavaScript from PHP |
3761 * |
1533 * |
3787 h = x.getResponseHeader('Content-Encoding'); |
1559 h = x.getResponseHeader('Content-Encoding'); |
3788 testCompression.check(r, h, test); |
1560 testCompression.check(r, h, test); |
3789 } |
1561 } |
3790 } |
1562 } |
3791 |
1563 |
3792 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true); |
1564 x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true); |
3793 x.send(''); |
1565 x.send(''); |
3794 } |
1566 } |
3795 }, |
1567 }, |
3796 |
1568 |
3797 check : function(r, h, test) { |
1569 check : function(r, h, test) { |
3819 /* ]]> */ |
1591 /* ]]> */ |
3820 </script> |
1592 </script> |
3821 <?php |
1593 <?php |
3822 } |
1594 } |
3823 |
1595 |
1596 /** |
|
1597 * Echos a submit button, with provided text and appropriate class |
|
1598 * |
|
1599 * @since 3.1.0 |
|
1600 * |
|
1601 * @param string $text The text of the button (defaults to 'Save Changes') |
|
1602 * @param string $type The type of button. One of: primary, secondary, delete |
|
1603 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute |
|
1604 * is given in $other_attributes below, $name will be used as the button's id. |
|
1605 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, |
|
1606 * false otherwise. Defaults to true |
|
1607 * @param array|string $other_attributes Other attributes that should be output with the button, |
|
1608 * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
|
1609 * These attributes will be output as attribute="value", such as tabindex="1". |
|
1610 * Defaults to no other attributes. Other attributes can also be provided as a |
|
1611 * string such as 'tabindex="1"', though the array format is typically cleaner. |
|
1612 */ |
|
1613 function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
|
1614 echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); |
|
1615 } |
|
1616 |
|
1617 /** |
|
1618 * Returns a submit button, with provided text and appropriate class |
|
1619 * |
|
1620 * @since 3.1.0 |
|
1621 * |
|
1622 * @param string $text The text of the button (defaults to 'Save Changes') |
|
1623 * @param string $type The type of button. One of: primary, secondary, delete |
|
1624 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute |
|
1625 * is given in $other_attributes below, $name will be used as the button's id. |
|
1626 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, |
|
1627 * false otherwise. Defaults to true |
|
1628 * @param array|string $other_attributes Other attributes that should be output with the button, |
|
1629 * mapping attributes to their values, such as array( 'tabindex' => '1' ). |
|
1630 * These attributes will be output as attribute="value", such as tabindex="1". |
|
1631 * Defaults to no other attributes. Other attributes can also be provided as a |
|
1632 * string such as 'tabindex="1"', though the array format is typically cleaner. |
|
1633 */ |
|
1634 function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
|
1635 switch ( $type ) : |
|
1636 case 'primary' : |
|
1637 case 'secondary' : |
|
1638 $class = 'button-' . $type; |
|
1639 break; |
|
1640 case 'delete' : |
|
1641 $class = 'button-secondary delete'; |
|
1642 break; |
|
1643 default : |
|
1644 $class = $type; // Custom cases can just pass in the classes they want to be used |
|
1645 endswitch; |
|
1646 $text = ( null == $text ) ? __( 'Save Changes' ) : $text; |
|
1647 |
|
1648 // Default the id attribute to $name unless an id was specifically provided in $other_attributes |
|
1649 $id = $name; |
|
1650 if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { |
|
1651 $id = $other_attributes['id']; |
|
1652 unset( $other_attributes['id'] ); |
|
1653 } |
|
1654 |
|
1655 $attributes = ''; |
|
1656 if ( is_array( $other_attributes ) ) { |
|
1657 foreach ( $other_attributes as $attribute => $value ) { |
|
1658 $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important |
|
1659 } |
|
1660 } else if ( !empty( $other_attributes ) ) { // Attributes provided as a string |
|
1661 $attributes = $other_attributes; |
|
1662 } |
|
1663 |
|
1664 $button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ); |
|
1665 $button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />'; |
|
1666 |
|
1667 if ( $wrap ) { |
|
1668 $button = '<p class="submit">' . $button . '</p>'; |
|
1669 } |
|
1670 |
|
1671 return $button; |
|
1672 } |
|
1673 |
|
1674 function _wp_admin_html_begin() { |
|
1675 $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : ''; |
|
3824 ?> |
1676 ?> |
1677 <!DOCTYPE html> |
|
1678 <!--[if IE 8]> |
|
1679 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|
1680 <![endif]--> |
|
1681 <!--[if !(IE 8) ]><!--> |
|
1682 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|
1683 <!--<![endif]--> |
|
1684 <head> |
|
1685 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|
1686 <?php |
|
1687 } |
|
1688 |
|
1689 final class WP_Internal_Pointers { |
|
1690 /** |
|
1691 * Initializes the new feature pointers. |
|
1692 * |
|
1693 * @since 3.3.0 |
|
1694 * |
|
1695 * All pointers can be disabled using the following: |
|
1696 * remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
1697 * |
|
1698 * Individual pointers (e.g. wp330_toolbar) can be disabled using the following: |
|
1699 * remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp330_toolbar' ) ); |
|
1700 */ |
|
1701 public static function enqueue_scripts( $hook_suffix ) { |
|
1702 /* |
|
1703 * Register feature pointers |
|
1704 * Format: array( hook_suffix => pointer_id ) |
|
1705 */ |
|
1706 |
|
1707 $registered_pointers = array( |
|
1708 'index.php' => 'wp330_toolbar', |
|
1709 'post-new.php' => 'wp330_media_uploader', |
|
1710 'post.php' => 'wp330_media_uploader', |
|
1711 'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ), |
|
1712 'appearance_page_custom-header' => 'wp340_choose_image_from_library', |
|
1713 'appearance_page_custom-background' => 'wp340_choose_image_from_library', |
|
1714 ); |
|
1715 |
|
1716 // Check if screen related pointer is registered |
|
1717 if ( empty( $registered_pointers[ $hook_suffix ] ) ) |
|
1718 return; |
|
1719 |
|
1720 $pointers = (array) $registered_pointers[ $hook_suffix ]; |
|
1721 |
|
1722 $caps_required = array( |
|
1723 'wp330_media_uploader' => array( 'upload_files' ), |
|
1724 'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ), |
|
1725 'wp340_customize_current_theme_link' => array( 'edit_theme_options' ), |
|
1726 'wp340_choose_image_from_library' => array( 'edit_theme_options' ), |
|
1727 ); |
|
1728 |
|
1729 // Get dismissed pointers |
|
1730 $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); |
|
1731 |
|
1732 $got_pointers = false; |
|
1733 foreach ( array_diff( $pointers, $dismissed ) as $pointer ) { |
|
1734 if ( isset( $caps_required[ $pointer ] ) ) { |
|
1735 foreach ( $caps_required[ $pointer ] as $cap ) { |
|
1736 if ( ! current_user_can( $cap ) ) |
|
1737 continue 2; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 // Bind pointer print function |
|
1742 add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); |
|
1743 $got_pointers = true; |
|
1744 } |
|
1745 |
|
1746 if ( ! $got_pointers ) |
|
1747 return; |
|
1748 |
|
1749 // Add pointers script and style to queue |
|
1750 wp_enqueue_style( 'wp-pointer' ); |
|
1751 wp_enqueue_script( 'wp-pointer' ); |
|
1752 } |
|
1753 |
|
1754 /** |
|
1755 * Print the pointer javascript data. |
|
1756 * |
|
1757 * @since 3.3.0 |
|
1758 * |
|
1759 * @param string $pointer_id The pointer ID. |
|
1760 * @param string $selector The HTML elements, on which the pointer should be attached. |
|
1761 * @param array $args Arguments to be passed to the pointer JS (see wp-pointer.dev.js). |
|
1762 */ |
|
1763 private static function print_js( $pointer_id, $selector, $args ) { |
|
1764 if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) |
|
1765 return; |
|
1766 |
|
1767 ?> |
|
1768 <script type="text/javascript"> |
|
1769 //<![CDATA[ |
|
1770 (function($){ |
|
1771 var options = <?php echo json_encode( $args ); ?>, setup; |
|
1772 |
|
1773 if ( ! options ) |
|
1774 return; |
|
1775 |
|
1776 options = $.extend( options, { |
|
1777 close: function() { |
|
1778 $.post( ajaxurl, { |
|
1779 pointer: '<?php echo $pointer_id; ?>', |
|
1780 action: 'dismiss-wp-pointer' |
|
1781 }); |
|
1782 } |
|
1783 }); |
|
1784 |
|
1785 setup = function() { |
|
1786 $('<?php echo $selector; ?>').pointer( options ).pointer('open'); |
|
1787 }; |
|
1788 |
|
1789 if ( options.position && options.position.defer_loading ) |
|
1790 $(window).bind( 'load.wp-pointers', setup ); |
|
1791 else |
|
1792 $(document).ready( setup ); |
|
1793 |
|
1794 })( jQuery ); |
|
1795 //]]> |
|
1796 </script> |
|
1797 <?php |
|
1798 } |
|
1799 |
|
1800 public static function pointer_wp330_toolbar() { |
|
1801 $content = '<h3>' . __( 'New Feature: Toolbar' ) . '</h3>'; |
|
1802 $content .= '<p>' . __( 'We’ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what’s new.' ) . '</p>'; |
|
1803 |
|
1804 if ( is_multisite() && is_super_admin() ) |
|
1805 $content .= '<p>' . __( 'Network Admin is now located in the My Sites menu.' ) . '</p>'; |
|
1806 |
|
1807 WP_Internal_Pointers::print_js( 'wp330_toolbar', '#wpadminbar', array( |
|
1808 'content' => $content, |
|
1809 'position' => array( 'edge' => 'top', 'align' => 'center' ), |
|
1810 ) ); |
|
1811 } |
|
1812 |
|
1813 /** |
|
1814 * Print 'Updated Media Uploader' for 3.3.0. |
|
1815 * |
|
1816 * @since 3.3.0 |
|
1817 */ |
|
1818 public static function pointer_wp330_media_uploader() { |
|
1819 $content = '<h3>' . __( 'Updated Media Uploader' ) . '</h3>'; |
|
1820 $content .= '<p>' . __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) . '</p>'; |
|
1821 |
|
1822 WP_Internal_Pointers::print_js( 'wp330_media_uploader', '#content-add_media', array( |
|
1823 'content' => $content, |
|
1824 'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ), |
|
1825 ) ); |
|
1826 } |
|
1827 |
|
1828 /** |
|
1829 * Print 'New Feature: Saving Widgets' for 3.3.0. |
|
1830 * |
|
1831 * @since 3.3.0 |
|
1832 */ |
|
1833 public static function pointer_wp330_saving_widgets() { |
|
1834 $content = '<h3>' . __( 'New Feature: Saving Widgets' ) . '</h3>'; |
|
1835 $content .= '<p>' . __( 'If you change your mind and revert to your previous theme, we’ll put the widgets back the way you had them.' ) . '</p>'; |
|
1836 |
|
1837 WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array( |
|
1838 'content' => $content, |
|
1839 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ), |
|
1840 ) ); |
|
1841 } |
|
1842 |
|
1843 /** |
|
1844 * Print 'New Feature: Current Theme Customize Link' for 3.4.0. |
|
1845 * |
|
1846 * @since 3.4.0 |
|
1847 */ |
|
1848 public static function pointer_wp340_customize_current_theme_link() { |
|
1849 $content = '<h3>' . __( 'New Feature: Customizer' ) . '</h3>'; |
|
1850 $content .= '<p>' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '</p>'; |
|
1851 $content .= '<p>' . __( 'Click the Live Preview links in the Available Themes list below to customize and preview another theme before activating it.' ) . '</p>'; |
|
1852 |
|
1853 WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array( |
|
1854 'content' => $content, |
|
1855 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'offset' => is_rtl() ? '32 0' : '-32 0' ), |
|
1856 ) ); |
|
1857 } |
|
1858 |
|
1859 /** |
|
1860 * Print 'New Feature: Choose Image from Library' for 3.4.0. |
|
1861 * |
|
1862 * @since 3.4.0 |
|
1863 */ |
|
1864 public static function pointer_wp340_choose_image_from_library() { |
|
1865 $content = '<h3>' . __( 'New Feature: Choose Image from Library' ) . '</h3>'; |
|
1866 $content .= '<p>' . __( 'Want to use an image you uploaded earlier? Select it from your media library instead of uploading it again.' ) . '</p>'; |
|
1867 |
|
1868 WP_Internal_Pointers::print_js( 'wp340_choose_image_from_library', '#choose-from-library-link', array( |
|
1869 'content' => $content, |
|
1870 'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ), |
|
1871 ) ); |
|
1872 } |
|
1873 |
|
1874 /** |
|
1875 * Prevents new users from seeing existing 'new feature' pointers. |
|
1876 * |
|
1877 * @since 3.3.0 |
|
1878 */ |
|
1879 public static function dismiss_pointers_for_new_users( $user_id ) { |
|
1880 add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_media_uploader,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link' ); |
|
1881 } |
|
1882 } |
|
1883 |
|
1884 add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
1885 add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
|
1886 |
|
1887 /** |
|
1888 * Convert a screen string to a screen object |
|
1889 * |
|
1890 * @since 3.0.0 |
|
1891 * |
|
1892 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen. |
|
1893 * @return WP_Screen Screen object. |
|
1894 */ |
|
1895 function convert_to_screen( $hook_name ) { |
|
1896 if ( ! class_exists( 'WP_Screen' ) ) { |
|
1897 _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' ); |
|
1898 return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' ); |
|
1899 } |
|
1900 |
|
1901 return WP_Screen::get( $hook_name ); |
|
1902 } |