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/repeater/repeater.php +108 -108 2.3.42.4.0 View file →
@@ -1,108 +1,108 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 -/**
3 - *
4 - * Field: repeater
5 - *
6 - * @since 1.0.0
7 - * @version 1.0.0
8 - *
9 - */
10 -if ( ! class_exists( 'CSF_Field_repeater' ) ) {
11 - class CSF_Field_repeater 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 - 'button_title' => '<i class="fas fa-plus-circle"></i>',
23 - ) );
24 -
25 - if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
26 -
27 - echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'csf' ) .'</div>';
28 -
29 - } else {
30 -
31 - echo $this->field_before();
32 -
33 - echo '<div class="csf-repeater-item csf-repeater-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
34 - echo '<div class="csf-repeater-content">';
35 - foreach ( $this->field['fields'] as $field ) {
36 -
37 - $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
38 - $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
39 -
40 - CSF::field( $field, $field_default, '___'. $field_unique, 'field/repeater' );
41 -
42 - }
43 - echo '</div>';
44 - echo '<div class="csf-repeater-helper">';
45 - echo '<div class="csf-repeater-helper-inner">';
46 - echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
47 - echo '<i class="csf-repeater-clone far fa-clone"></i>';
48 - echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
49 - echo '</div>';
50 - echo '</div>';
51 - echo '</div>';
52 -
53 - echo '<div class="csf-repeater-wrapper csf-data-wrapper" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
54 -
55 - if ( ! empty( $this->value ) && is_array( $this->value ) ) {
56 -
57 - $num = 0;
58 -
59 - foreach ( $this->value as $key => $value ) {
60 -
61 - echo '<div class="csf-repeater-item">';
62 - echo '<div class="csf-repeater-content">';
63 - foreach ( $this->field['fields'] as $field ) {
64 -
65 - $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
66 - $field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
67 -
68 - CSF::field( $field, $field_value, $field_unique, 'field/repeater' );
69 -
70 - }
71 - echo '</div>';
72 - echo '<div class="csf-repeater-helper">';
73 - echo '<div class="csf-repeater-helper-inner">';
74 - echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
75 - echo '<i class="csf-repeater-clone far fa-clone"></i>';
76 - echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'csf' ) .'"></i>';
77 - echo '</div>';
78 - echo '</div>';
79 - echo '</div>';
80 -
81 - $num++;
82 -
83 - }
84 -
85 - }
86 -
87 - echo '</div>';
88 -
89 - echo '<div class="csf-repeater-alert csf-repeater-max">'. esc_html__( 'You cannot add more.', 'csf' ) .'</div>';
90 - echo '<div class="csf-repeater-alert csf-repeater-min">'. esc_html__( 'You cannot remove more.', 'csf' ) .'</div>';
91 - echo '<a href="#" class="button button-primary csf-repeater-add">'. $args['button_title'] .'</a>';
92 -
93 - echo $this->field_after();
94 -
95 - }
96 -
97 - }
98 -
99 - public function enqueue() {
100 -
101 - if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
102 - wp_enqueue_script( 'jquery-ui-sortable' );
103 - }
104 -
105 - }
106 -
107 - }
108 -}
1 +<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 +/**
3 + *
4 + * Field: repeater
5 + *
6 + * @since 1.0.0
7 + * @version 1.0.0
8 + *
9 + */
10 +if ( ! class_exists( 'CSF_Field_repeater' ) ) {
11 + class CSF_Field_repeater 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 + 'button_title' => '<i class="fas fa-plus-circle"></i>',
23 + ) );
24 +
25 + if ( preg_match( '/'. preg_quote( '['. $this->field['id'] .']' ) .'/', $this->unique ) ) {
26 +
27 + echo '<div class="csf-notice csf-notice-danger">'. esc_html__( 'Error: Field ID conflict.', 'streamcast' ) .'</div>';
28 +
29 + } else {
30 +
31 + echo $this->field_before(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
32 +
33 + echo '<div class="csf-repeater-item csf-repeater-hidden" data-depend-id="'. esc_attr( $this->field['id'] ) .'">';
34 + echo '<div class="csf-repeater-content">';
35 + foreach ( $this->field['fields'] as $field ) {
36 +
37 + $field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
38 + $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .'][0]' : $this->field['id'] .'[0]';
39 +
40 + CSF::field( $field, $field_default, '___'. $field_unique, 'field/repeater' );
41 +
42 + }
43 + echo '</div>';
44 + echo '<div class="csf-repeater-helper">';
45 + echo '<div class="csf-repeater-helper-inner">';
46 + echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
47 + echo '<i class="csf-repeater-clone far fa-clone"></i>';
48 + echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'streamcast' ) .'"></i>';
49 + echo '</div>';
50 + echo '</div>';
51 + echo '</div>';
52 +
53 + echo '<div class="csf-repeater-wrapper csf-data-wrapper" data-field-id="['. esc_attr( $this->field['id'] ) .']" data-max="'. esc_attr( $args['max'] ) .'" data-min="'. esc_attr( $args['min'] ) .'">';
54 +
55 + if ( ! empty( $this->value ) && is_array( $this->value ) ) {
56 +
57 + $num = 0;
58 +
59 + foreach ( $this->value as $key => $value ) {
60 +
61 + echo '<div class="csf-repeater-item">';
62 + echo '<div class="csf-repeater-content">';
63 + foreach ( $this->field['fields'] as $field ) {
64 +
65 + $field_unique = ( ! empty( $this->unique ) ) ? $this->unique .'['. $this->field['id'] .']['. $num .']' : $this->field['id'] .'['. $num .']';
66 + $field_value = ( isset( $field['id'] ) && isset( $this->value[$key][$field['id']] ) ) ? $this->value[$key][$field['id']] : '';
67 +
68 + CSF::field( $field, $field_value, $field_unique, 'field/repeater' );
69 +
70 + }
71 + echo '</div>';
72 + echo '<div class="csf-repeater-helper">';
73 + echo '<div class="csf-repeater-helper-inner">';
74 + echo '<i class="csf-repeater-sort fas fa-arrows-alt"></i>';
75 + echo '<i class="csf-repeater-clone far fa-clone"></i>';
76 + echo '<i class="csf-repeater-remove csf-confirm fas fa-times" data-confirm="'. esc_html__( 'Are you sure to delete this item?', 'streamcast' ) .'"></i>';
77 + echo '</div>';
78 + echo '</div>';
79 + echo '</div>';
80 +
81 + $num++;
82 +
83 + }
84 +
85 + }
86 +
87 + echo '</div>';
88 +
89 + echo '<div class="csf-repeater-alert csf-repeater-max">'. esc_html__( 'You cannot add more.', 'streamcast' ) .'</div>';
90 + echo '<div class="csf-repeater-alert csf-repeater-min">'. esc_html__( 'You cannot remove more.', 'streamcast' ) .'</div>';
91 + echo '<a href="#" class="button button-primary csf-repeater-add">'. wp_kses_post( $args['button_title'] ) .'</a>';
92 +
93 + echo $this->field_after(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
94 +
95 + }
96 +
97 + }
98 +
99 + public function enqueue() {
100 +
101 + if ( ! wp_script_is( 'jquery-ui-sortable' ) ) {
102 + wp_enqueue_script( 'jquery-ui-sortable' );
103 + }
104 +
105 + }
106 +
107 + }
108 +}