This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Before sql query is generated, intercept `query_vars` and set `count_total` to false | |
| * to prevent `SQL_CALC_FOUND_ROWS` from being added to the sql query. | |
| * Also set our new `query_vars` attribute to true to track if count is required. | |
| */ | |
| add_action( 'pre_get_users', function($wpq) { | |
| if ( isset($wpq->query_vars['count_total'] ) && $wpq->query_vars['count_total'] ) { | |
| $wpq->query_vars['count_total'] = false; | |
| $wpq->query_vars['run_count'] = true; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | PHP Version 5.4.30 | |
| -------------------------------------------------- | |
| Testing 10 item array over 1,000 iterations: | |
| serialize 2.1979808807373 ms | |
| json_encode 1.3420581817627 ms | |
| var_export 1.9409656524658 ms | |
| msgpack_pack 1.5850067138672 ms | |
| -------------------------------------------------- | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| add_filter('gettext', function($translation, $text, $domain) { | |
| if(is_admin()) { | |
| return $translation; | |
| } | |
| if($domain == 'mythemedomain') { | |
| if(function_exists('icl_register_string')){ | |
| $slug = sanitize_title($text); | |
| icl_register_string($domain, $slug, $text); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Reference/source: http://stackoverflow.com/a/1464155/933782 | |
| * | |
| * I want a short alphanumeric hash that’s unique and who’s sequence is difficult to deduce. | |
| * I could run it out to md5 and trim the first n chars but that’s not going to be very unique. | |
| * Storing a truncated checksum in a unique field means that the frequency of collisions will increase | |
| * geometrically as the number of unique keys for a base 62 encoded integer approaches 62^n. | |
| * I’d rather do it right than code myself a timebomb. So I came up with this. | |
| * | 
OlderNewer