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 +19 -15 6.27 → 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 );
@@ -589,12 +591,14 @@
589 591 * @return void
590 592 */
591 593 private static function assign_featured_templates() {
592 594 foreach ( self::FEATURED_TEMPLATES_IDS as $key ) {
593 - if ( isset( self::$templates[ $key ] ) ) {
594 - self::$templates[ $key ]['is_featured'] = true;
595 - self::$featured_templates[] = self::$templates[ $key ];
595 + if ( ! isset( self::$templates[ $key ] ) ) {
596 + continue;
596 597 }
598 +
599 + self::$templates[ $key ]['is_featured'] = true;
600 + self::$featured_templates[] = self::$templates[ $key ];
597 601 }
598 602 }
599 603
600 604 /**
@@ -777,9 +781,9 @@
777 781 *
778 782 * @return int
779 783 */
780 784 public static function get_template_count() {
781 - if ( empty( self::$templates ) ) {
785 + if ( ! self::$templates ) {
782 786 self::$form_template_api = new FrmFormTemplateApi();
783 787 self::retrieve_and_set_templates();
784 788 }
785 789 return count( self::$templates );