Making WordPress.org

Changeset 1233


Ignore:
Timestamp:
02/06/2015 10:01:22 PM (11 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Whitespace, readability, coding standards cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php

    r1232 r1233  
    11<?php
    22
    3 if ( !class_exists( 'WordCamp_Admin' ) ) :
     3if ( ! class_exists( 'WordCamp_Admin' ) ) :
    44/**
    55 * WCPT_Admin
     
    6060     * @uses add_meta_box
    6161     */
    62     function metabox () {
    63         add_meta_box (
     62    function metabox() {
     63        add_meta_box(
    6464            'wcpt_information',
    6565            __( 'WordCamp Information', 'wcpt' ),
     
    7070        );
    7171
    72         add_meta_box (
     72        add_meta_box(
    7373            'wcpt_organizer_info',
    7474            __( 'Organizing Team', 'wcpt' ),
     
    7979        );
    8080
    81         add_meta_box (
     81        add_meta_box(
    8282            'wcpt_venue_info',
    8383            __( 'Venue Information', 'wcpt' ),
     
    9797     * @return int
    9898     */
    99     function metabox_save ( $post_id ) {
     99    function metabox_save( $post_id ) {
    100100
    101101        // Don't add/remove meta on revisions and auto-saves
     
    113113                // Get post value
    114114                $post_value   = wcpt_key_to_str( $key, 'wcpt_' );
    115                 $values[$key] = isset( $_POST[$post_value] ) ? esc_attr( $_POST[$post_value] ) : '';
     115                $values[ $key ] = isset( $_POST[ $post_value ] ) ? esc_attr( $_POST[ $post_value ] ) : '';
    116116
    117117                switch ( $value ) {
    118118                    case 'text'     :
    119119                    case 'textarea' :
    120                         update_post_meta( $post_id, $key, $values[$key] );
     120                        update_post_meta( $post_id, $key, $values[ $key ] );
    121121                        break;
    122                    
     122
    123123                    case 'checkbox' :
    124124                        if ( ! empty( $values[ $key ] ) && 'on' == $values[ $key ] ) {
     
    130130
    131131                    case 'date' :
    132                         if ( !empty( $values[$key] ) )
    133                             $values[$key] = strtotime( $values[$key] );
    134 
    135                         update_post_meta( $post_id, $key, $values[$key] );
     132                        if ( !empty( $values[ $key ] ) )
     133                            $values[ $key ] = strtotime( $values[ $key ] );
     134
     135                        update_post_meta( $post_id, $key, $values[ $key ] );
    136136                        break;
    137137
     
    151151     * @return array
    152152     */
    153     function meta_keys ( $meta_group = '' ) {
     153    function meta_keys( $meta_group = '' ) {
    154154
    155155        /*
     
    159159
    160160        switch ( $meta_group ) {
    161             case 'organizer' :
     161            case 'organizer':
    162162                $retval = array (
    163163                    'Organizer Name'                  => 'text',
     
    176176                break;
    177177
    178             case 'venue' :
     178            case 'venue':
    179179                $retval = array (
    180180                    'Venue Name'                      => 'text',
     
    188188                break;
    189189
    190             case 'wordcamp' :
     190            case 'wordcamp':
    191191                $retval = array (
    192192                    'Start Date (YYYY-mm-dd)'         => 'date',
     
    202202                break;
    203203
    204             case 'all' :
    205             default :
     204            case 'all':
     205            default:
    206206                $retval = array(
    207207                    'Start Date (YYYY-mm-dd)'         => 'date',
     
    254254        if ( get_post_type() == WCPT_POST_TYPE_ID ) :
    255255        ?>
    256         <script>
    257             jQuery(document).ready(function($) {
    258                 $('.date-field').datepicker({
    259                     dateFormat: 'yy-mm-dd',
    260                     changeMonth: true,
    261                     changeYear:  true
    262                 });
    263             });
    264         </script>
     256
     257            <script>
     258                jQuery( document ).ready( function( $ ) {
     259                    $( '.date-field' ).datepicker( {
     260                        dateFormat: 'yy-mm-dd',
     261                        changeMonth: true,
     262                        changeYear:  true
     263                    } );
     264                } );
     265            </script>
     266
    265267        <?php
    266268        endif;
     
    279281     * Add some general styling to the admin area
    280282     */
    281     function admin_head () {
     283    function admin_head() {
    282284        if ( !empty( $_GET['post_type'] ) && $_GET['post_type'] == WCPT_POST_TYPE_ID ) : ?>
    283285
     
    295297     * @todo Everything
    296298     */
    297     function user_profile_update ( $user_id ) {
     299    function user_profile_update( $user_id ) {
    298300        if ( !wcpt_has_access() )
    299301            return false;
     
    308310     * @todo Everything
    309311     */
    310     function user_profile_wordcamp ( $profileuser ) {
     312    function user_profile_wordcamp( $profileuser ) {
    311313
    312314        if ( !wcpt_has_access() )
    313315            return false;
    314316
    315 ?>
     317        ?>
     318
    316319        <h3><?php _e( 'WordCamps', 'wcpt' ); ?></h3>
    317320        <table class="form-table">
     
    323326            </tr>
    324327        </table>
    325 <?php
     328
     329        <?php
    326330    }
    327331
     
    334338     * @return array $columns
    335339     */
    336     function column_headers ( $columns ) {
     340    function column_headers( $columns ) {
    337341        $columns = array (
    338342            'cb'               => '<input type="checkbox" />',
     
    355359     * @param int $post_id
    356360     */
    357     function column_data ( $column, $post_id ) {
     361    function column_data( $column, $post_id ) {
    358362        if ( $_GET['post_type'] !== WCPT_POST_TYPE_ID )
    359363            return $column;
     
    388392            case 'wcpt_organizer' :
    389393                echo wcpt_get_wordcamp_organizer_name() ? wcpt_get_wordcamp_organizer_name() : __( 'No Organizer', 'wcpt' );
    390 
    391394                break;
    392395
     
    406409     * @return array $actions
    407410     */
    408     function post_row_actions ( $actions, $post ) {
     411    function post_row_actions( $actions, $post ) {
    409412        if ( WCPT_POST_TYPE_ID == $post->post_type ) {
    410413            unset( $actions['inline hide-if-no-js'] );
     
    653656 * Functions for displaying specific meta boxes
    654657 */
    655 function wcpt_wordcamp_metabox () {
     658function wcpt_wordcamp_metabox() {
    656659    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'wordcamp' );
    657660    wcpt_metabox( $meta_keys );
    658661}
    659662
    660 function wcpt_organizer_metabox () {
     663function wcpt_organizer_metabox() {
    661664    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'organizer' );
    662665    wcpt_metabox( $meta_keys );
    663666}
    664667
    665 function wcpt_venue_metabox () {
     668function wcpt_venue_metabox() {
    666669    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'venue' );
    667670    wcpt_metabox( $meta_keys );
     
    677680 * @since WordCamp Post Type (0.1)
    678681 */
    679 function wcpt_metabox ( $meta_keys ) {
     682function wcpt_metabox( $meta_keys ) {
    680683    global $post_id;
    681684
    682685    foreach ( $meta_keys as $key => $value ) :
    683686        $object_name = wcpt_key_to_str( $key, 'wcpt_' );
    684 ?>
     687
     688    ?>
    685689
    686690        <div class="inside">
     
    693697
    694698            <?php else : ?>
    695             <?php // todo indent the contents (and do other whitespace cleanup) in the next commit. avoid doing here because of diff noise. ?>
    696             <p>
    697                 <strong><?php echo $key; ?></strong>
    698             </p>
    699             <p>
    700                 <label class="screen-reader-text" for="<?php echo $object_name; ?>"><?php echo $key; ?></label>
    701 
    702 <?php           switch ( $value ) {
    703                     case 'text' : ?>
    704 
    705                         <input type="text" size="36" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>" value="<?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?>" />
    706 
    707 <?php                   break;
    708 
    709                     case 'date' :
    710 
    711                         // Quick filter on dates
    712                         if ( $date = get_post_meta( $post_id, $key, true ) ) {
    713                             $date = date( 'Y-m-d', $date );
    714                         }
    715 
    716                         ?>
    717 
    718                         <input type="text" size="36" class="date-field" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>" value="<?php echo $date; ?>" />
    719 
    720 <?php                   break;
    721 
    722                     case 'textarea' : ?>
    723 
    724                         <textarea rows="4" cols="23" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>"><?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?></textarea>
    725 
    726 <?php                   break;
    727 
    728                     default:
    729                         do_action( 'wcpt_metabox_value', $key, $value, $object_name );
    730                         break;
    731                 } ?>
    732 
    733             </p>
     699
     700                <p>
     701                    <strong><?php echo $key; ?></strong>
     702                </p>
     703
     704                <p>
     705                    <label class="screen-reader-text" for="<?php echo $object_name; ?>"><?php echo $key; ?></label>
     706
     707                    <?php switch ( $value ) :
     708                        case 'text' : ?>
     709
     710                            <input type="text" size="36" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>" value="<?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?>" />
     711
     712                        <?php break;
     713                        case 'date' :
     714
     715                            // Quick filter on dates
     716                            if ( $date = get_post_meta( $post_id, $key, true ) ) {
     717                                $date = date( 'Y-m-d', $date );
     718                            }
     719
     720                            ?>
     721
     722                            <input type="text" size="36" class="date-field" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>" value="<?php echo $date; ?>" />
     723
     724                        <?php break;
     725                        case 'textarea' : ?>
     726
     727                            <textarea rows="4" cols="23" name="<?php echo $object_name; ?>" id="<?php echo $object_name; ?>"><?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?></textarea>
     728
     729                        <?php break;
     730
     731                        default:
     732                            do_action( 'wcpt_metabox_value', $key, $value, $object_name );
     733                            break;
     734
     735                    endswitch; ?>
     736                </p>
     737
     738            <?php endif; ?>
    734739        </div>
    735         <?php endif; ?>
    736 
    737 <?php
    738 
    739     endforeach;
     740
     741    <?php endforeach;
    740742}
    741 
    742 ?>
Note: See TracChangeset for help on using the changeset viewer.