PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/views/styles/components/FrmStyleComponent.php +25 -15 6.25.1 → trunk View file →
@@ -62,9 +62,9 @@
62 62 * The FrmStyleComponent instance.
63 63 *
64 64 * @since 6.14
65 65 *
66 - * @var stdClass|null
66 + * @var FrmStyleComponent|null
67 67 */
68 68 private static $instance;
69 69
70 70 private function __construct() {
@@ -79,12 +79,10 @@
79 79 *
80 80 * @return void
81 81 */
82 82 public static function register_assets() {
83 - $plugin_url = FrmAppHelper::plugin_url();
84 - $version = FrmAppHelper::plugin_version();
85 -
86 - wp_register_script( self::ASSETS_SLUG, $plugin_url . '/js/formidable_styles.js', array( 'formidable_admin' ), $version, true );
83 + $version = FrmAppHelper::plugin_version();
84 + wp_register_script( self::ASSETS_SLUG, FrmAppHelper::plugin_url() . '/js/formidable_styles.js', array( 'formidable_admin' ), $version, true );
87 85 }
88 86
89 87 /**
90 88 * Get the singleton instance.
@@ -90,13 +88,13 @@
90 88 * Get the singleton instance.
91 89 *
92 90 * @since 6.14
93 91 *
94 - * @return stdClass|void
92 + * @return FrmStyleComponent|null
95 93 */
96 94 protected static function get_instance() {
97 95 if ( self::$instance ) {
98 - return;
96 + return null;
99 97 }
100 98
101 99 self::$instance = new FrmStyleComponent();
102 100 return self::$instance;
@@ -101,8 +99,15 @@
101 99 self::$instance = new FrmStyleComponent();
102 100 return self::$instance;
103 101 }
104 102
103 + /**
104 + * @param array $data
105 + * @param string $field_name
106 + * @param mixed $field_value
107 + *
108 + * @return void
109 + */
105 110 protected function init( $data, $field_name, $field_value ) {
106 111 $this->init_field_data( $data, $field_name, $field_value );
107 112 self::get_instance();
108 113 $this->load_view();
@@ -111,11 +116,13 @@
111 116 /**
112 117 * Init the field component data, field name and field value.
113 118 *
114 119 * @since 6.14
120 + *
115 121 * @param array $data The field extra options.
116 122 * @param string $field_name The field input's name.
117 123 * @param mixed $field_value The field value.
124 + *
118 125 * @return void
119 126 */
120 127 protected function init_field_data( $data, $field_name, $field_value ) {
121 128 $this->data = $data;
@@ -131,14 +138,17 @@
131 138 * @return string
132 139 */
133 140 protected function get_default_wrapper_class_names() {
134 141 $class = 'frm-style-component';
142 +
135 143 if ( ! empty( $this->data['classname'] ) ) {
136 144 $class .= ' ' . $this->data['classname'];
137 145 }
146 +
138 147 if ( ! empty( $this->data['will_change'] ) ) {
139 148 return $class . ' frm-style-dependent-updater-component';
140 149 }
150 +
141 151 return $class;
142 152 }
143 153
144 154 /**
@@ -160,11 +170,13 @@
160 170 * @return string
161 171 */
162 172 private function get_component_attributes() {
163 173 $attributes = '';
174 +
164 175 if ( ! empty( $this->data['will_change'] ) ) {
165 176 $attributes .= 'data-will-change=' . wp_json_encode( $this->data['will_change'] );
166 177 }
178 +
167 179 return $attributes;
168 180 }
169 181
170 182 /**
@@ -175,9 +187,9 @@
175 187 *
176 188 * @return string
177 189 */
178 190 private function get_field_name() {
179 - return ! empty( $this->field_name ) ? 'name=' . $this->field_name : '';
191 + return $this->field_name ? 'name=' . $this->field_name : '';
180 192 }
181 193
182 194 /**
183 195 * Init the full view path.
@@ -197,9 +209,9 @@
197 209 *
198 210 * @return void
199 211 */
200 212 protected function load_view() {
201 - if ( empty( $this->view_name ) ) {
213 + if ( ! $this->view_name ) {
202 214 return;
203 215 }
204 216
205 217 $this->set_view_path();
@@ -211,18 +223,16 @@
211 223
212 224 include $this->view_folder . $this->view_name . '.php';
213 225 }
214 226
227 + /**
228 + * @return bool
229 + */
215 230 protected function hide_component() {
216 231 if ( empty( $this->data['not_show_in'] ) ) {
217 232 return false;
218 233 }
219 -
220 - if ( FrmAppHelper::get_param( 'section', '', 'get', 'sanitize_text_field' ) === $this->data['not_show_in'] ) {
221 - return true;
222 - }
223 -
224 - return false;
234 + return FrmAppHelper::get_param( 'section', '', 'get', 'sanitize_text_field' ) === $this->data['not_show_in'];
225 235 }
226 236
227 237 /**
228 238 * Load component CSS file.