| @@ -32,9 +32,8 @@ | ||
| 32 | 32 | private $default_label_position_field_ids; |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @param int|string $form_id |
| 36 | - * | |
| 37 | 36 | * @return void |
| 38 | 37 | */ |
| 39 | 38 | public function __construct( $form_id ) { |
| 40 | 39 | $this->form_id = (int) $form_id; |
| @@ -63,9 +62,8 @@ | ||
| 63 | 62 | * Add a frm-default-label-position class to any field with a default label position. |
| 64 | 63 | * A field with a custom label position shouldn't ever change in the styler preview. |
| 65 | 64 | * |
| 66 | 65 | * @since 6.0.1 |
| 67 | - * | |
| 68 | 66 | * @return void |
| 69 | 67 | */ |
| 70 | 68 | private function add_a_div_class_for_default_label_positions() { |
| 71 | 69 | // Only fields with no label position set hit this filter, so track those for the frm_field_div_classes filter. |
| @@ -73,9 +71,8 @@ | ||
| 73 | 71 | 'frm_html_label_position', |
| 74 | 72 | /** |
| 75 | 73 | * @param string $position |
| 76 | 74 | * @param array|object $field |
| 77 | - * | |
| 78 | 75 | * @return string |
| 79 | 76 | */ |
| 80 | 77 | function ( $position, $field ) { |
| 81 | 78 | if ( is_array( $field ) ) { |
| @@ -91,9 +88,8 @@ | ||
| 91 | 88 | 'frm_field_div_classes', |
| 92 | 89 | /** |
| 93 | 90 | * @param string $classes |
| 94 | 91 | * @param array|object $field |
| 95 | - * | |
| 96 | 92 | * @return string |
| 97 | 93 | */ |
| 98 | 94 | function ( $classes, $field ) { |
| 99 | 95 | if ( is_array( $field ) && in_array( (int) $field['id'], $this->default_label_position_field_ids, true ) ) { |
| @@ -119,9 +115,8 @@ | ||
| 119 | 115 | /** |
| 120 | 116 | * @param bool $show |
| 121 | 117 | * @param string $field_type |
| 122 | 118 | * @param string $target_field_type |
| 123 | - * | |
| 124 | 119 | * @return bool |
| 125 | 120 | */ |
| 126 | 121 | function ( $show, $field_type ) { |
| 127 | 122 | if ( 'captcha' === $field_type ) { |
| @@ -148,9 +143,8 @@ | ||
| 148 | 143 | 'frm_form_object', |
| 149 | 144 | /** |
| 150 | 145 | * @param stdClass|null $form |
| 151 | 146 | * @param int $form_id |
| 152 | - * | |
| 153 | 147 | * @return stdClass|null |
| 154 | 148 | */ |
| 155 | 149 | function ( $form ) { |
| 156 | 150 | if ( is_object( $form ) && is_array( $form->options ) ) { |
| @@ -172,9 +166,8 @@ | ||
| 172 | 166 | |
| 173 | 167 | $target_form_preview_html = FrmFormsController::show_form( $this->form_id, '', 'auto', 'auto' ); |
| 174 | 168 | |
| 175 | 169 | $this->form_includes_captcha = wp_script_is( 'captcha-api', 'enqueued' ); |
| 176 | - | |
| 177 | 170 | if ( $this->form_includes_captcha ) { |
| 178 | 171 | // If a form includes a CAPTCHA field, don't try to load the CAPTCHA scripts for the visual styler preview. |
| 179 | 172 | wp_dequeue_script( 'captcha-api' ); |
| 180 | 173 | } |
| @@ -196,15 +189,13 @@ | ||
| 196 | 189 | public function get_notes_for_styler_preview() { |
| 197 | 190 | $notes = array(); |
| 198 | 191 | |
| 199 | 192 | $fallback_form_note = $this->get_fallback_form_note(); |
| 200 | - | |
| 201 | 193 | if ( is_string( $fallback_form_note ) ) { |
| 202 | 194 | $notes[] = $fallback_form_note; |
| 203 | 195 | } |
| 204 | 196 | |
| 205 | 197 | $frm_settings = FrmAppHelper::get_settings(); |
| 206 | - | |
| 207 | 198 | if ( 'none' === $frm_settings->load_style ) { |
| 208 | 199 | $notes[] = function () { |
| 209 | 200 | printf( |
| 210 | 201 | // translators: %1$s: Anchor tag open, %2$s: Anchor tag close. |
| @@ -223,9 +214,8 @@ | ||
| 223 | 214 | $notes = array_merge( $notes, FrmProStylesController::get_notes_for_styler_preview() ); |
| 224 | 215 | } |
| 225 | 216 | |
| 226 | 217 | $disabled_features_note = $this->get_disabled_features_note(); |
| 227 | - | |
| 228 | 218 | if ( is_string( $disabled_features_note ) ) { |
| 229 | 219 | $notes[] = $disabled_features_note; |
| 230 | 220 | } |
| 231 | 221 | |
| @@ -260,9 +250,8 @@ | ||
| 260 | 250 | * |
| 261 | 251 | * @param stdClass|WP_Post $style A new style is not a WP_Post object. |
| 262 | 252 | * @param WP_Post $default_style |
| 263 | 253 | * @param string $view Either 'list' or 'edit'. |
| 264 | - * | |
| 265 | 254 | * @return array<string> |
| 266 | 255 | */ |
| 267 | 256 | public function get_warnings_for_styler_preview( $style, $default_style, $view ) { |
| 268 | 257 | $warnings = array(); |
| @@ -278,9 +267,8 @@ | ||
| 278 | 267 | * @since 6.0 |
| 279 | 268 | * |
| 280 | 269 | * @param int $style_id |
| 281 | 270 | * @param int $default_style_id |
| 282 | - * | |
| 283 | 271 | * @return bool |
| 284 | 272 | */ |
| 285 | 273 | private function should_show_multiple_forms_warning( $style_id, $default_style_id ) { |
| 286 | 274 | $is_default_style = $style_id === $default_style_id; |
| @@ -287,9 +275,8 @@ | ||
| 287 | 275 | |
| 288 | 276 | if ( ! $is_default_style ) { |
| 289 | 277 | // Also check for the conversational default. |
| 290 | 278 | $conversational_style_id = FrmDb::get_var( 'posts', array( 'post_name' => 'lines-no-boxes' ), 'ID' ); |
| 291 | - | |
| 292 | 279 | if ( $conversational_style_id && (int) $conversational_style_id === $style_id ) { |
| 293 | 280 | $is_default_style = true; |
| 294 | 281 | } |
| 295 | 282 | } |
| @@ -316,9 +303,8 @@ | ||
| 316 | 303 | /** |
| 317 | 304 | * @since 6.0 |
| 318 | 305 | * |
| 319 | 306 | * @param WP_Styles $styles |
| 320 | - * | |
| 321 | 307 | * @return void |
| 322 | 308 | */ |
| 323 | 309 | public static function disable_conflicting_wp_admin_css( $styles ) { |
| 324 | 310 | if ( ! is_callable( array( $styles, 'remove' ) ) || ! array_key_exists( 'wp-admin', $styles->registered ) ) { |
| @@ -328,9 +314,8 @@ | ||
| 328 | 314 | $styles->remove( 'edit' ); |
| 329 | 315 | |
| 330 | 316 | $wp_admin_dependencies = $styles->registered['wp-admin']->deps; |
| 331 | 317 | $edit_key = array_search( 'edit', $wp_admin_dependencies ); |
| 332 | - | |
| 333 | 318 | if ( false === $edit_key ) { |
| 334 | 319 | return; |
| 335 | 320 | } |
| 336 | 321 | |
| @@ -353,9 +338,8 @@ | ||
| 353 | 338 | public static function get_additional_preview_style( $settings, $is_preview = false ) { |
| 354 | 339 | if ( ! $is_preview ) { |
| 355 | 340 | return; |
| 356 | 341 | } |
| 357 | - | |
| 358 | 342 | $radio_display_type = 'inline' === $settings['radio_align'] ? 'inline-block' : 'block'; |
| 359 | 343 | $check_display_type = 'inline' === $settings['check_align'] ? 'inline-block' : 'block'; |
| 360 | 344 | |
| 361 | 345 | $style = '#frm_style_preview .with_frm_style input[type=text], |
| @@ -389,15 +373,13 @@ | ||
| 389 | 373 | * @since 6.0 |
| 390 | 374 | * |
| 391 | 375 | * @param WP_Styles $styles |
| 392 | 376 | * @param string $key |
| 393 | - * | |
| 394 | 377 | * @return void |
| 395 | 378 | */ |
| 396 | 379 | private static function remove_wp_admin_dependency( $styles, $key ) { |
| 397 | 380 | $dependencies = $styles->registered['wp-admin']->deps; |
| 398 | 381 | $index = array_search( $key, $dependencies ); |
| 399 | - | |
| 400 | 382 | if ( false === $index ) { |
| 401 | 383 | return; |
| 402 | 384 | } |
| 403 | 385 | |