PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.3.2
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.3.2
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / admin / classes / admin-options / fields / flexible-content / template.php

template.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.3.2, at admin/classes/admin-options/fields/flexible-content/template.php

100 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template: Flexible Content field — main container.
4 *
5 * Includes: row.php for each live row + hidden JS-clone template rows.
6 *
7 * @var array<string, mixed> $settings Field configuration.
8 * @var mixed $value Current saved value.
9 * @var string $module_id Module ID.
10 * @var Merchant_Field_Flexible_Content $field The field instance.
11 *
12 * @package Merchant
13 * @since 2.2.5
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20
21 $values = ( is_array( $value ) && ! empty( $value ) ) ? $value : array();
22 $empty = empty( $values ) ? 'empty' : '';
23
24 $settings = wp_parse_args( $settings, array(
25 'sorting' => false,
26 'style' => 'default',
27 'accordion' => false,
28 ) );
29
30 $classes = array(
31 'merchant-flexible-content-control',
32 "{$settings['style']}-style",
33 );
34
35 $has_sorting = (bool) ( $settings['sorting'] ?? true );
36 if ( ! $has_sorting ) {
37 $classes[] = 'disable-sorting';
38 }
39
40 $has_accordion = (bool) ( $settings['accordion'] ?? false );
41 if ( $has_accordion ) {
42 $classes[] = 'has-accordion';
43 }
44
45 $has_duplicate = (bool) ( $settings['duplicate'] ?? false );
46 if ( $has_duplicate ) {
47 $classes[] = 'has-duplicate';
48 }
49
50 $row_template = __DIR__ . '/row.php';
51 ?>
52 <div class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
53 data-id="<?php echo esc_attr( $settings['id'] ) ?>">
54
55 <?php // Hidden clone templates for JS. ?>
56 <div class="layouts" data-id="<?php echo esc_attr( $settings['id'] ) ?>">
57 <?php
58 foreach ( $settings['layouts'] as $layout_type => $layout_config ) :
59 $layout = $layout_type;
60 $option_key = 0;
61 $option = $value;
62 $is_clone = true;
63
64 include $row_template;
65 endforeach;
66 ?>
67 </div>
68
69 <?php // Live rows. ?>
70 <div class="merchant-flexible-content <?php echo esc_attr( $empty ); ?> sortable">
71 <?php
72 $active_index = $has_accordion ? $field->get_active_index( $values ) : 0;
73
74 foreach ( $values as $option_key => $option ) :
75 $layout = $option['layout'] ?? '';
76 $layout_config = $settings['layouts'][ $layout ] ?? array();
77 $is_clone = false;
78 $deferred = $field->is_row_deferred( (int) $option_key, $active_index, $has_accordion, $is_clone );
79
80 include $row_template;
81 endforeach;
82 ?>
83 </div>
84
85 <div class="customize-control-flexible-content-add-wrapper">
86 <div class="customize-control-flexible-content-add-list">
87 <?php foreach ( $settings['layouts'] as $layout_type => $layout ) : ?>
88 <a href="#"
89 class="customize-control-flexible-content-add"
90 data-id="<?php echo esc_attr( $settings['id'] ) ?>"
91 data-layout="<?php echo esc_attr( $layout_type ) ?>">
92 <?php echo esc_attr( $layout['title'] ) ?>
93 </a>
94 <?php endforeach; ?>
95 </div>
96 <button class="button customize-control-flexible-content-add-button" type="button"><?php
97 echo esc_html( $settings['button_label'] ); ?></button>
98 </div>
99 </div>
100