Changeset 12053
- Timestamp:
- 09/05/2022 08:21:02 PM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 1 added
- 6 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/admin.php
r7817 r12053 23 23 public static function do_init() { 24 24 add_action( 'admin_enqueue_scripts', [ __CLASS__, 'admin_enqueue_scripts' ] ); 25 25 26 26 add_action( 'comment_author', [ __CLASS__, 'append_user_nicename' ], 10, 2 ); 27 27 … … 31 31 32 32 // Reset votes after editing a comment in the wp-admin. 33 add_filter( 'comment_edit_redirect', [ __CLASS__, 'comment_edit_redirect'], 10, 2 );33 add_filter( 'comment_edit_redirect', [ __CLASS__, 'comment_edit_redirect' ], 10, 2 ); 34 34 } 35 35 } … … 67 67 */ 68 68 if ( (bool) apply_filters( 'devhub-admin_enqueue_scripts', in_array( get_current_screen()->id, $screen_ids ) ) ) { 69 wp_enqueue_style( 'wporg-admin', get_template_directory_uri() . '/stylesheets/admin.css', [], '20181101' ); 69 wp_enqueue_style( 70 'wporg-admin', 71 get_template_directory_uri() . '/stylesheets/admin.css', 72 [], 73 filemtime( dirname( __DIR__ ) . '/stylesheets/admin.css' ), 74 ); 70 75 } 71 76 } … … 85 90 if ( $comment->user_id ) { 86 91 $username = get_user_by( 'id', $comment->user_id )->user_nicename; 87 92 88 93 $author_name .= '</strong><div class="comment-author-nicename">@' . $username . '</div><strong>'; 89 94 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/autocomplete.php
r12051 r12053 22 22 public function init() { 23 23 24 add_action( 'wp_ajax_autocomplete', 25 add_action( "wp_ajax_nopriv_autocomplete",array( $this, 'autocomplete_data_update' ) );24 add_action( 'wp_ajax_autocomplete', array( $this, 'autocomplete_data_update' ) ); 25 add_action( 'wp_ajax_nopriv_autocomplete', array( $this, 'autocomplete_data_update' ) ); 26 26 27 27 // Enqueue scripts and styles. … … 37 37 public function scripts_and_styles() { 38 38 39 wp_enqueue_style( 'awesomplete-css', get_template_directory_uri() . '/stylesheets/awesomplete.css', array(), '20220905' ); 40 wp_enqueue_style( 'autocomplete-css', get_template_directory_uri() . '/stylesheets/autocomplete.css', array(), '20220905' ); 39 wp_enqueue_style( 40 'awesomplete-css', 41 get_template_directory_uri() . '/stylesheets/awesomplete.css', 42 array(), 43 filemtime( dirname( __DIR__ ) . '/stylesheets/awesomplete.css' ) 44 ); 45 wp_enqueue_style( 46 'autocomplete-css', 47 get_template_directory_uri() . '/stylesheets/autocomplete.css', 48 array(), 49 filemtime( dirname( __DIR__ ) . '/stylesheets/autocomplete.css' ) 50 ); 41 51 42 wp_register_script( 'awesomplete', get_template_directory_uri() . '/js/awesomplete.min.js', array(), '20220905', true ); 52 wp_register_script( 53 'awesomplete', 54 get_template_directory_uri() . '/js/awesomplete.min.js', 55 array(), 56 filemtime( dirname( __DIR__ ) . '/js/awesomplete.min.js' ), 57 true 58 ); 43 59 wp_enqueue_script( 'awesomplete' ); 44 60 45 61 wp_register_script( 'autocomplete', get_stylesheet_directory_uri() . '/js/autocomplete.js', array( 'awesomplete' ), filemtime( dirname( __DIR__ ) . '/js/autocomplete.js' ), true ); 46 wp_localize_script( 'autocomplete', 'autocomplete', array( 62 wp_localize_script( 63 'autocomplete', 64 'autocomplete', 65 array( 47 66 'ajaxurl' => admin_url( 'admin-ajax.php' ), 48 67 'nonce' => wp_create_nonce( 'autocomplete_nonce' ), … … 72 91 ); 73 92 74 if ( ! ( isset( $_POST['data'] ) && $_POST['data'] ) ) {93 if ( ! ( isset( $_POST['data'] ) && $_POST['data'] ) ) { 75 94 wp_send_json_error( $defaults ); 76 95 } … … 86 105 87 106 foreach ( $form_data['post_type'] as $key => $post_type ) { 88 if ( ! in_array( $post_type, $parser_post_types ) ) {107 if ( ! in_array( $post_type, $parser_post_types ) ) { 89 108 unset( $form_data['post_type'][ $key ] ); 90 109 } 91 110 } 92 111 93 $post_types = ! empty( $form_data['post_type'] ) ? $form_data['post_type'] : $parser_post_types;112 $post_types = ! empty( $form_data['post_type'] ) ? $form_data['post_type'] : $parser_post_types; 94 113 95 114 $args = array( … … 117 136 118 137 if ( $post->post_type == 'wp-parser-class' ) { 119 $title = 138 $title = 'class ' . $title . ' {}'; 120 139 } 121 140 … … 124 143 } 125 144 126 wp_send_json_success 145 wp_send_json_success( $form_data ); 127 146 } 128 147 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/customizer.php
r9325 r12053 22 22 */ 23 23 function wporg_developer_customize_preview_js() { 24 wp_enqueue_script( 'wporg_developer_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true ); 24 wp_enqueue_script( 25 'wporg_developer_customizer', 26 get_template_directory_uri() . '/js/customizer.js', 27 array( 'customize-preview' ), 28 filemtime( dirname( __DIR__ ) . '/js/customizer.js' ), 29 true 30 ); 25 31 } 26 32 add_action( 'customize_preview_init', 'wporg_developer_customize_preview_js' ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/explanations.php
r12030 r12053 144 144 $url = parse_url( $preview_link ); 145 145 $url_query = array(); 146 parse_str 146 parse_str( $url['query'], $url_query ); 147 147 148 148 $preview_link = get_preview_post_link( … … 184 184 $menu[ $i ][0] = sprintf( 185 185 __( 'Explanations %s', 'wporg' ), 186 "<span class='update-plugins count-{$count}'><span class='plugin-count'>" . number_format_i18n( $count ) . "</span></span>"186 "<span class='update-plugins count-{$count}'><span class='plugin-count'>" . number_format_i18n( $count ) . '</span></span>' 187 187 ); 188 188 break; … … 274 274 <strong><?php _e( 'Associated with: ', 'wporg' ); ?></strong> 275 275 <?php 276 printf( '<a href="%1$s">%2$s</a>', 276 printf( 277 '<a href="%1$s">%2$s</a>', 277 278 esc_url( get_permalink( $post->post_parent ) ), 278 279 str_replace( 'Explanation: ', '', get_the_title( $post->post_parent ) ) … … 357 358 if ( in_array( $role, array( 'administrator', 'editor', 'expl_editor' ) ) ) { 358 359 $base_caps = array( 359 'edit_explanations', 'edit_others_explanations', 360 'edit_published_explanations', 'edit_posts' 360 'edit_explanations', 361 'edit_others_explanations', 362 'edit_published_explanations', 363 'edit_posts', 361 364 ); 362 365 … … 367 370 $editor_caps = array( 368 371 'publish_explanations', 369 'delete_explanations', 'delete_others_explanations', 370 'delete_published_explanations', 'delete_private_explanations', 371 'edit_private_explanations', 'read_private_explanations' 372 'delete_explanations', 373 'delete_others_explanations', 374 'delete_published_explanations', 375 'delete_private_explanations', 376 'edit_private_explanations', 377 'read_private_explanations', 372 378 ); 373 379 … … 405 411 } 406 412 407 $expl_action['edit-expl'] = sprintf( '<a href="%1$s" alt="%2$s">%3$s</a>', 413 $expl_action['edit-expl'] = sprintf( 414 '<a href="%1$s" alt="%2$s">%3$s</a>', 408 415 esc_url( get_edit_post_link( $expl->ID ) ), 409 416 esc_attr__( 'Edit Explanation', 'wporg' ), … … 411 418 ); 412 419 } else { 413 $expl_action['add-expl'] = sprintf( '<a href="" class="create-expl" data-nonce="%1$s" data-id="%2$s">%3$s</a>', 420 $expl_action['add-expl'] = sprintf( 421 '<a href="" class="create-expl" data-nonce="%1$s" data-id="%2$s">%3$s</a>', 414 422 esc_attr( wp_create_nonce( 'create-expl' ) ), 415 423 esc_attr( $post->ID ), … … 451 459 </a><!-- #create-explanation --> 452 460 </span><!-- expl-row-actions --> 453 <?php461 <?php 454 462 endif; 455 463 } … … 468 476 } 469 477 470 switch ( $status = $post->post_status ) {471 case 'draft' 478 switch ( $status = $post->post_status ) { 479 case 'draft': 472 480 $label = __( 'Draft', 'wporg' ); 473 481 break; 474 case 'pending' 482 case 'pending': 475 483 $label = __( 'Pending Review', 'wporg' ); 476 484 break; 477 case 'publish' 485 case 'publish': 478 486 $label = __( 'Published', 'wporg' ); 479 487 break; 480 default 488 default: 481 489 $status = ''; 482 490 $label = __( 'None', 'wporg' ); … … 496 504 */ 497 505 public function admin_enqueue_base_scripts( $do_enqueue ) { 498 return $do_enqueue || in_array( get_current_screen()->id, $this->screen_ids 506 return $do_enqueue || in_array( get_current_screen()->id, $this->screen_ids ); 499 507 } 500 508 … … 508 516 $parsed_post_types_screen_ids = DevHub_Admin::get_parsed_post_types_screen_ids(); 509 517 510 if ( in_array( get_current_screen()->id, array_merge( 518 if ( in_array( 519 get_current_screen()->id, 520 array_merge( 511 521 $parsed_post_types_screen_ids, 512 522 $this->screen_ids 513 ) ) ) { 514 wp_enqueue_script( 'wporg-explanations', get_template_directory_uri() . '/js/explanations.js', array( 'jquery', 'wp-util' ), '20160630', true ); 515 516 wp_localize_script( 'wporg-explanations', 'wporg', array( 517 'editContentLabel' => __( 'Edit Explanation', 'wporg' ), 518 'statusLabel' => array( 519 'draft' => __( 'Draft', 'wporg' ), 520 'pending' => __( 'Pending Review', 'wporg' ), 521 'publish' => __( 'Published', 'wporg' ), 522 ), 523 ) ); 523 ) 524 ) ) { 525 wp_enqueue_script( 526 'wporg-explanations', 527 get_template_directory_uri() . '/js/explanations.js', 528 array( 'jquery', 'wp-util' ), 529 filemtime( dirname( __DIR__ ) . '/js/explanations.js' ), 530 true 531 ); 532 533 wp_localize_script( 534 'wporg-explanations', 535 'wporg', 536 array( 537 'editContentLabel' => __( 'Edit Explanation', 'wporg' ), 538 'statusLabel' => array( 539 'draft' => __( 'Draft', 'wporg' ), 540 'pending' => __( 'Pending Review', 'wporg' ), 541 'publish' => __( 'Published', 'wporg' ), 542 ), 543 ) 544 ); 524 545 } 525 546 } … … 559 580 ); 560 581 } 561 562 582 } 563 583 } … … 605 625 $pos = false === $index ? count( $columns ) : $index + 1; 606 626 607 $col_data = [ 'has_explanation' => sprintf( 608 '<span class="dashicons dashicons-info" title="%s"></span><span class="screen-reader-text">%s</span>', 609 esc_attr__( 'Has explanation?', 'wporg' ), 610 esc_html__( 'Explanation?', 'wporg' ) 611 ) ]; 627 $col_data = [ 628 'has_explanation' => sprintf( 629 '<span class="dashicons dashicons-info" title="%s"></span><span class="screen-reader-text">%s</span>', 630 esc_attr__( 'Has explanation?', 'wporg' ), 631 esc_html__( 'Explanation?', 'wporg' ) 632 ), 633 ]; 612 634 $columns = array_merge( array_slice( $columns, 0, $pos ), $col_data, array_slice( $columns, $pos ) ); 613 635 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/parsed-content.php
r7815 r12053 99 99 <div class="wporg_parsed_readonly <?php echo $ticket ? 'hidden' : ''; ?>"><?php echo apply_filters( 'the_content', $content ); ?></div> 100 100 <div class="wporg_parsed_content <?php echo $ticket ? '' : 'hidden'; ?>"> 101 <?php wp_editor( $content, 'content', array( 102 'media_buttons' => false, 103 'tinymce' => false, 104 'quicktags' => true, 105 'textarea_rows' => 10, 106 'textarea_name' => 'content', 107 ) ); ?> 101 <?php wp_editor( 102 $content, 103 'content', 104 array( 105 'media_buttons' => false, 106 'tinymce' => false, 107 'quicktags' => true, 108 'textarea_rows' => 10, 109 'textarea_name' => 'content', 110 ) 111 ); ?> 108 112 </div> 109 113 </td> … … 164 168 // Only enqueue 'wporg-parsed-content' script and styles on Code Reference post type screens. 165 169 if ( in_array( get_current_screen()->id, $this->post_types ) ) { 166 wp_enqueue_script( 'wporg-parsed-content', get_template_directory_uri() . '/js/parsed-content.js', array( 'jquery', 'utils' ), '20150824', true ); 167 168 wp_localize_script( 'wporg-parsed-content', 'wporgParsedContent', array( 169 'ajaxURL' => admin_url( 'admin-ajax.php' ), 170 'searchText' => __( 'Searching ...', 'wporg' ), 171 'retryText' => __( 'Invalid ticket number, please try again.', 'wporg' ) 172 ) ); 170 wp_enqueue_script( 171 'wporg-parsed-content', 172 get_template_directory_uri() . '/js/parsed-content.js', 173 array( 'jquery', 'utils' ), 174 filemtime( dirname( __DIR__ ) . '/js/parsed-content.js' ), 175 true 176 ); 177 178 wp_localize_script( 179 'wporg-parsed-content', 180 'wporgParsedContent', 181 array( 182 'ajaxURL' => admin_url( 'admin-ajax.php' ), 183 'searchText' => __( 'Searching ...', 'wporg' ), 184 'retryText' => __( 'Invalid ticket number, please try again.', 'wporg' ), 185 ) 186 ); 173 187 } 174 188 } … … 200 214 201 215 $nodes = $doc->getElementsByTagName( 'title' ); 202 $title = $nodes->item( 0)->nodeValue;216 $title = $nodes->item( 0 )->nodeValue; 203 217 204 218 // Strip off the site name. … … 213 227 update_post_meta( $post_id, 'wporg_ticket_title', $title ); 214 228 215 $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $ticket_url ), 229 $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $ticket_url ), apply_filters( 'the_title', $title ) ); 216 230 217 231 // Can haz success. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php
r9433 r12053 36 36 public static function scripts_and_styles() { 37 37 if ( is_singular() ) { 38 wp_enqueue_script( 'wporg-developer-tabs', get_template_directory_uri() . '/js/tabs.js', array( 'jquery' ), '20160824', true ); 39 wp_enqueue_script( 'wporg-developer-preview', get_template_directory_uri() . '/js/user-notes-preview.js', array( 'jquery', 'wporg-developer-function-reference', 'wporg-developer-tabs' ), '20200111', true ); 40 wp_localize_script( 'wporg-developer-preview', 'wporg_note_preview', array( 41 'ajaxurl' => admin_url( 'admin-ajax.php' ), 42 'nonce' => wp_create_nonce( 'preview_nonce' ), 43 'preview' => __( 'preview note', 'wporg' ), 44 'preview_empty' => __( 'Nothing to preview', 'wporg' ), 45 'is_admin' => is_admin(), 46 ) ); 38 wp_enqueue_script( 39 'wporg-developer-tabs', 40 get_template_directory_uri() . '/js/tabs.js', 41 array( 'jquery' ), 42 filemtime( dirname( __DIR__ ) . '/js/tabs.js' ), 43 true 44 ); 45 46 wp_enqueue_script( 47 'wporg-developer-preview', 48 get_template_directory_uri() . '/js/user-notes-preview.js', 49 array( 'jquery', 'wporg-developer-function-reference', 'wporg-developer-tabs' ), 50 filemtime( dirname( __DIR__ ) . '/js/user-notes-preview.js' ), 51 true 52 ); 53 54 wp_localize_script( 55 'wporg-developer-preview', 56 'wporg_note_preview', 57 array( 58 'ajaxurl' => admin_url( 'admin-ajax.php' ), 59 'nonce' => wp_create_nonce( 'preview_nonce' ), 60 'preview' => __( 'preview note', 'wporg' ), 61 'preview_empty' => __( 'Nothing to preview', 'wporg' ), 62 'is_admin' => is_admin(), 63 ) 64 ); 47 65 } 48 66 } … … 51 69 * Ajax action to update the comment preview. 52 70 */ 53 public static function ajax_preview( 71 public static function ajax_preview() { 54 72 check_ajax_referer( 'preview_nonce', 'preview_nonce' ); 55 73 … … 80 98 81 99 ob_start(); 82 ?>100 ?> 83 101 <div id='comment-preview' class='tab-section comment byuser depth-1 comment-preview' aria-hidden="true"> 84 102 <article class='preview-body comment-body'> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php
r10937 r12053 48 48 public static function do_init() { 49 49 // Save a non-AJAX submitted vote. 50 add_action( 'template_redirect', 50 add_action( 'template_redirect', array( __CLASS__, 'vote_submission' ) ); 51 51 52 52 // Save AJAX submitted vote. 53 add_action( 'wp_ajax_note_vote', 53 add_action( 'wp_ajax_note_vote', array( __CLASS__, 'ajax_vote_submission' ) ); 54 54 55 55 // Enqueue scripts and styles. … … 65 65 // Only need to enqueue voting-related resources if there are comments to vote on. 66 66 if ( self::user_can_vote() && is_singular() && '0' != get_comments_number() ) { 67 wp_register_script( 'wporg-developer-user-notes-voting', get_template_directory_uri() . '/js/user-notes-voting.js', array( 'wp-a11y' ), '20210428', true ); 68 wp_localize_script( 'wporg-developer-user-notes-voting', 'wporg_note_voting', array( 69 'ajaxurl' => admin_url( 'admin-ajax.php' ), 70 ) ); 67 wp_register_script( 68 'wporg-developer-user-notes-voting', 69 get_template_directory_uri() . '/js/user-notes-voting.js', 70 array( 'wp-a11y' ), 71 filemtime( dirname( __DIR__ ) . '/js/user-notes-voting.js' ), 72 true 73 ); 74 75 wp_localize_script( 76 'wporg-developer-user-notes-voting', 77 'wporg_note_voting', 78 array( 79 'ajaxurl' => admin_url( 'admin-ajax.php' ), 80 ) 81 ); 71 82 wp_enqueue_script( 'wporg-developer-user-notes-voting' ); 72 83 } … … 97 108 exit(); 98 109 } 99 100 110 } 101 111 … … 177 187 * @access public 178 188 * 179 * @param int 180 * @param int 189 * @param int $user_id Optional. The user ID. If not defined, assumes current user. 190 * @param int $comment_id Optional. The comment ID. If not defined, assumes being able to comment generally. 181 191 * @return bool True if the user can vote. 182 192 */ … … 209 219 * Determines if a note was submitted by the current user. 210 220 * 211 * @param int 221 * @param int $comment_id The comment ID, or empty to use current comment. 212 222 * @return bool True if the note was submitted by the current user. 213 223 */ … … 237 247 * @access public 238 248 * 239 * @param int 240 * @param int 249 * @param int $comment_id The comment ID 250 * @param int $user_id Optional. The user ID. If not defined, assumes current user. 241 251 * @return bool True if the user has upvoted the comment. 242 252 */ … … 262 272 * @access public 263 273 * 264 * @param int 265 * @param int 274 * @param int $comment_id The comment ID 275 * @param int $user_id Optional. The user ID. If not defined, assumes current user. 266 276 * @return bool True if the user has downvoted the comment. 267 277 */ … … 289 299 * @param int $comment_id The comment ID, or empty to use current comment. 290 300 */ 291 public static function show_voting( $comment_id = '' ) {301 public static function show_voting( $comment_id = '' ) { 292 302 if ( ! $comment_id ) { 293 303 global $comment; … … 330 340 if ( 'a' === $tag ) { 331 341 $up_url = $logged_in ? 332 add_query_arg( array( '_wpnonce' => $nonce , 'comment' => $comment_id, 'vote' => 'up' ), $comment_link ) : 342 add_query_arg( 343 array( 344 '_wpnonce' => $nonce, 345 'comment' => $comment_id, 346 'vote' => 'up', 347 ), 348 $comment_link 349 ) : 333 350 $log_in_url; 334 351 echo '" href="' . esc_url( $up_url ); … … 336 353 echo '">'; 337 354 echo '<span class="dashicons dashicons-arrow-up" aria-hidden="true"></span>'; 338 echo '<span class="screen-reader-text">' . $title . 355 echo '<span class="screen-reader-text">' . $title . '</span>'; 339 356 echo "</{$tag}>"; 340 357 … … 348 365 . 'class="user-note-voting-count ' . esc_attr( $class ) . '" ' 349 366 . 'title="' . esc_attr( $title ) . '">' 350 . '<span class="screen-reader-text">' . __( 'Vote results for this note: ', 'wporg' ) . 367 . '<span class="screen-reader-text">' . __( 'Vote results for this note: ', 'wporg' ) . '</span>' 351 368 . self::count_votes( $comment_id, 'difference' ) 352 369 . '</span>'; … … 371 388 if ( 'a' === $tag ) { 372 389 $down_url = $logged_in ? 373 add_query_arg( array( '_wpnonce' => $nonce , 'comment' => $comment_id, 'vote' => 'down' ), $comment_link ) : 390 add_query_arg( 391 array( 392 '_wpnonce' => $nonce, 393 'comment' => $comment_id, 394 'vote' => 'down', 395 ), 396 $comment_link 397 ) : 374 398 $log_in_url; 375 399 echo '" href="' . esc_url( $down_url ); … … 377 401 echo '">'; 378 402 echo '<span class="dashicons dashicons-arrow-down" aria-hidden="true"></span>'; 379 echo '<span class="screen-reader-text">' . $title . 403 echo '<span class="screen-reader-text">' . $title . '</span>'; 380 404 echo "</{$tag}>"; 381 405 … … 435 459 * @access public 436 460 * 437 * @param int 438 * @param int 461 * @param int $comment_id The comment ID 462 * @param int $user_id Optional. The user ID. Default is current user. 439 463 * @return bool Whether the up vote succeed (a new vote or a change in vote). 440 464 */ … … 448 472 * @access public 449 473 * 450 * @param int 451 * @param int 474 * @param int $comment_id The comment ID 475 * @param int $user_id Optional. The user ID. Default is current user. 452 476 * @return bool Whether the down vote succeed (a new vote or a change in vote). 453 477 */ -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-dashicons.php
r11213 r12053 10 10 require_once __DIR__ . '/inc/dashicons.php'; 11 11 12 wp_enqueue_style( 'dashicons-page', get_template_directory_uri() . '/stylesheets/page-dashicons.css', array(), '20210830' ); 13 wp_enqueue_script( 'dashicons-page', get_template_directory_uri() . '/js/page-dashicons.js', array( 'jquery', 'wp-util' ), '20210830' ); 12 wp_enqueue_style( 13 'dashicons-page', 14 get_template_directory_uri() . '/stylesheets/page-dashicons.css', 15 array(), 16 filemtime( __DIR__ . '/stylesheets/page-dashicons.css' ) 17 ); 18 wp_enqueue_script( 19 'dashicons-page', 20 get_template_directory_uri() . '/js/page-dashicons.js', 21 array( 'jquery', 'wp-util' ), 22 filemtime( __DIR__ . '/js/page-dashicons.js' ) 23 ); 14 24 15 25 get_header(); ?> 16 26 17 27 <div id="content-area" <?php body_class( 'dashicons-page' ); ?>> 18 <?php while ( have_posts() ) : the_post(); ?> 28 <?php while ( have_posts() ) : 29 the_post(); ?> 19 30 <main id="main" <?php post_class( 'site-main' ); ?> role="main"> 20 31 … … 44 55 $group_info['label'] 45 56 ); 46 57 47 58 echo "<!-- {$group} -->\n"; 48 59 … … 68 79 <h3><?php _e( 'WordPress Usage', 'wporg' ); ?></h3> 69 80 70 <p><?php printf( 71 __( 'Admin menu items can be added with <code><a href="%s">register_post_type()</a></code> and <code><a href="%s">add_menu_page()</a></code>, which both have an option to set an icon. To show the current icon, you should pass in %s.', 'wporg' ), 81 <p> 82 <?php printf( 83 __( 'Admin menu items can be added with <code><a href="%1$s">register_post_type()</a></code> and <code><a href="%2$s">add_menu_page()</a></code>, which both have an option to set an icon. To show the current icon, you should pass in %3$s.', 'wporg' ), 72 84 'https://developer.wordpress.org/reference/functions/register_post_type/', 73 85 'https://developer.wordpress.org/reference/functions/add_menu_page/', … … 77 89 <h4><?php _e( 'Examples', 'wporg' ); ?></h4> 78 90 79 <p><?php printf( 91 <p> 92 <?php printf( 80 93 __( 'In <code><a href="%s">register_post_type()</a></code>, set <code>menu_icon</code> in the arguments array.', 'wporg' ), 81 94 'https://developer.wordpress.org/reference/functions/register_post_type/' … … 89 102 */ 90 103 function wpdocs_create_post_type() { 91 92 93 94 95 96 97 98 99 100 101 104 register_post_type( 'acme_product', 105 array( 106 'labels' => array( 107 'name' => __( 'Products', 'textdomain' ), 108 'singular_name' => __( 'Product', 'textdomain' ) 109 ), 110 'public' => true, 111 'has_archive' => true, 112 'menu_icon' => 'dashicons-products', 113 ) 114 ); 102 115 } 103 116 add_action( 'init', 'wpdocs_create_post_type', 0 ); 104 117 </pre> 105 118 106 <p><?php printf( 119 <p> 120 <?php printf( 107 121 __( 'The function <code><a href="%s">add_menu_page()</a></code> accepts a parameter after the callback function for an icon URL, which can also accept a dashicons class.', 'wporg' ), 108 122 'https://developer.wordpress.org/reference/functions/add_menu_page/' … … 116 130 */ 117 131 function wpdocs_add_my_custom_menu() { 118 119 120 121 122 123 124 125 126 132 // Add an item to the menu. 133 add_menu_page( 134 __( 'My Page', 'textdomain' ), 135 __( 'My Title', 'textdomain' ), 136 'manage_options', 137 'my-page', 138 'my_admin_page_function', 139 'dashicons-admin-media' 140 ); 127 141 }</pre> 128 142 … … 151 165 <h4><?php _e( 'Examples', 'wporg' ); ?></h4> 152 166 153 <p><?php printf( 167 <p> 168 <?php printf( 154 169 /* translators: %s: URL to Block Editor Handbook for registering a block. */ 155 170 __( 'Adding an icon to a block. The <code>registerBlockType</code> function accepts a parameter "icon" which accepts the name of a dashicon. The provided example is truncated. See the <a href="%s">full example</a> in the Block Editor Handbook.', 'wporg' ), … … 168 183 } ); 169 184 </pre> 170 <p><?php printf( 185 <p> 186 <?php printf( 171 187 /* translators: %s: URL to handbook page for Dashicon component. */ 172 188 __( 'Using an icon as a component. A dedicated <code>Dashicon</code> component is available. See the <a href="%s">related documentation</a> in the Block Editor Handbook.', 'wporg' ), … … 176 192 <pre> 177 193 import { Dashicon } from '@wordpress/components'; 178 194 179 195 const MyDashicon = () => ( 180 196 <div>
Note: See TracChangeset
for help on using the changeset viewer.