[ 'title' => esc_html__( 'Desktop', 'blogsy' ), 'icon' => 'dashicons dashicons-desktop', ], 'tablet' => [ 'title' => esc_html__( 'Tablet', 'blogsy' ), 'icon' => 'dashicons dashicons-tablet', ], 'mobile' => [ 'title' => esc_html__( 'Mobile', 'blogsy' ), 'icon' => 'dashicons dashicons-smartphone', ], ] ); // Allow both boolean and array forms of 'responsive'. if ( isset( $args['responsive'] ) ) { if ( true === $args['responsive'] ) { $this->responsive = $default_responsive; } elseif ( is_array( $args['responsive'] ) ) { // Filter out disabled devices. foreach ( $args['responsive'] as $device => $enabled ) { if ( ! empty( $enabled ) && isset( $default_responsive[ $device ] ) ) { $this->responsive[ $device ] = $default_responsive[ $device ]; } } } } } /** * Enqueue control related scripts/styles. * * @access public */ public function enqueue() { // Script debug. $blogsy_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; // Control type. $blogsy_type = str_replace( 'blogsy-', '', $this->type ); /** * Enqueue control stylesheet */ if ( file_exists( BLOGSY_THEME_DIR . '/inc/customizer/controls/' . $blogsy_type . '/' . $blogsy_type . $blogsy_suffix . '.css' ) ) { wp_enqueue_style( 'blogsy-' . $blogsy_type . '-control-style', BLOGSY_THEME_URI . '/inc/customizer/controls/' . $blogsy_type . '/' . $blogsy_type . $blogsy_suffix . '.css', false, BLOGSY_THEME_VERSION, 'all' ); } /** * Enqueue our control script. */ if ( file_exists( BLOGSY_THEME_DIR . '/inc/customizer/controls/' . $blogsy_type . '/' . $blogsy_type . $blogsy_suffix . '.js' ) ) { wp_enqueue_script( 'blogsy-' . $blogsy_type . '-js', BLOGSY_THEME_URI . '/inc/customizer/controls/' . $blogsy_type . '/' . $blogsy_type . $blogsy_suffix . '.js', [ 'jquery', 'customize-base' ], BLOGSY_THEME_VERSION, true ); } } /** * Refresh the parameters passed to the JavaScript via JSON. * * @see WP_Customize_Control::to_json() * @since 1.0.0 */ public function to_json() { $this->json['settings'] = []; foreach ( $this->settings as $key => $setting ) { $this->json['settings'][ $key ] = $setting->id; } $this->json['type'] = $this->type; $this->json['priority'] = $this->priority; $this->json['active'] = $this->active(); $this->json['section'] = $this->section; $this->json['label'] = $this->label; $this->json['description'] = $this->description; $this->json['instanceNumber'] = $this->instance_number; if ( 'dropdown-pages' === $this->type ) { $this->json['allow_addition'] = $this->allow_addition; } if ( isset( $this->default ) ) { $this->json['default'] = $this->default; } elseif ( isset( $this->setting->default ) ) { $this->json['default'] = $this->setting->default; } $this->json['value'] = $this->value(); $this->json['link'] = $this->get_link(); $this->json['id'] = $this->id; $this->json['required'] = $this->required; $this->json['responsive'] = $this->responsive; $this->json['inputAttrs'] = ''; foreach ( $this->input_attrs as $attr => $value ) { $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; } } /** * An Underscore (JS) template for this control's responsive devices buttons. * * @since 1.0.0 */ protected function responsive_devices() { ?>