Making WordPress.org


Ignore:
Timestamp:
09/05/2022 08:21:02 PM (4 years ago)
Author:
iandunn
Message:

Developer: Sync with Git 41e97d9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-dashicons.php

    r11213 r12053  
    1010require_once __DIR__ . '/inc/dashicons.php';
    1111
    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' );
     12wp_enqueue_style(
     13        'dashicons-page',
     14        get_template_directory_uri() . '/stylesheets/page-dashicons.css',
     15        array(),
     16        filemtime( __DIR__ . '/stylesheets/page-dashicons.css' )
     17);
     18wp_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);
    1424
    1525get_header(); ?>
    1626
    1727        <div id="content-area" <?php body_class( 'dashicons-page' ); ?>>
    18                 <?php while ( have_posts() ) : the_post(); ?>
     28                <?php while ( have_posts() ) :
     29                        the_post(); ?>
    1930                <main id="main" <?php post_class( 'site-main' ); ?> role="main">
    2031
     
    4455                                                $group_info['label']
    4556                                        );
    46                                        
     57
    4758                                        echo "<!-- {$group} -->\n";
    4859
     
    6879                                <h3><?php _e( 'WordPress Usage', 'wporg' ); ?></h3>
    6980
    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' ),
    7284                                        'https://developer.wordpress.org/reference/functions/register_post_type/',
    7385                                        'https://developer.wordpress.org/reference/functions/add_menu_page/',
     
    7789                                <h4><?php _e( 'Examples', 'wporg' ); ?></h4>
    7890
    79                                 <p><?php printf(
     91                                <p>
     92                                <?php printf(
    8093                                        __( 'In <code><a href="%s">register_post_type()</a></code>, set <code>menu_icon</code> in the arguments array.', 'wporg' ),
    8194                                        'https://developer.wordpress.org/reference/functions/register_post_type/'
     
    89102 */
    90103function wpdocs_create_post_type() {
    91     register_post_type( 'acme_product',
    92         array(
    93             'labels' => array(
    94                 'name'          => __( 'Products', 'textdomain' ),
    95                 'singular_name' => __( 'Product', 'textdomain' )
    96             ),
    97             'public'      => true,
    98             'has_archive' => true,
    99             'menu_icon'   => 'dashicons-products',
    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        );
    102115}
    103116add_action( 'init', 'wpdocs_create_post_type', 0 );
    104117</pre>
    105118
    106                                 <p><?php printf(
     119                                <p>
     120                                <?php printf(
    107121                                        __( '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' ),
    108122                                        'https://developer.wordpress.org/reference/functions/add_menu_page/'
     
    116130 */
    117131function wpdocs_add_my_custom_menu() {
    118     // Add an item to the menu.
    119     add_menu_page(
    120         __( 'My Page', 'textdomain' ),
    121         __( 'My Title', 'textdomain' ),
    122         'manage_options',
    123         'my-page',
    124         'my_admin_page_function',
    125         'dashicons-admin-media'
    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        );
    127141}</pre>
    128142
     
    151165                                <h4><?php _e( 'Examples', 'wporg' ); ?></h4>
    152166
    153                                 <p><?php printf(
     167                                <p>
     168                                <?php printf(
    154169                                        /* translators: %s: URL to Block Editor Handbook for registering a block. */
    155170                                        __( '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' ),
     
    168183} );
    169184</pre>
    170                                 <p><?php printf(
     185                                <p>
     186                                <?php printf(
    171187                                        /* translators: %s: URL to handbook page for Dashicon component. */
    172188                                        __( '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' ),
     
    176192<pre>
    177193import { Dashicon } from '@wordpress/components';
    178  
     194
    179195const MyDashicon = () =&gt; (
    180196    &lt;div&gt;
Note: See TracChangeset for help on using the changeset viewer.