PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.1.4
StreamCast – bring live radio to your site with a sleek player v2.1.4
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
streamcast / admin / codestar-framework / fields / group / group.php

group.php in StreamCast – bring live radio to your site with a sleek player 2.1.4, at admin/codestar-framework/fields/group/group.php

145 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: group
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'CSF_Field_group' ) ) {
11 class CSF_Field_group extends CSF_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args( $this->field, array(
20 'max' => 0,
21 'min' => 0,
22 'fields' => array(),
23 'button_title' => esc_html__( 'Add New', 'csf' ),
24 'accordion_title_prefix' => '',
25 'accordion_title_number' => false,
26 'accordion_title_auto' => true,
27 ) );
28
29 $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
30 $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
31 $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
32
33 if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
34
35 echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'csf' ) .'</div>';
36
37 } else {
38
39 echo $this->field_before();
40
41 echo '<div class="csf-cloneable-item csf-cloneable-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
42
43 echo '<div class="csf-cloneable-helper">';
44 echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
45 echo '<i class="csf-cloneable-clone far fa-clone"></i>';
46 echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
47 echo '</div>';
48
49 echo '<h4 class="csf-cloneable-title">';
50 echo '<span class="csf-cloneable-text">';
51 echo ( $title_number ) ? '<span class="csf-cloneable-title-number"></span>' : '';
52 echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
53 echo ( $title_auto ) ? '<span class="csf-cloneable-value"><span class="csf-cloneable-placeholder"></span></span>' : '';
54 echo '</span>';
55 echo '</h4>';
56
57 echo '<div class="csf-cloneable-content">';
58 foreach ( $this->field['fields'] as $field ) {
59
60 $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
61 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
62
63 CSF::field( $field, $field_default, '___'. $field_unique, 'field/group' );
64
65 }
66 echo '</div>';
67
68 echo '</div>';
69
70 echo '<div class="csf-cloneable-wrapper csf-data-wrapper" data-title-number="'. esc_attr( $title_number ) .'" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
71
72 if ( ! empty( $this->value ) ) {
73
74 $num = 0;
75
76 foreach ( $this->value as $value ) {
77
78 $first_id = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : '';
79 $first_value = ( isset( $value[$first_id] ) ) ? $value[$first_id] : '';
80 $first_value = ( is_array( $first_value ) ) ? reset( $first_value ) : $first_value;
81
82 echo '<div class="csf-cloneable-item">';
83
84 echo '<div class="csf-cloneable-helper">';
85 echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
86 echo '<i class="csf-cloneable-clone far fa-clone"></i>';
87 echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
88 echo '</div>';
89
90 echo '<h4 class="csf-cloneable-title">';
91 echo '<span class="csf-cloneable-text">';
92 echo ( $title_number ) ? '<span class="csf-cloneable-title-number">'. esc_attr( $num+1 ) .'.</span>' : '';
93 echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
94 echo ( $title_auto ) ? '<span class="csf-cloneable-value">' . esc_attr( $first_value ) .'</span>' : '';
95 echo '</span>';
96 echo '</h4>';
97
98 echo '<div class="csf-cloneable-content">';
99
100 foreach ( $this->field['fields'] as $field ) {
101
102 $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
103 $field_value = ( isset( $field['id'] ) && isset( $value[$field['id']] ) ) ? $value[$field['id']] : '';
104
105 CSF::field( $field, $field_value, $field_unique, 'field/group' );
106
107 }
108
109 echo '</div>';
110
111 echo '</div>';
112
113 $num++;
114
115 }
116
117 }
118
119 echo '</div>';
120
121 echo '<div class="csf-cloneable-alert csf-cloneable-max">'. esc_html__( 'You cannot add more.', 'csf' ) .'</div>';
122 echo '<div class="csf-cloneable-alert csf-cloneable-min">'. esc_html__( 'You cannot remove more.', 'csf' ) .'</div>';
123 echo '<a href="#" class="button button-primary csf-cloneable-add">'. $args['button_title'] .'</a>';
124
125 echo $this->field_after();
126
127 }
128
129 }
130
131 public function enqueue() {
132
133 if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
134 wp_enqueue_script( 'jquery-ui-accordion' );
135 }
136
137 if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
138 wp_enqueue_script( 'jquery-ui-sortable' );
139 }
140
141 }
142
143 }
144 }
145