| 1962 | | $this->add_control( new WP_Customize_Media_Control( $this, 'custom_logo', array( |
| 1963 | | 'label' => __( 'Logo' ), |
| 1964 | | 'section' => 'title_tagline', |
| 1965 | | 'priority' => 8, |
| 1966 | | 'mime_type' => 'image', |
| | 1964 | // Get custom logo settings and extend defaults with it. |
| | 1965 | $custom_logo_args = get_theme_support( 'custom-logo' ); |
| | 1966 | $custom_logo_args = (array) $custom_logo_args[0]; |
| | 1967 | $custom_logo_control_args = wp_parse_args( $custom_logo_args, array( |
| | 1968 | 'label' => __( 'Logo' ), |
| | 1969 | 'section' => 'title_tagline', |
| | 1970 | 'priority' => 8, |
| 1976 | | ) ) ); |
| | 1980 | ) ); |
| | 1981 | |
| | 1982 | // If no width/height were defined but there is a custom image size, use that. |
| | 1983 | if ( |
| | 1984 | ! empty( $custom_logo_args['size'] ) && |
| | 1985 | has_image_size( $custom_logo_args['size'] ) && |
| | 1986 | ! isset( $custom_logo_control_args['width'] ) && |
| | 1987 | ! isset( $custom_logo_control_args['height'] ) && |
| | 1988 | ! isset( $custom_logo_control_args['flex_width'] ) && |
| | 1989 | ! isset( $custom_logo_control_args['flex_height'] ) |
| | 1990 | ) { |
| | 1991 | global $_wp_additional_image_sizes; |
| | 1992 | $custom_logo_size = $custom_logo_args['size']; |
| | 1993 | |
| | 1994 | $custom_logo_control_args['width'] = $_wp_additional_image_sizes[ $custom_logo_size ]['width']; |
| | 1995 | $custom_logo_control_args['height'] = $_wp_additional_image_sizes[ $custom_logo_size ]['height']; |
| | 1996 | $custom_logo_control_args['flex_width'] = empty( $_wp_additional_image_sizes[ $custom_logo_size ]['crop'] ); |
| | 1997 | $custom_logo_control_args['flex_height'] = empty( $_wp_additional_image_sizes[ $custom_logo_size ]['crop'] ); |
| | 1998 | |
| | 1999 | // Otherwise fall back to these defaults. |
| | 2000 | } else { |
| | 2001 | $custom_logo_control_args['width'] = false; |
| | 2002 | $custom_logo_control_args['height'] = false; |
| | 2003 | $custom_logo_control_args['flex_width'] = true; |
| | 2004 | $custom_logo_control_args['flex_height'] = true; |
| | 2005 | } |
| | 2006 | $this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', $custom_logo_control_args ) ); |