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 -16 6.25 → 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,13 +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_style( self::ASSETS_SLUG, $plugin_url . '/css/admin/style-components.css', array(), $version );
87 - 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 );
88 85 }
89 86
90 87 /**
91 88 * Get the singleton instance.
@@ -91,13 +88,13 @@
91 88 * Get the singleton instance.
92 89 *
93 90 * @since 6.14
94 91 *
95 - * @return stdClass|void
92 + * @return FrmStyleComponent|null
96 93 */
97 94 protected static function get_instance() {
98 95 if ( self::$instance ) {
99 - return;
96 + return null;
100 97 }
101 98
102 99 self::$instance = new FrmStyleComponent();
103 100 return self::$instance;
@@ -102,8 +99,15 @@
102 99 self::$instance = new FrmStyleComponent();
103 100 return self::$instance;
104 101 }
105 102
103 + /**
104 + * @param array $data
105 + * @param string $field_name
106 + * @param mixed $field_value
107 + *
108 + * @return void
109 + */
106 110 protected function init( $data, $field_name, $field_value ) {
107 111 $this->init_field_data( $data, $field_name, $field_value );
108 112 self::get_instance();
109 113 $this->load_view();
@@ -112,11 +116,13 @@
112 116 /**
113 117 * Init the field component data, field name and field value.
114 118 *
115 119 * @since 6.14
120 + *
116 121 * @param array $data The field extra options.
117 122 * @param string $field_name The field input's name.
118 123 * @param mixed $field_value The field value.
124 + *
119 125 * @return void
120 126 */
121 127 protected function init_field_data( $data, $field_name, $field_value ) {
122 128 $this->data = $data;
@@ -132,14 +138,17 @@
132 138 * @return string
133 139 */
134 140 protected function get_default_wrapper_class_names() {
135 141 $class = 'frm-style-component';
142 +
136 143 if ( ! empty( $this->data['classname'] ) ) {
137 144 $class .= ' ' . $this->data['classname'];
138 145 }
146 +
139 147 if ( ! empty( $this->data['will_change'] ) ) {
140 148 return $class . ' frm-style-dependent-updater-component';
141 149 }
150 +
142 151 return $class;
143 152 }
144 153
145 154 /**
@@ -161,11 +170,13 @@
161 170 * @return string
162 171 */
163 172 private function get_component_attributes() {
164 173 $attributes = '';
174 +
165 175 if ( ! empty( $this->data['will_change'] ) ) {
166 176 $attributes .= 'data-will-change=' . wp_json_encode( $this->data['will_change'] );
167 177 }
178 +
168 179 return $attributes;
169 180 }
170 181
171 182 /**
@@ -176,9 +187,9 @@
176 187 *
177 188 * @return string
178 189 */
179 190 private function get_field_name() {
180 - return ! empty( $this->field_name ) ? 'name=' . $this->field_name : '';
191 + return $this->field_name ? 'name=' . $this->field_name : '';
181 192 }
182 193
183 194 /**
184 195 * Init the full view path.
@@ -198,9 +209,9 @@
198 209 *
199 210 * @return void
200 211 */
201 212 protected function load_view() {
202 - if ( empty( $this->view_name ) ) {
213 + if ( ! $this->view_name ) {
203 214 return;
204 215 }
205 216
206 217 $this->set_view_path();
@@ -212,18 +223,16 @@
212 223
213 224 include $this->view_folder . $this->view_name . '.php';
214 225 }
215 226
227 + /**
228 + * @return bool
229 + */
216 230 protected function hide_component() {
217 231 if ( empty( $this->data['not_show_in'] ) ) {
218 232 return false;
219 233 }
220 -
221 - if ( FrmAppHelper::get_param( 'section', '', 'get', 'sanitize_text_field' ) === $this->data['not_show_in'] ) {
222 - return true;
223 - }
224 -
225 - return false;
234 + return FrmAppHelper::get_param( 'section', '', 'get', 'sanitize_text_field' ) === $this->data['not_show_in'];
226 235 }
227 236
228 237 /**
229 238 * Load component CSS file.