Changeset 12053 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-dashicons.php
- Timestamp:
- 09/05/2022 08:21:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 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 ); 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 // 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 ); 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.