'; protected function __construct() { $this->default_contacts = array_values( array_filter( $this->get_all_contacts(), function( $item ) { return in_array( $item['id'], array( 'email', 'address' ), true ); } ) ); add_filter( 'brandy_extra_localize', array( $this, 'add_localize_data' ) ); parent::__construct(); } protected function register_components() { return array( 'list_contacts' => array( 'title' => array( 'text' => __( 'List contact', 'brandy' ), ), 'value_path' => array( 'items' ), 'default_value' => $this->default_contacts, 'type' => 'ListContacts', 'render_options' => array( 'type' => 'force_refresh', ), ), 'target' => array( 'title' => array( 'text' => __( 'Open links in new tab', 'brandy' ), 'type' => 'bold', ), 'type' => 'Switcher', 'default_value' => true, 'value_path' => array( 'target' ), 'render_options' => array( 'type' => 'data_attribute', 'data' => array( array( 'selector' => '.brandy-contact-item', 'name' => 'target', 'value_path' => array( 'target' ), 'enabled_value' => '_blank', 'disabled_value' => '_self', ), ), ), ), 'items_direction' => array( 'title' => array( 'text' => __( 'Item Direction', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'type' => 'ButtonGroup', 'default_value' => array( 'desktop' => 'row', 'tablet' => null, 'mobile' => null, ), 'options' => array( array( 'label' => __( 'Horizontal', 'brandy' ), 'value' => 'row', ), array( 'label' => __( 'Vertical', 'brandy' ), 'value' => 'column', ), ), 'value_path' => array( 'items_direction' ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'custom_variables', 'selector' => '.brandy-contact-list', 'value_path' => array( 'items_direction' ), 'mapping_variables' => array_merge( array_map( function( $device ) { return array( 'condition' => array( 'value' => 'row', 'operator' => 'equal', ), 'path' => array( $device ), 'mapping' => array( $device => array( '--b-items-direction' => 'row', ), ), ); }, brandy_get_devices() ), array_map( function( $device ) { return array( 'condition' => array( 'value' => 'column', 'operator' => 'equal', ), 'path' => array( $device ), 'mapping' => array( $device => array( '--b-items-direction' => 'column', ), ), ); }, brandy_get_devices() ) ), ), ), ), ), 'item_reset' => array( 'title' => array( 'text' => __( 'Item', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'type' => 'Reset', 'reset_paths' => array( array( 'icon', 'text' ), ), ), 'icon_size' => array( 'title' => array( 'text' => __( 'Icon size', 'brandy' ), 'type' => 'normal', ), 'type' => 'Dimension', 'value_path' => array( 'icon', 'size' ), 'units' => array( 'px' ), 'default_value' => array( 'desktop' => ElementsLoader::get_default_icon_size(), 'tablet' => null, 'mobile' => null, ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'dimension', 'value_path' => array( 'icon', 'size' ), 'name' => '--b-icon-size', ), ), ), ), 'text_typography' => array( 'title' => array( 'text' => __( 'Typography', 'brandy' ), 'type' => 'normal', ), 'type' => 'Typography', 'value_path' => array( 'text', 'typography' ), 'default_value' => null, 'is_responsive' => true, 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'typography', 'selector' => '.brandy-contact-item__text', 'value_path' => array( 'text', 'typography' ), ), ), ), ), 'color' => array( 'title' => array( 'text' => __( 'Color', 'brandy' ), 'type' => 'normal', ), 'type' => 'ColorGroup', 'value_path' => array( 'text', 'color' ), 'default_value' => array( 'normal' => array( 'desktop' => 'var(--wp--preset--color--brandy-primary-text)', 'tablet' => null, 'mobile' => null, ), 'hover' => array( 'desktop' => 'var(--wp--preset--color--brandy-primary-text)', 'tablet' => null, 'mobile' => null, ), ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'color', 'value_path' => array( 'text', 'color' ), 'name' => '--b-text-color', ), ), ), ), 'items_spacing' => array( 'title' => array( 'text' => __( 'Items Spacing', 'brandy' ), 'type' => 'bold', ), 'type' => 'Dimension', 'value_path' => array( 'item_spacing' ), 'default_value' => array( 'unit' => 'px', 'value' => 14, 'min' => 0, 'max' => 40, ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'dimension', 'selector' => '.brandy-contact-list', 'name' => 'gap', 'value_path' => array( 'item_spacing' ), ), ), ), ), 'margin' => array( 'title' => array( 'text' => __( 'Margin', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'value_path' => array( 'margin' ), 'type' => 'Spacing', 'default_value' => array( 'desktop' => array( 'unit' => 'px', 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'is_constraints' => false, ), 'tablet' => null, 'mobile' => null, ), 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'spacing', 'name' => '--b-margin', 'value_path' => array( 'margin' ), ), ), ), ), ); } public function add_layout( $layouts = array() ) { $layout = array( 'general' => array( 'sections' => array( array( 'components' => array( 'list_contacts' ), ), array( 'components' => array( 'target' ), ), array( 'components' => array( 'items_direction' ), ) ), ), 'designs' => array( 'sections' => array( array( 'components' => array( 'item_reset', 'color', 'text_typography', 'icon_size', ), ), array( 'components' => array( 'items_spacing', ), ), array( 'components' => array( 'margin', ), ), ), ), ); $mapped_layout = $this->map_layout( $layout ); $layouts[ $this->element_id ] = $mapped_layout; return $layouts; } public function add_localize_data( $localize_data ) { $icons = array(); $dir = new \DirectoryIterator( BRANDY_TEMPLATE_DIR . self::$path_to_icons ); foreach ( $dir as $fileinfo ) { if ( ! $fileinfo->isDot() ) { $file_name = $fileinfo->getFilename(); $file_path = BRANDY_TEMPLATE_DIR . self::$path_to_icons . "$file_name"; $icon_name = basename( $file_name, '.php' ); if ( $file_name && file_exists( $file_path ) ) { if ( empty( $icons ) ) { $icons = array(); } ob_start(); require $file_path; $icon_data = ob_get_contents(); ob_end_clean(); $icons[ $icon_name ] = $icon_data; } } } $localize_data['icons']['contact'] = $icons; $localize_data['all_contacts'] = $this->get_all_contacts(); return $localize_data; } public static function get_all_contacts() { return array( array( 'id' => 'email', 'label' => __( 'Email', 'brandy' ), 'url' => 'mailto:test@gmail.com', 'icon' => 'email', 'content' => 'test@gmail.com', ), array( 'id' => 'phone', 'label' => __( 'Phone number', 'brandy' ), 'url' => 'tel:222-222-222', 'icon' => 'phone', 'content' => '222-222-222', ), array( 'id' => 'link', 'label' => __( 'Link', 'brandy' ), 'url' => '#', 'icon' => 'link', 'content' => 'www.test.com', ), array( 'id' => 'address', 'label' => __( 'Address', 'brandy' ), 'url' => '', 'icon' => 'address', 'content' => 'New York', ), array( 'id' => 'website', 'label' => __( 'Website', 'brandy' ), 'url' => 'www.test.com', 'icon' => 'website', 'content' => 'www.test.com', ), array( 'id' => 'fax', 'label' => __( 'Fax', 'brandy' ), 'url' => 'fax:254254254', 'icon' => 'fax', 'content' => '254 254 254', ), ); } }