'; protected function __construct() { $this->default_payments = array_values( array_filter( $this->get_all_payments(), function( $item ) { return in_array( $item['id'], array( 'visa', 'mastercard', 'americanexpress', 'paypal', 'googlepay', 'applepay', 'jcb' ), true ); } ) ); $this->title = __( 'Payment method', 'brandy' ); add_filter( 'brandy_extra_localize', array( $this, 'add_localize_data' ) ); parent::__construct(); } protected function register_components() { return array( 'list_payments' => array( 'title' => array( 'text' => __( 'List payments', 'brandy' ), 'type' => 'bold', ), 'value_path' => array( 'items' ), 'default_value' => $this->default_payments, 'type' => 'ListPayments', ), 'item_reset' => array( 'title' => array( 'text' => __( 'Payment item', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'type' => 'Reset', 'reset_paths' => array( array( 'item' ), ), ), 'icon_size' => array( 'title' => array( 'text' => __( 'Logo size', 'brandy' ), 'type' => 'normal', ), 'value_path' => array( 'logo', 'size' ), 'default_value' => array( 'desktop' => ElementsLoader::get_default_icon_size(), 'tablet' => null, 'mobile' => null, ), 'units' => array( 'px' ), 'type' => 'Dimension', 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'dimension', 'name' => 'width', 'selector' => '.brandy-payment-item svg', 'value_path' => array( 'logo', 'size' ), ), ), ), ), 'item_spacing' => array( 'title' => array( 'text' => __( 'Item Spacing', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'value_path' => array( 'item', 'spacing' ), 'default_value' => array( 'desktop' => array( 'unit' => 'px', 'min' => 1, 'max' => 100, 'value' => 10, ), 'tablet' => null, 'mobile' => null, ), 'type' => 'Dimension', 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'dimension', 'name' => '--item-spacing', 'value_path' => array( 'item', 'spacing' ), ), ), ), ), 'margin' => array( 'value_path' => array( 'margin' ), 'title' => array( 'text' => __( 'Margin', 'brandy' ), 'type' => 'bold', 'show_devices' => true, ), 'default_value' => array( 'desktop' => array( 'unit' => 'px', 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'is_constraints' => false, ), 'tablet' => null, 'mobile' => null, ), 'type' => 'Spacing', 'render_options' => array( 'type' => 'variable', 'data' => array( array( 'type' => 'spacing', 'name' => '--margin', 'value_path' => array( 'margin' ), ), ), ), ), // 'content_alignment' => array( // 'title' => array( // 'text' => __( 'Horizontal Alignment', 'brandy' ), // 'type' => 'bold', // 'show_devices' => true, // ), // 'type' => 'Alignment', // 'value_path' => array( 'content_alignment' ), // 'default_value' => array( // 'desktop' => 'left', // 'tablet' => null, // 'mobile' => null, // ), // 'render_options' => array( // 'type' => 'variable', // 'data' => array_map( // function( $device ) { // return array( // 'type' => 'custom_variables', // 'selector' => '.brandy-element-wrapper', // 'value_path' => array( 'content_alignment', $device ), // 'mapping_variables' => array( // array( // 'condition' => array( // 'operator' => 'equal', // 'value' => 'left', // ), // 'path' => array(), // 'mapping' => array( // $device => array( // '--horizontal-alignment' => 'flex-start', // ), // ), // ), // array( // 'condition' => array( // 'operator' => 'equal', // 'value' => 'center', // ), // 'path' => array(), // 'mapping' => array( // $device => array( // '--horizontal-alignment' => 'center', // ), // ), // ), // array( // 'condition' => array( // 'operator' => 'equal', // 'value' => 'right', // ), // 'path' => array(), // 'mapping' => array( // $device => array( // '--horizontal-alignment' => 'flex-end', // ), // ), // ), // ), // ); // }, // brandy_get_devices() // ), // ), // ), ); } protected function register_layout() { return array( 'general' => array( 'sections' => array( array( 'components' => array( 'list_payments' ), ), // array( // 'components' => array( 'content_alignment' ), // ), ), ), 'designs' => array( 'sections' => array( array( 'components' => array( 'item_reset', 'icon_size', ), ), array( 'components' => array( 'item_spacing', ), ), array( 'components' => array( 'margin', ), ), ), ), ); } /** * Add socials icons to localize data * * @param array $localize_data General data * * @return array */ 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/default.php"; $icon_name = basename( $file_name, '.php' ); if ( $file_name && file_exists( $file_path ) ) { ob_start(); require $file_path; $icon_data = ob_get_contents(); ob_end_clean(); $icons[ $icon_name ] = $icon_data; } } } $localize_data['icons']['payments'] = $icons; $localize_data['all_payments'] = $this->get_all_payments(); return $localize_data; } /** * All payments */ public static function get_all_payments() { return array( array( 'id' => 'visa', 'label' => 'Visa', 'url' => '#', 'icon' => 'visa', 'visible' => true, ), array( 'id' => 'mastercard', 'label' => 'Mastercard', 'url' => '#', 'icon' => 'mastercard', 'visible' => true, ), array( 'id' => 'americanexpress', 'label' => 'American Express', 'url' => '#', 'icon' => 'americanexpress', 'visible' => true, ), array( 'id' => 'paypal', 'label' => 'Paypal', 'url' => '#', 'icon' => 'paypal', 'visible' => true, ), array( 'id' => 'googlepay', 'label' => 'Google Pay', 'url' => '#', 'icon' => 'googlepay', 'visible' => true, ), // Not yet array( 'id' => 'applepay', 'label' => 'Apple Pay', 'url' => '#', 'icon' => 'applepay', 'visible' => true, ), array( 'id' => 'jcb', 'label' => 'JCB', 'url' => '#', 'icon' => 'jcb', 'visible' => true, ), array( 'id' => 'discover', 'label' => 'Discover', 'url' => '#', 'icon' => 'discover', 'visible' => true, ), array( 'id' => 'stripe', 'label' => 'Stripe', 'url' => '#', 'icon' => 'stripe', 'visible' => true, ), ); } }