@@ -800,6 +800,7 @@ discard block |
||
| 800 | 800 | /** |
| 801 | 801 | * Get an array of the helper shortcodes to display in the customization panel |
| 802 | 802 | * @since 2.0.6 |
| 803 | + * @param boolean $settings_tab |
|
| 803 | 804 | */ |
| 804 | 805 | private static function get_shortcode_helpers( $settings_tab ) { |
| 805 | 806 | $entry_shortcodes = array( |
@@ -875,6 +876,9 @@ discard block |
||
| 875 | 876 | return $content; |
| 876 | 877 | } |
| 877 | 878 | |
| 879 | + /** |
|
| 880 | + * @param boolean $entry |
|
| 881 | + */ |
|
| 878 | 882 | private static function get_entry_by_param( &$entry ) { |
| 879 | 883 | if ( ! $entry || ! is_object( $entry ) ) { |
| 880 | 884 | if ( ! $entry || ! is_numeric( $entry ) ) { |
@@ -1198,6 +1202,9 @@ discard block |
||
| 1198 | 1202 | return $form; |
| 1199 | 1203 | } |
| 1200 | 1204 | |
| 1205 | + /** |
|
| 1206 | + * @param string $id |
|
| 1207 | + */ |
|
| 1201 | 1208 | private static function maybe_get_form_to_show( $id ) { |
| 1202 | 1209 | $form = false; |
| 1203 | 1210 | |
@@ -1597,6 +1604,7 @@ discard block |
||
| 1597 | 1604 | |
| 1598 | 1605 | /** |
| 1599 | 1606 | * @since 2.0.8 |
| 1607 | + * @param string $content |
|
| 1600 | 1608 | */ |
| 1601 | 1609 | private static function maybe_minimize_form( $atts, &$content ) { |
| 1602 | 1610 | // check if minimizing is turned on |
@@ -1664,6 +1672,7 @@ discard block |
||
| 1664 | 1672 | /** |
| 1665 | 1673 | * @deprecated 3.0 |
| 1666 | 1674 | * @codeCoverageIgnore |
| 1675 | + * @param string $field |
|
| 1667 | 1676 | */ |
| 1668 | 1677 | private static function edit_in_place_value( $field ) { |
| 1669 | 1678 | _deprecated_function( __METHOD__, '3.0' ); |
@@ -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,18 +24,18 @@ 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() { |
|
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 27 | + public static function head() { |
|
| 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 | - public static function register_widgets() { |
|
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 38 | - } |
|
| 35 | + public static function register_widgets() { |
|
| 36 | + require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | + register_widget('FrmShowForm'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * By default, Divi processes form shortcodes on the edit post page. |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | return $shortcodes; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public static function list_form() { |
|
| 52 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 51 | + public static function list_form() { |
|
| 52 | + FrmAppHelper::permission_check('frm_view_forms'); |
|
| 53 | 53 | |
| 54 | 54 | $params = FrmForm::list_page_params(); |
| 55 | - $errors = self::process_bulk_form_actions( array()); |
|
| 56 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 55 | + $errors = self::process_bulk_form_actions( array()); |
|
| 56 | + $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 57 | 57 | |
| 58 | 58 | return self::display_forms_list( $params, '', $errors ); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | public static function new_form( $values = array() ) { |
| 62 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 62 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 63 | 63 | |
| 64 | - global $frm_vars; |
|
| 64 | + global $frm_vars; |
|
| 65 | 65 | |
| 66 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 66 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 67 | 67 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
| 68 | 68 | |
| 69 | 69 | if ( $action == 'create' ) { |
@@ -71,18 +71,18 @@ discard block |
||
| 71 | 71 | return; |
| 72 | 72 | } else if ( $action == 'new' ) { |
| 73 | 73 | $frm_field_selection = FrmField::field_selection(); |
| 74 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 75 | - $id = FrmForm::create( $values ); |
|
| 76 | - $form = FrmForm::getOne($id); |
|
| 74 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
| 75 | + $id = FrmForm::create( $values ); |
|
| 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,118 +91,118 @@ 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 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 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 { |
|
| 122 | - $errors = FrmForm::validate($values); |
|
| 123 | - } |
|
| 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 | + $errors = FrmForm::validate($values); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - if ( count($errors) > 0 ) { |
|
| 126 | - $hide_preview = true; |
|
| 125 | + if ( count($errors) > 0 ) { |
|
| 126 | + $hide_preview = true; |
|
| 127 | 127 | $frm_field_selection = FrmField::field_selection(); |
| 128 | - $form = FrmForm::getOne( $id ); |
|
| 129 | - $fields = FrmField::get_all_for_form($id); |
|
| 128 | + $form = FrmForm::getOne( $id ); |
|
| 129 | + $fields = FrmField::get_all_for_form($id); |
|
| 130 | 130 | |
| 131 | 131 | $values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true); |
| 132 | 132 | $values['fields'] = $fields; |
| 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 ) ); |
| 140 | - } |
|
| 141 | - } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public static function edit( $values = false ) { |
|
| 144 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 143 | + public static function edit( $values = false ) { |
|
| 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 | - return self::get_edit_vars($id); |
|
| 148 | - } |
|
| 147 | + return self::get_edit_vars($id); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - public static function settings( $id = false, $message = '' ) { |
|
| 151 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + public static function settings( $id = false, $message = '' ) { |
|
| 151 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 152 | 152 | |
| 153 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 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() { |
|
| 160 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 159 | + public static function update_settings() { |
|
| 160 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 161 | 161 | |
| 162 | 162 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 163 | 163 | |
| 164 | - $errors = FrmForm::validate($_POST); |
|
| 165 | - if ( count($errors) > 0 ) { |
|
| 166 | - return self::get_settings_vars($id, $errors); |
|
| 167 | - } |
|
| 164 | + $errors = FrmForm::validate($_POST); |
|
| 165 | + if ( count($errors) > 0 ) { |
|
| 166 | + return self::get_settings_vars($id, $errors); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - do_action('frm_before_update_form_settings', $id); |
|
| 169 | + do_action('frm_before_update_form_settings', $id); |
|
| 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( $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() { |
|
| 228 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 227 | + public static function duplicate() { |
|
| 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 { |
|
| 236 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 237 | - } |
|
| 238 | - } |
|
| 235 | + } else { |
|
| 236 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 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(); |
| 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 | |
@@ -370,22 +370,22 @@ discard block |
||
| 370 | 370 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public static function untrash() { |
|
| 373 | + public static function untrash() { |
|
| 374 | 374 | self::change_form_status( 'untrash' ); |
| 375 | - } |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | 377 | public static function bulk_untrash( $ids ) { |
| 378 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 378 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 379 | 379 | |
| 380 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 380 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 381 | 381 | |
| 382 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 383 | - return $message; |
|
| 384 | - } |
|
| 382 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 383 | + return $message; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - public static function trash() { |
|
| 386 | + public static function trash() { |
|
| 387 | 387 | self::change_form_status( 'trash' ); |
| 388 | - } |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * @param string $status |
@@ -434,14 +434,14 @@ discard block |
||
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | public static function bulk_trash( $ids ) { |
| 437 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 437 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 438 | 438 | |
| 439 | - $count = 0; |
|
| 440 | - foreach ( $ids as $id ) { |
|
| 441 | - if ( FrmForm::trash( $id ) ) { |
|
| 442 | - $count++; |
|
| 443 | - } |
|
| 444 | - } |
|
| 439 | + $count = 0; |
|
| 440 | + foreach ( $ids as $id ) { |
|
| 441 | + if ( FrmForm::trash( $id ) ) { |
|
| 442 | + $count++; |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | 446 | $current_page = FrmAppHelper::get_simple_request( array( |
| 447 | 447 | 'param' => 'form_type', |
@@ -449,63 +449,63 @@ discard block |
||
| 449 | 449 | ) ); |
| 450 | 450 | $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
| 451 | 451 | |
| 452 | - return $message; |
|
| 453 | - } |
|
| 452 | + return $message; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - public static function destroy() { |
|
| 456 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 455 | + public static function destroy() { |
|
| 456 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 457 | 457 | |
| 458 | 458 | $params = FrmForm::list_page_params(); |
| 459 | 459 | |
| 460 | - //check nonce url |
|
| 461 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 460 | + //check nonce url |
|
| 461 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 462 | 462 | |
| 463 | - $count = 0; |
|
| 464 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 465 | - $count++; |
|
| 466 | - } |
|
| 463 | + $count = 0; |
|
| 464 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 465 | + $count++; |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 468 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 469 | 469 | |
| 470 | 470 | self::display_forms_list( $params, $message ); |
| 471 | - } |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | public static function bulk_destroy( $ids ) { |
| 474 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 474 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 475 | 475 | |
| 476 | - $count = 0; |
|
| 477 | - foreach ( $ids as $id ) { |
|
| 478 | - $d = FrmForm::destroy( $id ); |
|
| 479 | - if ( $d ) { |
|
| 480 | - $count++; |
|
| 481 | - } |
|
| 482 | - } |
|
| 476 | + $count = 0; |
|
| 477 | + foreach ( $ids as $id ) { |
|
| 478 | + $d = FrmForm::destroy( $id ); |
|
| 479 | + if ( $d ) { |
|
| 480 | + $count++; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 484 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 485 | 485 | |
| 486 | - return $message; |
|
| 487 | - } |
|
| 486 | + return $message; |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - private static function delete_all() { |
|
| 490 | - //check nonce url |
|
| 491 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 492 | - if ( $permission_error !== false ) { |
|
| 489 | + private static function delete_all() { |
|
| 490 | + //check nonce url |
|
| 491 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 492 | + if ( $permission_error !== false ) { |
|
| 493 | 493 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 494 | - return; |
|
| 495 | - } |
|
| 494 | + return; |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | $count = FrmForm::scheduled_delete( time() ); |
| 498 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 498 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 499 | 499 | |
| 500 | 500 | self::display_forms_list( array(), $message ); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | 503 | /** |
| 504 | - * Inserts Formidable button |
|
| 505 | - * Hook exists since 2.5.0 |
|
| 506 | - * |
|
| 507 | - * @since 2.0.15 |
|
| 508 | - */ |
|
| 504 | + * Inserts Formidable button |
|
| 505 | + * Hook exists since 2.5.0 |
|
| 506 | + * |
|
| 507 | + * @since 2.0.15 |
|
| 508 | + */ |
|
| 509 | 509 | public static function insert_form_button() { |
| 510 | 510 | if ( current_user_can('frm_view_forms') ) { |
| 511 | 511 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -516,45 +516,45 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - public static function insert_form_popup() { |
|
| 519 | + public static function insert_form_popup() { |
|
| 520 | 520 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 521 | 521 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 522 | - return; |
|
| 523 | - } |
|
| 522 | + return; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - FrmAppHelper::load_admin_wide_js(); |
|
| 525 | + FrmAppHelper::load_admin_wide_js(); |
|
| 526 | 526 | |
| 527 | - $shortcodes = array( |
|
| 527 | + $shortcodes = array( |
|
| 528 | 528 | 'formidable' => array( |
| 529 | 529 | 'name' => __( 'Form', 'formidable' ), |
| 530 | 530 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 531 | 531 | ), |
| 532 | - ); |
|
| 532 | + ); |
|
| 533 | 533 | |
| 534 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 534 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 535 | 535 | |
| 536 | 536 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 537 | - } |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - public static function get_shortcode_opts() { |
|
| 539 | + public static function get_shortcode_opts() { |
|
| 540 | 540 | FrmAppHelper::permission_check('frm_view_forms'); |
| 541 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 541 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 542 | 542 | |
| 543 | 543 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 544 | - if ( empty($shortcode) ) { |
|
| 545 | - wp_die(); |
|
| 546 | - } |
|
| 544 | + if ( empty($shortcode) ) { |
|
| 545 | + wp_die(); |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | 548 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 549 | 549 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 550 | 550 | |
| 551 | - $form_id = ''; |
|
| 552 | - $opts = array(); |
|
| 551 | + $form_id = ''; |
|
| 552 | + $opts = array(); |
|
| 553 | 553 | switch ( $shortcode ) { |
| 554 | - case 'formidable': |
|
| 555 | - $opts = array( |
|
| 554 | + case 'formidable': |
|
| 555 | + $opts = array( |
|
| 556 | 556 | 'form_id' => 'id', |
| 557 | - //'key' => ', |
|
| 557 | + //'key' => ', |
|
| 558 | 558 | 'title' => array( |
| 559 | 559 | 'val' => 1, |
| 560 | 560 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -567,8 +567,8 @@ discard block |
||
| 567 | 567 | 'val' => 1, |
| 568 | 568 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 569 | 569 | ), |
| 570 | - ); |
|
| 571 | - } |
|
| 570 | + ); |
|
| 571 | + } |
|
| 572 | 572 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 573 | 573 | |
| 574 | 574 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -579,38 +579,38 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 581 | 581 | |
| 582 | - echo '</div>'; |
|
| 582 | + echo '</div>'; |
|
| 583 | 583 | |
| 584 | - wp_die(); |
|
| 585 | - } |
|
| 584 | + wp_die(); |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 588 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 588 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 589 | 589 | |
| 590 | - global $wpdb, $frm_vars; |
|
| 590 | + global $wpdb, $frm_vars; |
|
| 591 | 591 | |
| 592 | 592 | if ( empty( $params ) ) { |
| 593 | 593 | $params = FrmForm::list_page_params(); |
| 594 | - } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 596 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 597 | 597 | |
| 598 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 598 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 599 | 599 | |
| 600 | - $wp_list_table->prepare_items(); |
|
| 600 | + $wp_list_table->prepare_items(); |
|
| 601 | 601 | |
| 602 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 603 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 602 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 603 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 604 | 604 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 605 | - die(); |
|
| 606 | - } |
|
| 605 | + die(); |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 609 | - } |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | 611 | public static function get_columns( $columns ) { |
| 612 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 613 | - $columns['id'] = 'ID'; |
|
| 612 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 613 | + $columns['id'] = 'ID'; |
|
| 614 | 614 | |
| 615 | 615 | $type = FrmAppHelper::get_simple_request( array( |
| 616 | 616 | 'param' => 'form_type', |
@@ -618,18 +618,18 @@ discard block |
||
| 618 | 618 | 'default' => 'published', |
| 619 | 619 | ) ); |
| 620 | 620 | |
| 621 | - if ( 'template' == $type ) { |
|
| 622 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 623 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 624 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 625 | - } else { |
|
| 626 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 627 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 628 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 629 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 630 | - } |
|
| 621 | + if ( 'template' == $type ) { |
|
| 622 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 623 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 624 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 625 | + } else { |
|
| 626 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 627 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 628 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 629 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 632 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 633 | 633 | |
| 634 | 634 | add_screen_option( 'per_page', array( |
| 635 | 635 | 'label' => __( 'Forms', 'formidable' ), |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | 'option' => 'formidable_page_formidable_per_page', |
| 638 | 638 | ) ); |
| 639 | 639 | |
| 640 | - return $columns; |
|
| 640 | + return $columns; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | public static function get_sortable_columns() { |
@@ -665,86 +665,86 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | public static function save_per_page( $save, $option, $value ) { |
| 668 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 669 | - $save = (int) $value; |
|
| 670 | - } |
|
| 671 | - return $save; |
|
| 672 | - } |
|
| 668 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 669 | + $save = (int) $value; |
|
| 670 | + } |
|
| 671 | + return $save; |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 675 | - global $frm_vars; |
|
| 675 | + global $frm_vars; |
|
| 676 | 676 | |
| 677 | - $form = FrmForm::getOne( $id ); |
|
| 678 | - if ( ! $form ) { |
|
| 679 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 680 | - } |
|
| 677 | + $form = FrmForm::getOne( $id ); |
|
| 678 | + if ( ! $form ) { |
|
| 679 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 680 | + } |
|
| 681 | 681 | |
| 682 | - if ( $form->parent_form_id ) { |
|
| 682 | + if ( $form->parent_form_id ) { |
|
| 683 | 683 | wp_die( sprintf( __( '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>' )); |
| 684 | - } |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | $frm_field_selection = FrmField::field_selection(); |
| 687 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 687 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 688 | 688 | |
| 689 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 690 | - $reset_fields = false; |
|
| 691 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 689 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 690 | + $reset_fields = false; |
|
| 691 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 692 | 692 | |
| 693 | - if ( $reset_fields ) { |
|
| 694 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 695 | - } |
|
| 693 | + if ( $reset_fields ) { |
|
| 694 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 697 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 698 | 698 | |
| 699 | 699 | $args = array( 'parent_form_id' => $form->id ); |
| 700 | 700 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 701 | 701 | $values['fields'] = $fields; |
| 702 | 702 | |
| 703 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 704 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 705 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 706 | - } |
|
| 703 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 704 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 705 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | 708 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 709 | 709 | |
| 710 | - if ( $form->default_template ) { |
|
| 711 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 712 | - } else if ( defined('DOING_AJAX') ) { |
|
| 713 | - wp_die(); |
|
| 714 | - } else if ( $create_link ) { |
|
| 710 | + if ( $form->default_template ) { |
|
| 711 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 712 | + } else if ( defined('DOING_AJAX') ) { |
|
| 713 | + wp_die(); |
|
| 714 | + } else if ( $create_link ) { |
|
| 715 | 715 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 716 | - } else { |
|
| 716 | + } else { |
|
| 717 | 717 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 718 | - } |
|
| 719 | - } |
|
| 718 | + } |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | 721 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 722 | 722 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 723 | 723 | |
| 724 | - global $frm_vars; |
|
| 724 | + global $frm_vars; |
|
| 725 | 725 | |
| 726 | - $form = FrmForm::getOne( $id ); |
|
| 726 | + $form = FrmForm::getOne( $id ); |
|
| 727 | 727 | |
| 728 | - $fields = FrmField::get_all_for_form($id); |
|
| 729 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 728 | + $fields = FrmField::get_all_for_form($id); |
|
| 729 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 730 | 730 | |
| 731 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 732 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 733 | - } |
|
| 731 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 732 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | 735 | self::clean_submit_html( $values ); |
| 736 | 736 | |
| 737 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 737 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 738 | 738 | |
| 739 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 740 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 739 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 740 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 741 | 741 | |
| 742 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 742 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 743 | 743 | |
| 744 | 744 | $first_h3 = 'frm_first_h3'; |
| 745 | 745 | |
| 746 | 746 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 747 | - } |
|
| 747 | + } |
|
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | 750 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -759,11 +759,11 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 763 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 764 | - $linked_forms = array(); |
|
| 765 | - $col = 'one'; |
|
| 766 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 762 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 763 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 764 | + $linked_forms = array(); |
|
| 765 | + $col = 'one'; |
|
| 766 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 767 | 767 | |
| 768 | 768 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 769 | 769 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 772 | 772 | |
| 773 | 773 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 774 | - } |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | 777 | * Get an array of the options to display in the advanced tab |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | '' => '', |
| 813 | 813 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 814 | 814 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 815 | - ); |
|
| 815 | + ); |
|
| 816 | 816 | |
| 817 | 817 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 818 | 818 | unset( $entry_shortcodes['post_id'] ); |
@@ -859,21 +859,21 @@ discard block |
||
| 859 | 859 | wp_die(); |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 862 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 863 | 863 | self::get_entry_by_param( $entry ); |
| 864 | - if ( ! $entry ) { |
|
| 865 | - return $content; |
|
| 866 | - } |
|
| 864 | + if ( ! $entry ) { |
|
| 865 | + return $content; |
|
| 866 | + } |
|
| 867 | 867 | |
| 868 | - if ( is_object( $form ) ) { |
|
| 869 | - $form = $form->id; |
|
| 870 | - } |
|
| 868 | + if ( is_object( $form ) ) { |
|
| 869 | + $form = $form->id; |
|
| 870 | + } |
|
| 871 | 871 | |
| 872 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 873 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 872 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 873 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 874 | 874 | |
| 875 | - return $content; |
|
| 876 | - } |
|
| 875 | + return $content; |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | 878 | private static function get_entry_by_param( &$entry ) { |
| 879 | 879 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -885,207 +885,207 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 889 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 890 | - } |
|
| 888 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 889 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - public static function process_bulk_form_actions( $errors ) { |
|
| 893 | - if ( ! $_REQUEST ) { |
|
| 894 | - return $errors; |
|
| 895 | - } |
|
| 892 | + public static function process_bulk_form_actions( $errors ) { |
|
| 893 | + if ( ! $_REQUEST ) { |
|
| 894 | + return $errors; |
|
| 895 | + } |
|
| 896 | 896 | |
| 897 | 897 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 898 | - if ( $bulkaction == -1 ) { |
|
| 898 | + if ( $bulkaction == -1 ) { |
|
| 899 | 899 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 900 | - } |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 903 | - FrmAppHelper::remove_get_action(); |
|
| 902 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 903 | + FrmAppHelper::remove_get_action(); |
|
| 904 | 904 | |
| 905 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 906 | - } |
|
| 905 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | 908 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 909 | - if ( empty( $ids ) ) { |
|
| 910 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 911 | - return $errors; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 915 | - if ( $permission_error !== false ) { |
|
| 916 | - $errors[] = $permission_error; |
|
| 917 | - return $errors; |
|
| 918 | - } |
|
| 919 | - |
|
| 920 | - if ( ! is_array( $ids ) ) { |
|
| 921 | - $ids = explode( ',', $ids ); |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - switch ( $bulkaction ) { |
|
| 925 | - case 'delete': |
|
| 926 | - $message = self::bulk_destroy( $ids ); |
|
| 909 | + if ( empty( $ids ) ) { |
|
| 910 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 911 | + return $errors; |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 915 | + if ( $permission_error !== false ) { |
|
| 916 | + $errors[] = $permission_error; |
|
| 917 | + return $errors; |
|
| 918 | + } |
|
| 919 | + |
|
| 920 | + if ( ! is_array( $ids ) ) { |
|
| 921 | + $ids = explode( ',', $ids ); |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + switch ( $bulkaction ) { |
|
| 925 | + case 'delete': |
|
| 926 | + $message = self::bulk_destroy( $ids ); |
|
| 927 | 927 | break; |
| 928 | - case 'trash': |
|
| 929 | - $message = self::bulk_trash( $ids ); |
|
| 928 | + case 'trash': |
|
| 929 | + $message = self::bulk_trash( $ids ); |
|
| 930 | 930 | break; |
| 931 | - case 'untrash': |
|
| 932 | - $message = self::bulk_untrash( $ids ); |
|
| 933 | - } |
|
| 931 | + case 'untrash': |
|
| 932 | + $message = self::bulk_untrash( $ids ); |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 935 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 936 | 936 | echo '<div id="message" class="updated frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; |
| 937 | - } |
|
| 937 | + } |
|
| 938 | 938 | |
| 939 | - return $errors; |
|
| 940 | - } |
|
| 939 | + return $errors; |
|
| 940 | + } |
|
| 941 | 941 | |
| 942 | 942 | /** |
| 943 | 943 | * @deprecated 1.07.05 |
| 944 | 944 | * @codeCoverageIgnore |
| 945 | 945 | */ |
| 946 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 947 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 946 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 947 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 948 | 948 | |
| 949 | - $path = untrailingslashit(trim($path)); |
|
| 949 | + $path = untrailingslashit(trim($path)); |
|
| 950 | 950 | $templates = glob( $path . '/*.php' ); |
| 951 | 951 | |
| 952 | 952 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 953 | 953 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 954 | 954 | $template_query = array( 'form_key' => $filename ); |
| 955 | - if ( $template ) { |
|
| 956 | - $template_query['is_template'] = 1; |
|
| 957 | - } |
|
| 958 | - if ( $default ) { |
|
| 959 | - $template_query['default_template'] = 1; |
|
| 960 | - } |
|
| 955 | + if ( $template ) { |
|
| 956 | + $template_query['is_template'] = 1; |
|
| 957 | + } |
|
| 958 | + if ( $default ) { |
|
| 959 | + $template_query['default_template'] = 1; |
|
| 960 | + } |
|
| 961 | 961 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 962 | 962 | |
| 963 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 964 | - $values['form_key'] = $filename; |
|
| 965 | - $values['is_template'] = $template; |
|
| 966 | - $values['status'] = 'published'; |
|
| 967 | - if ( $default ) { |
|
| 968 | - $values['default_template'] = 1; |
|
| 969 | - } |
|
| 970 | - |
|
| 971 | - include( $templates[ $i ] ); |
|
| 972 | - |
|
| 973 | - //get updated form |
|
| 974 | - if ( isset($form) && ! empty($form) ) { |
|
| 975 | - $old_id = $form->id; |
|
| 976 | - $form = FrmForm::getOne($form->id); |
|
| 977 | - } else { |
|
| 978 | - $old_id = false; |
|
| 963 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 964 | + $values['form_key'] = $filename; |
|
| 965 | + $values['is_template'] = $template; |
|
| 966 | + $values['status'] = 'published'; |
|
| 967 | + if ( $default ) { |
|
| 968 | + $values['default_template'] = 1; |
|
| 969 | + } |
|
| 970 | + |
|
| 971 | + include( $templates[ $i ] ); |
|
| 972 | + |
|
| 973 | + //get updated form |
|
| 974 | + if ( isset($form) && ! empty($form) ) { |
|
| 975 | + $old_id = $form->id; |
|
| 976 | + $form = FrmForm::getOne($form->id); |
|
| 977 | + } else { |
|
| 978 | + $old_id = false; |
|
| 979 | 979 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 980 | - } |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | - if ( $form ) { |
|
| 982 | + if ( $form ) { |
|
| 983 | 983 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 984 | - } |
|
| 985 | - } |
|
| 986 | - } |
|
| 984 | + } |
|
| 985 | + } |
|
| 986 | + } |
|
| 987 | 987 | |
| 988 | - public static function route() { |
|
| 989 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 990 | - $vars = array(); |
|
| 988 | + public static function route() { |
|
| 989 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 990 | + $vars = array(); |
|
| 991 | 991 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 992 | 992 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 993 | 993 | |
| 994 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 995 | - $json_vars = json_decode($json_vars, true); |
|
| 996 | - if ( empty($json_vars) ) { |
|
| 997 | - // json decoding failed so we should return an error message |
|
| 994 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 995 | + $json_vars = json_decode($json_vars, true); |
|
| 996 | + if ( empty($json_vars) ) { |
|
| 997 | + // json decoding failed so we should return an error message |
|
| 998 | 998 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 999 | - if ( 'edit' == $action ) { |
|
| 1000 | - $action = 'update'; |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 1004 | - } else { |
|
| 1005 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 1006 | - $action = $vars[ $action ]; |
|
| 999 | + if ( 'edit' == $action ) { |
|
| 1000 | + $action = 'update'; |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 1004 | + } else { |
|
| 1005 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 1006 | + $action = $vars[ $action ]; |
|
| 1007 | 1007 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1008 | 1008 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1009 | 1009 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1010 | - } |
|
| 1011 | - } else { |
|
| 1010 | + } |
|
| 1011 | + } else { |
|
| 1012 | 1012 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1013 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1014 | - // override the action for this page |
|
| 1015 | - $action = 'delete_all'; |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1013 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1014 | + // override the action for this page |
|
| 1015 | + $action = 'delete_all'; |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | 1018 | |
| 1019 | 1019 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1020 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1021 | - |
|
| 1022 | - switch ( $action ) { |
|
| 1023 | - case 'new': |
|
| 1024 | - return self::new_form($vars); |
|
| 1025 | - case 'create': |
|
| 1026 | - case 'edit': |
|
| 1027 | - case 'update': |
|
| 1028 | - case 'duplicate': |
|
| 1029 | - case 'trash': |
|
| 1030 | - case 'untrash': |
|
| 1031 | - case 'destroy': |
|
| 1032 | - case 'delete_all': |
|
| 1033 | - case 'settings': |
|
| 1034 | - case 'update_settings': |
|
| 1020 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1021 | + |
|
| 1022 | + switch ( $action ) { |
|
| 1023 | + case 'new': |
|
| 1024 | + return self::new_form($vars); |
|
| 1025 | + case 'create': |
|
| 1026 | + case 'edit': |
|
| 1027 | + case 'update': |
|
| 1028 | + case 'duplicate': |
|
| 1029 | + case 'trash': |
|
| 1030 | + case 'untrash': |
|
| 1031 | + case 'destroy': |
|
| 1032 | + case 'delete_all': |
|
| 1033 | + case 'settings': |
|
| 1034 | + case 'update_settings': |
|
| 1035 | 1035 | return self::$action( $vars ); |
| 1036 | - default: |
|
| 1036 | + default: |
|
| 1037 | 1037 | do_action( 'frm_form_action_' . $action ); |
| 1038 | 1038 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1039 | - return; |
|
| 1040 | - } |
|
| 1039 | + return; |
|
| 1040 | + } |
|
| 1041 | 1041 | |
| 1042 | 1042 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1043 | - if ( $action == -1 ) { |
|
| 1043 | + if ( $action == -1 ) { |
|
| 1044 | 1044 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1045 | - } |
|
| 1045 | + } |
|
| 1046 | 1046 | |
| 1047 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 1048 | - FrmAppHelper::remove_get_action(); |
|
| 1049 | - return self::list_form(); |
|
| 1050 | - } |
|
| 1047 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 1048 | + FrmAppHelper::remove_get_action(); |
|
| 1049 | + return self::list_form(); |
|
| 1050 | + } |
|
| 1051 | 1051 | |
| 1052 | - return self::display_forms_list(); |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1052 | + return self::display_forms_list(); |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | 1055 | |
| 1056 | - public static function json_error( $errors ) { |
|
| 1057 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1058 | - return $errors; |
|
| 1059 | - } |
|
| 1056 | + public static function json_error( $errors ) { |
|
| 1057 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1058 | + return $errors; |
|
| 1059 | + } |
|
| 1060 | 1060 | |
| 1061 | 1061 | |
| 1062 | - /* FRONT-END FORMS */ |
|
| 1063 | - public static function admin_bar_css() { |
|
| 1062 | + /* FRONT-END FORMS */ |
|
| 1063 | + public static function admin_bar_css() { |
|
| 1064 | 1064 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1065 | - return; |
|
| 1066 | - } |
|
| 1065 | + return; |
|
| 1066 | + } |
|
| 1067 | 1067 | |
| 1068 | 1068 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1069 | 1069 | FrmAppHelper::load_font_style(); |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | public static function admin_bar_configure() { |
| 1073 | - global $frm_vars; |
|
| 1074 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 1075 | - return; |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - $actions = array(); |
|
| 1079 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 1080 | - if ( is_object($form) ) { |
|
| 1081 | - $actions[ $form->id ] = $form->name; |
|
| 1082 | - } |
|
| 1083 | - unset($form); |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - if ( empty($actions) ) { |
|
| 1087 | - return; |
|
| 1088 | - } |
|
| 1073 | + global $frm_vars; |
|
| 1074 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 1075 | + return; |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + $actions = array(); |
|
| 1079 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 1080 | + if ( is_object($form) ) { |
|
| 1081 | + $actions[ $form->id ] = $form->name; |
|
| 1082 | + } |
|
| 1083 | + unset($form); |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + if ( empty($actions) ) { |
|
| 1087 | + return; |
|
| 1088 | + } |
|
| 1089 | 1089 | |
| 1090 | 1090 | self::add_menu_to_admin_bar(); |
| 1091 | 1091 | self::add_forms_to_admin_bar( $actions ); |
@@ -1126,18 +1126,18 @@ discard block |
||
| 1126 | 1126 | } |
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - //formidable shortcode |
|
| 1129 | + //formidable shortcode |
|
| 1130 | 1130 | public static function get_form_shortcode( $atts ) { |
| 1131 | - global $frm_vars; |
|
| 1132 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1133 | - $sc = '[formidable'; |
|
| 1131 | + global $frm_vars; |
|
| 1132 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1133 | + $sc = '[formidable'; |
|
| 1134 | 1134 | if ( ! empty( $atts ) ) { |
| 1135 | 1135 | foreach ( $atts as $k => $v ) { |
| 1136 | 1136 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
| 1139 | 1139 | return $sc . ']'; |
| 1140 | - } |
|
| 1140 | + } |
|
| 1141 | 1141 | |
| 1142 | 1142 | $shortcode_atts = shortcode_atts( array( |
| 1143 | 1143 | 'id' => '', |
@@ -1152,30 +1152,30 @@ discard block |
||
| 1152 | 1152 | ), $atts ); |
| 1153 | 1153 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1154 | 1154 | |
| 1155 | - return self::show_form( |
|
| 1156 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1157 | - $shortcode_atts['description'], $atts |
|
| 1158 | - ); |
|
| 1159 | - } |
|
| 1155 | + return self::show_form( |
|
| 1156 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1157 | + $shortcode_atts['description'], $atts |
|
| 1158 | + ); |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1162 | - if ( empty( $id ) ) { |
|
| 1163 | - $id = $key; |
|
| 1164 | - } |
|
| 1161 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1162 | + if ( empty( $id ) ) { |
|
| 1163 | + $id = $key; |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1167 | - if ( ! $form ) { |
|
| 1168 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1169 | - } |
|
| 1166 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1167 | + if ( ! $form ) { |
|
| 1168 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1169 | + } |
|
| 1170 | 1170 | |
| 1171 | 1171 | FrmAppController::maybe_update_styles(); |
| 1172 | 1172 | |
| 1173 | 1173 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1174 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1174 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1175 | 1175 | |
| 1176 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1176 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1177 | 1177 | |
| 1178 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1178 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1179 | 1179 | |
| 1180 | 1180 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1181 | 1181 | // don't show a draft form on a page |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | return $form; |
| 1199 | - } |
|
| 1199 | + } |
|
| 1200 | 1200 | |
| 1201 | 1201 | private static function maybe_get_form_to_show( $id ) { |
| 1202 | 1202 | $form = false; |
@@ -1225,21 +1225,21 @@ discard block |
||
| 1225 | 1225 | 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'] ); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1229 | - ob_start(); |
|
| 1228 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1229 | + ob_start(); |
|
| 1230 | 1230 | |
| 1231 | 1231 | do_action( 'frm_before_get_form', $atts ); |
| 1232 | 1232 | |
| 1233 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1233 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1234 | 1234 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1235 | 1235 | |
| 1236 | - $contents = ob_get_contents(); |
|
| 1237 | - ob_end_clean(); |
|
| 1236 | + $contents = ob_get_contents(); |
|
| 1237 | + ob_end_clean(); |
|
| 1238 | 1238 | |
| 1239 | 1239 | self::maybe_minimize_form( $atts, $contents ); |
| 1240 | 1240 | |
| 1241 | - return $contents; |
|
| 1242 | - } |
|
| 1241 | + return $contents; |
|
| 1242 | + } |
|
| 1243 | 1243 | |
| 1244 | 1244 | public static function enqueue_scripts( $params ) { |
| 1245 | 1245 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1578,10 +1578,10 @@ discard block |
||
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | public static function defer_script_loading( $tag, $handle ) { |
| 1581 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1582 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1581 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1582 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1583 | 1583 | } |
| 1584 | - return $tag; |
|
| 1584 | + return $tag; |
|
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | public static function footer_js( $location = 'footer' ) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 8 | 8 | $menu_label .= ' (Lite)'; |
| 9 | 9 | } |
| 10 | - add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
| 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 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public static function head() { |
| 28 | - wp_enqueue_script('formidable-editinplace'); |
|
| 28 | + wp_enqueue_script( 'formidable-editinplace' ); |
|
| 29 | 29 | |
| 30 | 30 | if ( wp_is_mobile() ) { |
| 31 | 31 | wp_enqueue_script( 'jquery-touch-punch' ); |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function register_widgets() { |
| 36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
| 37 | - register_widget('FrmShowForm'); |
|
| 36 | + require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
| 37 | + register_widget( 'FrmShowForm' ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -49,31 +49,31 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public static function list_form() { |
| 52 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 52 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 53 | 53 | |
| 54 | 54 | $params = FrmForm::list_page_params(); |
| 55 | - $errors = self::process_bulk_form_actions( array()); |
|
| 56 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 55 | + $errors = self::process_bulk_form_actions( array() ); |
|
| 56 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
| 57 | 57 | |
| 58 | 58 | return self::display_forms_list( $params, '', $errors ); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public static function new_form( $values = array() ) { |
| 62 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 62 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 63 | 63 | |
| 64 | 64 | global $frm_vars; |
| 65 | 65 | |
| 66 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 67 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
| 66 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 67 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
| 68 | 68 | |
| 69 | 69 | if ( $action == 'create' ) { |
| 70 | - self::create($values); |
|
| 70 | + self::create( $values ); |
|
| 71 | 71 | return; |
| 72 | 72 | } else if ( $action == 'new' ) { |
| 73 | 73 | $frm_field_selection = FrmField::field_selection(); |
| 74 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 74 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
| 75 | 75 | $id = FrmForm::create( $values ); |
| 76 | - $form = FrmForm::getOne($id); |
|
| 76 | + $form = FrmForm::getOne( $id ); |
|
| 77 | 77 | |
| 78 | 78 | self::create_default_email_action( $form ); |
| 79 | 79 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public static function create( $values = array() ) { |
| 104 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 104 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 105 | 105 | |
| 106 | 106 | global $frm_vars; |
| 107 | 107 | if ( empty( $values ) ) { |
@@ -113,22 +113,22 @@ discard block |
||
| 113 | 113 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 116 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 117 | 117 | |
| 118 | 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 | 119 | $frm_settings = FrmAppHelper::get_settings(); |
| 120 | 120 | $errors = array( 'form' => $frm_settings->admin_permission ); |
| 121 | 121 | } else { |
| 122 | - $errors = FrmForm::validate($values); |
|
| 122 | + $errors = FrmForm::validate( $values ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( count($errors) > 0 ) { |
|
| 125 | + if ( count( $errors ) > 0 ) { |
|
| 126 | 126 | $hide_preview = true; |
| 127 | 127 | $frm_field_selection = FrmField::field_selection(); |
| 128 | 128 | $form = FrmForm::getOne( $id ); |
| 129 | - $fields = FrmField::get_all_for_form($id); |
|
| 129 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 130 | 130 | |
| 131 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true); |
|
| 131 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true ); |
|
| 132 | 132 | $values['fields'] = $fields; |
| 133 | 133 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 134 | 134 | |
@@ -141,32 +141,32 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | public static function edit( $values = false ) { |
| 144 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 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 | - return self::get_edit_vars($id); |
|
| 147 | + return self::get_edit_vars( $id ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public static function settings( $id = false, $message = '' ) { |
| 151 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 151 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 152 | 152 | |
| 153 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 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 | 159 | public static function update_settings() { |
| 160 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 160 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 161 | 161 | |
| 162 | 162 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 163 | 163 | |
| 164 | - $errors = FrmForm::validate($_POST); |
|
| 165 | - if ( count($errors) > 0 ) { |
|
| 166 | - return self::get_settings_vars($id, $errors); |
|
| 164 | + $errors = FrmForm::validate( $_POST ); |
|
| 165 | + if ( count( $errors ) > 0 ) { |
|
| 166 | + return self::get_settings_vars( $id, $errors ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - do_action('frm_before_update_form_settings', $id); |
|
| 169 | + do_action( 'frm_before_update_form_settings', $id ); |
|
| 170 | 170 | |
| 171 | 171 | FrmForm::update( $id, $_POST ); |
| 172 | 172 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @since 2.0 |
| 211 | 211 | */ |
| 212 | 212 | public static function _create_from_template() { |
| 213 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 213 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 214 | 214 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 215 | 215 | |
| 216 | 216 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | public static function duplicate() { |
| 228 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 228 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 229 | 229 | |
| 230 | 230 | $params = FrmForm::list_page_params(); |
| 231 | 231 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | if ( $form ) { |
| 234 | 234 | return self::get_edit_vars( $form, array(), $message, true ); |
| 235 | 235 | } else { |
| 236 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 236 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -375,11 +375,11 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | public static function bulk_untrash( $ids ) { |
| 378 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 378 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 379 | 379 | |
| 380 | 380 | $count = FrmForm::set_status( $ids, 'published' ); |
| 381 | 381 | |
| 382 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 382 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 383 | 383 | return $message; |
| 384 | 384 | } |
| 385 | 385 | |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | ), |
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
| 407 | + if ( ! isset( $available_status[$status] ) ) { |
|
| 408 | 408 | return; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
| 411 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
| 412 | 412 | |
| 413 | 413 | $params = FrmForm::list_page_params(); |
| 414 | 414 | |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | check_admin_referer( $status . '_form_' . $params['id'] ); |
| 417 | 417 | |
| 418 | 418 | $count = 0; |
| 419 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
| 420 | - $count++; |
|
| 419 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
| 420 | + $count ++; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $form_type = FrmAppHelper::get_simple_request( array( |
@@ -425,21 +425,21 @@ discard block |
||
| 425 | 425 | 'type' => 'request', |
| 426 | 426 | ) ); |
| 427 | 427 | |
| 428 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 428 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 429 | 429 | $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . $form_type . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
| 430 | 430 | |
| 431 | - $message = $available_status[ $status ]['message']; |
|
| 431 | + $message = $available_status[$status]['message']; |
|
| 432 | 432 | |
| 433 | 433 | self::display_forms_list( $params, $message ); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | public static function bulk_trash( $ids ) { |
| 437 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 437 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 438 | 438 | |
| 439 | 439 | $count = 0; |
| 440 | 440 | foreach ( $ids as $id ) { |
| 441 | 441 | if ( FrmForm::trash( $id ) ) { |
| 442 | - $count++; |
|
| 442 | + $count ++; |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
@@ -453,49 +453,49 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | public static function destroy() { |
| 456 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 456 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 457 | 457 | |
| 458 | 458 | $params = FrmForm::list_page_params(); |
| 459 | 459 | |
| 460 | 460 | //check nonce url |
| 461 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 461 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
| 462 | 462 | |
| 463 | 463 | $count = 0; |
| 464 | 464 | if ( FrmForm::destroy( $params['id'] ) ) { |
| 465 | - $count++; |
|
| 465 | + $count ++; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 468 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 469 | 469 | |
| 470 | 470 | self::display_forms_list( $params, $message ); |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | public static function bulk_destroy( $ids ) { |
| 474 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 474 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 475 | 475 | |
| 476 | 476 | $count = 0; |
| 477 | 477 | foreach ( $ids as $id ) { |
| 478 | 478 | $d = FrmForm::destroy( $id ); |
| 479 | 479 | if ( $d ) { |
| 480 | - $count++; |
|
| 480 | + $count ++; |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 484 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 485 | 485 | |
| 486 | 486 | return $message; |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | private static function delete_all() { |
| 490 | 490 | //check nonce url |
| 491 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 491 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 492 | 492 | if ( $permission_error !== false ) { |
| 493 | 493 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 494 | 494 | return; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $count = FrmForm::scheduled_delete( time() ); |
| 498 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 498 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 499 | 499 | |
| 500 | 500 | self::display_forms_list( array(), $message ); |
| 501 | 501 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @since 2.0.15 |
| 508 | 508 | */ |
| 509 | 509 | public static function insert_form_button() { |
| 510 | - if ( current_user_can('frm_view_forms') ) { |
|
| 510 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
| 511 | 511 | $menu_name = FrmAppHelper::get_menu_name(); |
| 512 | 512 | $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"> |
| 513 | 513 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
@@ -531,17 +531,17 @@ discard block |
||
| 531 | 531 | ), |
| 532 | 532 | ); |
| 533 | 533 | |
| 534 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 534 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
| 535 | 535 | |
| 536 | 536 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | public static function get_shortcode_opts() { |
| 540 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 540 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 541 | 541 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 542 | 542 | |
| 543 | 543 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 544 | - if ( empty($shortcode) ) { |
|
| 544 | + if ( empty( $shortcode ) ) { |
|
| 545 | 545 | wp_die(); |
| 546 | 546 | } |
| 547 | 547 | |
@@ -680,11 +680,11 @@ discard block |
||
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | if ( $form->parent_form_id ) { |
| 683 | - wp_die( sprintf( __( '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>' )); |
|
| 683 | + wp_die( sprintf( __( '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>' ) ); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | $frm_field_selection = FrmField::field_selection(); |
| 687 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 687 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 688 | 688 | |
| 689 | 689 | // Automatically add end section fields if they don't exist (2.0 migration) |
| 690 | 690 | $reset_fields = false; |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 697 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
| 698 | 698 | |
| 699 | 699 | $args = array( 'parent_form_id' => $form->id ); |
| 700 | 700 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
@@ -708,8 +708,8 @@ discard block |
||
| 708 | 708 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 709 | 709 | |
| 710 | 710 | if ( $form->default_template ) { |
| 711 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 712 | - } else if ( defined('DOING_AJAX') ) { |
|
| 711 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 712 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
| 713 | 713 | wp_die(); |
| 714 | 714 | } else if ( $create_link ) { |
| 715 | 715 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -725,21 +725,21 @@ discard block |
||
| 725 | 725 | |
| 726 | 726 | $form = FrmForm::getOne( $id ); |
| 727 | 727 | |
| 728 | - $fields = FrmField::get_all_for_form($id); |
|
| 729 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 728 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 729 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 730 | 730 | |
| 731 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 732 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 731 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
| 732 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | self::clean_submit_html( $values ); |
| 736 | 736 | |
| 737 | 737 | $action_controls = FrmFormActionsController::get_form_actions(); |
| 738 | 738 | |
| 739 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 739 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
| 740 | 740 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
| 741 | 741 | |
| 742 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 742 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
| 743 | 743 | |
| 744 | 744 | $first_h3 = 'frm_first_h3'; |
| 745 | 745 | |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | public static function mb_tags_box( $form_id, $class = '' ) { |
| 763 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 763 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 764 | 764 | $linked_forms = array(); |
| 765 | 765 | $col = 'one'; |
| 766 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 766 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
| 767 | 767 | |
| 768 | 768 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 769 | 769 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | * Insert the form class setting into the form |
| 839 | 839 | */ |
| 840 | 840 | public static function form_classes( $form ) { |
| 841 | - if ( isset($form->options['form_class']) ) { |
|
| 841 | + if ( isset( $form->options['form_class'] ) ) { |
|
| 842 | 842 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 843 | 843 | } |
| 844 | 844 | |
@@ -946,11 +946,11 @@ discard block |
||
| 946 | 946 | public static function add_default_templates( $path, $default = true, $template = true ) { |
| 947 | 947 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
| 948 | 948 | |
| 949 | - $path = untrailingslashit(trim($path)); |
|
| 949 | + $path = untrailingslashit( trim( $path ) ); |
|
| 950 | 950 | $templates = glob( $path . '/*.php' ); |
| 951 | 951 | |
| 952 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
| 953 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
| 952 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
| 953 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
| 954 | 954 | $template_query = array( 'form_key' => $filename ); |
| 955 | 955 | if ( $template ) { |
| 956 | 956 | $template_query['is_template'] = 1; |
@@ -968,12 +968,12 @@ discard block |
||
| 968 | 968 | $values['default_template'] = 1; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - include( $templates[ $i ] ); |
|
| 971 | + include( $templates[$i] ); |
|
| 972 | 972 | |
| 973 | 973 | //get updated form |
| 974 | - if ( isset($form) && ! empty($form) ) { |
|
| 974 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
| 975 | 975 | $old_id = $form->id; |
| 976 | - $form = FrmForm::getOne($form->id); |
|
| 976 | + $form = FrmForm::getOne( $form->id ); |
|
| 977 | 977 | } else { |
| 978 | 978 | $old_id = false; |
| 979 | 979 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -986,24 +986,24 @@ discard block |
||
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | public static function route() { |
| 989 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 989 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 990 | 990 | $vars = array(); |
| 991 | 991 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 992 | 992 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 993 | 993 | |
| 994 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 995 | - $json_vars = json_decode($json_vars, true); |
|
| 996 | - if ( empty($json_vars) ) { |
|
| 994 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
| 995 | + $json_vars = json_decode( $json_vars, true ); |
|
| 996 | + if ( empty( $json_vars ) ) { |
|
| 997 | 997 | // json decoding failed so we should return an error message |
| 998 | 998 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 999 | 999 | if ( 'edit' == $action ) { |
| 1000 | 1000 | $action = 'update'; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 1003 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
| 1004 | 1004 | } else { |
| 1005 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 1006 | - $action = $vars[ $action ]; |
|
| 1005 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
| 1006 | + $action = $vars[$action]; |
|
| 1007 | 1007 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1008 | 1008 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1009 | 1009 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -1021,7 +1021,7 @@ discard block |
||
| 1021 | 1021 | |
| 1022 | 1022 | switch ( $action ) { |
| 1023 | 1023 | case 'new': |
| 1024 | - return self::new_form($vars); |
|
| 1024 | + return self::new_form( $vars ); |
|
| 1025 | 1025 | case 'create': |
| 1026 | 1026 | case 'edit': |
| 1027 | 1027 | case 'update': |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 1047 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
| 1048 | 1048 | FrmAppHelper::remove_get_action(); |
| 1049 | 1049 | return self::list_form(); |
| 1050 | 1050 | } |
@@ -1071,19 +1071,19 @@ discard block |
||
| 1071 | 1071 | |
| 1072 | 1072 | public static function admin_bar_configure() { |
| 1073 | 1073 | global $frm_vars; |
| 1074 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 1074 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
| 1075 | 1075 | return; |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | $actions = array(); |
| 1079 | 1079 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 1080 | - if ( is_object($form) ) { |
|
| 1081 | - $actions[ $form->id ] = $form->name; |
|
| 1080 | + if ( is_object( $form ) ) { |
|
| 1081 | + $actions[$form->id] = $form->name; |
|
| 1082 | 1082 | } |
| 1083 | - unset($form); |
|
| 1083 | + unset( $form ); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - if ( empty($actions) ) { |
|
| 1086 | + if ( empty( $actions ) ) { |
|
| 1087 | 1087 | return; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
@@ -1129,7 +1129,7 @@ discard block |
||
| 1129 | 1129 | //formidable shortcode |
| 1130 | 1130 | public static function get_form_shortcode( $atts ) { |
| 1131 | 1131 | global $frm_vars; |
| 1132 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1132 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
| 1133 | 1133 | $sc = '[formidable'; |
| 1134 | 1134 | if ( ! empty( $atts ) ) { |
| 1135 | 1135 | foreach ( $atts as $k => $v ) { |
@@ -1289,8 +1289,8 @@ discard block |
||
| 1289 | 1289 | private static function get_saved_errors( $form, $params ) { |
| 1290 | 1290 | global $frm_vars; |
| 1291 | 1291 | |
| 1292 | - if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][ $form->id ] ) ) { |
|
| 1293 | - $errors = $frm_vars['created_entries'][ $form->id ]['errors']; |
|
| 1292 | + if ( $params['posted_form_id'] == $form->id && $_POST && isset( $frm_vars['created_entries'][$form->id] ) ) { |
|
| 1293 | + $errors = $frm_vars['created_entries'][$form->id]['errors']; |
|
| 1294 | 1294 | } else { |
| 1295 | 1295 | $errors = array(); |
| 1296 | 1296 | } |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | */ |
| 1303 | 1303 | public static function just_created_entry( $form_id ) { |
| 1304 | 1304 | global $frm_vars; |
| 1305 | - return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; |
|
| 1305 | + return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0; |
|
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | /** |
@@ -1310,7 +1310,7 @@ discard block |
||
| 1310 | 1310 | */ |
| 1311 | 1311 | private static function get_confirmation_method( $atts ) { |
| 1312 | 1312 | $opt = 'success_action'; |
| 1313 | - $method = ( isset( $atts['form']->options[ $opt ] ) && ! empty( $atts['form']->options[ $opt ] ) ) ? $atts['form']->options[ $opt ] : 'message'; |
|
| 1313 | + $method = ( isset( $atts['form']->options[$opt] ) && ! empty( $atts['form']->options[$opt] ) ) ? $atts['form']->options[$opt] : 'message'; |
|
| 1314 | 1314 | $method = apply_filters( 'frm_success_filter', $method, $atts['form'], 'create' ); |
| 1315 | 1315 | |
| 1316 | 1316 | if ( $method != 'message' && ( ! $atts['entry_id'] || ! is_numeric( $atts['entry_id'] ) ) ) { |
@@ -1323,7 +1323,7 @@ discard block |
||
| 1323 | 1323 | public static function maybe_trigger_redirect( $form, $params, $args ) { |
| 1324 | 1324 | if ( ! isset( $params['id'] ) ) { |
| 1325 | 1325 | global $frm_vars; |
| 1326 | - $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id']; |
|
| 1326 | + $params['id'] = $frm_vars['created_entries'][$form->id]['entry_id']; |
|
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | $conf_method = self::get_confirmation_method( array( |
@@ -1363,7 +1363,7 @@ discard block |
||
| 1363 | 1363 | |
| 1364 | 1364 | $opt = ( ! isset( $args['action'] ) || $args['action'] == 'create' ) ? 'success' : 'edit'; |
| 1365 | 1365 | $args['success_opt'] = $opt; |
| 1366 | - if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[ $opt . '_page_id' ] ) ) { |
|
| 1366 | + if ( $args['conf_method'] == 'page' && is_numeric( $args['form']->options[$opt . '_page_id'] ) ) { |
|
| 1367 | 1367 | self::load_page_after_submit( $args ); |
| 1368 | 1368 | } elseif ( $args['conf_method'] == 'redirect' ) { |
| 1369 | 1369 | self::redirect_after_submit( $args ); |
@@ -1378,8 +1378,8 @@ discard block |
||
| 1378 | 1378 | private static function load_page_after_submit( $args ) { |
| 1379 | 1379 | global $post; |
| 1380 | 1380 | $opt = $args['success_opt']; |
| 1381 | - if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) { |
|
| 1382 | - $page = get_post( $args['form']->options[ $opt . '_page_id' ] ); |
|
| 1381 | + if ( ! $post || $args['form']->options[$opt . '_page_id'] != $post->ID ) { |
|
| 1382 | + $page = get_post( $args['form']->options[$opt . '_page_id'] ); |
|
| 1383 | 1383 | $old_post = $post; |
| 1384 | 1384 | $post = $page; |
| 1385 | 1385 | $content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] ); |
@@ -1397,10 +1397,10 @@ discard block |
||
| 1397 | 1397 | add_filter( 'frm_use_wpautop', '__return_false' ); |
| 1398 | 1398 | |
| 1399 | 1399 | $opt = $args['success_opt']; |
| 1400 | - $success_url = trim( $args['form']->options[ $opt . '_url' ] ); |
|
| 1400 | + $success_url = trim( $args['form']->options[$opt . '_url'] ); |
|
| 1401 | 1401 | $success_url = apply_filters( 'frm_content', $success_url, $args['form'], $args['entry_id'] ); |
| 1402 | 1402 | |
| 1403 | - $success_msg = isset( $args['form']->options[ $opt . '_msg' ] ) ? $args['form']->options[ $opt . '_msg' ] : __( 'Please wait while you are redirected.', 'formidable' ); |
|
| 1403 | + $success_msg = isset( $args['form']->options[$opt . '_msg'] ) ? $args['form']->options[$opt . '_msg'] : __( 'Please wait while you are redirected.', 'formidable' ); |
|
| 1404 | 1404 | |
| 1405 | 1405 | $redirect_msg = self::get_redirect_message( $success_url, $success_msg, $args ); |
| 1406 | 1406 | |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | FrmEntriesController::delete_entry_before_redirect( $success_url, $args['form'], $args ); |
| 1409 | 1409 | |
| 1410 | 1410 | add_filter( 'frm_redirect_url', 'FrmEntriesController::prepare_redirect_url' ); |
| 1411 | - $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args); |
|
| 1411 | + $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args ); |
|
| 1412 | 1412 | |
| 1413 | 1413 | $doing_ajax = FrmAppHelper::doing_ajax(); |
| 1414 | 1414 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | */ |
| 1435 | 1435 | private static function get_redirect_message( $success_url, $success_msg, $args ) { |
| 1436 | 1436 | $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg frm_message">' . $success_msg . '<br/>' . |
| 1437 | - sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>') . |
|
| 1437 | + sprintf( __( '%1$sClick here%2$s if you are not automatically redirected.', 'formidable' ), '<a href="' . esc_url( $success_url ) . '">', '</a>' ) . |
|
| 1438 | 1438 | '</div></div>'; |
| 1439 | 1439 | |
| 1440 | 1440 | return apply_filters( 'frm_redirect_msg', $redirect_msg, array( |
@@ -1668,7 +1668,7 @@ discard block |
||
| 1668 | 1668 | private static function edit_in_place_value( $field ) { |
| 1669 | 1669 | _deprecated_function( __METHOD__, '3.0' ); |
| 1670 | 1670 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 1671 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
| 1671 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 1672 | 1672 | |
| 1673 | 1673 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 1674 | 1674 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -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,113 +90,113 @@ 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( 'wp_ajax_frm_settings_tab', 'FrmSettingsController::load_settings_tab' ); |
| 122 | 122 | |
| 123 | - // Styles Controller |
|
| 124 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 125 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 123 | + // Styles Controller |
|
| 124 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 125 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 126 | 126 | |
| 127 | - // XML Controller |
|
| 128 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 129 | - } |
|
| 127 | + // XML Controller |
|
| 128 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | public static function load_ajax_hooks() { |
| 132 | 132 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 133 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 134 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 133 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 134 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 135 | 135 | |
| 136 | 136 | // Addons |
| 137 | 137 | add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 138 | 138 | add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 139 | 139 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
| 140 | 140 | |
| 141 | - // Fields Controller |
|
| 142 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 143 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 144 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 145 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 146 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 147 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 148 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 149 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 150 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 151 | - |
|
| 152 | - // Form Actions Controller |
|
| 153 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 154 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 155 | - |
|
| 156 | - // Forms Controller |
|
| 141 | + // Fields Controller |
|
| 142 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 143 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 144 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 145 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 146 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 147 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 148 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 149 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 150 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 151 | + |
|
| 152 | + // Form Actions Controller |
|
| 153 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 154 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 155 | + |
|
| 156 | + // Forms Controller |
|
| 157 | 157 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 158 | 158 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 159 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 160 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 161 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 162 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 163 | - |
|
| 164 | - // Styles Controller |
|
| 165 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 166 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 167 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 168 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 159 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 160 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 161 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 162 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 163 | + |
|
| 164 | + // Styles Controller |
|
| 165 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 166 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 167 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 168 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 169 | 169 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 170 | 170 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 171 | 171 | |
| 172 | - // XML Controller |
|
| 172 | + // XML Controller |
|
| 173 | 173 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 174 | 174 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 175 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 176 | - } |
|
| 175 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | public static function load_form_hooks() { |
| 179 | - // Fields Controller |
|
| 180 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 181 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 182 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 183 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 179 | + // Fields Controller |
|
| 180 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 181 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 182 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 183 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 184 | 184 | |
| 185 | 185 | // Forms Controller |
| 186 | 186 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 187 | 187 | |
| 188 | - // Styles Controller |
|
| 189 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 190 | - } |
|
| 188 | + // Styles Controller |
|
| 189 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | public static function load_view_hooks() { |
| 193 | - // Hooks go here when a view is loaded |
|
| 194 | - } |
|
| 193 | + // Hooks go here when a view is loaded |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | public static function load_multisite_hooks() { |
| 197 | 197 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 198 | 198 | |
| 199 | - // drop tables when mu site is deleted |
|
| 200 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 201 | - } |
|
| 199 | + // drop tables when mu site is deleted |
|
| 200 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 201 | + } |
|
| 202 | 202 | } |