Make WordPress Core

Ticket #21598: buttons.4.php

File buttons.4.php, 1.6 KB (added by kadamwhite, 14 years ago)

Would it be preferable to create a re-usable function to render all the button variants?

Line 
1<?php
2/*
3Plugin Name: Button Styles
4*/
5
6global $button_styles;
7$button_styles = new Button_Styles();
8
9class Button_Styles {
10
11 function __construct() {
12 add_action( 'admin_menu', array( &$this, 'menu' ) );
13 }
14
15 function menu() {
16 add_management_page( __( 'Button Styles', 'buttons' ), __( 'Button Styles', 'buttons' ), 'edit_posts', __FILE__, array( &$this, 'page' ) );
17 }
18
19 function page() {
20
21 function render_button_states( $text, $type, $width = '18%' ) {
22 //submit_button( $text, $type, $name, $wrap, $other_attributes );
23
24 echo '<div style="float: left; width: ' . $width . '">';
25 submit_button( $text, $type );
26 submit_button( $text . ' (hover)', $type . ' hover' );
27 submit_button( $text . ' (focus)', $type . ' focus' );
28 submit_button( $text . ' (active)', $type . ' active' );
29 submit_button( $text . ' (disabled)', $type . ' active', null, null, array( 'disabled' => 'disabled' ) );
30 echo '</div>';
31 }
32
33 ?><div class="wrap">
34 <h2><?php _e( 'Button Styles', 'buttons' ); ?></h2>
35
36 <!-- <p><a href="#" title="This is here so you can easily cmd/ctrl+f to this part of the page">:)</a></p> -->
37
38 <?php render_button_states( 'Primary', 'button-primary' ); ?>
39 <?php render_button_states( 'Secondary', 'button-secondary' ); ?>
40 <?php /*render_button_states( 'Delete', 'button-secondary delete' );*/ ?>
41 <?php render_button_states( 'Highlighted', 'button-highlighted' ); ?>
42 <?php render_button_states( '.button', 'button' ); ?>
43 <?php render_button_states( 'Short', 'button short', '14%' ); ?>
44 <?php render_button_states( 'Small', 'button small', '14%' ); ?>
45
46 </div><?php
47
48 }
49
50}