WordPress.org

Plugin Directory

Changeset 550142


Ignore:
Timestamp:
05/29/12 07:23:58 (23 months ago)
Author:
cnorris23
Message:

Improve auto-update settings, and respect those settings in the auto-update functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • edit-author-slug/trunk/includes/admin-functions.php

    r550129 r550142  
    182182 
    183183/** 
     184 * Can the current user edit the author slug? 
     185 * 
     186 * @since 0.8.0 
     187 * 
     188 * @uses is_super_admin() To check if super admin 
     189 * @uses current_user_can() To check for 'edit_users' and 'edit_author_slug' caps 
     190 * @uses apply_filters() To call 'ba_eas_can_edit_author_slug' hook 
     191 * 
     192 * @return bool True if edit privileges. Defaults to false. 
     193 */ 
     194function ba_eas_do_auto_update() { 
     195 
     196    // Default to false 
     197    $retval = false; 
     198 
     199    $retval = (bool) get_option( '_ba_eas_do_auto_update', '0' ); 
     200 
     201    return apply_filters( 'ba_eas_do_auto_update', $retval ); 
     202} 
     203 
     204/** 
    184205 * Auto-update the user_nicename for a given user. 
    185206 * 
     
    199220 
    200221    if ( false === $bulk ) { 
     222        // Should we auto-update 
     223        if ( !ba_eas_do_auto_update() ) 
     224            return; 
     225 
    201226        // Get WP_User object 
    202227        $user = get_userdata( $user ); 
     
    501526 
    502527    // Add the default user nicename section 
    503     add_settings_section( 'ba_eas_default_user_nicename', __( 'Author Slug Creation', 'edit-author-slug' ), 'ba_eas_admin_setting_callback_default_user_nicename_section', 'edit-author-slug' ); 
     528    add_settings_section( 'ba_eas_auto_update', __( 'Automatic Author Slug Creation', 'edit-author-slug' ), 'ba_eas_admin_setting_callback_auto_update_section', 'edit-author-slug' ); 
     529 
     530    // Auto-update on/off 
     531    add_settings_field( '_ba_eas_do_auto_update', __( 'Automatically Update', 'edit-author-slug' ), 'ba_eas_admin_setting_callback_do_auto_update', 'edit-author-slug', 'ba_eas_auto_update' ); 
     532    register_setting( 'edit-author-slug', '_ba_eas_do_auto_update' ); 
    504533 
    505534    // Default user nicename setting 
    506     add_settings_field( '_ba_eas_default_user_nicename', __( 'Author Base', 'edit-author-slug' ), 'ba_eas_admin_setting_callback_default_user_nicename', 'edit-author-slug', 'ba_eas_default_user_nicename' ); 
     535    add_settings_field( '_ba_eas_default_user_nicename', __( 'Author Base', 'edit-author-slug' ), 'ba_eas_admin_setting_callback_default_user_nicename', 'edit-author-slug', 'ba_eas_auto_update' ); 
    507536    register_setting( 'edit-author-slug', '_ba_eas_default_user_nicename' ); 
    508537} 
     
    526555 * @since 0.9.0 
    527556 */ 
    528 function ba_eas_admin_setting_callback_default_user_nicename_section() { 
     557function ba_eas_admin_setting_callback_auto_update_section() { 
    529558?> 
    530559 
    531     <p><?php _e( 'Set the default Author Slug structure for new users', 'edit-author-slug' ); ?></p> 
     560    <p><?php _e( "Allow Author Slugs to be automatically update, and set the default Author Slug structure for users. Automatic updating will only occur when a user can't edit Author Slugs own their own.<br />**WARNING** This could have SEO repercussions if users update their profiles frequently, and it will override any manual editing of the Author Slug you may have previously done.", 'edit-author-slug' ); ?></p> 
    532561 
    533562<?php 
     
    551580 
    552581/** 
     582 * Add auto-update checkbox. 
     583 * 
     584 * @since 0.9.0 
     585 * 
     586 * @uses get_option() To get the auto-update option 
     587 */ 
     588function ba_eas_admin_setting_callback_do_auto_update() { 
     589    $do_auto_update = (int) get_option( '_ba_eas_do_auto_update', '0' ); 
     590 
     591?> 
     592 
     593    <input name="_ba_eas_do_auto_update" id="_ba_eas_do_auto_update" value="1"<?php checked( $do_auto_update, '1' ); ?>type="checkbox"> 
     594    <label for="_ba_eas_do_auto_update">Automatically update Author Slug when a user updates their profile</label> 
     595 
     596<?php 
     597} 
     598 
     599/** 
    553600 * Add default user nicename options. 
    554601 * 
     
    556603 * 
    557604 * @uses get_option() To get the default user nicename 
    558  * @uses apply_filters() To call 'ba_eas_admin_setting_callback_default_user_nicename_list' hook 
     605 * @uses apply_filters() To call 'ba_eas_default_user_nicename_options_list' hook 
    559606 * @uses esc_attr_e() To sanitize the nicename options 
    560607 */ 
Note: See TracChangeset for help on using the changeset viewer.