PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/controllers/FrmFormTemplatesController.php +22 -17 6.26 → trunk View file →
@@ -153,13 +153,15 @@
153 153 add_action( 'admin_menu', self::class . '::menu', 14 );
154 154 add_action( 'admin_footer', self::class . '::render_modal' );
155 155 add_filter( 'frm_form_nav_list', self::class . '::append_new_template_to_nav', 10, 2 );
156 156
157 - if ( self::is_templates_page() ) {
158 - add_action( 'admin_init', self::class . '::set_form_templates_data' );
159 - add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
160 - add_filter( 'frm_show_footer_links', '__return_false' );
157 + if ( ! self::is_templates_page() ) {
158 + return;
161 159 }
160 +
161 + add_action( 'admin_init', self::class . '::set_form_templates_data' );
162 + add_action( 'admin_enqueue_scripts', self::class . '::enqueue_assets', 15 );
163 + add_filter( 'frm_show_footer_links', '__return_false' );
162 164 }
163 165
164 166 /**
165 167 * Add Form Templates menu item to sidebar and define index page.
@@ -349,9 +351,9 @@
349 351 }
350 352 }
351 353
352 354 // Update the favorite templates option.
353 - update_option( self::FAVORITE_TEMPLATES_OPTION, self::$favorite_templates );
355 + update_option( self::FAVORITE_TEMPLATES_OPTION, self::$favorite_templates, false );
354 356
355 357 // Return the updated list of favorite templates.
356 358 wp_send_json_success( self::$favorite_templates );
357 359 }
@@ -374,14 +376,9 @@
374 376 // Get posted data.
375 377 $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
376 378 $new_form_id = FrmForm::duplicate( $form_id, 1, true );
377 379
378 - if ( ! $new_form_id ) {
379 - // Send an error response if form duplication fails.
380 - $response = array(
381 - 'message' => __( 'There was an error creating a template.', 'formidable' ),
382 - );
383 - } else {
380 + if ( $new_form_id ) {
384 381 FrmForm::update( $new_form_id, FrmFormsController::get_modal_values() );
385 382
386 383 // Send a success response with redirect URL.
387 384 $response = array(
@@ -386,8 +383,13 @@
386 383 // Send a success response with redirect URL.
387 384 $response = array(
388 385 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ) . '&_wpnonce=' . wp_create_nonce(),
389 386 );
387 + } else {
388 + // Send an error response if form duplication fails.
389 + $response = array(
390 + 'message' => __( 'There was an error creating a template.', 'formidable' ),
391 + );
390 392 }
391 393
392 394 // Send response.
393 395 echo wp_json_encode( $response );
@@ -406,9 +408,9 @@
406 408 check_ajax_referer( 'frm_ajax', 'nonce' );
407 409
408 410 $email = FrmAppHelper::get_post_param( 'email', '', 'sanitize_email' );
409 411
410 - if ( empty( $email ) || ! is_email( $email ) ) {
412 + if ( ! $email || ! is_email( $email ) ) {
411 413 wp_send_json_error(
412 414 array( 'message' => __( 'Please enter a valid email address.', 'formidable' ) ),
413 415 WP_Http::BAD_REQUEST
414 416 );
@@ -565,9 +567,10 @@
565 567 // Assigned via JavaScript.
566 568 'count' => 0,
567 569 );
568 570 }
569 - $special_categories['all-items'] = array(
571 +
572 + $special_categories['all-items'] = array(
570 573 'name' => __( 'All Templates', 'formidable' ),
571 574 'count' => self::get_template_count(),
572 575 );
573 576
@@ -588,12 +591,14 @@
588 591 * @return void
589 592 */
590 593 private static function assign_featured_templates() {
591 594 foreach ( self::FEATURED_TEMPLATES_IDS as $key ) {
592 - if ( isset( self::$templates[ $key ] ) ) {
593 - self::$templates[ $key ]['is_featured'] = true;
594 - self::$featured_templates[] = self::$templates[ $key ];
595 + if ( ! isset( self::$templates[ $key ] ) ) {
596 + continue;
595 597 }
598 +
599 + self::$templates[ $key ]['is_featured'] = true;
600 + self::$featured_templates[] = self::$templates[ $key ];
596 601 }
597 602 }
598 603
599 604 /**
@@ -776,9 +781,9 @@
776 781 *
777 782 * @return int
778 783 */
779 784 public static function get_template_count() {
780 - if ( empty( self::$templates ) ) {
785 + if ( ! self::$templates ) {
781 786 self::$form_template_api = new FrmFormTemplateApi();
782 787 self::retrieve_and_set_templates();
783 788 }
784 789 return count( self::$templates );