PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.4.0
StreamCast – bring live radio to your site with a sleek player v2.4.0
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
← All changes | frameworks/codestar-framework/fields/group/group.php +164 -164 2.3.42.4.0 View file →
@@ -1,164 +1,164 @@
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 - 'accordion_title_by' => array(),
28 - 'accordion_title_by_prefix' => ' ',
29 - ) );
30 -
31 - $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
32 - $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
33 - $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
34 - $title_first = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : $this->field['fields'][1]['id'];
35 - $title_by = ( is_array( $args['accordion_title_by'] ) ) ? $args['accordion_title_by'] : (array) $args['accordion_title_by'];
36 - $title_by = ( empty( $title_by ) ) ? array( $title_first ) : $title_by;
37 - $title_by_prefix = ( ! empty( $args['accordion_title_by_prefix'] ) ) ? $args['accordion_title_by_prefix'] : '';
38 -
39 - if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
40 -
41 - echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'csf' ) .'</div>';
42 -
43 - } else {
44 -
45 - echo $this->field_before();
46 -
47 - echo '<div class="csf-cloneable-item csf-cloneable-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
48 -
49 - echo '<div class="csf-cloneable-helper">';
50 - echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
51 - echo '<i class="csf-cloneable-clone far fa-clone"></i>';
52 - echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
53 - echo '</div>';
54 -
55 - echo '<h4 class="csf-cloneable-title">';
56 - echo '<span class="csf-cloneable-text">';
57 - echo ( $title_number ) ? '<span class="csf-cloneable-title-number"></span>' : '';
58 - echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
59 - echo ( $title_auto ) ? '<span class="csf-cloneable-value"><span class="csf-cloneable-placeholder"></span></span>' : '';
60 - echo '</span>';
61 - echo '</h4>';
62 -
63 - echo '<div class="csf-cloneable-content">';
64 - foreach ( $this->field['fields'] as $field ) {
65 -
66 - $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
67 - $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
68 -
69 - CSF::field( $field, $field_default, '___'. $field_unique, 'field/group' );
70 -
71 - }
72 - echo '</div>';
73 -
74 - echo '</div>';
75 -
76 - echo '<div class="csf-cloneable-wrapper csf-data-wrapper" data-title-by="'. esc_attr( json_encode( $title_by ) ) .'" data-title-by-prefix="'. esc_attr( $title_by_prefix ) .'" 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'] ) .'">';
77 -
78 - if ( ! empty( $this->value ) ) {
79 -
80 - $num = 0;
81 -
82 - foreach ( $this->value as $value ) {
83 -
84 - $title = '';
85 -
86 - if ( ! empty( $title_by ) ) {
87 -
88 - $titles = array();
89 -
90 - foreach ( $title_by as $title_key ) {
91 - if ( isset( $value[ $title_key ] ) ) {
92 - $titles[] = $value[ $title_key ];
93 - }
94 - }
95 -
96 - $title = join( $title_by_prefix, $titles );
97 -
98 - }
99 -
100 - $title = ( is_array( $title ) ) ? reset( $title ) : $title;
101 -
102 - echo '<div class="csf-cloneable-item">';
103 -
104 - echo '<div class="csf-cloneable-helper">';
105 - echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
106 - echo '<i class="csf-cloneable-clone far fa-clone"></i>';
107 - echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
108 - echo '</div>';
109 -
110 - echo '<h4 class="csf-cloneable-title">';
111 - echo '<span class="csf-cloneable-text">';
112 - echo ( $title_number ) ? '<span class="csf-cloneable-title-number">'. esc_attr( $num+1 ) .'.</span>' : '';
113 - echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
114 - echo ( $title_auto ) ? '<span class="csf-cloneable-value">' . esc_attr( $title ) .'</span>' : '';
115 - echo '</span>';
116 - echo '</h4>';
117 -
118 - echo '<div class="csf-cloneable-content">';
119 -
120 - foreach ( $this->field['fields'] as $field ) {
121 -
122 - $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
123 - $field_value = ( isset( $field['id'] ) && isset( $value[$field['id']] ) ) ? $value[$field['id']] : '';
124 -
125 - CSF::field( $field, $field_value, $field_unique, 'field/group' );
126 -
127 - }
128 -
129 - echo '</div>';
130 -
131 - echo '</div>';
132 -
133 - $num++;
134 -
135 - }
136 -
137 - }
138 -
139 - echo '</div>';
140 -
141 - echo '<div class="csf-cloneable-alert csf-cloneable-max">'. esc_html__( 'You cannot add more.', 'csf' ) .'</div>';
142 - echo '<div class="csf-cloneable-alert csf-cloneable-min">'. esc_html__( 'You cannot remove more.', 'csf' ) .'</div>';
143 - echo '<a href="#" class="button button-primary csf-cloneable-add">'. $args['button_title'] .'</a>';
144 -
145 - echo $this->field_after();
146 -
147 - }
148 -
149 - }
150 -
151 - public function enqueue() {
152 -
153 - if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
154 - wp_enqueue_script( 'jquery-ui-accordion' );
155 - }
156 -
157 - if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
158 - wp_enqueue_script( 'jquery-ui-sortable' );
159 - }
160 -
161 - }
162 -
163 - }
164 -}
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', 'streamcast' ),
24 + 'accordion_title_prefix' => '',
25 + 'accordion_title_number' => false,
26 + 'accordion_title_auto' => true,
27 + 'accordion_title_by' => array(),
28 + 'accordion_title_by_prefix' => ' ',
29 + ) );
30 +
31 + $title_prefix = ( ! empty( $args['accordion_title_prefix'] ) ) ? $args['accordion_title_prefix'] : '';
32 + $title_number = ( ! empty( $args['accordion_title_number'] ) ) ? true : false;
33 + $title_auto = ( ! empty( $args['accordion_title_auto'] ) ) ? true : false;
34 + $title_first = ( isset( $this->field['fields'][0]['id'] ) ) ? $this->field['fields'][0]['id'] : $this->field['fields'][1]['id'];
35 + $title_by = ( is_array( $args['accordion_title_by'] ) ) ? $args['accordion_title_by'] : (array) $args['accordion_title_by'];
36 + $title_by = ( empty( $title_by ) ) ? array( $title_first ) : $title_by;
37 + $title_by_prefix = ( ! empty( $args['accordion_title_by_prefix'] ) ) ? $args['accordion_title_by_prefix'] : '';
38 +
39 + if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
40 +
41 + echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'streamcast' ) .'</div>';
42 +
43 + } else {
44 +
45 + echo $this->field_before(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
46 +
47 + echo '<div class="csf-cloneable-item csf-cloneable-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
48 +
49 + echo '<div class="csf-cloneable-helper">';
50 + echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
51 + echo '<i class="csf-cloneable-clone far fa-clone"></i>';
52 + echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'streamcast' ) .'"></i>';
53 + echo '</div>';
54 +
55 + echo '<h4 class="csf-cloneable-title">';
56 + echo '<span class="csf-cloneable-text">';
57 + echo ( $title_number ) ? '<span class="csf-cloneable-title-number"></span>' : '';
58 + echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
59 + echo ( $title_auto ) ? '<span class="csf-cloneable-value"><span class="csf-cloneable-placeholder"></span></span>' : '';
60 + echo '</span>';
61 + echo '</h4>';
62 +
63 + echo '<div class="csf-cloneable-content">';
64 + foreach ( $this->field['fields'] as $field ) {
65 +
66 + $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
67 + $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
68 +
69 + CSF::field( $field, $field_default, '___'. $field_unique, 'field/group' );
70 +
71 + }
72 + echo '</div>';
73 +
74 + echo '</div>';
75 +
76 + echo '<div class="csf-cloneable-wrapper csf-data-wrapper" data-title-by="'. esc_attr( json_encode( $title_by ) ) .'" data-title-by-prefix="'. esc_attr( $title_by_prefix ) .'" 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'] ) .'">';
77 +
78 + if ( ! empty( $this->value ) ) {
79 +
80 + $num = 0;
81 +
82 + foreach ( $this->value as $value ) {
83 +
84 + $title = '';
85 +
86 + if ( ! empty( $title_by ) ) {
87 +
88 + $titles = array();
89 +
90 + foreach ( $title_by as $title_key ) {
91 + if ( isset( $value[ $title_key ] ) ) {
92 + $titles[] = $value[ $title_key ];
93 + }
94 + }
95 +
96 + $title = join( $title_by_prefix, $titles );
97 +
98 + }
99 +
100 + $title = ( is_array( $title ) ) ? reset( $title ) : $title;
101 +
102 + echo '<div class="csf-cloneable-item">';
103 +
104 + echo '<div class="csf-cloneable-helper">';
105 + echo '<i class="csf-cloneable-sort fas fa-arrows-alt"></i>';
106 + echo '<i class="csf-cloneable-clone far fa-clone"></i>';
107 + echo '<i class="csf-cloneable-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'streamcast' ) .'"></i>';
108 + echo '</div>';
109 +
110 + echo '<h4 class="csf-cloneable-title">';
111 + echo '<span class="csf-cloneable-text">';
112 + echo ( $title_number ) ? '<span class="csf-cloneable-title-number">'. esc_attr( $num+1 ) .'.</span>' : '';
113 + echo ( $title_prefix ) ? '<span class="csf-cloneable-title-prefix">'. esc_attr( $title_prefix ) .'</span>' : '';
114 + echo ( $title_auto ) ? '<span class="csf-cloneable-value">' . esc_attr( $title ) .'</span>' : '';
115 + echo '</span>';
116 + echo '</h4>';
117 +
118 + echo '<div class="csf-cloneable-content">';
119 +
120 + foreach ( $this->field['fields'] as $field ) {
121 +
122 + $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
123 + $field_value = ( isset( $field['id'] ) && isset( $value[$field['id']] ) ) ? $value[$field['id']] : '';
124 +
125 + CSF::field( $field, $field_value, $field_unique, 'field/group' );
126 +
127 + }
128 +
129 + echo '</div>';
130 +
131 + echo '</div>';
132 +
133 + $num++;
134 +
135 + }
136 +
137 + }
138 +
139 + echo '</div>';
140 +
141 + echo '<div class="csf-cloneable-alert csf-cloneable-max">'. esc_html__( 'You cannot add more.', 'streamcast' ) .'</div>';
142 + echo '<div class="csf-cloneable-alert csf-cloneable-min">'. esc_html__( 'You cannot remove more.', 'streamcast' ) .'</div>';
143 + echo '<a href="#" class="button button-primary csf-cloneable-add">'. wp_kses_post( $args['button_title'] ) .'</a>';
144 +
145 + echo $this->field_after(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
146 +
147 + }
148 +
149 + }
150 +
151 + public function enqueue() {
152 +
153 + if ( ! wp_script_is( 'jquery-ui-accordion' ) ) {
154 + wp_enqueue_script( 'jquery-ui-accordion' );
155 + }
156 +
157 + if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
158 + wp_enqueue_script( 'jquery-ui-sortable' );
159 + }
160 +
161 + }
162 +
163 + }
164 +}