400 * |
402 * |
401 * @since 2.7.0 |
403 * @since 2.7.0 |
402 * |
404 * |
403 * @global WP_List_Table $wp_list_table |
405 * @global WP_List_Table $wp_list_table |
404 * |
406 * |
405 * @param int $position |
407 * @param int $position Optional. The value of the 'position' input field. Default 1. |
406 * @param bool $checkbox |
408 * @param bool $checkbox Optional. The value of the 'checkbox' input field. Default false. |
407 * @param string $mode |
409 * @param string $mode Optional. If set to 'single', will use WP_Post_Comments_List_Table, |
408 * @param bool $table_row |
410 * otherwise WP_Comments_List_Table. Default 'single'. |
|
411 * @param bool $table_row Optional. Whether to use a table instead of a div element. Default true. |
409 */ |
412 */ |
410 function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { |
413 function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { |
411 global $wp_list_table; |
414 global $wp_list_table; |
412 /** |
415 /** |
413 * Filters the in-line comment reply-to form output in the Comments |
416 * Filters the in-line comment reply-to form output in the Comments |
456 <?php endif; ?> |
459 <?php endif; ?> |
457 <fieldset class="comment-reply"> |
460 <fieldset class="comment-reply"> |
458 <legend> |
461 <legend> |
459 <span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span> |
462 <span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span> |
460 <span class="hidden" id="replyhead"><?php _e( 'Reply to Comment' ); ?></span> |
463 <span class="hidden" id="replyhead"><?php _e( 'Reply to Comment' ); ?></span> |
461 <span class="hidden" id="addhead"><?php _e( 'Add new Comment' ); ?></span> |
464 <span class="hidden" id="addhead"><?php _e( 'Add New Comment' ); ?></span> |
462 </legend> |
465 </legend> |
463 |
466 |
464 <div id="replycontainer"> |
467 <div id="replycontainer"> |
465 <label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label> |
468 <label for="replycontent" class="screen-reader-text"> |
|
469 <?php |
|
470 /* translators: Hidden accessibility text. */ |
|
471 _e( 'Comment' ); |
|
472 ?> |
|
473 </label> |
466 <?php |
474 <?php |
467 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); |
475 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); |
468 wp_editor( |
476 wp_editor( |
469 '', |
477 '', |
470 'replycontent', |
478 'replycontent', |
643 $entry['meta_id'] = (int) $entry['meta_id']; |
658 $entry['meta_id'] = (int) $entry['meta_id']; |
644 |
659 |
645 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
660 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); |
646 |
661 |
647 $r .= "\n\t<tr id='meta-{$entry['meta_id']}'>"; |
662 $r .= "\n\t<tr id='meta-{$entry['meta_id']}'>"; |
648 $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' type='text' size='20' value='{$entry['meta_key']}' />"; |
663 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta-{$entry['meta_id']}-key'>" . |
|
664 /* translators: Hidden accessibility text. */ |
|
665 __( 'Key' ) . |
|
666 "</label><input name='meta[{$entry['meta_id']}][key]' id='meta-{$entry['meta_id']}-key' type='text' size='20' value='{$entry['meta_key']}' />"; |
649 |
667 |
650 $r .= "\n\t\t<div class='submit'>"; |
668 $r .= "\n\t\t<div class='submit'>"; |
651 $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); |
669 $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); |
652 $r .= "\n\t\t"; |
670 $r .= "\n\t\t"; |
653 $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); |
671 $r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) ); |
654 $r .= '</div>'; |
672 $r .= '</div>'; |
655 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
673 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); |
656 $r .= '</td>'; |
674 $r .= '</td>'; |
657 |
675 |
658 $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' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
676 $r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . |
|
677 /* translators: Hidden accessibility text. */ |
|
678 __( 'Value' ) . |
|
679 "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>"; |
659 return $r; |
680 return $r; |
660 } |
681 } |
661 |
682 |
662 /** |
683 /** |
663 * Prints the form in the Custom Fields meta box. |
684 * Prints the form in the Custom Fields meta box. |
739 } |
757 } |
740 echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>'; |
758 echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>'; |
741 } |
759 } |
742 ?> |
760 ?> |
743 </select> |
761 </select> |
744 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" /> |
762 <input class="hidden" type="text" id="metakeyinput" name="metakeyinput" value="" aria-label="<?php _e( 'New custom field name' ); ?>" /> |
745 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> |
763 <button type="button" id="newmeta-button" class="button button-small hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggleClass('hidden');jQuery('#metakeyinput, #metakeyselect').filter(':visible').trigger('focus');"> |
746 <span id="enternew"><?php _e( 'Enter new' ); ?></span> |
764 <span id="enternew"><?php _e( 'Enter new' ); ?></span> |
747 <span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></a> |
765 <span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></button> |
748 <?php } else { ?> |
766 <?php } else { ?> |
749 <input type="text" id="metakeyinput" name="metakeyinput" value="" /> |
767 <input type="text" id="metakeyinput" name="metakeyinput" value="" /> |
750 <?php } ?> |
768 <?php } ?> |
751 </td> |
769 </td> |
752 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td> |
770 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea> |
|
771 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> |
|
772 </td> |
753 </tr> |
773 </tr> |
754 |
774 </tbody> |
755 <tr><td colspan="2"> |
775 </table> |
756 <div class="submit"> |
776 <div class="submit add-custom-field"> |
757 <?php |
777 <?php |
758 submit_button( |
778 submit_button( |
759 __( 'Add Custom Field' ), |
779 __( 'Add Custom Field' ), |
760 '', |
780 '', |
761 'addmeta', |
781 'addmeta', |
817 $cur_mm = current_time( 'm' ); |
832 $cur_mm = current_time( 'm' ); |
818 $cur_aa = current_time( 'Y' ); |
833 $cur_aa = current_time( 'Y' ); |
819 $cur_hh = current_time( 'H' ); |
834 $cur_hh = current_time( 'H' ); |
820 $cur_mn = current_time( 'i' ); |
835 $cur_mn = current_time( 'i' ); |
821 |
836 |
822 $month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select class="form-required" ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n"; |
837 $month = '<label><span class="screen-reader-text">' . |
|
838 /* translators: Hidden accessibility text. */ |
|
839 __( 'Month' ) . |
|
840 '</span><select class="form-required" ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n"; |
823 for ( $i = 1; $i < 13; $i = $i + 1 ) { |
841 for ( $i = 1; $i < 13; $i = $i + 1 ) { |
824 $monthnum = zeroise( $i, 2 ); |
842 $monthnum = zeroise( $i, 2 ); |
825 $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); |
843 $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); |
826 $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>'; |
844 $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum, $mm, false ) . '>'; |
827 /* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */ |
845 /* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */ |
828 $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n"; |
846 $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $monthtext ) . "</option>\n"; |
829 } |
847 } |
830 $month .= '</select></label>'; |
848 $month .= '</select></label>'; |
831 |
849 |
832 $day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
850 $day = '<label><span class="screen-reader-text">' . |
833 $year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
851 /* translators: Hidden accessibility text. */ |
834 $hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
852 __( 'Day' ) . |
835 $minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
853 '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
|
854 $year = '<label><span class="screen-reader-text">' . |
|
855 /* translators: Hidden accessibility text. */ |
|
856 __( 'Year' ) . |
|
857 '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
|
858 $hour = '<label><span class="screen-reader-text">' . |
|
859 /* translators: Hidden accessibility text. */ |
|
860 __( 'Hour' ) . |
|
861 '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
|
862 $minute = '<label><span class="screen-reader-text">' . |
|
863 /* translators: Hidden accessibility text. */ |
|
864 __( 'Minute' ) . |
|
865 '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" class="form-required" /></label>'; |
836 |
866 |
837 echo '<div class="timestamp-wrap">'; |
867 echo '<div class="timestamp-wrap">'; |
838 /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ |
868 /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ |
839 printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); |
869 printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); |
840 |
870 |
897 * @since 4.4.0 `$post` argument was added. |
927 * @since 4.4.0 `$post` argument was added. |
898 * |
928 * |
899 * @global wpdb $wpdb WordPress database abstraction object. |
929 * @global wpdb $wpdb WordPress database abstraction object. |
900 * |
930 * |
901 * @param int $default_page Optional. The default page ID to be pre-selected. Default 0. |
931 * @param int $default_page Optional. The default page ID to be pre-selected. Default 0. |
902 * @param int $parent Optional. The parent page ID. Default 0. |
932 * @param int $parent_page Optional. The parent page ID. Default 0. |
903 * @param int $level Optional. Page depth level. Default 0. |
933 * @param int $level Optional. Page depth level. Default 0. |
904 * @param int|WP_Post $post Post ID or WP_Post object. |
934 * @param int|WP_Post $post Post ID or WP_Post object. |
905 * @return void|false Void on success, false if the page has no children. |
935 * @return void|false Void on success, false if the page has no children. |
906 */ |
936 */ |
907 function parent_dropdown( $default_page = 0, $parent = 0, $level = 0, $post = null ) { |
937 function parent_dropdown( $default_page = 0, $parent_page = 0, $level = 0, $post = null ) { |
908 global $wpdb; |
938 global $wpdb; |
909 |
939 |
910 $post = get_post( $post ); |
940 $post = get_post( $post ); |
911 $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) ); |
941 $items = $wpdb->get_results( |
|
942 $wpdb->prepare( |
|
943 "SELECT ID, post_parent, post_title |
|
944 FROM $wpdb->posts |
|
945 WHERE post_parent = %d AND post_type = 'page' |
|
946 ORDER BY menu_order", |
|
947 $parent_page |
|
948 ) |
|
949 ); |
912 |
950 |
913 if ( $items ) { |
951 if ( $items ) { |
914 foreach ( $items as $item ) { |
952 foreach ( $items as $item ) { |
915 // A page cannot be its own parent. |
953 // A page cannot be its own parent. |
916 if ( $post && $post->ID && (int) $item->ID === $post->ID ) { |
954 if ( $post && $post->ID && (int) $item->ID === $post->ID ) { |
973 */ |
1011 */ |
974 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
1012 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); |
975 $size = size_format( $bytes ); |
1013 $size = size_format( $bytes ); |
976 $upload_dir = wp_upload_dir(); |
1014 $upload_dir = wp_upload_dir(); |
977 if ( ! empty( $upload_dir['error'] ) ) : |
1015 if ( ! empty( $upload_dir['error'] ) ) : |
978 ?> |
1016 $upload_directory_error = '<p>' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '</p>'; |
979 <div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p> |
1017 $upload_directory_error .= '<p><strong>' . $upload_dir['error'] . '</strong></p>'; |
980 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div> |
1018 wp_admin_notice( |
981 <?php |
1019 $upload_directory_error, |
|
1020 array( |
|
1021 'additional_classes' => array( 'error' ), |
|
1022 'paragraph_wrap' => false, |
|
1023 ) |
|
1024 ); |
982 else : |
1025 else : |
983 ?> |
1026 ?> |
984 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> |
1027 <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> |
985 <p> |
1028 <p> |
986 <?php |
1029 <?php |
1220 |
1263 |
1221 // Only show errors if the meta box was registered by a plugin. |
1264 // Only show errors if the meta box was registered by a plugin. |
1222 $filename = wp_normalize_path( $reflection->getFileName() ); |
1265 $filename = wp_normalize_path( $reflection->getFileName() ); |
1223 $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); |
1266 $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); |
1224 |
1267 |
1225 if ( strpos( $filename, $plugin_dir ) === 0 ) { |
1268 if ( str_starts_with( $filename, $plugin_dir ) ) { |
1226 $filename = str_replace( $plugin_dir, '', $filename ); |
1269 $filename = str_replace( $plugin_dir, '', $filename ); |
1227 $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename ); |
1270 $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename ); |
1228 |
1271 |
1229 $plugins = get_plugins(); |
1272 $plugins = get_plugins(); |
1230 |
1273 |
1231 foreach ( $plugins as $name => $plugin ) { |
1274 foreach ( $plugins as $name => $plugin ) { |
1232 if ( strpos( $name, $filename ) === 0 ) { |
1275 if ( str_starts_with( $name, $filename ) ) { |
1233 return $plugin; |
1276 return $plugin; |
1234 } |
1277 } |
1235 } |
1278 } |
1236 } |
1279 } |
1237 } |
1280 } |
1320 $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box']; |
1365 $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box']; |
1321 unset( $box['args']['__back_compat_meta_box'] ); |
1366 unset( $box['args']['__back_compat_meta_box'] ); |
1322 } |
1367 } |
1323 } |
1368 } |
1324 |
1369 |
1325 $i++; |
1370 ++$i; |
1326 // get_hidden_meta_boxes() doesn't apply in the block editor. |
1371 // get_hidden_meta_boxes() doesn't apply in the block editor. |
1327 $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; |
1372 $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; |
1328 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n"; |
1373 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n"; |
1329 |
1374 |
1330 echo '<div class="postbox-header">'; |
1375 echo '<div class="postbox-header">'; |
1331 echo '<h2 class="hndle">'; |
1376 echo '<h2 class="hndle">'; |
1332 if ( 'dashboard_php_nag' === $box['id'] ) { |
1377 if ( 'dashboard_php_nag' === $box['id'] ) { |
1333 echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>'; |
1378 echo '<span aria-hidden="true" class="dashicons dashicons-warning"></span>'; |
1334 echo '<span class="screen-reader-text">' . __( 'Warning:' ) . ' </span>'; |
1379 echo '<span class="screen-reader-text">' . |
|
1380 /* translators: Hidden accessibility text. */ |
|
1381 __( 'Warning:' ) . |
|
1382 ' </span>'; |
1335 } |
1383 } |
1336 echo $box['title']; |
1384 echo $box['title']; |
1337 echo "</h2>\n"; |
1385 echo "</h2>\n"; |
1338 |
1386 |
1339 if ( 'dashboard_browser_nag' !== $box['id'] ) { |
1387 if ( 'dashboard_browser_nag' !== $box['id'] ) { |
1346 } |
1394 } |
1347 |
1395 |
1348 echo '<div class="handle-actions hide-if-no-js">'; |
1396 echo '<div class="handle-actions hide-if-no-js">'; |
1349 |
1397 |
1350 echo '<button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-higher-description">'; |
1398 echo '<button type="button" class="handle-order-higher" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-higher-description">'; |
1351 echo '<span class="screen-reader-text">' . __( 'Move up' ) . '</span>'; |
1399 echo '<span class="screen-reader-text">' . |
|
1400 /* translators: Hidden accessibility text. */ |
|
1401 __( 'Move up' ) . |
|
1402 '</span>'; |
1352 echo '<span class="order-higher-indicator" aria-hidden="true"></span>'; |
1403 echo '<span class="order-higher-indicator" aria-hidden="true"></span>'; |
1353 echo '</button>'; |
1404 echo '</button>'; |
1354 echo '<span class="hidden" id="' . $box['id'] . '-handle-order-higher-description">' . sprintf( |
1405 echo '<span class="hidden" id="' . $box['id'] . '-handle-order-higher-description">' . sprintf( |
1355 /* translators: %s: Meta box title. */ |
1406 /* translators: %s: Meta box title. */ |
1356 __( 'Move %s box up' ), |
1407 __( 'Move %s box up' ), |
1357 $widget_title |
1408 $widget_title |
1358 ) . '</span>'; |
1409 ) . '</span>'; |
1359 |
1410 |
1360 echo '<button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-lower-description">'; |
1411 echo '<button type="button" class="handle-order-lower" aria-disabled="false" aria-describedby="' . $box['id'] . '-handle-order-lower-description">'; |
1361 echo '<span class="screen-reader-text">' . __( 'Move down' ) . '</span>'; |
1412 echo '<span class="screen-reader-text">' . |
|
1413 /* translators: Hidden accessibility text. */ |
|
1414 __( 'Move down' ) . |
|
1415 '</span>'; |
1362 echo '<span class="order-lower-indicator" aria-hidden="true"></span>'; |
1416 echo '<span class="order-lower-indicator" aria-hidden="true"></span>'; |
1363 echo '</button>'; |
1417 echo '</button>'; |
1364 echo '<span class="hidden" id="' . $box['id'] . '-handle-order-lower-description">' . sprintf( |
1418 echo '<span class="hidden" id="' . $box['id'] . '-handle-order-lower-description">' . sprintf( |
1365 /* translators: %s: Meta box title. */ |
1419 /* translators: %s: Meta box title. */ |
1366 __( 'Move %s box down' ), |
1420 __( 'Move %s box down' ), |
1367 $widget_title |
1421 $widget_title |
1368 ) . '</span>'; |
1422 ) . '</span>'; |
1369 |
1423 |
1370 echo '<button type="button" class="handlediv" aria-expanded="true">'; |
1424 echo '<button type="button" class="handlediv" aria-expanded="true">'; |
1371 echo '<span class="screen-reader-text">' . sprintf( |
1425 echo '<span class="screen-reader-text">' . sprintf( |
1372 /* translators: %s: Meta box title. */ |
1426 /* translators: %s: Hidden accessibility text. Meta box title. */ |
1373 __( 'Toggle panel: %s' ), |
1427 __( 'Toggle panel: %s' ), |
1374 $widget_title |
1428 $widget_title |
1375 ) . '</span>'; |
1429 ) . '</span>'; |
1376 echo '<span class="toggle-indicator" aria-hidden="true"></span>'; |
1430 echo '<span class="toggle-indicator" aria-hidden="true"></span>'; |
1377 echo '</button>'; |
1431 echo '</button>'; |
1383 echo '<div class="inside">' . "\n"; |
1437 echo '<div class="inside">' . "\n"; |
1384 |
1438 |
1385 if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) { |
1439 if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) { |
1386 $plugin = _get_plugin_from_callback( $box['callback'] ); |
1440 $plugin = _get_plugin_from_callback( $box['callback'] ); |
1387 if ( $plugin ) { |
1441 if ( $plugin ) { |
1388 ?> |
1442 $meta_box_not_compatible_message = sprintf( |
1389 <div class="error inline"> |
1443 /* translators: %s: The name of the plugin that generated this meta box. */ |
1390 <p> |
1444 __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), |
1391 <?php |
1445 "<strong>{$plugin['Name']}</strong>" |
1392 /* translators: %s: The name of the plugin that generated this meta box. */ |
1446 ); |
1393 printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" ); |
1447 wp_admin_notice( |
1394 ?> |
1448 $meta_box_not_compatible_message, |
1395 </p> |
1449 array( |
1396 </div> |
1450 'additional_classes' => array( 'error', 'inline' ), |
1397 <?php |
1451 ) |
|
1452 ); |
1398 } |
1453 } |
1399 } |
1454 } |
1400 |
1455 |
1401 call_user_func( $box['callback'], $data_object, $box ); |
1456 call_user_func( $box['callback'], $data_object, $box ); |
1402 echo "</div>\n"; |
1457 echo "</div>\n"; |
1519 } |
1573 } |
1520 ?> |
1574 ?> |
1521 <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>"> |
1575 <li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>"> |
1522 <h3 class="accordion-section-title hndle" tabindex="0"> |
1576 <h3 class="accordion-section-title hndle" tabindex="0"> |
1523 <?php echo esc_html( $box['title'] ); ?> |
1577 <?php echo esc_html( $box['title'] ); ?> |
1524 <span class="screen-reader-text"><?php _e( 'Press return or enter to open this section' ); ?></span> |
1578 <span class="screen-reader-text"> |
|
1579 <?php |
|
1580 /* translators: Hidden accessibility text. */ |
|
1581 _e( 'Press return or enter to open this section' ); |
|
1582 ?> |
|
1583 </span> |
1525 </h3> |
1584 </h3> |
1526 <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>"> |
1585 <div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>"> |
1527 <div class="inside"> |
1586 <div class="inside"> |
1528 <?php call_user_func( $box['callback'], $data_object, $box ); ?> |
1587 <?php call_user_func( $box['callback'], $data_object, $box ); ?> |
1529 </div><!-- .inside --> |
1588 </div><!-- .inside --> |
1551 * The $callback argument should be the name of a function that echoes out any |
1610 * The $callback argument should be the name of a function that echoes out any |
1552 * content you want to show at the top of the settings section before the actual |
1611 * content you want to show at the top of the settings section before the actual |
1553 * fields. It can output nothing if you want. |
1612 * fields. It can output nothing if you want. |
1554 * |
1613 * |
1555 * @since 2.7.0 |
1614 * @since 2.7.0 |
|
1615 * @since 6.1.0 Added an `$args` parameter for the section's HTML wrapper and class name. |
1556 * |
1616 * |
1557 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. |
1617 * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. |
1558 * |
1618 * |
1559 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags. |
1619 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags. |
1560 * @param string $title Formatted title of the section. Shown as the heading for the section. |
1620 * @param string $title Formatted title of the section. Shown as the heading for the section. |
1561 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields). |
1621 * @param callable $callback Function that echos out any content at the top of the section (between heading and fields). |
1562 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include |
1622 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include |
1563 * 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using |
1623 * 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using |
1564 * add_options_page(); |
1624 * add_options_page(); |
1565 */ |
1625 * @param array $args { |
1566 function add_settings_section( $id, $title, $callback, $page ) { |
1626 * Arguments used to create the settings section. |
|
1627 * |
|
1628 * @type string $before_section HTML content to prepend to the section's HTML output. |
|
1629 * Receives the section's class name as `%s`. Default empty. |
|
1630 * @type string $after_section HTML content to append to the section's HTML output. Default empty. |
|
1631 * @type string $section_class The class name to use for the section. Default empty. |
|
1632 * } |
|
1633 */ |
|
1634 function add_settings_section( $id, $title, $callback, $page, $args = array() ) { |
1567 global $wp_settings_sections; |
1635 global $wp_settings_sections; |
|
1636 |
|
1637 $defaults = array( |
|
1638 'id' => $id, |
|
1639 'title' => $title, |
|
1640 'callback' => $callback, |
|
1641 'before_section' => '', |
|
1642 'after_section' => '', |
|
1643 'section_class' => '', |
|
1644 ); |
|
1645 |
|
1646 $section = wp_parse_args( $args, $defaults ); |
1568 |
1647 |
1569 if ( 'misc' === $page ) { |
1648 if ( 'misc' === $page ) { |
1570 _deprecated_argument( |
1649 _deprecated_argument( |
1571 __FUNCTION__, |
1650 __FUNCTION__, |
1572 '3.0.0', |
1651 '3.0.0', |
1623 * @param string $page The slug-name of the settings page on which to show the section |
1698 * @param string $page The slug-name of the settings page on which to show the section |
1624 * (general, reading, writing, ...). |
1699 * (general, reading, writing, ...). |
1625 * @param string $section Optional. The slug-name of the section of the settings page |
1700 * @param string $section Optional. The slug-name of the section of the settings page |
1626 * in which to show the box. Default 'default'. |
1701 * in which to show the box. Default 'default'. |
1627 * @param array $args { |
1702 * @param array $args { |
1628 * Optional. Extra arguments used when outputting the field. |
1703 * Optional. Extra arguments that get passed to the callback function. |
1629 * |
1704 * |
1630 * @type string $label_for When supplied, the setting title will be wrapped |
1705 * @type string $label_for When supplied, the setting title will be wrapped |
1631 * in a `<label>` element, its `for` attribute populated |
1706 * in a `<label>` element, its `for` attribute populated |
1632 * with this value. |
1707 * with this value. |
1633 * @type string $class CSS Class to be added to the `<tr>` element when the |
1708 * @type string $class CSS Class to be added to the `<tr>` element when the |
1803 * hasn't submitted data (i.e. when they first load an options page, or in the {@see 'admin_notices'} |
1890 * hasn't submitted data (i.e. when they first load an options page, or in the {@see 'admin_notices'} |
1804 * action hook). |
1891 * action hook). |
1805 * |
1892 * |
1806 * @since 3.0.0 |
1893 * @since 3.0.0 |
1807 * |
1894 * |
1808 * @global array $wp_settings_errors Storage array of errors registered during this pageload |
1895 * @global array[] $wp_settings_errors Storage array of errors registered during this pageload |
1809 * |
1896 * |
1810 * @param string $setting Optional. Slug title of a specific setting whose errors you want. |
1897 * @param string $setting Optional. Slug title of a specific setting whose errors you want. |
1811 * @param bool $sanitize Optional. Whether to re-sanitize the setting value before returning errors. |
1898 * @param bool $sanitize Optional. Whether to re-sanitize the setting value before returning errors. |
1812 * @return array { |
1899 * @return array[] { |
1813 * Array of settings errors. |
1900 * Array of settings error arrays. |
1814 * |
1901 * |
1815 * @type string $setting Slug title of the setting to which this error applies. |
1902 * @type array ...$0 { |
1816 * @type string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. |
1903 * Associative array of setting error data. |
1817 * @type string $message The formatted message text to display to the user (will be shown inside styled |
1904 * |
1818 * `<div>` and `<p>` tags). |
1905 * @type string $setting Slug title of the setting to which this error applies. |
1819 * @type string $type Optional. Message type, controls HTML class. Possible values include 'error', |
1906 * @type string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output. |
1820 * 'success', 'warning', 'info'. Default 'error'. |
1907 * @type string $message The formatted message text to display to the user (will be shown inside styled |
|
1908 * `<div>` and `<p>` tags). |
|
1909 * @type string $type Optional. Message type, controls HTML class. Possible values include 'error', |
|
1910 * 'success', 'warning', 'info'. Default 'error'. |
|
1911 * } |
1821 * } |
1912 * } |
1822 */ |
1913 */ |
1823 function get_settings_errors( $setting = '', $sanitize = false ) { |
1914 function get_settings_errors( $setting = '', $sanitize = false ) { |
1824 global $wp_settings_errors; |
1915 global $wp_settings_errors; |
1825 |
1916 |
1931 /** |
2022 /** |
1932 * Outputs the modal window used for attaching media to posts or pages in the media-listing screen. |
2023 * Outputs the modal window used for attaching media to posts or pages in the media-listing screen. |
1933 * |
2024 * |
1934 * @since 2.7.0 |
2025 * @since 2.7.0 |
1935 * |
2026 * |
1936 * @param string $found_action |
2027 * @param string $found_action Optional. The value of the 'found_action' input field. Default empty string. |
1937 */ |
2028 */ |
1938 function find_posts_div( $found_action = '' ) { |
2029 function find_posts_div( $found_action = '' ) { |
1939 ?> |
2030 ?> |
1940 <div id="find-posts" class="find-box" style="display: none;"> |
2031 <div id="find-posts" class="find-box" style="display: none;"> |
1941 <div id="find-posts-head" class="find-box-head"> |
2032 <div id="find-posts-head" class="find-box-head"> |
1942 <?php _e( 'Attach to existing content' ); ?> |
2033 <?php _e( 'Attach to existing content' ); ?> |
1943 <button type="button" id="find-posts-close"><span class="screen-reader-text"><?php _e( 'Close media attachment panel' ); ?></span></button> |
2034 <button type="button" id="find-posts-close"><span class="screen-reader-text"> |
|
2035 <?php |
|
2036 /* translators: Hidden accessibility text. */ |
|
2037 _e( 'Close media attachment panel' ); |
|
2038 ?> |
|
2039 </span></button> |
1944 </div> |
2040 </div> |
1945 <div class="find-box-inside"> |
2041 <div class="find-box-inside"> |
1946 <div class="find-box-search"> |
2042 <div class="find-box-search"> |
1947 <?php if ( $found_action ) { ?> |
2043 <?php if ( $found_action ) { ?> |
1948 <input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" /> |
2044 <input type="hidden" name="found_action" value="<?php echo esc_attr( $found_action ); ?>" /> |
1949 <?php } ?> |
2045 <?php } ?> |
1950 <input type="hidden" name="affected" id="affected" value="" /> |
2046 <input type="hidden" name="affected" id="affected" value="" /> |
1951 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
2047 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> |
1952 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> |
2048 <label class="screen-reader-text" for="find-posts-input"> |
|
2049 <?php |
|
2050 /* translators: Hidden accessibility text. */ |
|
2051 _e( 'Search' ); |
|
2052 ?> |
|
2053 </label> |
1953 <input type="text" id="find-posts-input" name="ps" value="" /> |
2054 <input type="text" id="find-posts-input" name="ps" value="" /> |
1954 <span class="spinner"></span> |
2055 <span class="spinner"></span> |
1955 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> |
2056 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> |
1956 <div class="clear"></div> |
2057 <div class="clear"></div> |
1957 </div> |
2058 </div> |
2015 * |
2116 * |
2016 * @since 2.7.0 |
2117 * @since 2.7.0 |
2017 * |
2118 * |
2018 * @global string $hook_suffix |
2119 * @global string $hook_suffix |
2019 * @global string $admin_body_class |
2120 * @global string $admin_body_class |
|
2121 * @global string $body_id |
2020 * @global WP_Locale $wp_locale WordPress date and time locale object. |
2122 * @global WP_Locale $wp_locale WordPress date and time locale object. |
2021 * |
2123 * |
2022 * @param string $title Optional. Title of the Iframe page. Default empty. |
2124 * @param string $title Optional. Title of the Iframe page. Default empty. |
2023 * @param bool $deprecated Not used. |
2125 * @param bool $deprecated Not used. |
2024 */ |
2126 */ |
2025 function iframe_header( $title = '', $deprecated = false ) { |
2127 function iframe_header( $title = '', $deprecated = false ) { |
|
2128 global $hook_suffix, $admin_body_class, $body_id, $wp_locale; |
|
2129 |
2026 show_admin_bar( false ); |
2130 show_admin_bar( false ); |
2027 global $hook_suffix, $admin_body_class, $wp_locale; |
2131 |
2028 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix ); |
2132 $admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix ); |
2029 |
2133 |
2030 $current_screen = get_current_screen(); |
2134 $current_screen = get_current_screen(); |
2031 |
2135 |
2032 header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
2136 header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
2437 * |
2538 * |
2438 * @since 3.1.0 |
2539 * @since 3.1.0 |
2439 * |
2540 * |
2440 * @see get_submit_button() |
2541 * @see get_submit_button() |
2441 * |
2542 * |
2442 * @param string $text The text of the button (defaults to 'Save Changes') |
2543 * @param string $text Optional. The text of the button. Defaults to 'Save Changes'. |
2443 * @param string $type Optional. The type and CSS class(es) of the button. Core values |
2544 * @param string $type Optional. The type and CSS class(es) of the button. Core values |
2444 * include 'primary', 'small', and 'large'. Default 'primary'. |
2545 * include 'primary', 'small', and 'large'. Default 'primary'. |
2445 * @param string $name The HTML name of the submit button. Defaults to "submit". If no |
2546 * @param string $name Optional. The HTML name of the submit button. If no `id` attribute |
2446 * id attribute is given in $other_attributes below, $name will be |
2547 * is given in the `$other_attributes` parameter, `$name` will be used |
2447 * used as the button's id. |
2548 * as the button's `id`. Default 'submit'. |
2448 * @param bool $wrap True if the output button should be wrapped in a paragraph tag, |
2549 * @param bool $wrap Optional. True if the output button should be wrapped in a paragraph tag, |
2449 * false otherwise. Defaults to true. |
2550 * false otherwise. Default true. |
2450 * @param array|string $other_attributes Other attributes that should be output with the button, mapping |
2551 * @param array|string $other_attributes Optional. Other attributes that should be output with the button, |
2451 * attributes to their values, such as setting tabindex to 1, etc. |
2552 * mapping attributes to their values, e.g. `array( 'id' => 'search-submit' )`. |
2452 * These key/value attribute pairs will be output as attribute="value", |
2553 * These key/value attribute pairs will be output as `attribute="value"`, |
2453 * where attribute is the key. Other attributes can also be provided |
2554 * where attribute is the key. Attributes can also be provided as a string, |
2454 * as a string such as 'tabindex="1"', though the array format is |
2555 * e.g. `id="search-submit"`, though the array format is generally preferred. |
2455 * preferred. Default null. |
2556 * Default empty string. |
2456 */ |
2557 */ |
2457 function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) { |
2558 function submit_button( $text = '', $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = '' ) { |
2458 echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); |
2559 echo get_submit_button( $text, $type, $name, $wrap, $other_attributes ); |
2459 } |
2560 } |
2460 |
2561 |
2461 /** |
2562 /** |
2462 * Returns a submit button, with provided text and appropriate class. |
2563 * Returns a submit button, with provided text and appropriate class. |
2463 * |
2564 * |
2464 * @since 3.1.0 |
2565 * @since 3.1.0 |
2465 * |
2566 * |
2466 * @param string $text Optional. The text of the button. Default 'Save Changes'. |
2567 * @param string $text Optional. The text of the button. Defaults to 'Save Changes'. |
2467 * @param string $type Optional. The type and CSS class(es) of the button. Core values |
2568 * @param string $type Optional. The type and CSS class(es) of the button. Core values |
2468 * include 'primary', 'small', and 'large'. Default 'primary large'. |
2569 * include 'primary', 'small', and 'large'. Default 'primary large'. |
2469 * @param string $name Optional. The HTML name of the submit button. Defaults to "submit". |
2570 * @param string $name Optional. The HTML name of the submit button. If no `id` attribute |
2470 * If no id attribute is given in $other_attributes below, `$name` will |
2571 * is given in the `$other_attributes` parameter, `$name` will be used |
2471 * be used as the button's id. Default 'submit'. |
2572 * as the button's `id`. Default 'submit'. |
2472 * @param bool $wrap Optional. True if the output button should be wrapped in a paragraph |
2573 * @param bool $wrap Optional. True if the output button should be wrapped in a paragraph tag, |
2473 * tag, false otherwise. Default true. |
2574 * false otherwise. Default true. |
2474 * @param array|string $other_attributes Optional. Other attributes that should be output with the button, |
2575 * @param array|string $other_attributes Optional. Other attributes that should be output with the button, |
2475 * mapping attributes to their values, such as `array( 'tabindex' => '1' )`. |
2576 * mapping attributes to their values, e.g. `array( 'id' => 'search-submit' )`. |
2476 * These attributes will be output as `attribute="value"`, such as |
2577 * These key/value attribute pairs will be output as `attribute="value"`, |
2477 * `tabindex="1"`. Other attributes can also be provided as a string such |
2578 * where attribute is the key. Attributes can also be provided as a string, |
2478 * as `tabindex="1"`, though the array format is typically cleaner. |
2579 * e.g. `id="search-submit"`, though the array format is generally preferred. |
2479 * Default empty. |
2580 * Default empty string. |
2480 * @return string Submit button HTML. |
2581 * @return string Submit button HTML. |
2481 */ |
2582 */ |
2482 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) { |
2583 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) { |
2483 if ( ! is_array( $type ) ) { |
2584 if ( ! is_array( $type ) ) { |
2484 $type = explode( ' ', $type ); |
2585 $type = explode( ' ', $type ); |
2590 |
2693 |
2591 return WP_Screen::get( $hook_name ); |
2694 return WP_Screen::get( $hook_name ); |
2592 } |
2695 } |
2593 |
2696 |
2594 /** |
2697 /** |
2595 * Output the HTML for restoring the post data from DOM storage |
2698 * Outputs the HTML for restoring the post data from DOM storage |
2596 * |
2699 * |
2597 * @since 3.6.0 |
2700 * @since 3.6.0 |
2598 * @access private |
2701 * @access private |
2599 */ |
2702 */ |
2600 function _local_storage_notice() { |
2703 function _local_storage_notice() { |
2601 ?> |
2704 $local_storage_message = '<p class="local-restore">'; |
2602 <div id="local-storage-notice" class="hidden notice is-dismissible"> |
2705 $local_storage_message .= __( 'The backup of this post in your browser is different from the version below.' ); |
2603 <p class="local-restore"> |
2706 $local_storage_message .= '<button type="button" class="button restore-backup">' . __( 'Restore the backup' ) . '</button></p>'; |
2604 <?php _e( 'The backup of this post in your browser is different from the version below.' ); ?> |
2707 $local_storage_message .= '<p class="help">'; |
2605 <button type="button" class="button restore-backup"><?php _e( 'Restore the backup' ); ?></button> |
2708 $local_storage_message .= __( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); |
2606 </p> |
2709 $local_storage_message .= '</p>'; |
2607 <p class="help"> |
2710 |
2608 <?php _e( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); ?> |
2711 wp_admin_notice( |
2609 </p> |
2712 $local_storage_message, |
2610 </div> |
2713 array( |
2611 <?php |
2714 'id' => 'local-storage-notice', |
|
2715 'additional_classes' => array( 'hidden' ), |
|
2716 'dismissible' => true, |
|
2717 'paragraph_wrap' => false, |
|
2718 ) |
|
2719 ); |
2612 } |
2720 } |
2613 |
2721 |
2614 /** |
2722 /** |
2615 * Outputs a HTML element with a star rating for a given rating. |
2723 * Outputs a HTML element with a star rating for a given rating. |
2616 * |
2724 * |
2655 $full_stars = floor( $rating ); |
2763 $full_stars = floor( $rating ); |
2656 $half_stars = ceil( $rating - $full_stars ); |
2764 $half_stars = ceil( $rating - $full_stars ); |
2657 $empty_stars = 5 - $full_stars - $half_stars; |
2765 $empty_stars = 5 - $full_stars - $half_stars; |
2658 |
2766 |
2659 if ( $parsed_args['number'] ) { |
2767 if ( $parsed_args['number'] ) { |
2660 /* translators: 1: The rating, 2: The number of ratings. */ |
2768 /* translators: Hidden accessibility text. 1: The rating, 2: The number of ratings. */ |
2661 $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] ); |
2769 $format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $parsed_args['number'] ); |
2662 $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) ); |
2770 $title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $parsed_args['number'] ) ); |
2663 } else { |
2771 } else { |
2664 /* translators: %s: The rating. */ |
2772 /* translators: Hidden accessibility text. %s: The rating. */ |
2665 $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) ); |
2773 $title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) ); |
2666 } |
2774 } |
2667 |
2775 |
2668 $output = '<div class="star-rating">'; |
2776 $output = '<div class="star-rating">'; |
2669 $output .= '<span class="screen-reader-text">' . $title . '</span>'; |
2777 $output .= '<span class="screen-reader-text">' . $title . '</span>'; |