WordPress.org

Plugin Directory

Changeset 1699378


Ignore:
Timestamp:
07/20/17 06:57:49 (3 months ago)
Author:
petersplugins
Message:

v 1.4 DEV - current dev state

Location:
smart-user-slug-hider/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smart-user-slug-hider/trunk/inc/class-smart-user-slug-hider.php

    r1697491 r1699378  
    3737      $this->plugin_name = 'smart User Slug Hider'; 
    3838      $this->plugin_slug = 'smart-user-slug-hider'; 
    39       $this->version = '1.3'; 
     39      $this->version = '1.4 DEV'; 
    4040      $this->init(); 
    4141 
     
    5454            add_action( 'init', array( $this, 'add_text_domain' ) ); 
    5555      add_action( 'pre_get_posts', array( $this, 'alter_query' ), 99 ); 
     56      add_action( 'bp_include', array( $this, 'activate_buddypress_support' ) ); 
     57       
    5658      add_action( 'admin_menu', array( $this, 'add_info_page' ) ); 
    5759            add_action( 'admin_head', array( $this, 'admin_css' ) ); 
     
    5961      add_filter( 'plugin_action_links_' . plugin_basename( $this->_file ), array( $this, 'add_settings_links' ) ); 
    6062            add_filter( 'author_link', array( $this, 'alter_link' ), 99, 3 ); 
    61       add_filter( 'bp_core_get_user_domain', array( $this, 'alter_link_buddypress' ), 99, 4 ); 
    62       add_filter ('bp_core_get_userid', array( $this, 'get_user_buddypress' ), 99, 2); 
    63       add_filter ('bp_core_get_userid_from_nicename', array( $this, 'get_user_buddypress' ), 99, 2); 
    64  
    6563 
    6664      add_shortcode( 'smart_user_slug', array( $this, 'shortcode_smart_user_slug' ) ); 
     
    7270 
    7371    /** 
     72         * Add support for BudyPress 
     73     * used by bp_include action, which only fires if BuddyPress is active 
     74         */ 
     75    function activate_buddypress_support() { 
     76      add_filter( 'bp_core_get_user_domain', array( $this, 'alter_link_buddypress' ), 99, 4 ); 
     77      add_filter ( 'bp_core_get_userid', array( $this, 'get_user_buddypress' ), 99, 2 ); 
     78      add_filter ( 'bp_core_get_userid_from_nicename', array( $this, 'get_user_buddypress' ), 99, 2 ); 
     79      add_filter ( 'bp_core_set_uri_globals_member_slug', array( $this, 'alter_query_buddypress' ), 99, 1 ); 
     80      remove_action( 'pre_get_posts', array( $this, 'alter_query' ), 99 ); 
     81    } 
     82     
     83     
     84    /** 
    7485         * replace author name in author link to encrypted value 
    7586     * used by author_link filter 
     
    116127    /** 
    117128         * if a author name is queried we have to decrypt it 
    118      * used by pre_get_posts filter 
     129     * used by pre_get_posts action 
    119130         */ 
    120131    function alter_query( $query ) { 
    121        
    122        
     132            
    123133      if ( $query->is_author() && $query->query_vars['author_name'] != '' ) { 
    124134         
     
    149159       
    150160      return; 
     161       
     162    } 
     163     
     164     
     165    /** 
     166         * decrypt userslug for BuddyPress 
     167     * used by bp_core_set_uri_globals_member_slug filter 
     168     * WP core pre_get_posts does not work if BuddyPress Root Profiles are enabled 
     169         */ 
     170    function alter_query_buddypress( $userslug ) { 
     171       
     172      if ( ctype_xdigit( $userslug ) ) { 
     173         
     174        $userslug = $this->decrypt( $userslug ); 
     175         
     176        if ( ! bp_is_username_compatibility_mode() ) { 
     177           
     178          $user = get_user_by( 'id', $userslug ); 
     179           
     180          if ( $user ) { 
     181             
     182            $userslug = $user->user_nicename; 
     183          } 
     184           
     185        }  
     186         
     187      } 
     188       
     189      return $userslug; 
    151190       
    152191    } 
  • smart-user-slug-hider/trunk/smart-user-slug-hider.php

    r1697491 r1699378  
    1010 * Plugin URI: http://petersplugins.com/free-wordpress-plugins/smart-user-slug-hider 
    1111 * Description: Hide usernames in author pages URLs to enhance security 
    12  * Version: 1.3 
     12 * Version: 1.4 DEV 
    1313 * Author: Peter Raschendorfer 
    1414 * Author URI: http://petersplugins.com 
Note: See TracChangeset for help on using the changeset viewer.