| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | class FrmFormsController { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Track the form that opened the redirect URL in a new tab. This is used to check if we should show the default |
| 10 | - * message in the current tab. | |
| 10 | + * message in the currect tab. | |
| 11 | 11 | * |
| 12 | 12 | * @since 6.2 |
| 13 | 13 | * |
| 14 | 14 | * @var array Keys are form IDs and values are 1. |
| @@ -14,18 +14,8 @@ | ||
| 14 | 14 | * @var array Keys are form IDs and values are 1. |
| 15 | 15 | */ |
| 16 | 16 | private static $redirected_in_new_tab = array(); |
| 17 | 17 | |
| 18 | - /** | |
| 19 | - * The HTML for the Formdiable TinyMCE button (That triggers a popup to insert shortcodes) | |
| 20 | - * is stored here and re-used as an optimization. | |
| 21 | - * | |
| 22 | - * @since 6.11 | |
| 23 | - * | |
| 24 | - * @var string|null | |
| 25 | - */ | |
| 26 | - private static $formidable_tinymce_button; | |
| 27 | - | |
| 28 | 18 | public static function menu() { |
| 29 | 19 | $menu_label = __( 'Forms', 'formidable' ); |
| 30 | 20 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 31 | 21 | $menu_label .= ' (Lite)'; |
| @@ -64,12 +54,12 @@ | ||
| 64 | 54 | */ |
| 65 | 55 | public static function logic_tip() { |
| 66 | 56 | $images_url = FrmAppHelper::plugin_url() . '/images/'; |
| 67 | 57 | $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' ); |
| 68 | - $data_message .= ' <img src="' . esc_url( $images_url ) . '/survey-logic.png" srcset="' . esc_url( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>'; | |
| 58 | + $data_message .= ' <img src="' . esc_attr( $images_url ) . '/survey-logic.png" srcset="' . esc_attr( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>'; | |
| 69 | 59 | echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link frm-collapsed frm-flex-justify" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr( $data_message ) . '" data-medium="builder" data-content="logic">'; |
| 70 | 60 | esc_html_e( 'Conditional Logic', 'formidable' ); |
| 71 | - FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon', array( 'aria-hidden' => 'true' ) ); | |
| 61 | + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) ); | |
| 72 | 62 | echo '</a>'; |
| 73 | 63 | } |
| 74 | 64 | |
| 75 | 65 | /** |
| @@ -106,23 +96,15 @@ | ||
| 106 | 96 | * Create the default email action |
| 107 | 97 | * |
| 108 | 98 | * @since 2.02.11 |
| 109 | 99 | * |
| 110 | - * @param int|object $form | |
| 111 | - * @return void | |
| 100 | + * @param object|int $form | |
| 112 | 101 | */ |
| 113 | 102 | private static function create_default_email_action( $form ) { |
| 114 | 103 | FrmForm::maybe_get_form( $form ); |
| 115 | - if ( ! is_object( $form ) ) { | |
| 116 | - return; | |
| 117 | - } | |
| 118 | - | |
| 119 | 104 | $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
| 120 | 105 | |
| 121 | 106 | if ( $create_email ) { |
| 122 | - /** | |
| 123 | - * @var FrmFormAction | |
| 124 | - */ | |
| 125 | 107 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 126 | 108 | $action_control->create( $form->id ); |
| 127 | 109 | } |
| 128 | 110 | } |
| @@ -131,16 +113,12 @@ | ||
| 131 | 113 | * Create the default On submit action |
| 132 | 114 | * |
| 133 | 115 | * @since 6.0.0 |
| 134 | 116 | * |
| 135 | - * @param int|object $form Form object or ID. | |
| 136 | - * @return void | |
| 117 | + * @param object|int $form Form object or ID. | |
| 137 | 118 | */ |
| 138 | 119 | private static function create_default_on_submit_action( $form ) { |
| 139 | 120 | FrmForm::maybe_get_form( $form ); |
| 140 | - if ( ! is_object( $form ) ) { | |
| 141 | - return; | |
| 142 | - } | |
| 143 | 121 | |
| 144 | 122 | /** |
| 145 | 123 | * Enable or disable the default On Submit action. |
| 146 | 124 | * |
| @@ -151,65 +129,21 @@ | ||
| 151 | 129 | */ |
| 152 | 130 | $create = apply_filters( 'frm_create_default_on_submit_action', true, $form ); |
| 153 | 131 | |
| 154 | 132 | if ( $create ) { |
| 155 | - /** | |
| 156 | - * @var FrmFormAction | |
| 157 | - */ | |
| 158 | 133 | $action_control = FrmFormActionsController::get_form_actions( FrmOnSubmitAction::$slug ); |
| 159 | 134 | $action_control->create( $form->id ); |
| 160 | 135 | } |
| 161 | 136 | } |
| 162 | 137 | |
| 163 | - /** | |
| 164 | - * Creates submit button field. | |
| 165 | - * | |
| 166 | - * @since 6.9 | |
| 167 | - * | |
| 168 | - * @param int|object $form Form ID or object. | |
| 169 | - * @return void | |
| 170 | - */ | |
| 171 | - private static function create_submit_button_field( $form ) { | |
| 172 | - FrmForm::maybe_get_form( $form ); | |
| 173 | - if ( ! is_object( $form ) ) { | |
| 174 | - return; | |
| 175 | - } | |
| 176 | - | |
| 177 | - if ( FrmSubmitHelper::get_submit_field( $form->id ) ) { | |
| 178 | - // Do not create submit button field if it exists. | |
| 179 | - return; | |
| 180 | - } | |
| 181 | - | |
| 182 | - FrmField::create( | |
| 183 | - array( | |
| 184 | - 'type' => FrmSubmitHelper::FIELD_TYPE, | |
| 185 | - 'name' => __( 'Submit', 'formidable' ), | |
| 186 | - 'field_order' => FrmSubmitHelper::DEFAULT_ORDER, | |
| 187 | - 'form_id' => $form->id, | |
| 188 | - 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ), | |
| 189 | - 'description' => '', | |
| 190 | - 'default_value' => '', | |
| 191 | - 'options' => array(), | |
| 192 | - ) | |
| 193 | - ); | |
| 194 | - } | |
| 195 | - | |
| 196 | - /** | |
| 197 | - * @return void | |
| 198 | - */ | |
| 199 | 138 | public static function edit( $values = false ) { |
| 200 | 139 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 201 | 140 | |
| 202 | 141 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 203 | 142 | |
| 204 | - self::get_edit_vars( $id ); | |
| 143 | + return self::get_edit_vars( $id ); | |
| 205 | 144 | } |
| 206 | 145 | |
| 207 | - /** | |
| 208 | - * @param mixed $id | |
| 209 | - * @param string $message | |
| 210 | - * @return void | |
| 211 | - */ | |
| 212 | 146 | public static function settings( $id = false, $message = '' ) { |
| 213 | 147 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 214 | 148 | |
| 215 | 149 | if ( ! $id || ! is_numeric( $id ) ) { |
| @@ -217,9 +151,9 @@ | ||
| 217 | 151 | } |
| 218 | 152 | |
| 219 | 153 | FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id ); |
| 220 | 154 | |
| 221 | - self::get_settings_vars( $id, array(), $message ); | |
| 155 | + return self::get_settings_vars( $id, array(), $message ); | |
| 222 | 156 | } |
| 223 | 157 | |
| 224 | 158 | public static function update_settings() { |
| 225 | 159 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| @@ -226,9 +160,9 @@ | ||
| 226 | 160 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 227 | 161 | |
| 228 | 162 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 229 | 163 | $frm_settings = FrmAppHelper::get_settings(); |
| 230 | - $error_args = array( | |
| 164 | + $error_args = array( | |
| 231 | 165 | 'title' => __( 'Verification failed', 'formidable' ), |
| 232 | 166 | 'body' => $frm_settings->admin_permission, |
| 233 | 167 | 'cancel_text' => __( 'Cancel', 'formidable' ), |
| 234 | 168 | ); |
| @@ -237,14 +171,13 @@ | ||
| 237 | 171 | } |
| 238 | 172 | |
| 239 | 173 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 240 | 174 | |
| 241 | - $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 175 | + $errors = FrmForm::validate( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 242 | 176 | $warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 243 | 177 | |
| 244 | 178 | if ( count( $errors ) > 0 ) { |
| 245 | - self::get_settings_vars( $id, $errors, compact( 'warnings' ) ); | |
| 246 | - return; | |
| 179 | + return self::get_settings_vars( $id, $errors, compact( 'warnings' ) ); | |
| 247 | 180 | } |
| 248 | 181 | |
| 249 | 182 | do_action( 'frm_before_update_form_settings', $id ); |
| 250 | 183 | |
| @@ -258,9 +191,9 @@ | ||
| 258 | 191 | } |
| 259 | 192 | |
| 260 | 193 | $message = __( 'Settings Successfully Updated', 'formidable' ); |
| 261 | 194 | |
| 262 | - self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) ); | |
| 195 | + return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) ); | |
| 263 | 196 | } |
| 264 | 197 | |
| 265 | 198 | /** |
| 266 | 199 | * @param int $form_id |
| @@ -270,11 +203,8 @@ | ||
| 270 | 203 | $form = FrmForm::getOne( $form_id ); |
| 271 | 204 | return ! empty( $form->options['antispam'] ); |
| 272 | 205 | } |
| 273 | 206 | |
| 274 | - /** | |
| 275 | - * @return void | |
| 276 | - */ | |
| 277 | 207 | public static function update( $values = array() ) { |
| 278 | 208 | if ( empty( $values ) ) { |
| 279 | 209 | $values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 280 | 210 | } |
| @@ -292,47 +222,33 @@ | ||
| 292 | 222 | |
| 293 | 223 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 294 | 224 | |
| 295 | 225 | if ( count( $errors ) > 0 ) { |
| 296 | - self::get_edit_vars( $id, $errors ); | |
| 297 | - return; | |
| 298 | - } | |
| 226 | + return self::get_edit_vars( $id, $errors ); | |
| 227 | + } else { | |
| 228 | + self::maybe_remove_draft_option_from_fields( $id ); | |
| 299 | 229 | |
| 300 | - self::maybe_remove_draft_option_from_fields( $id ); | |
| 230 | + FrmForm::update( $id, $values ); | |
| 231 | + $message = __( 'Form was successfully updated.', 'formidable' ); | |
| 301 | 232 | |
| 302 | - FrmForm::update( $id, $values ); | |
| 303 | - $message = __( 'Form was successfully updated.', 'formidable' ); | |
| 233 | + if ( self::is_too_long( $values ) ) { | |
| 234 | + $message .= '<br/> ' . sprintf( | |
| 235 | + /* translators: %1$s: Start link HTML, %2$s: end link HTML */ | |
| 236 | + __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ), | |
| 237 | + '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">', | |
| 238 | + '</a>' | |
| 239 | + ); | |
| 240 | + } | |
| 304 | 241 | |
| 305 | - if ( self::is_too_long( $values ) ) { | |
| 306 | - $message .= '<br/> ' . sprintf( | |
| 307 | - /* translators: %1$s: Start link HTML, %2$s: end link HTML */ | |
| 308 | - __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ), | |
| 309 | - '<a href="' . esc_url( self::get_form_too_long_docs_url() ) . '" target="_blank" rel="noopener">', | |
| 310 | - '</a>' | |
| 311 | - ); | |
| 312 | - } | |
| 242 | + if ( defined( 'DOING_AJAX' ) ) { | |
| 243 | + wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 244 | + } | |
| 313 | 245 | |
| 314 | - if ( defined( 'DOING_AJAX' ) ) { | |
| 315 | - wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 316 | - } | |
| 317 | - | |
| 318 | - self::get_edit_vars( $id, array(), $message ); | |
| 246 | + return self::get_edit_vars( $id, array(), $message ); | |
| 247 | + }//end if | |
| 319 | 248 | } |
| 320 | 249 | |
| 321 | 250 | /** |
| 322 | - * @since 6.25.1 | |
| 323 | - * | |
| 324 | - * @return string | |
| 325 | - */ | |
| 326 | - private static function get_form_too_long_docs_url() { | |
| 327 | - $utm = array( | |
| 328 | - 'campaign' => 'builder', | |
| 329 | - 'content' => 'form-too-long', | |
| 330 | - ); | |
| 331 | - return FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/' ); | |
| 332 | - } | |
| 333 | - | |
| 334 | - /** | |
| 335 | 251 | * Remove the draft flag from any new fields from this current session. |
| 336 | 252 | * |
| 337 | 253 | * @since 6.8 |
| 338 | 254 | * |
| @@ -364,14 +280,35 @@ | ||
| 364 | 280 | * If it's missing, it means other values at the end of the form |
| 365 | 281 | * were likely not saved either. |
| 366 | 282 | * |
| 367 | 283 | * @since 3.06.01 |
| 284 | + */ | |
| 285 | + private static function is_too_long( $values ) { | |
| 286 | + return ( ! isset( $values['frm_end'] ) ) || empty( $values['frm_end'] ); | |
| 287 | + } | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * Redirect to the url for creating from a template | |
| 291 | + * Also delete the current form | |
| 368 | 292 | * |
| 369 | - * @param array $values | |
| 370 | - * @return bool | |
| 293 | + * @since 2.0 | |
| 294 | + * @deprecated 3.06 | |
| 371 | 295 | */ |
| 372 | - private static function is_too_long( $values ) { | |
| 373 | - return empty( $values['frm_end'] ); | |
| 296 | + public static function _create_from_template() { | |
| 297 | + _deprecated_function( __FUNCTION__, '3.06' ); | |
| 298 | + | |
| 299 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 300 | + check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 301 | + | |
| 302 | + $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); | |
| 303 | + $template_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); | |
| 304 | + | |
| 305 | + if ( $current_form ) { | |
| 306 | + FrmForm::destroy( $current_form ); | |
| 307 | + } | |
| 308 | + | |
| 309 | + echo esc_url_raw( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template_id ) ) ); | |
| 310 | + wp_die(); | |
| 374 | 311 | } |
| 375 | 312 | |
| 376 | 313 | public static function duplicate() { |
| 377 | 314 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| @@ -388,10 +325,10 @@ | ||
| 388 | 325 | $message = 'form_duplicate_error'; |
| 389 | 326 | |
| 390 | 327 | if ( $form ) { |
| 391 | 328 | $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : ''; |
| 392 | - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template ); | |
| 393 | - $message = 'form_duplicated'; | |
| 329 | + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template ); | |
| 330 | + $message = 'form_duplicated'; | |
| 394 | 331 | } |
| 395 | 332 | |
| 396 | 333 | $url .= '&message=' . $message; |
| 397 | 334 | |
| @@ -399,24 +336,20 @@ | ||
| 399 | 336 | exit(); |
| 400 | 337 | } |
| 401 | 338 | |
| 402 | 339 | /** |
| 403 | - * @return string|null | |
| 340 | + * @return string | |
| 404 | 341 | */ |
| 405 | 342 | public static function page_preview() { |
| 406 | 343 | $params = FrmForm::list_page_params(); |
| 407 | - if ( ! $params['form'] || is_numeric( $params['form'] ) ) { | |
| 408 | - return null; | |
| 344 | + if ( ! $params['form'] ) { | |
| 345 | + return; | |
| 409 | 346 | } |
| 410 | 347 | |
| 411 | - self::maybe_block_preview( $params['form'] ); | |
| 412 | - | |
| 413 | 348 | $form = FrmForm::getOne( $params['form'] ); |
| 414 | - if ( ! $form ) { | |
| 415 | - return null; | |
| 349 | + if ( $form ) { | |
| 350 | + return self::show_form( $form->id, '', 'auto', 'auto' ); | |
| 416 | 351 | } |
| 417 | - | |
| 418 | - return self::show_form( $form->id, '', 'auto', 'auto' ); | |
| 419 | 352 | } |
| 420 | 353 | |
| 421 | 354 | /** |
| 422 | 355 | * @since 3.0 |
| @@ -423,18 +356,9 @@ | ||
| 423 | 356 | * |
| 424 | 357 | * @return void |
| 425 | 358 | */ |
| 426 | 359 | public static function show_page_preview() { |
| 427 | - $preview = self::page_preview(); | |
| 428 | - if ( is_null( $preview ) ) { | |
| 429 | - wp_die( | |
| 430 | - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>', | |
| 431 | - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>', | |
| 432 | - 404 | |
| 433 | - ); | |
| 434 | - } | |
| 435 | - | |
| 436 | - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 360 | + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 437 | 361 | } |
| 438 | 362 | |
| 439 | 363 | /** |
| 440 | 364 | * @return void |
| @@ -445,17 +369,8 @@ | ||
| 445 | 369 | |
| 446 | 370 | global $frm_vars; |
| 447 | 371 | $frm_vars['preview'] = true; |
| 448 | 372 | |
| 449 | - // print_emoji_styles is deprecated. | |
| 450 | - remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
| 451 | - | |
| 452 | - if ( FrmTestModeController::should_add_test_mode_container() ) { | |
| 453 | - do_action( 'frm_test_mode_init' ); | |
| 454 | - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' ); | |
| 455 | - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 ); | |
| 456 | - } | |
| 457 | - | |
| 458 | 373 | $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' ); |
| 459 | 374 | if ( $include_theme ) { |
| 460 | 375 | self::set_preview_query(); |
| 461 | 376 | self::load_theme_preview(); |
| @@ -522,10 +437,8 @@ | ||
| 522 | 437 | } |
| 523 | 438 | |
| 524 | 439 | /** |
| 525 | 440 | * @since 3.0 |
| 526 | - * | |
| 527 | - * @return void | |
| 528 | 441 | */ |
| 529 | 442 | private static function load_theme_preview() { |
| 530 | 443 | add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 ); |
| 531 | 444 | add_filter( 'the_title', 'FrmFormsController::preview_page_title', 9999 ); |
| @@ -557,10 +470,8 @@ | ||
| 557 | 470 | |
| 558 | 471 | /** |
| 559 | 472 | * Not every theme supports get_template_part( 'page' ). |
| 560 | 473 | * When this is not supported, false is returned, and we can handle a fallback. |
| 561 | - * | |
| 562 | - * @return void | |
| 563 | 474 | */ |
| 564 | 475 | private static function fallback_when_page_template_part_is_not_supported_by_theme() { |
| 565 | 476 | if ( have_posts() ) { |
| 566 | 477 | the_post(); |
| @@ -572,12 +483,8 @@ | ||
| 572 | 483 | echo '<div class="container entry-content">'; |
| 573 | 484 | the_content(); |
| 574 | 485 | echo '</div>'; |
| 575 | 486 | |
| 576 | - // Prevent extra unexpected forms in the footer. | |
| 577 | - // For some reason this happens in the Twenty Twenty Five theme. | |
| 578 | - add_filter( 'frm_filter_final_form', '__return_empty_string' ); | |
| 579 | - | |
| 580 | 487 | self::get_template( 'footer' ); |
| 581 | 488 | } |
| 582 | 489 | } |
| 583 | 490 | |
| @@ -582,9 +489,9 @@ | ||
| 582 | 489 | } |
| 583 | 490 | |
| 584 | 491 | /** |
| 585 | 492 | * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call |
| 586 | - * and renders required html fragments calling required functions. | |
| 493 | + * and renders required html fragements calling required functions. | |
| 587 | 494 | * |
| 588 | 495 | * @since 6.7.1 |
| 589 | 496 | * @param string $template |
| 590 | 497 | * @return void |
| @@ -634,14 +541,11 @@ | ||
| 634 | 541 | return $title; |
| 635 | 542 | } |
| 636 | 543 | |
| 637 | 544 | /** |
| 638 | - * Set the page title for the theme preview page. | |
| 545 | + * Set the page title for the theme preview page | |
| 639 | 546 | * |
| 640 | 547 | * @since 3.0 |
| 641 | - * | |
| 642 | - * @param string $title | |
| 643 | - * @return string | |
| 644 | 548 | */ |
| 645 | 549 | public static function preview_title( $title ) { |
| 646 | 550 | return __( 'Form Preview', 'formidable' ); |
| 647 | 551 | } |
| @@ -667,88 +571,23 @@ | ||
| 667 | 571 | /** |
| 668 | 572 | * @since 3.0 |
| 669 | 573 | */ |
| 670 | 574 | private static function load_direct_preview() { |
| 575 | + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); | |
| 576 | + | |
| 671 | 577 | $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' ); |
| 672 | 578 | if ( $key == '' ) { |
| 673 | 579 | $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' ); |
| 674 | 580 | } |
| 675 | 581 | |
| 676 | - if ( ! $key ) { | |
| 677 | - $error = __( 'Form key is missing', 'formidable' ); | |
| 678 | - wp_die( | |
| 679 | - '<h1>' . esc_html( $error ) . '</h1>', | |
| 680 | - '<p>' . esc_html( $error ) . '</p>', | |
| 681 | - 404 | |
| 682 | - ); | |
| 683 | - } | |
| 684 | - | |
| 685 | - self::maybe_block_preview( $key ); | |
| 686 | - | |
| 687 | 582 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
| 688 | - if ( ! $form ) { | |
| 689 | - $error = __( 'Form does not exist', 'formidable' ); | |
| 690 | - wp_die( | |
| 691 | - '<h1>' . esc_html( $error ) . '</h1>', | |
| 692 | - '<p>' . esc_html( $error ) . '</p>', | |
| 693 | - 404 | |
| 694 | - ); | |
| 583 | + if ( empty( $form ) ) { | |
| 584 | + $form = FrmForm::getAll( array(), '', 1 ); | |
| 695 | 585 | } |
| 696 | 586 | |
| 697 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); | |
| 698 | - | |
| 699 | - self::fix_deprecated_null_param_warning(); | |
| 700 | - | |
| 701 | - require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php'; | |
| 587 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); | |
| 702 | 588 | } |
| 703 | 589 | |
| 704 | - /** | |
| 705 | - * Block the form preview for the contact form by default if the user cannot view forms. | |
| 706 | - * This is to prevent the contact form being exploited. | |
| 707 | - * Since this form is added by default and every site uses the same key, it is too easy | |
| 708 | - * to guess this form. | |
| 709 | - * | |
| 710 | - * @since 6.20 | |
| 711 | - * | |
| 712 | - * @param string $form_key Form key. | |
| 713 | - * @return void | |
| 714 | - */ | |
| 715 | - public static function maybe_block_preview( $form_key ) { | |
| 716 | - if ( FrmFormsHelper::should_block_preview( $form_key ) ) { | |
| 717 | - $error = __( 'You do not have permission to view this form', 'formidable' ); | |
| 718 | - wp_die( | |
| 719 | - '<h1>' . esc_html( $error ) . '</h1>', | |
| 720 | - '<p>' . esc_html( $error ) . '</p>', | |
| 721 | - 403 | |
| 722 | - ); | |
| 723 | - } | |
| 724 | - } | |
| 725 | - | |
| 726 | - /** | |
| 727 | - * Some themes have a null $src value. | |
| 728 | - * This function adds a filter to ensure that $src is not null. | |
| 729 | - * WP will call str_starts_with with the null value triggering a deprecated message otherwise. | |
| 730 | - * | |
| 731 | - * @since 6.10 | |
| 732 | - * | |
| 733 | - * @return void | |
| 734 | - */ | |
| 735 | - private static function fix_deprecated_null_param_warning() { | |
| 736 | - add_filter( | |
| 737 | - 'script_loader_src', | |
| 738 | - /** | |
| 739 | - * @param string|null $src | |
| 740 | - * @return string | |
| 741 | - */ | |
| 742 | - function ( $src ) { | |
| 743 | - if ( is_null( $src ) ) { | |
| 744 | - $src = ''; | |
| 745 | - } | |
| 746 | - return $src; | |
| 747 | - } | |
| 748 | - ); | |
| 749 | - } | |
| 750 | - | |
| 751 | 590 | public static function untrash() { |
| 752 | 591 | self::change_form_status( 'untrash' ); |
| 753 | 592 | } |
| 754 | 593 | |
| @@ -816,9 +655,9 @@ | ||
| 816 | 655 | check_admin_referer( $status . '_form_' . $params['id'] ); |
| 817 | 656 | |
| 818 | 657 | $count = 0; |
| 819 | 658 | if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
| 820 | - ++$count; | |
| 659 | + $count ++; | |
| 821 | 660 | } |
| 822 | 661 | |
| 823 | 662 | $form_type = FrmAppHelper::get_simple_request( |
| 824 | 663 | array( |
| @@ -830,9 +669,9 @@ | ||
| 830 | 669 | /* translators: %1$s: Number of forms */ |
| 831 | 670 | $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
| 832 | 671 | |
| 833 | 672 | /* translators: %1$s: Number of forms, %2$s: Start link HTML, %3$s: End link HTML */ |
| 834 | - $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); | |
| 673 | + $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); | |
| 835 | 674 | |
| 836 | 675 | $message = $available_status[ $status ]['message']; |
| 837 | 676 | |
| 838 | 677 | self::display_forms_list( $params, $message ); |
| @@ -837,12 +676,8 @@ | ||
| 837 | 676 | |
| 838 | 677 | self::display_forms_list( $params, $message ); |
| 839 | 678 | } |
| 840 | 679 | |
| 841 | - /** | |
| 842 | - * @param array $ids | |
| 843 | - * @return string | |
| 844 | - */ | |
| 845 | 680 | public static function bulk_trash( $ids ) { |
| 846 | 681 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 847 | 682 | |
| 848 | 683 | $count = 0; |
| @@ -847,16 +682,12 @@ | ||
| 847 | 682 | |
| 848 | 683 | $count = 0; |
| 849 | 684 | foreach ( $ids as $id ) { |
| 850 | 685 | if ( FrmForm::trash( $id ) ) { |
| 851 | - ++$count; | |
| 686 | + $count ++; | |
| 852 | 687 | } |
| 853 | 688 | } |
| 854 | 689 | |
| 855 | - if ( ! $count ) { | |
| 856 | - return ''; | |
| 857 | - } | |
| 858 | - | |
| 859 | 690 | $current_page = FrmAppHelper::get_simple_request( |
| 860 | 691 | array( |
| 861 | 692 | 'param' => 'form_type', |
| 862 | 693 | 'type' => 'request', |
| @@ -882,9 +713,9 @@ | ||
| 882 | 713 | check_admin_referer( 'destroy_form_' . $params['id'] ); |
| 883 | 714 | |
| 884 | 715 | $count = 0; |
| 885 | 716 | if ( FrmForm::destroy( $params['id'] ) ) { |
| 886 | - ++$count; | |
| 717 | + $count ++; | |
| 887 | 718 | } |
| 888 | 719 | |
| 889 | 720 | /* translators: %1$s: Number of forms */ |
| 890 | 721 | $message = sprintf( _n( '%1$s Form Permanently Deleted', '%1$s Forms Permanently Deleted', $count, 'formidable' ), $count ); |
| @@ -891,12 +722,8 @@ | ||
| 891 | 722 | |
| 892 | 723 | self::display_forms_list( $params, $message ); |
| 893 | 724 | } |
| 894 | 725 | |
| 895 | - /** | |
| 896 | - * @param array $ids | |
| 897 | - * @return string | |
| 898 | - */ | |
| 899 | 726 | public static function bulk_destroy( $ids ) { |
| 900 | 727 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 901 | 728 | |
| 902 | 729 | $count = 0; |
| @@ -902,9 +729,9 @@ | ||
| 902 | 729 | $count = 0; |
| 903 | 730 | foreach ( $ids as $id ) { |
| 904 | 731 | $d = FrmForm::destroy( $id ); |
| 905 | 732 | if ( $d ) { |
| 906 | - ++$count; | |
| 733 | + $count ++; | |
| 907 | 734 | } |
| 908 | 735 | } |
| 909 | 736 | |
| 910 | 737 | if ( $count ) { |
| @@ -929,9 +756,9 @@ | ||
| 929 | 756 | |
| 930 | 757 | $count = FrmForm::scheduled_delete( time() ); |
| 931 | 758 | $url = remove_query_arg( array( 'delete_all' ) ); |
| 932 | 759 | |
| 933 | - $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count; | |
| 760 | + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count; | |
| 934 | 761 | |
| 935 | 762 | wp_safe_redirect( $url ); |
| 936 | 763 | die(); |
| 937 | 764 | } |
| @@ -947,9 +774,9 @@ | ||
| 947 | 774 | |
| 948 | 775 | $new_values = self::get_modal_values(); |
| 949 | 776 | $new_values['form_key'] = $new_values['name']; |
| 950 | 777 | $new_values['options'] = array( |
| 951 | - 'antispam' => 1, | |
| 778 | + 'antispam' => 1, | |
| 952 | 779 | 'on_submit_migrated' => 1, |
| 953 | 780 | ); |
| 954 | 781 | |
| 955 | 782 | /** |
| @@ -968,9 +795,8 @@ | ||
| 968 | 795 | * @param int $form_id |
| 969 | 796 | */ |
| 970 | 797 | do_action( 'frm_build_new_form', $form_id ); |
| 971 | 798 | |
| 972 | - self::create_submit_button_field( $form_id ); | |
| 973 | 799 | self::create_default_on_submit_action( $form_id ); |
| 974 | 800 | self::create_default_email_action( $form_id ); |
| 975 | 801 | |
| 976 | 802 | $response = array( |
| @@ -984,10 +810,8 @@ | ||
| 984 | 810 | /** |
| 985 | 811 | * Before creating a new form, get the name and description from the modal. |
| 986 | 812 | * |
| 987 | 813 | * @since 4.0 |
| 988 | - * | |
| 989 | - * @return array<string,string> | |
| 990 | 814 | */ |
| 991 | 815 | public static function get_modal_values() { |
| 992 | 816 | $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' ); |
| 993 | 817 | $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' ); |
| @@ -1002,24 +826,17 @@ | ||
| 1002 | 826 | * Inserts Formidable button |
| 1003 | 827 | * Hook exists since 2.5.0 |
| 1004 | 828 | * |
| 1005 | 829 | * @since 2.0.15 |
| 1006 | - * | |
| 1007 | - * @return void | |
| 1008 | 830 | */ |
| 1009 | 831 | public static function insert_form_button() { |
| 1010 | 832 | if ( current_user_can( 'frm_view_forms' ) ) { |
| 1011 | - // Store the result in memory and re-use it when this function is called multiple times. | |
| 1012 | - // This helps speed up the form builder when there are a lot of HTML fields, where this | |
| 1013 | - // button is inserted once per HTML field. | |
| 1014 | - // In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally. | |
| 1015 | - if ( ! isset( self::$formidable_tinymce_button ) ) { | |
| 1016 | - FrmAppHelper::load_admin_wide_js(); | |
| 1017 | - $menu_name = FrmAppHelper::get_menu_name(); | |
| 1018 | - $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() ); | |
| 1019 | - self::$formidable_tinymce_button = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . FrmAppHelper::kses( $icon, 'all' ) . ' ' . esc_html( $menu_name ) . '</a>'; | |
| 1020 | - } | |
| 1021 | - echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 833 | + FrmAppHelper::load_admin_wide_js(); | |
| 834 | + $menu_name = FrmAppHelper::get_menu_name(); | |
| 835 | + $icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() ); | |
| 836 | + echo '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . | |
| 837 | + FrmAppHelper::kses( $icon, 'all' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 838 | + ' ' . esc_html( $menu_name ) . '</a>'; | |
| 1022 | 839 | } |
| 1023 | 840 | } |
| 1024 | 841 | |
| 1025 | 842 | /** |
| @@ -1107,9 +924,9 @@ | ||
| 1107 | 924 | $form_id = $opts['form_id']; |
| 1108 | 925 | unset( $opts['form_id'] ); |
| 1109 | 926 | } |
| 1110 | 927 | |
| 1111 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php'; | |
| 928 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); | |
| 1112 | 929 | |
| 1113 | 930 | echo '</div>'; |
| 1114 | 931 | |
| 1115 | 932 | wp_die(); |
| @@ -1149,14 +966,8 @@ | ||
| 1149 | 966 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 1150 | 967 | die(); |
| 1151 | 968 | } |
| 1152 | 969 | |
| 1153 | - $inbox = new FrmInbox(); | |
| 1154 | - $error = $inbox->check_for_error(); | |
| 1155 | - if ( $error ) { | |
| 1156 | - $show_messages = array( $error['subject'] . '. ' . $error['message'] ); | |
| 1157 | - } | |
| 1158 | - | |
| 1159 | 970 | require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php'; |
| 1160 | 971 | } |
| 1161 | 972 | |
| 1162 | 973 | /** |
| @@ -1163,16 +974,14 @@ | ||
| 1163 | 974 | * @param array<string,string> $columns |
| 1164 | 975 | * @return array<string,string> |
| 1165 | 976 | */ |
| 1166 | 977 | public static function get_columns( $columns ) { |
| 1167 | - $columns['cb'] = '<input type="checkbox" />'; | |
| 1168 | - $columns['name'] = esc_html__( 'Form Title', 'formidable' ); | |
| 1169 | - $columns['entries'] = esc_html__( 'Entries', 'formidable' ); | |
| 1170 | - $columns['id'] = 'ID'; | |
| 1171 | - $columns['form_key'] = esc_html__( 'Key', 'formidable' ); | |
| 1172 | - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) { | |
| 1173 | - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' ); | |
| 1174 | - } | |
| 978 | + $columns['cb'] = '<input type="checkbox" />'; | |
| 979 | + $columns['name'] = esc_html__( 'Form Title', 'formidable' ); | |
| 980 | + $columns['entries'] = esc_html__( 'Entries', 'formidable' ); | |
| 981 | + $columns['id'] = 'ID'; | |
| 982 | + $columns['form_key'] = esc_html__( 'Key', 'formidable' ); | |
| 983 | + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' ); | |
| 1175 | 984 | $columns['created_at'] = esc_html__( 'Date', 'formidable' ); |
| 1176 | 985 | |
| 1177 | 986 | add_screen_option( |
| 1178 | 987 | 'per_page', |
| @@ -1185,11 +994,8 @@ | ||
| 1185 | 994 | |
| 1186 | 995 | return $columns; |
| 1187 | 996 | } |
| 1188 | 997 | |
| 1189 | - /** | |
| 1190 | - * @return array<string,string> | |
| 1191 | - */ | |
| 1192 | 998 | public static function get_sortable_columns() { |
| 1193 | 999 | return array( |
| 1194 | 1000 | 'id' => 'id', |
| 1195 | 1001 | 'name' => 'name', |
| @@ -1223,9 +1029,9 @@ | ||
| 1223 | 1029 | return $hidden_columns; |
| 1224 | 1030 | } |
| 1225 | 1031 | |
| 1226 | 1032 | public static function save_per_page( $save, $option, $value ) { |
| 1227 | - if ( $option === 'formidable_page_formidable_per_page' ) { | |
| 1033 | + if ( $option == 'formidable_page_formidable_per_page' ) { | |
| 1228 | 1034 | $save = (int) $value; |
| 1229 | 1035 | } |
| 1230 | 1036 | |
| 1231 | 1037 | return $save; |
| @@ -1230,23 +1036,16 @@ | ||
| 1230 | 1036 | |
| 1231 | 1037 | return $save; |
| 1232 | 1038 | } |
| 1233 | 1039 | |
| 1234 | - /** | |
| 1235 | - * @param int|string $id | |
| 1236 | - * @param array $errors | |
| 1237 | - * @param string $message | |
| 1238 | - * @param bool $create_link | |
| 1239 | - * @return void | |
| 1240 | - */ | |
| 1241 | 1040 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 1242 | 1041 | global $frm_vars; |
| 1243 | 1042 | |
| 1244 | - $form = FrmForm::getOne( $id ); | |
| 1043 | + $form = FrmForm::getOne( $id ); | |
| 1245 | 1044 | $error_args = array( |
| 1246 | - 'title' => __( 'You can\'t edit the form', 'formidable' ), | |
| 1247 | - 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ), | |
| 1248 | - 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 1045 | + 'title' => __( 'You can\'t edit the form', 'formidable' ), | |
| 1046 | + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ), | |
| 1047 | + 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 1249 | 1048 | 'continue_url' => add_query_arg( |
| 1250 | 1049 | array( |
| 1251 | 1050 | 'page' => 'formidable', |
| 1252 | 1051 | ) |
| @@ -1257,10 +1056,10 @@ | ||
| 1257 | 1056 | return; |
| 1258 | 1057 | } |
| 1259 | 1058 | |
| 1260 | 1059 | if ( 'trash' === $form->status ) { |
| 1261 | - $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' ); | |
| 1262 | - $error_args['continue_url'] = add_query_arg( | |
| 1060 | + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' ); | |
| 1061 | + $error_args['continue_url'] = add_query_arg( | |
| 1263 | 1062 | array( |
| 1264 | 1063 | 'page' => 'formidable', |
| 1265 | 1064 | '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ), |
| 1266 | 1065 | 'form_type' => 'trash', |
| @@ -1284,9 +1083,8 @@ | ||
| 1284 | 1083 | |
| 1285 | 1084 | // Automatically add end section fields if they don't exist (2.0 migration). |
| 1286 | 1085 | $reset_fields = false; |
| 1287 | 1086 | FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
| 1288 | - FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields ); | |
| 1289 | 1087 | |
| 1290 | 1088 | if ( $reset_fields ) { |
| 1291 | 1089 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
| 1292 | 1090 | } |
| @@ -1312,9 +1110,10 @@ | ||
| 1312 | 1110 | } |
| 1313 | 1111 | |
| 1314 | 1112 | self::maybe_update_form_builder_message( $message ); |
| 1315 | 1113 | |
| 1316 | - $has_fields = ! empty( $values['fields'] ) && ! FrmSubmitHelper::only_contains_submit_field( $values['fields'] ); | |
| 1114 | + $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); | |
| 1115 | + $has_fields = isset( $values['fields'] ) && ! empty( $values['fields'] ); | |
| 1317 | 1116 | |
| 1318 | 1117 | if ( defined( 'DOING_AJAX' ) ) { |
| 1319 | 1118 | wp_die(); |
| 1320 | 1119 | } |
| @@ -1321,12 +1120,8 @@ | ||
| 1321 | 1120 | |
| 1322 | 1121 | require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php'; |
| 1323 | 1122 | } |
| 1324 | 1123 | |
| 1325 | - /** | |
| 1326 | - * @param array $fields | |
| 1327 | - * @return array | |
| 1328 | - */ | |
| 1329 | 1124 | public static function update_form_builder_fields( $fields, $form ) { |
| 1330 | 1125 | foreach ( $fields as $field ) { |
| 1331 | 1126 | $field->do_not_include_icons = true; |
| 1332 | 1127 | } |
| @@ -1338,21 +1133,13 @@ | ||
| 1338 | 1133 | $message = __( 'Form was Successfully Copied', 'formidable' ); |
| 1339 | 1134 | } |
| 1340 | 1135 | } |
| 1341 | 1136 | |
| 1342 | - /** | |
| 1343 | - * @param int|string $id | |
| 1344 | - * @param array $errors | |
| 1345 | - * @param array|string $args | |
| 1346 | - * @return void | |
| 1347 | - */ | |
| 1348 | 1137 | public static function get_settings_vars( $id, $errors = array(), $args = array() ) { |
| 1349 | 1138 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1350 | 1139 | |
| 1351 | 1140 | global $frm_vars; |
| 1352 | 1141 | |
| 1353 | - self::maybe_print_media_templates(); | |
| 1354 | - | |
| 1355 | 1142 | if ( ! is_array( $args ) ) { |
| 1356 | 1143 | // For reverse compatibility. |
| 1357 | 1144 | $args = array( |
| 1358 | 1145 | 'message' => $args, |
| @@ -1385,38 +1172,17 @@ | ||
| 1385 | 1172 | |
| 1386 | 1173 | $sections = self::get_settings_tabs( $values ); |
| 1387 | 1174 | $current = FrmAppHelper::simple_get( 't', 'sanitize_title', 'advanced_settings' ); |
| 1388 | 1175 | |
| 1389 | - require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php'; | |
| 1176 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); | |
| 1390 | 1177 | } |
| 1391 | 1178 | |
| 1392 | 1179 | /** |
| 1393 | - * Print WordPress media templates email actions does not trigger a "Uncaught Error: Template not found: #tmpl-media-selection" error when the media button is clicked. | |
| 1394 | - * | |
| 1395 | - * @since 6.10 | |
| 1396 | - * | |
| 1397 | - * @return void | |
| 1398 | - */ | |
| 1399 | - private static function maybe_print_media_templates() { | |
| 1400 | - if ( FrmAppHelper::pro_is_included() ) { | |
| 1401 | - // This issue does not exist when Pro is active so exit early. | |
| 1402 | - return; | |
| 1403 | - } | |
| 1404 | - | |
| 1405 | - add_action( | |
| 1406 | - 'wp_enqueue_editor', | |
| 1407 | - function () { | |
| 1408 | - wp_print_media_templates(); | |
| 1409 | - } | |
| 1410 | - ); | |
| 1411 | - } | |
| 1412 | - | |
| 1413 | - /** | |
| 1414 | 1180 | * @since 4.0 |
| 1415 | 1181 | */ |
| 1416 | 1182 | public static function form_publish_button( $atts ) { |
| 1417 | 1183 | $values = $atts['values']; |
| 1418 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php'; | |
| 1184 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php' ); | |
| 1419 | 1185 | } |
| 1420 | 1186 | |
| 1421 | 1187 | /** |
| 1422 | 1188 | * Get a list of all the settings tabs for the form settings page. |
| @@ -1430,9 +1196,9 @@ | ||
| 1430 | 1196 | $sections = array( |
| 1431 | 1197 | 'advanced' => array( |
| 1432 | 1198 | 'name' => __( 'General', 'formidable' ), |
| 1433 | 1199 | 'title' => __( 'General Form Settings', 'formidable' ), |
| 1434 | - 'function' => array( self::class, 'advanced_settings' ), | |
| 1200 | + 'function' => array( __CLASS__, 'advanced_settings' ), | |
| 1435 | 1201 | 'icon' => 'frm_icon_font frm_settings_icon', |
| 1436 | 1202 | ), |
| 1437 | 1203 | 'email' => array( |
| 1438 | 1204 | 'name' => __( 'Actions & Notifications', 'formidable' ), |
| @@ -1441,9 +1207,9 @@ | ||
| 1441 | 1207 | 'icon' => 'frm_icon_font frm_mail_bulk_icon', |
| 1442 | 1208 | ), |
| 1443 | 1209 | 'permissions' => array( |
| 1444 | 1210 | 'name' => __( 'Form Permissions', 'formidable' ), |
| 1445 | - 'icon' => 'frm_icon_font frm_lock_closed_icon', | |
| 1211 | + 'icon' => 'frm_icon_font frm_lock_icon', | |
| 1446 | 1212 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 1447 | 1213 | 'data' => array( |
| 1448 | 1214 | 'medium' => 'permissions', |
| 1449 | 1215 | 'upgrade' => __( 'Form Permissions', 'formidable' ), |
| @@ -1450,9 +1216,9 @@ | ||
| 1450 | 1216 | 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ), |
| 1451 | 1217 | 'screenshot' => 'permissions.png', |
| 1452 | 1218 | ), |
| 1453 | 1219 | ), |
| 1454 | - 'scheduling' => array( | |
| 1220 | + 'scheduling' => array( | |
| 1455 | 1221 | 'name' => __( 'Form Scheduling', 'formidable' ), |
| 1456 | 1222 | 'icon' => 'frm_icon_font frm_calendar_icon', |
| 1457 | 1223 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 1458 | 1224 | 'data' => array( |
| @@ -1462,9 +1228,9 @@ | ||
| 1462 | 1228 | ), |
| 1463 | 1229 | ), |
| 1464 | 1230 | 'buttons' => array( |
| 1465 | 1231 | 'name' => __( 'Buttons', 'formidable' ), |
| 1466 | - 'class' => self::class, | |
| 1232 | + 'class' => __CLASS__, | |
| 1467 | 1233 | 'function' => 'buttons_settings', |
| 1468 | 1234 | 'icon' => 'frm_icon_font frm_button_icon', |
| 1469 | 1235 | ), |
| 1470 | 1236 | 'landing' => array( |
| @@ -1485,9 +1251,9 @@ | ||
| 1485 | 1251 | 'screenshot' => 'chat.png', |
| 1486 | 1252 | ) |
| 1487 | 1253 | ), |
| 1488 | 1254 | ), |
| 1489 | - 'abandonment' => array( | |
| 1255 | + 'abandonment' => array( | |
| 1490 | 1256 | 'name' => __( 'Form Abandonment', 'formidable' ), |
| 1491 | 1257 | 'icon' => 'frm_icon_font frm_abandoned_icon', |
| 1492 | 1258 | 'html_class' => 'frm_show_upgrade_tab frm_noallow', |
| 1493 | 1259 | 'data' => FrmAppHelper::get_upgrade_data_params( |
| @@ -1500,18 +1266,14 @@ | ||
| 1500 | 1266 | ), |
| 1501 | 1267 | ), |
| 1502 | 1268 | 'html' => array( |
| 1503 | 1269 | 'name' => __( 'Customize HTML', 'formidable' ), |
| 1504 | - 'class' => self::class, | |
| 1270 | + 'class' => __CLASS__, | |
| 1505 | 1271 | 'function' => 'html_settings', |
| 1506 | 1272 | 'icon' => 'frm_icon_font frm_code_icon', |
| 1507 | 1273 | ), |
| 1508 | 1274 | ); |
| 1509 | 1275 | |
| 1510 | - if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) { | |
| 1511 | - unset( $sections['buttons'] ); | |
| 1512 | - } | |
| 1513 | - | |
| 1514 | 1276 | foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) { |
| 1515 | 1277 | if ( ! FrmAppHelper::show_new_feature( $feature ) ) { |
| 1516 | 1278 | unset( $sections[ $feature ] ); |
| 1517 | 1279 | } |
| @@ -1518,8 +1280,13 @@ | ||
| 1518 | 1280 | } |
| 1519 | 1281 | |
| 1520 | 1282 | $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values ); |
| 1521 | 1283 | |
| 1284 | + if ( FrmAppHelper::pro_is_installed() && ! FrmAppHelper::meets_min_pro_version( '4.0' ) ) { | |
| 1285 | + // Prevent settings from showing in 2 spots. | |
| 1286 | + unset( $sections['permissions'], $sections['scheduling'] ); | |
| 1287 | + } | |
| 1288 | + | |
| 1522 | 1289 | foreach ( $sections as $key => $section ) { |
| 1523 | 1290 | $defaults = array( |
| 1524 | 1291 | 'html_class' => '', |
| 1525 | 1292 | 'name' => ucfirst( $key ), |
| @@ -1550,9 +1317,8 @@ | ||
| 1550 | 1317 | /** |
| 1551 | 1318 | * @since 4.0 |
| 1552 | 1319 | * |
| 1553 | 1320 | * @param array $values |
| 1554 | - * @return void | |
| 1555 | 1321 | */ |
| 1556 | 1322 | public static function advanced_settings( $values ) { |
| 1557 | 1323 | $first_h3 = 'frm_first_h3'; |
| 1558 | 1324 | |
| @@ -1560,15 +1326,14 @@ | ||
| 1560 | 1326 | } |
| 1561 | 1327 | |
| 1562 | 1328 | /** |
| 1563 | 1329 | * @param array $values |
| 1564 | - * @return void | |
| 1565 | 1330 | */ |
| 1566 | 1331 | public static function render_spam_settings( $values ) { |
| 1567 | 1332 | if ( function_exists( 'akismet_http_post' ) ) { |
| 1568 | 1333 | include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php'; |
| 1569 | 1334 | } |
| 1570 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php'; | |
| 1335 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php'; | |
| 1571 | 1336 | include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php'; |
| 1572 | 1337 | } |
| 1573 | 1338 | |
| 1574 | 1339 | /** |
| @@ -1574,12 +1339,16 @@ | ||
| 1574 | 1339 | /** |
| 1575 | 1340 | * @since 4.0 |
| 1576 | 1341 | * |
| 1577 | 1342 | * @param array $values |
| 1578 | - * @return void | |
| 1579 | 1343 | */ |
| 1580 | 1344 | public static function buttons_settings( $values ) { |
| 1581 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php'; | |
| 1345 | + $styles = apply_filters( 'frm_get_style_opts', array() ); | |
| 1346 | + | |
| 1347 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 1348 | + $no_global_style = $frm_settings->load_style === 'none'; | |
| 1349 | + | |
| 1350 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php' ); | |
| 1582 | 1351 | } |
| 1583 | 1352 | |
| 1584 | 1353 | /** |
| 1585 | 1354 | * @since 4.0 |
| @@ -1584,12 +1353,11 @@ | ||
| 1584 | 1353 | /** |
| 1585 | 1354 | * @since 4.0 |
| 1586 | 1355 | * |
| 1587 | 1356 | * @param array $values |
| 1588 | - * @return void | |
| 1589 | 1357 | */ |
| 1590 | 1358 | public static function html_settings( $values ) { |
| 1591 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php'; | |
| 1359 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php' ); | |
| 1592 | 1360 | } |
| 1593 | 1361 | |
| 1594 | 1362 | /** |
| 1595 | 1363 | * Replace old Submit Button href with new href to avoid errors in Chrome |
| @@ -1595,10 +1363,9 @@ | ||
| 1595 | 1363 | * Replace old Submit Button href with new href to avoid errors in Chrome |
| 1596 | 1364 | * |
| 1597 | 1365 | * @since 2.03.08 |
| 1598 | 1366 | * |
| 1599 | - * @param array|bool $values | |
| 1600 | - * @return void | |
| 1367 | + * @param array|boolean $values | |
| 1601 | 1368 | */ |
| 1602 | 1369 | private static function clean_submit_html( &$values ) { |
| 1603 | 1370 | if ( is_array( $values ) && isset( $values['submit_html'] ) ) { |
| 1604 | 1371 | $values['submit_html'] = str_replace( 'javascript:void(0)', '#', $values['submit_html'] ); |
| @@ -1619,13 +1386,8 @@ | ||
| 1619 | 1386 | |
| 1620 | 1387 | return $classes; |
| 1621 | 1388 | } |
| 1622 | 1389 | |
| 1623 | - /** | |
| 1624 | - * @param int|string $form_id | |
| 1625 | - * @param string $class | |
| 1626 | - * @return void | |
| 1627 | - */ | |
| 1628 | 1390 | public static function mb_tags_box( $form_id, $class = '' ) { |
| 1629 | 1391 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 1630 | 1392 | |
| 1631 | 1393 | /** |
| @@ -1638,9 +1400,9 @@ | ||
| 1638 | 1400 | */ |
| 1639 | 1401 | $fields = apply_filters( 'frm_fields_in_tags_box', $fields, compact( 'form_id' ) ); |
| 1640 | 1402 | $linked_forms = array(); |
| 1641 | 1403 | $col = 'one'; |
| 1642 | - $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ); | |
| 1404 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; | |
| 1643 | 1405 | |
| 1644 | 1406 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 1645 | 1407 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 1646 | 1408 | |
| @@ -1645,9 +1407,9 @@ | ||
| 1645 | 1407 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 1646 | 1408 | |
| 1647 | 1409 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 1648 | 1410 | |
| 1649 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php'; | |
| 1411 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); | |
| 1650 | 1412 | } |
| 1651 | 1413 | |
| 1652 | 1414 | /** |
| 1653 | 1415 | * @since 3.04.01 |
| @@ -1660,9 +1422,9 @@ | ||
| 1660 | 1422 | ), |
| 1661 | 1423 | ); |
| 1662 | 1424 | |
| 1663 | 1425 | $user_fields = self::user_shortcodes(); |
| 1664 | - if ( $user_fields ) { | |
| 1426 | + if ( ! empty( $user_fields ) ) { | |
| 1665 | 1427 | $user_helpers = array(); |
| 1666 | 1428 | foreach ( $user_fields as $uk => $uf ) { |
| 1667 | 1429 | $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf; |
| 1668 | 1430 | unset( $uk, $uf ); |
| @@ -1668,9 +1430,9 @@ | ||
| 1668 | 1430 | unset( $uk, $uf ); |
| 1669 | 1431 | } |
| 1670 | 1432 | |
| 1671 | 1433 | $advanced_helpers['user_id'] = array( |
| 1672 | - 'codes' => $user_helpers, | |
| 1434 | + 'codes' => $user_helpers, | |
| 1673 | 1435 | ); |
| 1674 | 1436 | } |
| 1675 | 1437 | |
| 1676 | 1438 | /** |
| @@ -1747,16 +1509,21 @@ | ||
| 1747 | 1509 | 'updated-at' => __( 'Entry updated', 'formidable' ), |
| 1748 | 1510 | '' => '', |
| 1749 | 1511 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 1750 | 1512 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 1751 | - 'form_name' => __( 'Form Name', 'formidable' ), | |
| 1752 | 1513 | ); |
| 1753 | 1514 | |
| 1754 | - $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes ); | |
| 1755 | 1515 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 1756 | 1516 | unset( $entry_shortcodes['post_id'] ); |
| 1757 | 1517 | } |
| 1758 | 1518 | |
| 1519 | + if ( $settings_tab ) { | |
| 1520 | + $entry_shortcodes['default-message'] = __( 'Default Msg', 'formidable' ); | |
| 1521 | + $entry_shortcodes['default-html'] = __( 'Default HTML', 'formidable' ); | |
| 1522 | + $entry_shortcodes['default-plain'] = __( 'Default Plain', 'formidable' ); | |
| 1523 | + $entry_shortcodes['form_name'] = __( 'Form Name', 'formidable' ); | |
| 1524 | + } | |
| 1525 | + | |
| 1759 | 1526 | /** |
| 1760 | 1527 | * Use this hook to add or remove buttons in the helpers section |
| 1761 | 1528 | * in the customization panel |
| 1762 | 1529 | * |
| @@ -1782,9 +1549,9 @@ | ||
| 1782 | 1549 | echo ' frm_js_validate '; |
| 1783 | 1550 | self::add_js_validate_form_to_global_vars( $form ); |
| 1784 | 1551 | } |
| 1785 | 1552 | |
| 1786 | - if ( FrmForm::is_ajax_on( $form ) ) { | |
| 1553 | + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) { | |
| 1787 | 1554 | echo ' frm_ajax_submit '; |
| 1788 | 1555 | } |
| 1789 | 1556 | } |
| 1790 | 1557 | |
| @@ -1806,11 +1573,11 @@ | ||
| 1806 | 1573 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 1807 | 1574 | |
| 1808 | 1575 | echo FrmEntriesController::show_entry_shortcode( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1809 | 1576 | array( |
| 1810 | - 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1577 | + 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), | |
| 1811 | 1578 | 'default_email' => true, |
| 1812 | - 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1579 | + 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), | |
| 1813 | 1580 | ) |
| 1814 | 1581 | ); |
| 1815 | 1582 | wp_die(); |
| 1816 | 1583 | } |
| @@ -1816,10 +1583,10 @@ | ||
| 1816 | 1583 | } |
| 1817 | 1584 | |
| 1818 | 1585 | /** |
| 1819 | 1586 | * @param string $content |
| 1820 | - * @param int|stdClass|string $form | |
| 1821 | - * @param false|int|stdClass|string $entry | |
| 1587 | + * @param stdClass|string|int $form | |
| 1588 | + * @param stdClass|string|int|false $entry | |
| 1822 | 1589 | * @return string |
| 1823 | 1590 | */ |
| 1824 | 1591 | public static function filter_content( $content, $form, $entry = false ) { |
| 1825 | 1592 | $content = self::replace_form_name_shortcodes( $content, $form ); |
| @@ -1832,16 +1599,8 @@ | ||
| 1832 | 1599 | if ( is_object( $form ) ) { |
| 1833 | 1600 | $form = $form->id; |
| 1834 | 1601 | } |
| 1835 | 1602 | |
| 1836 | - /* | |
| 1837 | - * Repeater actions adds `parent_entry` to `$entry` store the parent entry data. If `parent_entry` is not empty, | |
| 1838 | - * use the parent form ID instead of repeater form ID to fix the parent form field shortcodes doesn't work. | |
| 1839 | - */ | |
| 1840 | - if ( ! empty( $entry->parent_entry ) ) { | |
| 1841 | - $form = $entry->parent_entry->form_id; | |
| 1842 | - } | |
| 1843 | - | |
| 1844 | 1603 | $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
| 1845 | 1604 | $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
| 1846 | 1605 | |
| 1847 | 1606 | return $content; |
| @@ -1851,11 +1610,11 @@ | ||
| 1851 | 1610 | * Replace any [form_name] shortcodes in a string. |
| 1852 | 1611 | * |
| 1853 | 1612 | * @since 5.5 |
| 1854 | 1613 | * |
| 1855 | - * @param array|string $string | |
| 1856 | - * @param int|stdClass|string $form | |
| 1857 | - * @return array|string | |
| 1614 | + * @param string|array $string | |
| 1615 | + * @param stdClass|string|int $form | |
| 1616 | + * @return string|array | |
| 1858 | 1617 | */ |
| 1859 | 1618 | public static function replace_form_name_shortcodes( $string, $form ) { |
| 1860 | 1619 | if ( ! is_string( $string ) ) { |
| 1861 | 1620 | return $string; |
| @@ -1873,9 +1632,9 @@ | ||
| 1873 | 1632 | return str_replace( '[form_name]', $form_name, $string ); |
| 1874 | 1633 | } |
| 1875 | 1634 | |
| 1876 | 1635 | /** |
| 1877 | - * @param false|int|stdClass|string $entry | |
| 1636 | + * @param stdClass|string|int|false $entry | |
| 1878 | 1637 | * @return void |
| 1879 | 1638 | */ |
| 1880 | 1639 | private static function get_entry_by_param( &$entry ) { |
| 1881 | 1640 | if ( ! $entry || ! is_object( $entry ) ) { |
| @@ -1890,12 +1649,8 @@ | ||
| 1890 | 1649 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 1891 | 1650 | return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
| 1892 | 1651 | } |
| 1893 | 1652 | |
| 1894 | - /** | |
| 1895 | - * @param array $errors | |
| 1896 | - * @return array | |
| 1897 | - */ | |
| 1898 | 1653 | public static function process_bulk_form_actions( $errors ) { |
| 1899 | 1654 | if ( ! $_REQUEST ) { |
| 1900 | 1655 | return $errors; |
| 1901 | 1656 | } |
| @@ -1939,9 +1694,9 @@ | ||
| 1939 | 1694 | case 'untrash': |
| 1940 | 1695 | $message = self::bulk_untrash( $ids ); |
| 1941 | 1696 | } |
| 1942 | 1697 | |
| 1943 | - if ( ! empty( $message ) ) { | |
| 1698 | + if ( isset( $message ) && ! empty( $message ) ) { | |
| 1944 | 1699 | $errors['message'] = $message; |
| 1945 | 1700 | } |
| 1946 | 1701 | |
| 1947 | 1702 | return $errors; |
| @@ -1946,26 +1701,13 @@ | ||
| 1946 | 1701 | |
| 1947 | 1702 | return $errors; |
| 1948 | 1703 | } |
| 1949 | 1704 | |
| 1950 | - /** | |
| 1951 | - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages. | |
| 1952 | - * | |
| 1953 | - * @since 6.20 | |
| 1954 | - * @return void | |
| 1955 | - */ | |
| 1956 | - public static function include_device_too_small_message() { | |
| 1957 | - if ( ! FrmAppHelper::is_formidable_admin() ) { | |
| 1958 | - return; | |
| 1959 | - } | |
| 1960 | - | |
| 1961 | - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php'; | |
| 1962 | - } | |
| 1963 | - | |
| 1964 | 1705 | public static function route() { |
| 1965 | 1706 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1966 | 1707 | $vars = array(); |
| 1967 | 1708 | FrmAppHelper::include_svg(); |
| 1709 | + | |
| 1968 | 1710 | if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 1969 | 1711 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1970 | 1712 | |
| 1971 | 1713 | // Javascript needs to be allowed in some field settings. |
| @@ -1974,9 +1716,9 @@ | ||
| 1974 | 1716 | $json_vars = json_decode( $json_vars, true ); |
| 1975 | 1717 | if ( empty( $json_vars ) ) { |
| 1976 | 1718 | // json decoding failed so we should return an error message. |
| 1977 | 1719 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1978 | - if ( 'edit' === $action ) { | |
| 1720 | + if ( 'edit' == $action ) { | |
| 1979 | 1721 | $action = 'update'; |
| 1980 | 1722 | } |
| 1981 | 1723 | |
| 1982 | 1724 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| @@ -1998,8 +1740,10 @@ | ||
| 1998 | 1740 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1999 | 1741 | FrmAppHelper::trigger_hook_load( 'form' ); |
| 2000 | 1742 | |
| 2001 | 1743 | switch ( $action ) { |
| 1744 | + case 'new': | |
| 1745 | + return self::new_form( $vars ); | |
| 2002 | 1746 | case 'create': |
| 2003 | 1747 | case 'edit': |
| 2004 | 1748 | case 'update': |
| 2005 | 1749 | case 'trash': |
| @@ -2008,13 +1752,11 @@ | ||
| 2008 | 1752 | case 'settings': |
| 2009 | 1753 | case 'update_settings': |
| 2010 | 1754 | return self::$action( $vars ); |
| 2011 | 1755 | case 'lite-reports': |
| 2012 | - self::no_reports( $vars ); | |
| 2013 | - return; | |
| 1756 | + return self::no_reports( $vars ); | |
| 2014 | 1757 | case 'views': |
| 2015 | - self::no_views( $vars ); | |
| 2016 | - return; | |
| 1758 | + return self::no_views( $vars ); | |
| 2017 | 1759 | default: |
| 2018 | 1760 | do_action( 'frm_form_action_' . $action ); |
| 2019 | 1761 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 2020 | 1762 | return; |
| @@ -2069,32 +1811,12 @@ | ||
| 2069 | 1811 | // Get posted data |
| 2070 | 1812 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 2071 | 1813 | $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' ); |
| 2072 | 1814 | |
| 2073 | - $form = FrmForm::getOne( $form_id ); | |
| 2074 | - if ( ! $form ) { | |
| 2075 | - wp_send_json_error( __( 'Form not found', 'formidable' ) ); | |
| 2076 | - } | |
| 1815 | + // Update the form name and form key. | |
| 1816 | + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' ); | |
| 1817 | + FrmForm::update( $form_id, compact( 'name', 'form_key' ) ); | |
| 2077 | 1818 | |
| 2078 | - if ( $name === $form->name ) { | |
| 2079 | - // Nothing to change so exit early. | |
| 2080 | - wp_send_json_success(); | |
| 2081 | - } | |
| 2082 | - | |
| 2083 | - $to_update = array( | |
| 2084 | - 'name' => $name, | |
| 2085 | - ); | |
| 2086 | - | |
| 2087 | - if ( '' !== $name ) { | |
| 2088 | - // Only update form_key if name is not empty. | |
| 2089 | - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' ); | |
| 2090 | - $to_update['form_key'] = $form_key; | |
| 2091 | - } else { | |
| 2092 | - $form_key = $form->form_key; | |
| 2093 | - } | |
| 2094 | - | |
| 2095 | - FrmForm::update( $form_id, $to_update ); | |
| 2096 | - | |
| 2097 | 1819 | wp_send_json_success( compact( 'form_key' ) ); |
| 2098 | 1820 | } |
| 2099 | 1821 | |
| 2100 | 1822 | public static function json_error( $errors ) { |
| @@ -2103,13 +1825,20 @@ | ||
| 2103 | 1825 | return $errors; |
| 2104 | 1826 | } |
| 2105 | 1827 | |
| 2106 | 1828 | /** |
| 1829 | + * Education for premium features. | |
| 1830 | + * | |
| 1831 | + * @since 4.05 | |
| 1832 | + */ | |
| 1833 | + public static function add_form_style_tab_options() { | |
| 1834 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php' ); | |
| 1835 | + } | |
| 1836 | + | |
| 1837 | + /** | |
| 2107 | 1838 | * Add education about views. |
| 2108 | 1839 | * |
| 2109 | 1840 | * @since 4.07 |
| 2110 | - * | |
| 2111 | - * @return void | |
| 2112 | 1841 | */ |
| 2113 | 1842 | public static function no_views( $values = array() ) { |
| 2114 | 1843 | FrmAppHelper::include_svg(); |
| 2115 | 1844 | $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' ); |
| @@ -2121,10 +1850,8 @@ | ||
| 2121 | 1850 | /** |
| 2122 | 1851 | * Add education about reports. |
| 2123 | 1852 | * |
| 2124 | 1853 | * @since 4.07 |
| 2125 | - * | |
| 2126 | - * @return void | |
| 2127 | 1854 | */ |
| 2128 | 1855 | public static function no_reports( $values = array() ) { |
| 2129 | 1856 | $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' ); |
| 2130 | 1857 | $form = $id ? FrmForm::getOne( $id ) : false; |
| @@ -2209,9 +1936,9 @@ | ||
| 2209 | 1936 | $wp_admin_bar->add_node( |
| 2210 | 1937 | array( |
| 2211 | 1938 | 'parent' => 'frm-forms', |
| 2212 | 1939 | 'id' => 'edit_form_' . $form_id, |
| 2213 | - 'title' => empty( $name ) ? FrmFormsHelper::get_no_title_text() : $name, | |
| 1940 | + 'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name, | |
| 2214 | 1941 | 'href' => FrmForm::get_edit_link( $form_id ), |
| 2215 | 1942 | ) |
| 2216 | 1943 | ); |
| 2217 | 1944 | } |
| @@ -2224,10 +1951,10 @@ | ||
| 2224 | 1951 | * @return string |
| 2225 | 1952 | */ |
| 2226 | 1953 | public static function get_form_shortcode( $atts ) { |
| 2227 | 1954 | global $frm_vars; |
| 2228 | - if ( ! empty( $frm_vars['skip_shortcode'] ) ) { | |
| 2229 | - $sc = '[formidable'; | |
| 1955 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { | |
| 1956 | + $sc = '[formidable'; | |
| 2230 | 1957 | $sc .= FrmAppHelper::array_to_html_params( $atts ); |
| 2231 | 1958 | return $sc . ']'; |
| 2232 | 1959 | } |
| 2233 | 1960 | |
| @@ -2252,11 +1979,11 @@ | ||
| 2252 | 1979 | |
| 2253 | 1980 | /** |
| 2254 | 1981 | * @since 5.2.01 |
| 2255 | 1982 | * |
| 2256 | - * @param false|int|string $id | |
| 2257 | - * @param false|string $key | |
| 2258 | - * @return false|stdClass | |
| 1983 | + * @param string|int|false $id | |
| 1984 | + * @param string|false $key | |
| 1985 | + * @return stdClass|false | |
| 2259 | 1986 | */ |
| 2260 | 1987 | private static function maybe_get_form_by_id_or_key( $id, $key ) { |
| 2261 | 1988 | if ( ! $id ) { |
| 2262 | 1989 | $id = $key; |
| @@ -2264,12 +1991,12 @@ | ||
| 2264 | 1991 | return self::maybe_get_form_to_show( $id ); |
| 2265 | 1992 | } |
| 2266 | 1993 | |
| 2267 | 1994 | /** |
| 2268 | - * @param false|int|string $id | |
| 2269 | - * @param false|string $key | |
| 2270 | - * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0. | |
| 2271 | - * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0. | |
| 1995 | + * @param string|int|false $id | |
| 1996 | + * @param string|false $key | |
| 1997 | + * @param string|int|bool $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0. | |
| 1998 | + * @param string|int|bool $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0. | |
| 2272 | 1999 | * @param array $atts |
| 2273 | 2000 | * @return string |
| 2274 | 2001 | */ |
| 2275 | 2002 | public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
| @@ -2317,10 +2044,10 @@ | ||
| 2317 | 2044 | return $form; |
| 2318 | 2045 | } |
| 2319 | 2046 | |
| 2320 | 2047 | /** |
| 2321 | - * @param false|int|string $id | |
| 2322 | - * @return false|stdClass | |
| 2048 | + * @param string|int|false $id | |
| 2049 | + * @return stdClass|false | |
| 2323 | 2050 | */ |
| 2324 | 2051 | private static function maybe_get_form_to_show( $id ) { |
| 2325 | 2052 | $form = false; |
| 2326 | 2053 | |
| @@ -2384,11 +2111,11 @@ | ||
| 2384 | 2111 | |
| 2385 | 2112 | do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
| 2386 | 2113 | |
| 2387 | 2114 | if ( apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
| 2388 | - $entry_id = self::just_created_entry( $form->id ); | |
| 2389 | - $pass_args['entry_id'] = $entry_id; | |
| 2390 | - $pass_args['reset'] = true; | |
| 2115 | + $entry_id = self::just_created_entry( $form->id ); | |
| 2116 | + $pass_args['entry_id'] = $entry_id; | |
| 2117 | + $pass_args['reset'] = true; | |
| 2391 | 2118 | |
| 2392 | 2119 | self::run_on_submit_actions( $pass_args ); |
| 2393 | 2120 | |
| 2394 | 2121 | do_action( |
| @@ -2432,9 +2159,9 @@ | ||
| 2432 | 2159 | */ |
| 2433 | 2160 | public static function just_created_entry( $form_id ) { |
| 2434 | 2161 | global $frm_vars; |
| 2435 | 2162 | |
| 2436 | - return isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; | |
| 2163 | + return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; | |
| 2437 | 2164 | } |
| 2438 | 2165 | |
| 2439 | 2166 | /** |
| 2440 | 2167 | * Gets confirmation method. |
| @@ -2447,14 +2174,14 @@ | ||
| 2447 | 2174 | * |
| 2448 | 2175 | * @type object $form Form object. |
| 2449 | 2176 | * @type int $entry_id Entry ID. |
| 2450 | 2177 | * } |
| 2451 | - * @return array|string | |
| 2178 | + * @return string|array | |
| 2452 | 2179 | */ |
| 2453 | 2180 | private static function get_confirmation_method( $atts ) { |
| 2454 | 2181 | $action = FrmOnSubmitHelper::current_event( $atts ); |
| 2455 | 2182 | $opt = 'update' === $action ? 'edit_action' : 'success_action'; |
| 2456 | - $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message'; | |
| 2183 | + $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message'; | |
| 2457 | 2184 | |
| 2458 | 2185 | if ( ! empty( $atts['entry_id'] ) ) { |
| 2459 | 2186 | $met_actions = self::get_met_on_submit_actions( $atts, $action ); |
| 2460 | 2187 | if ( $met_actions ) { |
| @@ -2463,9 +2190,9 @@ | ||
| 2463 | 2190 | } |
| 2464 | 2191 | |
| 2465 | 2192 | $method = apply_filters( 'frm_success_filter', $method, $atts['form'], $action ); |
| 2466 | 2193 | |
| 2467 | - if ( $method !== 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) { | |
| 2194 | + if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) { | |
| 2468 | 2195 | $method = 'message'; |
| 2469 | 2196 | } |
| 2470 | 2197 | |
| 2471 | 2198 | return $method; |
| @@ -2499,9 +2226,9 @@ | ||
| 2499 | 2226 | * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}. |
| 2500 | 2227 | */ |
| 2501 | 2228 | public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) { |
| 2502 | 2229 | if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) { |
| 2503 | - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) { | |
| 2230 | + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) { | |
| 2504 | 2231 | $event = FrmOnSubmitHelper::current_event( $params ); |
| 2505 | 2232 | FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event ); |
| 2506 | 2233 | $conf_method = 'redirect'; |
| 2507 | 2234 | } |
| @@ -2550,9 +2277,9 @@ | ||
| 2550 | 2277 | unset( $extra_args['form'] ); |
| 2551 | 2278 | |
| 2552 | 2279 | do_action( 'frm_success_action', $args['conf_method'], $args['form'], $args['form']->options, $args['entry_id'], $extra_args ); |
| 2553 | 2280 | |
| 2554 | - $opt = ! isset( $args['action'] ) || $args['action'] === 'create' ? 'success' : 'edit'; | |
| 2281 | + $opt = ( ! isset( $args['action'] ) || $args['action'] === 'create' ) ? 'success' : 'edit'; | |
| 2555 | 2282 | |
| 2556 | 2283 | $args['success_opt'] = $opt; |
| 2557 | 2284 | $args['ajax'] = ! empty( $frm_vars['ajax'] ); |
| 2558 | 2285 | |
| @@ -2578,16 +2305,16 @@ | ||
| 2578 | 2305 | if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) { |
| 2579 | 2306 | return array(); |
| 2580 | 2307 | } |
| 2581 | 2308 | |
| 2582 | - // If a redirect action has already opened the URL in a new tab, we show the default message in the current tab. | |
| 2309 | + // If a redirect action has already opened the URL in a new tab, we show the default message in the currect tab. | |
| 2583 | 2310 | if ( ! empty( self::$redirected_in_new_tab[ $args['form']->id ] ) ) { |
| 2584 | 2311 | return array( FrmOnSubmitHelper::get_fallback_action_after_open_in_new_tab( $event ) ); |
| 2585 | 2312 | } |
| 2586 | 2313 | |
| 2587 | - $entry = FrmEntry::getOne( $args['entry_id'], true ); | |
| 2588 | - $actions = FrmOnSubmitHelper::get_actions( $args['form']->id ); | |
| 2589 | - $met_actions = array(); | |
| 2314 | + $entry = FrmEntry::getOne( $args['entry_id'], true ); | |
| 2315 | + $actions = FrmOnSubmitHelper::get_actions( $args['form']->id ); | |
| 2316 | + $met_actions = array(); | |
| 2590 | 2317 | $has_redirect = false; |
| 2591 | 2318 | |
| 2592 | 2319 | foreach ( $actions as $action ) { |
| 2593 | 2320 | if ( ! in_array( $event, $action->post_content['event'], true ) ) { |
| @@ -2836,9 +2563,9 @@ | ||
| 2836 | 2563 | echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) ); |
| 2837 | 2564 | wp_die(); |
| 2838 | 2565 | } |
| 2839 | 2566 | |
| 2840 | - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) { | |
| 2567 | + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { | |
| 2841 | 2568 | // Not AJAX submit, no headers sent, and there is just one Redirect action runs. |
| 2842 | 2569 | if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) { |
| 2843 | 2570 | self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args ); |
| 2844 | 2571 | self::$redirected_in_new_tab[ $args['form']->id ] = 1; |
| @@ -2883,46 +2610,28 @@ | ||
| 2883 | 2610 | * @param array $args See {@see FrmFormsController::run_success_action()}. |
| 2884 | 2611 | * @return array |
| 2885 | 2612 | */ |
| 2886 | 2613 | private static function get_ajax_redirect_response_data( $args ) { |
| 2887 | - $response_data = array( | |
| 2888 | - 'redirect' => $args['success_url'], | |
| 2889 | - 'content' => '', | |
| 2890 | - ); | |
| 2891 | - $unset_content = true; | |
| 2614 | + $response_data = array( 'redirect' => $args['success_url'] ); | |
| 2892 | 2615 | |
| 2893 | - if ( ! empty( $args['form']->options['redirect_delay'] ) ) { | |
| 2894 | - $response_data['delay'] = $args['form']->options['redirect_delay_time']; | |
| 2895 | - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args ); | |
| 2896 | - $unset_content = false; | |
| 2897 | - } | |
| 2898 | - | |
| 2899 | 2616 | if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) { |
| 2900 | 2617 | $response_data['openInNewTab'] = 1; |
| 2901 | 2618 | |
| 2902 | - // Only show open in new tab text if there is no delay. | |
| 2903 | - if ( empty( $response_data['content'] ) ) { | |
| 2904 | - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg(); | |
| 2619 | + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg(); | |
| 2905 | 2620 | |
| 2906 | - $args['form']->options['success_msg'] = $args['message']; | |
| 2907 | - $args['form']->options['edit_msg'] = $args['message']; | |
| 2908 | - if ( ! isset( $args['fields'] ) ) { | |
| 2909 | - $args['fields'] = FrmField::get_all_for_form( $args['form']->id ); | |
| 2910 | - } | |
| 2621 | + $args['form']->options['success_msg'] = $args['message']; | |
| 2622 | + $args['form']->options['edit_msg'] = $args['message']; | |
| 2623 | + if ( ! isset( $args['fields'] ) ) { | |
| 2624 | + $args['fields'] = FrmField::get_all_for_form( $args['form']->id ); | |
| 2625 | + } | |
| 2911 | 2626 | |
| 2912 | - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args ); | |
| 2627 | + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args ); | |
| 2913 | 2628 | |
| 2914 | - ob_start(); | |
| 2915 | - self::show_lone_success_message( $args ); | |
| 2916 | - $response_data['content'] .= ob_get_clean(); | |
| 2917 | - $unset_content = false; | |
| 2918 | - }//end if | |
| 2629 | + ob_start(); | |
| 2630 | + self::show_lone_success_messsage( $args ); | |
| 2631 | + $response_data['content'] = ob_get_clean(); | |
| 2919 | 2632 | |
| 2920 | 2633 | $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args ); |
| 2921 | - }//end if | |
| 2922 | - | |
| 2923 | - if ( $unset_content && '' === $response_data['content'] ) { | |
| 2924 | - unset( $response_data['content'] ); | |
| 2925 | 2634 | } |
| 2926 | 2635 | |
| 2927 | 2636 | return $response_data; |
| 2928 | 2637 | } |
| @@ -2934,9 +2643,9 @@ | ||
| 2934 | 2643 | * |
| 2935 | 2644 | * @param array $args See {@see FrmFormsController::run_success_action()}. |
| 2936 | 2645 | */ |
| 2937 | 2646 | private static function redirect_after_submit_using_js( $args ) { |
| 2938 | - $success_msg = $args['form']->options['redirect_delay_msg']; | |
| 2647 | + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg(); | |
| 2939 | 2648 | $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args ); |
| 2940 | 2649 | $success_url = esc_url_raw( $args['success_url'] ); |
| 2941 | 2650 | |
| 2942 | 2651 | /** |
| @@ -2943,11 +2652,11 @@ | ||
| 2943 | 2652 | * Filters the delay time before redirecting when On Submit Redirect action is delayed. |
| 2944 | 2653 | * |
| 2945 | 2654 | * @since 6.0 |
| 2946 | 2655 | * |
| 2947 | - * @param int $delay_time Delay time in milliseconds. | |
| 2656 | + * @param int $delay_time Delay time in miliseconds. | |
| 2948 | 2657 | */ |
| 2949 | - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] ); | |
| 2658 | + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 ); | |
| 2950 | 2659 | |
| 2951 | 2660 | if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) { |
| 2952 | 2661 | $redirect_js = 'window.open("' . $success_url . '", "_blank")'; |
| 2953 | 2662 | } else { |
| @@ -2976,10 +2685,8 @@ | ||
| 2976 | 2685 | * @param string $success_msg |
| 2977 | 2686 | * @param array $args |
| 2978 | 2687 | */ |
| 2979 | 2688 | private static function get_redirect_message( $success_url, $success_msg, $args ) { |
| 2980 | - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] ); | |
| 2981 | - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) ); | |
| 2982 | 2689 | $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' . |
| 2983 | 2690 | self::get_redirect_fallback_message( $success_url, $args ) . |
| 2984 | 2691 | '</div></div>'; |
| 2985 | 2692 | |
| @@ -3035,9 +2742,9 @@ | ||
| 3035 | 2742 | } else { |
| 3036 | 2743 | self::show_form_after_submit( $atts ); |
| 3037 | 2744 | } |
| 3038 | 2745 | } else { |
| 3039 | - self::show_lone_success_message( $atts ); | |
| 2746 | + self::show_lone_success_messsage( $atts ); | |
| 3040 | 2747 | } |
| 3041 | 2748 | } |
| 3042 | 2749 | |
| 3043 | 2750 | /** |
| @@ -3065,9 +2772,9 @@ | ||
| 3065 | 2772 | |
| 3066 | 2773 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 3067 | 2774 | |
| 3068 | 2775 | $frm_settings = FrmAppHelper::get_settings(); |
| 3069 | - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value; | |
| 2776 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; | |
| 3070 | 2777 | |
| 3071 | 2778 | global $frm_vars; |
| 3072 | 2779 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 3073 | 2780 | |
| @@ -3076,10 +2783,11 @@ | ||
| 3076 | 2783 | include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php'; |
| 3077 | 2784 | } |
| 3078 | 2785 | |
| 3079 | 2786 | /** |
| 2787 | + * @return string - 'before', 'after', or 'submit' | |
| 2788 | + * | |
| 3080 | 2789 | * @since 4.05.02 |
| 3081 | - * @return string - 'before', 'after', or 'submit' | |
| 3082 | 2790 | */ |
| 3083 | 2791 | private static function message_placement( $form, $message ) { |
| 3084 | 2792 | $place = 'before'; |
| 3085 | 2793 | |
| @@ -3091,10 +2799,11 @@ | ||
| 3091 | 2799 | } |
| 3092 | 2800 | } |
| 3093 | 2801 | |
| 3094 | 2802 | /** |
| 2803 | + * @return string - 'before' or 'after' | |
| 2804 | + * | |
| 3095 | 2805 | * @since 4.05.02 |
| 3096 | - * @return string - 'before' or 'after' | |
| 3097 | 2806 | */ |
| 3098 | 2807 | return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) ); |
| 3099 | 2808 | } |
| 3100 | 2809 | |
| @@ -3128,9 +2837,9 @@ | ||
| 3128 | 2837 | * Show the success message without the form |
| 3129 | 2838 | * |
| 3130 | 2839 | * @since 2.05 |
| 3131 | 2840 | */ |
| 3132 | - private static function show_lone_success_message( $atts ) { | |
| 2841 | + private static function show_lone_success_messsage( $atts ) { | |
| 3133 | 2842 | global $frm_vars; |
| 3134 | 2843 | $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true ); |
| 3135 | 2844 | self::maybe_load_css( $atts['form'], $values['custom_style'], $frm_vars['load_css'] ); |
| 3136 | 2845 | |
| @@ -3139,9 +2848,9 @@ | ||
| 3139 | 2848 | $errors = array(); |
| 3140 | 2849 | $form = $atts['form']; |
| 3141 | 2850 | $message = $atts['message']; |
| 3142 | 2851 | |
| 3143 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php'; | |
| 2852 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); | |
| 3144 | 2853 | } |
| 3145 | 2854 | |
| 3146 | 2855 | /** |
| 3147 | 2856 | * Prepare the success message before it's shown |
| @@ -3155,12 +2864,12 @@ | ||
| 3155 | 2864 | * @return string |
| 3156 | 2865 | */ |
| 3157 | 2866 | private static function prepare_submit_message( $form, $entry_id, $args = array() ) { |
| 3158 | 2867 | $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) ); |
| 3159 | - $opt = $args['success_opt'] ?? 'success'; | |
| 2868 | + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success'; | |
| 3160 | 2869 | |
| 3161 | 2870 | if ( $entry_id && is_numeric( $entry_id ) ) { |
| 3162 | - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg; | |
| 2871 | + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg; | |
| 3163 | 2872 | $class = 'frm_message'; |
| 3164 | 2873 | } else { |
| 3165 | 2874 | $message = $frm_settings->failed_msg; |
| 3166 | 2875 | $class = FrmFormsHelper::form_error_class(); |
| @@ -3261,13 +2970,11 @@ | ||
| 3261 | 2970 | global $frm_vars; |
| 3262 | 2971 | |
| 3263 | 2972 | FrmStylesController::enqueue_css(); |
| 3264 | 2973 | |
| 3265 | - if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) { | |
| 2974 | + if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty( $frm_vars['forms_loaded'] ) ) { | |
| 3266 | 2975 | // load formidable js |
| 3267 | 2976 | wp_enqueue_script( 'formidable' ); |
| 3268 | - | |
| 3269 | - FrmHoneypot::maybe_print_honeypot_js(); | |
| 3270 | 2977 | } |
| 3271 | 2978 | } |
| 3272 | 2979 | |
| 3273 | 2980 | /** |
| @@ -3281,12 +2988,12 @@ | ||
| 3281 | 2988 | } |
| 3282 | 2989 | |
| 3283 | 2990 | /** |
| 3284 | 2991 | * @since 2.0.8 |
| 3285 | - * @return bool | |
| 2992 | + * @return boolean | |
| 3286 | 2993 | */ |
| 3287 | 2994 | private static function is_minification_on( $atts ) { |
| 3288 | - return ! empty( $atts['minimize'] ); | |
| 2995 | + return isset( $atts['minimize'] ) && ! empty( $atts['minimize'] ); | |
| 3289 | 2996 | } |
| 3290 | 2997 | |
| 3291 | 2998 | /** |
| 3292 | 2999 | * @since 5.0.16 |
| @@ -3384,9 +3091,9 @@ | ||
| 3384 | 3091 | |
| 3385 | 3092 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 3386 | 3093 | |
| 3387 | 3094 | $html = FrmAppHelper::clip( |
| 3388 | - function () { | |
| 3095 | + function() { | |
| 3389 | 3096 | FrmAppHelper::maybe_autocomplete_pages_options( |
| 3390 | 3097 | array( |
| 3391 | 3098 | 'field_name' => 'frm_page_dropdown', |
| 3392 | 3099 | 'page_id' => '', |
| @@ -3406,8 +3113,15 @@ | ||
| 3406 | 3113 | |
| 3407 | 3114 | /** |
| 3408 | 3115 | * @deprecated 4.0 |
| 3409 | 3116 | */ |
| 3117 | + public static function new_form( $values = array() ) { | |
| 3118 | + FrmDeprecated::new_form( $values ); | |
| 3119 | + } | |
| 3120 | + | |
| 3121 | + /** | |
| 3122 | + * @deprecated 4.0 | |
| 3123 | + */ | |
| 3410 | 3124 | public static function create( $values = array() ) { |
| 3411 | 3125 | _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' ); |
| 3412 | 3126 | self::update( $values ); |
| 3413 | 3127 | } |
| @@ -3412,16 +3126,75 @@ | ||
| 3412 | 3126 | self::update( $values ); |
| 3413 | 3127 | } |
| 3414 | 3128 | |
| 3415 | 3129 | /** |
| 3416 | - * Education for premium features. | |
| 3130 | + * @deprecated 3.0 | |
| 3131 | + * @codeCoverageIgnore | |
| 3132 | + */ | |
| 3133 | + public static function bulk_create_template( $ids ) { | |
| 3134 | + return FrmDeprecated::bulk_create_template( $ids ); | |
| 3135 | + } | |
| 3136 | + | |
| 3137 | + /** | |
| 3138 | + * @deprecated 3.0 | |
| 3139 | + * @codeCoverageIgnore | |
| 3140 | + */ | |
| 3141 | + public static function edit_key() { | |
| 3142 | + FrmDeprecated::edit_key(); | |
| 3143 | + } | |
| 3144 | + | |
| 3145 | + /** | |
| 3146 | + * @deprecated 3.0 | |
| 3147 | + * @codeCoverageIgnore | |
| 3148 | + */ | |
| 3149 | + public static function edit_description() { | |
| 3150 | + FrmDeprecated::edit_description(); | |
| 3151 | + } | |
| 3152 | + | |
| 3153 | + /** | |
| 3154 | + * @deprecated 4.08 | |
| 3155 | + * @since 3.06 | |
| 3156 | + */ | |
| 3157 | + public static function add_new() { | |
| 3158 | + _deprecated_function( __FUNCTION__, '4.08' ); | |
| 3159 | + } | |
| 3160 | + | |
| 3161 | + /** | |
| 3162 | + * Create a custom template from a form | |
| 3417 | 3163 | * |
| 3418 | - * @since 4.05 | |
| 3419 | - * @deprecated 6.16.3 | |
| 3164 | + * @since 3.06 | |
| 3165 | + * @deprecated 6.7 | |
| 3166 | + */ | |
| 3167 | + public static function build_template() { | |
| 3168 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3169 | + } | |
| 3170 | + | |
| 3171 | + /** | |
| 3172 | + * @deprecated 6.7 | |
| 3420 | 3173 | * |
| 3174 | + * @return bool | |
| 3175 | + */ | |
| 3176 | + public static function expired() { | |
| 3177 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3178 | + return FrmAddonsController::is_license_expired(); | |
| 3179 | + } | |
| 3180 | + | |
| 3181 | + /** | |
| 3182 | + * Get data from api before rendering it so that we can flag the modal as expired | |
| 3183 | + * | |
| 3184 | + * @deprecated 6.7 | |
| 3185 | + * | |
| 3421 | 3186 | * @return void |
| 3422 | 3187 | */ |
| 3423 | - public static function add_form_style_tab_options() { | |
| 3424 | - _deprecated_function( __METHOD__, '6.16.3' ); | |
| 3425 | - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_form_style_options.php'; | |
| 3188 | + public static function before_list_templates() { | |
| 3189 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3190 | + } | |
| 3191 | + | |
| 3192 | + /** | |
| 3193 | + * @deprecated 6.7 | |
| 3194 | + * | |
| 3195 | + * @return void | |
| 3196 | + */ | |
| 3197 | + public static function list_templates() { | |
| 3198 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3426 | 3199 | } |
| 3427 | 3200 | } |