WordPress.org

Plugin Directory

Changeset 1042332


Ignore:
Timestamp:
12/11/14 00:16:09 (3 years ago)
Author:
cardiganmedia
Message:

taxonomy slug bug fix

Location:
staffer/trunk
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • staffer/trunk/load-staffer.php

    r1032756 r1042332  
    55    Description: A WordPress plugin that adds staff management and custom staff profile pages. 
    66    Author: Edward R. Jenkins 
    7     Version: 1.3 
     7    Version: 1.3.2 
    88    Author URI: https://edwardrjenkins.com 
    99    Text Domain: staffer 
     
    1717add_action( 'init', 'staffer_load_textdomain' ); 
    1818 
    19 add_action('admin_init', 'staffer_init' ); 
    20 add_action('admin_menu', 'staffer_add_page'); 
    2119// staffer init 
    2220function staffer_init(){ 
     
    2624    register_setting( 'staffer_options', 'staffer', 'staffer_validate' ); 
    2725} 
     26add_action('admin_init', 'staffer_init' ); 
     27 
    2828// adds menu page 
    2929function staffer_add_page() { 
    3030    add_options_page('Staffer Options', 'Staffer Options', 'manage_options', 'staffer', 'staffer_do_page'); 
    3131} 
     32add_action('admin_menu', 'staffer_add_page'); 
     33 
    3234// writes the menu page 
    3335function staffer_do_page() { 
     
    3840        echo '</h4>'; 
    3941        ?> 
    40     <div class="wrap"> 
    41         <h2><?php _e ('Staffer Options Panel', 'staffer'); ?></h2> 
    42         <form method="post" action="options.php"> 
    43             <?php settings_fields('staffer_options'); ?> 
    44             <?php $stafferoptions = get_option('staffer'); ?> 
    45             <table class="form-table"> 
    46                 <tr valign="top"><th scope="row"><?php _e ('Staff Layout', 'staffer'); ?></th> 
    47                 <td><input name="staffer[gridlayout]" type="checkbox" value="1" <?php checked(true, $stafferoptions['gridlayout']); ?> /> 
    48                     <p class="description"><?php _e('Check this to use the staff grid layout.', 'staffer'); ?></p> 
    49                 </td> 
    50                 </tr> 
    51  
    52                 <tr valign="top"><th scope="row"><?php _e ('Excerpt Style', 'staffer'); ?></th> 
    53                 <td> 
    54                 <?php $staffer_estyle = $stafferoptions['estyle']; ?> 
    55                 <select name="staffer[estyle]"> 
    56                     <option value="excerpt" <?php if ($staffer_estyle == "excerpt") echo ('selected="selected"'); ?> ><?php _e ('Excerpt', 'staffer' ); ?></option> 
    57                     <option value="full" <?php if ($staffer_estyle == "full") echo ('selected="selected"'); ?> ><?php _e ('Full', 'staffer' ); ?></option> 
    58                     <option value="none" <?php if ($staffer_estyle == "none") echo ('selected="selected"'); ?> ><?php _e ('Disabled', 'staffer' ); ?></option> 
    59                 </select> 
    60                     <p class="description"><?php _e('Choose your staff listing excerpt style.', 'staffer'); ?></p> 
    61                 </td> 
    62                 </tr> 
    63  
    64                 <tr valign="top"><th scope="row"><?php _e ('Staffer Main Page Description', 'staffer'); ?></th> 
    65                 <td> 
    66                 <?php  
    67                     $text =  $stafferoptions['sdesc']; 
    68                     wp_editor( $text, 'sdesc', array( 'textarea_name' => 'sdesc', 'media_buttons' => true, 'textarea_rows' => '10' ) ); ?> 
    69                     <p class="description"><?php _e('Add a description for the Staffer directory, which will appear below the main directory title.', 'staffer'); ?></p> 
    70                 </td> 
    71                 </tr> 
    72                 <tr valign="top"><th scope="row"><?php _e ('Listings per page', 'staffer'); ?></th> 
    73                 <td><input type="number" size="80" max="99" name="staffer[perpage]" value='<?php echo $stafferoptions['perpage']; ?>' /> 
    74                     <p class="description"><?php _e('Set the number of staff members per page. Leave blank to inherit the Settings->Reading.', 'staffer'); ?></p> 
    75                 </td> 
    76                 </tr> 
    77                 <tr valign="top"><th scope="row"><?php _e ('Staffer Page Title', 'staffer'); ?></th> 
    78                 <td><input type="text" size="80" name="staffer[ptitle]" value='<?php echo $stafferoptions['ptitle']; ?>' /> 
    79                     <p class="description"><?php _e('Set a custom Staffer page title, if desired. The default title is <code>Staff</code>. This title will be used as the archive page title and within breadcrumbs. Leave blank to use the default.', 'staffer'); ?></p> 
    80                 </td> 
    81                 </tr> 
    82                 <tr valign="top"><th scope="row"><?php _e ('Staffer Label', 'staffer'); ?></th> 
    83                 <td><input type="text" size="80" name="staffer[label]" value='<?php if ( isset ($stafferoptions['label'] ) ) { echo $stafferoptions['label']; } ?>' /> 
    84                     <p class="description"><?php _e('Set a custom label, if desired. This is shown in the admin panel and is used in the <code>title</code> tag. The default label is <code>Staff</code>. Leave blank to use the default.', 'staffer'); ?></p> 
    85                 </td> 
    86                 </tr>                
    87                 <tr valign="top"><th scope="row"><?php _e ('Staffer URL slug', 'staffer'); ?></th> 
    88                 <td><input type="text" size="80" name="staffer[slug]" value='<?php echo $stafferoptions['slug']; ?>' /> 
    89                     <p class="description"><?php _e('Set a custom URL slug, if desired. The default slug is <code>staff</code>.<strong>Notice:</strong> Use lowercase only, and use no spaces, i.e., instead of using <code>Staff Pages</code>, use <code>staff-pages</code>. Leave blank to use the default.', 'staffer'); ?></p> 
    90                 </td> 
    91                 </tr> 
    92                 <tr valign="top"><th scope="row"><?php _e ('Disable CSS', 'staffer'); ?></th> 
    93                 <td><input name="staffer[disablecss]" type="checkbox" value="1" <?php checked(true, $stafferoptions['disablecss']); ?> /> 
    94                     <p class="description"><?php _e('Check this box to disable all Staffer CSS.', 'staffer'); ?></p> 
    95                 </td> 
    96                 </tr> 
    97                 <tr valign="top"><th scope="row"><?php _e ('Use custom wrappers', 'staffer'); ?></th> 
    98                 <td><input name="staffer[customwrapper]" type="checkbox" value="1" <?php checked(true, $stafferoptions['customwrapper']); ?> /> 
    99                     <p class="description"><?php _e('Check this box and enter your wrappers below to use custom content wrappers. See the documentation for details. You may need to use custom wrappers if Staffer pages do not flow well with your theme.', 'staffer'); ?></p> 
    100                 </td> 
    101                 </tr> 
    102                 <tr valign="top"><th scope="row"><?php _e ('Custom start wrapper', 'staffer'); ?></th> 
    103                 <td><input type="text" size="80" name="staffer[startwrapper]" value='<?php echo $stafferoptions['startwrapper']; ?>' /> 
    104                     <p class="description"><?php _e('Enter your custom start wrapper.', 'staffer'); ?></p> 
    105                 </td> 
    106                 </tr> 
    107                 <tr valign="top"><th scope="row"><?php _e ('Custom end wrapper', 'staffer'); ?></th> 
    108                 <td><input type="text" size="80" name="staffer[endwrapper]" value='<?php echo $stafferoptions['endwrapper']; ?>' /> 
    109                     <p class="description"><?php _e('Enter your custom ending wrapper. This should close out the wrapper started above.', 'staffer'); ?></p> 
    110                 </td> 
    111                 </tr> 
    112                 <tr valign="top"><th scope="row"><?php _e ('Custom CSS'); ?></th> 
    113                 <td> 
    114                 <textarea rows="20" class="large-text" type="text" name="staffer[customcss]" cols="50" rows="10" /><?php echo $stafferoptions['customcss']; ?></textarea> 
    115                 <p class="description"><?php _e('Input your custom style rules here.', 'staffer'); ?></p> 
    116                 </td> 
    117                 </tr> 
    118             </table> 
    119             <p class="submit"> 
    120             <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'staffer') ?>" /> 
    121             </p> 
    122         </form> 
    123  
    124         <?php esc_attr_e('Thank you for using Staffer. A lot of time went into development. Donations small or large are always appreciated.' , 'staffer'); ?></p> 
    125         <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post"> 
    126             <input type="hidden" name="cmd" value="_s-xclick"> 
    127             <input type="hidden" name="hosted_button_id" value="QD8ECU2CY3N8J"> 
    128             <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
    129             <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
    130         </form> 
    131     </div> 
     42        <div class="wrap"> 
     43            <h2><?php _e ('Staffer Options Panel', 'staffer'); ?></h2> 
     44            <form method="post" action="options.php"> 
     45                <?php settings_fields('staffer_options'); ?> 
     46                <?php $stafferoptions = get_option('staffer'); ?> 
     47                <table class="form-table"> 
     48                    <tr valign="top"><th scope="row"><?php _e ('Staff Layout', 'staffer'); ?></th> 
     49                    <td><input name="staffer[gridlayout]" type="checkbox" value="1" <?php checked(true, $stafferoptions['gridlayout']); ?> /> 
     50                        <p class="description"><?php _e('Check this to use the staff grid layout.', 'staffer'); ?></p> 
     51                    </td> 
     52                    </tr> 
     53 
     54                    <tr valign="top"><th scope="row"><?php _e ('Excerpt Style', 'staffer'); ?></th> 
     55                    <td> 
     56                    <?php $staffer_estyle = $stafferoptions['estyle']; ?> 
     57                    <select name="staffer[estyle]"> 
     58                        <option value="excerpt" <?php if ($staffer_estyle == "excerpt") echo ('selected="selected"'); ?> ><?php _e ('Excerpt', 'staffer' ); ?></option> 
     59                        <option value="full" <?php if ($staffer_estyle == "full") echo ('selected="selected"'); ?> ><?php _e ('Full', 'staffer' ); ?></option> 
     60                        <option value="none" <?php if ($staffer_estyle == "none") echo ('selected="selected"'); ?> ><?php _e ('Disabled', 'staffer' ); ?></option> 
     61                    </select> 
     62                        <p class="description"><?php _e('Choose your staff listing excerpt style.', 'staffer'); ?></p> 
     63                    </td> 
     64                    </tr> 
     65 
     66                    <tr valign="top"><th scope="row"><?php _e ('Staffer Main Page Description', 'staffer'); ?></th> 
     67                    <td> 
     68                    <?php  
     69                        $text =  $stafferoptions['sdesc']; 
     70                        wp_editor( $text, 'sdesc', array( 'textarea_name' => 'sdesc', 'media_buttons' => true, 'textarea_rows' => '10' ) ); ?> 
     71                        <p class="description"><?php _e('Add a description for the Staffer directory, which will appear below the main directory title.', 'staffer'); ?></p> 
     72                    </td> 
     73                    </tr> 
     74                    <tr valign="top"><th scope="row"><?php _e ('Listings per page', 'staffer'); ?></th> 
     75                    <td><input type="number" size="80" max="99" name="staffer[perpage]" value='<?php echo $stafferoptions['perpage']; ?>' /> 
     76                        <p class="description"><?php _e('Set the number of staff members per page. Leave blank to inherit the Settings->Reading.', 'staffer'); ?></p> 
     77                    </td> 
     78                    </tr> 
     79                    <tr valign="top"><th scope="row"><?php _e ('Staffer Page Title', 'staffer'); ?></th> 
     80                    <td><input type="text" size="80" name="staffer[ptitle]" value='<?php echo $stafferoptions['ptitle']; ?>' /> 
     81                        <p class="description"><?php _e('Set a custom Staffer page title, if desired. The default title is <code>Staff</code>. This title will be used as the archive page title and within breadcrumbs. Leave blank to use the default.', 'staffer'); ?></p> 
     82                    </td> 
     83                    </tr> 
     84                    <tr valign="top"><th scope="row"><?php _e ('Staffer Label', 'staffer'); ?></th> 
     85                    <td><input type="text" size="80" name="staffer[label]" value='<?php if ( isset ($stafferoptions['label'] ) ) { echo $stafferoptions['label']; } ?>' /> 
     86                        <p class="description"><?php _e('Set a custom label, if desired. This is shown in the admin panel and is used in the <code>title</code> tag. The default label is <code>Staff</code>. Leave blank to use the default.', 'staffer'); ?></p> 
     87                    </td> 
     88                    </tr>                
     89                    <tr valign="top"><th scope="row"><?php _e ('Staffer URL slug', 'staffer'); ?></th> 
     90                    <td><input type="text" size="80" name="staffer[slug]" value='<?php echo $stafferoptions['slug']; ?>' /> 
     91                        <p class="description"><?php _e('Set a custom URL slug, if desired. The default slug is <code>staff</code>.<strong>Notice:</strong> Use lowercase only, and use no spaces, i.e., instead of using <code>Staff Pages</code>, use <code>staff-pages</code>. Leave blank to use the default.', 'staffer'); ?></p> 
     92                    </td> 
     93                    </tr> 
     94                    <tr valign="top"><th scope="row"><?php _e ('Disable CSS', 'staffer'); ?></th> 
     95                    <td><input name="staffer[disablecss]" type="checkbox" value="1" <?php checked(true, $stafferoptions['disablecss']); ?> /> 
     96                        <p class="description"><?php _e('Check this box to disable all Staffer CSS.', 'staffer'); ?></p> 
     97                    </td> 
     98                    </tr> 
     99                    <tr valign="top"><th scope="row"><?php _e ('Use custom wrappers', 'staffer'); ?></th> 
     100                    <td><input name="staffer[customwrapper]" type="checkbox" value="1" <?php checked(true, $stafferoptions['customwrapper']); ?> /> 
     101                        <p class="description"><?php _e('Check this box and enter your wrappers below to use custom content wrappers. See the documentation for details. You may need to use custom wrappers if Staffer pages do not flow well with your theme.', 'staffer'); ?></p> 
     102                    </td> 
     103                    </tr> 
     104                    <tr valign="top"><th scope="row"><?php _e ('Custom start wrapper', 'staffer'); ?></th> 
     105                    <td><input type="text" size="80" name="staffer[startwrapper]" value='<?php echo $stafferoptions['startwrapper']; ?>' /> 
     106                        <p class="description"><?php _e('Enter your custom start wrapper.', 'staffer'); ?></p> 
     107                    </td> 
     108                    </tr> 
     109                    <tr valign="top"><th scope="row"><?php _e ('Custom end wrapper', 'staffer'); ?></th> 
     110                    <td><input type="text" size="80" name="staffer[endwrapper]" value='<?php echo $stafferoptions['endwrapper']; ?>' /> 
     111                        <p class="description"><?php _e('Enter your custom ending wrapper. This should close out the wrapper started above.', 'staffer'); ?></p> 
     112                    </td> 
     113                    </tr> 
     114                    <tr valign="top"><th scope="row"><?php _e ('Custom CSS'); ?></th> 
     115                    <td> 
     116                    <textarea rows="20" class="large-text" type="text" name="staffer[customcss]" cols="50" rows="10" /><?php echo $stafferoptions['customcss']; ?></textarea> 
     117                    <p class="description"><?php _e('Input your custom style rules here.', 'staffer'); ?></p> 
     118                    </td> 
     119                    </tr> 
     120                </table> 
     121                <p class="submit"> 
     122                <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'staffer') ?>" /> 
     123                </p> 
     124            </form> 
     125 
     126            <?php esc_attr_e('Thank you for using Staffer. A lot of time went into development. Donations small or large are always appreciated.' , 'staffer'); ?></p> 
     127            <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post"> 
     128                <input type="hidden" name="cmd" value="_s-xclick"> 
     129                <input type="hidden" name="hosted_button_id" value="QD8ECU2CY3N8J"> 
     130                <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> 
     131                <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
     132            </form> 
     133        </div> 
    132134    <?php    
    133135    } 
     136 
    134137// sanitize and validate input 
    135138function staffer_validate($input) { 
     
    166169function staffer_taxonomy () { 
    167170    $stafferoptions = get_option ('staffer'); 
    168     $stafferslug = $stafferoptions['slug']; 
    169     if ( $stafferslug == '' ) { 
    170         $stafferslug = 'department'; 
     171    if ( $stafferoptions['slug'] == '' ) { 
     172        $stafferslug = 'staff'; 
     173    } else { 
     174        $stafferslug = $stafferoptions['slug']; 
    171175    } 
    172176    $taxslug = $stafferslug . '/department'; 
     
    185189add_action ('init', 'staffer_taxonomy'); 
    186190 
    187     // custom post type for staff 
    188     function create_staff_cpt_staffer() { 
    189         $stafferoptions = get_option ('staffer'); 
    190         $stafferslug = $stafferoptions['slug']; 
    191         // fixes title tag issue and adds label option 
    192         if ( !empty ($stafferoptions['label'] ) ) { 
    193         $stafferlabel = $stafferoptions['label']; 
    194         } else { 
    195         $stafferlabel = 'Staff'; 
    196         } 
    197         $rewrite = array( 
    198         'slug'                => $stafferslug, 
    199         'with_front'          => true, 
    200         'pages'               => true, 
    201         'feeds'               => true, 
    202         ); 
    203         register_post_type('staff', array( 
    204             'labels' => array( 
    205             'name' => $stafferlabel, 
    206             // future release 'taxonomy' => 'department', 
    207             'singular_name' => __('Staff Member'), 
    208             'add_new_item' => __('Add New Staff Member'), 
    209             'edit_item' => 'Edit Staff Member', 
    210             'new_item' => 'New Staff Member', 
    211             'all_items' => 'All Staff Members', 
    212             'view_item' => 'View Staff Member', 
    213             'search_items' => 'Search Staff Members', 
    214             'not_found' => 'No Staff Members Found', 
    215             'not_found_in_trash' => 'No Staff Members in Trash', 
    216             ), 
    217             'public' => true, 
    218             'has_archive' => true, 
    219             'show_in_menu' => true, 
    220             'menu_order' => '4', 
    221             'rewrite' => $rewrite, 
    222             'menu_icon' => 'dashicons-id', 
    223             'supports' => array( 
    224                 'title', 
    225                 'editor', 
    226                 'revisions', 
    227                 'custom-fields', 
    228                 'thumbnail', 
    229                 'excerpt' 
    230                 ) 
    231                 )); 
    232                 } 
     191// custom post type for staff 
     192function create_staff_cpt_staffer() { 
     193    $stafferoptions = get_option ('staffer'); 
     194    $stafferslug = $stafferoptions['slug']; 
     195    // fixes title tag issue and adds label option 
     196    if ( !empty ($stafferoptions['label'] ) ) { 
     197    $stafferlabel = $stafferoptions['label']; 
     198    } else { 
     199    $stafferlabel = 'Staff'; 
     200    } 
     201    $rewrite = array( 
     202    'slug'                => $stafferslug, 
     203    'with_front'          => true, 
     204    'pages'               => true, 
     205    'feeds'               => true, 
     206    ); 
     207    register_post_type('staff', array( 
     208        'labels' => array( 
     209        'name' => $stafferlabel, 
     210        // future release 'taxonomy' => 'department', 
     211        'singular_name' => __('Staff Member'), 
     212        'add_new_item' => __('Add New Staff Member'), 
     213        'edit_item' => 'Edit Staff Member', 
     214        'new_item' => 'New Staff Member', 
     215        'all_items' => 'All Staff Members', 
     216        'view_item' => 'View Staff Member', 
     217        'search_items' => 'Search Staff Members', 
     218        'not_found' => 'No Staff Members Found', 
     219        'not_found_in_trash' => 'No Staff Members in Trash', 
     220        ), 
     221        'public' => true, 
     222        'has_archive' => true, 
     223        'show_in_menu' => true, 
     224        'menu_order' => '4', 
     225        'rewrite' => $rewrite, 
     226        'menu_icon' => 'dashicons-id', 
     227        'supports' => array( 
     228            'title', 
     229            'editor', 
     230            'revisions', 
     231            'custom-fields', 
     232            'thumbnail', 
     233            'excerpt' 
     234            ) 
     235            )); 
     236            } 
    233237add_action ('init', 'create_staff_cpt_staffer' ); 
    234238 
    235239// adds meta box to member post types 
    236  
    237 add_action('add_meta_boxes', 'staffer_staff_meta_box', 0); 
    238  
    239 add_action('save_post_staff', 'staffer_staff_save_postdata'); 
    240 // Adds a box to the main column on the Post and Page edit screens 
    241240function staffer_staff_meta_box() { 
    242241                $post_types = array( 
     
    247246                        } 
    248247        } 
     248add_action('add_meta_boxes', 'staffer_staff_meta_box', 0); 
     249 
    249250// prints the staffer post type boxes 
    250251function staffer_staff_role_box($post) { 
    251                 // Use nonce for verification 
    252                 wp_nonce_field(plugin_basename(__FILE__), 'cpt_noncename'); 
    253                 // Use get_post_meta to retrieve an existing value from the database and use the value for the form 
    254                 $value = get_post_meta($post->ID, 'staffer_staff_title', true); 
    255                 echo '<label for="staffer_staff_title"><strong>Title</strong></label>'; 
    256                 echo '<input id="staffer_staff_title" name="staffer_staff_title" size="28" value="' . esc_attr($value) . '"><br>'; 
    257                 $value = get_post_meta($post->ID, 'staffer_staff_fb', true); 
    258                 echo '<label for="staffer_staff_fb"><strong>Facebook</strong></label>'; 
    259                 echo '<input id="staffer_staff_fb" name="staffer_staff_fb" size="28" value="' . esc_attr($value) . '"><br>'; 
    260                 $value = get_post_meta($post->ID, 'staffer_staff_gplus', true); 
    261                 echo '<label for="staffer_staff_gplus"><strong>Google+</strong></label>'; 
    262                 echo '<input id="staffer_staff_gplus" name="staffer_staff_gplus" size="28" value="' . esc_attr($value) . '"><br>'; 
    263                 $value = get_post_meta($post->ID, 'staffer_staff_twitter', true); 
    264                 echo '<label for="staffer_staff_twitter"><strong>Twitter</strong></label>'; 
    265                 echo '<input id="staffer_staff_twitter" name="staffer_staff_twitter" size="28" value="' . esc_attr($value) . '"><br>'; 
    266                 $value = get_post_meta($post->ID, 'staffer_staff_linkedin', true); 
    267                 echo '<label for="staffer_staff_linkedin"><strong>LinkedIn</strong></label>'; 
    268                 echo '<input id="staffer_staff_linkedin" name="staffer_staff_linkedin" size="28" value="' . esc_attr($value) . '"><br>'; 
    269                 $value = get_post_meta($post->ID, 'staffer_staff_website', true); 
    270                 echo '<label for="staffer_staff_website"><strong>Website</strong></label>'; 
    271                 echo '<input id="staffer_staff_website" name="staffer_staff_website" size="28" value="' . esc_attr($value) . '"><br>'; 
    272                 $value = get_post_meta($post->ID, 'staffer_staff_email', true); 
    273                 echo '<label for="staffer_staff_email"><strong>Email</strong></label>'; 
    274                 echo '<input id="staffer_staff_email" name="staffer_staff_email" size="28" value="' . esc_attr($value) . '"><br>'; 
    275                 $value = get_post_meta($post->ID, 'staffer_staff_phone', true); 
    276                 echo '<label for="staffer_staff_phone"><strong>Phone Number</strong></label>'; 
    277                 echo '<input id="staffer_staff_phone" name="staffer_staff_phone" size="28" value="' . esc_attr($value) . '"><br>'; 
     252    // Use nonce for verification 
     253    wp_nonce_field(plugin_basename(__FILE__), 'cpt_noncename'); 
     254    // Use get_post_meta to retrieve an existing value from the database and use the value for the form 
     255    $value = get_post_meta($post->ID, 'staffer_staff_title', true); 
     256    echo '<label for="staffer_staff_title"><strong>Title</strong></label>'; 
     257    echo '<input id="staffer_staff_title" name="staffer_staff_title" size="28" value="' . esc_attr($value) . '"><br>'; 
     258    $value = get_post_meta($post->ID, 'staffer_staff_fb', true); 
     259    echo '<label for="staffer_staff_fb"><strong>Facebook</strong></label>'; 
     260    echo '<input id="staffer_staff_fb" name="staffer_staff_fb" size="28" value="' . esc_attr($value) . '"><br>'; 
     261    $value = get_post_meta($post->ID, 'staffer_staff_gplus', true); 
     262    echo '<label for="staffer_staff_gplus"><strong>Google+</strong></label>'; 
     263    echo '<input id="staffer_staff_gplus" name="staffer_staff_gplus" size="28" value="' . esc_attr($value) . '"><br>'; 
     264    $value = get_post_meta($post->ID, 'staffer_staff_twitter', true); 
     265    echo '<label for="staffer_staff_twitter"><strong>Twitter</strong></label>'; 
     266    echo '<input id="staffer_staff_twitter" name="staffer_staff_twitter" size="28" value="' . esc_attr($value) . '"><br>'; 
     267    $value = get_post_meta($post->ID, 'staffer_staff_linkedin', true); 
     268    echo '<label for="staffer_staff_linkedin"><strong>LinkedIn</strong></label>'; 
     269    echo '<input id="staffer_staff_linkedin" name="staffer_staff_linkedin" size="28" value="' . esc_attr($value) . '"><br>'; 
     270    $value = get_post_meta($post->ID, 'staffer_staff_website', true); 
     271    echo '<label for="staffer_staff_website"><strong>Website</strong></label>'; 
     272    echo '<input id="staffer_staff_website" name="staffer_staff_website" size="28" value="' . esc_attr($value) . '"><br>'; 
     273    $value = get_post_meta($post->ID, 'staffer_staff_email', true); 
     274    echo '<label for="staffer_staff_email"><strong>Email</strong></label>'; 
     275    echo '<input id="staffer_staff_email" name="staffer_staff_email" size="28" value="' . esc_attr($value) . '"><br>'; 
     276    $value = get_post_meta($post->ID, 'staffer_staff_phone', true); 
     277    echo '<label for="staffer_staff_phone"><strong>Phone Number</strong></label>'; 
     278    echo '<input id="staffer_staff_phone" name="staffer_staff_phone" size="28" value="' . esc_attr($value) . '"><br>'; 
    278279        } 
    279280// saves the staffer post type details 
    280281function staffer_staff_save_postdata($post_id) { 
    281                 if (!current_user_can('edit_page', $post_id)) { 
    282                                 return; 
    283                         } 
    284                 else { 
    285                                 if (!current_user_can('edit_post', $post_id)) 
    286                                                 return; 
    287                         } 
    288                 if (!isset($_POST['cpt_noncename']) || !wp_verify_nonce($_POST['cpt_noncename'], plugin_basename(__FILE__))) 
    289                                 return; 
    290                 // get ID and save data 
    291                 $post_ID      = $_POST['post_ID']; 
    292                 //sanitize user input 
    293                 $title = ($_POST['staffer_staff_title']); 
    294                 $fb = ($_POST['staffer_staff_fb']); 
    295                 $gplus = ($_POST['staffer_staff_gplus']); 
    296                 $twitter = ($_POST['staffer_staff_twitter']); 
    297                 $linkedin = ($_POST['staffer_staff_linkedin']); 
    298                 $website = ($_POST['staffer_staff_website']); 
    299                 $email = ($_POST['staffer_staff_email']); 
    300                 $phone = ($_POST['staffer_staff_phone']); 
    301                 update_post_meta($post_ID, 'staffer_staff_title', $title); 
    302                 update_post_meta($post_ID, 'staffer_staff_fb', $fb); 
    303                 update_post_meta($post_ID, 'staffer_staff_gplus', $gplus); 
    304                 update_post_meta($post_ID, 'staffer_staff_twitter', $twitter); 
    305                 update_post_meta($post_ID, 'staffer_staff_linkedin', $linkedin); 
    306                 update_post_meta($post_ID, 'staffer_staff_website', $website); 
    307                 update_post_meta($post_ID, 'staffer_staff_email', $email); 
    308                 update_post_meta($post_ID, 'staffer_staff_phone', $phone); 
    309         } 
     282    if (!current_user_can('edit_page', $post_id)) { 
     283                    return; 
     284            } 
     285    else { 
     286                    if (!current_user_can('edit_post', $post_id)) 
     287                                    return; 
     288            } 
     289    if (!isset($_POST['cpt_noncename']) || !wp_verify_nonce($_POST['cpt_noncename'], plugin_basename(__FILE__))) 
     290                    return; 
     291    // get ID and save data 
     292    $post_ID      = $_POST['post_ID']; 
     293    //sanitize user input 
     294    $title = ($_POST['staffer_staff_title']); 
     295    $fb = ($_POST['staffer_staff_fb']); 
     296    $gplus = ($_POST['staffer_staff_gplus']); 
     297    $twitter = ($_POST['staffer_staff_twitter']); 
     298    $linkedin = ($_POST['staffer_staff_linkedin']); 
     299    $website = ($_POST['staffer_staff_website']); 
     300    $email = ($_POST['staffer_staff_email']); 
     301    $phone = ($_POST['staffer_staff_phone']); 
     302    update_post_meta($post_ID, 'staffer_staff_title', $title); 
     303    update_post_meta($post_ID, 'staffer_staff_fb', $fb); 
     304    update_post_meta($post_ID, 'staffer_staff_gplus', $gplus); 
     305    update_post_meta($post_ID, 'staffer_staff_twitter', $twitter); 
     306    update_post_meta($post_ID, 'staffer_staff_linkedin', $linkedin); 
     307    update_post_meta($post_ID, 'staffer_staff_website', $website); 
     308    update_post_meta($post_ID, 'staffer_staff_email', $email); 
     309    update_post_meta($post_ID, 'staffer_staff_phone', $phone); 
     310} 
     311add_action('save_post_staff', 'staffer_staff_save_postdata'); 
     312 
    310313// sets template override for custom template use 
    311314function staffer_staff_templates( $template ) { 
     
    352355    // flush rewrite rules to prevent 404s 
    353356    flush_rewrite_rules(); 
    354  
    355357} 
    356358register_activation_hook( __FILE__, 'staffer_activate' ); 
     
    361363register_deactivation_hook( __FILE__, 'staffer_deactivate' ); 
    362364 
     365//enables thumbnail support if the theme does not 
    363366function staffer_thumbnail_check() { 
    364367    if ( ! current_theme_supports ('post-thumbnails') ) { 
     
    388391add_action('admin_menu', 'staffer_admin_menu'); 
    389392 
    390 // allows modification of posts per page without affecting non-staffer pages 
    391  
     393// pre get posts allows modification of posts per page without affecting non-staffer pages 
    392394function staffer_per_page_mod($query) { 
    393395    $stafferoptions = get_option ('staffer'); 
     
    402404 
    403405    } 
    404     $stafferoptions = get_option ('staffer'); 
    405     $perpage = $stafferoptions['perpage']; 
    406     if ($perpage != '' ) { 
    407         add_action ('pre_get_posts', 'staffer_per_page_mod' ); 
    408     } 
     406 
     407$stafferoptions = get_option ('staffer'); 
     408$perpage = $stafferoptions['perpage']; 
     409 
     410// if per page option is set, hooks into pre get posts 
     411if ($perpage != '' ) { 
     412    add_action ('pre_get_posts', 'staffer_per_page_mod' ); 
     413} 
  • staffer/trunk/readme.txt

    r1032755 r1042332  
    5555 
    5656== Changelog == 
     57= 1.3.1 = 
     58= December 10, 2014 = 
     59* fixed department slug 404 issue 
    5760= 1.3 = 
    5861= November 25, 2014 = 
Note: See TracChangeset for help on using the changeset viewer.