@@ -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,128 +24,128 @@ 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 | - public static function list_form() { |
|
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 40 | + public static function list_form() { |
|
| 41 | + FrmAppHelper::permission_check('frm_view_forms'); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array()); |
|
| 45 | + $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 52 | 52 | |
| 53 | - global $frm_vars; |
|
| 53 | + global $frm_vars; |
|
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 55 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | 56 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create($values); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | - $id = FrmForm::create( $values ); |
|
| 64 | - $form = FrmForm::getOne($id); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
| 63 | + $id = FrmForm::create( $values ); |
|
| 64 | + $form = FrmForm::getOne($id); |
|
| 65 | 65 | |
| 66 | - // add default email notification |
|
| 67 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | - $action_control->create($form->id); |
|
| 66 | + // add default email notification |
|
| 67 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 68 | + $action_control->create($form->id); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
| 72 | - $values['id'] = $id; |
|
| 72 | + $values['id'] = $id; |
|
| 73 | 73 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 74 | - } |
|
| 75 | - } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 79 | 79 | |
| 80 | - global $frm_vars; |
|
| 81 | - if ( empty( $values ) ) { |
|
| 82 | - $values = $_POST; |
|
| 83 | - } |
|
| 80 | + global $frm_vars; |
|
| 81 | + if ( empty( $values ) ) { |
|
| 82 | + $values = $_POST; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - //Set radio button and checkbox meta equal to "other" value |
|
| 86 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | - } |
|
| 85 | + //Set radio button and checkbox meta equal to "other" value |
|
| 86 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 87 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 91 | 91 | |
| 92 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | - } else { |
|
| 96 | - $errors = FrmForm::validate($values); |
|
| 97 | - } |
|
| 92 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 93 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 94 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 95 | + } else { |
|
| 96 | + $errors = FrmForm::validate($values); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 100 | - $hide_preview = true; |
|
| 99 | + if ( count($errors) > 0 ) { |
|
| 100 | + $hide_preview = true; |
|
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | - $form = FrmForm::getOne( $id ); |
|
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 102 | + $form = FrmForm::getOne( $id ); |
|
| 103 | + $fields = FrmField::get_all_for_form($id); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 109 | - } else { |
|
| 110 | - FrmForm::update( $id, $values, true ); |
|
| 109 | + } else { |
|
| 110 | + FrmForm::update( $id, $values, true ); |
|
| 111 | 111 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 112 | 112 | die( FrmAppHelper::js_redirect( $url ) ); |
| 113 | - } |
|
| 114 | - } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public static function edit( $values = false ) { |
|
| 117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 116 | + public static function edit( $values = false ) { |
|
| 117 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 118 | 118 | |
| 119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 120 | - return self::get_edit_vars($id); |
|
| 121 | - } |
|
| 120 | + return self::get_edit_vars($id); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - public static function settings( $id = false, $message = '' ) { |
|
| 124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 123 | + public static function settings( $id = false, $message = '' ) { |
|
| 124 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 125 | 125 | |
| 126 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 126 | + if ( ! $id || ! is_numeric($id) ) { |
|
| 127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public static function update_settings() { |
|
| 133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 132 | + public static function update_settings() { |
|
| 133 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 134 | 134 | |
| 135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 136 | 136 | |
| 137 | - $errors = FrmForm::validate($_POST); |
|
| 138 | - if ( count($errors) > 0 ) { |
|
| 139 | - return self::get_settings_vars($id, $errors); |
|
| 140 | - } |
|
| 137 | + $errors = FrmForm::validate($_POST); |
|
| 138 | + if ( count($errors) > 0 ) { |
|
| 139 | + return self::get_settings_vars($id, $errors); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - do_action('frm_before_update_form_settings', $id); |
|
| 142 | + do_action('frm_before_update_form_settings', $id); |
|
| 143 | 143 | |
| 144 | 144 | FrmForm::update( $id, $_POST ); |
| 145 | 145 | |
| 146 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 146 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 147 | 147 | return self::get_settings_vars( $id, array(), $message ); |
| 148 | - } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | public static function edit_key() { |
| 151 | 151 | $values = self::edit_in_place_value( 'form_key' ); |
@@ -175,43 +175,43 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | public static function update( $values = array() ) { |
| 177 | 177 | if ( empty( $values ) ) { |
| 178 | - $values = $_POST; |
|
| 179 | - } |
|
| 178 | + $values = $_POST; |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - //Set radio button and checkbox meta equal to "other" value |
|
| 182 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 183 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 184 | - } |
|
| 181 | + //Set radio button and checkbox meta equal to "other" value |
|
| 182 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 183 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - $errors = FrmForm::validate( $values ); |
|
| 187 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 188 | - if ( $permission_error !== false ) { |
|
| 189 | - $errors['form'] = $permission_error; |
|
| 190 | - } |
|
| 186 | + $errors = FrmForm::validate( $values ); |
|
| 187 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 188 | + if ( $permission_error !== false ) { |
|
| 189 | + $errors['form'] = $permission_error; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 193 | 193 | |
| 194 | 194 | if ( count( $errors ) > 0 ) { |
| 195 | - return self::get_edit_vars( $id, $errors ); |
|
| 195 | + return self::get_edit_vars( $id, $errors ); |
|
| 196 | 196 | } else { |
| 197 | - FrmForm::update( $id, $values ); |
|
| 198 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 199 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 197 | + FrmForm::update( $id, $values ); |
|
| 198 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 199 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 200 | 200 | wp_die( $message ); |
| 201 | - } |
|
| 201 | + } |
|
| 202 | 202 | return self::get_edit_vars( $id, array(), $message ); |
| 203 | - } |
|
| 204 | - } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - public static function bulk_create_template( $ids ) { |
|
| 207 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 206 | + public static function bulk_create_template( $ids ) { |
|
| 207 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 208 | 208 | |
| 209 | - foreach ( $ids as $id ) { |
|
| 210 | - FrmForm::duplicate( $id, true, true ); |
|
| 211 | - } |
|
| 209 | + foreach ( $ids as $id ) { |
|
| 210 | + FrmForm::duplicate( $id, true, true ); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 214 | - } |
|
| 213 | + return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | 217 | * Redirect to the url for creating from a template |
@@ -233,45 +233,45 @@ discard block |
||
| 233 | 233 | wp_die(); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - public static function duplicate() { |
|
| 237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 236 | + public static function duplicate() { |
|
| 237 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 238 | 238 | |
| 239 | 239 | $params = FrmForm::list_page_params(); |
| 240 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | - if ( $form ) { |
|
| 240 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 241 | + $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | + if ( $form ) { |
|
| 243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
| 244 | - } else { |
|
| 245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 246 | - } |
|
| 247 | - } |
|
| 244 | + } else { |
|
| 245 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - public static function page_preview() { |
|
| 249 | + public static function page_preview() { |
|
| 250 | 250 | $params = FrmForm::list_page_params(); |
| 251 | - if ( ! $params['form'] ) { |
|
| 252 | - return; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 256 | - if ( ! $form ) { |
|
| 257 | - return; |
|
| 258 | - } |
|
| 259 | - return self::show_form( $form->id, '', true, true ); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - public static function preview() { |
|
| 263 | - do_action( 'frm_wp' ); |
|
| 264 | - |
|
| 265 | - global $frm_vars; |
|
| 266 | - $frm_vars['preview'] = true; |
|
| 267 | - |
|
| 268 | - if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 269 | - global $wp; |
|
| 270 | - $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 251 | + if ( ! $params['form'] ) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 256 | + if ( ! $form ) { |
|
| 257 | + return; |
|
| 258 | + } |
|
| 259 | + return self::show_form( $form->id, '', true, true ); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + public static function preview() { |
|
| 263 | + do_action( 'frm_wp' ); |
|
| 264 | + |
|
| 265 | + global $frm_vars; |
|
| 266 | + $frm_vars['preview'] = true; |
|
| 267 | + |
|
| 268 | + if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 269 | + global $wp; |
|
| 270 | + $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 271 | 271 | include_once( $root . '/wp-config.php' ); |
| 272 | - $wp->init(); |
|
| 273 | - $wp->register_globals(); |
|
| 274 | - } |
|
| 272 | + $wp->init(); |
|
| 273 | + $wp->register_globals(); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | self::register_pro_scripts(); |
| 277 | 277 | |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
| 286 | 286 | if ( empty( $form ) ) { |
| 287 | 287 | $form = FrmForm::getAll( array(), '', 1 ); |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 291 | - wp_die(); |
|
| 292 | - } |
|
| 291 | + wp_die(); |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | public static function register_pro_scripts() { |
| 295 | 295 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -299,22 +299,22 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public static function untrash() { |
|
| 302 | + public static function untrash() { |
|
| 303 | 303 | self::change_form_status( 'untrash' ); |
| 304 | - } |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | 306 | public static function bulk_untrash( $ids ) { |
| 307 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 307 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 308 | 308 | |
| 309 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 309 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 310 | 310 | |
| 311 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 312 | - return $message; |
|
| 313 | - } |
|
| 311 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 312 | + return $message; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - public static function trash() { |
|
| 315 | + public static function trash() { |
|
| 316 | 316 | self::change_form_status( 'trash' ); |
| 317 | - } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | 320 | * @param string $status |
@@ -352,68 +352,68 @@ discard block |
||
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | public static function bulk_trash( $ids ) { |
| 355 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 355 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 356 | 356 | |
| 357 | - $count = 0; |
|
| 358 | - foreach ( $ids as $id ) { |
|
| 359 | - if ( FrmForm::trash( $id ) ) { |
|
| 360 | - $count++; |
|
| 361 | - } |
|
| 362 | - } |
|
| 357 | + $count = 0; |
|
| 358 | + foreach ( $ids as $id ) { |
|
| 359 | + if ( FrmForm::trash( $id ) ) { |
|
| 360 | + $count++; |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 364 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 365 | 365 | $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( 'item-action[]=', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
| 366 | 366 | |
| 367 | - return $message; |
|
| 368 | - } |
|
| 367 | + return $message; |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - public static function destroy() { |
|
| 371 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 370 | + public static function destroy() { |
|
| 371 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 372 | 372 | |
| 373 | 373 | $params = FrmForm::list_page_params(); |
| 374 | 374 | |
| 375 | - //check nonce url |
|
| 376 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 375 | + //check nonce url |
|
| 376 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 377 | 377 | |
| 378 | - $count = 0; |
|
| 379 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 380 | - $count++; |
|
| 381 | - } |
|
| 378 | + $count = 0; |
|
| 379 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 380 | + $count++; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 383 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 384 | 384 | |
| 385 | 385 | self::display_forms_list( $params, $message ); |
| 386 | - } |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | 388 | public static function bulk_destroy( $ids ) { |
| 389 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 389 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 390 | 390 | |
| 391 | - $count = 0; |
|
| 392 | - foreach ( $ids as $id ) { |
|
| 393 | - $d = FrmForm::destroy( $id ); |
|
| 394 | - if ( $d ) { |
|
| 395 | - $count++; |
|
| 396 | - } |
|
| 397 | - } |
|
| 391 | + $count = 0; |
|
| 392 | + foreach ( $ids as $id ) { |
|
| 393 | + $d = FrmForm::destroy( $id ); |
|
| 394 | + if ( $d ) { |
|
| 395 | + $count++; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 399 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 400 | 400 | |
| 401 | - return $message; |
|
| 402 | - } |
|
| 401 | + return $message; |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - private static function delete_all() { |
|
| 405 | - //check nonce url |
|
| 406 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 407 | - if ( $permission_error !== false ) { |
|
| 404 | + private static function delete_all() { |
|
| 405 | + //check nonce url |
|
| 406 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 407 | + if ( $permission_error !== false ) { |
|
| 408 | 408 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 409 | - return; |
|
| 410 | - } |
|
| 409 | + return; |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | $count = FrmForm::scheduled_delete( time() ); |
| 413 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 413 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 414 | 414 | |
| 415 | 415 | self::display_forms_list( array(), $message ); |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | 418 | public static function scheduled_delete( $delete_timestamp = '' ) { |
| 419 | 419 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' ); |
@@ -421,11 +421,11 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | - * Inserts Formidable button |
|
| 425 | - * Hook exists since 2.5.0 |
|
| 426 | - * |
|
| 427 | - * @since 2.0.15 |
|
| 428 | - */ |
|
| 424 | + * Inserts Formidable button |
|
| 425 | + * Hook exists since 2.5.0 |
|
| 426 | + * |
|
| 427 | + * @since 2.0.15 |
|
| 428 | + */ |
|
| 429 | 429 | public static function insert_form_button() { |
| 430 | 430 | if ( current_user_can('frm_view_forms') ) { |
| 431 | 431 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -436,49 +436,49 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - public static function insert_form_popup() { |
|
| 439 | + public static function insert_form_popup() { |
|
| 440 | 440 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 441 | 441 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 442 | - return; |
|
| 443 | - } |
|
| 442 | + return; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - FrmAppHelper::load_admin_wide_js(); |
|
| 445 | + FrmAppHelper::load_admin_wide_js(); |
|
| 446 | 446 | |
| 447 | - $shortcodes = array( |
|
| 447 | + $shortcodes = array( |
|
| 448 | 448 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 449 | - ); |
|
| 449 | + ); |
|
| 450 | 450 | |
| 451 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 451 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 452 | 452 | |
| 453 | 453 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 454 | - } |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | - public static function get_shortcode_opts() { |
|
| 456 | + public static function get_shortcode_opts() { |
|
| 457 | 457 | FrmAppHelper::permission_check('frm_view_forms'); |
| 458 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 458 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 459 | 459 | |
| 460 | 460 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 461 | - if ( empty($shortcode) ) { |
|
| 462 | - wp_die(); |
|
| 463 | - } |
|
| 461 | + if ( empty($shortcode) ) { |
|
| 462 | + wp_die(); |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | 465 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 466 | 466 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 467 | 467 | |
| 468 | - $form_id = ''; |
|
| 469 | - $opts = array(); |
|
| 468 | + $form_id = ''; |
|
| 469 | + $opts = array(); |
|
| 470 | 470 | switch ( $shortcode ) { |
| 471 | - case 'formidable': |
|
| 472 | - $opts = array( |
|
| 471 | + case 'formidable': |
|
| 472 | + $opts = array( |
|
| 473 | 473 | 'form_id' => 'id', |
| 474 | - //'key' => ', |
|
| 474 | + //'key' => ', |
|
| 475 | 475 | 'title' => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ), |
| 476 | 476 | 'description' => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ), |
| 477 | 477 | 'minimize' => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ), |
| 478 | - ); |
|
| 479 | - break; |
|
| 480 | - } |
|
| 481 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 478 | + ); |
|
| 479 | + break; |
|
| 480 | + } |
|
| 481 | + $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 482 | 482 | |
| 483 | 483 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 484 | 484 | // allow other shortcodes to use the required form id option |
@@ -488,61 +488,61 @@ discard block |
||
| 488 | 488 | |
| 489 | 489 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 490 | 490 | |
| 491 | - echo '</div>'; |
|
| 491 | + echo '</div>'; |
|
| 492 | 492 | |
| 493 | - wp_die(); |
|
| 494 | - } |
|
| 493 | + wp_die(); |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) { |
| 497 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 497 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 498 | 498 | if ( ! empty( $deprecated_errors ) ) { |
| 499 | 499 | $errors = $deprecated_errors; |
| 500 | 500 | _deprecated_argument( 'errors', '2.0.8' ); |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - global $wpdb, $frm_vars; |
|
| 503 | + global $wpdb, $frm_vars; |
|
| 504 | 504 | |
| 505 | 505 | if ( empty( $params ) ) { |
| 506 | 506 | $params = FrmForm::list_page_params(); |
| 507 | - } |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 509 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 510 | 510 | |
| 511 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 511 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 512 | 512 | |
| 513 | - $wp_list_table->prepare_items(); |
|
| 513 | + $wp_list_table->prepare_items(); |
|
| 514 | 514 | |
| 515 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 516 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 515 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 516 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 517 | 517 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 518 | - die(); |
|
| 519 | - } |
|
| 518 | + die(); |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | 521 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 522 | - } |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | public static function get_columns( $columns ) { |
| 525 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 526 | - $columns['id'] = 'ID'; |
|
| 525 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 526 | + $columns['id'] = 'ID'; |
|
| 527 | 527 | |
| 528 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 528 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 529 | 529 | |
| 530 | - if ( 'template' == $type ) { |
|
| 531 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 532 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 533 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 534 | - } else { |
|
| 535 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 536 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 537 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 538 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 539 | - } |
|
| 530 | + if ( 'template' == $type ) { |
|
| 531 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 532 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 533 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 534 | + } else { |
|
| 535 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 536 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 537 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 538 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 541 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 542 | 542 | |
| 543 | 543 | add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) ); |
| 544 | 544 | |
| 545 | - return $columns; |
|
| 545 | + return $columns; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | public static function get_sortable_columns() { |
@@ -556,110 +556,110 @@ discard block |
||
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | public static function hidden_columns( $result ) { |
| 559 | - $return = false; |
|
| 560 | - foreach ( (array) $result as $r ) { |
|
| 561 | - if ( ! empty( $r ) ) { |
|
| 562 | - $return = true; |
|
| 563 | - break; |
|
| 564 | - } |
|
| 565 | - } |
|
| 559 | + $return = false; |
|
| 560 | + foreach ( (array) $result as $r ) { |
|
| 561 | + if ( ! empty( $r ) ) { |
|
| 562 | + $return = true; |
|
| 563 | + break; |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - if ( $return ) { |
|
| 568 | - return $result; |
|
| 567 | + if ( $return ) { |
|
| 568 | + return $result; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 571 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 572 | 572 | |
| 573 | - $result[] = 'created_at'; |
|
| 574 | - if ( $type == 'template' ) { |
|
| 575 | - $result[] = 'id'; |
|
| 576 | - $result[] = 'form_key'; |
|
| 577 | - } |
|
| 573 | + $result[] = 'created_at'; |
|
| 574 | + if ( $type == 'template' ) { |
|
| 575 | + $result[] = 'id'; |
|
| 576 | + $result[] = 'form_key'; |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | - return $result; |
|
| 580 | - } |
|
| 579 | + return $result; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | public static function save_per_page( $save, $option, $value ) { |
| 583 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 584 | - $save = (int) $value; |
|
| 585 | - } |
|
| 586 | - return $save; |
|
| 587 | - } |
|
| 583 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 584 | + $save = (int) $value; |
|
| 585 | + } |
|
| 586 | + return $save; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | 589 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 590 | - global $frm_vars; |
|
| 590 | + global $frm_vars; |
|
| 591 | 591 | |
| 592 | - $form = FrmForm::getOne( $id ); |
|
| 593 | - if ( ! $form ) { |
|
| 594 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 595 | - } |
|
| 592 | + $form = FrmForm::getOne( $id ); |
|
| 593 | + if ( ! $form ) { |
|
| 594 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - if ( $form->parent_form_id ) { |
|
| 597 | + if ( $form->parent_form_id ) { |
|
| 598 | 598 | 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>' )); |
| 599 | - } |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | 601 | $frm_field_selection = FrmField::field_selection(); |
| 602 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 602 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 603 | 603 | |
| 604 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 605 | - $reset_fields = false; |
|
| 606 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 604 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 605 | + $reset_fields = false; |
|
| 606 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 607 | 607 | |
| 608 | - if ( $reset_fields ) { |
|
| 609 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 610 | - } |
|
| 608 | + if ( $reset_fields ) { |
|
| 609 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 610 | + } |
|
| 611 | 611 | |
| 612 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 612 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 613 | 613 | |
| 614 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 614 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 615 | 615 | |
| 616 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 617 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 618 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 619 | - } |
|
| 616 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 617 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 618 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 622 | 622 | |
| 623 | - if ( $form->default_template ) { |
|
| 624 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 625 | - } else if ( defined('DOING_AJAX') ) { |
|
| 626 | - wp_die(); |
|
| 627 | - } else if ( $create_link ) { |
|
| 623 | + if ( $form->default_template ) { |
|
| 624 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 625 | + } else if ( defined('DOING_AJAX') ) { |
|
| 626 | + wp_die(); |
|
| 627 | + } else if ( $create_link ) { |
|
| 628 | 628 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 629 | - } else { |
|
| 629 | + } else { |
|
| 630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 631 | - } |
|
| 632 | - } |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | 634 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 635 | 635 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 636 | 636 | |
| 637 | - global $frm_vars; |
|
| 637 | + global $frm_vars; |
|
| 638 | 638 | |
| 639 | - $form = FrmForm::getOne( $id ); |
|
| 639 | + $form = FrmForm::getOne( $id ); |
|
| 640 | 640 | |
| 641 | - $fields = FrmField::get_all_for_form($id); |
|
| 642 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 641 | + $fields = FrmField::get_all_for_form($id); |
|
| 642 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 643 | 643 | |
| 644 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 645 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 646 | - } |
|
| 644 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 645 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 646 | + } |
|
| 647 | 647 | |
| 648 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 648 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 649 | 649 | |
| 650 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 651 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 650 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 651 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 652 | 652 | |
| 653 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 653 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 654 | 654 | |
| 655 | 655 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 656 | - } |
|
| 656 | + } |
|
| 657 | 657 | |
| 658 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 659 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 660 | - $linked_forms = array(); |
|
| 661 | - $col = 'one'; |
|
| 662 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 658 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 659 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 660 | + $linked_forms = array(); |
|
| 661 | + $col = 'one'; |
|
| 662 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 663 | 663 | |
| 664 | 664 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 665 | 665 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 668 | 668 | |
| 669 | 669 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 670 | - } |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | 672 | /** |
| 673 | 673 | * Get an array of the options to display in the advanced tab |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | '' => '', |
| 709 | 709 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 710 | 710 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 711 | - ); |
|
| 711 | + ); |
|
| 712 | 712 | |
| 713 | 713 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 714 | 714 | unset( $entry_shortcodes['post_id'] ); |
@@ -735,39 +735,39 @@ discard block |
||
| 735 | 735 | return $entry_shortcodes; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - // Insert the form class setting into the form |
|
| 738 | + // Insert the form class setting into the form |
|
| 739 | 739 | public static function form_classes( $form ) { |
| 740 | - if ( isset($form->options['form_class']) ) { |
|
| 740 | + if ( isset($form->options['form_class']) ) { |
|
| 741 | 741 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 742 | - } |
|
| 743 | - } |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - public static function get_email_html() { |
|
| 745 | + public static function get_email_html() { |
|
| 746 | 746 | FrmAppHelper::permission_check('frm_view_forms'); |
| 747 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 747 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 748 | 748 | echo FrmEntryFormat::show_entry( array( |
| 749 | 749 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 750 | - 'default_email' => true, |
|
| 750 | + 'default_email' => true, |
|
| 751 | 751 | 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
| 752 | - ) ); |
|
| 753 | - wp_die(); |
|
| 752 | + ) ); |
|
| 753 | + wp_die(); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 756 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 757 | 757 | self::get_entry_by_param( $entry ); |
| 758 | - if ( ! $entry ) { |
|
| 759 | - return $content; |
|
| 760 | - } |
|
| 758 | + if ( ! $entry ) { |
|
| 759 | + return $content; |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - if ( is_object( $form ) ) { |
|
| 763 | - $form = $form->id; |
|
| 764 | - } |
|
| 762 | + if ( is_object( $form ) ) { |
|
| 763 | + $form = $form->id; |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 767 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 766 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 767 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 768 | 768 | |
| 769 | - return $content; |
|
| 770 | - } |
|
| 769 | + return $content; |
|
| 770 | + } |
|
| 771 | 771 | |
| 772 | 772 | private static function get_entry_by_param( &$entry ) { |
| 773 | 773 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -779,287 +779,287 @@ discard block |
||
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 783 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 784 | - } |
|
| 782 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 783 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - public static function process_bulk_form_actions( $errors ) { |
|
| 787 | - if ( ! $_REQUEST ) { |
|
| 788 | - return $errors; |
|
| 789 | - } |
|
| 786 | + public static function process_bulk_form_actions( $errors ) { |
|
| 787 | + if ( ! $_REQUEST ) { |
|
| 788 | + return $errors; |
|
| 789 | + } |
|
| 790 | 790 | |
| 791 | 791 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 792 | - if ( $bulkaction == -1 ) { |
|
| 792 | + if ( $bulkaction == -1 ) { |
|
| 793 | 793 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 794 | - } |
|
| 795 | - |
|
| 796 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 797 | - FrmAppHelper::remove_get_action(); |
|
| 798 | - |
|
| 799 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 803 | - if ( empty( $ids ) ) { |
|
| 804 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 805 | - return $errors; |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 809 | - if ( $permission_error !== false ) { |
|
| 810 | - $errors[] = $permission_error; |
|
| 811 | - return $errors; |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - if ( ! is_array( $ids ) ) { |
|
| 815 | - $ids = explode( ',', $ids ); |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - switch ( $bulkaction ) { |
|
| 819 | - case 'delete': |
|
| 820 | - $message = self::bulk_destroy( $ids ); |
|
| 821 | - break; |
|
| 822 | - case 'trash': |
|
| 823 | - $message = self::bulk_trash( $ids ); |
|
| 824 | - break; |
|
| 825 | - case 'untrash': |
|
| 826 | - $message = self::bulk_untrash( $ids ); |
|
| 827 | - break; |
|
| 828 | - case 'create_template': |
|
| 829 | - $message = self::bulk_create_template( $ids ); |
|
| 830 | - break; |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 797 | + FrmAppHelper::remove_get_action(); |
|
| 798 | + |
|
| 799 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 803 | + if ( empty( $ids ) ) { |
|
| 804 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 805 | + return $errors; |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 809 | + if ( $permission_error !== false ) { |
|
| 810 | + $errors[] = $permission_error; |
|
| 811 | + return $errors; |
|
| 812 | + } |
|
| 813 | + |
|
| 814 | + if ( ! is_array( $ids ) ) { |
|
| 815 | + $ids = explode( ',', $ids ); |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + switch ( $bulkaction ) { |
|
| 819 | + case 'delete': |
|
| 820 | + $message = self::bulk_destroy( $ids ); |
|
| 821 | + break; |
|
| 822 | + case 'trash': |
|
| 823 | + $message = self::bulk_trash( $ids ); |
|
| 824 | + break; |
|
| 825 | + case 'untrash': |
|
| 826 | + $message = self::bulk_untrash( $ids ); |
|
| 827 | + break; |
|
| 828 | + case 'create_template': |
|
| 829 | + $message = self::bulk_create_template( $ids ); |
|
| 830 | + break; |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 834 | 834 | echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message ) . '</div>'; |
| 835 | - } |
|
| 835 | + } |
|
| 836 | 836 | |
| 837 | - return $errors; |
|
| 838 | - } |
|
| 837 | + return $errors; |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 841 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 840 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 841 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 842 | 842 | |
| 843 | - $path = untrailingslashit(trim($path)); |
|
| 843 | + $path = untrailingslashit(trim($path)); |
|
| 844 | 844 | $templates = glob( $path . '/*.php' ); |
| 845 | 845 | |
| 846 | 846 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 847 | 847 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 848 | 848 | $template_query = array( 'form_key' => $filename ); |
| 849 | - if ( $template ) { |
|
| 850 | - $template_query['is_template'] = 1; |
|
| 851 | - } |
|
| 852 | - if ( $default ) { |
|
| 853 | - $template_query['default_template'] = 1; |
|
| 854 | - } |
|
| 849 | + if ( $template ) { |
|
| 850 | + $template_query['is_template'] = 1; |
|
| 851 | + } |
|
| 852 | + if ( $default ) { |
|
| 853 | + $template_query['default_template'] = 1; |
|
| 854 | + } |
|
| 855 | 855 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 856 | 856 | |
| 857 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 858 | - $values['form_key'] = $filename; |
|
| 859 | - $values['is_template'] = $template; |
|
| 860 | - $values['status'] = 'published'; |
|
| 861 | - if ( $default ) { |
|
| 862 | - $values['default_template'] = 1; |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - include( $templates[ $i ] ); |
|
| 866 | - |
|
| 867 | - //get updated form |
|
| 868 | - if ( isset($form) && ! empty($form) ) { |
|
| 869 | - $old_id = $form->id; |
|
| 870 | - $form = FrmForm::getOne($form->id); |
|
| 871 | - } else { |
|
| 872 | - $old_id = false; |
|
| 857 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 858 | + $values['form_key'] = $filename; |
|
| 859 | + $values['is_template'] = $template; |
|
| 860 | + $values['status'] = 'published'; |
|
| 861 | + if ( $default ) { |
|
| 862 | + $values['default_template'] = 1; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + include( $templates[ $i ] ); |
|
| 866 | + |
|
| 867 | + //get updated form |
|
| 868 | + if ( isset($form) && ! empty($form) ) { |
|
| 869 | + $old_id = $form->id; |
|
| 870 | + $form = FrmForm::getOne($form->id); |
|
| 871 | + } else { |
|
| 872 | + $old_id = false; |
|
| 873 | 873 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 874 | - } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - if ( $form ) { |
|
| 876 | + if ( $form ) { |
|
| 877 | 877 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 878 | - } |
|
| 879 | - } |
|
| 880 | - } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | - public static function route() { |
|
| 883 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 884 | - $vars = array(); |
|
| 882 | + public static function route() { |
|
| 883 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 884 | + $vars = array(); |
|
| 885 | 885 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 886 | 886 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 887 | 887 | |
| 888 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 889 | - $json_vars = json_decode($json_vars, true); |
|
| 890 | - if ( empty($json_vars) ) { |
|
| 891 | - // json decoding failed so we should return an error message |
|
| 888 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 889 | + $json_vars = json_decode($json_vars, true); |
|
| 890 | + if ( empty($json_vars) ) { |
|
| 891 | + // json decoding failed so we should return an error message |
|
| 892 | 892 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 893 | - if ( 'edit' == $action ) { |
|
| 894 | - $action = 'update'; |
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 898 | - } else { |
|
| 899 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 900 | - $action = $vars[ $action ]; |
|
| 893 | + if ( 'edit' == $action ) { |
|
| 894 | + $action = 'update'; |
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 898 | + } else { |
|
| 899 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 900 | + $action = $vars[ $action ]; |
|
| 901 | 901 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 902 | 902 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 903 | 903 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 904 | - } |
|
| 905 | - } else { |
|
| 904 | + } |
|
| 905 | + } else { |
|
| 906 | 906 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 907 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 908 | - // override the action for this page |
|
| 909 | - $action = 'delete_all'; |
|
| 910 | - } |
|
| 911 | - } |
|
| 907 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 908 | + // override the action for this page |
|
| 909 | + $action = 'delete_all'; |
|
| 910 | + } |
|
| 911 | + } |
|
| 912 | 912 | |
| 913 | 913 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 914 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 915 | - |
|
| 916 | - switch ( $action ) { |
|
| 917 | - case 'new': |
|
| 918 | - return self::new_form($vars); |
|
| 919 | - case 'create': |
|
| 920 | - case 'edit': |
|
| 921 | - case 'update': |
|
| 922 | - case 'duplicate': |
|
| 923 | - case 'trash': |
|
| 924 | - case 'untrash': |
|
| 925 | - case 'destroy': |
|
| 926 | - case 'delete_all': |
|
| 927 | - case 'settings': |
|
| 928 | - case 'update_settings': |
|
| 914 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 915 | + |
|
| 916 | + switch ( $action ) { |
|
| 917 | + case 'new': |
|
| 918 | + return self::new_form($vars); |
|
| 919 | + case 'create': |
|
| 920 | + case 'edit': |
|
| 921 | + case 'update': |
|
| 922 | + case 'duplicate': |
|
| 923 | + case 'trash': |
|
| 924 | + case 'untrash': |
|
| 925 | + case 'destroy': |
|
| 926 | + case 'delete_all': |
|
| 927 | + case 'settings': |
|
| 928 | + case 'update_settings': |
|
| 929 | 929 | return self::$action( $vars ); |
| 930 | - default: |
|
| 930 | + default: |
|
| 931 | 931 | do_action( 'frm_form_action_' . $action ); |
| 932 | 932 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 933 | - return; |
|
| 934 | - } |
|
| 933 | + return; |
|
| 934 | + } |
|
| 935 | 935 | |
| 936 | 936 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 937 | - if ( $action == -1 ) { |
|
| 937 | + if ( $action == -1 ) { |
|
| 938 | 938 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 939 | - } |
|
| 939 | + } |
|
| 940 | 940 | |
| 941 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 942 | - FrmAppHelper::remove_get_action(); |
|
| 943 | - return self::list_form(); |
|
| 944 | - } |
|
| 941 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 942 | + FrmAppHelper::remove_get_action(); |
|
| 943 | + return self::list_form(); |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - return self::display_forms_list(); |
|
| 947 | - } |
|
| 948 | - } |
|
| 946 | + return self::display_forms_list(); |
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | - public static function json_error( $errors ) { |
|
| 951 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 952 | - return $errors; |
|
| 953 | - } |
|
| 950 | + public static function json_error( $errors ) { |
|
| 951 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 952 | + return $errors; |
|
| 953 | + } |
|
| 954 | 954 | |
| 955 | 955 | |
| 956 | - /* FRONT-END FORMS */ |
|
| 957 | - public static function admin_bar_css() { |
|
| 956 | + /* FRONT-END FORMS */ |
|
| 957 | + public static function admin_bar_css() { |
|
| 958 | 958 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 959 | - return; |
|
| 960 | - } |
|
| 959 | + return; |
|
| 960 | + } |
|
| 961 | 961 | |
| 962 | 962 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 963 | 963 | FrmAppHelper::load_font_style(); |
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | public static function admin_bar_configure() { |
| 967 | - global $frm_vars; |
|
| 968 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 969 | - return; |
|
| 970 | - } |
|
| 971 | - |
|
| 972 | - $actions = array(); |
|
| 973 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 974 | - if ( is_object($form) ) { |
|
| 975 | - $actions[ $form->id ] = $form->name; |
|
| 976 | - } |
|
| 977 | - unset($form); |
|
| 978 | - } |
|
| 979 | - |
|
| 980 | - if ( empty($actions) ) { |
|
| 981 | - return; |
|
| 982 | - } |
|
| 983 | - |
|
| 984 | - asort($actions); |
|
| 985 | - |
|
| 986 | - global $wp_admin_bar; |
|
| 987 | - |
|
| 988 | - if ( count($actions) == 1 ) { |
|
| 989 | - $wp_admin_bar->add_menu( array( |
|
| 990 | - 'title' => 'Edit Form', |
|
| 967 | + global $frm_vars; |
|
| 968 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 969 | + return; |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + $actions = array(); |
|
| 973 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 974 | + if ( is_object($form) ) { |
|
| 975 | + $actions[ $form->id ] = $form->name; |
|
| 976 | + } |
|
| 977 | + unset($form); |
|
| 978 | + } |
|
| 979 | + |
|
| 980 | + if ( empty($actions) ) { |
|
| 981 | + return; |
|
| 982 | + } |
|
| 983 | + |
|
| 984 | + asort($actions); |
|
| 985 | + |
|
| 986 | + global $wp_admin_bar; |
|
| 987 | + |
|
| 988 | + if ( count($actions) == 1 ) { |
|
| 989 | + $wp_admin_bar->add_menu( array( |
|
| 990 | + 'title' => 'Edit Form', |
|
| 991 | 991 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 992 | - 'id' => 'frm-forms', |
|
| 993 | - ) ); |
|
| 994 | - } else { |
|
| 995 | - $wp_admin_bar->add_menu( array( |
|
| 996 | - 'id' => 'frm-forms', |
|
| 997 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 992 | + 'id' => 'frm-forms', |
|
| 993 | + ) ); |
|
| 994 | + } else { |
|
| 995 | + $wp_admin_bar->add_menu( array( |
|
| 996 | + 'id' => 'frm-forms', |
|
| 997 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 998 | 998 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 999 | - 'meta' => array( |
|
| 999 | + 'meta' => array( |
|
| 1000 | 1000 | 'title' => __( 'Edit Forms', 'formidable' ), |
| 1001 | - ), |
|
| 1002 | - ) ); |
|
| 1001 | + ), |
|
| 1002 | + ) ); |
|
| 1003 | 1003 | |
| 1004 | - foreach ( $actions as $form_id => $name ) { |
|
| 1004 | + foreach ( $actions as $form_id => $name ) { |
|
| 1005 | 1005 | |
| 1006 | - $wp_admin_bar->add_menu( array( |
|
| 1007 | - 'parent' => 'frm-forms', |
|
| 1006 | + $wp_admin_bar->add_menu( array( |
|
| 1007 | + 'parent' => 'frm-forms', |
|
| 1008 | 1008 | 'id' => 'edit_form_' . $form_id, |
| 1009 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1009 | + 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1010 | 1010 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1011 | - ) ); |
|
| 1012 | - } |
|
| 1013 | - } |
|
| 1014 | - } |
|
| 1011 | + ) ); |
|
| 1012 | + } |
|
| 1013 | + } |
|
| 1014 | + } |
|
| 1015 | 1015 | |
| 1016 | - //formidable shortcode |
|
| 1016 | + //formidable shortcode |
|
| 1017 | 1017 | public static function get_form_shortcode( $atts ) { |
| 1018 | - global $frm_vars; |
|
| 1019 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1020 | - $sc = '[formidable'; |
|
| 1018 | + global $frm_vars; |
|
| 1019 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1020 | + $sc = '[formidable'; |
|
| 1021 | 1021 | if ( ! empty( $atts ) ) { |
| 1022 | 1022 | foreach ( $atts as $k => $v ) { |
| 1023 | 1023 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | return $sc . ']'; |
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - $shortcode_atts = shortcode_atts( array( |
|
| 1030 | - 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1031 | - 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1032 | - 'exclude_fields' => array(), 'minimize' => false, |
|
| 1033 | - ), $atts); |
|
| 1034 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1035 | - |
|
| 1036 | - return self::show_form( |
|
| 1037 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1038 | - $shortcode_atts['description'], $atts |
|
| 1039 | - ); |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1043 | - if ( empty( $id ) ) { |
|
| 1044 | - $id = $key; |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - // no form id or key set |
|
| 1048 | - if ( empty( $id ) ) { |
|
| 1049 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1050 | - } |
|
| 1051 | - |
|
| 1052 | - $form = FrmForm::getOne( $id ); |
|
| 1053 | - if ( ! $form || $form->parent_form_id ) { |
|
| 1054 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1055 | - } |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + $shortcode_atts = shortcode_atts( array( |
|
| 1030 | + 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1031 | + 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1032 | + 'exclude_fields' => array(), 'minimize' => false, |
|
| 1033 | + ), $atts); |
|
| 1034 | + do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1035 | + |
|
| 1036 | + return self::show_form( |
|
| 1037 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1038 | + $shortcode_atts['description'], $atts |
|
| 1039 | + ); |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1043 | + if ( empty( $id ) ) { |
|
| 1044 | + $id = $key; |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + // no form id or key set |
|
| 1048 | + if ( empty( $id ) ) { |
|
| 1049 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1050 | + } |
|
| 1051 | + |
|
| 1052 | + $form = FrmForm::getOne( $id ); |
|
| 1053 | + if ( ! $form || $form->parent_form_id ) { |
|
| 1054 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | 1057 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1058 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1058 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1059 | 1059 | |
| 1060 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1060 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1061 | 1061 | |
| 1062 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1062 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1063 | 1063 | |
| 1064 | 1064 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1065 | 1065 | // don't show a draft form on a page |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | return $form; |
| 1083 | - } |
|
| 1083 | + } |
|
| 1084 | 1084 | |
| 1085 | 1085 | private static function is_viewable_draft_form( $form ) { |
| 1086 | 1086 | global $post; |
@@ -1096,98 +1096,98 @@ discard block |
||
| 1096 | 1096 | 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'] ); |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1100 | - ob_start(); |
|
| 1099 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1100 | + ob_start(); |
|
| 1101 | 1101 | |
| 1102 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1102 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1103 | 1103 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1104 | 1104 | |
| 1105 | - $contents = ob_get_contents(); |
|
| 1106 | - ob_end_clean(); |
|
| 1105 | + $contents = ob_get_contents(); |
|
| 1106 | + ob_end_clean(); |
|
| 1107 | 1107 | |
| 1108 | 1108 | self::maybe_minimize_form( $atts, $contents ); |
| 1109 | 1109 | |
| 1110 | - return $contents; |
|
| 1111 | - } |
|
| 1110 | + return $contents; |
|
| 1111 | + } |
|
| 1112 | 1112 | |
| 1113 | 1113 | public static function enqueue_scripts( $params ) { |
| 1114 | 1114 | do_action( 'frm_enqueue_form_scripts', $params ); |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | 1117 | public static function get_form_contents( $form, $title, $description, $atts ) { |
| 1118 | - global $frm_vars; |
|
| 1118 | + global $frm_vars; |
|
| 1119 | 1119 | |
| 1120 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1120 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1121 | 1121 | |
| 1122 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1122 | + $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1123 | 1123 | |
| 1124 | - $user_ID = get_current_user_id(); |
|
| 1124 | + $user_ID = get_current_user_id(); |
|
| 1125 | 1125 | $params = FrmForm::get_params( $form ); |
| 1126 | - $message = $errors = ''; |
|
| 1126 | + $message = $errors = ''; |
|
| 1127 | 1127 | |
| 1128 | - if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1129 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1130 | - } |
|
| 1128 | + if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1129 | + $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | 1132 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1133 | - $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1133 | + $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1134 | 1134 | |
| 1135 | - if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1136 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1137 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1138 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1135 | + if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1136 | + do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1137 | + if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1138 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1139 | 1139 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1140 | - } |
|
| 1141 | - return; |
|
| 1142 | - } |
|
| 1140 | + } |
|
| 1141 | + return; |
|
| 1142 | + } |
|
| 1143 | 1143 | |
| 1144 | - if ( ! empty($errors) ) { |
|
| 1145 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1144 | + if ( ! empty($errors) ) { |
|
| 1145 | + $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1146 | 1146 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1147 | - return; |
|
| 1148 | - } |
|
| 1147 | + return; |
|
| 1148 | + } |
|
| 1149 | 1149 | |
| 1150 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1151 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1152 | - return; |
|
| 1153 | - } |
|
| 1150 | + do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1151 | + if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1152 | + return; |
|
| 1153 | + } |
|
| 1154 | 1154 | |
| 1155 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1156 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1157 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1155 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1156 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1157 | + $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1158 | 1158 | |
| 1159 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1160 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1159 | + if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1160 | + do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1161 | 1161 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1162 | - return; |
|
| 1163 | - } |
|
| 1162 | + return; |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | - if ( $created && is_numeric($created) ) { |
|
| 1166 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1167 | - $class = 'frm_message'; |
|
| 1168 | - } else { |
|
| 1169 | - $message = $frm_settings->failed_msg; |
|
| 1170 | - $class = 'frm_error_style'; |
|
| 1171 | - } |
|
| 1165 | + if ( $created && is_numeric($created) ) { |
|
| 1166 | + $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1167 | + $class = 'frm_message'; |
|
| 1168 | + } else { |
|
| 1169 | + $message = $frm_settings->failed_msg; |
|
| 1170 | + $class = 'frm_error_style'; |
|
| 1171 | + } |
|
| 1172 | 1172 | |
| 1173 | 1173 | $message = FrmFormsHelper::get_success_message( array( |
| 1174 | 1174 | 'message' => $message, 'form' => $form, |
| 1175 | 1175 | 'entry_id' => $created, 'class' => $class, |
| 1176 | 1176 | ) ); |
| 1177 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1177 | + $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1178 | 1178 | |
| 1179 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1179 | + if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1180 | 1180 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1181 | - } else { |
|
| 1182 | - global $frm_vars; |
|
| 1181 | + } else { |
|
| 1182 | + global $frm_vars; |
|
| 1183 | 1183 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 1184 | 1184 | |
| 1185 | 1185 | $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
| 1186 | 1186 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
| 1187 | - } |
|
| 1187 | + } |
|
| 1188 | 1188 | |
| 1189 | 1189 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1190 | - } |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | 1192 | public static function front_head() { |
| 1193 | 1193 | $version = FrmAppHelper::plugin_version(); |
@@ -1216,10 +1216,10 @@ discard block |
||
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | public static function defer_script_loading( $tag, $handle ) { |
| 1219 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1220 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1219 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1220 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1221 | 1221 | } |
| 1222 | - return $tag; |
|
| 1222 | + return $tag; |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | 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 | } |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 21 | + add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
| 22 | 22 | |
| 23 | - add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | - add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 23 | + add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
| 24 | + add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
| 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,39 +33,39 @@ 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 | public static function list_form() { |
| 41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 41 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 42 | 42 | |
| 43 | 43 | $params = FrmForm::list_page_params(); |
| 44 | - $errors = self::process_bulk_form_actions( array()); |
|
| 45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
| 44 | + $errors = self::process_bulk_form_actions( array() ); |
|
| 45 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
| 46 | 46 | |
| 47 | 47 | return self::display_forms_list( $params, '', $errors ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public static function new_form( $values = array() ) { |
| 51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 51 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 52 | 52 | |
| 53 | 53 | global $frm_vars; |
| 54 | 54 | |
| 55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 56 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
| 55 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 56 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
| 57 | 57 | |
| 58 | 58 | if ( $action == 'create' ) { |
| 59 | - return self::create($values); |
|
| 59 | + return self::create( $values ); |
|
| 60 | 60 | } else if ( $action == 'new' ) { |
| 61 | 61 | $frm_field_selection = FrmField::field_selection(); |
| 62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 62 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
| 63 | 63 | $id = FrmForm::create( $values ); |
| 64 | - $form = FrmForm::getOne($id); |
|
| 64 | + $form = FrmForm::getOne( $id ); |
|
| 65 | 65 | |
| 66 | 66 | // add default email notification |
| 67 | 67 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 68 | - $action_control->create($form->id); |
|
| 68 | + $action_control->create( $form->id ); |
|
| 69 | 69 | |
| 70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public static function create( $values = array() ) { |
| 78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 78 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 79 | 79 | |
| 80 | 80 | global $frm_vars; |
| 81 | 81 | if ( empty( $values ) ) { |
@@ -87,22 +87,22 @@ discard block |
||
| 87 | 87 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 90 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
| 91 | 91 | |
| 92 | 92 | if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
| 93 | 93 | $frm_settings = FrmAppHelper::get_settings(); |
| 94 | 94 | $errors = array( 'form' => $frm_settings->admin_permission ); |
| 95 | 95 | } else { |
| 96 | - $errors = FrmForm::validate($values); |
|
| 96 | + $errors = FrmForm::validate( $values ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( count($errors) > 0 ) { |
|
| 99 | + if ( count( $errors ) > 0 ) { |
|
| 100 | 100 | $hide_preview = true; |
| 101 | 101 | $frm_field_selection = FrmField::field_selection(); |
| 102 | 102 | $form = FrmForm::getOne( $id ); |
| 103 | - $fields = FrmField::get_all_for_form($id); |
|
| 103 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 104 | 104 | |
| 105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 105 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 107 | 107 | |
| 108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -114,32 +114,32 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public static function edit( $values = false ) { |
| 117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 117 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 118 | 118 | |
| 119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 120 | - return self::get_edit_vars($id); |
|
| 120 | + return self::get_edit_vars( $id ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public static function settings( $id = false, $message = '' ) { |
| 124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 124 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 125 | 125 | |
| 126 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 126 | + if ( ! $id || ! is_numeric( $id ) ) { |
|
| 127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 128 | 128 | } |
| 129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public static function update_settings() { |
| 133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 133 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 134 | 134 | |
| 135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 136 | 136 | |
| 137 | - $errors = FrmForm::validate($_POST); |
|
| 138 | - if ( count($errors) > 0 ) { |
|
| 139 | - return self::get_settings_vars($id, $errors); |
|
| 137 | + $errors = FrmForm::validate( $_POST ); |
|
| 138 | + if ( count( $errors ) > 0 ) { |
|
| 139 | + return self::get_settings_vars( $id, $errors ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - do_action('frm_before_update_form_settings', $id); |
|
| 142 | + do_action( 'frm_before_update_form_settings', $id ); |
|
| 143 | 143 | |
| 144 | 144 | FrmForm::update( $id, $_POST ); |
| 145 | 145 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | private static function edit_in_place_value( $field ) { |
| 163 | 163 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 164 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
| 164 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 165 | 165 | |
| 166 | 166 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 167 | 167 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @since 2.0 |
| 220 | 220 | */ |
| 221 | 221 | public static function _create_from_template() { |
| 222 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 222 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 223 | 223 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 224 | 224 | |
| 225 | 225 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -234,15 +234,15 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | public static function duplicate() { |
| 237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 237 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 238 | 238 | |
| 239 | 239 | $params = FrmForm::list_page_params(); |
| 240 | 240 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
| 241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 241 | + $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 242 | 242 | if ( $form ) { |
| 243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
| 244 | 244 | } else { |
| 245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 245 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | public static function bulk_untrash( $ids ) { |
| 307 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 307 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 308 | 308 | |
| 309 | 309 | $count = FrmForm::set_status( $ids, 'published' ); |
| 310 | 310 | |
| 311 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 311 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 312 | 312 | return $message; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -327,11 +327,11 @@ discard block |
||
| 327 | 327 | 'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ), |
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
| 330 | + if ( ! isset( $available_status[$status] ) ) { |
|
| 331 | 331 | return; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
| 334 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
| 335 | 335 | |
| 336 | 336 | $params = FrmForm::list_page_params(); |
| 337 | 337 | |
@@ -339,25 +339,25 @@ discard block |
||
| 339 | 339 | check_admin_referer( $status . '_form_' . $params['id'] ); |
| 340 | 340 | |
| 341 | 341 | $count = 0; |
| 342 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
| 343 | - $count++; |
|
| 342 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
| 343 | + $count ++; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 346 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
| 347 | 347 | $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=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
| 348 | 348 | |
| 349 | - $message = $available_status[ $status ]['message']; |
|
| 349 | + $message = $available_status[$status]['message']; |
|
| 350 | 350 | |
| 351 | 351 | self::display_forms_list( $params, $message ); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | public static function bulk_trash( $ids ) { |
| 355 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 355 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 356 | 356 | |
| 357 | 357 | $count = 0; |
| 358 | 358 | foreach ( $ids as $id ) { |
| 359 | 359 | if ( FrmForm::trash( $id ) ) { |
| 360 | - $count++; |
|
| 360 | + $count ++; |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
@@ -368,49 +368,49 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | public static function destroy() { |
| 371 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 371 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 372 | 372 | |
| 373 | 373 | $params = FrmForm::list_page_params(); |
| 374 | 374 | |
| 375 | 375 | //check nonce url |
| 376 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 376 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
| 377 | 377 | |
| 378 | 378 | $count = 0; |
| 379 | 379 | if ( FrmForm::destroy( $params['id'] ) ) { |
| 380 | - $count++; |
|
| 380 | + $count ++; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 383 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 384 | 384 | |
| 385 | 385 | self::display_forms_list( $params, $message ); |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | public static function bulk_destroy( $ids ) { |
| 389 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 389 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
| 390 | 390 | |
| 391 | 391 | $count = 0; |
| 392 | 392 | foreach ( $ids as $id ) { |
| 393 | 393 | $d = FrmForm::destroy( $id ); |
| 394 | 394 | if ( $d ) { |
| 395 | - $count++; |
|
| 395 | + $count ++; |
|
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 399 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 400 | 400 | |
| 401 | 401 | return $message; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | private static function delete_all() { |
| 405 | 405 | //check nonce url |
| 406 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 406 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 407 | 407 | if ( $permission_error !== false ) { |
| 408 | 408 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 409 | 409 | return; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $count = FrmForm::scheduled_delete( time() ); |
| 413 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 413 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
| 414 | 414 | |
| 415 | 415 | self::display_forms_list( array(), $message ); |
| 416 | 416 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @since 2.0.15 |
| 428 | 428 | */ |
| 429 | 429 | public static function insert_form_button() { |
| 430 | - if ( current_user_can('frm_view_forms') ) { |
|
| 430 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
| 431 | 431 | $menu_name = FrmAppHelper::get_menu_name(); |
| 432 | 432 | $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' ) . '"> |
| 433 | 433 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
@@ -448,17 +448,17 @@ discard block |
||
| 448 | 448 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 449 | 449 | ); |
| 450 | 450 | |
| 451 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 451 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
| 452 | 452 | |
| 453 | 453 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | public static function get_shortcode_opts() { |
| 457 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 457 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 458 | 458 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 459 | 459 | |
| 460 | 460 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 461 | - if ( empty($shortcode) ) { |
|
| 461 | + if ( empty( $shortcode ) ) { |
|
| 462 | 462 | wp_die(); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | ); |
| 479 | 479 | break; |
| 480 | 480 | } |
| 481 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 481 | + $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
| 482 | 482 | |
| 483 | 483 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 484 | 484 | // allow other shortcodes to use the required form id option |
@@ -595,11 +595,11 @@ discard block |
||
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | if ( $form->parent_form_id ) { |
| 598 | - 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>' )); |
|
| 598 | + 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>' ) ); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | $frm_field_selection = FrmField::field_selection(); |
| 602 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 602 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 603 | 603 | |
| 604 | 604 | // Automatically add end section fields if they don't exist (2.0 migration) |
| 605 | 605 | $reset_fields = false; |
@@ -609,9 +609,9 @@ discard block |
||
| 609 | 609 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 612 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
| 613 | 613 | |
| 614 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 614 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 615 | 615 | |
| 616 | 616 | $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
| 617 | 617 | if ( $form->is_template && $message == $edit_message ) { |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 622 | 622 | |
| 623 | 623 | if ( $form->default_template ) { |
| 624 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 625 | - } else if ( defined('DOING_AJAX') ) { |
|
| 624 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 625 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
| 626 | 626 | wp_die(); |
| 627 | 627 | } else if ( $create_link ) { |
| 628 | 628 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -638,28 +638,28 @@ discard block |
||
| 638 | 638 | |
| 639 | 639 | $form = FrmForm::getOne( $id ); |
| 640 | 640 | |
| 641 | - $fields = FrmField::get_all_for_form($id); |
|
| 642 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 641 | + $fields = FrmField::get_all_for_form( $id ); |
|
| 642 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
| 643 | 643 | |
| 644 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 645 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 644 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
| 645 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | $action_controls = FrmFormActionsController::get_form_actions(); |
| 649 | 649 | |
| 650 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 650 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
| 651 | 651 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
| 652 | 652 | |
| 653 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 653 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
| 654 | 654 | |
| 655 | 655 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | public static function mb_tags_box( $form_id, $class = '' ) { |
| 659 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 659 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 660 | 660 | $linked_forms = array(); |
| 661 | 661 | $col = 'one'; |
| 662 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 662 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
| 663 | 663 | |
| 664 | 664 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 665 | 665 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -737,13 +737,13 @@ discard block |
||
| 737 | 737 | |
| 738 | 738 | // Insert the form class setting into the form |
| 739 | 739 | public static function form_classes( $form ) { |
| 740 | - if ( isset($form->options['form_class']) ) { |
|
| 740 | + if ( isset( $form->options['form_class'] ) ) { |
|
| 741 | 741 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | public static function get_email_html() { |
| 746 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
| 746 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 747 | 747 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 748 | 748 | echo FrmEntryFormat::show_entry( array( |
| 749 | 749 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
@@ -840,11 +840,11 @@ discard block |
||
| 840 | 840 | public static function add_default_templates( $path, $default = true, $template = true ) { |
| 841 | 841 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
| 842 | 842 | |
| 843 | - $path = untrailingslashit(trim($path)); |
|
| 843 | + $path = untrailingslashit( trim( $path ) ); |
|
| 844 | 844 | $templates = glob( $path . '/*.php' ); |
| 845 | 845 | |
| 846 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
| 847 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
| 846 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
| 847 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
| 848 | 848 | $template_query = array( 'form_key' => $filename ); |
| 849 | 849 | if ( $template ) { |
| 850 | 850 | $template_query['is_template'] = 1; |
@@ -862,12 +862,12 @@ discard block |
||
| 862 | 862 | $values['default_template'] = 1; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - include( $templates[ $i ] ); |
|
| 865 | + include( $templates[$i] ); |
|
| 866 | 866 | |
| 867 | 867 | //get updated form |
| 868 | - if ( isset($form) && ! empty($form) ) { |
|
| 868 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
| 869 | 869 | $old_id = $form->id; |
| 870 | - $form = FrmForm::getOne($form->id); |
|
| 870 | + $form = FrmForm::getOne( $form->id ); |
|
| 871 | 871 | } else { |
| 872 | 872 | $old_id = false; |
| 873 | 873 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -880,24 +880,24 @@ discard block |
||
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | public static function route() { |
| 883 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 883 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 884 | 884 | $vars = array(); |
| 885 | 885 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 886 | 886 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 887 | 887 | |
| 888 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 889 | - $json_vars = json_decode($json_vars, true); |
|
| 890 | - if ( empty($json_vars) ) { |
|
| 888 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
| 889 | + $json_vars = json_decode( $json_vars, true ); |
|
| 890 | + if ( empty( $json_vars ) ) { |
|
| 891 | 891 | // json decoding failed so we should return an error message |
| 892 | 892 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 893 | 893 | if ( 'edit' == $action ) { |
| 894 | 894 | $action = 'update'; |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 897 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
| 898 | 898 | } else { |
| 899 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 900 | - $action = $vars[ $action ]; |
|
| 899 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
| 900 | + $action = $vars[$action]; |
|
| 901 | 901 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 902 | 902 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 903 | 903 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | |
| 916 | 916 | switch ( $action ) { |
| 917 | 917 | case 'new': |
| 918 | - return self::new_form($vars); |
|
| 918 | + return self::new_form( $vars ); |
|
| 919 | 919 | case 'create': |
| 920 | 920 | case 'edit': |
| 921 | 921 | case 'update': |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 941 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
| 942 | 942 | FrmAppHelper::remove_get_action(); |
| 943 | 943 | return self::list_form(); |
| 944 | 944 | } |
@@ -965,27 +965,27 @@ discard block |
||
| 965 | 965 | |
| 966 | 966 | public static function admin_bar_configure() { |
| 967 | 967 | global $frm_vars; |
| 968 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 968 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
| 969 | 969 | return; |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | $actions = array(); |
| 973 | 973 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
| 974 | - if ( is_object($form) ) { |
|
| 975 | - $actions[ $form->id ] = $form->name; |
|
| 974 | + if ( is_object( $form ) ) { |
|
| 975 | + $actions[$form->id] = $form->name; |
|
| 976 | 976 | } |
| 977 | - unset($form); |
|
| 977 | + unset( $form ); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - if ( empty($actions) ) { |
|
| 980 | + if ( empty( $actions ) ) { |
|
| 981 | 981 | return; |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - asort($actions); |
|
| 984 | + asort( $actions ); |
|
| 985 | 985 | |
| 986 | 986 | global $wp_admin_bar; |
| 987 | 987 | |
| 988 | - if ( count($actions) == 1 ) { |
|
| 988 | + if ( count( $actions ) == 1 ) { |
|
| 989 | 989 | $wp_admin_bar->add_menu( array( |
| 990 | 990 | 'title' => 'Edit Form', |
| 991 | 991 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | $wp_admin_bar->add_menu( array( |
| 1007 | 1007 | 'parent' => 'frm-forms', |
| 1008 | 1008 | 'id' => 'edit_form_' . $form_id, |
| 1009 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1009 | + 'title' => empty( $name ) ? __( '(no title)' ) : $name, |
|
| 1010 | 1010 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1011 | 1011 | ) ); |
| 1012 | 1012 | } |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | //formidable shortcode |
| 1017 | 1017 | public static function get_form_shortcode( $atts ) { |
| 1018 | 1018 | global $frm_vars; |
| 1019 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1019 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
| 1020 | 1020 | $sc = '[formidable'; |
| 1021 | 1021 | if ( ! empty( $atts ) ) { |
| 1022 | 1022 | foreach ( $atts as $k => $v ) { |
@@ -1030,8 +1030,8 @@ discard block |
||
| 1030 | 1030 | 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
| 1031 | 1031 | 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
| 1032 | 1032 | 'exclude_fields' => array(), 'minimize' => false, |
| 1033 | - ), $atts); |
|
| 1034 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1033 | + ), $atts ); |
|
| 1034 | + do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
| 1035 | 1035 | |
| 1036 | 1036 | return self::show_form( |
| 1037 | 1037 | $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
@@ -1119,51 +1119,51 @@ discard block |
||
| 1119 | 1119 | |
| 1120 | 1120 | $frm_settings = FrmAppHelper::get_settings(); |
| 1121 | 1121 | |
| 1122 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1122 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1123 | 1123 | |
| 1124 | 1124 | $user_ID = get_current_user_id(); |
| 1125 | 1125 | $params = FrmForm::get_params( $form ); |
| 1126 | 1126 | $message = $errors = ''; |
| 1127 | 1127 | |
| 1128 | 1128 | if ( $params['posted_form_id'] == $form->id && $_POST ) { |
| 1129 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1129 | + $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array(); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1133 | 1133 | $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
| 1134 | 1134 | |
| 1135 | 1135 | if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
| 1136 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1137 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1138 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1136 | + do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
| 1137 | + if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
| 1138 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form ); |
|
| 1139 | 1139 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1140 | 1140 | } |
| 1141 | 1141 | return; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - if ( ! empty($errors) ) { |
|
| 1145 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1144 | + if ( ! empty( $errors ) ) { |
|
| 1145 | + $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array(); |
|
| 1146 | 1146 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1147 | 1147 | return; |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1151 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1150 | + do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
| 1151 | + if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
| 1152 | 1152 | return; |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1156 | - $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form->id ] ) ) ? $frm_vars['created_entries'][ $form->id ]['entry_id'] : 0; |
|
| 1157 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1155 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true ); |
|
| 1156 | + $created = ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form->id] ) ) ? $frm_vars['created_entries'][$form->id]['entry_id'] : 0; |
|
| 1157 | + $conf_method = apply_filters( 'frm_success_filter', 'message', $form, $form->options, 'create' ); |
|
| 1158 | 1158 | |
| 1159 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1160 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1159 | + if ( $created && is_numeric( $created ) && $conf_method != 'message' ) { |
|
| 1160 | + do_action( 'frm_success_action', $conf_method, $form, $form->options, $created ); |
|
| 1161 | 1161 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1162 | 1162 | return; |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - if ( $created && is_numeric($created) ) { |
|
| 1166 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1165 | + if ( $created && is_numeric( $created ) ) { |
|
| 1166 | + $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1167 | 1167 | $class = 'frm_message'; |
| 1168 | 1168 | } else { |
| 1169 | 1169 | $message = $frm_settings->failed_msg; |
@@ -1174,9 +1174,9 @@ discard block |
||
| 1174 | 1174 | 'message' => $message, 'form' => $form, |
| 1175 | 1175 | 'entry_id' => $created, 'class' => $class, |
| 1176 | 1176 | ) ); |
| 1177 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1177 | + $message = apply_filters( 'frm_main_feedback', $message, $form, $created ); |
|
| 1178 | 1178 | |
| 1179 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1179 | + if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) { |
|
| 1180 | 1180 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1181 | 1181 | } else { |
| 1182 | 1182 | global $frm_vars; |
@@ -2,137 +2,137 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta['. $field_id .']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public static function create() { |
|
| 52 | + public static function create() { |
|
| 53 | 53 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 54 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 54 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 58 | 58 | |
| 59 | - $field = self::include_new_field($field_type, $form_id); |
|
| 59 | + $field = self::include_new_field($field_type, $form_id); |
|
| 60 | 60 | |
| 61 | - // this hook will allow for multiple fields to be added at once |
|
| 62 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 61 | + // this hook will allow for multiple fields to be added at once |
|
| 62 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 63 | 63 | |
| 64 | - wp_die(); |
|
| 65 | - } |
|
| 64 | + wp_die(); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @param integer $form_id |
|
| 69 | - */ |
|
| 67 | + /** |
|
| 68 | + * @param integer $form_id |
|
| 69 | + */ |
|
| 70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
| 71 | - $values = array(); |
|
| 72 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 74 | - } |
|
| 71 | + $values = array(); |
|
| 72 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 73 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 77 | - $field_id = FrmField::create( $field_values ); |
|
| 76 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 77 | + $field_id = FrmField::create( $field_values ); |
|
| 78 | 78 | |
| 79 | - if ( ! $field_id ) { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 79 | + if ( ! $field_id ) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 83 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 84 | 84 | |
| 85 | - return $field; |
|
| 86 | - } |
|
| 85 | + return $field; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public static function update_form_id() { |
|
| 88 | + public static function update_form_id() { |
|
| 89 | 89 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 90 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 90 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 91 | 91 | |
| 92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 93 | 93 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 94 | 94 | |
| 95 | - if ( ! $field_id || ! $form_id ) { |
|
| 96 | - wp_die(); |
|
| 97 | - } |
|
| 95 | + if ( ! $field_id || ! $form_id ) { |
|
| 96 | + wp_die(); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
| 100 | 100 | echo absint( $updated ); |
| 101 | 101 | |
| 102 | - wp_die(); |
|
| 103 | - } |
|
| 102 | + wp_die(); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
| 106 | 106 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 107 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 107 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 108 | 108 | |
| 109 | - if ( empty($field) ) { |
|
| 110 | - $field = 'name'; |
|
| 111 | - } |
|
| 109 | + if ( empty($field) ) { |
|
| 110 | + $field = 'name'; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if ( empty($id) ) { |
|
| 113 | + if ( empty($id) ) { |
|
| 114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 119 | 119 | $value = trim( $value ); |
| 120 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 121 | - // set blank value if there is no content |
|
| 122 | - $value = ''; |
|
| 123 | - } |
|
| 120 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 121 | + // set blank value if there is no content |
|
| 122 | + $value = ''; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | FrmField::update( $id, array( $field => $value ) ); |
| 126 | 126 | |
| 127 | 127 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 128 | 128 | |
| 129 | 129 | echo stripslashes( wp_kses_post( $value ) ); |
| 130 | - wp_die(); |
|
| 131 | - } |
|
| 130 | + wp_die(); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - public static function update_ajax_option() { |
|
| 133 | + public static function update_ajax_option() { |
|
| 134 | 134 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 135 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 135 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 136 | 136 | |
| 137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 138 | 138 | if ( ! $field_id ) { |
@@ -147,141 +147,141 @@ discard block |
||
| 147 | 147 | unset($new_val); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - FrmField::update( $field_id, array( |
|
| 151 | - 'field_options' => $field->field_options, |
|
| 150 | + FrmField::update( $field_id, array( |
|
| 151 | + 'field_options' => $field->field_options, |
|
| 152 | 152 | 'form_id' => $field->form_id, |
| 153 | - ) ); |
|
| 154 | - wp_die(); |
|
| 155 | - } |
|
| 153 | + ) ); |
|
| 154 | + wp_die(); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - public static function duplicate() { |
|
| 157 | + public static function duplicate() { |
|
| 158 | 158 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 159 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 159 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 160 | 160 | |
| 161 | - global $wpdb; |
|
| 161 | + global $wpdb; |
|
| 162 | 162 | |
| 163 | 163 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 164 | 164 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 165 | 165 | |
| 166 | 166 | $copy_field = FrmField::getOne( $field_id ); |
| 167 | - if ( ! $copy_field ) { |
|
| 168 | - wp_die(); |
|
| 169 | - } |
|
| 167 | + if ( ! $copy_field ) { |
|
| 168 | + wp_die(); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 172 | 172 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
| 173 | 173 | |
| 174 | - $values = array( 'id' => $form_id ); |
|
| 175 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 174 | + $values = array( 'id' => $form_id ); |
|
| 175 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 176 | 176 | |
| 177 | 177 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 178 | 178 | |
| 179 | - $values['field_order'] = $field_count + 1; |
|
| 179 | + $values['field_order'] = $field_count + 1; |
|
| 180 | 180 | |
| 181 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 182 | - wp_die(); |
|
| 183 | - } |
|
| 181 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 182 | + wp_die(); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - self::include_single_field($field_id, $values); |
|
| 185 | + self::include_single_field($field_id, $values); |
|
| 186 | 186 | |
| 187 | - wp_die(); |
|
| 188 | - } |
|
| 187 | + wp_die(); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Load a single field in the form builder along with all needed variables |
|
| 192 | - */ |
|
| 193 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 194 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 190 | + /** |
|
| 191 | + * Load a single field in the form builder along with all needed variables |
|
| 192 | + */ |
|
| 193 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 194 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 195 | 195 | $field_name = 'item_meta[' . $field_id . ']'; |
| 196 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 197 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 198 | - if ( $field['type'] == 'html' ) { |
|
| 199 | - $field['stop_filter'] = true; |
|
| 200 | - } |
|
| 196 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 197 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 198 | + if ( $field['type'] == 'html' ) { |
|
| 199 | + $field['stop_filter'] = true; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 203 | 203 | |
| 204 | - return $field; |
|
| 205 | - } |
|
| 204 | + return $field; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - public static function destroy() { |
|
| 207 | + public static function destroy() { |
|
| 208 | 208 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 209 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 209 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 210 | 210 | |
| 211 | 211 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 212 | 212 | FrmField::destroy( $field_id ); |
| 213 | - wp_die(); |
|
| 214 | - } |
|
| 213 | + wp_die(); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - /* Field Options */ |
|
| 216 | + /* Field Options */ |
|
| 217 | 217 | |
| 218 | - //Add Single Option or Other Option |
|
| 219 | - public static function add_option() { |
|
| 218 | + //Add Single Option or Other Option |
|
| 219 | + public static function add_option() { |
|
| 220 | 220 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 221 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 221 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 222 | 222 | |
| 223 | 223 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 224 | 224 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 225 | 225 | |
| 226 | - //Get the field |
|
| 227 | - $field = FrmField::getOne($id); |
|
| 226 | + //Get the field |
|
| 227 | + $field = FrmField::getOne($id); |
|
| 228 | 228 | |
| 229 | 229 | if ( ! empty( $field->options ) ) { |
| 230 | 230 | $keys = array_keys( $field->options ); |
| 231 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 232 | - } else { |
|
| 233 | - $last = 0; |
|
| 234 | - } |
|
| 235 | - $opt_key = $last + 1; |
|
| 231 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 232 | + } else { |
|
| 233 | + $last = 0; |
|
| 234 | + } |
|
| 235 | + $opt_key = $last + 1; |
|
| 236 | 236 | |
| 237 | - if ( 'other' == $opt_type ) { |
|
| 237 | + if ( 'other' == $opt_type ) { |
|
| 238 | 238 | $opt = esc_html__( 'Other', 'formidable' ); |
| 239 | - $other_val = ''; |
|
| 240 | - $opt_key = 'other_' . $opt_key; |
|
| 241 | - |
|
| 242 | - //Update value of "other" in DB |
|
| 243 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 244 | - $field_options['other'] = 1; |
|
| 245 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 246 | - } else { |
|
| 239 | + $other_val = ''; |
|
| 240 | + $opt_key = 'other_' . $opt_key; |
|
| 241 | + |
|
| 242 | + //Update value of "other" in DB |
|
| 243 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 244 | + $field_options['other'] = 1; |
|
| 245 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 246 | + } else { |
|
| 247 | 247 | $first_opt = reset( $field->options ); |
| 248 | 248 | $next_opt = count( $field->options ); |
| 249 | - if ( $first_opt != '' ) { |
|
| 250 | - $next_opt++; |
|
| 251 | - } |
|
| 249 | + if ( $first_opt != '' ) { |
|
| 250 | + $next_opt++; |
|
| 251 | + } |
|
| 252 | 252 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 253 | - unset($next_opt); |
|
| 254 | - } |
|
| 255 | - $field_val = $opt; |
|
| 253 | + unset($next_opt); |
|
| 254 | + } |
|
| 255 | + $field_val = $opt; |
|
| 256 | 256 | $field->options[ $opt_key ] = $opt; |
| 257 | 257 | |
| 258 | - //Update options in DB |
|
| 258 | + //Update options in DB |
|
| 259 | 259 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 260 | 260 | |
| 261 | - $field_data = $field; |
|
| 262 | - $field = array( |
|
| 263 | - 'type' => $field_data->type, |
|
| 264 | - 'id' => $id, |
|
| 265 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 266 | - 'form_id' => $field_data->form_id, |
|
| 267 | - 'field_key' => $field_data->field_key, |
|
| 268 | - ); |
|
| 261 | + $field_data = $field; |
|
| 262 | + $field = array( |
|
| 263 | + 'type' => $field_data->type, |
|
| 264 | + 'id' => $id, |
|
| 265 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 266 | + 'form_id' => $field_data->form_id, |
|
| 267 | + 'field_key' => $field_data->field_key, |
|
| 268 | + ); |
|
| 269 | 269 | |
| 270 | 270 | $field_name = 'item_meta[' . $id . ']'; |
| 271 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 272 | - $checked = ''; |
|
| 271 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 272 | + $checked = ''; |
|
| 273 | 273 | |
| 274 | - if ( 'other' == $opt_type ) { |
|
| 274 | + if ( 'other' == $opt_type ) { |
|
| 275 | 275 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 276 | - } else { |
|
| 276 | + } else { |
|
| 277 | 277 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 278 | - } |
|
| 279 | - wp_die(); |
|
| 280 | - } |
|
| 278 | + } |
|
| 279 | + wp_die(); |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - public static function edit_option() { |
|
| 282 | + public static function edit_option() { |
|
| 283 | 283 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 284 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 284 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 285 | 285 | |
| 286 | 286 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 287 | 287 | $ids = explode( '-', $element_id ); |
@@ -289,43 +289,43 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
| 291 | 291 | if ( strpos( $element_id, 'key_' ) ) { |
| 292 | - $new_value = $update_value; |
|
| 293 | - } else { |
|
| 294 | - $new_label = $update_value; |
|
| 295 | - } |
|
| 292 | + $new_value = $update_value; |
|
| 293 | + } else { |
|
| 294 | + $new_label = $update_value; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - $field = FrmField::getOne($id); |
|
| 298 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 297 | + $field = FrmField::getOne($id); |
|
| 298 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 299 | 299 | |
| 300 | - $this_opt_id = end($ids); |
|
| 300 | + $this_opt_id = end($ids); |
|
| 301 | 301 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 302 | 302 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 303 | 303 | |
| 304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 304 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 306 | 306 | |
| 307 | - if ( ! isset( $new_label ) ) { |
|
| 308 | - $new_label = $label; |
|
| 309 | - } |
|
| 307 | + if ( ! isset( $new_label ) ) { |
|
| 308 | + $new_label = $label; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - if ( isset($new_value) || isset($value) ) { |
|
| 312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | - } |
|
| 311 | + if ( isset($new_value) || isset($value) ) { |
|
| 312 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 316 | 316 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 317 | - } else { |
|
| 317 | + } else { |
|
| 318 | 318 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 319 | - } |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 322 | 322 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 323 | - wp_die(); |
|
| 324 | - } |
|
| 323 | + wp_die(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - public static function delete_option() { |
|
| 326 | + public static function delete_option() { |
|
| 327 | 327 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 328 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 328 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 329 | 329 | |
| 330 | 330 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 331 | 331 | $field = FrmField::getOne( $field_id ); |
@@ -333,310 +333,310 @@ discard block |
||
| 333 | 333 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 334 | 334 | |
| 335 | 335 | $options = $field->options; |
| 336 | - unset( $options[ $opt_key ] ); |
|
| 337 | - $response = array( 'other' => true ); |
|
| 336 | + unset( $options[ $opt_key ] ); |
|
| 337 | + $response = array( 'other' => true ); |
|
| 338 | 338 | |
| 339 | - //If the deleted option is an "other" option |
|
| 339 | + //If the deleted option is an "other" option |
|
| 340 | 340 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 341 | - //Assume all other options are gone, unless proven otherwise |
|
| 342 | - $other = false; |
|
| 341 | + //Assume all other options are gone, unless proven otherwise |
|
| 342 | + $other = false; |
|
| 343 | 343 | |
| 344 | - //Check if all other options are really gone |
|
| 345 | - foreach ( $options as $o_key => $o_val ) { |
|
| 346 | - //If there is still an other option in the field, set other to true |
|
| 344 | + //Check if all other options are really gone |
|
| 345 | + foreach ( $options as $o_key => $o_val ) { |
|
| 346 | + //If there is still an other option in the field, set other to true |
|
| 347 | 347 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 348 | - $other = true; |
|
| 349 | - break; |
|
| 350 | - } |
|
| 351 | - unset( $o_key, $o_val ); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - //If all other options are gone |
|
| 355 | - if ( false === $other ) { |
|
| 356 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 357 | - $field_options['other'] = 0; |
|
| 348 | + $other = true; |
|
| 349 | + break; |
|
| 350 | + } |
|
| 351 | + unset( $o_key, $o_val ); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + //If all other options are gone |
|
| 355 | + if ( false === $other ) { |
|
| 356 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 357 | + $field_options['other'] = 0; |
|
| 358 | 358 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 359 | - $response = array( 'other' => false ); |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - echo json_encode( $response ); |
|
| 359 | + $response = array( 'other' => false ); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + echo json_encode( $response ); |
|
| 363 | 363 | |
| 364 | 364 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 365 | 365 | |
| 366 | - wp_die(); |
|
| 367 | - } |
|
| 366 | + wp_die(); |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - public static function import_choices() { |
|
| 370 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 369 | + public static function import_choices() { |
|
| 370 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 371 | 371 | |
| 372 | 372 | $field_id = absint( $_REQUEST['field_id'] ); |
| 373 | 373 | |
| 374 | - global $current_screen, $hook_suffix; |
|
| 374 | + global $current_screen, $hook_suffix; |
|
| 375 | 375 | |
| 376 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 377 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 378 | - $hook_suffix = ''; |
|
| 379 | - set_current_screen(); |
|
| 380 | - } |
|
| 376 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 377 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 378 | + $hook_suffix = ''; |
|
| 379 | + set_current_screen(); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 383 | - register_admin_color_schemes(); |
|
| 384 | - } |
|
| 382 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 383 | + register_admin_color_schemes(); |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - $hook_suffix = $admin_body_class = ''; |
|
| 386 | + $hook_suffix = $admin_body_class = ''; |
|
| 387 | 387 | |
| 388 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 389 | - $admin_body_class .= ' folded'; |
|
| 390 | - } |
|
| 388 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 389 | + $admin_body_class .= ' folded'; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 393 | - $admin_body_class .= ' admin-bar'; |
|
| 394 | - } |
|
| 392 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 393 | + $admin_body_class .= ' admin-bar'; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - if ( is_rtl() ) { |
|
| 397 | - $admin_body_class .= ' rtl'; |
|
| 398 | - } |
|
| 396 | + if ( is_rtl() ) { |
|
| 397 | + $admin_body_class .= ' rtl'; |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 401 | - $prepop = array(); |
|
| 402 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 400 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 401 | + $prepop = array(); |
|
| 402 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 403 | 403 | |
| 404 | - $field = FrmField::getOne($field_id); |
|
| 404 | + $field = FrmField::getOne($field_id); |
|
| 405 | 405 | |
| 406 | - wp_enqueue_script( 'utils' ); |
|
| 406 | + wp_enqueue_script( 'utils' ); |
|
| 407 | 407 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 408 | - FrmAppHelper::load_admin_wide_js(); |
|
| 408 | + FrmAppHelper::load_admin_wide_js(); |
|
| 409 | 409 | |
| 410 | 410 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 411 | - wp_die(); |
|
| 412 | - } |
|
| 411 | + wp_die(); |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - public static function import_options() { |
|
| 414 | + public static function import_options() { |
|
| 415 | 415 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 416 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 416 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 417 | 417 | |
| 418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | - return; |
|
| 420 | - } |
|
| 418 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | + return; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | $field_id = absint( $_POST['field_id'] ); |
| 423 | - $field = FrmField::getOne($field_id); |
|
| 423 | + $field = FrmField::getOne($field_id); |
|
| 424 | 424 | |
| 425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 426 | - return; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | - if ( $field['separate_value'] ) { |
|
| 433 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | - if ( strpos($opt, '|') !== false ) { |
|
| 435 | - $vals = explode('|', $opt); |
|
| 436 | - if ( $vals[0] != $vals[1] ) { |
|
| 437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | - } |
|
| 439 | - unset($vals); |
|
| 440 | - } |
|
| 441 | - unset($opt_key, $opt); |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - //Keep other options after bulk update |
|
| 446 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | - $other_array = array(); |
|
| 448 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | - $other_array[ $opt_key ] = $opt; |
|
| 451 | - } |
|
| 452 | - unset($opt_key, $opt); |
|
| 453 | - } |
|
| 454 | - if ( ! empty($other_array) ) { |
|
| 455 | - $opts = array_merge( $opts, $other_array); |
|
| 456 | - } |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | - |
|
| 461 | - $field['options'] = $opts; |
|
| 462 | - $field_name = $field['name']; |
|
| 463 | - |
|
| 464 | - // Get html_id which will be used in single-option.php |
|
| 465 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | - |
|
| 467 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 426 | + return; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | + $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | + if ( $field['separate_value'] ) { |
|
| 433 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | + if ( strpos($opt, '|') !== false ) { |
|
| 435 | + $vals = explode('|', $opt); |
|
| 436 | + if ( $vals[0] != $vals[1] ) { |
|
| 437 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | + } |
|
| 439 | + unset($vals); |
|
| 440 | + } |
|
| 441 | + unset($opt_key, $opt); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + //Keep other options after bulk update |
|
| 446 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | + $other_array = array(); |
|
| 448 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | + $other_array[ $opt_key ] = $opt; |
|
| 451 | + } |
|
| 452 | + unset($opt_key, $opt); |
|
| 453 | + } |
|
| 454 | + if ( ! empty($other_array) ) { |
|
| 455 | + $opts = array_merge( $opts, $other_array); |
|
| 456 | + } |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | + |
|
| 461 | + $field['options'] = $opts; |
|
| 462 | + $field_name = $field['name']; |
|
| 463 | + |
|
| 464 | + // Get html_id which will be used in single-option.php |
|
| 465 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | + |
|
| 467 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 468 | 468 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 469 | - } else { |
|
| 470 | - FrmFieldsHelper::show_single_option($field); |
|
| 471 | - } |
|
| 469 | + } else { |
|
| 470 | + FrmFieldsHelper::show_single_option($field); |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - wp_die(); |
|
| 474 | - } |
|
| 473 | + wp_die(); |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - public static function update_order() { |
|
| 476 | + public static function update_order() { |
|
| 477 | 477 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 478 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 478 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 479 | 479 | |
| 480 | 480 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 481 | 481 | foreach ( (array) $fields as $position => $item ) { |
| 482 | 482 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 483 | 483 | } |
| 484 | - wp_die(); |
|
| 485 | - } |
|
| 484 | + wp_die(); |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | 487 | public static function change_type( $type ) { |
| 488 | - $type_switch = array( |
|
| 489 | - 'scale' => 'radio', |
|
| 490 | - '10radio' => 'radio', |
|
| 491 | - 'rte' => 'textarea', |
|
| 492 | - 'website' => 'url', |
|
| 493 | - ); |
|
| 494 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 495 | - $type = $type_switch[ $type ]; |
|
| 496 | - } |
|
| 488 | + $type_switch = array( |
|
| 489 | + 'scale' => 'radio', |
|
| 490 | + '10radio' => 'radio', |
|
| 491 | + 'rte' => 'textarea', |
|
| 492 | + 'website' => 'url', |
|
| 493 | + ); |
|
| 494 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 495 | + $type = $type_switch[ $type ]; |
|
| 496 | + } |
|
| 497 | 497 | |
| 498 | 498 | $frm_field_selection = FrmField::field_selection(); |
| 499 | - $types = array_keys($frm_field_selection); |
|
| 500 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 501 | - $type = 'text'; |
|
| 502 | - } |
|
| 499 | + $types = array_keys($frm_field_selection); |
|
| 500 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 501 | + $type = 'text'; |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | - return $type; |
|
| 505 | - } |
|
| 504 | + return $type; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | public static function display_field_options( $display ) { |
| 508 | 508 | switch ( $display['type'] ) { |
| 509 | - case 'captcha': |
|
| 510 | - $display['required'] = false; |
|
| 511 | - $display['invalid'] = true; |
|
| 512 | - $display['default_blank'] = false; |
|
| 509 | + case 'captcha': |
|
| 510 | + $display['required'] = false; |
|
| 511 | + $display['invalid'] = true; |
|
| 512 | + $display['default_blank'] = false; |
|
| 513 | 513 | $display['captcha_size'] = true; |
| 514 | - break; |
|
| 515 | - case 'radio': |
|
| 516 | - $display['default_blank'] = false; |
|
| 517 | - break; |
|
| 518 | - case 'text': |
|
| 519 | - case 'textarea': |
|
| 520 | - $display['size'] = true; |
|
| 521 | - $display['clear_on_focus'] = true; |
|
| 522 | - break; |
|
| 523 | - case 'select': |
|
| 524 | - $display['size'] = true; |
|
| 525 | - break; |
|
| 526 | - case 'url': |
|
| 527 | - case 'website': |
|
| 528 | - case 'email': |
|
| 529 | - $display['size'] = true; |
|
| 530 | - $display['clear_on_focus'] = true; |
|
| 531 | - $display['invalid'] = true; |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - return $display; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - public static function input_html( $field, $echo = true ) { |
|
| 538 | - $class = array(); //$field['type']; |
|
| 539 | - self::add_input_classes($field, $class); |
|
| 540 | - |
|
| 541 | - $add_html = array(); |
|
| 542 | - self::add_html_size($field, $add_html); |
|
| 543 | - self::add_html_length($field, $add_html); |
|
| 544 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 514 | + break; |
|
| 515 | + case 'radio': |
|
| 516 | + $display['default_blank'] = false; |
|
| 517 | + break; |
|
| 518 | + case 'text': |
|
| 519 | + case 'textarea': |
|
| 520 | + $display['size'] = true; |
|
| 521 | + $display['clear_on_focus'] = true; |
|
| 522 | + break; |
|
| 523 | + case 'select': |
|
| 524 | + $display['size'] = true; |
|
| 525 | + break; |
|
| 526 | + case 'url': |
|
| 527 | + case 'website': |
|
| 528 | + case 'email': |
|
| 529 | + $display['size'] = true; |
|
| 530 | + $display['clear_on_focus'] = true; |
|
| 531 | + $display['invalid'] = true; |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + return $display; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + public static function input_html( $field, $echo = true ) { |
|
| 538 | + $class = array(); //$field['type']; |
|
| 539 | + self::add_input_classes($field, $class); |
|
| 540 | + |
|
| 541 | + $add_html = array(); |
|
| 542 | + self::add_html_size($field, $add_html); |
|
| 543 | + self::add_html_length($field, $add_html); |
|
| 544 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 545 | 545 | self::add_validation_messages( $field, $add_html ); |
| 546 | 546 | |
| 547 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 547 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 548 | 548 | |
| 549 | 549 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 550 | 550 | |
| 551 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 551 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 552 | 552 | |
| 553 | 553 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 554 | 554 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 555 | 555 | |
| 556 | - if ( $echo ) { |
|
| 557 | - echo $add_html; |
|
| 558 | - } |
|
| 556 | + if ( $echo ) { |
|
| 557 | + echo $add_html; |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - return $add_html; |
|
| 561 | - } |
|
| 560 | + return $add_html; |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | 563 | private static function add_input_classes( $field, array &$class ) { |
| 564 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 565 | - $class[] = $field['input_class']; |
|
| 566 | - } |
|
| 564 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 565 | + $class[] = $field['input_class']; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 569 | - return; |
|
| 570 | - } |
|
| 568 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 569 | + return; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - global $frm_vars; |
|
| 572 | + global $frm_vars; |
|
| 573 | 573 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
| 574 | - $class[] = 'dyn_default_value'; |
|
| 575 | - } |
|
| 574 | + $class[] = 'dyn_default_value'; |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 578 | - $class[] = 'auto_width'; |
|
| 579 | - } |
|
| 580 | - } |
|
| 577 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 578 | + $class[] = 'auto_width'; |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | private static function add_html_size( $field, array &$add_html ) { |
| 583 | 583 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
| 584 | - return; |
|
| 585 | - } |
|
| 584 | + return; |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 588 | - return; |
|
| 589 | - } |
|
| 587 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 588 | + return; |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | - if ( is_numeric($field['size']) ) { |
|
| 592 | - $field['size'] .= 'px'; |
|
| 593 | - } |
|
| 591 | + if ( is_numeric($field['size']) ) { |
|
| 592 | + $field['size'] .= 'px'; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 596 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 595 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 596 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 597 | 597 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 598 | 598 | |
| 599 | - self::add_html_cols($field, $add_html); |
|
| 600 | - } |
|
| 599 | + self::add_html_cols($field, $add_html); |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | 602 | private static function add_html_cols( $field, array &$add_html ) { |
| 603 | 603 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 604 | - return; |
|
| 605 | - } |
|
| 604 | + return; |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | - // convert to cols for textareas |
|
| 608 | - $calc = array( |
|
| 609 | - '' => 9, |
|
| 610 | - 'px' => 9, |
|
| 611 | - 'rem' => 0.444, |
|
| 612 | - 'em' => 0.544, |
|
| 613 | - ); |
|
| 607 | + // convert to cols for textareas |
|
| 608 | + $calc = array( |
|
| 609 | + '' => 9, |
|
| 610 | + 'px' => 9, |
|
| 611 | + 'rem' => 0.444, |
|
| 612 | + 'em' => 0.544, |
|
| 613 | + ); |
|
| 614 | 614 | |
| 615 | - // include "col" for valid html |
|
| 616 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 615 | + // include "col" for valid html |
|
| 616 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 617 | 617 | |
| 618 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 619 | - return; |
|
| 620 | - } |
|
| 618 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 619 | + return; |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 622 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 623 | 623 | |
| 624 | 624 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 625 | - } |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | 627 | private static function add_html_length( $field, array &$add_html ) { |
| 628 | - // check for max setting and if this field accepts maxlength |
|
| 628 | + // check for max setting and if this field accepts maxlength |
|
| 629 | 629 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 630 | - return; |
|
| 631 | - } |
|
| 630 | + return; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 634 | - // don't load on form builder page |
|
| 635 | - return; |
|
| 636 | - } |
|
| 633 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 634 | + // don't load on form builder page |
|
| 635 | + return; |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 639 | - } |
|
| 639 | + } |
|
| 640 | 640 | |
| 641 | 641 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 642 | 642 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -644,35 +644,35 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | $default_value_array = is_array( $field['default_value'] ); |
| 647 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 647 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 648 | 648 | if ( $default_value_array ) { |
| 649 | 649 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 650 | 650 | } |
| 651 | 651 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 652 | - return; |
|
| 653 | - } |
|
| 652 | + return; |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | 655 | if ( $default_value_array ) { |
| 656 | 656 | // don't include a json placeholder |
| 657 | 657 | return; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 660 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 661 | 661 | |
| 662 | 662 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 663 | - // use HMTL5 placeholder with js fallback |
|
| 663 | + // use HMTL5 placeholder with js fallback |
|
| 664 | 664 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 665 | - wp_enqueue_script('jquery-placeholder'); |
|
| 666 | - } else if ( ! $frm_settings->use_html ) { |
|
| 665 | + wp_enqueue_script('jquery-placeholder'); |
|
| 666 | + } else if ( ! $frm_settings->use_html ) { |
|
| 667 | 667 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 668 | 668 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 669 | - $class[] = 'frm_toggle_default'; |
|
| 669 | + $class[] = 'frm_toggle_default'; |
|
| 670 | 670 | |
| 671 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 672 | - $class[] = 'frm_default'; |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 671 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 672 | + $class[] = 'frm_default'; |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | 676 | |
| 677 | 677 | private static function add_validation_messages( $field, array &$add_html ) { |
| 678 | 678 | if ( FrmField::is_required( $field ) ) { |
@@ -693,44 +693,44 @@ discard block |
||
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 697 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 698 | - return; |
|
| 699 | - } |
|
| 696 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 697 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 698 | + return; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 702 | - if ( 'opt' === $k ) { |
|
| 703 | - continue; |
|
| 704 | - } |
|
| 701 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 702 | + if ( 'opt' === $k ) { |
|
| 703 | + continue; |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 707 | - $add_html[] = $v; |
|
| 708 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 706 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 707 | + $add_html[] = $v; |
|
| 708 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 709 | 709 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 710 | - } else { |
|
| 710 | + } else { |
|
| 711 | 711 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 712 | - } |
|
| 713 | - |
|
| 714 | - unset($k, $v); |
|
| 715 | - } |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 719 | - if ( is_array( $opt ) ) { |
|
| 720 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 721 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 722 | - } else { |
|
| 723 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - return $opt; |
|
| 727 | - } |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + unset($k, $v); |
|
| 715 | + } |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 719 | + if ( is_array( $opt ) ) { |
|
| 720 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 721 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 722 | + } else { |
|
| 723 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + return $opt; |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | 729 | public static function check_label( $opt ) { |
| 730 | - if ( is_array($opt) ) { |
|
| 731 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 732 | - } |
|
| 730 | + if ( is_array($opt) ) { |
|
| 731 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - return $opt; |
|
| 735 | - } |
|
| 734 | + return $opt; |
|
| 735 | + } |
|
| 736 | 736 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,32 +34,32 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public static function create() { |
| 53 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 53 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 54 | 54 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 55 | 55 | |
| 56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 58 | 58 | |
| 59 | - $field = self::include_new_field($field_type, $form_id); |
|
| 59 | + $field = self::include_new_field( $field_type, $form_id ); |
|
| 60 | 60 | |
| 61 | 61 | // this hook will allow for multiple fields to be added at once |
| 62 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 62 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 63 | 63 | |
| 64 | 64 | wp_die(); |
| 65 | 65 | } |
@@ -70,23 +70,23 @@ discard block |
||
| 70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
| 71 | 71 | $values = array(); |
| 72 | 72 | if ( FrmAppHelper::pro_is_installed() ) { |
| 73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 73 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 76 | + $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) ); |
|
| 77 | 77 | $field_id = FrmField::create( $field_values ); |
| 78 | 78 | |
| 79 | 79 | if ( ! $field_id ) { |
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 83 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 84 | 84 | |
| 85 | 85 | return $field; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public static function update_form_id() { |
| 89 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 89 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 90 | 90 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 91 | 91 | |
| 92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -103,21 +103,21 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
| 106 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 106 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 107 | 107 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 108 | 108 | |
| 109 | - if ( empty($field) ) { |
|
| 109 | + if ( empty( $field ) ) { |
|
| 110 | 110 | $field = 'name'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( empty($id) ) { |
|
| 113 | + if ( empty( $id ) ) { |
|
| 114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 119 | 119 | $value = trim( $value ); |
| 120 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 120 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 121 | 121 | // set blank value if there is no content |
| 122 | 122 | $value = ''; |
| 123 | 123 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public static function update_ajax_option() { |
| 134 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 134 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 135 | 135 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 136 | 136 | |
| 137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | if ( isset( $_POST['separate_value'] ) ) { |
| 145 | 145 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 146 | 146 | $field->field_options['separate_value'] = $new_val; |
| 147 | - unset($new_val); |
|
| 147 | + unset( $new_val ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | FrmField::update( $field_id, array( |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public static function duplicate() { |
| 158 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 158 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 159 | 159 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 160 | 160 | |
| 161 | 161 | global $wpdb; |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $values['field_order'] = $field_count + 1; |
| 180 | 180 | |
| 181 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 181 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
| 182 | 182 | wp_die(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - self::include_single_field($field_id, $values); |
|
| 185 | + self::include_single_field( $field_id, $values ); |
|
| 186 | 186 | |
| 187 | 187 | wp_die(); |
| 188 | 188 | } |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | * Load a single field in the form builder along with all needed variables |
| 192 | 192 | */ |
| 193 | 193 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 194 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 194 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 195 | 195 | $field_name = 'item_meta[' . $field_id . ']'; |
| 196 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 196 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 197 | 197 | $id = $form_id ? $form_id : $field['form_id']; |
| 198 | 198 | if ( $field['type'] == 'html' ) { |
| 199 | 199 | $field['stop_filter'] = true; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | public static function destroy() { |
| 208 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 208 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 209 | 209 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 210 | 210 | |
| 211 | 211 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -217,14 +217,14 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | //Add Single Option or Other Option |
| 219 | 219 | public static function add_option() { |
| 220 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 220 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 221 | 221 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 222 | 222 | |
| 223 | 223 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 224 | 224 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 225 | 225 | |
| 226 | 226 | //Get the field |
| 227 | - $field = FrmField::getOne($id); |
|
| 227 | + $field = FrmField::getOne( $id ); |
|
| 228 | 228 | |
| 229 | 229 | if ( ! empty( $field->options ) ) { |
| 230 | 230 | $keys = array_keys( $field->options ); |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | $first_opt = reset( $field->options ); |
| 248 | 248 | $next_opt = count( $field->options ); |
| 249 | 249 | if ( $first_opt != '' ) { |
| 250 | - $next_opt++; |
|
| 250 | + $next_opt ++; |
|
| 251 | 251 | } |
| 252 | 252 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 253 | - unset($next_opt); |
|
| 253 | + unset( $next_opt ); |
|
| 254 | 254 | } |
| 255 | 255 | $field_val = $opt; |
| 256 | - $field->options[ $opt_key ] = $opt; |
|
| 256 | + $field->options[$opt_key] = $opt; |
|
| 257 | 257 | |
| 258 | 258 | //Update options in DB |
| 259 | 259 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | $field = array( |
| 263 | 263 | 'type' => $field_data->type, |
| 264 | 264 | 'id' => $id, |
| 265 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 265 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 266 | 266 | 'form_id' => $field_data->form_id, |
| 267 | 267 | 'field_key' => $field_data->field_key, |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | 270 | $field_name = 'item_meta[' . $id . ']'; |
| 271 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 271 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 272 | 272 | $checked = ''; |
| 273 | 273 | |
| 274 | 274 | if ( 'other' == $opt_type ) { |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | public static function edit_option() { |
| 283 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 283 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 284 | 284 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 285 | 285 | |
| 286 | 286 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -294,28 +294,28 @@ discard block |
||
| 294 | 294 | $new_label = $update_value; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - $field = FrmField::getOne($id); |
|
| 297 | + $field = FrmField::getOne( $id ); |
|
| 298 | 298 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 299 | 299 | |
| 300 | - $this_opt_id = end($ids); |
|
| 301 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
| 300 | + $this_opt_id = end( $ids ); |
|
| 301 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
| 303 | 303 | |
| 304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 304 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 305 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 306 | 306 | |
| 307 | 307 | if ( ! isset( $new_label ) ) { |
| 308 | 308 | $new_label = $label; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - if ( isset($new_value) || isset($value) ) { |
|
| 312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 311 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 312 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 316 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 316 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 317 | 317 | } else { |
| 318 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 318 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | public static function delete_option() { |
| 327 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 327 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 328 | 328 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 329 | 329 | |
| 330 | 330 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 334 | 334 | |
| 335 | 335 | $options = $field->options; |
| 336 | - unset( $options[ $opt_key ] ); |
|
| 336 | + unset( $options[$opt_key] ); |
|
| 337 | 337 | $response = array( 'other' => true ); |
| 338 | 338 | |
| 339 | 339 | //If the deleted option is an "other" option |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 401 | 401 | $prepop = array(); |
| 402 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 402 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 403 | 403 | |
| 404 | - $field = FrmField::getOne($field_id); |
|
| 404 | + $field = FrmField::getOne( $field_id ); |
|
| 405 | 405 | |
| 406 | 406 | wp_enqueue_script( 'utils' ); |
| 407 | 407 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -412,33 +412,33 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | public static function import_options() { |
| 415 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 415 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 416 | 416 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 417 | 417 | |
| 418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 418 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 419 | 419 | return; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | $field_id = absint( $_POST['field_id'] ); |
| 423 | - $field = FrmField::getOne($field_id); |
|
| 423 | + $field = FrmField::getOne( $field_id ); |
|
| 424 | 424 | |
| 425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 426 | 426 | return; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 429 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 430 | + $opts = stripslashes_deep( $_POST['opts'] ); |
|
| 431 | + $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
|
| 432 | 432 | if ( $field['separate_value'] ) { |
| 433 | 433 | foreach ( $opts as $opt_key => $opt ) { |
| 434 | - if ( strpos($opt, '|') !== false ) { |
|
| 435 | - $vals = explode('|', $opt); |
|
| 434 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 435 | + $vals = explode( '|', $opt ); |
|
| 436 | 436 | if ( $vals[0] != $vals[1] ) { |
| 437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 437 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | 438 | } |
| 439 | - unset($vals); |
|
| 439 | + unset( $vals ); |
|
| 440 | 440 | } |
| 441 | - unset($opt_key, $opt); |
|
| 441 | + unset( $opt_key, $opt ); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | $other_array = array(); |
| 448 | 448 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 449 | 449 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 450 | - $other_array[ $opt_key ] = $opt; |
|
| 450 | + $other_array[$opt_key] = $opt; |
|
| 451 | 451 | } |
| 452 | - unset($opt_key, $opt); |
|
| 452 | + unset( $opt_key, $opt ); |
|
| 453 | 453 | } |
| 454 | - if ( ! empty($other_array) ) { |
|
| 455 | - $opts = array_merge( $opts, $other_array); |
|
| 454 | + if ( ! empty( $other_array ) ) { |
|
| 455 | + $opts = array_merge( $opts, $other_array ); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -467,14 +467,14 @@ discard block |
||
| 467 | 467 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 468 | 468 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 469 | 469 | } else { |
| 470 | - FrmFieldsHelper::show_single_option($field); |
|
| 470 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | wp_die(); |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | public static function update_order() { |
| 477 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 477 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 478 | 478 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 479 | 479 | |
| 480 | 480 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -491,13 +491,13 @@ discard block |
||
| 491 | 491 | 'rte' => 'textarea', |
| 492 | 492 | 'website' => 'url', |
| 493 | 493 | ); |
| 494 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 495 | - $type = $type_switch[ $type ]; |
|
| 494 | + if ( isset( $type_switch[$type] ) ) { |
|
| 495 | + $type = $type_switch[$type]; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | $frm_field_selection = FrmField::field_selection(); |
| 499 | - $types = array_keys($frm_field_selection); |
|
| 500 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 499 | + $types = array_keys( $frm_field_selection ); |
|
| 500 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
| 501 | 501 | $type = 'text'; |
| 502 | 502 | } |
| 503 | 503 | |
@@ -536,19 +536,19 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | public static function input_html( $field, $echo = true ) { |
| 538 | 538 | $class = array(); //$field['type']; |
| 539 | - self::add_input_classes($field, $class); |
|
| 539 | + self::add_input_classes( $field, $class ); |
|
| 540 | 540 | |
| 541 | 541 | $add_html = array(); |
| 542 | - self::add_html_size($field, $add_html); |
|
| 543 | - self::add_html_length($field, $add_html); |
|
| 544 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 542 | + self::add_html_size( $field, $add_html ); |
|
| 543 | + self::add_html_length( $field, $add_html ); |
|
| 544 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 545 | 545 | self::add_validation_messages( $field, $add_html ); |
| 546 | 546 | |
| 547 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 547 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 548 | 548 | |
| 549 | 549 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 550 | 550 | |
| 551 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 551 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 552 | 552 | |
| 553 | 553 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 554 | 554 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | private static function add_input_classes( $field, array &$class ) { |
| 564 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 564 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 565 | 565 | $class[] = $field['input_class']; |
| 566 | 566 | } |
| 567 | 567 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | $class[] = 'dyn_default_value'; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 577 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 578 | 578 | $class[] = 'auto_width'; |
| 579 | 579 | } |
| 580 | 580 | } |
@@ -584,19 +584,19 @@ discard block |
||
| 584 | 584 | return; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 587 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 588 | 588 | return; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - if ( is_numeric($field['size']) ) { |
|
| 591 | + if ( is_numeric( $field['size'] ) ) { |
|
| 592 | 592 | $field['size'] .= 'px'; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 595 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 596 | 596 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 597 | 597 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 598 | 598 | |
| 599 | - self::add_html_cols($field, $add_html); |
|
| 599 | + self::add_html_cols( $field, $add_html ); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -613,13 +613,13 @@ discard block |
||
| 613 | 613 | ); |
| 614 | 614 | |
| 615 | 615 | // include "col" for valid html |
| 616 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 616 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 617 | 617 | |
| 618 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 618 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 619 | 619 | return; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 622 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 623 | 623 | |
| 624 | 624 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 625 | 625 | } |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | return; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 633 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 634 | 634 | // don't load on form builder page |
| 635 | 635 | return; |
| 636 | 636 | } |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 663 | 663 | // use HMTL5 placeholder with js fallback |
| 664 | 664 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 665 | - wp_enqueue_script('jquery-placeholder'); |
|
| 665 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 666 | 666 | } else if ( ! $frm_settings->use_html ) { |
| 667 | 667 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 668 | 668 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | $format = FrmEntryValidate::phone_format( $field ); |
| 690 | 690 | $format = substr( $format, 2, -2 ); |
| 691 | 691 | $key = 'pattern'; |
| 692 | - $add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 692 | + $add_html[$key] = $key . '="' . esc_attr( $format ) . '"'; |
|
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | |
@@ -703,15 +703,15 @@ discard block |
||
| 703 | 703 | continue; |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 706 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 707 | 707 | $add_html[] = $v; |
| 708 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 709 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 708 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 709 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 710 | 710 | } else { |
| 711 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 711 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - unset($k, $v); |
|
| 714 | + unset( $k, $v ); |
|
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | |
@@ -727,8 +727,8 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | public static function check_label( $opt ) { |
| 730 | - if ( is_array($opt) ) { |
|
| 731 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 730 | + if ( is_array( $opt ) ) { |
|
| 731 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | return $opt; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $keyed_addons = array(); |
| 41 | 41 | foreach ( $addons as $addon ) { |
| 42 | - $keyed_addons[ $addon['info']['slug'] ] = $addon; |
|
| 42 | + $keyed_addons[$addon['info']['slug']] = $addon; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $plugin_order = array( |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | ); |
| 50 | 50 | $ordered_addons = array(); |
| 51 | 51 | foreach ( $plugin_order as $plugin ) { |
| 52 | - if ( isset( $keyed_addons[ $plugin ] ) ) { |
|
| 53 | - $ordered_addons[] = $keyed_addons[ $plugin ]; |
|
| 54 | - unset( $keyed_addons[ $plugin ] ); |
|
| 52 | + if ( isset( $keyed_addons[$plugin] ) ) { |
|
| 53 | + $ordered_addons[] = $keyed_addons[$plugin]; |
|
| 54 | + unset( $keyed_addons[$plugin] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | $addons = $ordered_addons + $keyed_addons; |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public static function get_licenses() { |
| 89 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 89 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 90 | 90 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 91 | 91 | |
| 92 | - $license = get_option('frmpro-credentials'); |
|
| 92 | + $license = get_option( 'frmpro-credentials' ); |
|
| 93 | 93 | if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
| 94 | 94 | $url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
| 95 | 95 | $licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) ); |
@@ -2,110 +2,110 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmXMLController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' ); |
| 7 | - } |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public static function add_default_templates() { |
|
| 9 | + public static function add_default_templates() { |
|
| 10 | 10 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 11 | - // XML import is not enabled on your server |
|
| 12 | - return; |
|
| 13 | - } |
|
| 11 | + // XML import is not enabled on your server |
|
| 12 | + return; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 16 | - $loader = libxml_disable_entity_loader( true ); |
|
| 15 | + $set_err = libxml_use_internal_errors(true); |
|
| 16 | + $loader = libxml_disable_entity_loader( true ); |
|
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | - foreach ( (array) $files as $file ) { |
|
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 23 | - } |
|
| 24 | - /* |
|
| 20 | + foreach ( (array) $files as $file ) { |
|
| 21 | + FrmXMLHelper::import_xml($file); |
|
| 22 | + unset($file); |
|
| 23 | + } |
|
| 24 | + /* |
|
| 25 | 25 | if(is_wp_error($result)) |
| 26 | 26 | $errors[] = $result->get_error_message(); |
| 27 | 27 | else if($result) |
| 28 | 28 | $message = $result; |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | - unset( $files ); |
|
| 31 | + unset( $files ); |
|
| 32 | 32 | |
| 33 | - libxml_use_internal_errors( $set_err ); |
|
| 34 | - libxml_disable_entity_loader( $loader ); |
|
| 35 | - } |
|
| 33 | + libxml_use_internal_errors( $set_err ); |
|
| 34 | + libxml_disable_entity_loader( $loader ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function route() { |
|
| 38 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 37 | + public static function route() { |
|
| 38 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 39 | 39 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 40 | 40 | if ( $action == 'import_xml' ) { |
| 41 | - return self::import_xml(); |
|
| 41 | + return self::import_xml(); |
|
| 42 | 42 | } else if ( $action == 'export_xml' ) { |
| 43 | - return self::export_xml(); |
|
| 44 | - } else { |
|
| 45 | - if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | - return self::form(); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public static function form( $errors = array(), $message = '' ) { |
|
| 43 | + return self::export_xml(); |
|
| 44 | + } else { |
|
| 45 | + if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | + return self::form(); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public static function form( $errors = array(), $message = '' ) { |
|
| 52 | 52 | $where = array( |
| 53 | 53 | 'parent_form_id' => array( null, 0 ), |
| 54 | 54 | 'status' => array( null, '', 'published' ), |
| 55 | 55 | ); |
| 56 | 56 | $forms = FrmForm::getAll( $where, 'name' ); |
| 57 | 57 | |
| 58 | - $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | - array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | - ); |
|
| 58 | + $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | + array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | - $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | - 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 62 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | + 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 64 | 64 | 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ), |
| 65 | - ) ); |
|
| 65 | + ) ); |
|
| 66 | 66 | |
| 67 | 67 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' ); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public static function import_xml() { |
|
| 71 | - $errors = array(); |
|
| 72 | - $message = ''; |
|
| 70 | + public static function import_xml() { |
|
| 71 | + $errors = array(); |
|
| 72 | + $message = ''; |
|
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | - if ( $permission_error !== false ) { |
|
| 76 | - $errors[] = $permission_error; |
|
| 77 | - self::form($errors); |
|
| 78 | - return; |
|
| 79 | - } |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | + if ( $permission_error !== false ) { |
|
| 76 | + $errors[] = $permission_error; |
|
| 77 | + self::form($errors); |
|
| 78 | + return; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | - $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | - self::form($errors); |
|
| 84 | - return; |
|
| 85 | - } |
|
| 81 | + if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | + $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | + self::form($errors); |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 87 | + $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 88 | 88 | |
| 89 | - if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | - unset($file); |
|
| 91 | - $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | - self::form($errors); |
|
| 93 | - return; |
|
| 94 | - } |
|
| 89 | + if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | + unset($file); |
|
| 91 | + $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | + self::form($errors); |
|
| 93 | + return; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 96 | + //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters('frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | - // allow other file types to be imported |
|
| 102 | + $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | + // allow other file types to be imported |
|
| 105 | 105 | do_action( 'frm_before_import_' . $file_type ); |
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - unset($file_type); |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + unset($file_type); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,148 +124,148 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 128 | - } |
|
| 127 | + self::form($errors, $message); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - public static function export_xml() { |
|
| 131 | - $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | - if ( ! empty($error) ) { |
|
| 133 | - wp_die( $error ); |
|
| 134 | - } |
|
| 130 | + public static function export_xml() { |
|
| 131 | + $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | + if ( ! empty($error) ) { |
|
| 133 | + wp_die( $error ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | $ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() ); |
| 137 | 137 | $type = FrmAppHelper::get_post_param( 'type', array() ); |
| 138 | 138 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
| 139 | 139 | |
| 140 | - if ( ! headers_sent() && ! $type ) { |
|
| 141 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | - die(); |
|
| 143 | - } |
|
| 140 | + if ( ! headers_sent() && ! $type ) { |
|
| 141 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | + die(); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ( $format == 'xml' ) { |
|
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 145 | + if ( $format == 'xml' ) { |
|
| 146 | + self::generate_xml($type, compact('ids')); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | 148 | self::generate_csv( compact('ids') ); |
| 149 | - } else { |
|
| 149 | + } else { |
|
| 150 | 150 | do_action( 'frm_export_format_' . $format, compact('ids') ); |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - wp_die(); |
|
| 154 | - } |
|
| 153 | + wp_die(); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | public static function generate_xml( $type, $args = array() ) { |
| 157 | - global $wpdb; |
|
| 157 | + global $wpdb; |
|
| 158 | 158 | |
| 159 | - $type = (array) $type; |
|
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | - // make sure the form is included if there are entries |
|
| 162 | - $type[] = 'forms'; |
|
| 163 | - } |
|
| 159 | + $type = (array) $type; |
|
| 160 | + if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | + // make sure the form is included if there are entries |
|
| 162 | + $type[] = 'forms'; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 166 | - // include actions with forms |
|
| 167 | - $type[] = 'actions'; |
|
| 168 | - } |
|
| 165 | + if ( in_array( 'forms', $type) ) { |
|
| 166 | + // include actions with forms |
|
| 167 | + $type[] = 'actions'; |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - $tables = array( |
|
| 170 | + $tables = array( |
|
| 171 | 171 | 'items' => $wpdb->prefix . 'frm_items', |
| 172 | 172 | 'forms' => $wpdb->prefix . 'frm_forms', |
| 173 | - 'posts' => $wpdb->posts, |
|
| 174 | - 'styles' => $wpdb->posts, |
|
| 175 | - 'actions' => $wpdb->posts, |
|
| 176 | - ); |
|
| 173 | + 'posts' => $wpdb->posts, |
|
| 174 | + 'styles' => $wpdb->posts, |
|
| 175 | + 'actions' => $wpdb->posts, |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | 178 | $defaults = array( 'ids' => false ); |
| 179 | - $args = wp_parse_args( $args, $defaults ); |
|
| 179 | + $args = wp_parse_args( $args, $defaults ); |
|
| 180 | 180 | |
| 181 | - $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 181 | + $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 182 | 182 | |
| 183 | - if ( ! empty( $sitename ) ) { |
|
| 183 | + if ( ! empty( $sitename ) ) { |
|
| 184 | 184 | $sitename .= '.'; |
| 185 | 185 | } |
| 186 | - $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 186 | + $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 187 | 187 | |
| 188 | - header( 'Content-Description: File Transfer' ); |
|
| 189 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | - header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 188 | + header( 'Content-Description: File Transfer' ); |
|
| 189 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 191 | 191 | |
| 192 | - //make sure ids are numeric |
|
| 193 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | - $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | - } |
|
| 192 | + //make sure ids are numeric |
|
| 193 | + if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | + $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $records = array(); |
|
| 197 | + $records = array(); |
|
| 198 | 198 | |
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | - $where = array(); |
|
| 200 | + $where = array(); |
|
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[ $tb_type ]; |
|
| 203 | 203 | |
| 204 | 204 | $select = $table . '.id'; |
| 205 | - $query_vars = array(); |
|
| 205 | + $query_vars = array(); |
|
| 206 | 206 | |
| 207 | - switch ( $tb_type ) { |
|
| 208 | - case 'forms': |
|
| 209 | - //add forms |
|
| 210 | - if ( $args['ids'] ) { |
|
| 207 | + switch ( $tb_type ) { |
|
| 208 | + case 'forms': |
|
| 209 | + //add forms |
|
| 210 | + if ( $args['ids'] ) { |
|
| 211 | 211 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 212 | - } else { |
|
| 212 | + } else { |
|
| 213 | 213 | $where[ $table . '.status !' ] = 'draft'; |
| 214 | - } |
|
| 215 | - break; |
|
| 216 | - case 'actions': |
|
| 214 | + } |
|
| 215 | + break; |
|
| 216 | + case 'actions': |
|
| 217 | 217 | $select = $table . '.ID'; |
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty($args['ids']) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | - } |
|
| 222 | - break; |
|
| 223 | - case 'items': |
|
| 224 | - //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | - if ( $args['ids'] ) { |
|
| 221 | + } |
|
| 222 | + break; |
|
| 223 | + case 'items': |
|
| 224 | + //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | + if ( $args['ids'] ) { |
|
| 226 | 226 | $where[ $table . '.form_id' ] = $args['ids']; |
| 227 | - } |
|
| 228 | - break; |
|
| 229 | - case 'styles': |
|
| 230 | - // Loop through all exported forms and get their selected style IDs |
|
| 231 | - $form_ids = $args['ids']; |
|
| 232 | - $style_ids = array(); |
|
| 233 | - foreach ( $form_ids as $form_id ) { |
|
| 234 | - $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | - // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | - if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | - $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | - } |
|
| 239 | - unset( $form_id, $form_data ); |
|
| 240 | - } |
|
| 227 | + } |
|
| 228 | + break; |
|
| 229 | + case 'styles': |
|
| 230 | + // Loop through all exported forms and get their selected style IDs |
|
| 231 | + $form_ids = $args['ids']; |
|
| 232 | + $style_ids = array(); |
|
| 233 | + foreach ( $form_ids as $form_id ) { |
|
| 234 | + $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | + // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | + if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | + $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | + } |
|
| 239 | + unset( $form_id, $form_data ); |
|
| 240 | + } |
|
| 241 | 241 | $select = $table . '.ID'; |
| 242 | - $where['post_type'] = 'frm_styles'; |
|
| 243 | - |
|
| 244 | - // Only export selected styles |
|
| 245 | - if ( ! empty( $style_ids ) ) { |
|
| 246 | - $where['ID'] = $style_ids; |
|
| 247 | - } |
|
| 248 | - break; |
|
| 249 | - default: |
|
| 242 | + $where['post_type'] = 'frm_styles'; |
|
| 243 | + |
|
| 244 | + // Only export selected styles |
|
| 245 | + if ( ! empty( $style_ids ) ) { |
|
| 246 | + $where['ID'] = $style_ids; |
|
| 247 | + } |
|
| 248 | + break; |
|
| 249 | + default: |
|
| 250 | 250 | $select = $table . '.ID'; |
| 251 | - $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | - $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | - |
|
| 254 | - if ( empty($args['ids']) ) { |
|
| 255 | - $where['pm.meta_value >'] = 1; |
|
| 256 | - } else { |
|
| 257 | - $where['pm.meta_value'] = $args['ids']; |
|
| 258 | - } |
|
| 259 | - break; |
|
| 260 | - } |
|
| 251 | + $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | + $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | + |
|
| 254 | + if ( empty($args['ids']) ) { |
|
| 255 | + $where['pm.meta_value >'] = 1; |
|
| 256 | + } else { |
|
| 257 | + $where['pm.meta_value'] = $args['ids']; |
|
| 258 | + } |
|
| 259 | + break; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
| 263 | - unset($tb_type); |
|
| 264 | - } |
|
| 263 | + unset($tb_type); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
| 267 | 267 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 268 | - } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | public static function generate_csv( $atts ) { |
@@ -336,14 +336,14 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Get the fields that should be included in the CSV export |
|
| 340 | - * |
|
| 341 | - * @since 2.0.19 |
|
| 342 | - * |
|
| 343 | - * @param int $form_id |
|
| 344 | - * @param object $form |
|
| 345 | - * @return array $csv_fields |
|
| 346 | - */ |
|
| 339 | + * Get the fields that should be included in the CSV export |
|
| 340 | + * |
|
| 341 | + * @since 2.0.19 |
|
| 342 | + * |
|
| 343 | + * @param int $form_id |
|
| 344 | + * @param object $form |
|
| 345 | + * @return array $csv_fields |
|
| 346 | + */ |
|
| 347 | 347 | private static function get_fields_for_csv_export( $form_id, $form ) { |
| 348 | 348 | // Phase frm_csv_field_ids out by 2.01.05 |
| 349 | 349 | $csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) ); |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | public static function allow_mime( $mimes ) { |
| 376 | - if ( ! isset( $mimes['csv'] ) ) { |
|
| 377 | - // allow csv files |
|
| 378 | - $mimes['csv'] = 'text/csv'; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - if ( ! isset( $mimes['xml'] ) ) { |
|
| 382 | - // allow xml |
|
| 383 | - $mimes['xml'] = 'text/xml'; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - return $mimes; |
|
| 387 | - } |
|
| 376 | + if ( ! isset( $mimes['csv'] ) ) { |
|
| 377 | + // allow csv files |
|
| 378 | + $mimes['csv'] = 'text/csv'; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + if ( ! isset( $mimes['xml'] ) ) { |
|
| 382 | + // allow xml |
|
| 383 | + $mimes['xml'] = 'text/xml'; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + return $mimes; |
|
| 387 | + } |
|
| 388 | 388 | } |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 15 | + $set_err = libxml_use_internal_errors( true ); |
|
| 16 | 16 | $loader = libxml_disable_entity_loader( true ); |
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | 20 | foreach ( (array) $files as $file ) { |
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 21 | + FrmXMLHelper::import_xml( $file ); |
|
| 22 | + unset( $file ); |
|
| 23 | 23 | } |
| 24 | 24 | /* |
| 25 | 25 | if(is_wp_error($result)) |
@@ -71,41 +71,41 @@ discard block |
||
| 71 | 71 | $errors = array(); |
| 72 | 72 | $message = ''; |
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); |
|
| 75 | 75 | if ( $permission_error !== false ) { |
| 76 | 76 | $errors[] = $permission_error; |
| 77 | - self::form($errors); |
|
| 77 | + self::form( $errors ); |
|
| 78 | 78 | return; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | + if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | 82 | $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
| 83 | - self::form($errors); |
|
| 83 | + self::form( $errors ); |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $file = $_FILES['frm_import_file']['tmp_name']; |
| 88 | 88 | |
| 89 | 89 | if ( ! is_uploaded_file( $file ) ) { |
| 90 | - unset($file); |
|
| 90 | + unset( $file ); |
|
| 91 | 91 | $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
| 92 | - self::form($errors); |
|
| 92 | + self::form( $errors ); |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 102 | + $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) { |
|
| 104 | 104 | // allow other file types to be imported |
| 105 | 105 | do_action( 'frm_before_import_' . $file_type ); |
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | - unset($file_type); |
|
| 108 | + unset( $file_type ); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 127 | + self::form( $errors, $message ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public static function export_xml() { |
| 131 | 131 | $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
| 132 | - if ( ! empty($error) ) { |
|
| 132 | + if ( ! empty( $error ) ) { |
|
| 133 | 133 | wp_die( $error ); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if ( $format == 'xml' ) { |
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 146 | + self::generate_xml( $type, compact( 'ids' ) ); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | - self::generate_csv( compact('ids') ); |
|
| 148 | + self::generate_csv( compact( 'ids' ) ); |
|
| 149 | 149 | } else { |
| 150 | - do_action( 'frm_export_format_' . $format, compact('ids') ); |
|
| 150 | + do_action( 'frm_export_format_' . $format, compact( 'ids' ) ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | wp_die(); |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | global $wpdb; |
| 158 | 158 | |
| 159 | 159 | $type = (array) $type; |
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 160 | + if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) { |
|
| 161 | 161 | // make sure the form is included if there are entries |
| 162 | 162 | $type[] = 'forms'; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 165 | + if ( in_array( 'forms', $type ) ) { |
|
| 166 | 166 | // include actions with forms |
| 167 | 167 | $type[] = 'actions'; |
| 168 | 168 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | 200 | $where = array(); |
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[$tb_type]; |
|
| 203 | 203 | |
| 204 | 204 | $select = $table . '.id'; |
| 205 | 205 | $query_vars = array(); |
@@ -210,20 +210,20 @@ discard block |
||
| 210 | 210 | if ( $args['ids'] ) { |
| 211 | 211 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 212 | 212 | } else { |
| 213 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 213 | + $where[$table . '.status !'] = 'draft'; |
|
| 214 | 214 | } |
| 215 | 215 | break; |
| 216 | 216 | case 'actions': |
| 217 | 217 | $select = $table . '.ID'; |
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty( $args['ids'] ) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | 221 | } |
| 222 | 222 | break; |
| 223 | 223 | case 'items': |
| 224 | 224 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 225 | 225 | if ( $args['ids'] ) { |
| 226 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 226 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 227 | 227 | } |
| 228 | 228 | break; |
| 229 | 229 | case 'styles': |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
| 252 | 252 | $where['pm.meta_key'] = 'frm_form_id'; |
| 253 | 253 | |
| 254 | - if ( empty($args['ids']) ) { |
|
| 254 | + if ( empty( $args['ids'] ) ) { |
|
| 255 | 255 | $where['pm.meta_value >'] = 1; |
| 256 | 256 | } else { |
| 257 | 257 | $where['pm.meta_value'] = $args['ids']; |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | - unset($tb_type); |
|
| 262 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | + unset( $tb_type ); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
|
| 266 | + echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n"; |
|
| 267 | 267 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( ! ini_get('safe_mode') ) { |
|
| 293 | - set_time_limit(0); //Remove time limit to execute this function |
|
| 294 | - $mem_limit = str_replace('M', '', ini_get('memory_limit')); |
|
| 292 | + if ( ! ini_get( 'safe_mode' ) ) { |
|
| 293 | + set_time_limit( 0 ); //Remove time limit to execute this function |
|
| 294 | + $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) ); |
|
| 295 | 295 | if ( (int) $mem_limit < 256 ) { |
| 296 | - ini_set('memory_limit', '256M'); |
|
| 296 | + ini_set( 'memory_limit', '256M' ); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | $no_export_fields = FrmField::no_save_fields(); |
| 365 | 365 | foreach ( $csv_fields as $k => $f ) { |
| 366 | 366 | if ( in_array( $f->type, $no_export_fields ) ) { |
| 367 | - unset( $csv_fields[ $k ] ); |
|
| 367 | + unset( $csv_fields[$k] ); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | } |
@@ -1,109 +1,109 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 6 | - |
|
| 7 | - public static function register_post_types() { |
|
| 8 | - register_post_type( self::$action_post_type, array( |
|
| 9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | - 'description' => '', |
|
| 11 | - 'public' => false, |
|
| 12 | - 'show_ui' => false, |
|
| 13 | - 'exclude_from_search' => true, |
|
| 14 | - 'show_in_nav_menus' => false, |
|
| 15 | - 'show_in_menu' => true, |
|
| 16 | - 'capability_type' => 'page', |
|
| 17 | - 'supports' => array( |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | + |
|
| 7 | + public static function register_post_types() { |
|
| 8 | + register_post_type( self::$action_post_type, array( |
|
| 9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | + 'description' => '', |
|
| 11 | + 'public' => false, |
|
| 12 | + 'show_ui' => false, |
|
| 13 | + 'exclude_from_search' => true, |
|
| 14 | + 'show_in_nav_menus' => false, |
|
| 15 | + 'show_in_menu' => true, |
|
| 16 | + 'capability_type' => 'page', |
|
| 17 | + 'supports' => array( |
|
| 18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
| 19 | 19 | 'page-attributes', |
| 20 | - ), |
|
| 21 | - 'has_archive' => false, |
|
| 22 | - ) ); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * post_content: json settings |
|
| 26 | - * menu_order: form id |
|
| 27 | - * post_excerpt: action type |
|
| 28 | - */ |
|
| 29 | - |
|
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public static function register_actions() { |
|
| 40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'highrise' => 'FrmDefHrsAction', |
|
| 49 | - ) ); |
|
| 50 | - |
|
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | - |
|
| 54 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | - self::$registered_actions->register($action_class); |
|
| 56 | - } |
|
| 57 | - } |
|
| 20 | + ), |
|
| 21 | + 'has_archive' => false, |
|
| 22 | + ) ); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * post_content: json settings |
|
| 26 | + * menu_order: form id |
|
| 27 | + * post_excerpt: action type |
|
| 28 | + */ |
|
| 29 | + |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public static function register_actions() { |
|
| 40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'highrise' => 'FrmDefHrsAction', |
|
| 49 | + ) ); |
|
| 50 | + |
|
| 51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | + |
|
| 54 | + foreach ( $action_classes as $action_class ) { |
|
| 55 | + self::$registered_actions->register($action_class); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | - $temp_actions = self::$registered_actions; |
|
| 61 | - if ( empty($temp_actions) ) { |
|
| 62 | - self::actions_init(); |
|
| 63 | - $temp_actions = self::$registered_actions->actions; |
|
| 64 | - } else { |
|
| 65 | - $temp_actions = $temp_actions->actions; |
|
| 66 | - } |
|
| 60 | + $temp_actions = self::$registered_actions; |
|
| 61 | + if ( empty($temp_actions) ) { |
|
| 62 | + self::actions_init(); |
|
| 63 | + $temp_actions = self::$registered_actions->actions; |
|
| 64 | + } else { |
|
| 65 | + $temp_actions = $temp_actions->actions; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $actions = array(); |
|
| 68 | + $actions = array(); |
|
| 69 | 69 | |
| 70 | - foreach ( $temp_actions as $a ) { |
|
| 71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | - return $a; |
|
| 73 | - } |
|
| 70 | + foreach ( $temp_actions as $a ) { |
|
| 71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | + return $a; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | $actions[ $a->id_base ] = $a; |
| 76 | - } |
|
| 77 | - unset( $temp_actions, $a ); |
|
| 78 | - |
|
| 79 | - $action_limit = 10; |
|
| 80 | - if ( count( $actions ) <= $action_limit ) { |
|
| 81 | - return $actions; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // remove the last few inactive icons if there are too many |
|
| 85 | - $temp_actions = $actions; |
|
| 86 | - arsort( $temp_actions ); |
|
| 87 | - foreach ( $temp_actions as $type => $a ) { |
|
| 88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 76 | + } |
|
| 77 | + unset( $temp_actions, $a ); |
|
| 78 | + |
|
| 79 | + $action_limit = 10; |
|
| 80 | + if ( count( $actions ) <= $action_limit ) { |
|
| 81 | + return $actions; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // remove the last few inactive icons if there are too many |
|
| 85 | + $temp_actions = $actions; |
|
| 86 | + arsort( $temp_actions ); |
|
| 87 | + foreach ( $temp_actions as $type => $a ) { |
|
| 88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 89 | 89 | unset( $actions[ $type ] ); |
| 90 | - if ( count( $actions ) <= $action_limit ) { |
|
| 91 | - break; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - unset( $type, $a ); |
|
| 95 | - } |
|
| 90 | + if ( count( $actions ) <= $action_limit ) { |
|
| 91 | + break; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + unset( $type, $a ); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $actions; |
|
| 98 | - } |
|
| 97 | + return $actions; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @since 2.0 |
| 102 | 102 | */ |
| 103 | - public static function list_actions( $form, $values ) { |
|
| 104 | - if ( empty( $form ) ) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 103 | + public static function list_actions( $form, $values ) { |
|
| 104 | + if ( empty( $form ) ) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
| 115 | 115 | |
| 116 | - $action_controls = self::get_form_actions(); |
|
| 116 | + $action_controls = self::get_form_actions(); |
|
| 117 | 117 | |
| 118 | - $action_map = array(); |
|
| 118 | + $action_map = array(); |
|
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 122 | - } |
|
| 121 | + $action_map[ $control->id_base ] = $key; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - foreach ( $form_actions as $action ) { |
|
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | - // don't try and show settings if action no longer exists |
|
| 127 | - continue; |
|
| 128 | - } |
|
| 124 | + foreach ( $form_actions as $action ) { |
|
| 125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | + // don't try and show settings if action no longer exists |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 135 | + $action_control->_set($action_key); |
|
| 136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public static function add_form_action() { |
|
| 139 | + public static function add_form_action() { |
|
| 140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 142 | 142 | |
| 143 | - global $frm_vars; |
|
| 143 | + global $frm_vars; |
|
| 144 | 144 | |
| 145 | 145 | $action_key = absint( $_POST['list_id'] ); |
| 146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 147 | 147 | |
| 148 | - $action_control = self::get_form_actions( $action_type ); |
|
| 149 | - $action_control->_set($action_key); |
|
| 148 | + $action_control = self::get_form_actions( $action_type ); |
|
| 149 | + $action_control->_set($action_key); |
|
| 150 | 150 | |
| 151 | - $form_id = absint( $_POST['form_id'] ); |
|
| 151 | + $form_id = absint( $_POST['form_id'] ); |
|
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new($form_id); |
|
| 154 | 154 | |
| 155 | - $values = array(); |
|
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 155 | + $values = array(); |
|
| 156 | + $form = self::fields_to_values($form_id, $values); |
|
| 157 | 157 | |
| 158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 159 | - wp_die(); |
|
| 160 | - } |
|
| 159 | + wp_die(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public static function fill_action() { |
|
| 162 | + public static function fill_action() { |
|
| 163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 165 | 165 | |
| 166 | - $action_key = absint( $_POST['action_id'] ); |
|
| 167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 166 | + $action_key = absint( $_POST['action_id'] ); |
|
| 167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 168 | 168 | |
| 169 | - $action_control = self::get_form_actions( $action_type ); |
|
| 170 | - if ( empty($action_control) ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 169 | + $action_control = self::get_form_actions( $action_type ); |
|
| 170 | + if ( empty($action_control) ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 175 | 175 | |
| 176 | - $values = array(); |
|
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 176 | + $values = array(); |
|
| 177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 178 | 178 | |
| 179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 180 | - wp_die(); |
|
| 181 | - } |
|
| 180 | + wp_die(); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne($form_id); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | - foreach ( $fields as $k => $f ) { |
|
| 190 | - $f = (array) $f; |
|
| 191 | - $opts = (array) $f['field_options']; |
|
| 192 | - $f = array_merge($opts, $f); |
|
| 193 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | - $f['post_field'] = ''; |
|
| 195 | - } |
|
| 196 | - $values['fields'][] = $f; |
|
| 197 | - unset($k, $f); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $form; |
|
| 201 | - } |
|
| 188 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | + foreach ( $fields as $k => $f ) { |
|
| 190 | + $f = (array) $f; |
|
| 191 | + $opts = (array) $f['field_options']; |
|
| 192 | + $f = array_merge($opts, $f); |
|
| 193 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | + $f['post_field'] = ''; |
|
| 195 | + } |
|
| 196 | + $values['fields'][] = $f; |
|
| 197 | + unset($k, $f); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $form; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | public static function update_settings( $form_id ) { |
| 204 | - global $wpdb; |
|
| 204 | + global $wpdb; |
|
| 205 | 205 | |
| 206 | - $registered_actions = self::$registered_actions->actions; |
|
| 206 | + $registered_actions = self::$registered_actions->actions; |
|
| 207 | 207 | |
| 208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
| 209 | - $new_actions = array(); |
|
| 209 | + $new_actions = array(); |
|
| 210 | 210 | |
| 211 | - foreach ( $registered_actions as $registered_action ) { |
|
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | - if ( ! empty( $action_ids ) ) { |
|
| 214 | - $new_actions[] = $action_ids; |
|
| 215 | - } |
|
| 216 | - } |
|
| 211 | + foreach ( $registered_actions as $registered_action ) { |
|
| 212 | + $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | + if ( ! empty( $action_ids ) ) { |
|
| 214 | + $new_actions[] = $action_ids; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - //Only use array_merge if there are new actions |
|
| 219 | - if ( ! empty( $new_actions ) ) { |
|
| 220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | - } |
|
| 222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 218 | + //Only use array_merge if there are new actions |
|
| 219 | + if ( ! empty( $new_actions ) ) { |
|
| 220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | + } |
|
| 222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 223 | 223 | |
| 224 | 224 | self::delete_missing_actions( $old_actions ); |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | public static function delete_missing_actions( $old_actions ) { |
| 228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -242,36 +242,36 @@ discard block |
||
| 242 | 242 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * @param string $event |
|
| 247 | - */ |
|
| 245 | + /** |
|
| 246 | + * @param string $event |
|
| 247 | + */ |
|
| 248 | 248 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 249 | 249 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 250 | 250 | |
| 251 | 251 | if ( empty( $form_actions ) ) { |
| 252 | - return; |
|
| 253 | - } |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | FrmForm::maybe_get_form( $form ); |
| 256 | 256 | |
| 257 | - $link_settings = self::get_form_actions( $type ); |
|
| 258 | - if ( 'all' != $type ) { |
|
| 259 | - $link_settings = array( $type => $link_settings ); |
|
| 260 | - } |
|
| 257 | + $link_settings = self::get_form_actions( $type ); |
|
| 258 | + if ( 'all' != $type ) { |
|
| 259 | + $link_settings = array( $type => $link_settings ); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - $stored_actions = $action_priority = array(); |
|
| 262 | + $stored_actions = $action_priority = array(); |
|
| 263 | 263 | |
| 264 | 264 | $importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING; |
| 265 | 265 | |
| 266 | - foreach ( $form_actions as $action ) { |
|
| 266 | + foreach ( $form_actions as $action ) { |
|
| 267 | 267 | $trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] ); |
| 268 | 268 | if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) { |
| 269 | - continue; |
|
| 270 | - } |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - if ( ! is_object( $entry ) ) { |
|
| 273 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 274 | - } |
|
| 272 | + if ( ! is_object( $entry ) ) { |
|
| 273 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
| 277 | 277 | continue; |
@@ -280,66 +280,66 @@ discard block |
||
| 280 | 280 | $child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) ); |
| 281 | 281 | |
| 282 | 282 | if ( $child_entry ) { |
| 283 | - //don't trigger actions for sub forms |
|
| 284 | - continue; |
|
| 285 | - } |
|
| 283 | + //don't trigger actions for sub forms |
|
| 284 | + continue; |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - // check conditional logic |
|
| 287 | + // check conditional logic |
|
| 288 | 288 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 289 | - if ( $stop ) { |
|
| 290 | - continue; |
|
| 291 | - } |
|
| 289 | + if ( $stop ) { |
|
| 290 | + continue; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - // store actions so they can be triggered with the correct priority |
|
| 294 | - $stored_actions[ $action->ID ] = $action; |
|
| 295 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 293 | + // store actions so they can be triggered with the correct priority |
|
| 294 | + $stored_actions[ $action->ID ] = $action; |
|
| 295 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 296 | 296 | |
| 297 | - unset($action); |
|
| 298 | - } |
|
| 297 | + unset($action); |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - if ( ! empty( $stored_actions ) ) { |
|
| 301 | - asort($action_priority); |
|
| 300 | + if ( ! empty( $stored_actions ) ) { |
|
| 301 | + asort($action_priority); |
|
| 302 | 302 | |
| 303 | - // make sure hooks are loaded |
|
| 304 | - new FrmNotification(); |
|
| 303 | + // make sure hooks are loaded |
|
| 304 | + new FrmNotification(); |
|
| 305 | 305 | |
| 306 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 307 | - $action = $stored_actions[ $action_id ]; |
|
| 306 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 307 | + $action = $stored_actions[ $action_id ]; |
|
| 308 | 308 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 309 | 309 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 310 | 310 | |
| 311 | - // If post is created, get updated $entry object |
|
| 312 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 313 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 311 | + // If post is created, get updated $entry object |
|
| 312 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 313 | + $entry = FrmEntry::getOne($entry->id, true); |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | 319 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 320 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 321 | - // continue if we know which actions to copy |
|
| 322 | - return; |
|
| 323 | - } |
|
| 320 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 321 | + // continue if we know which actions to copy |
|
| 322 | + return; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - $action_controls = self::get_form_actions( ); |
|
| 325 | + $action_controls = self::get_form_actions( ); |
|
| 326 | 326 | |
| 327 | - foreach ( $action_controls as $action_control ) { |
|
| 328 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 329 | - unset( $action_control ); |
|
| 330 | - } |
|
| 331 | - } |
|
| 327 | + foreach ( $action_controls as $action_control ) { |
|
| 328 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 329 | + unset( $action_control ); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - public static function limit_by_type( $where ) { |
|
| 334 | - global $frm_vars, $wpdb; |
|
| 333 | + public static function limit_by_type( $where ) { |
|
| 334 | + global $frm_vars, $wpdb; |
|
| 335 | 335 | |
| 336 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 337 | - return $where; |
|
| 338 | - } |
|
| 336 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 337 | + return $where; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 341 | - return $where; |
|
| 342 | - } |
|
| 340 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 341 | + return $where; |
|
| 342 | + } |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | foreach ( $keys as $key ) { |
| 367 | 367 | // don't register new action if old action with the same id is already registered |
| 368 | 368 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 369 | - $this->actions[ $key ]->_register(); |
|
| 369 | + $this->actions[ $key ]->_register(); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | 'highrise' => 'FrmDefHrsAction', |
| 49 | 49 | ) ); |
| 50 | 50 | |
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
| 52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
| 53 | 53 | |
| 54 | 54 | foreach ( $action_classes as $action_class ) { |
| 55 | - self::$registered_actions->register($action_class); |
|
| 55 | + self::$registered_actions->register( $action_class ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | 60 | $temp_actions = self::$registered_actions; |
| 61 | - if ( empty($temp_actions) ) { |
|
| 61 | + if ( empty( $temp_actions ) ) { |
|
| 62 | 62 | self::actions_init(); |
| 63 | 63 | $temp_actions = self::$registered_actions->actions; |
| 64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | return $a; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $actions[ $a->id_base ] = $a; |
|
| 75 | + $actions[$a->id_base] = $a; |
|
| 76 | 76 | } |
| 77 | 77 | unset( $temp_actions, $a ); |
| 78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | arsort( $temp_actions ); |
| 87 | 87 | foreach ( $temp_actions as $type => $a ) { |
| 88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
| 89 | - unset( $actions[ $type ] ); |
|
| 89 | + unset( $actions[$type] ); |
|
| 90 | 90 | if ( count( $actions ) <= $action_limit ) { |
| 91 | 91 | break; |
| 92 | 92 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | $action_map = array(); |
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 121 | + $action_map[$control->id_base] = $key; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | foreach ( $form_actions as $action ) { |
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
| 126 | 126 | // don't try and show settings if action no longer exists |
| 127 | 127 | continue; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 135 | + $action_control->_set( $action_key ); |
|
| 136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | public static function add_form_action() { |
| 140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 140 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 141 | 141 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 142 | 142 | |
| 143 | 143 | global $frm_vars; |
@@ -146,55 +146,55 @@ discard block |
||
| 146 | 146 | $action_type = sanitize_text_field( $_POST['type'] ); |
| 147 | 147 | |
| 148 | 148 | $action_control = self::get_form_actions( $action_type ); |
| 149 | - $action_control->_set($action_key); |
|
| 149 | + $action_control->_set( $action_key ); |
|
| 150 | 150 | |
| 151 | 151 | $form_id = absint( $_POST['form_id'] ); |
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new( $form_id ); |
|
| 154 | 154 | |
| 155 | 155 | $values = array(); |
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 156 | + $form = self::fields_to_values( $form_id, $values ); |
|
| 157 | 157 | |
| 158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 159 | 159 | wp_die(); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public static function fill_action() { |
| 163 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 163 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 164 | 164 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 165 | 165 | |
| 166 | 166 | $action_key = absint( $_POST['action_id'] ); |
| 167 | 167 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
| 168 | 168 | |
| 169 | 169 | $action_control = self::get_form_actions( $action_type ); |
| 170 | - if ( empty($action_control) ) { |
|
| 170 | + if ( empty( $action_control ) ) { |
|
| 171 | 171 | wp_die(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $form_action = $action_control->get_single_action( $action_key ); |
| 175 | 175 | |
| 176 | 176 | $values = array(); |
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 177 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
| 178 | 178 | |
| 179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 180 | 180 | wp_die(); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne( $form_id ); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 188 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
| 189 | 189 | foreach ( $fields as $k => $f ) { |
| 190 | 190 | $f = (array) $f; |
| 191 | 191 | $opts = (array) $f['field_options']; |
| 192 | - $f = array_merge($opts, $f); |
|
| 192 | + $f = array_merge( $opts, $f ); |
|
| 193 | 193 | if ( ! isset( $f['post_field'] ) ) { |
| 194 | 194 | $f['post_field'] = ''; |
| 195 | 195 | } |
| 196 | 196 | $values['fields'][] = $f; |
| 197 | - unset($k, $f); |
|
| 197 | + unset( $k, $f ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | return $form; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $new_actions = array(); |
| 210 | 210 | |
| 211 | 211 | foreach ( $registered_actions as $registered_action ) { |
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 212 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
| 213 | 213 | if ( ! empty( $action_ids ) ) { |
| 214 | 214 | $new_actions[] = $action_ids; |
| 215 | 215 | } |
@@ -291,33 +291,33 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // store actions so they can be triggered with the correct priority |
| 294 | - $stored_actions[ $action->ID ] = $action; |
|
| 295 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 294 | + $stored_actions[$action->ID] = $action; |
|
| 295 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
| 296 | 296 | |
| 297 | - unset($action); |
|
| 297 | + unset( $action ); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if ( ! empty( $stored_actions ) ) { |
| 301 | - asort($action_priority); |
|
| 301 | + asort( $action_priority ); |
|
| 302 | 302 | |
| 303 | 303 | // make sure hooks are loaded |
| 304 | 304 | new FrmNotification(); |
| 305 | 305 | |
| 306 | 306 | foreach ( $action_priority as $action_id => $priority ) { |
| 307 | - $action = $stored_actions[ $action_id ]; |
|
| 307 | + $action = $stored_actions[$action_id]; |
|
| 308 | 308 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 309 | 309 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 310 | 310 | |
| 311 | 311 | // If post is created, get updated $entry object |
| 312 | 312 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
| 313 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 313 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 320 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 320 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
| 321 | 321 | // continue if we know which actions to copy |
| 322 | 322 | return; |
| 323 | 323 | } |
@@ -351,22 +351,22 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public function register( $action_class ) { |
| 354 | - $this->actions[ $action_class ] = new $action_class(); |
|
| 354 | + $this->actions[$action_class] = new $action_class(); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | public function unregister( $action_class ) { |
| 358 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
| 359 | - unset($this->actions[ $action_class ]); |
|
| 358 | + if ( isset( $this->actions[$action_class] ) ) { |
|
| 359 | + unset( $this->actions[$action_class] ); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | public function _register_actions() { |
| 364 | - $keys = array_keys($this->actions); |
|
| 364 | + $keys = array_keys( $this->actions ); |
|
| 365 | 365 | |
| 366 | 366 | foreach ( $keys as $key ) { |
| 367 | 367 | // don't register new action if old action with the same id is already registered |
| 368 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
| 369 | - $this->actions[ $key ]->_register(); |
|
| 368 | + if ( ! isset( $this->actions[$key] ) ) { |
|
| 369 | + $this->actions[$key]->_register(); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -23,41 +23,41 @@ |
||
| 23 | 23 | |
| 24 | 24 | global $frm_vars; |
| 25 | 25 | $frm_vars = array( |
| 26 | - 'load_css' => false, 'forms_loaded' => array(), |
|
| 27 | - 'created_entries' => array(), |
|
| 28 | - 'pro_is_authorized' => false, |
|
| 26 | + 'load_css' => false, 'forms_loaded' => array(), |
|
| 27 | + 'created_entries' => array(), |
|
| 28 | + 'pro_is_authorized' => false, |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | function frm_forms_autoloader( $class_name ) { |
| 32 | - // Only load Frm classes here |
|
| 32 | + // Only load Frm classes here |
|
| 33 | 33 | if ( ! preg_match( '/^Frm.+$/', $class_name ) ) { |
| 34 | - return; |
|
| 35 | - } |
|
| 34 | + return; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - $filepath = dirname(__FILE__); |
|
| 37 | + $filepath = dirname(__FILE__); |
|
| 38 | 38 | if ( preg_match( '/^FrmPro.+$/', $class_name ) || 'FrmUpdatesController' == $class_name ) { |
| 39 | - $filepath .= '/pro'; |
|
| 40 | - } |
|
| 41 | - $filepath .= '/classes'; |
|
| 39 | + $filepath .= '/pro'; |
|
| 40 | + } |
|
| 41 | + $filepath .= '/classes'; |
|
| 42 | 42 | |
| 43 | 43 | if ( preg_match( '/^.+Helper$/', $class_name ) ) { |
| 44 | - $filepath .= '/helpers/'; |
|
| 44 | + $filepath .= '/helpers/'; |
|
| 45 | 45 | } else if ( preg_match( '/^.+Controller$/', $class_name ) ) { |
| 46 | - $filepath .= '/controllers/'; |
|
| 47 | - } else { |
|
| 48 | - $filepath .= '/models/'; |
|
| 49 | - } |
|
| 46 | + $filepath .= '/controllers/'; |
|
| 47 | + } else { |
|
| 48 | + $filepath .= '/models/'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $filepath .= $class_name . '.php'; |
| 52 | 52 | |
| 53 | - if ( file_exists($filepath) ) { |
|
| 54 | - include($filepath); |
|
| 55 | - } |
|
| 53 | + if ( file_exists($filepath) ) { |
|
| 54 | + include($filepath); |
|
| 55 | + } |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // if __autoload is active, put it on the spl_autoload stack |
| 59 | 59 | if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) { |
| 60 | - spl_autoload_register('__autoload'); |
|
| 60 | + spl_autoload_register('__autoload'); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Add the autoloader |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $filepath = dirname(__FILE__); |
|
| 37 | + $filepath = dirname( __FILE__ ); |
|
| 38 | 38 | if ( preg_match( '/^FrmPro.+$/', $class_name ) || 'FrmUpdatesController' == $class_name ) { |
| 39 | 39 | $filepath .= '/pro'; |
| 40 | 40 | } |
@@ -50,25 +50,25 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $filepath .= $class_name . '.php'; |
| 52 | 52 | |
| 53 | - if ( file_exists($filepath) ) { |
|
| 54 | - include($filepath); |
|
| 53 | + if ( file_exists( $filepath ) ) { |
|
| 54 | + include( $filepath ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // if __autoload is active, put it on the spl_autoload stack |
| 59 | -if ( is_array(spl_autoload_functions()) && in_array( '__autoload', spl_autoload_functions()) ) { |
|
| 60 | - spl_autoload_register('__autoload'); |
|
| 59 | +if ( is_array( spl_autoload_functions() ) && in_array( '__autoload', spl_autoload_functions() ) ) { |
|
| 60 | + spl_autoload_register( '__autoload' ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Add the autoloader |
| 64 | -spl_autoload_register('frm_forms_autoloader'); |
|
| 64 | +spl_autoload_register( 'frm_forms_autoloader' ); |
|
| 65 | 65 | |
| 66 | -$frm_path = dirname(__FILE__); |
|
| 67 | -if ( file_exists($frm_path . '/pro/formidable-pro.php') ) { |
|
| 66 | +$frm_path = dirname( __FILE__ ); |
|
| 67 | +if ( file_exists( $frm_path . '/pro/formidable-pro.php' ) ) { |
|
| 68 | 68 | include( $frm_path . '/pro/formidable-pro.php' ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | FrmHooksController::trigger_load_hook(); |
| 72 | 72 | |
| 73 | 73 | include_once( $frm_path . '/deprecated.php' ); |
| 74 | -unset($frm_path); |
|
| 74 | +unset( $frm_path ); |
|
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! is_array($field['options']) ) { |
| 3 | - return; |
|
| 3 | + return; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 7 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 9 | 9 | |
| 10 | - // Get string for Other text field, if needed |
|
| 10 | + // Get string for Other text field, if needed |
|
| 11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
| 12 | 12 | |
| 13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 13 | + $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 17 | - } else { |
|
| 17 | + } else { |
|
| 18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - unset($checked, $other_val); |
|
| 21 | + unset($checked, $other_val); |
|
| 22 | 22 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! is_array($field['options']) ) { |
|
| 2 | +if ( ! is_array( $field['options'] ) ) { |
|
| 3 | 3 | return; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 7 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 8 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 9 | 9 | |
| 10 | 10 | // Get string for Other text field, if needed |
| 11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
| 12 | 12 | |
| 13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
| 13 | + $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : ''; |
|
| 14 | 14 | |
| 15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
@@ -18,5 +18,5 @@ discard block |
||
| 18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - unset($checked, $other_val); |
|
| 21 | + unset( $checked, $other_val ); |
|
| 22 | 22 | } |
@@ -3,38 +3,38 @@ discard block |
||
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:'. $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '') . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | - } else { |
|
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 14 | + } else { |
|
| 15 | + do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | 16 | <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | } else if ( $field['type'] == 'select' ) { |
| 22 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 22 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 23 | 23 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 24 | - } else { ?> |
|
| 24 | + } else { ?> |
|
| 25 | 25 | <select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php |
| 26 | 26 | echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : ''; |
| 27 | 27 | echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> > |
| 28 | 28 | <?php foreach ( $field['options'] as $opt_key => $opt ) { |
| 29 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 29 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 31 | 31 | $selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?> |
| 32 | 32 | <option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option> |
| 33 | 33 | <?php } ?> |
| 34 | 34 | </select> |
| 35 | 35 | <?php } |
| 36 | 36 | |
| 37 | - if ( $display['default_blank'] ) { ?> |
|
| 37 | + if ( $display['default_blank'] ) { ?> |
|
| 38 | 38 | <span id="frm_clear_on_focus_<?php echo esc_attr( $field['id'] ) ?>" class="frm_clear_on_focus frm-show-click"> |
| 39 | 39 | <?php FrmFieldsHelper::show_default_blank_js( $field['default_blank'] ); ?> |
| 40 | 40 | </span> |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | <?php FrmFieldsHelper::show_single_option($field); ?> |
| 51 | 51 | </ul> |
| 52 | 52 | <?php |
| 53 | - } ?> |
|
| 53 | + } ?> |
|
| 54 | 54 | </div> |
| 55 | 55 | <?php |
| 56 | 56 | } else if ( $field['type'] == 'captcha' ) { |
| 57 | 57 | if ( empty($frm_settings->pubkey) ) { ?> |
| 58 | 58 | <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Private Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
| 59 | 59 | <?php |
| 60 | - } ?> |
|
| 60 | + } ?> |
|
| 61 | 61 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
| 62 | 62 | <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" /> |
| 63 | 63 | <?php |
| 64 | 64 | } else { |
| 65 | - do_action( 'frm_display_added_fields', $field ); |
|
| 65 | + do_action( 'frm_display_added_fields', $field ); |
|
| 66 | 66 | do_action( 'frm_display_added_' . $field['type'] . '_field', $field ); |
| 67 | 67 | } |
@@ -1,33 +1,33 @@ discard block |
||
| 1 | 1 | <?php if ( in_array( $display['type'], array( 'text', 'website', 'email', 'url' ) ) ) { ?> |
| 2 | - <input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '') . ';"' ) : ''; ?> class="dyn_default_value" /> |
|
| 2 | + <input type="text" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" value="<?php echo esc_attr( $field['default_value'] ); ?>" <?php echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; ?> class="dyn_default_value" /> |
|
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
| 5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
| 6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
| 6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea> |
|
| 7 | 7 | |
| 8 | 8 | <?php |
| 9 | 9 | |
| 10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
| 12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 11 | + $field['default_value'] = maybe_unserialize( $field['default_value'] ); |
|
| 12 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 14 | 14 | } else { |
| 15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 16 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 15 | + do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
| 16 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
| 18 | 18 | </ul> |
| 19 | 19 | <?php |
| 20 | 20 | } |
| 21 | 21 | } else if ( $field['type'] == 'select' ) { |
| 22 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 22 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 23 | 23 | echo FrmFieldsHelper::dropdown_categories( array( 'name' => $field_name, 'field' => $field ) ); |
| 24 | 24 | } else { ?> |
| 25 | 25 | <select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php |
| 26 | 26 | echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : ''; |
| 27 | 27 | echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> > |
| 28 | 28 | <?php foreach ( $field['options'] as $opt_key => $opt ) { |
| 29 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 30 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 29 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 30 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 31 | 31 | $selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?> |
| 32 | 32 | <option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option> |
| 33 | 33 | <?php } ?> |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | <?php |
| 46 | 46 | |
| 47 | 47 | if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?> |
| 48 | - <?php do_action('frm_add_multiple_opts_labels', $field); ?> |
|
| 49 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 50 | - <?php FrmFieldsHelper::show_single_option($field); ?> |
|
| 48 | + <?php do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
| 49 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
| 50 | + <?php FrmFieldsHelper::show_single_option( $field ); ?> |
|
| 51 | 51 | </ul> |
| 52 | 52 | <?php |
| 53 | 53 | } ?> |
| 54 | 54 | </div> |
| 55 | 55 | <?php |
| 56 | 56 | } else if ( $field['type'] == 'captcha' ) { |
| 57 | - if ( empty($frm_settings->pubkey) ) { ?> |
|
| 58 | - <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Private Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
|
| 57 | + if ( empty( $frm_settings->pubkey ) ) { ?> |
|
| 58 | + <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Private Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div> |
|
| 59 | 59 | <?php |
| 60 | 60 | } ?> |
| 61 | 61 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
| 5 | 5 | <title><?php bloginfo('name'); ?></title> |
| 6 | 6 | <?php |
| 7 | - wp_admin_css( 'global' ); |
|
| 8 | - wp_admin_css(); |
|
| 9 | - wp_admin_css( 'colors' ); |
|
| 10 | - wp_admin_css( 'ie' ); |
|
| 7 | + wp_admin_css( 'global' ); |
|
| 8 | + wp_admin_css(); |
|
| 9 | + wp_admin_css( 'colors' ); |
|
| 10 | + wp_admin_css( 'ie' ); |
|
| 11 | 11 | if ( is_multisite() ) { |
| 12 | - wp_admin_css( 'ms' ); |
|
| 12 | + wp_admin_css( 'ms' ); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - do_action('admin_print_styles'); |
|
| 16 | - do_action('admin_print_scripts'); |
|
| 15 | + do_action('admin_print_styles'); |
|
| 16 | + do_action('admin_print_scripts'); |
|
| 17 | 17 | |
| 18 | - ?> |
|
| 18 | + ?> |
|
| 19 | 19 | </head> |
| 20 | 20 | <body class="wp-admin no-js wp-core-ui frm_field_opts_popup <?php echo esc_attr( apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class ); ?>"> |
| 21 | 21 | <div class="frm_med_padding"> |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | <?php |
| 30 | 30 | $other_array = array(); |
| 31 | 31 | foreach ( $field->options as $fkey => $fopt ) { |
| 32 | - //If it is an other option, don't include it |
|
| 33 | - if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 34 | - continue; |
|
| 35 | - } |
|
| 32 | + //If it is an other option, don't include it |
|
| 33 | + if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 34 | + continue; |
|
| 35 | + } |
|
| 36 | 36 | if ( is_array( $fopt ) ) { |
| 37 | - $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | - $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 37 | + $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | + $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 39 | 39 | if ( $label != $value && FrmField::is_option_true( $field, 'separate_value' ) ) { |
| 40 | - echo "$label|$value\n"; |
|
| 40 | + echo "$label|$value\n"; |
|
| 41 | 41 | } else { |
| 42 | 42 | echo $label . "\n"; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | } else { |
| 45 | 45 | echo $fopt . "\n"; |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | } ?> |
| 48 | 48 | </textarea> |
| 49 | 49 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | <html <?php language_attributes(); ?>> |
| 3 | 3 | <head> |
| 4 | 4 | <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
| 5 | - <title><?php bloginfo('name'); ?></title> |
|
| 5 | + <title><?php bloginfo( 'name' ); ?></title> |
|
| 6 | 6 | <?php |
| 7 | 7 | wp_admin_css( 'global' ); |
| 8 | 8 | wp_admin_css(); |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | wp_admin_css( 'ms' ); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - do_action('admin_print_styles'); |
|
| 16 | - do_action('admin_print_scripts'); |
|
| 15 | + do_action( 'admin_print_styles' ); |
|
| 16 | + do_action( 'admin_print_scripts' ); |
|
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | 19 | </head> |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | <p class="howto"><?php _e( 'Edit or add field options (one per line)', 'formidable' ) ?></p> |
| 23 | 23 | <ul class="frm_prepop"> |
| 24 | 24 | <?php foreach ( $prepop as $label => $pop ) { ?> |
| 25 | - <li><a href="javascript:void(0)" onclick='frmPrePop(<?php echo str_replace("'", '‘', json_encode($pop)) ?>); return false;'><?php echo esc_html( $label ) ?></a></li> |
|
| 25 | + <li><a href="javascript:void(0)" onclick='frmPrePop(<?php echo str_replace( "'", '‘', json_encode( $pop ) ) ?>); return false;'><?php echo esc_html( $label ) ?></a></li> |
|
| 26 | 26 | <?php } ?> |
| 27 | 27 | </ul> |
| 28 | 28 | <textarea name="frm_bulk_options" id="frm_bulk_options"> |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | $other_array = array(); |
| 31 | 31 | foreach ( $field->options as $fkey => $fopt ) { |
| 32 | 32 | //If it is an other option, don't include it |
| 33 | - if ( $fkey && strpos( $fkey, 'other') !== false ) { |
|
| 33 | + if ( $fkey && strpos( $fkey, 'other' ) !== false ) { |
|
| 34 | 34 | continue; |
| 35 | 35 | } |
| 36 | 36 | if ( is_array( $fopt ) ) { |
| 37 | - $label = (isset($fopt['label'])) ? $fopt['label'] : reset($fopt); |
|
| 38 | - $value = (isset($fopt['value'])) ? $fopt['value'] : $label; |
|
| 37 | + $label = ( isset( $fopt['label'] ) ) ? $fopt['label'] : reset( $fopt ); |
|
| 38 | + $value = ( isset( $fopt['value'] ) ) ? $fopt['value'] : $label; |
|
| 39 | 39 | if ( $label != $value && FrmField::is_option_true( $field, 'separate_value' ) ) { |
| 40 | 40 | echo "$label|$value\n"; |
| 41 | 41 | } else { |