@@ -225,6 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * @since 3.04.02 |
| 228 | + * @param string $link |
|
| 228 | 229 | */ |
| 229 | 230 | private static function prepare_addon_link( &$link ) { |
| 230 | 231 | $site_url = 'https://formidableforms.com/'; |
@@ -292,6 +293,9 @@ discard block |
||
| 292 | 293 | wp_die(); |
| 293 | 294 | } |
| 294 | 295 | |
| 296 | + /** |
|
| 297 | + * @param string $url |
|
| 298 | + */ |
|
| 295 | 299 | private static function send_api_request( $url, $transient = array() ) { |
| 296 | 300 | $data = get_transient( $transient['name'] ); |
| 297 | 301 | if ( $data !== false ) { |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | ) |
| 70 | 70 | ); |
| 71 | 71 | if ( is_array( $response ) && ! is_wp_error( $response ) ) { |
| 72 | - $addons = $response['body']; |
|
| 72 | + $addons = $response['body']; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | if ( ! empty( $addons ) ) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | foreach ( $addons as $k => $addon ) { |
| 79 | 79 | $cats = array_intersect( $skip_categories, $addon['categories'] ); |
| 80 | 80 | if ( empty( $addon['excerpt'] ) || ! empty( $cats ) ) { |
| 81 | - unset( $addons[ $k ] ); |
|
| 81 | + unset( $addons[$k] ); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | return $addons; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | self::prepare_addon_link( $addon['link'] ); |
| 208 | 208 | |
| 209 | 209 | self::set_addon_status( $addon ); |
| 210 | - $addons[ $id ] = $addon; |
|
| 210 | + $addons[$id] = $addon; |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | <?php |
| 5 | 5 | } |
| 6 | 6 | if ( isset( $message ) && $message != '' ) { |
| 7 | - if ( FrmAppHelper::is_admin() ) { |
|
| 7 | + if ( FrmAppHelper::is_admin() ) { |
|
| 8 | 8 | ?> |
| 9 | 9 | <div id="message" class="frm_updated_message"><?php echo wp_kses_post( $message ) ?></div> |
| 10 | 10 | <?php |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | // we need to allow scripts here for javascript in the success message |
| 15 | 15 | echo $message; // WPCS: XSS ok. |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) { |
| 20 | 20 | |
| 21 | 21 | if ( isset( $form ) && is_object( $form ) ) { |
| 22 | - FrmFormsHelper::get_scroll_js( $form->id ); |
|
| 22 | + FrmFormsHelper::get_scroll_js( $form->id ); |
|
| 23 | 23 | } |
| 24 | 24 | ?> |
| 25 | 25 | <div class="<?php echo esc_attr( FrmFormsHelper::form_error_class() ) ?>"> |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | if ( ! FrmAppHelper::is_admin() ) { |
| 29 | 29 | $img = apply_filters( 'frm_error_icon', $img ); |
| 30 | 30 | if ( $img && ! empty( $img ) ) { |
| 31 | - echo '<img src="' . esc_url( $img ) . '" alt="" />'; |
|
| 32 | - } |
|
| 31 | + echo '<img src="' . esc_url( $img ) . '" alt="" />'; |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | FrmFormsHelper::show_errors( compact( 'img', 'errors', 'form' ) ); |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function set_upgrader( &$upgrader ) { |
| 23 | 23 | if ( is_object( $upgrader ) ) { |
| 24 | - $this->upgrader =& $upgrader; |
|
| 24 | + $this->upgrader = & $upgrader; |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
@@ -2,86 +2,86 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * Trigger plugin-wide hook loading |
|
| 7 | - */ |
|
| 8 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | - |
|
| 11 | - $trigger_hooks = $hooks; |
|
| 12 | - $hooks = (array) $hooks; |
|
| 13 | - |
|
| 14 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | - if ( is_admin() ) { |
|
| 16 | - $hooks[] = 'load_admin_hooks'; |
|
| 17 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | - $hooks[] = 'load_ajax_hooks'; |
|
| 19 | - $hooks[] = 'load_form_hooks'; |
|
| 20 | - } |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - if ( is_multisite() ) { |
|
| 24 | - $hooks[] = 'load_multisite_hooks'; |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - // Make sure the hooks are only triggered once |
|
| 28 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | - } |
|
| 30 | - unset( $trigger_hooks ); |
|
| 31 | - |
|
| 32 | - // Instansiate Controllers |
|
| 33 | - foreach ( $controllers as $c ) { |
|
| 34 | - foreach ( $hooks as $hook ) { |
|
| 5 | + /** |
|
| 6 | + * Trigger plugin-wide hook loading |
|
| 7 | + */ |
|
| 8 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 9 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 10 | + |
|
| 11 | + $trigger_hooks = $hooks; |
|
| 12 | + $hooks = (array) $hooks; |
|
| 13 | + |
|
| 14 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 15 | + if ( is_admin() ) { |
|
| 16 | + $hooks[] = 'load_admin_hooks'; |
|
| 17 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 18 | + $hooks[] = 'load_ajax_hooks'; |
|
| 19 | + $hooks[] = 'load_form_hooks'; |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + if ( is_multisite() ) { |
|
| 24 | + $hooks[] = 'load_multisite_hooks'; |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + // Make sure the hooks are only triggered once |
|
| 28 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 29 | + } |
|
| 30 | + unset( $trigger_hooks ); |
|
| 31 | + |
|
| 32 | + // Instansiate Controllers |
|
| 33 | + foreach ( $controllers as $c ) { |
|
| 34 | + foreach ( $hooks as $hook ) { |
|
| 35 | 35 | call_user_func( array( $c, $hook ) ); |
| 36 | 36 | unset( $hook ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | unset( $c ); |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function trigger_load_form_hooks() { |
|
| 44 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | - } |
|
| 43 | + public static function trigger_load_form_hooks() { |
|
| 44 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | public static function load_hooks() { |
| 48 | 48 | add_action( 'rest_api_init', 'FrmAppController::create_rest_routes', 0 ); |
| 49 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 49 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 50 | 50 | add_filter( 'widget_text', 'do_shortcode' ); |
| 51 | 51 | |
| 52 | - // Entries controller |
|
| 53 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 52 | + // Entries controller |
|
| 53 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 54 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 55 | 55 | |
| 56 | - // Form Actions Controller |
|
| 57 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 56 | + // Form Actions Controller |
|
| 57 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 58 | 58 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 59 | 59 | |
| 60 | - // Forms Controller |
|
| 61 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 60 | + // Forms Controller |
|
| 61 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 62 | 62 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 63 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 63 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 64 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 65 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 66 | 66 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 67 | 67 | |
| 68 | 68 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 69 | 69 | |
| 70 | - // Form Shortcodes |
|
| 71 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 70 | + // Form Shortcodes |
|
| 71 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 72 | 72 | |
| 73 | - // Styles Controller |
|
| 74 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 78 | - } |
|
| 73 | + // Styles Controller |
|
| 74 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 75 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 76 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 77 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | public static function load_admin_hooks() { |
| 81 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 81 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 82 | 82 | add_filter( 'admin_body_class', 'FrmAppController::add_admin_class', 999 ); |
| 83 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 84 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 83 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 84 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 85 | 85 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 86 | 86 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
| 87 | 87 | add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' ); |
@@ -90,49 +90,49 @@ discard block |
||
| 90 | 90 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 91 | 91 | add_filter( 'upgrader_pre_download', 'FrmAddonsController::add_shorten_edd_filename_filter', 10, 4 ); |
| 92 | 92 | |
| 93 | - // Entries Controller |
|
| 94 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 95 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 96 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 97 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 98 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 99 | - |
|
| 100 | - // Form Actions Controller |
|
| 101 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 102 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 103 | - } |
|
| 104 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 105 | - |
|
| 106 | - // Forms Controller |
|
| 107 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 108 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 109 | - |
|
| 110 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 111 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 93 | + // Entries Controller |
|
| 94 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 95 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 96 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 97 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 98 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 99 | + |
|
| 100 | + // Form Actions Controller |
|
| 101 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 102 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 103 | + } |
|
| 104 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 105 | + |
|
| 106 | + // Forms Controller |
|
| 107 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 108 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 109 | + |
|
| 110 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 111 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 112 | 112 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 113 | 113 | add_action( 'et_pb_admin_excluded_shortcodes', 'FrmFormsController::prevent_divi_conflict' ); |
| 114 | 114 | |
| 115 | - // Forms Model |
|
| 116 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 115 | + // Forms Model |
|
| 116 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 117 | 117 | |
| 118 | - // Settings Controller |
|
| 119 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 120 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 118 | + // Settings Controller |
|
| 119 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 120 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 121 | 121 | add_action( 'frm_after_settings', 'FrmSettingsController::settings_cta' ); |
| 122 | 122 | add_action( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' ); |
| 123 | 123 | |
| 124 | - // Styles Controller |
|
| 125 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 126 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 124 | + // Styles Controller |
|
| 125 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 126 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 127 | 127 | |
| 128 | - // XML Controller |
|
| 129 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 130 | - } |
|
| 128 | + // XML Controller |
|
| 129 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | 132 | public static function load_ajax_hooks() { |
| 133 | 133 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 134 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 135 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 134 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 135 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 136 | 136 | |
| 137 | 137 | // Addons |
| 138 | 138 | add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
@@ -140,68 +140,68 @@ discard block |
||
| 140 | 140 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
| 141 | 141 | add_action( 'wp_ajax_frm_install_addon', 'FrmAddonsController::ajax_install_addon' ); |
| 142 | 142 | |
| 143 | - // Fields Controller |
|
| 144 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 145 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 146 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 147 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 148 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 149 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 150 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 151 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 152 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 153 | - |
|
| 154 | - // Form Actions Controller |
|
| 155 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 156 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 157 | - |
|
| 158 | - // Forms Controller |
|
| 143 | + // Fields Controller |
|
| 144 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 145 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 146 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 147 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 148 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 149 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 150 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 151 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 152 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 153 | + |
|
| 154 | + // Form Actions Controller |
|
| 155 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 156 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 157 | + |
|
| 158 | + // Forms Controller |
|
| 159 | 159 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 160 | 160 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 161 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 162 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 163 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 164 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 161 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 162 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 163 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 164 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 165 | 165 | |
| 166 | 166 | // Settings |
| 167 | 167 | add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' ); |
| 168 | 168 | |
| 169 | - // Styles Controller |
|
| 170 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 171 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 172 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 173 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 169 | + // Styles Controller |
|
| 170 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 171 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 172 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 173 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 174 | 174 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 175 | 175 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 176 | 176 | |
| 177 | - // XML Controller |
|
| 177 | + // XML Controller |
|
| 178 | 178 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 179 | 179 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 180 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 181 | - } |
|
| 180 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | public static function load_form_hooks() { |
| 184 | - // Fields Controller |
|
| 185 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 186 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 187 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 188 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 184 | + // Fields Controller |
|
| 185 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 186 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 187 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 188 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 189 | 189 | |
| 190 | 190 | // Forms Controller |
| 191 | 191 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 192 | 192 | |
| 193 | - // Styles Controller |
|
| 194 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 195 | - } |
|
| 193 | + // Styles Controller |
|
| 194 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | public static function load_view_hooks() { |
| 198 | - // Hooks go here when a view is loaded |
|
| 199 | - } |
|
| 198 | + // Hooks go here when a view is loaded |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | public static function load_multisite_hooks() { |
| 202 | 202 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 203 | 203 | |
| 204 | - // drop tables when mu site is deleted |
|
| 205 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 206 | - } |
|
| 204 | + // drop tables when mu site is deleted |
|
| 205 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 206 | + } |
|
| 207 | 207 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
| 11 | 11 | |
| 12 | 12 | self::maybe_load_listing_hooks(); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | public static function maybe_load_listing_hooks() { |
| 16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function head() { |
|
| 27 | + public static function head() { |
|
| 28 | 28 | wp_enqueue_script( 'formidable-editinplace' ); |
| 29 | 29 | |
| 30 | - if ( wp_is_mobile() ) { |
|
| 31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + if ( wp_is_mobile() ) { |
|
| 31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | 36 | require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public static function new_form( $values = array() ) { |
| 62 | 62 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 63 | 63 | |
| 64 | - global $frm_vars; |
|
| 64 | + global $frm_vars; |
|
| 65 | 65 | |
| 66 | 66 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 67 | 67 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | } else if ( $action == 'new' ) { |
| 73 | 73 | $frm_field_selection = FrmField::field_selection(); |
| 74 | 74 | $values = FrmFormsHelper::setup_new_vars( $values ); |
| 75 | - $id = FrmForm::create( $values ); |
|
| 75 | + $id = FrmForm::create( $values ); |
|
| 76 | 76 | $form = FrmForm::getOne( $id ); |
| 77 | 77 | |
| 78 | 78 | self::create_default_email_action( $form ); |
| 79 | 79 | |
| 80 | 80 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 81 | 81 | |
| 82 | - $values['id'] = $id; |
|
| 82 | + $values['id'] = $id; |
|
| 83 | 83 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 84 | - } |
|
| 85 | - } |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Create the default email action |
@@ -91,41 +91,41 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @param object $form |
| 93 | 93 | */ |
| 94 | - private static function create_default_email_action( $form ) { |
|
| 95 | - $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 94 | + private static function create_default_email_action( $form ) { |
|
| 95 | + $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 96 | 96 | |
| 97 | - if ( $create_email ) { |
|
| 98 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 99 | - $action_control->create( $form->id ); |
|
| 100 | - } |
|
| 101 | - } |
|
| 97 | + if ( $create_email ) { |
|
| 98 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 99 | + $action_control->create( $form->id ); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | public static function create( $values = array() ) { |
| 104 | 104 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 105 | 105 | |
| 106 | - global $frm_vars; |
|
| 107 | - if ( empty( $values ) ) { |
|
| 108 | - $values = $_POST; |
|
| 109 | - } |
|
| 106 | + global $frm_vars; |
|
| 107 | + if ( empty( $values ) ) { |
|
| 108 | + $values = $_POST; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - //Set radio button and checkbox meta equal to "other" value |
|
| 112 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 113 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 114 | - } |
|
| 111 | + //Set radio button and checkbox meta equal to "other" value |
|
| 112 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 113 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 117 | 117 | |
| 118 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 119 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 120 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 121 | - } else { |
|
| 118 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 119 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 120 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 121 | + } else { |
|
| 122 | 122 | $errors = FrmForm::validate( $values ); |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | if ( count( $errors ) > 0 ) { |
| 126 | - $hide_preview = true; |
|
| 126 | + $hide_preview = true; |
|
| 127 | 127 | $frm_field_selection = FrmField::field_selection(); |
| 128 | - $form = FrmForm::getOne( $id ); |
|
| 128 | + $form = FrmForm::getOne( $id ); |
|
| 129 | 129 | $fields = FrmField::get_all_for_form( $id ); |
| 130 | 130 | |
| 131 | 131 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true ); |
@@ -133,30 +133,30 @@ discard block |
||
| 133 | 133 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 134 | 134 | |
| 135 | 135 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 136 | - } else { |
|
| 137 | - FrmForm::update( $id, $values, true ); |
|
| 136 | + } else { |
|
| 137 | + FrmForm::update( $id, $values, true ); |
|
| 138 | 138 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 139 | 139 | die( FrmAppHelper::js_redirect( $url ) ); // WPCS: XSS ok. |
| 140 | - } |
|
| 141 | - } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public static function edit( $values = false ) { |
|
| 143 | + public static function edit( $values = false ) { |
|
| 144 | 144 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 145 | 145 | |
| 146 | 146 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 147 | 147 | return self::get_edit_vars( $id ); |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - public static function settings( $id = false, $message = '' ) { |
|
| 150 | + public static function settings( $id = false, $message = '' ) { |
|
| 151 | 151 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 152 | 152 | |
| 153 | 153 | if ( ! $id || ! is_numeric( $id ) ) { |
| 154 | 154 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 155 | - } |
|
| 155 | + } |
|
| 156 | 156 | return self::get_settings_vars( $id, array(), $message ); |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - public static function update_settings() { |
|
| 159 | + public static function update_settings() { |
|
| 160 | 160 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 161 | 161 | |
| 162 | 162 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
@@ -170,39 +170,39 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | FrmForm::update( $id, $_POST ); |
| 172 | 172 | |
| 173 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 173 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 174 | 174 | return self::get_settings_vars( $id, array(), $message ); |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | public static function update( $values = array() ) { |
| 178 | 178 | if ( empty( $values ) ) { |
| 179 | - $values = $_POST; |
|
| 180 | - } |
|
| 179 | + $values = $_POST; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - //Set radio button and checkbox meta equal to "other" value |
|
| 183 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 184 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 185 | - } |
|
| 182 | + //Set radio button and checkbox meta equal to "other" value |
|
| 183 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 184 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - $errors = FrmForm::validate( $values ); |
|
| 188 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 189 | - if ( $permission_error !== false ) { |
|
| 190 | - $errors['form'] = $permission_error; |
|
| 191 | - } |
|
| 187 | + $errors = FrmForm::validate( $values ); |
|
| 188 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 189 | + if ( $permission_error !== false ) { |
|
| 190 | + $errors['form'] = $permission_error; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 194 | 194 | |
| 195 | 195 | if ( count( $errors ) > 0 ) { |
| 196 | - return self::get_edit_vars( $id, $errors ); |
|
| 196 | + return self::get_edit_vars( $id, $errors ); |
|
| 197 | 197 | } else { |
| 198 | - FrmForm::update( $id, $values ); |
|
| 199 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 200 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 198 | + FrmForm::update( $id, $values ); |
|
| 199 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 200 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 201 | 201 | wp_die( esc_html( $message ) ); |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | return self::get_edit_vars( $id, array(), $message ); |
| 204 | - } |
|
| 205 | - } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * Redirect to the url for creating from a template |
@@ -224,30 +224,30 @@ discard block |
||
| 224 | 224 | wp_die(); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public static function duplicate() { |
|
| 227 | + public static function duplicate() { |
|
| 228 | 228 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 229 | 229 | |
| 230 | 230 | $params = FrmForm::list_page_params(); |
| 231 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 232 | - $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 233 | - if ( $form ) { |
|
| 231 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 232 | + $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 233 | + if ( $form ) { |
|
| 234 | 234 | return self::get_edit_vars( $form, array(), $message, true ); |
| 235 | - } else { |
|
| 235 | + } else { |
|
| 236 | 236 | return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
| 237 | - } |
|
| 238 | - } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - public static function page_preview() { |
|
| 240 | + public static function page_preview() { |
|
| 241 | 241 | $params = FrmForm::list_page_params(); |
| 242 | - if ( ! $params['form'] ) { |
|
| 243 | - return; |
|
| 244 | - } |
|
| 242 | + if ( ! $params['form'] ) { |
|
| 243 | + return; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 246 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 247 | 247 | if ( $form ) { |
| 248 | 248 | return self::show_form( $form->id, '', true, true ); |
| 249 | 249 | } |
| 250 | - } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | 253 | * @since 3.0 |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | echo self::page_preview(); // WPCS: XSS ok. |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - public static function preview() { |
|
| 260 | - do_action( 'frm_wp' ); |
|
| 259 | + public static function preview() { |
|
| 260 | + do_action( 'frm_wp' ); |
|
| 261 | 261 | |
| 262 | - global $frm_vars; |
|
| 263 | - $frm_vars['preview'] = true; |
|
| 262 | + global $frm_vars; |
|
| 263 | + $frm_vars['preview'] = true; |
|
| 264 | 264 | |
| 265 | 265 | self::load_wp(); |
| 266 | 266 | |
@@ -374,22 +374,22 @@ discard block |
||
| 374 | 374 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - public static function untrash() { |
|
| 377 | + public static function untrash() { |
|
| 378 | 378 | self::change_form_status( 'untrash' ); |
| 379 | - } |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | public static function bulk_untrash( $ids ) { |
| 382 | 382 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 383 | 383 | |
| 384 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 384 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 385 | 385 | |
| 386 | 386 | $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
| 387 | - return $message; |
|
| 388 | - } |
|
| 387 | + return $message; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - public static function trash() { |
|
| 390 | + public static function trash() { |
|
| 391 | 391 | self::change_form_status( 'trash' ); |
| 392 | - } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * @param string $status |
@@ -442,12 +442,12 @@ discard block |
||
| 442 | 442 | public static function bulk_trash( $ids ) { |
| 443 | 443 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 444 | 444 | |
| 445 | - $count = 0; |
|
| 446 | - foreach ( $ids as $id ) { |
|
| 447 | - if ( FrmForm::trash( $id ) ) { |
|
| 448 | - $count++; |
|
| 449 | - } |
|
| 450 | - } |
|
| 445 | + $count = 0; |
|
| 446 | + foreach ( $ids as $id ) { |
|
| 447 | + if ( FrmForm::trash( $id ) ) { |
|
| 448 | + $count++; |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | 452 | $current_page = FrmAppHelper::get_simple_request( |
| 453 | 453 | array( |
@@ -462,63 +462,63 @@ discard block |
||
| 462 | 462 | '</a>' |
| 463 | 463 | ); |
| 464 | 464 | |
| 465 | - return $message; |
|
| 466 | - } |
|
| 465 | + return $message; |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - public static function destroy() { |
|
| 468 | + public static function destroy() { |
|
| 469 | 469 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 470 | 470 | |
| 471 | 471 | $params = FrmForm::list_page_params(); |
| 472 | 472 | |
| 473 | - //check nonce url |
|
| 473 | + //check nonce url |
|
| 474 | 474 | check_admin_referer( 'destroy_form_' . $params['id'] ); |
| 475 | 475 | |
| 476 | - $count = 0; |
|
| 477 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 478 | - $count++; |
|
| 479 | - } |
|
| 476 | + $count = 0; |
|
| 477 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 478 | + $count++; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | 481 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 482 | 482 | |
| 483 | 483 | self::display_forms_list( $params, $message ); |
| 484 | - } |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | 486 | public static function bulk_destroy( $ids ) { |
| 487 | 487 | FrmAppHelper::permission_check( 'frm_delete_forms' ); |
| 488 | 488 | |
| 489 | - $count = 0; |
|
| 490 | - foreach ( $ids as $id ) { |
|
| 491 | - $d = FrmForm::destroy( $id ); |
|
| 492 | - if ( $d ) { |
|
| 493 | - $count++; |
|
| 494 | - } |
|
| 495 | - } |
|
| 489 | + $count = 0; |
|
| 490 | + foreach ( $ids as $id ) { |
|
| 491 | + $d = FrmForm::destroy( $id ); |
|
| 492 | + if ( $d ) { |
|
| 493 | + $count++; |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 498 | 498 | |
| 499 | - return $message; |
|
| 500 | - } |
|
| 499 | + return $message; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - private static function delete_all() { |
|
| 503 | - //check nonce url |
|
| 502 | + private static function delete_all() { |
|
| 503 | + //check nonce url |
|
| 504 | 504 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
| 505 | - if ( $permission_error !== false ) { |
|
| 505 | + if ( $permission_error !== false ) { |
|
| 506 | 506 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 507 | - return; |
|
| 508 | - } |
|
| 507 | + return; |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | $count = FrmForm::scheduled_delete( time() ); |
| 511 | 511 | $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
| 512 | 512 | |
| 513 | 513 | self::display_forms_list( array(), $message ); |
| 514 | - } |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | 516 | /** |
| 517 | - * Inserts Formidable button |
|
| 518 | - * Hook exists since 2.5.0 |
|
| 519 | - * |
|
| 520 | - * @since 2.0.15 |
|
| 521 | - */ |
|
| 517 | + * Inserts Formidable button |
|
| 518 | + * Hook exists since 2.5.0 |
|
| 519 | + * |
|
| 520 | + * @since 2.0.15 |
|
| 521 | + */ |
|
| 522 | 522 | public static function insert_form_button() { |
| 523 | 523 | if ( current_user_can( 'frm_view_forms' ) ) { |
| 524 | 524 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -529,45 +529,45 @@ discard block |
||
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - public static function insert_form_popup() { |
|
| 532 | + public static function insert_form_popup() { |
|
| 533 | 533 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 534 | 534 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 535 | - return; |
|
| 536 | - } |
|
| 535 | + return; |
|
| 536 | + } |
|
| 537 | 537 | |
| 538 | - FrmAppHelper::load_admin_wide_js(); |
|
| 538 | + FrmAppHelper::load_admin_wide_js(); |
|
| 539 | 539 | |
| 540 | - $shortcodes = array( |
|
| 540 | + $shortcodes = array( |
|
| 541 | 541 | 'formidable' => array( |
| 542 | 542 | 'name' => __( 'Form', 'formidable' ), |
| 543 | 543 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 544 | 544 | ), |
| 545 | - ); |
|
| 545 | + ); |
|
| 546 | 546 | |
| 547 | 547 | $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
| 548 | 548 | |
| 549 | 549 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 550 | - } |
|
| 550 | + } |
|
| 551 | 551 | |
| 552 | - public static function get_shortcode_opts() { |
|
| 552 | + public static function get_shortcode_opts() { |
|
| 553 | 553 | FrmAppHelper::permission_check( 'frm_view_forms' ); |
| 554 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 554 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 555 | 555 | |
| 556 | 556 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 557 | 557 | if ( empty( $shortcode ) ) { |
| 558 | - wp_die(); |
|
| 559 | - } |
|
| 558 | + wp_die(); |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | 561 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 562 | 562 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 563 | 563 | |
| 564 | - $form_id = ''; |
|
| 565 | - $opts = array(); |
|
| 564 | + $form_id = ''; |
|
| 565 | + $opts = array(); |
|
| 566 | 566 | switch ( $shortcode ) { |
| 567 | - case 'formidable': |
|
| 568 | - $opts = array( |
|
| 567 | + case 'formidable': |
|
| 568 | + $opts = array( |
|
| 569 | 569 | 'form_id' => 'id', |
| 570 | - //'key' => ', |
|
| 570 | + //'key' => ', |
|
| 571 | 571 | 'title' => array( |
| 572 | 572 | 'val' => 1, |
| 573 | 573 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | 'val' => 1, |
| 581 | 581 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 582 | 582 | ), |
| 583 | - ); |
|
| 584 | - } |
|
| 583 | + ); |
|
| 584 | + } |
|
| 585 | 585 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 586 | 586 | |
| 587 | 587 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -592,38 +592,38 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 594 | 594 | |
| 595 | - echo '</div>'; |
|
| 595 | + echo '</div>'; |
|
| 596 | 596 | |
| 597 | - wp_die(); |
|
| 598 | - } |
|
| 597 | + wp_die(); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 601 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 601 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 602 | 602 | |
| 603 | - global $wpdb, $frm_vars; |
|
| 603 | + global $wpdb, $frm_vars; |
|
| 604 | 604 | |
| 605 | 605 | if ( empty( $params ) ) { |
| 606 | 606 | $params = FrmForm::list_page_params(); |
| 607 | - } |
|
| 607 | + } |
|
| 608 | 608 | |
| 609 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 609 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 610 | 610 | |
| 611 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 611 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 612 | 612 | |
| 613 | - $wp_list_table->prepare_items(); |
|
| 613 | + $wp_list_table->prepare_items(); |
|
| 614 | 614 | |
| 615 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 616 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 615 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 616 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 617 | 617 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 618 | - die(); |
|
| 619 | - } |
|
| 618 | + die(); |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 622 | - } |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | public static function get_columns( $columns ) { |
| 625 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 626 | - $columns['id'] = 'ID'; |
|
| 625 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 626 | + $columns['id'] = 'ID'; |
|
| 627 | 627 | |
| 628 | 628 | $type = FrmAppHelper::get_simple_request( |
| 629 | 629 | array( |
@@ -633,18 +633,18 @@ discard block |
||
| 633 | 633 | ) |
| 634 | 634 | ); |
| 635 | 635 | |
| 636 | - if ( 'template' == $type ) { |
|
| 637 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 638 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 639 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 640 | - } else { |
|
| 641 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 642 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 643 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 644 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 645 | - } |
|
| 636 | + if ( 'template' == $type ) { |
|
| 637 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 638 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 639 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 640 | + } else { |
|
| 641 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 642 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 643 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 644 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 647 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 648 | 648 | |
| 649 | 649 | add_screen_option( |
| 650 | 650 | 'per_page', |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | ) |
| 656 | 656 | ); |
| 657 | 657 | |
| 658 | - return $columns; |
|
| 658 | + return $columns; |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | public static function get_sortable_columns() { |
@@ -685,34 +685,34 @@ discard block |
||
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | public static function save_per_page( $save, $option, $value ) { |
| 688 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 689 | - $save = (int) $value; |
|
| 690 | - } |
|
| 691 | - return $save; |
|
| 692 | - } |
|
| 688 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 689 | + $save = (int) $value; |
|
| 690 | + } |
|
| 691 | + return $save; |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | 694 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 695 | - global $frm_vars; |
|
| 695 | + global $frm_vars; |
|
| 696 | 696 | |
| 697 | - $form = FrmForm::getOne( $id ); |
|
| 698 | - if ( ! $form ) { |
|
| 699 | - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 700 | - } |
|
| 697 | + $form = FrmForm::getOne( $id ); |
|
| 698 | + if ( ! $form ) { |
|
| 699 | + wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | - if ( $form->parent_form_id ) { |
|
| 702 | + if ( $form->parent_form_id ) { |
|
| 703 | 703 | wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | 706 | $frm_field_selection = FrmField::field_selection(); |
| 707 | 707 | $fields = FrmField::get_all_for_form( $form->id ); |
| 708 | 708 | |
| 709 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 710 | - $reset_fields = false; |
|
| 711 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 709 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 710 | + $reset_fields = false; |
|
| 711 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 712 | 712 | |
| 713 | - if ( $reset_fields ) { |
|
| 714 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 715 | - } |
|
| 713 | + if ( $reset_fields ) { |
|
| 714 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | 717 | unset( $end_section_values, $last_order, $open, $reset_fields ); |
| 718 | 718 | |
@@ -720,30 +720,30 @@ discard block |
||
| 720 | 720 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 721 | 721 | $values['fields'] = $fields; |
| 722 | 722 | |
| 723 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 724 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 725 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 726 | - } |
|
| 723 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 724 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 725 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | 728 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 729 | 729 | |
| 730 | - if ( $form->default_template ) { |
|
| 730 | + if ( $form->default_template ) { |
|
| 731 | 731 | wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) ); |
| 732 | 732 | } elseif ( defined( 'DOING_AJAX' ) ) { |
| 733 | - wp_die(); |
|
| 734 | - } else if ( $create_link ) { |
|
| 733 | + wp_die(); |
|
| 734 | + } else if ( $create_link ) { |
|
| 735 | 735 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 736 | - } else { |
|
| 736 | + } else { |
|
| 737 | 737 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 738 | - } |
|
| 739 | - } |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | 741 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 742 | 742 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 743 | 743 | |
| 744 | - global $frm_vars; |
|
| 744 | + global $frm_vars; |
|
| 745 | 745 | |
| 746 | - $form = FrmForm::getOne( $id ); |
|
| 746 | + $form = FrmForm::getOne( $id ); |
|
| 747 | 747 | |
| 748 | 748 | $fields = FrmField::get_all_for_form( $id ); |
| 749 | 749 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
@@ -754,17 +754,17 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | self::clean_submit_html( $values ); |
| 756 | 756 | |
| 757 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 757 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 758 | 758 | |
| 759 | 759 | $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
| 760 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 760 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 761 | 761 | |
| 762 | 762 | $styles = apply_filters( 'frm_get_style_opts', array() ); |
| 763 | 763 | |
| 764 | 764 | $first_h3 = 'frm_first_h3'; |
| 765 | 765 | |
| 766 | 766 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 767 | - } |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | 769 | /** |
| 770 | 770 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -779,10 +779,10 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 782 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 783 | 783 | $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
| 784 | - $linked_forms = array(); |
|
| 785 | - $col = 'one'; |
|
| 784 | + $linked_forms = array(); |
|
| 785 | + $col = 'one'; |
|
| 786 | 786 | $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
| 787 | 787 | |
| 788 | 788 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | $advanced_helpers = self::advanced_helpers( compact( 'fields', 'form_id' ) ); |
| 792 | 792 | |
| 793 | 793 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * @since 3.04.01 |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | '' => '', |
| 883 | 883 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 884 | 884 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 885 | - ); |
|
| 885 | + ); |
|
| 886 | 886 | |
| 887 | 887 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 888 | 888 | unset( $entry_shortcodes['post_id'] ); |
@@ -931,21 +931,21 @@ discard block |
||
| 931 | 931 | wp_die(); |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 934 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 935 | 935 | self::get_entry_by_param( $entry ); |
| 936 | - if ( ! $entry ) { |
|
| 937 | - return $content; |
|
| 938 | - } |
|
| 936 | + if ( ! $entry ) { |
|
| 937 | + return $content; |
|
| 938 | + } |
|
| 939 | 939 | |
| 940 | - if ( is_object( $form ) ) { |
|
| 941 | - $form = $form->id; |
|
| 942 | - } |
|
| 940 | + if ( is_object( $form ) ) { |
|
| 941 | + $form = $form->id; |
|
| 942 | + } |
|
| 943 | 943 | |
| 944 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 945 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 944 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 945 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 946 | 946 | |
| 947 | - return $content; |
|
| 948 | - } |
|
| 947 | + return $content; |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | 950 | private static function get_entry_by_param( &$entry ) { |
| 951 | 951 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -957,66 +957,66 @@ discard block |
||
| 957 | 957 | } |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 961 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 962 | - } |
|
| 960 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 961 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 962 | + } |
|
| 963 | 963 | |
| 964 | - public static function process_bulk_form_actions( $errors ) { |
|
| 965 | - if ( ! $_REQUEST ) { |
|
| 966 | - return $errors; |
|
| 967 | - } |
|
| 964 | + public static function process_bulk_form_actions( $errors ) { |
|
| 965 | + if ( ! $_REQUEST ) { |
|
| 966 | + return $errors; |
|
| 967 | + } |
|
| 968 | 968 | |
| 969 | 969 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 970 | - if ( $bulkaction == -1 ) { |
|
| 970 | + if ( $bulkaction == -1 ) { |
|
| 971 | 971 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 972 | - } |
|
| 972 | + } |
|
| 973 | 973 | |
| 974 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 975 | - FrmAppHelper::remove_get_action(); |
|
| 974 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 975 | + FrmAppHelper::remove_get_action(); |
|
| 976 | 976 | |
| 977 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 978 | - } |
|
| 977 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 978 | + } |
|
| 979 | 979 | |
| 980 | 980 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 981 | - if ( empty( $ids ) ) { |
|
| 982 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 983 | - return $errors; |
|
| 984 | - } |
|
| 985 | - |
|
| 986 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 987 | - if ( $permission_error !== false ) { |
|
| 988 | - $errors[] = $permission_error; |
|
| 989 | - return $errors; |
|
| 990 | - } |
|
| 991 | - |
|
| 992 | - if ( ! is_array( $ids ) ) { |
|
| 993 | - $ids = explode( ',', $ids ); |
|
| 994 | - } |
|
| 995 | - |
|
| 996 | - switch ( $bulkaction ) { |
|
| 997 | - case 'delete': |
|
| 998 | - $message = self::bulk_destroy( $ids ); |
|
| 981 | + if ( empty( $ids ) ) { |
|
| 982 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 983 | + return $errors; |
|
| 984 | + } |
|
| 985 | + |
|
| 986 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 987 | + if ( $permission_error !== false ) { |
|
| 988 | + $errors[] = $permission_error; |
|
| 989 | + return $errors; |
|
| 990 | + } |
|
| 991 | + |
|
| 992 | + if ( ! is_array( $ids ) ) { |
|
| 993 | + $ids = explode( ',', $ids ); |
|
| 994 | + } |
|
| 995 | + |
|
| 996 | + switch ( $bulkaction ) { |
|
| 997 | + case 'delete': |
|
| 998 | + $message = self::bulk_destroy( $ids ); |
|
| 999 | 999 | break; |
| 1000 | - case 'trash': |
|
| 1001 | - $message = self::bulk_trash( $ids ); |
|
| 1000 | + case 'trash': |
|
| 1001 | + $message = self::bulk_trash( $ids ); |
|
| 1002 | 1002 | break; |
| 1003 | - case 'untrash': |
|
| 1004 | - $message = self::bulk_untrash( $ids ); |
|
| 1005 | - } |
|
| 1003 | + case 'untrash': |
|
| 1004 | + $message = self::bulk_untrash( $ids ); |
|
| 1005 | + } |
|
| 1006 | 1006 | |
| 1007 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1007 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 1008 | 1008 | echo '<div id="message" class="frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; // WPCS: XSS ok. |
| 1009 | - } |
|
| 1009 | + } |
|
| 1010 | 1010 | |
| 1011 | - return $errors; |
|
| 1012 | - } |
|
| 1011 | + return $errors; |
|
| 1012 | + } |
|
| 1013 | 1013 | |
| 1014 | 1014 | /** |
| 1015 | 1015 | * @deprecated 1.07.05 |
| 1016 | 1016 | * @codeCoverageIgnore |
| 1017 | 1017 | */ |
| 1018 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 1019 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 1018 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 1019 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 1020 | 1020 | |
| 1021 | 1021 | $path = untrailingslashit( trim( $path ) ); |
| 1022 | 1022 | $templates = glob( $path . '/*.php' ); |
@@ -1024,130 +1024,130 @@ discard block |
||
| 1024 | 1024 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 1025 | 1025 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 1026 | 1026 | $template_query = array( 'form_key' => $filename ); |
| 1027 | - if ( $template ) { |
|
| 1028 | - $template_query['is_template'] = 1; |
|
| 1029 | - } |
|
| 1030 | - if ( $default ) { |
|
| 1031 | - $template_query['default_template'] = 1; |
|
| 1032 | - } |
|
| 1027 | + if ( $template ) { |
|
| 1028 | + $template_query['is_template'] = 1; |
|
| 1029 | + } |
|
| 1030 | + if ( $default ) { |
|
| 1031 | + $template_query['default_template'] = 1; |
|
| 1032 | + } |
|
| 1033 | 1033 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 1034 | 1034 | |
| 1035 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 1036 | - $values['form_key'] = $filename; |
|
| 1037 | - $values['is_template'] = $template; |
|
| 1038 | - $values['status'] = 'published'; |
|
| 1039 | - if ( $default ) { |
|
| 1040 | - $values['default_template'] = 1; |
|
| 1041 | - } |
|
| 1035 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 1036 | + $values['form_key'] = $filename; |
|
| 1037 | + $values['is_template'] = $template; |
|
| 1038 | + $values['status'] = 'published'; |
|
| 1039 | + if ( $default ) { |
|
| 1040 | + $values['default_template'] = 1; |
|
| 1041 | + } |
|
| 1042 | 1042 | |
| 1043 | - include( $templates[ $i ] ); |
|
| 1043 | + include( $templates[ $i ] ); |
|
| 1044 | 1044 | |
| 1045 | - //get updated form |
|
| 1045 | + //get updated form |
|
| 1046 | 1046 | if ( isset( $form ) && ! empty( $form ) ) { |
| 1047 | - $old_id = $form->id; |
|
| 1047 | + $old_id = $form->id; |
|
| 1048 | 1048 | $form = FrmForm::getOne( $form->id ); |
| 1049 | - } else { |
|
| 1050 | - $old_id = false; |
|
| 1049 | + } else { |
|
| 1050 | + $old_id = false; |
|
| 1051 | 1051 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 1052 | - } |
|
| 1052 | + } |
|
| 1053 | 1053 | |
| 1054 | - if ( $form ) { |
|
| 1054 | + if ( $form ) { |
|
| 1055 | 1055 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 1056 | - } |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1056 | + } |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | 1059 | |
| 1060 | - public static function route() { |
|
| 1060 | + public static function route() { |
|
| 1061 | 1061 | $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
| 1062 | - $vars = array(); |
|
| 1062 | + $vars = array(); |
|
| 1063 | 1063 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1064 | 1064 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1065 | 1065 | |
| 1066 | 1066 | $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
| 1067 | 1067 | $json_vars = json_decode( $json_vars, true ); |
| 1068 | 1068 | if ( empty( $json_vars ) ) { |
| 1069 | - // json decoding failed so we should return an error message |
|
| 1069 | + // json decoding failed so we should return an error message |
|
| 1070 | 1070 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1071 | - if ( 'edit' == $action ) { |
|
| 1072 | - $action = 'update'; |
|
| 1073 | - } |
|
| 1071 | + if ( 'edit' == $action ) { |
|
| 1072 | + $action = 'update'; |
|
| 1073 | + } |
|
| 1074 | 1074 | |
| 1075 | 1075 | add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
| 1076 | - } else { |
|
| 1076 | + } else { |
|
| 1077 | 1077 | $vars = FrmAppHelper::json_to_array( $json_vars ); |
| 1078 | - $action = $vars[ $action ]; |
|
| 1078 | + $action = $vars[ $action ]; |
|
| 1079 | 1079 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1080 | 1080 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1081 | 1081 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1082 | - } |
|
| 1083 | - } else { |
|
| 1082 | + } |
|
| 1083 | + } else { |
|
| 1084 | 1084 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1085 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1086 | - // override the action for this page |
|
| 1087 | - $action = 'delete_all'; |
|
| 1088 | - } |
|
| 1089 | - } |
|
| 1085 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1086 | + // override the action for this page |
|
| 1087 | + $action = 'delete_all'; |
|
| 1088 | + } |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | 1091 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1092 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1092 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1093 | 1093 | |
| 1094 | - switch ( $action ) { |
|
| 1095 | - case 'new': |
|
| 1094 | + switch ( $action ) { |
|
| 1095 | + case 'new': |
|
| 1096 | 1096 | return self::new_form( $vars ); |
| 1097 | - case 'create': |
|
| 1098 | - case 'edit': |
|
| 1099 | - case 'update': |
|
| 1100 | - case 'duplicate': |
|
| 1101 | - case 'trash': |
|
| 1102 | - case 'untrash': |
|
| 1103 | - case 'destroy': |
|
| 1104 | - case 'delete_all': |
|
| 1105 | - case 'settings': |
|
| 1106 | - case 'update_settings': |
|
| 1097 | + case 'create': |
|
| 1098 | + case 'edit': |
|
| 1099 | + case 'update': |
|
| 1100 | + case 'duplicate': |
|
| 1101 | + case 'trash': |
|
| 1102 | + case 'untrash': |
|
| 1103 | + case 'destroy': |
|
| 1104 | + case 'delete_all': |
|
| 1105 | + case 'settings': |
|
| 1106 | + case 'update_settings': |
|
| 1107 | 1107 | return self::$action( $vars ); |
| 1108 | - default: |
|
| 1108 | + default: |
|
| 1109 | 1109 | do_action( 'frm_form_action_' . $action ); |
| 1110 | 1110 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1111 | - return; |
|
| 1112 | - } |
|
| 1111 | + return; |
|
| 1112 | + } |
|
| 1113 | 1113 | |
| 1114 | 1114 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1115 | - if ( $action == -1 ) { |
|
| 1115 | + if ( $action == -1 ) { |
|
| 1116 | 1116 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1117 | - } |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | 1119 | if ( strpos( $action, 'bulk_' ) === 0 ) { |
| 1120 | - FrmAppHelper::remove_get_action(); |
|
| 1121 | - return self::list_form(); |
|
| 1122 | - } |
|
| 1120 | + FrmAppHelper::remove_get_action(); |
|
| 1121 | + return self::list_form(); |
|
| 1122 | + } |
|
| 1123 | 1123 | |
| 1124 | - return self::display_forms_list(); |
|
| 1125 | - } |
|
| 1126 | - } |
|
| 1124 | + return self::display_forms_list(); |
|
| 1125 | + } |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | - public static function json_error( $errors ) { |
|
| 1129 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1130 | - return $errors; |
|
| 1131 | - } |
|
| 1128 | + public static function json_error( $errors ) { |
|
| 1129 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1130 | + return $errors; |
|
| 1131 | + } |
|
| 1132 | 1132 | |
| 1133 | 1133 | |
| 1134 | - /* FRONT-END FORMS */ |
|
| 1135 | - public static function admin_bar_css() { |
|
| 1134 | + /* FRONT-END FORMS */ |
|
| 1135 | + public static function admin_bar_css() { |
|
| 1136 | 1136 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1137 | - return; |
|
| 1138 | - } |
|
| 1137 | + return; |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | 1140 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1141 | 1141 | FrmAppHelper::load_font_style(); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | public static function admin_bar_configure() { |
| 1145 | - global $frm_vars; |
|
| 1145 | + global $frm_vars; |
|
| 1146 | 1146 | if ( empty( $frm_vars['forms_loaded'] ) ) { |
| 1147 | - return; |
|
| 1148 | - } |
|
| 1147 | + return; |
|
| 1148 | + } |
|
| 1149 | 1149 | |
| 1150 | - $actions = array(); |
|
| 1150 | + $actions = array(); |
|
| 1151 | 1151 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1152 | 1152 | if ( is_object( $form ) ) { |
| 1153 | 1153 | $actions[ $form->id ] = $form->name; |
@@ -1202,18 +1202,18 @@ discard block |
||
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - //formidable shortcode |
|
| 1205 | + //formidable shortcode |
|
| 1206 | 1206 | public static function get_form_shortcode( $atts ) { |
| 1207 | - global $frm_vars; |
|
| 1207 | + global $frm_vars; |
|
| 1208 | 1208 | if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
| 1209 | - $sc = '[formidable'; |
|
| 1209 | + $sc = '[formidable'; |
|
| 1210 | 1210 | if ( ! empty( $atts ) ) { |
| 1211 | 1211 | foreach ( $atts as $k => $v ) { |
| 1212 | 1212 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | return $sc . ']'; |
| 1216 | - } |
|
| 1216 | + } |
|
| 1217 | 1217 | |
| 1218 | 1218 | $shortcode_atts = shortcode_atts( |
| 1219 | 1219 | array( |
@@ -1231,27 +1231,27 @@ discard block |
||
| 1231 | 1231 | ); |
| 1232 | 1232 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1233 | 1233 | |
| 1234 | - return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1235 | - } |
|
| 1234 | + return self::show_form( $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], $shortcode_atts['description'], $atts ); |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1238 | - if ( empty( $id ) ) { |
|
| 1239 | - $id = $key; |
|
| 1240 | - } |
|
| 1237 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1238 | + if ( empty( $id ) ) { |
|
| 1239 | + $id = $key; |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1243 | - if ( ! $form ) { |
|
| 1244 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1245 | - } |
|
| 1242 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1243 | + if ( ! $form ) { |
|
| 1244 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1245 | + } |
|
| 1246 | 1246 | |
| 1247 | 1247 | FrmAppController::maybe_update_styles(); |
| 1248 | 1248 | |
| 1249 | 1249 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1250 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1250 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1251 | 1251 | |
| 1252 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1252 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1253 | 1253 | |
| 1254 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1254 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1255 | 1255 | |
| 1256 | 1256 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1257 | 1257 | // don't show a draft form on a page |
@@ -1273,7 +1273,7 @@ discard block |
||
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | return $form; |
| 1276 | - } |
|
| 1276 | + } |
|
| 1277 | 1277 | |
| 1278 | 1278 | private static function maybe_get_form_to_show( $id ) { |
| 1279 | 1279 | $form = false; |
@@ -1302,21 +1302,21 @@ discard block |
||
| 1302 | 1302 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1305 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1306 | 1306 | ob_start(); |
| 1307 | 1307 | |
| 1308 | 1308 | do_action( 'frm_before_get_form', $atts ); |
| 1309 | 1309 | |
| 1310 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1310 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1311 | 1311 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1312 | 1312 | |
| 1313 | - $contents = ob_get_contents(); |
|
| 1314 | - ob_end_clean(); |
|
| 1313 | + $contents = ob_get_contents(); |
|
| 1314 | + ob_end_clean(); |
|
| 1315 | 1315 | |
| 1316 | 1316 | self::maybe_minimize_form( $atts, $contents ); |
| 1317 | 1317 | |
| 1318 | - return $contents; |
|
| 1319 | - } |
|
| 1318 | + return $contents; |
|
| 1319 | + } |
|
| 1320 | 1320 | |
| 1321 | 1321 | public static function enqueue_scripts( $params ) { |
| 1322 | 1322 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1662,10 +1662,10 @@ discard block |
||
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | public static function defer_script_loading( $tag, $handle ) { |
| 1665 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1666 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1665 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1666 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1667 | 1667 | } |
| 1668 | - return $tag; |
|
| 1668 | + return $tag; |
|
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | public static function footer_js( $location = 'footer' ) { |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | 6 | |
| 7 | - public static function register_post_types() { |
|
| 7 | + public static function register_post_types() { |
|
| 8 | 8 | register_post_type( |
| 9 | 9 | self::$action_post_type, |
| 10 | 10 | array( |
@@ -21,90 +21,90 @@ discard block |
||
| 21 | 21 | ) |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * post_content: json settings |
|
| 26 | - * menu_order: form id |
|
| 27 | - * post_excerpt: action type |
|
| 28 | - */ |
|
| 24 | + /** |
|
| 25 | + * post_content: json settings |
|
| 26 | + * menu_order: form id |
|
| 27 | + * post_excerpt: action type |
|
| 28 | + */ |
|
| 29 | 29 | |
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function register_actions() { |
|
| 39 | + public static function register_actions() { |
|
| 40 | 40 | $action_classes = array( |
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'payment' => 'FrmDefHrsAction', |
|
| 49 | - ); |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'payment' => 'FrmDefHrsAction', |
|
| 49 | + ); |
|
| 50 | 50 | $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes ); |
| 51 | 51 | |
| 52 | 52 | include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
| 53 | 53 | include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
| 54 | 54 | |
| 55 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | + foreach ( $action_classes as $action_class ) { |
|
| 56 | 56 | self::$registered_actions->register( $action_class ); |
| 57 | - } |
|
| 58 | - } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function get_form_actions( $action = 'all' ) { |
| 61 | - $temp_actions = self::$registered_actions; |
|
| 61 | + $temp_actions = self::$registered_actions; |
|
| 62 | 62 | if ( empty( $temp_actions ) ) { |
| 63 | - self::actions_init(); |
|
| 64 | - $temp_actions = self::$registered_actions->actions; |
|
| 65 | - } else { |
|
| 66 | - $temp_actions = $temp_actions->actions; |
|
| 67 | - } |
|
| 63 | + self::actions_init(); |
|
| 64 | + $temp_actions = self::$registered_actions->actions; |
|
| 65 | + } else { |
|
| 66 | + $temp_actions = $temp_actions->actions; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $actions = array(); |
|
| 69 | + $actions = array(); |
|
| 70 | 70 | |
| 71 | - foreach ( $temp_actions as $a ) { |
|
| 72 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 73 | - return $a; |
|
| 74 | - } |
|
| 71 | + foreach ( $temp_actions as $a ) { |
|
| 72 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 73 | + return $a; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | $actions[ $a->id_base ] = $a; |
| 77 | - } |
|
| 78 | - unset( $temp_actions, $a ); |
|
| 79 | - |
|
| 80 | - $action_limit = 10; |
|
| 81 | - if ( count( $actions ) <= $action_limit ) { |
|
| 82 | - return $actions; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // remove the last few inactive icons if there are too many |
|
| 86 | - $temp_actions = $actions; |
|
| 87 | - arsort( $temp_actions ); |
|
| 88 | - foreach ( $temp_actions as $type => $a ) { |
|
| 89 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 77 | + } |
|
| 78 | + unset( $temp_actions, $a ); |
|
| 79 | + |
|
| 80 | + $action_limit = 10; |
|
| 81 | + if ( count( $actions ) <= $action_limit ) { |
|
| 82 | + return $actions; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // remove the last few inactive icons if there are too many |
|
| 86 | + $temp_actions = $actions; |
|
| 87 | + arsort( $temp_actions ); |
|
| 88 | + foreach ( $temp_actions as $type => $a ) { |
|
| 89 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 90 | 90 | unset( $actions[ $type ] ); |
| 91 | - if ( count( $actions ) <= $action_limit ) { |
|
| 92 | - break; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - unset( $type, $a ); |
|
| 96 | - } |
|
| 91 | + if ( count( $actions ) <= $action_limit ) { |
|
| 92 | + break; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + unset( $type, $a ); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return $actions; |
|
| 99 | - } |
|
| 98 | + return $actions; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * @since 2.0 |
| 103 | 103 | */ |
| 104 | - public static function list_actions( $form, $values ) { |
|
| 105 | - if ( empty( $form ) ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 104 | + public static function list_actions( $form, $values ) { |
|
| 105 | + if ( empty( $form ) ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * use this hook to migrate old settings into a new action |
@@ -117,72 +117,72 @@ discard block |
||
| 117 | 117 | ); |
| 118 | 118 | $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters ); |
| 119 | 119 | |
| 120 | - $action_controls = self::get_form_actions(); |
|
| 120 | + $action_controls = self::get_form_actions(); |
|
| 121 | 121 | |
| 122 | - $action_map = array(); |
|
| 122 | + $action_map = array(); |
|
| 123 | 123 | |
| 124 | 124 | foreach ( $action_controls as $key => $control ) { |
| 125 | - $action_map[ $control->id_base ] = $key; |
|
| 126 | - } |
|
| 125 | + $action_map[ $control->id_base ] = $key; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - foreach ( $form_actions as $action ) { |
|
| 129 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 130 | - // don't try and show settings if action no longer exists |
|
| 131 | - continue; |
|
| 132 | - } |
|
| 128 | + foreach ( $form_actions as $action ) { |
|
| 129 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 130 | + // don't try and show settings if action no longer exists |
|
| 131 | + continue; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 135 | - } |
|
| 136 | - } |
|
| 134 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 139 | 139 | $action_control->_set( $action_key ); |
| 140 | 140 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public static function add_form_action() { |
|
| 143 | + public static function add_form_action() { |
|
| 144 | 144 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 145 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 145 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 146 | 146 | |
| 147 | - global $frm_vars; |
|
| 147 | + global $frm_vars; |
|
| 148 | 148 | |
| 149 | 149 | $action_key = absint( $_POST['list_id'] ); |
| 150 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 150 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 151 | 151 | |
| 152 | - $action_control = self::get_form_actions( $action_type ); |
|
| 152 | + $action_control = self::get_form_actions( $action_type ); |
|
| 153 | 153 | $action_control->_set( $action_key ); |
| 154 | 154 | |
| 155 | - $form_id = absint( $_POST['form_id'] ); |
|
| 155 | + $form_id = absint( $_POST['form_id'] ); |
|
| 156 | 156 | |
| 157 | 157 | $form_action = $action_control->prepare_new( $form_id ); |
| 158 | 158 | |
| 159 | - $values = array(); |
|
| 159 | + $values = array(); |
|
| 160 | 160 | $form = self::fields_to_values( $form_id, $values ); |
| 161 | 161 | |
| 162 | 162 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 163 | - wp_die(); |
|
| 164 | - } |
|
| 163 | + wp_die(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - public static function fill_action() { |
|
| 166 | + public static function fill_action() { |
|
| 167 | 167 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 168 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 168 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 169 | 169 | |
| 170 | - $action_key = absint( $_POST['action_id'] ); |
|
| 171 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 170 | + $action_key = absint( $_POST['action_id'] ); |
|
| 171 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 172 | 172 | |
| 173 | - $action_control = self::get_form_actions( $action_type ); |
|
| 173 | + $action_control = self::get_form_actions( $action_type ); |
|
| 174 | 174 | if ( empty( $action_control ) ) { |
| 175 | - wp_die(); |
|
| 176 | - } |
|
| 175 | + wp_die(); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 178 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 179 | 179 | |
| 180 | - $values = array(); |
|
| 180 | + $values = array(); |
|
| 181 | 181 | $form = self::fields_to_values( $form_action->menu_order, $values ); |
| 182 | 182 | |
| 183 | 183 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 184 | - wp_die(); |
|
| 185 | - } |
|
| 184 | + wp_die(); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | 187 | private static function fields_to_values( $form_id, array &$values ) { |
| 188 | 188 | $form = FrmForm::getOne( $form_id ); |
@@ -193,19 +193,19 @@ discard block |
||
| 193 | 193 | ); |
| 194 | 194 | |
| 195 | 195 | $fields = FrmField::get_all_for_form( $form->id ); |
| 196 | - foreach ( $fields as $k => $f ) { |
|
| 197 | - $f = (array) $f; |
|
| 198 | - $opts = (array) $f['field_options']; |
|
| 196 | + foreach ( $fields as $k => $f ) { |
|
| 197 | + $f = (array) $f; |
|
| 198 | + $opts = (array) $f['field_options']; |
|
| 199 | 199 | $f = array_merge( $opts, $f ); |
| 200 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 201 | - $f['post_field'] = ''; |
|
| 202 | - } |
|
| 203 | - $values['fields'][] = $f; |
|
| 200 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 201 | + $f['post_field'] = ''; |
|
| 202 | + } |
|
| 203 | + $values['fields'][] = $f; |
|
| 204 | 204 | unset( $k, $f ); |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - return $form; |
|
| 208 | - } |
|
| 207 | + return $form; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | public static function update_settings( $form_id ) { |
| 211 | 211 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | wp_die( esc_html__( 'You do not have permission to do that', 'formidable' ) ); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - global $wpdb; |
|
| 216 | + global $wpdb; |
|
| 217 | 217 | |
| 218 | - $registered_actions = self::$registered_actions->actions; |
|
| 218 | + $registered_actions = self::$registered_actions->actions; |
|
| 219 | 219 | |
| 220 | 220 | $old_actions = FrmDb::get_col( |
| 221 | 221 | $wpdb->posts, |
@@ -225,23 +225,23 @@ discard block |
||
| 225 | 225 | ), |
| 226 | 226 | 'ID' |
| 227 | 227 | ); |
| 228 | - $new_actions = array(); |
|
| 228 | + $new_actions = array(); |
|
| 229 | 229 | |
| 230 | - foreach ( $registered_actions as $registered_action ) { |
|
| 230 | + foreach ( $registered_actions as $registered_action ) { |
|
| 231 | 231 | $action_ids = $registered_action->update_callback( $form_id ); |
| 232 | - if ( ! empty( $action_ids ) ) { |
|
| 233 | - $new_actions[] = $action_ids; |
|
| 234 | - } |
|
| 235 | - } |
|
| 232 | + if ( ! empty( $action_ids ) ) { |
|
| 233 | + $new_actions[] = $action_ids; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - //Only use array_merge if there are new actions |
|
| 238 | - if ( ! empty( $new_actions ) ) { |
|
| 239 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 240 | - } |
|
| 241 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 237 | + //Only use array_merge if there are new actions |
|
| 238 | + if ( ! empty( $new_actions ) ) { |
|
| 239 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 240 | + } |
|
| 241 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 242 | 242 | |
| 243 | 243 | self::delete_missing_actions( $old_actions ); |
| 244 | - } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | 246 | public static function delete_missing_actions( $old_actions ) { |
| 247 | 247 | if ( ! empty( $old_actions ) ) { |
@@ -261,22 +261,22 @@ discard block |
||
| 261 | 261 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * @param string $event |
|
| 266 | - */ |
|
| 264 | + /** |
|
| 265 | + * @param string $event |
|
| 266 | + */ |
|
| 267 | 267 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 268 | 268 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 269 | 269 | |
| 270 | 270 | if ( empty( $form_actions ) ) { |
| 271 | - return; |
|
| 272 | - } |
|
| 271 | + return; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | FrmForm::maybe_get_form( $form ); |
| 275 | 275 | |
| 276 | - $link_settings = self::get_form_actions( $type ); |
|
| 277 | - if ( 'all' != $type ) { |
|
| 278 | - $link_settings = array( $type => $link_settings ); |
|
| 279 | - } |
|
| 276 | + $link_settings = self::get_form_actions( $type ); |
|
| 277 | + if ( 'all' != $type ) { |
|
| 278 | + $link_settings = array( $type => $link_settings ); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | 281 | $stored_actions = array(); |
| 282 | 282 | $action_priority = array(); |
@@ -287,17 +287,17 @@ discard block |
||
| 287 | 287 | $this_event = $event; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - foreach ( $form_actions as $action ) { |
|
| 290 | + foreach ( $form_actions as $action ) { |
|
| 291 | 291 | |
| 292 | 292 | $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); |
| 293 | 293 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 294 | 294 | if ( $skip_this_action ) { |
| 295 | - continue; |
|
| 296 | - } |
|
| 295 | + continue; |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - if ( ! is_object( $entry ) ) { |
|
| 299 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 300 | - } |
|
| 298 | + if ( ! is_object( $entry ) ) { |
|
| 299 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | 302 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
| 303 | 303 | continue; |
@@ -311,64 +311,64 @@ discard block |
||
| 311 | 311 | if ( ! $trigger_children ) { |
| 312 | 312 | continue; |
| 313 | 313 | } |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - // check conditional logic |
|
| 316 | + // check conditional logic |
|
| 317 | 317 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 318 | - if ( $stop ) { |
|
| 319 | - continue; |
|
| 320 | - } |
|
| 318 | + if ( $stop ) { |
|
| 319 | + continue; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - // store actions so they can be triggered with the correct priority |
|
| 323 | - $stored_actions[ $action->ID ] = $action; |
|
| 324 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 322 | + // store actions so they can be triggered with the correct priority |
|
| 323 | + $stored_actions[ $action->ID ] = $action; |
|
| 324 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 325 | 325 | |
| 326 | 326 | unset( $action ); |
| 327 | - } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - if ( ! empty( $stored_actions ) ) { |
|
| 329 | + if ( ! empty( $stored_actions ) ) { |
|
| 330 | 330 | asort( $action_priority ); |
| 331 | 331 | |
| 332 | - // make sure hooks are loaded |
|
| 333 | - new FrmNotification(); |
|
| 332 | + // make sure hooks are loaded |
|
| 333 | + new FrmNotification(); |
|
| 334 | 334 | |
| 335 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 336 | - $action = $stored_actions[ $action_id ]; |
|
| 335 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 336 | + $action = $stored_actions[ $action_id ]; |
|
| 337 | 337 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 338 | 338 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 339 | 339 | |
| 340 | - // If post is created, get updated $entry object |
|
| 341 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 340 | + // If post is created, get updated $entry object |
|
| 341 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 342 | 342 | $entry = FrmEntry::getOne( $entry->id, true ); |
| 343 | - } |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | 348 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 349 | 349 | if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
| 350 | - // continue if we know which actions to copy |
|
| 351 | - return; |
|
| 352 | - } |
|
| 350 | + // continue if we know which actions to copy |
|
| 351 | + return; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | $action_controls = self::get_form_actions(); |
| 355 | 355 | |
| 356 | - foreach ( $action_controls as $action_control ) { |
|
| 357 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 358 | - unset( $action_control ); |
|
| 359 | - } |
|
| 360 | - } |
|
| 356 | + foreach ( $action_controls as $action_control ) { |
|
| 357 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 358 | + unset( $action_control ); |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - public static function limit_by_type( $where ) { |
|
| 363 | - global $frm_vars, $wpdb; |
|
| 362 | + public static function limit_by_type( $where ) { |
|
| 363 | + global $frm_vars, $wpdb; |
|
| 364 | 364 | |
| 365 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 366 | - return $where; |
|
| 367 | - } |
|
| 365 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 366 | + return $where; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 370 | - return $where; |
|
| 371 | - } |
|
| 369 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 370 | + return $where; |
|
| 371 | + } |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | foreach ( $keys as $key ) { |
| 396 | 396 | // don't register new action if old action with the same id is already registered |
| 397 | 397 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 398 | - $this->actions[ $key ]->_register(); |
|
| 398 | + $this->actions[ $key ]->_register(); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | } |