= $logo['height'] ) { $output = fast_food_pizza_min_max( $logo['height'], $logo['width'], $max['height'], $max['width'], $size, $min ); $img = array( 'height' => $output['short'], 'width' => $output['long'] ); // portrait } else if ( $logo['width'] < $logo['height'] ) { $output = fast_food_pizza_min_max( $logo['width'], $logo['height'], $max['width'], $max['height'], $size, $min ); $img = array( 'height' => $output['long'], 'width' => $output['short'] ); } // add the CSS $css = ' '; $html = $css . $html; } return $html; } add_filter( 'get_custom_logo', 'fast_food_pizza_customize_logo_resizer' ); /* Helper function to determine the max size of the logo */ function fast_food_pizza_min_max( $short, $long, $short_max, $long_max, $percent, $min ){ $ratio = ( $long / $short ); $max['long'] = ( $long_max >= $long ) ? $long : $long_max; $max['short'] = ( $short_max >= ( $max['long'] / $ratio ) ) ? floor( $max['long'] / $ratio ) : $short_max; $ppp = ( $max['short'] - $min ) / 100; $size['short'] = round( $min + ( $percent * $ppp ) ); $size['long'] = round( $size['short'] / ( $short / $long ) ); return $size; } function fast_food_pizza_customize_preview_js() { wp_enqueue_script( 'fast-food-pizza-customizer', esc_url(get_template_directory_uri()) . '/js/logo-sizer/customize-preview.js', array( 'jquery', 'customize-preview' ), '201709081119', true ); } add_action( 'customize_preview_init', 'fast_food_pizza_customize_preview_js' ); function fast_food_pizza_customize_controls_js() { wp_enqueue_script( 'fast-food-pizza-customizer-controls', esc_url(get_template_directory_uri()) . '/js/logo-sizer/customize-controls.js', array( 'jquery', 'customize-preview' ), '201709071000', true ); } add_action( 'customize_controls_enqueue_scripts', 'fast_food_pizza_customize_controls_js' ); function fast_food_pizza_remove_theme_mod() { if ( isset( $_GET['remove_logo_size'] ) && 'true' == $_GET['remove_logo_size'] ){ set_theme_mod( 'fast_food_pizza_logo_sizer', '' ); } } add_action( 'wp_loaded', 'fast_food_pizza_remove_theme_mod' );