Skip to content

Commit

Permalink
Use mb_strtolower() in the class loader (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
Screenfeed authored and remyperona committed Oct 17, 2018
1 parent 58c4c9e commit cc3eba7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions inc/functions/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ function imagify_sanitize_context( $context ) {
* @param string $class Name of the class to include.
*/
function imagify_autoload( $class ) {
static $strtolower;

if ( ! isset( $strtolower ) ) {
$strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower';
}

// Generic classes.
$classes = array(
'Imagify_Abstract_Attachment' => 1,
Expand Down Expand Up @@ -218,7 +224,7 @@ function imagify_autoload( $class ) {
);

if ( isset( $classes[ $class ] ) ) {
$class = str_replace( '_', '-', strtolower( $class ) );
$class = str_replace( '_', '-', call_user_func( $strtolower, $class ) );
include IMAGIFY_CLASSES_PATH . 'class-' . $class . '.php';
return;
}
Expand All @@ -242,7 +248,7 @@ function imagify_autoload( $class ) {

if ( isset( $classes[ $class ] ) ) {
$folder = $classes[ $class ];
$class = str_replace( '_', '-', strtolower( $class ) );
$class = str_replace( '_', '-', call_user_func( $strtolower, $class ) );
include IMAGIFY_3RD_PARTY_PATH . $folder . '/inc/classes/class-' . $class . '.php';
}
}
Expand Down

0 comments on commit cc3eba7

Please sign in to comment.