Changeset 1271 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-dashicons.php
- Timestamp:
- 02/17/2015 09:33:10 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/page-dashicons.php
r1056 r1271 319 319 <div id="instructions"> 320 320 321 <h3><?php _e( 'WordPress Usage', 'wporg' ); ?></h3> 322 323 <p><?php printf( 324 __( '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' ), 325 'https://developer.wordpress.org/reference/functions/register_post_type/', 326 'https://developer.wordpress.org/reference/functions/add_menu_page/', 327 '<code>\'dashicons-<span id="wp-class-example">{icon}</span>\'</code>' 328 ); ?></p> 329 330 <h4><?php _e( 'Examples', 'wporg' ); ?></h4> 331 332 <p><?php printf( 333 __( 'In <code><a href="">register_post_type()</a></code>, set <code>menu_icon</code> in the arguments array.', 'wporg' ), 334 'https://developer.wordpress.org/reference/functions/register_post_type/' 335 ); ?></p> 336 337 <pre><?php 338 add_action( 'init', 'create_post_type' ); 339 //Registers the Product's post type 340 function create_post_type() { 341 register_post_type( 'acme_product', 342 array( 343 'labels' => array( 344 'name' => __( 'Products' ), 345 'singular_name' => __( 'Product' ) 346 ), 347 'public' => true, 348 'has_archive' => true, 349 'menu_icon' => 'dashicons-products', 350 ) 351 ); 352 } 353 </pre> 354 355 <p><?php printf( 356 __( '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' ), 357 'https://developer.wordpress.org/reference/functions/add_menu_page/' 358 ); ?></p> 359 360 <pre><?php 361 function add_my_custom_menu() { 362 //add an item to the menu 363 add_menu_page ( 364 'My Page', 365 'My Title', 366 'manage_options', 367 'my-page', 368 'my_admin_page_function', 369 'dashicons-admin-media', 370 ); 371 }</pre> 372 373 <h3><?php _e( 'CSS/HTML Usage', 'wporg' ); ?></h3> 374 375 <p><?php _e( "If you want to use dashicons in the admin outside of the menu, there are two helper classes you can use. These are <code>dashicons-before</code> and <code>dashicons</code>, and they can be thought of as setting up dashicons (since you still need your icon's class, too).", 'wporg' ); ?></p> 376 377 <h4><?php _e( 'Examples', 'wporg' ); ?></h4> 378 379 <p><?php _e( 'Adding an icon to a header, with the <code>dashicons-before</code> class. This can be added right to the element with text.', 'wporg' ); ?></p> 380 381 <pre> 382 <h2 class="dashicons-before dashicons-smiley"><?php _e( 'A Cheerful Headline', 'wporg' ); ?></h2> 383 </pre> 384 385 <p><?php _e( 'Adding an icon to a header, with the <code>dashicons</code> class. Note that here, you need extra markup specifically for the icon.', 'wporg' ); ?></p> 386 387 <pre> 388 <h2><span class="dashicons dashicons-smiley"></span> <?php _e( 'A Cheerful Headline', 'wporg' ); ?></h2> 389 </pre> 390 321 391 <h3><?php _e( 'Photoshop Usage', 'wporg' ); ?></h3> 322 392 323 393 <p><?php _e( 'Use the .OTF version of the font for Photoshop mockups, the web-font versions won\'t work. For most accurate results, pick the "Sharp" font smoothing.', 'wporg' ); ?></p> 324 325 <h3><?php _e( 'CSS Usage', 'wporg' ); ?></h3>326 327 <p><?php _e( 'Link the stylesheet:', 'wporg' ); ?></p>328 329 <pre><link rel="stylesheet" href="css/dashicons.css"></pre>330 331 <p><?php printf( __( 'Now add the icons using the %s selector. You can insert the Star icon like this:', 'wporg' ), '<code>:before</code>' ); ?></p>332 333 <textarea class="code" onclick="select();">334 .myicon:before {335 content: "\f155";336 display: inline-block;337 -webkit-font-smoothing: antialiased;338 font: normal 20px/1 'dashicons';339 vertical-align: top;340 }</textarea>341 394 342 395 </div><!-- /#instructions --> … … 350 403 <div class="dashicons {{data.cssClass}}"></div> 351 404 <div class="info"> 352 <span class="name"> ← {{data.cssClass}}</span>405 <span class="name"><code>{{data.cssClass}}</code></span> 353 406 <span class="link"><a href='javascript:dashicons.copy( "content: \"\\{{data.attr}}\";", "css" )'><?php _e( 'Copy CSS', 'wporg' ); ?></a></span> 354 407 <span class="link"><a href="javascript:dashicons.copy( '{{data.html}}', 'html' )"><?php _e( 'Copy HTML', 'wporg' ); ?></a></span>
Note: See TracChangeset
for help on using the changeset viewer.