@@ -185,6 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * @deprecated 3.0 |
| 188 | + * @param string $field |
|
| 188 | 189 | */ |
| 189 | 190 | private static function edit_in_place_value( $field ) { |
| 190 | 191 | _deprecated_function( __METHOD__, '3.0' ); |
@@ -837,6 +838,7 @@ discard block |
||
| 837 | 838 | /** |
| 838 | 839 | * Get an array of the helper shortcodes to display in the customization panel |
| 839 | 840 | * @since 2.0.6 |
| 841 | + * @param boolean $settings_tab |
|
| 840 | 842 | */ |
| 841 | 843 | private static function get_shortcode_helpers( $settings_tab ) { |
| 842 | 844 | $entry_shortcodes = array( |
@@ -912,6 +914,9 @@ discard block |
||
| 912 | 914 | return $content; |
| 913 | 915 | } |
| 914 | 916 | |
| 917 | + /** |
|
| 918 | + * @param boolean $entry |
|
| 919 | + */ |
|
| 915 | 920 | private static function get_entry_by_param( &$entry ) { |
| 916 | 921 | if ( ! $entry || ! is_object( $entry ) ) { |
| 917 | 922 | if ( ! $entry || ! is_numeric( $entry ) ) { |
@@ -1234,6 +1239,9 @@ discard block |
||
| 1234 | 1239 | return $form; |
| 1235 | 1240 | } |
| 1236 | 1241 | |
| 1242 | + /** |
|
| 1243 | + * @param string $id |
|
| 1244 | + */ |
|
| 1237 | 1245 | private static function maybe_get_form_to_show( $id ) { |
| 1238 | 1246 | $form = false; |
| 1239 | 1247 | |
@@ -1633,6 +1641,7 @@ discard block |
||
| 1633 | 1641 | |
| 1634 | 1642 | /** |
| 1635 | 1643 | * @since 2.0.8 |
| 1644 | + * @param string $content |
|
| 1636 | 1645 | */ |
| 1637 | 1646 | private static function maybe_minimize_form( $atts, &$content ) { |
| 1638 | 1647 | // check if minimizing is turned on |
@@ -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,35 +24,35 @@ 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' ) { |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | return; |
| 61 | 61 | } else if ( $action == 'new' ) { |
| 62 | 62 | $frm_field_selection = FrmField::field_selection(); |
| 63 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
| 64 | - $id = FrmForm::create( $values ); |
|
| 65 | - $form = FrmForm::getOne($id); |
|
| 63 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
| 64 | + $id = FrmForm::create( $values ); |
|
| 65 | + $form = FrmForm::getOne($id); |
|
| 66 | 66 | |
| 67 | 67 | self::create_default_email_action( $form ); |
| 68 | 68 | |
| 69 | 69 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 70 | 70 | |
| 71 | - $values['id'] = $id; |
|
| 71 | + $values['id'] = $id; |
|
| 72 | 72 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 73 | - } |
|
| 74 | - } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Create the default email action |
@@ -80,88 +80,88 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @param object $form |
| 82 | 82 | */ |
| 83 | - private static function create_default_email_action( $form ) { |
|
| 84 | - $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 83 | + private static function create_default_email_action( $form ) { |
|
| 84 | + $create_email = apply_filters( 'frm_create_default_email_action', true, $form ); |
|
| 85 | 85 | |
| 86 | - if ( $create_email ) { |
|
| 87 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 88 | - $action_control->create( $form->id ); |
|
| 89 | - } |
|
| 90 | - } |
|
| 86 | + if ( $create_email ) { |
|
| 87 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 88 | + $action_control->create( $form->id ); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | public static function create( $values = array() ) { |
| 93 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 93 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 94 | 94 | |
| 95 | - global $frm_vars; |
|
| 96 | - if ( empty( $values ) ) { |
|
| 97 | - $values = $_POST; |
|
| 98 | - } |
|
| 95 | + global $frm_vars; |
|
| 96 | + if ( empty( $values ) ) { |
|
| 97 | + $values = $_POST; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - //Set radio button and checkbox meta equal to "other" value |
|
| 101 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 102 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 103 | - } |
|
| 100 | + //Set radio button and checkbox meta equal to "other" value |
|
| 101 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 102 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 106 | 106 | |
| 107 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 108 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 109 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 110 | - } else { |
|
| 111 | - $errors = FrmForm::validate($values); |
|
| 112 | - } |
|
| 107 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
| 108 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 109 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
| 110 | + } else { |
|
| 111 | + $errors = FrmForm::validate($values); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - if ( count($errors) > 0 ) { |
|
| 115 | - $hide_preview = true; |
|
| 114 | + if ( count($errors) > 0 ) { |
|
| 115 | + $hide_preview = true; |
|
| 116 | 116 | $frm_field_selection = FrmField::field_selection(); |
| 117 | - $form = FrmForm::getOne( $id ); |
|
| 118 | - $fields = FrmField::get_all_for_form($id); |
|
| 117 | + $form = FrmForm::getOne( $id ); |
|
| 118 | + $fields = FrmField::get_all_for_form($id); |
|
| 119 | 119 | |
| 120 | 120 | $values = FrmAppHelper::setup_edit_vars($form, 'forms', '', true); |
| 121 | 121 | $values['fields'] = $fields; |
| 122 | 122 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 123 | 123 | |
| 124 | 124 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 125 | - } else { |
|
| 126 | - FrmForm::update( $id, $values, true ); |
|
| 125 | + } else { |
|
| 126 | + FrmForm::update( $id, $values, true ); |
|
| 127 | 127 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 128 | 128 | die( FrmAppHelper::js_redirect( $url ) ); |
| 129 | - } |
|
| 130 | - } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public static function edit( $values = false ) { |
|
| 133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 132 | + public static function edit( $values = false ) { |
|
| 133 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 134 | 134 | |
| 135 | 135 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 136 | - return self::get_edit_vars($id); |
|
| 137 | - } |
|
| 136 | + return self::get_edit_vars($id); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public static function settings( $id = false, $message = '' ) { |
|
| 140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 139 | + public static function settings( $id = false, $message = '' ) { |
|
| 140 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 141 | 141 | |
| 142 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 142 | + if ( ! $id || ! is_numeric($id) ) { |
|
| 143 | 143 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 144 | - } |
|
| 144 | + } |
|
| 145 | 145 | return self::get_settings_vars( $id, array(), $message ); |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - public static function update_settings() { |
|
| 149 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 148 | + public static function update_settings() { |
|
| 149 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | 150 | |
| 151 | 151 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 152 | 152 | |
| 153 | - $errors = FrmForm::validate($_POST); |
|
| 154 | - if ( count($errors) > 0 ) { |
|
| 155 | - return self::get_settings_vars($id, $errors); |
|
| 156 | - } |
|
| 153 | + $errors = FrmForm::validate($_POST); |
|
| 154 | + if ( count($errors) > 0 ) { |
|
| 155 | + return self::get_settings_vars($id, $errors); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - do_action('frm_before_update_form_settings', $id); |
|
| 158 | + do_action('frm_before_update_form_settings', $id); |
|
| 159 | 159 | |
| 160 | 160 | FrmForm::update( $id, $_POST ); |
| 161 | 161 | |
| 162 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 162 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 163 | 163 | return self::get_settings_vars( $id, array(), $message ); |
| 164 | - } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * @deprecated 3.0 |
@@ -203,33 +203,33 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | public static function update( $values = array() ) { |
| 205 | 205 | if ( empty( $values ) ) { |
| 206 | - $values = $_POST; |
|
| 207 | - } |
|
| 206 | + $values = $_POST; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - //Set radio button and checkbox meta equal to "other" value |
|
| 210 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 211 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 212 | - } |
|
| 209 | + //Set radio button and checkbox meta equal to "other" value |
|
| 210 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 211 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - $errors = FrmForm::validate( $values ); |
|
| 215 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 216 | - if ( $permission_error !== false ) { |
|
| 217 | - $errors['form'] = $permission_error; |
|
| 218 | - } |
|
| 214 | + $errors = FrmForm::validate( $values ); |
|
| 215 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 216 | + if ( $permission_error !== false ) { |
|
| 217 | + $errors['form'] = $permission_error; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 221 | 221 | |
| 222 | 222 | if ( count( $errors ) > 0 ) { |
| 223 | - return self::get_edit_vars( $id, $errors ); |
|
| 223 | + return self::get_edit_vars( $id, $errors ); |
|
| 224 | 224 | } else { |
| 225 | - FrmForm::update( $id, $values ); |
|
| 226 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 227 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 225 | + FrmForm::update( $id, $values ); |
|
| 226 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 227 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 228 | 228 | wp_die( $message ); |
| 229 | - } |
|
| 229 | + } |
|
| 230 | 230 | return self::get_edit_vars( $id, array(), $message ); |
| 231 | - } |
|
| 232 | - } |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | 235 | * Redirect to the url for creating from a template |
@@ -251,30 +251,30 @@ discard block |
||
| 251 | 251 | wp_die(); |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - public static function duplicate() { |
|
| 255 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 254 | + public static function duplicate() { |
|
| 255 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 256 | 256 | |
| 257 | 257 | $params = FrmForm::list_page_params(); |
| 258 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 259 | - $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 260 | - if ( $form ) { |
|
| 258 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 259 | + $message = $params['template'] ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 260 | + if ( $form ) { |
|
| 261 | 261 | return self::get_edit_vars( $form, array(), $message, true ); |
| 262 | - } else { |
|
| 263 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 264 | - } |
|
| 265 | - } |
|
| 262 | + } else { |
|
| 263 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - public static function page_preview() { |
|
| 267 | + public static function page_preview() { |
|
| 268 | 268 | $params = FrmForm::list_page_params(); |
| 269 | - if ( ! $params['form'] ) { |
|
| 270 | - return; |
|
| 271 | - } |
|
| 269 | + if ( ! $params['form'] ) { |
|
| 270 | + return; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 273 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 274 | 274 | if ( $form ) { |
| 275 | 275 | return self::show_form( $form->id, '', true, true ); |
| 276 | 276 | } |
| 277 | - } |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * @since 3.0 |
@@ -283,11 +283,11 @@ discard block |
||
| 283 | 283 | echo self::page_preview(); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - public static function preview() { |
|
| 287 | - do_action( 'frm_wp' ); |
|
| 286 | + public static function preview() { |
|
| 287 | + do_action( 'frm_wp' ); |
|
| 288 | 288 | |
| 289 | - global $frm_vars; |
|
| 290 | - $frm_vars['preview'] = true; |
|
| 289 | + global $frm_vars; |
|
| 290 | + $frm_vars['preview'] = true; |
|
| 291 | 291 | |
| 292 | 292 | self::load_wp(); |
| 293 | 293 | |
@@ -407,22 +407,22 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - public static function untrash() { |
|
| 410 | + public static function untrash() { |
|
| 411 | 411 | self::change_form_status( 'untrash' ); |
| 412 | - } |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | 414 | public static function bulk_untrash( $ids ) { |
| 415 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 415 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 416 | 416 | |
| 417 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 417 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 418 | 418 | |
| 419 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 420 | - return $message; |
|
| 421 | - } |
|
| 419 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 420 | + return $message; |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - public static function trash() { |
|
| 423 | + public static function trash() { |
|
| 424 | 424 | self::change_form_status( 'trash' ); |
| 425 | - } |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | 428 | * @param string $status |
@@ -471,14 +471,14 @@ discard block |
||
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | public static function bulk_trash( $ids ) { |
| 474 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 474 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 475 | 475 | |
| 476 | - $count = 0; |
|
| 477 | - foreach ( $ids as $id ) { |
|
| 478 | - if ( FrmForm::trash( $id ) ) { |
|
| 479 | - $count++; |
|
| 480 | - } |
|
| 481 | - } |
|
| 476 | + $count = 0; |
|
| 477 | + foreach ( $ids as $id ) { |
|
| 478 | + if ( FrmForm::trash( $id ) ) { |
|
| 479 | + $count++; |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | $current_page = FrmAppHelper::get_simple_request( array( |
| 484 | 484 | 'param' => 'form_type', |
@@ -486,63 +486,63 @@ discard block |
||
| 486 | 486 | ) ); |
| 487 | 487 | $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
| 488 | 488 | |
| 489 | - return $message; |
|
| 490 | - } |
|
| 489 | + return $message; |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | - public static function destroy() { |
|
| 493 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 492 | + public static function destroy() { |
|
| 493 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 494 | 494 | |
| 495 | 495 | $params = FrmForm::list_page_params(); |
| 496 | 496 | |
| 497 | - //check nonce url |
|
| 498 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 497 | + //check nonce url |
|
| 498 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 499 | 499 | |
| 500 | - $count = 0; |
|
| 501 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 502 | - $count++; |
|
| 503 | - } |
|
| 500 | + $count = 0; |
|
| 501 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 502 | + $count++; |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 505 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 506 | 506 | |
| 507 | 507 | self::display_forms_list( $params, $message ); |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | public static function bulk_destroy( $ids ) { |
| 511 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 511 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 512 | 512 | |
| 513 | - $count = 0; |
|
| 514 | - foreach ( $ids as $id ) { |
|
| 515 | - $d = FrmForm::destroy( $id ); |
|
| 516 | - if ( $d ) { |
|
| 517 | - $count++; |
|
| 518 | - } |
|
| 519 | - } |
|
| 513 | + $count = 0; |
|
| 514 | + foreach ( $ids as $id ) { |
|
| 515 | + $d = FrmForm::destroy( $id ); |
|
| 516 | + if ( $d ) { |
|
| 517 | + $count++; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 521 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 522 | 522 | |
| 523 | - return $message; |
|
| 524 | - } |
|
| 523 | + return $message; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - private static function delete_all() { |
|
| 527 | - //check nonce url |
|
| 528 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 529 | - if ( $permission_error !== false ) { |
|
| 526 | + private static function delete_all() { |
|
| 527 | + //check nonce url |
|
| 528 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 529 | + if ( $permission_error !== false ) { |
|
| 530 | 530 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 531 | - return; |
|
| 532 | - } |
|
| 531 | + return; |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | 534 | $count = FrmForm::scheduled_delete( time() ); |
| 535 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 535 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 536 | 536 | |
| 537 | 537 | self::display_forms_list( array(), $message ); |
| 538 | - } |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | - * Inserts Formidable button |
|
| 542 | - * Hook exists since 2.5.0 |
|
| 543 | - * |
|
| 544 | - * @since 2.0.15 |
|
| 545 | - */ |
|
| 541 | + * Inserts Formidable button |
|
| 542 | + * Hook exists since 2.5.0 |
|
| 543 | + * |
|
| 544 | + * @since 2.0.15 |
|
| 545 | + */ |
|
| 546 | 546 | public static function insert_form_button() { |
| 547 | 547 | if ( current_user_can('frm_view_forms') ) { |
| 548 | 548 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -553,45 +553,45 @@ discard block |
||
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - public static function insert_form_popup() { |
|
| 556 | + public static function insert_form_popup() { |
|
| 557 | 557 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 558 | 558 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 559 | - return; |
|
| 560 | - } |
|
| 559 | + return; |
|
| 560 | + } |
|
| 561 | 561 | |
| 562 | - FrmAppHelper::load_admin_wide_js(); |
|
| 562 | + FrmAppHelper::load_admin_wide_js(); |
|
| 563 | 563 | |
| 564 | - $shortcodes = array( |
|
| 564 | + $shortcodes = array( |
|
| 565 | 565 | 'formidable' => array( |
| 566 | 566 | 'name' => __( 'Form', 'formidable' ), |
| 567 | 567 | 'label' => __( 'Insert a Form', 'formidable' ), |
| 568 | 568 | ), |
| 569 | - ); |
|
| 569 | + ); |
|
| 570 | 570 | |
| 571 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 571 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 572 | 572 | |
| 573 | 573 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 574 | - } |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - public static function get_shortcode_opts() { |
|
| 576 | + public static function get_shortcode_opts() { |
|
| 577 | 577 | FrmAppHelper::permission_check('frm_view_forms'); |
| 578 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 578 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 579 | 579 | |
| 580 | 580 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 581 | - if ( empty($shortcode) ) { |
|
| 582 | - wp_die(); |
|
| 583 | - } |
|
| 581 | + if ( empty($shortcode) ) { |
|
| 582 | + wp_die(); |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | 585 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 586 | 586 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 587 | 587 | |
| 588 | - $form_id = ''; |
|
| 589 | - $opts = array(); |
|
| 588 | + $form_id = ''; |
|
| 589 | + $opts = array(); |
|
| 590 | 590 | switch ( $shortcode ) { |
| 591 | - case 'formidable': |
|
| 592 | - $opts = array( |
|
| 591 | + case 'formidable': |
|
| 592 | + $opts = array( |
|
| 593 | 593 | 'form_id' => 'id', |
| 594 | - //'key' => ', |
|
| 594 | + //'key' => ', |
|
| 595 | 595 | 'title' => array( |
| 596 | 596 | 'val' => 1, |
| 597 | 597 | 'label' => __( 'Display form title', 'formidable' ), |
@@ -604,8 +604,8 @@ discard block |
||
| 604 | 604 | 'val' => 1, |
| 605 | 605 | 'label' => __( 'Minimize form HTML', 'formidable' ), |
| 606 | 606 | ), |
| 607 | - ); |
|
| 608 | - } |
|
| 607 | + ); |
|
| 608 | + } |
|
| 609 | 609 | $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
| 610 | 610 | |
| 611 | 611 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
@@ -616,38 +616,38 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 618 | 618 | |
| 619 | - echo '</div>'; |
|
| 619 | + echo '</div>'; |
|
| 620 | 620 | |
| 621 | - wp_die(); |
|
| 622 | - } |
|
| 621 | + wp_die(); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | public static function display_forms_list( $params = array(), $message = '', $errors = array() ) { |
| 625 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 625 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 626 | 626 | |
| 627 | - global $wpdb, $frm_vars; |
|
| 627 | + global $wpdb, $frm_vars; |
|
| 628 | 628 | |
| 629 | 629 | if ( empty( $params ) ) { |
| 630 | 630 | $params = FrmForm::list_page_params(); |
| 631 | - } |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 633 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 634 | 634 | |
| 635 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 635 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 636 | 636 | |
| 637 | - $wp_list_table->prepare_items(); |
|
| 637 | + $wp_list_table->prepare_items(); |
|
| 638 | 638 | |
| 639 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 640 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 639 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 640 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 641 | 641 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 642 | - die(); |
|
| 643 | - } |
|
| 642 | + die(); |
|
| 643 | + } |
|
| 644 | 644 | |
| 645 | 645 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 646 | - } |
|
| 646 | + } |
|
| 647 | 647 | |
| 648 | 648 | public static function get_columns( $columns ) { |
| 649 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 650 | - $columns['id'] = 'ID'; |
|
| 649 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 650 | + $columns['id'] = 'ID'; |
|
| 651 | 651 | |
| 652 | 652 | $type = FrmAppHelper::get_simple_request( array( |
| 653 | 653 | 'param' => 'form_type', |
@@ -655,18 +655,18 @@ discard block |
||
| 655 | 655 | 'default' => 'published', |
| 656 | 656 | ) ); |
| 657 | 657 | |
| 658 | - if ( 'template' == $type ) { |
|
| 659 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 660 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 661 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 662 | - } else { |
|
| 663 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 664 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 665 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 666 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 667 | - } |
|
| 658 | + if ( 'template' == $type ) { |
|
| 659 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 660 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 661 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 662 | + } else { |
|
| 663 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 664 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 665 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 666 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 669 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 670 | 670 | |
| 671 | 671 | add_screen_option( 'per_page', array( |
| 672 | 672 | 'label' => __( 'Forms', 'formidable' ), |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | 'option' => 'formidable_page_formidable_per_page', |
| 675 | 675 | ) ); |
| 676 | 676 | |
| 677 | - return $columns; |
|
| 677 | + return $columns; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | public static function get_sortable_columns() { |
@@ -702,86 +702,86 @@ discard block |
||
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | public static function save_per_page( $save, $option, $value ) { |
| 705 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 706 | - $save = (int) $value; |
|
| 707 | - } |
|
| 708 | - return $save; |
|
| 709 | - } |
|
| 705 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 706 | + $save = (int) $value; |
|
| 707 | + } |
|
| 708 | + return $save; |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | 711 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 712 | - global $frm_vars; |
|
| 712 | + global $frm_vars; |
|
| 713 | 713 | |
| 714 | - $form = FrmForm::getOne( $id ); |
|
| 715 | - if ( ! $form ) { |
|
| 716 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 717 | - } |
|
| 714 | + $form = FrmForm::getOne( $id ); |
|
| 715 | + if ( ! $form ) { |
|
| 716 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - if ( $form->parent_form_id ) { |
|
| 719 | + if ( $form->parent_form_id ) { |
|
| 720 | 720 | 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>' )); |
| 721 | - } |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | 723 | $frm_field_selection = FrmField::field_selection(); |
| 724 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 724 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 725 | 725 | |
| 726 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 727 | - $reset_fields = false; |
|
| 728 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 726 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 727 | + $reset_fields = false; |
|
| 728 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 729 | 729 | |
| 730 | - if ( $reset_fields ) { |
|
| 731 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 732 | - } |
|
| 730 | + if ( $reset_fields ) { |
|
| 731 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 734 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 735 | 735 | |
| 736 | 736 | $args = array( 'parent_form_id' => $form->id ); |
| 737 | 737 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); |
| 738 | 738 | $values['fields'] = $fields; |
| 739 | 739 | |
| 740 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 741 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 742 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 743 | - } |
|
| 740 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 741 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 742 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | 745 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 746 | 746 | |
| 747 | - if ( $form->default_template ) { |
|
| 748 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 749 | - } else if ( defined('DOING_AJAX') ) { |
|
| 750 | - wp_die(); |
|
| 751 | - } else if ( $create_link ) { |
|
| 747 | + if ( $form->default_template ) { |
|
| 748 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 749 | + } else if ( defined('DOING_AJAX') ) { |
|
| 750 | + wp_die(); |
|
| 751 | + } else if ( $create_link ) { |
|
| 752 | 752 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 753 | - } else { |
|
| 753 | + } else { |
|
| 754 | 754 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 755 | - } |
|
| 756 | - } |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | 758 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 759 | 759 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 760 | 760 | |
| 761 | - global $frm_vars; |
|
| 761 | + global $frm_vars; |
|
| 762 | 762 | |
| 763 | - $form = FrmForm::getOne( $id ); |
|
| 763 | + $form = FrmForm::getOne( $id ); |
|
| 764 | 764 | |
| 765 | - $fields = FrmField::get_all_for_form($id); |
|
| 766 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 765 | + $fields = FrmField::get_all_for_form($id); |
|
| 766 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 767 | 767 | |
| 768 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 769 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 770 | - } |
|
| 768 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 769 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 770 | + } |
|
| 771 | 771 | |
| 772 | 772 | self::clean_submit_html( $values ); |
| 773 | 773 | |
| 774 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 774 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 775 | 775 | |
| 776 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 777 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 776 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 777 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 778 | 778 | |
| 779 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 779 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 780 | 780 | |
| 781 | 781 | $first_h3 = 'frm_first_h3'; |
| 782 | 782 | |
| 783 | 783 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 784 | - } |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | 787 | * Replace old Submit Button href with new href to avoid errors in Chrome |
@@ -796,11 +796,11 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 800 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 801 | - $linked_forms = array(); |
|
| 802 | - $col = 'one'; |
|
| 803 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 799 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 800 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 801 | + $linked_forms = array(); |
|
| 802 | + $col = 'one'; |
|
| 803 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 804 | 804 | |
| 805 | 805 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 806 | 806 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 809 | 809 | |
| 810 | 810 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 811 | - } |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | 813 | /** |
| 814 | 814 | * Get an array of the options to display in the advanced tab |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | '' => '', |
| 850 | 850 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 851 | 851 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 852 | - ); |
|
| 852 | + ); |
|
| 853 | 853 | |
| 854 | 854 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 855 | 855 | unset( $entry_shortcodes['post_id'] ); |
@@ -896,21 +896,21 @@ discard block |
||
| 896 | 896 | wp_die(); |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 899 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 900 | 900 | self::get_entry_by_param( $entry ); |
| 901 | - if ( ! $entry ) { |
|
| 902 | - return $content; |
|
| 903 | - } |
|
| 901 | + if ( ! $entry ) { |
|
| 902 | + return $content; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - if ( is_object( $form ) ) { |
|
| 906 | - $form = $form->id; |
|
| 907 | - } |
|
| 905 | + if ( is_object( $form ) ) { |
|
| 906 | + $form = $form->id; |
|
| 907 | + } |
|
| 908 | 908 | |
| 909 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 910 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 909 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 910 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 911 | 911 | |
| 912 | - return $content; |
|
| 913 | - } |
|
| 912 | + return $content; |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | private static function get_entry_by_param( &$entry ) { |
| 916 | 916 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -922,206 +922,206 @@ discard block |
||
| 922 | 922 | } |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 926 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 927 | - } |
|
| 925 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 926 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 927 | + } |
|
| 928 | 928 | |
| 929 | - public static function process_bulk_form_actions( $errors ) { |
|
| 930 | - if ( ! $_REQUEST ) { |
|
| 931 | - return $errors; |
|
| 932 | - } |
|
| 929 | + public static function process_bulk_form_actions( $errors ) { |
|
| 930 | + if ( ! $_REQUEST ) { |
|
| 931 | + return $errors; |
|
| 932 | + } |
|
| 933 | 933 | |
| 934 | 934 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 935 | - if ( $bulkaction == -1 ) { |
|
| 935 | + if ( $bulkaction == -1 ) { |
|
| 936 | 936 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 937 | - } |
|
| 937 | + } |
|
| 938 | 938 | |
| 939 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 940 | - FrmAppHelper::remove_get_action(); |
|
| 939 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 940 | + FrmAppHelper::remove_get_action(); |
|
| 941 | 941 | |
| 942 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 943 | - } |
|
| 942 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | 945 | $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' ); |
| 946 | - if ( empty( $ids ) ) { |
|
| 947 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 948 | - return $errors; |
|
| 949 | - } |
|
| 950 | - |
|
| 951 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 952 | - if ( $permission_error !== false ) { |
|
| 953 | - $errors[] = $permission_error; |
|
| 954 | - return $errors; |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - if ( ! is_array( $ids ) ) { |
|
| 958 | - $ids = explode( ',', $ids ); |
|
| 959 | - } |
|
| 960 | - |
|
| 961 | - switch ( $bulkaction ) { |
|
| 962 | - case 'delete': |
|
| 963 | - $message = self::bulk_destroy( $ids ); |
|
| 946 | + if ( empty( $ids ) ) { |
|
| 947 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 948 | + return $errors; |
|
| 949 | + } |
|
| 950 | + |
|
| 951 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 952 | + if ( $permission_error !== false ) { |
|
| 953 | + $errors[] = $permission_error; |
|
| 954 | + return $errors; |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + if ( ! is_array( $ids ) ) { |
|
| 958 | + $ids = explode( ',', $ids ); |
|
| 959 | + } |
|
| 960 | + |
|
| 961 | + switch ( $bulkaction ) { |
|
| 962 | + case 'delete': |
|
| 963 | + $message = self::bulk_destroy( $ids ); |
|
| 964 | 964 | break; |
| 965 | - case 'trash': |
|
| 966 | - $message = self::bulk_trash( $ids ); |
|
| 965 | + case 'trash': |
|
| 966 | + $message = self::bulk_trash( $ids ); |
|
| 967 | 967 | break; |
| 968 | - case 'untrash': |
|
| 969 | - $message = self::bulk_untrash( $ids ); |
|
| 970 | - } |
|
| 968 | + case 'untrash': |
|
| 969 | + $message = self::bulk_untrash( $ids ); |
|
| 970 | + } |
|
| 971 | 971 | |
| 972 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 972 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 973 | 973 | echo '<div id="message" class="updated frm_updated_message">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; |
| 974 | - } |
|
| 974 | + } |
|
| 975 | 975 | |
| 976 | - return $errors; |
|
| 977 | - } |
|
| 976 | + return $errors; |
|
| 977 | + } |
|
| 978 | 978 | |
| 979 | 979 | /** |
| 980 | 980 | * @deprecated 1.07.05 |
| 981 | 981 | */ |
| 982 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 983 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 982 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 983 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 984 | 984 | |
| 985 | - $path = untrailingslashit(trim($path)); |
|
| 985 | + $path = untrailingslashit(trim($path)); |
|
| 986 | 986 | $templates = glob( $path . '/*.php' ); |
| 987 | 987 | |
| 988 | 988 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 989 | 989 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 990 | 990 | $template_query = array( 'form_key' => $filename ); |
| 991 | - if ( $template ) { |
|
| 992 | - $template_query['is_template'] = 1; |
|
| 993 | - } |
|
| 994 | - if ( $default ) { |
|
| 995 | - $template_query['default_template'] = 1; |
|
| 996 | - } |
|
| 991 | + if ( $template ) { |
|
| 992 | + $template_query['is_template'] = 1; |
|
| 993 | + } |
|
| 994 | + if ( $default ) { |
|
| 995 | + $template_query['default_template'] = 1; |
|
| 996 | + } |
|
| 997 | 997 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 998 | 998 | |
| 999 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 1000 | - $values['form_key'] = $filename; |
|
| 1001 | - $values['is_template'] = $template; |
|
| 1002 | - $values['status'] = 'published'; |
|
| 1003 | - if ( $default ) { |
|
| 1004 | - $values['default_template'] = 1; |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - include( $templates[ $i ] ); |
|
| 1008 | - |
|
| 1009 | - //get updated form |
|
| 1010 | - if ( isset($form) && ! empty($form) ) { |
|
| 1011 | - $old_id = $form->id; |
|
| 1012 | - $form = FrmForm::getOne($form->id); |
|
| 1013 | - } else { |
|
| 1014 | - $old_id = false; |
|
| 999 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 1000 | + $values['form_key'] = $filename; |
|
| 1001 | + $values['is_template'] = $template; |
|
| 1002 | + $values['status'] = 'published'; |
|
| 1003 | + if ( $default ) { |
|
| 1004 | + $values['default_template'] = 1; |
|
| 1005 | + } |
|
| 1006 | + |
|
| 1007 | + include( $templates[ $i ] ); |
|
| 1008 | + |
|
| 1009 | + //get updated form |
|
| 1010 | + if ( isset($form) && ! empty($form) ) { |
|
| 1011 | + $old_id = $form->id; |
|
| 1012 | + $form = FrmForm::getOne($form->id); |
|
| 1013 | + } else { |
|
| 1014 | + $old_id = false; |
|
| 1015 | 1015 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 1016 | - } |
|
| 1016 | + } |
|
| 1017 | 1017 | |
| 1018 | - if ( $form ) { |
|
| 1018 | + if ( $form ) { |
|
| 1019 | 1019 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 1020 | - } |
|
| 1021 | - } |
|
| 1022 | - } |
|
| 1020 | + } |
|
| 1021 | + } |
|
| 1022 | + } |
|
| 1023 | 1023 | |
| 1024 | - public static function route() { |
|
| 1025 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 1026 | - $vars = array(); |
|
| 1024 | + public static function route() { |
|
| 1025 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 1026 | + $vars = array(); |
|
| 1027 | 1027 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 1028 | 1028 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 1029 | 1029 | |
| 1030 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 1031 | - $json_vars = json_decode($json_vars, true); |
|
| 1032 | - if ( empty($json_vars) ) { |
|
| 1033 | - // json decoding failed so we should return an error message |
|
| 1030 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 1031 | + $json_vars = json_decode($json_vars, true); |
|
| 1032 | + if ( empty($json_vars) ) { |
|
| 1033 | + // json decoding failed so we should return an error message |
|
| 1034 | 1034 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1035 | - if ( 'edit' == $action ) { |
|
| 1036 | - $action = 'update'; |
|
| 1037 | - } |
|
| 1038 | - |
|
| 1039 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 1040 | - } else { |
|
| 1041 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 1042 | - $action = $vars[ $action ]; |
|
| 1035 | + if ( 'edit' == $action ) { |
|
| 1036 | + $action = 'update'; |
|
| 1037 | + } |
|
| 1038 | + |
|
| 1039 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 1040 | + } else { |
|
| 1041 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 1042 | + $action = $vars[ $action ]; |
|
| 1043 | 1043 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 1044 | 1044 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 1045 | 1045 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 1046 | - } |
|
| 1047 | - } else { |
|
| 1046 | + } |
|
| 1047 | + } else { |
|
| 1048 | 1048 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 1049 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1050 | - // override the action for this page |
|
| 1051 | - $action = 'delete_all'; |
|
| 1052 | - } |
|
| 1053 | - } |
|
| 1049 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 1050 | + // override the action for this page |
|
| 1051 | + $action = 'delete_all'; |
|
| 1052 | + } |
|
| 1053 | + } |
|
| 1054 | 1054 | |
| 1055 | 1055 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1056 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1057 | - |
|
| 1058 | - switch ( $action ) { |
|
| 1059 | - case 'new': |
|
| 1060 | - return self::new_form($vars); |
|
| 1061 | - case 'create': |
|
| 1062 | - case 'edit': |
|
| 1063 | - case 'update': |
|
| 1064 | - case 'duplicate': |
|
| 1065 | - case 'trash': |
|
| 1066 | - case 'untrash': |
|
| 1067 | - case 'destroy': |
|
| 1068 | - case 'delete_all': |
|
| 1069 | - case 'settings': |
|
| 1070 | - case 'update_settings': |
|
| 1056 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 1057 | + |
|
| 1058 | + switch ( $action ) { |
|
| 1059 | + case 'new': |
|
| 1060 | + return self::new_form($vars); |
|
| 1061 | + case 'create': |
|
| 1062 | + case 'edit': |
|
| 1063 | + case 'update': |
|
| 1064 | + case 'duplicate': |
|
| 1065 | + case 'trash': |
|
| 1066 | + case 'untrash': |
|
| 1067 | + case 'destroy': |
|
| 1068 | + case 'delete_all': |
|
| 1069 | + case 'settings': |
|
| 1070 | + case 'update_settings': |
|
| 1071 | 1071 | return self::$action( $vars ); |
| 1072 | - default: |
|
| 1072 | + default: |
|
| 1073 | 1073 | do_action( 'frm_form_action_' . $action ); |
| 1074 | 1074 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 1075 | - return; |
|
| 1076 | - } |
|
| 1075 | + return; |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 1079 | - if ( $action == -1 ) { |
|
| 1079 | + if ( $action == -1 ) { |
|
| 1080 | 1080 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 1081 | - } |
|
| 1081 | + } |
|
| 1082 | 1082 | |
| 1083 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 1084 | - FrmAppHelper::remove_get_action(); |
|
| 1085 | - return self::list_form(); |
|
| 1086 | - } |
|
| 1083 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 1084 | + FrmAppHelper::remove_get_action(); |
|
| 1085 | + return self::list_form(); |
|
| 1086 | + } |
|
| 1087 | 1087 | |
| 1088 | - return self::display_forms_list(); |
|
| 1089 | - } |
|
| 1090 | - } |
|
| 1088 | + return self::display_forms_list(); |
|
| 1089 | + } |
|
| 1090 | + } |
|
| 1091 | 1091 | |
| 1092 | - public static function json_error( $errors ) { |
|
| 1093 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1094 | - return $errors; |
|
| 1095 | - } |
|
| 1092 | + public static function json_error( $errors ) { |
|
| 1093 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 1094 | + return $errors; |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | 1097 | |
| 1098 | - /* FRONT-END FORMS */ |
|
| 1099 | - public static function admin_bar_css() { |
|
| 1098 | + /* FRONT-END FORMS */ |
|
| 1099 | + public static function admin_bar_css() { |
|
| 1100 | 1100 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1101 | - return; |
|
| 1102 | - } |
|
| 1101 | + return; |
|
| 1102 | + } |
|
| 1103 | 1103 | |
| 1104 | 1104 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 1105 | 1105 | FrmAppHelper::load_font_style(); |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | public static function admin_bar_configure() { |
| 1109 | - global $frm_vars; |
|
| 1110 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 1111 | - return; |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - $actions = array(); |
|
| 1115 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 1116 | - if ( is_object($form) ) { |
|
| 1117 | - $actions[ $form->id ] = $form->name; |
|
| 1118 | - } |
|
| 1119 | - unset($form); |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - if ( empty($actions) ) { |
|
| 1123 | - return; |
|
| 1124 | - } |
|
| 1109 | + global $frm_vars; |
|
| 1110 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 1111 | + return; |
|
| 1112 | + } |
|
| 1113 | + |
|
| 1114 | + $actions = array(); |
|
| 1115 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 1116 | + if ( is_object($form) ) { |
|
| 1117 | + $actions[ $form->id ] = $form->name; |
|
| 1118 | + } |
|
| 1119 | + unset($form); |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + if ( empty($actions) ) { |
|
| 1123 | + return; |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | self::add_menu_to_admin_bar(); |
| 1127 | 1127 | self::add_forms_to_admin_bar( $actions ); |
@@ -1162,18 +1162,18 @@ discard block |
||
| 1162 | 1162 | } |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - //formidable shortcode |
|
| 1165 | + //formidable shortcode |
|
| 1166 | 1166 | public static function get_form_shortcode( $atts ) { |
| 1167 | - global $frm_vars; |
|
| 1168 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1169 | - $sc = '[formidable'; |
|
| 1167 | + global $frm_vars; |
|
| 1168 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1169 | + $sc = '[formidable'; |
|
| 1170 | 1170 | if ( ! empty( $atts ) ) { |
| 1171 | 1171 | foreach ( $atts as $k => $v ) { |
| 1172 | 1172 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1173 | 1173 | } |
| 1174 | 1174 | } |
| 1175 | 1175 | return $sc . ']'; |
| 1176 | - } |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | 1178 | $shortcode_atts = shortcode_atts( array( |
| 1179 | 1179 | 'id' => '', |
@@ -1188,30 +1188,30 @@ discard block |
||
| 1188 | 1188 | ), $atts ); |
| 1189 | 1189 | do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
| 1190 | 1190 | |
| 1191 | - return self::show_form( |
|
| 1192 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1193 | - $shortcode_atts['description'], $atts |
|
| 1194 | - ); |
|
| 1195 | - } |
|
| 1191 | + return self::show_form( |
|
| 1192 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1193 | + $shortcode_atts['description'], $atts |
|
| 1194 | + ); |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1198 | - if ( empty( $id ) ) { |
|
| 1199 | - $id = $key; |
|
| 1200 | - } |
|
| 1197 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1198 | + if ( empty( $id ) ) { |
|
| 1199 | + $id = $key; |
|
| 1200 | + } |
|
| 1201 | 1201 | |
| 1202 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1203 | - if ( ! $form ) { |
|
| 1204 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1205 | - } |
|
| 1202 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1203 | + if ( ! $form ) { |
|
| 1204 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1205 | + } |
|
| 1206 | 1206 | |
| 1207 | 1207 | FrmAppController::maybe_update_styles(); |
| 1208 | 1208 | |
| 1209 | 1209 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1210 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1210 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1211 | 1211 | |
| 1212 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1212 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1213 | 1213 | |
| 1214 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1214 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1215 | 1215 | |
| 1216 | 1216 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1217 | 1217 | // don't show a draft form on a page |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | return $form; |
| 1235 | - } |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | 1237 | private static function maybe_get_form_to_show( $id ) { |
| 1238 | 1238 | $form = false; |
@@ -1261,21 +1261,21 @@ discard block |
||
| 1261 | 1261 | 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'] ); |
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1265 | - ob_start(); |
|
| 1264 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1265 | + ob_start(); |
|
| 1266 | 1266 | |
| 1267 | 1267 | do_action( 'frm_before_get_form', $atts ); |
| 1268 | 1268 | |
| 1269 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1269 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1270 | 1270 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1271 | 1271 | |
| 1272 | - $contents = ob_get_contents(); |
|
| 1273 | - ob_end_clean(); |
|
| 1272 | + $contents = ob_get_contents(); |
|
| 1273 | + ob_end_clean(); |
|
| 1274 | 1274 | |
| 1275 | 1275 | self::maybe_minimize_form( $atts, $contents ); |
| 1276 | 1276 | |
| 1277 | - return $contents; |
|
| 1278 | - } |
|
| 1277 | + return $contents; |
|
| 1278 | + } |
|
| 1279 | 1279 | |
| 1280 | 1280 | public static function enqueue_scripts( $params ) { |
| 1281 | 1281 | do_action( 'frm_enqueue_form_scripts', $params ); |
@@ -1614,10 +1614,10 @@ discard block |
||
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | 1616 | public static function defer_script_loading( $tag, $handle ) { |
| 1617 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1618 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1617 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1618 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1619 | 1619 | } |
| 1620 | - return $tag; |
|
| 1620 | + return $tag; |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | public static function footer_js( $location = 'footer' ) { |
@@ -1,176 +1,176 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('ABSPATH') ) { |
| 3 | - die('You are not allowed to call this page directly.'); |
|
| 3 | + die('You are not allowed to call this page directly.'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmForm { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return int|boolean id on success or false on failure |
|
| 10 | - */ |
|
| 11 | - public static function create( $values ) { |
|
| 12 | - global $wpdb; |
|
| 8 | + /** |
|
| 9 | + * @return int|boolean id on success or false on failure |
|
| 10 | + */ |
|
| 11 | + public static function create( $values ) { |
|
| 12 | + global $wpdb; |
|
| 13 | 13 | |
| 14 | - $new_values = array( |
|
| 14 | + $new_values = array( |
|
| 15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 16 | - 'name' => $values['name'], |
|
| 17 | - 'description' => $values['description'], |
|
| 18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 16 | + 'name' => $values['name'], |
|
| 17 | + 'description' => $values['description'], |
|
| 18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | - ); |
|
| 22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | + ); |
|
| 26 | 26 | |
| 27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 29 | 29 | |
| 30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 33 | 33 | |
| 34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | - $new_values['options'] = serialize($options); |
|
| 34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | + $new_values['options'] = serialize($options); |
|
| 36 | 36 | |
| 37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | - // $new_values['id'] = $values['id']; |
|
| 37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | + // $new_values['id'] = $values['id']; |
|
| 39 | 39 | |
| 40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 41 | 41 | |
| 42 | - $id = $wpdb->insert_id; |
|
| 42 | + $id = $wpdb->insert_id; |
|
| 43 | 43 | |
| 44 | 44 | // Clear form caching |
| 45 | 45 | self::clear_form_cache(); |
| 46 | 46 | |
| 47 | - return $id; |
|
| 48 | - } |
|
| 47 | + return $id; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return int|boolean ID on success or false on failure |
|
| 52 | - */ |
|
| 53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | - global $wpdb; |
|
| 50 | + /** |
|
| 51 | + * @return int|boolean ID on success or false on failure |
|
| 52 | + */ |
|
| 53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | + global $wpdb; |
|
| 55 | 55 | |
| 56 | - $values = self::getOne( $id, $blog_id ); |
|
| 57 | - if ( ! $values ) { |
|
| 58 | - return false; |
|
| 59 | - } |
|
| 56 | + $values = self::getOne( $id, $blog_id ); |
|
| 57 | + if ( ! $values ) { |
|
| 58 | + return false; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
| 61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
| 62 | 62 | |
| 63 | - $new_values = array( |
|
| 63 | + $new_values = array( |
|
| 64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 65 | - 'name' => $values->name, |
|
| 66 | - 'description' => $values->description, |
|
| 67 | - 'status' => $template ? 'published' : 'draft', |
|
| 68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | - 'created_at' => current_time('mysql', 1), |
|
| 71 | - 'is_template' => $template ? 1 : 0, |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - if ( $blog_id ) { |
|
| 75 | - $new_values['status'] = 'published'; |
|
| 76 | - $new_options = maybe_unserialize($values->options); |
|
| 77 | - $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | - $new_options['copy'] = false; |
|
| 79 | - $new_values['options'] = $new_options; |
|
| 80 | - } else { |
|
| 81 | - $new_values['options'] = $values->options; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if ( is_array($new_values['options']) ) { |
|
| 85 | - $new_values['options'] = serialize($new_values['options']); |
|
| 86 | - } |
|
| 65 | + 'name' => $values->name, |
|
| 66 | + 'description' => $values->description, |
|
| 67 | + 'status' => $template ? 'published' : 'draft', |
|
| 68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | + 'created_at' => current_time('mysql', 1), |
|
| 71 | + 'is_template' => $template ? 1 : 0, |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + if ( $blog_id ) { |
|
| 75 | + $new_values['status'] = 'published'; |
|
| 76 | + $new_options = maybe_unserialize($values->options); |
|
| 77 | + $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | + $new_options['copy'] = false; |
|
| 79 | + $new_values['options'] = $new_options; |
|
| 80 | + } else { |
|
| 81 | + $new_values['options'] = $values->options; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if ( is_array($new_values['options']) ) { |
|
| 85 | + $new_values['options'] = serialize($new_values['options']); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 89 | 89 | |
| 90 | - if ( $query_results ) { |
|
| 90 | + if ( $query_results ) { |
|
| 91 | 91 | // Clear form caching |
| 92 | 92 | self::clear_form_cache(); |
| 93 | 93 | |
| 94 | - $form_id = $wpdb->insert_id; |
|
| 95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 94 | + $form_id = $wpdb->insert_id; |
|
| 95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 96 | 96 | |
| 97 | - // update form settings after fields are created |
|
| 97 | + // update form settings after fields are created |
|
| 98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
| 99 | - return $form_id; |
|
| 100 | - } |
|
| 99 | + return $form_id; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return false; |
|
| 103 | - } |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | public static function after_duplicate( $form_id, $values ) { |
| 106 | 106 | $new_opts = maybe_unserialize( $values['options'] ); |
| 107 | 107 | $values['options'] = $new_opts; |
| 108 | 108 | |
| 109 | - if ( isset($new_opts['success_msg']) ) { |
|
| 110 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 111 | - } |
|
| 109 | + if ( isset($new_opts['success_msg']) ) { |
|
| 110 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 113 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 114 | 114 | |
| 115 | - if ( $new_opts != $values['options'] ) { |
|
| 116 | - global $wpdb; |
|
| 115 | + if ( $new_opts != $values['options'] ) { |
|
| 116 | + global $wpdb; |
|
| 117 | 117 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
| 118 | - } |
|
| 119 | - } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @return int|boolean |
|
| 123 | - */ |
|
| 124 | - public static function update( $id, $values, $create_link = false ) { |
|
| 125 | - global $wpdb; |
|
| 121 | + /** |
|
| 122 | + * @return int|boolean |
|
| 123 | + */ |
|
| 124 | + public static function update( $id, $values, $create_link = false ) { |
|
| 125 | + global $wpdb; |
|
| 126 | 126 | |
| 127 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 128 | - $values['status'] = 'published'; |
|
| 129 | - } |
|
| 127 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 128 | + $values['status'] = 'published'; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - if ( isset($values['form_key']) ) { |
|
| 131 | + if ( isset($values['form_key']) ) { |
|
| 132 | 132 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 133 | - } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
| 136 | 136 | |
| 137 | - $new_values = self::set_update_options( array(), $values); |
|
| 137 | + $new_values = self::set_update_options( array(), $values); |
|
| 138 | 138 | |
| 139 | - foreach ( $values as $value_key => $value ) { |
|
| 139 | + foreach ( $values as $value_key => $value ) { |
|
| 140 | 140 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
| 141 | 141 | $new_values[ $value_key ] = $value; |
| 142 | - } |
|
| 143 | - } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 146 | - $new_values['status'] = $values['new_status']; |
|
| 147 | - } |
|
| 145 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 146 | + $new_values['status'] = $values['new_status']; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - if ( ! empty( $new_values ) ) { |
|
| 149 | + if ( ! empty( $new_values ) ) { |
|
| 150 | 150 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
| 151 | - if ( $query_results ) { |
|
| 151 | + if ( $query_results ) { |
|
| 152 | 152 | self::clear_form_cache(); |
| 153 | - } |
|
| 154 | - } else { |
|
| 155 | - $query_results = true; |
|
| 156 | - } |
|
| 157 | - unset($new_values); |
|
| 153 | + } |
|
| 154 | + } else { |
|
| 155 | + $query_results = true; |
|
| 156 | + } |
|
| 157 | + unset($new_values); |
|
| 158 | 158 | |
| 159 | - $values = self::update_fields($id, $values); |
|
| 159 | + $values = self::update_fields($id, $values); |
|
| 160 | 160 | |
| 161 | 161 | do_action( 'frm_update_form', $id, $values ); |
| 162 | 162 | do_action( 'frm_update_form_' . $id, $values ); |
| 163 | 163 | |
| 164 | - return $query_results; |
|
| 165 | - } |
|
| 164 | + return $query_results; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * @return array |
|
| 169 | - */ |
|
| 167 | + /** |
|
| 168 | + * @return array |
|
| 169 | + */ |
|
| 170 | 170 | public static function set_update_options( $new_values, $values ) { |
| 171 | - if ( ! isset($values['options']) ) { |
|
| 172 | - return $new_values; |
|
| 173 | - } |
|
| 171 | + if ( ! isset($values['options']) ) { |
|
| 172 | + return $new_values; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 176 | 176 | FrmFormsHelper::fill_form_options( $options, $values ); |
@@ -184,47 +184,47 @@ discard block |
||
| 184 | 184 | $new_values['options'] = serialize( $options ); |
| 185 | 185 | |
| 186 | 186 | return $new_values; |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * @return array |
|
| 192 | - */ |
|
| 190 | + /** |
|
| 191 | + * @return array |
|
| 192 | + */ |
|
| 193 | 193 | public static function update_fields( $id, $values ) { |
| 194 | 194 | |
| 195 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 196 | - return $values; |
|
| 197 | - } |
|
| 195 | + if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 196 | + return $values; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 200 | - if ( empty($all_fields) ) { |
|
| 201 | - return $values; |
|
| 202 | - } |
|
| 199 | + $all_fields = FrmField::get_all_for_form($id); |
|
| 200 | + if ( empty($all_fields) ) { |
|
| 201 | + return $values; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - if ( ! isset($values['item_meta']) ) { |
|
| 205 | - $values['item_meta'] = array(); |
|
| 206 | - } |
|
| 204 | + if ( ! isset($values['item_meta']) ) { |
|
| 205 | + $values['item_meta'] = array(); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - $field_array = array(); |
|
| 209 | - $existing_keys = array_keys($values['item_meta']); |
|
| 210 | - foreach ( $all_fields as $fid ) { |
|
| 211 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 208 | + $field_array = array(); |
|
| 209 | + $existing_keys = array_keys($values['item_meta']); |
|
| 210 | + foreach ( $all_fields as $fid ) { |
|
| 211 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 212 | 212 | $values['item_meta'][ $fid->id ] = ''; |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | $field_array[ $fid->id ] = $fid; |
| 215 | - } |
|
| 216 | - unset($all_fields); |
|
| 215 | + } |
|
| 216 | + unset($all_fields); |
|
| 217 | 217 | |
| 218 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 218 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 219 | 219 | if ( isset( $field_array[ $field_id ] ) ) { |
| 220 | 220 | $field = $field_array[ $field_id ]; |
| 221 | - } else { |
|
| 222 | - $field = FrmField::getOne($field_id); |
|
| 223 | - } |
|
| 221 | + } else { |
|
| 222 | + $field = FrmField::getOne($field_id); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - if ( ! $field ) { |
|
| 226 | - continue; |
|
| 227 | - } |
|
| 225 | + if ( ! $field ) { |
|
| 226 | + continue; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | 229 | $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
| 230 | 230 | if ( $is_settings_page ) { |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | if ( is_string( $field->field_options[ $opt ] ) ) { |
| 246 | 246 | $field->field_options[ $opt ] = trim( sanitize_text_field( $field->field_options[ $opt ] ) ); |
| 247 | 247 | } |
| 248 | - } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 250 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 251 | 251 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
| 252 | 252 | |
| 253 | 253 | $new_field = array( |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | FrmField::update( $field_id, $new_field ); |
| 261 | 261 | |
| 262 | - FrmField::delete_form_transient($field->form_id); |
|
| 263 | - } |
|
| 262 | + FrmField::delete_form_transient($field->form_id); |
|
| 263 | + } |
|
| 264 | 264 | self::clear_form_cache(); |
| 265 | 265 | |
| 266 | - return $values; |
|
| 267 | - } |
|
| 266 | + return $values; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | 270 | * updating the settings page |
@@ -301,23 +301,23 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - /** |
|
| 305 | - * @param string $status |
|
| 306 | - * @return int|boolean |
|
| 307 | - */ |
|
| 304 | + /** |
|
| 305 | + * @param string $status |
|
| 306 | + * @return int|boolean |
|
| 307 | + */ |
|
| 308 | 308 | public static function set_status( $id, $status ) { |
| 309 | - if ( 'trash' == $status ) { |
|
| 310 | - return self::trash($id); |
|
| 311 | - } |
|
| 309 | + if ( 'trash' == $status ) { |
|
| 310 | + return self::trash($id); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | $statuses = array( 'published', 'draft', 'trash' ); |
| 314 | - if ( ! in_array( $status, $statuses ) ) { |
|
| 315 | - return false; |
|
| 316 | - } |
|
| 314 | + if ( ! in_array( $status, $statuses ) ) { |
|
| 315 | + return false; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - global $wpdb; |
|
| 318 | + global $wpdb; |
|
| 319 | 319 | |
| 320 | - if ( is_array($id) ) { |
|
| 320 | + if ( is_array($id) ) { |
|
| 321 | 321 | $where = array( |
| 322 | 322 | 'id' => $id, |
| 323 | 323 | 'parent_form_id' => $id, |
@@ -327,33 +327,33 @@ discard block |
||
| 327 | 327 | array_unshift( $where['values'], $status ); |
| 328 | 328 | |
| 329 | 329 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
| 330 | - } else { |
|
| 330 | + } else { |
|
| 331 | 331 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
| 332 | 332 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) ); |
| 333 | - } |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - if ( $query_results ) { |
|
| 335 | + if ( $query_results ) { |
|
| 336 | 336 | self::clear_form_cache(); |
| 337 | - } |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - return $query_results; |
|
| 340 | - } |
|
| 339 | + return $query_results; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - /** |
|
| 343 | - * @return int|boolean |
|
| 344 | - */ |
|
| 342 | + /** |
|
| 343 | + * @return int|boolean |
|
| 344 | + */ |
|
| 345 | 345 | public static function trash( $id ) { |
| 346 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
| 347 | - return self::destroy( $id ); |
|
| 348 | - } |
|
| 346 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
| 347 | + return self::destroy( $id ); |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - $form = self::getOne($id); |
|
| 351 | - if ( ! $form ) { |
|
| 352 | - return false; |
|
| 353 | - } |
|
| 350 | + $form = self::getOne($id); |
|
| 351 | + if ( ! $form ) { |
|
| 352 | + return false; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - $options = $form->options; |
|
| 356 | - $options['trash_time'] = time(); |
|
| 355 | + $options = $form->options; |
|
| 356 | + $options['trash_time'] = time(); |
|
| 357 | 357 | |
| 358 | 358 | global $wpdb; |
| 359 | 359 | $query_results = $wpdb->update( |
@@ -378,50 +378,50 @@ discard block |
||
| 378 | 378 | ) |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | - if ( $query_results ) { |
|
| 381 | + if ( $query_results ) { |
|
| 382 | 382 | self::clear_form_cache(); |
| 383 | - } |
|
| 383 | + } |
|
| 384 | 384 | |
| 385 | - return $query_results; |
|
| 386 | - } |
|
| 385 | + return $query_results; |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - /** |
|
| 389 | - * @return int|boolean |
|
| 390 | - */ |
|
| 388 | + /** |
|
| 389 | + * @return int|boolean |
|
| 390 | + */ |
|
| 391 | 391 | public static function destroy( $id ) { |
| 392 | - global $wpdb; |
|
| 392 | + global $wpdb; |
|
| 393 | 393 | |
| 394 | - $form = self::getOne($id); |
|
| 395 | - if ( ! $form ) { |
|
| 396 | - return false; |
|
| 397 | - } |
|
| 394 | + $form = self::getOne($id); |
|
| 395 | + if ( ! $form ) { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 398 | 398 | $id = $form->id; |
| 399 | 399 | |
| 400 | - // Disconnect the entries from this form |
|
| 400 | + // Disconnect the entries from this form |
|
| 401 | 401 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 402 | - foreach ( $entries as $entry_id ) { |
|
| 403 | - FrmEntry::destroy($entry_id); |
|
| 404 | - unset($entry_id); |
|
| 405 | - } |
|
| 402 | + foreach ( $entries as $entry_id ) { |
|
| 403 | + FrmEntry::destroy($entry_id); |
|
| 404 | + unset($entry_id); |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | - // Disconnect the fields from this form |
|
| 407 | + // Disconnect the fields from this form |
|
| 408 | 408 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
| 409 | 409 | |
| 410 | 410 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
| 411 | - if ( $query_results ) { |
|
| 412 | - // Delete all form actions linked to this form |
|
| 413 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 414 | - $action_control->destroy($id, 'all'); |
|
| 411 | + if ( $query_results ) { |
|
| 412 | + // Delete all form actions linked to this form |
|
| 413 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 414 | + $action_control->destroy($id, 'all'); |
|
| 415 | 415 | |
| 416 | 416 | // Clear form caching |
| 417 | 417 | self::clear_form_cache(); |
| 418 | 418 | |
| 419 | 419 | do_action( 'frm_destroy_form', $id ); |
| 420 | 420 | do_action( 'frm_destroy_form_' . $id ); |
| 421 | - } |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - return $query_results; |
|
| 424 | - } |
|
| 423 | + return $query_results; |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | 426 | /** |
| 427 | 427 | * Delete trashed forms based on how long they have been trashed |
@@ -453,58 +453,58 @@ discard block |
||
| 453 | 453 | return $count; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - /** |
|
| 457 | - * @return string form name |
|
| 458 | - */ |
|
| 459 | - public static function getName( $id ) { |
|
| 456 | + /** |
|
| 457 | + * @return string form name |
|
| 458 | + */ |
|
| 459 | + public static function getName( $id ) { |
|
| 460 | 460 | $form = FrmDb::check_cache( $id, 'frm_form' ); |
| 461 | - if ( $form ) { |
|
| 462 | - $r = stripslashes($form->name); |
|
| 463 | - return $r; |
|
| 464 | - } |
|
| 461 | + if ( $form ) { |
|
| 462 | + $r = stripslashes($form->name); |
|
| 463 | + return $r; |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 467 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 468 | - $r = stripslashes($r); |
|
| 466 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 467 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 468 | + $r = stripslashes($r); |
|
| 469 | 469 | |
| 470 | - return $r; |
|
| 471 | - } |
|
| 470 | + return $r; |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - /** |
|
| 473 | + /** |
|
| 474 | 474 | * @since 3.0 |
| 475 | - * @param string $key |
|
| 476 | - * @return int form id |
|
| 477 | - */ |
|
| 475 | + * @param string $key |
|
| 476 | + * @return int form id |
|
| 477 | + */ |
|
| 478 | 478 | public static function get_id_by_key( $key ) { |
| 479 | 479 | return (int) FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
| 480 | - } |
|
| 480 | + } |
|
| 481 | 481 | |
| 482 | 482 | /** |
| 483 | 483 | * @deprecated 3.0 |
| 484 | - * @param string $key |
|
| 485 | - * @return int form id |
|
| 486 | - */ |
|
| 484 | + * @param string $key |
|
| 485 | + * @return int form id |
|
| 486 | + */ |
|
| 487 | 487 | public static function getIdByKey( $key ) { |
| 488 | 488 | _deprecated_function( __METHOD__, '3.0', 'FrmForm::get_id_by_key' ); |
| 489 | 489 | return self::get_id_by_key( $key ); |
| 490 | - } |
|
| 490 | + } |
|
| 491 | 491 | |
| 492 | - /** |
|
| 492 | + /** |
|
| 493 | 493 | * @since 3.0 |
| 494 | - * @param int $id |
|
| 495 | - * @return string form key |
|
| 496 | - */ |
|
| 494 | + * @param int $id |
|
| 495 | + * @return string form key |
|
| 496 | + */ |
|
| 497 | 497 | public static function get_key_by_id( $id ) { |
| 498 | - $id = (int) $id; |
|
| 498 | + $id = (int) $id; |
|
| 499 | 499 | $cache = FrmDb::check_cache( $id, 'frm_form' ); |
| 500 | - if ( $cache ) { |
|
| 501 | - return $cache->form_key; |
|
| 502 | - } |
|
| 500 | + if ( $cache ) { |
|
| 501 | + return $cache->form_key; |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 504 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 505 | 505 | |
| 506 | - return $key; |
|
| 507 | - } |
|
| 506 | + return $key; |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | 509 | /** |
| 510 | 510 | * @deprecated 3.0 |
@@ -525,47 +525,47 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - /** |
|
| 529 | - * @return object form |
|
| 530 | - */ |
|
| 531 | - public static function getOne( $id, $blog_id = false ) { |
|
| 532 | - global $wpdb; |
|
| 528 | + /** |
|
| 529 | + * @return object form |
|
| 530 | + */ |
|
| 531 | + public static function getOne( $id, $blog_id = false ) { |
|
| 532 | + global $wpdb; |
|
| 533 | 533 | |
| 534 | - if ( $blog_id && is_multisite() ) { |
|
| 535 | - global $wpmuBaseTablePrefix; |
|
| 534 | + if ( $blog_id && is_multisite() ) { |
|
| 535 | + global $wpmuBaseTablePrefix; |
|
| 536 | 536 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
| 537 | 537 | |
| 538 | 538 | $table_name = $prefix . 'frm_forms'; |
| 539 | - } else { |
|
| 539 | + } else { |
|
| 540 | 540 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 541 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 542 | - if ( $cache ) { |
|
| 543 | - if ( isset($cache->options) ) { |
|
| 544 | - $cache->options = maybe_unserialize($cache->options); |
|
| 545 | - } |
|
| 541 | + $cache = wp_cache_get($id, 'frm_form'); |
|
| 542 | + if ( $cache ) { |
|
| 543 | + if ( isset($cache->options) ) { |
|
| 544 | + $cache->options = maybe_unserialize($cache->options); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - return stripslashes_deep($cache); |
|
| 548 | - } |
|
| 549 | - } |
|
| 547 | + return stripslashes_deep($cache); |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - if ( is_numeric($id) ) { |
|
| 552 | - $where = array( 'id' => $id ); |
|
| 553 | - } else { |
|
| 554 | - $where = array( 'form_key' => $id ); |
|
| 555 | - } |
|
| 551 | + if ( is_numeric($id) ) { |
|
| 552 | + $where = array( 'id' => $id ); |
|
| 553 | + } else { |
|
| 554 | + $where = array( 'form_key' => $id ); |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - $results = FrmDb::get_row( $table_name, $where ); |
|
| 557 | + $results = FrmDb::get_row( $table_name, $where ); |
|
| 558 | 558 | |
| 559 | - if ( isset($results->options) ) { |
|
| 559 | + if ( isset($results->options) ) { |
|
| 560 | 560 | FrmDb::set_cache( $results->id, $results, 'frm_form' ); |
| 561 | - $results->options = maybe_unserialize($results->options); |
|
| 562 | - } |
|
| 563 | - return stripslashes_deep($results); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * @return object|array of objects |
|
| 568 | - */ |
|
| 561 | + $results->options = maybe_unserialize($results->options); |
|
| 562 | + } |
|
| 563 | + return stripslashes_deep($results); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * @return object|array of objects |
|
| 568 | + */ |
|
| 569 | 569 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
| 570 | 570 | if ( is_array( $where ) && ! empty( $where ) ) { |
| 571 | 571 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( |
@@ -592,8 +592,8 @@ discard block |
||
| 592 | 592 | $results = reset( $results ); |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - return stripslashes_deep($results); |
|
| 596 | - } |
|
| 595 | + return stripslashes_deep($results); |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | 598 | /** |
| 599 | 599 | * Get all published forms |
@@ -611,18 +611,18 @@ discard block |
||
| 611 | 611 | return $forms; |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - /** |
|
| 615 | - * @return int count of forms |
|
| 616 | - */ |
|
| 617 | - public static function get_count() { |
|
| 618 | - global $wpdb; |
|
| 614 | + /** |
|
| 615 | + * @return int count of forms |
|
| 616 | + */ |
|
| 617 | + public static function get_count() { |
|
| 618 | + global $wpdb; |
|
| 619 | 619 | |
| 620 | - $cache_key = 'frm_form_counts'; |
|
| 620 | + $cache_key = 'frm_form_counts'; |
|
| 621 | 621 | |
| 622 | - $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
| 623 | - if ( false !== $counts ) { |
|
| 624 | - return $counts; |
|
| 625 | - } |
|
| 622 | + $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
| 623 | + if ( false !== $counts ) { |
|
| 624 | + return $counts; |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | 627 | $results = (array) FrmDb::get_results( 'frm_forms', array( |
| 628 | 628 | 'or' => 1, |
@@ -631,31 +631,31 @@ discard block |
||
| 631 | 631 | ), 'status, is_template' ); |
| 632 | 632 | |
| 633 | 633 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
| 634 | - $counts = array_fill_keys( $statuses, 0 ); |
|
| 634 | + $counts = array_fill_keys( $statuses, 0 ); |
|
| 635 | 635 | |
| 636 | - foreach ( $results as $row ) { |
|
| 637 | - if ( 'trash' != $row->status ) { |
|
| 638 | - if ( $row->is_template ) { |
|
| 636 | + foreach ( $results as $row ) { |
|
| 637 | + if ( 'trash' != $row->status ) { |
|
| 638 | + if ( $row->is_template ) { |
|
| 639 | 639 | $counts['template']++; |
| 640 | - } else { |
|
| 640 | + } else { |
|
| 641 | 641 | $counts['published']++; |
| 642 | - } |
|
| 643 | - } else { |
|
| 642 | + } |
|
| 643 | + } else { |
|
| 644 | 644 | $counts['trash']++; |
| 645 | - } |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | - if ( 'draft' == $row->status ) { |
|
| 647 | + if ( 'draft' == $row->status ) { |
|
| 648 | 648 | $counts['draft']++; |
| 649 | - } |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | - unset($row); |
|
| 652 | - } |
|
| 651 | + unset($row); |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - $counts = (object) $counts; |
|
| 654 | + $counts = (object) $counts; |
|
| 655 | 655 | FrmDb::set_cache( $cache_key, $counts, 'frm_form' ); |
| 656 | 656 | |
| 657 | - return $counts; |
|
| 658 | - } |
|
| 657 | + return $counts; |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | 661 | * Clear form caching |
@@ -668,14 +668,14 @@ discard block |
||
| 668 | 668 | FrmDb::cache_delete_group( 'frm_form' ); |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - /** |
|
| 672 | - * @return array of errors |
|
| 673 | - */ |
|
| 671 | + /** |
|
| 672 | + * @return array of errors |
|
| 673 | + */ |
|
| 674 | 674 | public static function validate( $values ) { |
| 675 | - $errors = array(); |
|
| 675 | + $errors = array(); |
|
| 676 | 676 | |
| 677 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 678 | - } |
|
| 677 | + return apply_filters('frm_validate_form', $errors, $values); |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | 680 | public static function get_params( $form = null ) { |
| 681 | 681 | global $frm_vars; |
@@ -26,55 +26,55 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - /* Display in Back End */ |
|
| 30 | - public static function route() { |
|
| 29 | + /* Display in Back End */ |
|
| 30 | + public static function route() { |
|
| 31 | 31 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 32 | 32 | |
| 33 | - switch ( $action ) { |
|
| 34 | - case 'show': |
|
| 35 | - case 'destroy': |
|
| 36 | - case 'destroy_all': |
|
| 37 | - return self::$action(); |
|
| 33 | + switch ( $action ) { |
|
| 34 | + case 'show': |
|
| 35 | + case 'destroy': |
|
| 36 | + case 'destroy_all': |
|
| 37 | + return self::$action(); |
|
| 38 | 38 | |
| 39 | - default: |
|
| 40 | - do_action( 'frm_entry_action_route', $action ); |
|
| 41 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 42 | - return; |
|
| 43 | - } |
|
| 39 | + default: |
|
| 40 | + do_action( 'frm_entry_action_route', $action ); |
|
| 41 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return self::display_list(); |
|
| 46 | - } |
|
| 47 | - } |
|
| 45 | + return self::display_list(); |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 50 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 51 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 52 | - return $help; |
|
| 53 | - } |
|
| 50 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 51 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 52 | + return $help; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 56 | 56 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 57 | 57 | $show_help = ( $page == 'formidable-entries' && ( empty( $action ) || $action == 'list' ) ); |
| 58 | 58 | if ( ! $show_help ) { |
| 59 | - return $help; |
|
| 60 | - } |
|
| 59 | + return $help; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | unset( $action, $page ); |
| 63 | 63 | |
| 64 | - $screen->add_help_tab( array( |
|
| 65 | - 'id' => 'formidable-entries-tab', |
|
| 66 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 64 | + $screen->add_help_tab( array( |
|
| 65 | + 'id' => 'formidable-entries-tab', |
|
| 66 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 67 | 67 | 'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>', |
| 68 | - )); |
|
| 68 | + )); |
|
| 69 | 69 | |
| 70 | - $screen->set_help_sidebar( |
|
| 70 | + $screen->set_help_sidebar( |
|
| 71 | 71 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 72 | 72 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/knowledgebase/manage-entries-from-the-back-end/' ) ) . '" target="_blank">' . esc_html__( 'Documentation on Entries', 'formidable' ) . '</a></p>' . |
| 73 | 73 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 74 | - ); |
|
| 74 | + ); |
|
| 75 | 75 | |
| 76 | - return $help; |
|
| 77 | - } |
|
| 76 | + return $help; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Prevent the "screen options" tab from showing when |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | public static function manage_columns( $columns ) { |
| 95 | - global $frm_vars; |
|
| 95 | + global $frm_vars; |
|
| 96 | 96 | $form_id = FrmForm::get_current_form_id(); |
| 97 | 97 | |
| 98 | 98 | $columns[ $form_id . '_id' ] = 'ID'; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 111 | 111 | self::maybe_add_ip_col( $form_id, $columns ); |
| 112 | 112 | |
| 113 | - $frm_vars['cols'] = $columns; |
|
| 113 | + $frm_vars['cols'] = $columns; |
|
| 114 | 114 | |
| 115 | 115 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 116 | 116 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | 'default' => 20, |
| 120 | 120 | 'option' => 'formidable_page_formidable_entries_per_page', |
| 121 | 121 | ) ); |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - return $columns; |
|
| 125 | - } |
|
| 124 | + return $columns; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | private static function get_columns_for_form( $form_id, &$columns ) { |
| 128 | 128 | $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
@@ -171,67 +171,67 @@ discard block |
||
| 171 | 171 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 172 | 172 | $this_page_name = self::hidden_column_key(); |
| 173 | 173 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 174 | - return $check; |
|
| 175 | - } |
|
| 174 | + return $check; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | if ( empty( $prev_value ) ) { |
| 178 | 178 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - global $frm_vars; |
|
| 181 | + global $frm_vars; |
|
| 182 | 182 | //add a check so we don't create a loop |
| 183 | 183 | $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
| 184 | 184 | |
| 185 | - return $check; |
|
| 186 | - } |
|
| 185 | + return $check; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - //add hidden columns back from other forms |
|
| 188 | + //add hidden columns back from other forms |
|
| 189 | 189 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 190 | 190 | $this_page_name = self::hidden_column_key(); |
| 191 | 191 | if ( $meta_key != $this_page_name ) { |
| 192 | - return; |
|
| 193 | - } |
|
| 192 | + return; |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | 195 | global $frm_vars; |
| 196 | 196 | if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
| 197 | 197 | return; //don't continue if there's no previous value |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 201 | - //remove blank values |
|
| 202 | - if ( empty( $mv ) ) { |
|
| 203 | - unset( $meta_value[ $mk ] ); |
|
| 204 | - } |
|
| 205 | - } |
|
| 200 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 201 | + //remove blank values |
|
| 202 | + if ( empty( $mv ) ) { |
|
| 203 | + unset( $meta_value[ $mk ] ); |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | $cur_form_prefix = reset( $meta_value ); |
| 208 | 208 | $cur_form_prefix = explode( '_', $cur_form_prefix ); |
| 209 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 210 | - $save = false; |
|
| 209 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 210 | + $save = false; |
|
| 211 | 211 | |
| 212 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 212 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 213 | 213 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 214 | - //don't add blank cols or process included cols |
|
| 215 | - continue; |
|
| 216 | - } |
|
| 214 | + //don't add blank cols or process included cols |
|
| 215 | + continue; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | 218 | $form_prefix = explode( '_', $prev_hidden ); |
| 219 | - $form_prefix = $form_prefix[0]; |
|
| 220 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 221 | - //don't add back columns that are meant to be hidden |
|
| 222 | - continue; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $meta_value[] = $prev_hidden; |
|
| 226 | - $save = true; |
|
| 219 | + $form_prefix = $form_prefix[0]; |
|
| 220 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 221 | + //don't add back columns that are meant to be hidden |
|
| 222 | + continue; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $meta_value[] = $prev_hidden; |
|
| 226 | + $save = true; |
|
| 227 | 227 | unset( $form_prefix ); |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | 230 | if ( $save ) { |
| 231 | 231 | $user_id = get_current_user_id(); |
| 232 | 232 | update_user_option( $user_id, $this_page_name, $meta_value, true ); |
| 233 | - } |
|
| 234 | - } |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * @since 2.05.07 |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | public static function save_per_page( $save, $option, $value ) { |
| 255 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 256 | - $save = (int) $value; |
|
| 257 | - } |
|
| 258 | - return $save; |
|
| 259 | - } |
|
| 255 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 256 | + $save = (int) $value; |
|
| 257 | + } |
|
| 258 | + return $save; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | public static function sortable_columns() { |
| 262 | 262 | $form_id = FrmForm::get_current_form_id(); |
@@ -356,43 +356,43 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public static function display_list( $message = '', $errors = array() ) { |
| 359 | - global $wpdb, $frm_vars; |
|
| 359 | + global $wpdb, $frm_vars; |
|
| 360 | 360 | |
| 361 | 361 | $form = FrmForm::maybe_get_current_form(); |
| 362 | 362 | $params = FrmForm::get_admin_params( $form ); |
| 363 | 363 | |
| 364 | - if ( $form ) { |
|
| 365 | - $params['form'] = $form->id; |
|
| 366 | - $frm_vars['current_form'] = $form; |
|
| 364 | + if ( $form ) { |
|
| 365 | + $params['form'] = $form->id; |
|
| 366 | + $frm_vars['current_form'] = $form; |
|
| 367 | 367 | |
| 368 | 368 | self::get_delete_form_time( $form, $errors ); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 371 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 372 | 372 | |
| 373 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 373 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 374 | 374 | |
| 375 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 375 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 376 | 376 | |
| 377 | - $wp_list_table->prepare_items(); |
|
| 377 | + $wp_list_table->prepare_items(); |
|
| 378 | 378 | |
| 379 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 380 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 379 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 380 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 381 | 381 | $url = add_query_arg( 'paged', $total_pages ); |
| 382 | - if ( headers_sent() ) { |
|
| 382 | + if ( headers_sent() ) { |
|
| 383 | 383 | echo FrmAppHelper::js_redirect( $url ); |
| 384 | - } else { |
|
| 385 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 386 | - } |
|
| 387 | - die(); |
|
| 388 | - } |
|
| 384 | + } else { |
|
| 385 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 386 | + } |
|
| 387 | + die(); |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | 390 | if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
| 391 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 392 | - } |
|
| 391 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 395 | - } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | 397 | private static function get_delete_form_time( $form, &$errors ) { |
| 398 | 398 | if ( 'trash' == $form->status ) { |
@@ -402,17 +402,17 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - /* Back End CRUD */ |
|
| 405 | + /* Back End CRUD */ |
|
| 406 | 406 | public static function show( $id = 0 ) { |
| 407 | 407 | FrmAppHelper::permission_check( 'frm_view_entries' ); |
| 408 | 408 | |
| 409 | - if ( ! $id ) { |
|
| 409 | + if ( ! $id ) { |
|
| 410 | 410 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 411 | 411 | |
| 412 | - if ( ! $id ) { |
|
| 412 | + if ( ! $id ) { |
|
| 413 | 413 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 414 | - } |
|
| 415 | - } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | 417 | $entry = FrmEntry::getOne( $id, true ); |
| 418 | 418 | if ( ! $entry ) { |
@@ -428,109 +428,109 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 431 | - $to_emails = array(); |
|
| 431 | + $to_emails = array(); |
|
| 432 | 432 | $form = FrmForm::getOne( $entry->form_id ); |
| 433 | 433 | |
| 434 | 434 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 435 | - } |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - public static function destroy() { |
|
| 437 | + public static function destroy() { |
|
| 438 | 438 | FrmAppHelper::permission_check( 'frm_delete_entries' ); |
| 439 | 439 | |
| 440 | 440 | $params = FrmForm::get_admin_params(); |
| 441 | 441 | |
| 442 | 442 | if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
| 443 | 443 | self::unlink_post( $params['id'] ); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | - $message = ''; |
|
| 447 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 448 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 449 | - } |
|
| 446 | + $message = ''; |
|
| 447 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 448 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - self::display_list( $message ); |
|
| 452 | - } |
|
| 451 | + self::display_list( $message ); |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - public static function destroy_all() { |
|
| 455 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 456 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 457 | - wp_die( $frm_settings->admin_permission ); |
|
| 458 | - } |
|
| 454 | + public static function destroy_all() { |
|
| 455 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 456 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 457 | + wp_die( $frm_settings->admin_permission ); |
|
| 458 | + } |
|
| 459 | 459 | |
| 460 | - global $wpdb; |
|
| 460 | + global $wpdb; |
|
| 461 | 461 | $params = FrmForm::get_admin_params(); |
| 462 | - $message = ''; |
|
| 463 | - $errors = array(); |
|
| 464 | - $form_id = (int) $params['form']; |
|
| 462 | + $message = ''; |
|
| 463 | + $errors = array(); |
|
| 464 | + $form_id = (int) $params['form']; |
|
| 465 | 465 | |
| 466 | - if ( $form_id ) { |
|
| 467 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 466 | + if ( $form_id ) { |
|
| 467 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 468 | 468 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 469 | 469 | |
| 470 | - if ( $action ) { |
|
| 471 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 472 | - foreach ( $entry_ids as $entry_id ) { |
|
| 473 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 474 | - unset( $entry_id ); |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 479 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 480 | - if ( $results ) { |
|
| 470 | + if ( $action ) { |
|
| 471 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 472 | + foreach ( $entry_ids as $entry_id ) { |
|
| 473 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 474 | + unset( $entry_id ); |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + $wpdb->query( $wpdb->prepare( "DELETE em.* FROM {$wpdb->prefix}frm_item_metas as em INNER JOIN {$wpdb->prefix}frm_items as e on (em.item_id=e.id) and form_id=%d", $form_id ) ); |
|
| 479 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 480 | + if ( $results ) { |
|
| 481 | 481 | FrmEntry::clear_cache(); |
| 482 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 483 | - } |
|
| 484 | - } else { |
|
| 485 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 486 | - } |
|
| 482 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 483 | + } |
|
| 484 | + } else { |
|
| 485 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - self::display_list( $message, $errors ); |
|
| 489 | - } |
|
| 488 | + self::display_list( $message, $errors ); |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | 492 | * @deprecated 1.07.05 |
| 493 | 493 | */ |
| 494 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 495 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 496 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 497 | - } |
|
| 494 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 495 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 496 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | 499 | /** |
| 500 | 500 | * @deprecated 1.07.05 |
| 501 | 501 | */ |
| 502 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 503 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 504 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 505 | - } |
|
| 502 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 503 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 504 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 507 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 508 | 508 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 509 | 509 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 510 | - return; |
|
| 511 | - } |
|
| 510 | + return; |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - global $frm_vars; |
|
| 513 | + global $frm_vars; |
|
| 514 | 514 | |
| 515 | 515 | $form = FrmForm::getOne( $form_id ); |
| 516 | - if ( ! $form ) { |
|
| 517 | - return; |
|
| 518 | - } |
|
| 516 | + if ( ! $form ) { |
|
| 517 | + return; |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | 520 | $params = FrmForm::get_params( $form ); |
| 521 | 521 | |
| 522 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 523 | - $frm_vars['form_params'] = array(); |
|
| 524 | - } |
|
| 522 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 523 | + $frm_vars['form_params'] = array(); |
|
| 524 | + } |
|
| 525 | 525 | $frm_vars['form_params'][ $form->id ] = $params; |
| 526 | 526 | |
| 527 | 527 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 528 | - return; |
|
| 529 | - } |
|
| 528 | + return; |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - if ( $errors == '' && ! $ajax ) { |
|
| 531 | + if ( $errors == '' && ! $ajax ) { |
|
| 532 | 532 | $errors = FrmEntryValidate::validate( $_POST ); |
| 533 | - } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * Use this filter to add trigger actions and add errors after |
@@ -541,24 +541,24 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 543 | 543 | |
| 544 | - if ( empty( $errors ) ) { |
|
| 544 | + if ( empty( $errors ) ) { |
|
| 545 | 545 | $_POST['frm_skip_cookie'] = 1; |
| 546 | 546 | $do_success = false; |
| 547 | - if ( $params['action'] == 'create' ) { |
|
| 547 | + if ( $params['action'] == 'create' ) { |
|
| 548 | 548 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 549 | 549 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 550 | 550 | $params['id'] = $frm_vars['created_entries'][ $form_id ]['entry_id']; |
| 551 | 551 | $do_success = true; |
| 552 | - } |
|
| 553 | - } |
|
| 552 | + } |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 555 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 556 | 556 | if ( $do_success ) { |
| 557 | 557 | FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) ); |
| 558 | 558 | } |
| 559 | 559 | unset( $_POST['frm_skip_cookie'] ); |
| 560 | - } |
|
| 561 | - } |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | 564 | * Escape url entities before redirect |
@@ -572,27 +572,27 @@ discard block |
||
| 572 | 572 | return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url ); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 576 | - self::_delete_entry( $atts['id'], $form ); |
|
| 577 | - return $url; |
|
| 578 | - } |
|
| 575 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 576 | + self::_delete_entry( $atts['id'], $form ); |
|
| 577 | + return $url; |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - //Delete entry if not redirected |
|
| 581 | - public static function delete_entry_after_save( $atts ) { |
|
| 582 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 583 | - } |
|
| 580 | + //Delete entry if not redirected |
|
| 581 | + public static function delete_entry_after_save( $atts ) { |
|
| 582 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 586 | - if ( ! $form ) { |
|
| 587 | - return; |
|
| 588 | - } |
|
| 585 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 586 | + if ( ! $form ) { |
|
| 587 | + return; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - $form->options = maybe_unserialize( $form->options ); |
|
| 591 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 590 | + $form->options = maybe_unserialize( $form->options ); |
|
| 591 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 592 | 592 | self::unlink_post( $entry_id ); |
| 593 | - FrmEntry::destroy( $entry_id ); |
|
| 594 | - } |
|
| 595 | - } |
|
| 593 | + FrmEntry::destroy( $entry_id ); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | /** |
| 598 | 598 | * unlink entry from post |
@@ -664,5 +664,5 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 667 | - } |
|
| 667 | + } |
|
| 668 | 668 | } |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | return $is_white_page; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public static function load_wp_admin_style() { |
|
| 50 | - FrmAppHelper::load_font_style(); |
|
| 51 | - } |
|
| 49 | + public static function load_wp_admin_style() { |
|
| 50 | + FrmAppHelper::load_font_style(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 54 | 54 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 55 | - if ( empty( $show_nav ) || ! $form ) { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 55 | + if ( empty( $show_nav ) || ! $form ) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | FrmForm::maybe_get_form( $form ); |
| 60 | 60 | if ( ! is_object( $form ) ) { |
@@ -115,21 +115,21 @@ discard block |
||
| 115 | 115 | return $nav_items; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - // Adds a settings link to the plugins page |
|
| 119 | - public static function settings_link( $links ) { |
|
| 118 | + // Adds a settings link to the plugins page |
|
| 119 | + public static function settings_link( $links ) { |
|
| 120 | 120 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable' ) ) . '">' . __( 'Build a Form', 'formidable' ) . '</a>'; |
| 121 | - array_unshift( $links, $settings ); |
|
| 121 | + array_unshift( $links, $settings ); |
|
| 122 | 122 | |
| 123 | - return $links; |
|
| 124 | - } |
|
| 123 | + return $links; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - public static function pro_get_started_headline() { |
|
| 126 | + public static function pro_get_started_headline() { |
|
| 127 | 127 | self::maybe_show_upgrade_bar(); |
| 128 | 128 | |
| 129 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 130 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 131 | - return; |
|
| 132 | - } |
|
| 129 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 130 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | $pro_installed = is_dir( WP_PLUGIN_DIR . '/formidable-pro' ); |
| 135 | 135 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } else { |
| 145 | 145 | $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
| 146 | 146 | } |
| 147 | - ?> |
|
| 147 | + ?> |
|
| 148 | 148 | <div class="error" class="frm_previous_install"> |
| 149 | 149 | <?php |
| 150 | 150 | echo apply_filters( 'frm_pro_update_msg', |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | ?> |
| 158 | 158 | </div> |
| 159 | 159 | <?php |
| 160 | - } |
|
| 161 | - } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | private static function maybe_show_upgrade_bar() { |
| 164 | 164 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public static function admin_js() { |
|
| 290 | + public static function admin_js() { |
|
| 291 | 291 | $version = FrmAppHelper::plugin_version(); |
| 292 | 292 | FrmAppHelper::load_admin_wide_js( false ); |
| 293 | 293 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | 'bootstrap-multiselect', |
| 303 | 303 | ), $version, true ); |
| 304 | 304 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 305 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 305 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 306 | 306 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 307 | 307 | |
| 308 | 308 | // load multselect js |
@@ -314,49 +314,49 @@ discard block |
||
| 314 | 314 | global $pagenow; |
| 315 | 315 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 316 | 316 | |
| 317 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 318 | - wp_enqueue_style( 'widgets' ); |
|
| 319 | - wp_enqueue_script( 'formidable' ); |
|
| 320 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 317 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 318 | + wp_enqueue_style( 'widgets' ); |
|
| 319 | + wp_enqueue_script( 'formidable' ); |
|
| 320 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 321 | 321 | FrmAppHelper::localize_script( 'admin' ); |
| 322 | 322 | |
| 323 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 323 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 324 | 324 | if ( 'formidable-styles' !== $page ) { |
| 325 | 325 | wp_enqueue_style( 'formidable-grids' ); |
| 326 | 326 | wp_enqueue_style( 'formidable-dropzone' ); |
| 327 | 327 | add_thickbox(); |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 330 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 331 | 331 | |
| 332 | 332 | do_action( 'frm_enqueue_builder_scripts' ); |
| 333 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 334 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 335 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 333 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 334 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 335 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 336 | 336 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 337 | 337 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 338 | - if ( ! $post ) { |
|
| 339 | - return; |
|
| 340 | - } |
|
| 341 | - $post_type = $post->post_type; |
|
| 342 | - } else { |
|
| 343 | - return; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - if ( $post_type == 'frm_display' ) { |
|
| 347 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 348 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 349 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 338 | + if ( ! $post ) { |
|
| 339 | + return; |
|
| 340 | + } |
|
| 341 | + $post_type = $post->post_type; |
|
| 342 | + } else { |
|
| 343 | + return; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + if ( $post_type == 'frm_display' ) { |
|
| 347 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 348 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 349 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 350 | 350 | FrmAppHelper::localize_script( 'admin' ); |
| 351 | - } |
|
| 352 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 353 | - FrmAppHelper::load_admin_wide_js(); |
|
| 354 | - } |
|
| 355 | - } |
|
| 351 | + } |
|
| 352 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 353 | + FrmAppHelper::load_admin_wide_js(); |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - public static function load_lang() { |
|
| 358 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 359 | - } |
|
| 357 | + public static function load_lang() { |
|
| 358 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Filter shortcodes in text widgets |
@@ -457,21 +457,21 @@ discard block |
||
| 457 | 457 | /** |
| 458 | 458 | * @deprecated 3.0.04 |
| 459 | 459 | */ |
| 460 | - public static function activation_install() { |
|
| 460 | + public static function activation_install() { |
|
| 461 | 461 | _deprecated_function( __METHOD__, '3.0.04', 'FrmAppController::install' ); |
| 462 | - FrmDb::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 463 | - FrmFormActionsController::actions_init(); |
|
| 464 | - self::install(); |
|
| 465 | - } |
|
| 462 | + FrmDb::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 463 | + FrmFormActionsController::actions_init(); |
|
| 464 | + self::install(); |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - public static function install( $old_db_version = false ) { |
|
| 468 | - $frmdb = new FrmMigrate(); |
|
| 469 | - $frmdb->upgrade( $old_db_version ); |
|
| 470 | - } |
|
| 467 | + public static function install( $old_db_version = false ) { |
|
| 468 | + $frmdb = new FrmMigrate(); |
|
| 469 | + $frmdb->upgrade( $old_db_version ); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - public static function uninstall() { |
|
| 472 | + public static function uninstall() { |
|
| 473 | 473 | FrmAppHelper::permission_check('administrator'); |
| 474 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 474 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 475 | 475 | |
| 476 | 476 | $frmdb = new FrmMigrate(); |
| 477 | 477 | $frmdb->uninstall(); |
@@ -480,17 +480,17 @@ discard block |
||
| 480 | 480 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 481 | 481 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 482 | 482 | |
| 483 | - wp_die(); |
|
| 484 | - } |
|
| 483 | + wp_die(); |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | - public static function drop_tables( $tables ) { |
|
| 487 | - global $wpdb; |
|
| 488 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 489 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 490 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 491 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 492 | - return $tables; |
|
| 493 | - } |
|
| 486 | + public static function drop_tables( $tables ) { |
|
| 487 | + global $wpdb; |
|
| 488 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 489 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 490 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 491 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 492 | + return $tables; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | 495 | /** |
| 496 | 496 | * Routes for wordpress pages -- we're just replacing content |
@@ -508,16 +508,16 @@ discard block |
||
| 508 | 508 | return $content; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - public static function deauthorize() { |
|
| 511 | + public static function deauthorize() { |
|
| 512 | 512 | FrmAppHelper::permission_check('frm_change_settings'); |
| 513 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 513 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 514 | 514 | |
| 515 | - delete_option( 'frmpro-credentials' ); |
|
| 516 | - delete_option( 'frmpro-authorized' ); |
|
| 517 | - delete_site_option( 'frmpro-credentials' ); |
|
| 518 | - delete_site_option( 'frmpro-authorized' ); |
|
| 519 | - wp_die(); |
|
| 520 | - } |
|
| 515 | + delete_option( 'frmpro-credentials' ); |
|
| 516 | + delete_option( 'frmpro-authorized' ); |
|
| 517 | + delete_site_option( 'frmpro-credentials' ); |
|
| 518 | + delete_site_option( 'frmpro-authorized' ); |
|
| 519 | + wp_die(); |
|
| 520 | + } |
|
| 521 | 521 | |
| 522 | 522 | public static function set_footer_text( $text ) { |
| 523 | 523 | if ( FrmAppHelper::is_formidable_admin() ) { |
@@ -537,8 +537,8 @@ discard block |
||
| 537 | 537 | /** |
| 538 | 538 | * @deprecated 1.07.05 |
| 539 | 539 | */ |
| 540 | - public static function get_form_shortcode( $atts ) { |
|
| 541 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 542 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 543 | - } |
|
| 540 | + public static function get_form_shortcode( $atts ) { |
|
| 541 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 542 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 543 | + } |
|
| 544 | 544 | } |
@@ -2,25 +2,25 @@ 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 | 17 | $values = array( |
| 18 | 18 | 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 19 | 19 | 'doing_ajax' => true, |
| 20 | 20 | ); |
| 21 | - $field_html = array(); |
|
| 21 | + $field_html = array(); |
|
| 22 | 22 | |
| 23 | - foreach ( $fields as $field ) { |
|
| 23 | + foreach ( $fields as $field ) { |
|
| 24 | 24 | $field = htmlspecialchars_decode( nl2br( $field ) ); |
| 25 | 25 | $field = json_decode( $field ); |
| 26 | 26 | if ( ! isset( $field->id ) || ! is_numeric( $field->id ) ) { |
@@ -38,19 +38,19 @@ discard block |
||
| 38 | 38 | self::load_single_field( $field, $values ); |
| 39 | 39 | $field_html[ absint( $field->id ) ] = ob_get_contents(); |
| 40 | 40 | ob_end_clean(); |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | echo json_encode( $field_html ); |
| 44 | 44 | |
| 45 | - wp_die(); |
|
| 46 | - } |
|
| 45 | + wp_die(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Create a new field with ajax |
| 50 | 50 | */ |
| 51 | - public static function create() { |
|
| 51 | + public static function create() { |
|
| 52 | 52 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 53 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 53 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 54 | 54 | |
| 55 | 55 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 56 | 56 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | // this hook will allow for multiple fields to be added at once |
| 61 | 61 | do_action( 'frm_after_field_created', $field, $form_id ); |
| 62 | 62 | |
| 63 | - wp_die(); |
|
| 64 | - } |
|
| 63 | + wp_die(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Set up and create a new field |
|
| 68 | - * |
|
| 69 | - * @param string $field_type |
|
| 70 | - * @param integer $form_id |
|
| 71 | - * @return array|bool |
|
| 72 | - */ |
|
| 66 | + /** |
|
| 67 | + * Set up and create a new field |
|
| 68 | + * |
|
| 69 | + * @param string $field_type |
|
| 70 | + * @param integer $form_id |
|
| 71 | + * @return array|bool |
|
| 72 | + */ |
|
| 73 | 73 | public static function include_new_field( $field_type, $form_id ) { |
| 74 | 74 | $values = array(); |
| 75 | 75 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -77,19 +77,19 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 80 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 80 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 81 | 81 | |
| 82 | - $field_id = FrmField::create( $field_values ); |
|
| 82 | + $field_id = FrmField::create( $field_values ); |
|
| 83 | 83 | |
| 84 | - if ( ! $field_id ) { |
|
| 85 | - return false; |
|
| 86 | - } |
|
| 84 | + if ( ! $field_id ) { |
|
| 85 | + return false; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | $field = self::get_field_array_from_id( $field_id ); |
| 89 | 89 | self::load_single_field( $field, $values, $form_id ); |
| 90 | 90 | |
| 91 | - return $field; |
|
| 92 | - } |
|
| 91 | + return $field; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | 95 | * @deprecated 3.0 |
@@ -104,29 +104,29 @@ discard block |
||
| 104 | 104 | $field = 'name'; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( empty( $id ) ) { |
|
| 107 | + if ( empty( $id ) ) { |
|
| 108 | 108 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 109 | 109 | $id = str_replace( 'field_label_', '', $id ); |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 113 | 113 | $value = trim( $value ); |
| 114 | - if ( trim( strip_tags( $value ) ) === '' ) { |
|
| 115 | - // set blank value if there is no content |
|
| 116 | - $value = ''; |
|
| 117 | - } |
|
| 114 | + if ( trim( strip_tags( $value ) ) === '' ) { |
|
| 115 | + // set blank value if there is no content |
|
| 116 | + $value = ''; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | FrmField::update( $id, array( $field => $value ) ); |
| 120 | 120 | |
| 121 | 121 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 122 | 122 | |
| 123 | 123 | echo stripslashes( wp_kses_post( $value ) ); |
| 124 | - wp_die(); |
|
| 125 | - } |
|
| 124 | + wp_die(); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - public static function update_ajax_option() { |
|
| 127 | + public static function update_ajax_option() { |
|
| 128 | 128 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 129 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 129 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 130 | 130 | |
| 131 | 131 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 132 | 132 | if ( ! $field_id ) { |
@@ -141,24 +141,24 @@ discard block |
||
| 141 | 141 | unset( $new_val ); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - FrmField::update( $field_id, array( |
|
| 145 | - 'field_options' => $field->field_options, |
|
| 144 | + FrmField::update( $field_id, array( |
|
| 145 | + 'field_options' => $field->field_options, |
|
| 146 | 146 | 'form_id' => $field->form_id, |
| 147 | - ) ); |
|
| 148 | - wp_die(); |
|
| 149 | - } |
|
| 147 | + ) ); |
|
| 148 | + wp_die(); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public static function duplicate() { |
|
| 151 | + public static function duplicate() { |
|
| 152 | 152 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 153 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 153 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 154 | 154 | |
| 155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 157 | 157 | |
| 158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
| 159 | - if ( ! $copy_field ) { |
|
| 160 | - wp_die(); |
|
| 161 | - } |
|
| 159 | + if ( ! $copy_field ) { |
|
| 160 | + wp_die(); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | self::load_single_field( $field_id, $values ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - wp_die(); |
|
| 176 | - } |
|
| 175 | + wp_die(); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | * Load a single field in the form builder along with all needed variables |
@@ -264,21 +264,21 @@ discard block |
||
| 264 | 264 | return $li_classes; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - public static function destroy() { |
|
| 267 | + public static function destroy() { |
|
| 268 | 268 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 269 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 269 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 270 | 270 | |
| 271 | 271 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 272 | 272 | FrmField::destroy( $field_id ); |
| 273 | - wp_die(); |
|
| 274 | - } |
|
| 273 | + wp_die(); |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /* Field Options */ |
|
| 276 | + /* Field Options */ |
|
| 277 | 277 | |
| 278 | - //Add Single Option or Other Option |
|
| 279 | - public static function add_option() { |
|
| 278 | + //Add Single Option or Other Option |
|
| 279 | + public static function add_option() { |
|
| 280 | 280 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 281 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 281 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 282 | 282 | |
| 283 | 283 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 284 | 284 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
@@ -303,67 +303,67 @@ discard block |
||
| 303 | 303 | FrmFieldsHelper::show_single_option( $field ); |
| 304 | 304 | |
| 305 | 305 | wp_die(); |
| 306 | - } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * @deprecated 2.3 |
| 310 | 310 | */ |
| 311 | - public static function edit_option() { |
|
| 311 | + public static function edit_option() { |
|
| 312 | 312 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | /** |
| 316 | 316 | * @deprecated 2.3 |
| 317 | 317 | */ |
| 318 | - public static function delete_option() { |
|
| 318 | + public static function delete_option() { |
|
| 319 | 319 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - public static function import_choices() { |
|
| 323 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 322 | + public static function import_choices() { |
|
| 323 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 324 | 324 | |
| 325 | 325 | $field_id = absint( $_REQUEST['field_id'] ); |
| 326 | 326 | |
| 327 | - global $current_screen, $hook_suffix; |
|
| 327 | + global $current_screen, $hook_suffix; |
|
| 328 | 328 | |
| 329 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 330 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 331 | - $hook_suffix = ''; |
|
| 332 | - set_current_screen(); |
|
| 333 | - } |
|
| 329 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 330 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 331 | + $hook_suffix = ''; |
|
| 332 | + set_current_screen(); |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 336 | - register_admin_color_schemes(); |
|
| 337 | - } |
|
| 335 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 336 | + register_admin_color_schemes(); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | $hook_suffix = ''; |
| 340 | 340 | $admin_body_class = ''; |
| 341 | 341 | |
| 342 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 343 | - $admin_body_class .= ' folded'; |
|
| 344 | - } |
|
| 342 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 343 | + $admin_body_class .= ' folded'; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 347 | - $admin_body_class .= ' admin-bar'; |
|
| 348 | - } |
|
| 346 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 347 | + $admin_body_class .= ' admin-bar'; |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - if ( is_rtl() ) { |
|
| 351 | - $admin_body_class .= ' rtl'; |
|
| 352 | - } |
|
| 350 | + if ( is_rtl() ) { |
|
| 351 | + $admin_body_class .= ' rtl'; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 355 | - $prepop = array(); |
|
| 354 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 355 | + $prepop = array(); |
|
| 356 | 356 | FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
| 357 | 357 | |
| 358 | 358 | $field = FrmField::getOne( $field_id ); |
| 359 | 359 | |
| 360 | - wp_enqueue_script( 'utils' ); |
|
| 360 | + wp_enqueue_script( 'utils' ); |
|
| 361 | 361 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 362 | - FrmAppHelper::load_admin_wide_js(); |
|
| 362 | + FrmAppHelper::load_admin_wide_js(); |
|
| 363 | 363 | |
| 364 | 364 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 365 | - wp_die(); |
|
| 366 | - } |
|
| 365 | + wp_die(); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | public static function import_options() { |
| 369 | 369 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | $field = FrmField::getOne( $field_id ); |
| 378 | 378 | |
| 379 | 379 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 380 | - return; |
|
| 381 | - } |
|
| 380 | + return; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | 383 | $field = FrmFieldsHelper::setup_edit_vars( $field ); |
| 384 | 384 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
@@ -401,10 +401,10 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - //Keep other options after bulk update |
|
| 405 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 406 | - $other_array = array(); |
|
| 407 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 404 | + //Keep other options after bulk update |
|
| 405 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 406 | + $other_array = array(); |
|
| 407 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 408 | 408 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 409 | 409 | $other_array[ $opt_key ] = $opt; |
| 410 | 410 | } |
@@ -415,36 +415,36 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $field['options'] = $opts; |
|
| 418 | + $field['options'] = $opts; |
|
| 419 | 419 | |
| 420 | 420 | FrmFieldsHelper::show_single_option( $field ); |
| 421 | 421 | |
| 422 | - wp_die(); |
|
| 423 | - } |
|
| 422 | + wp_die(); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - public static function update_order() { |
|
| 425 | + public static function update_order() { |
|
| 426 | 426 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 427 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 427 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 428 | 428 | |
| 429 | 429 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 430 | 430 | foreach ( (array) $fields as $position => $item ) { |
| 431 | 431 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 432 | 432 | } |
| 433 | - wp_die(); |
|
| 434 | - } |
|
| 433 | + wp_die(); |
|
| 434 | + } |
|
| 435 | 435 | |
| 436 | 436 | public static function change_type( $type ) { |
| 437 | - $type_switch = array( |
|
| 438 | - 'scale' => 'radio', |
|
| 437 | + $type_switch = array( |
|
| 438 | + 'scale' => 'radio', |
|
| 439 | 439 | 'star' => 'radio', |
| 440 | - '10radio' => 'radio', |
|
| 441 | - 'rte' => 'textarea', |
|
| 442 | - 'website' => 'url', |
|
| 440 | + '10radio' => 'radio', |
|
| 441 | + 'rte' => 'textarea', |
|
| 442 | + 'website' => 'url', |
|
| 443 | 443 | 'image' => 'url', |
| 444 | - ); |
|
| 445 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 446 | - $type = $type_switch[ $type ]; |
|
| 447 | - } |
|
| 444 | + ); |
|
| 445 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 446 | + $type = $type_switch[ $type ]; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | 449 | $pro_fields = FrmField::pro_field_selection(); |
| 450 | 450 | $types = array_keys( $pro_fields ); |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | $type = 'text'; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - return $type; |
|
| 456 | - } |
|
| 455 | + return $type; |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | 459 | * @param array $settings |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | return apply_filters( 'frm_display_field_options', $settings ); |
| 471 | - } |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | /** |
| 474 | 474 | * Display the format option |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/value-format.php' ); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - public static function input_html( $field, $echo = true ) { |
|
| 484 | - $class = array(); //$field['type']; |
|
| 483 | + public static function input_html( $field, $echo = true ) { |
|
| 484 | + $class = array(); //$field['type']; |
|
| 485 | 485 | self::add_input_classes( $field, $class ); |
| 486 | 486 | |
| 487 | 487 | $add_html = array(); |
@@ -500,85 +500,85 @@ discard block |
||
| 500 | 500 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 501 | 501 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 502 | 502 | |
| 503 | - if ( $echo ) { |
|
| 504 | - echo $add_html; |
|
| 505 | - } |
|
| 503 | + if ( $echo ) { |
|
| 504 | + echo $add_html; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - return $add_html; |
|
| 508 | - } |
|
| 507 | + return $add_html; |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | 510 | private static function add_input_classes( $field, array &$class ) { |
| 511 | 511 | if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
| 512 | 512 | $class[] = $field['input_class']; |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 516 | - return; |
|
| 517 | - } |
|
| 515 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 516 | + return; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | 519 | if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
| 520 | 520 | $class[] = 'auto_width'; |
| 521 | 521 | } |
| 522 | - } |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | private static function add_html_size( $field, array &$add_html ) { |
| 525 | 525 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 526 | - return; |
|
| 527 | - } |
|
| 526 | + return; |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 530 | - return; |
|
| 531 | - } |
|
| 529 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 530 | + return; |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | 533 | if ( is_numeric( $field['size'] ) ) { |
| 534 | 534 | $field['size'] .= 'px'; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | $important = apply_filters( 'frm_use_important_width', 1, $field ); |
| 538 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 538 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 539 | 539 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 540 | 540 | |
| 541 | 541 | self::add_html_cols( $field, $add_html ); |
| 542 | - } |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | 544 | private static function add_html_cols( $field, array &$add_html ) { |
| 545 | 545 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 546 | - return; |
|
| 547 | - } |
|
| 546 | + return; |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | - // convert to cols for textareas |
|
| 550 | - $calc = array( |
|
| 551 | - '' => 9, |
|
| 552 | - 'px' => 9, |
|
| 553 | - 'rem' => 0.444, |
|
| 554 | - 'em' => 0.544, |
|
| 555 | - ); |
|
| 549 | + // convert to cols for textareas |
|
| 550 | + $calc = array( |
|
| 551 | + '' => 9, |
|
| 552 | + 'px' => 9, |
|
| 553 | + 'rem' => 0.444, |
|
| 554 | + 'em' => 0.544, |
|
| 555 | + ); |
|
| 556 | 556 | |
| 557 | 557 | // include "col" for valid html |
| 558 | 558 | $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
| 559 | 559 | |
| 560 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 561 | - return; |
|
| 562 | - } |
|
| 560 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 561 | + return; |
|
| 562 | + } |
|
| 563 | 563 | |
| 564 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 564 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 565 | 565 | |
| 566 | 566 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 567 | - } |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | 569 | private static function add_html_length( $field, array &$add_html ) { |
| 570 | - // check for max setting and if this field accepts maxlength |
|
| 570 | + // check for max setting and if this field accepts maxlength |
|
| 571 | 571 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 572 | - return; |
|
| 573 | - } |
|
| 572 | + return; |
|
| 573 | + } |
|
| 574 | 574 | |
| 575 | 575 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 576 | - // don't load on form builder page |
|
| 577 | - return; |
|
| 578 | - } |
|
| 576 | + // don't load on form builder page |
|
| 577 | + return; |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 581 | - } |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 584 | 584 | if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -680,27 +680,27 @@ discard block |
||
| 680 | 680 | } |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 684 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 685 | - return; |
|
| 686 | - } |
|
| 683 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 684 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 685 | + return; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 689 | - if ( 'opt' === $k ) { |
|
| 690 | - continue; |
|
| 691 | - } |
|
| 688 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 689 | + if ( 'opt' === $k ) { |
|
| 690 | + continue; |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | 693 | if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
| 694 | - $add_html[] = $v; |
|
| 695 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 694 | + $add_html[] = $v; |
|
| 695 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 696 | 696 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 697 | - } else { |
|
| 697 | + } else { |
|
| 698 | 698 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 699 | - } |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | 701 | unset( $k, $v ); |
| 702 | - } |
|
| 703 | - } |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | 705 | /** |
| 706 | 706 | * Add pattern attribute |
@@ -724,16 +724,16 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 728 | - if ( is_array( $opt ) ) { |
|
| 729 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 730 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 731 | - } else { |
|
| 732 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 733 | - } |
|
| 734 | - } |
|
| 735 | - return $opt; |
|
| 736 | - } |
|
| 727 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 728 | + if ( is_array( $opt ) ) { |
|
| 729 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 730 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 731 | + } else { |
|
| 732 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 733 | + } |
|
| 734 | + } |
|
| 735 | + return $opt; |
|
| 736 | + } |
|
| 737 | 737 | |
| 738 | 738 | public static function check_label( $opt ) { |
| 739 | 739 | if ( is_array( $opt ) ) { |
@@ -13,50 +13,50 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.0.06'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public static function plugin_folder() { |
|
| 27 | - return basename(self::plugin_path()); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public static function plugin_path() { |
|
| 31 | - return dirname(dirname(dirname(__FILE__))); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 16 | + /** |
|
| 17 | + * @since 1.07.02 |
|
| 18 | + * |
|
| 19 | + * @param none |
|
| 20 | + * @return string The version of this plugin |
|
| 21 | + */ |
|
| 22 | + public static function plugin_version() { |
|
| 23 | + return self::$plug_version; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public static function plugin_folder() { |
|
| 27 | + return basename(self::plugin_path()); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public static function plugin_path() { |
|
| 31 | + return dirname(dirname(dirname(__FILE__))); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public static function plugin_url() { |
|
| 35 | + //prevously FRM_URL constant |
|
| 36 | 36 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public static function relative_plugin_url() { |
| 40 | 40 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string Site URL |
|
| 45 | - */ |
|
| 46 | - public static function site_url() { |
|
| 47 | - return site_url(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Get the name of this site |
|
| 52 | - * Used for [sitename] shortcode |
|
| 53 | - * |
|
| 54 | - * @since 2.0 |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public static function site_name() { |
|
| 58 | - return get_option('blogname'); |
|
| 59 | - } |
|
| 43 | + /** |
|
| 44 | + * @return string Site URL |
|
| 45 | + */ |
|
| 46 | + public static function site_url() { |
|
| 47 | + return site_url(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Get the name of this site |
|
| 52 | + * Used for [sitename] shortcode |
|
| 53 | + * |
|
| 54 | + * @since 2.0 |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public static function site_name() { |
|
| 58 | + return get_option('blogname'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | public static function make_affiliate_url( $url ) { |
| 62 | 62 | $affiliate_id = self::get_affiliate(); |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get the Formidable settings |
|
| 76 | - * |
|
| 77 | - * @since 2.0 |
|
| 78 | - * |
|
| 79 | - * @param None |
|
| 80 | - * @return FrmSettings $frm_setings |
|
| 81 | - */ |
|
| 82 | - public static function get_settings() { |
|
| 83 | - global $frm_settings; |
|
| 84 | - if ( empty($frm_settings) ) { |
|
| 85 | - $frm_settings = new FrmSettings(); |
|
| 86 | - } |
|
| 87 | - return $frm_settings; |
|
| 88 | - } |
|
| 74 | + /** |
|
| 75 | + * Get the Formidable settings |
|
| 76 | + * |
|
| 77 | + * @since 2.0 |
|
| 78 | + * |
|
| 79 | + * @param None |
|
| 80 | + * @return FrmSettings $frm_setings |
|
| 81 | + */ |
|
| 82 | + public static function get_settings() { |
|
| 83 | + global $frm_settings; |
|
| 84 | + if ( empty($frm_settings) ) { |
|
| 85 | + $frm_settings = new FrmSettings(); |
|
| 86 | + } |
|
| 87 | + return $frm_settings; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | public static function get_menu_name() { |
| 91 | 91 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | return ! $frm_settings->no_ips; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public static function pro_is_installed() { |
|
| 104 | - return apply_filters('frm_pro_installed', false); |
|
| 105 | - } |
|
| 103 | + public static function pro_is_installed() { |
|
| 104 | + return apply_filters('frm_pro_installed', false); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | public static function is_formidable_admin() { |
| 108 | 108 | $page = self::simple_get( 'page', 'sanitize_title' ); |
@@ -119,50 +119,50 @@ discard block |
||
| 119 | 119 | return $is_formidable; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Check for certain page in Formidable settings |
|
| 124 | - * |
|
| 125 | - * @since 2.0 |
|
| 126 | - * |
|
| 127 | - * @param string $page The name of the page to check |
|
| 128 | - * @return boolean |
|
| 129 | - */ |
|
| 122 | + /** |
|
| 123 | + * Check for certain page in Formidable settings |
|
| 124 | + * |
|
| 125 | + * @since 2.0 |
|
| 126 | + * |
|
| 127 | + * @param string $page The name of the page to check |
|
| 128 | + * @return boolean |
|
| 129 | + */ |
|
| 130 | 130 | public static function is_admin_page( $page = 'formidable' ) { |
| 131 | - global $pagenow; |
|
| 131 | + global $pagenow; |
|
| 132 | 132 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 133 | - if ( $pagenow ) { |
|
| 133 | + if ( $pagenow ) { |
|
| 134 | 134 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 135 | 135 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | return is_admin() && $get_page == $page; |
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Check for the form preview page |
|
| 143 | - * |
|
| 144 | - * @since 2.0 |
|
| 145 | - * |
|
| 146 | - * @param None |
|
| 147 | - * @return boolean |
|
| 148 | - */ |
|
| 149 | - public static function is_preview_page() { |
|
| 150 | - global $pagenow; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Check for the form preview page |
|
| 143 | + * |
|
| 144 | + * @since 2.0 |
|
| 145 | + * |
|
| 146 | + * @param None |
|
| 147 | + * @return boolean |
|
| 148 | + */ |
|
| 149 | + public static function is_preview_page() { |
|
| 150 | + global $pagenow; |
|
| 151 | 151 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 152 | 152 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Check for ajax except the form preview page |
|
| 157 | - * |
|
| 158 | - * @since 2.0 |
|
| 159 | - * |
|
| 160 | - * @param None |
|
| 161 | - * @return boolean |
|
| 162 | - */ |
|
| 163 | - public static function doing_ajax() { |
|
| 164 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | - } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Check for ajax except the form preview page |
|
| 157 | + * |
|
| 158 | + * @since 2.0 |
|
| 159 | + * |
|
| 160 | + * @param None |
|
| 161 | + * @return boolean |
|
| 162 | + */ |
|
| 163 | + public static function doing_ajax() { |
|
| 164 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | public static function js_suffix() { |
| 168 | 168 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -189,81 +189,81 @@ discard block |
||
| 189 | 189 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Check if on an admin page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function is_admin() { |
|
| 201 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Check if value contains blank value or empty array |
|
| 206 | - * |
|
| 207 | - * @since 2.0 |
|
| 208 | - * @param mixed $value - value to check |
|
| 192 | + /** |
|
| 193 | + * Check if on an admin page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function is_admin() { |
|
| 201 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Check if value contains blank value or empty array |
|
| 206 | + * |
|
| 207 | + * @since 2.0 |
|
| 208 | + * @param mixed $value - value to check |
|
| 209 | 209 | * @param string |
| 210 | - * @return boolean |
|
| 211 | - */ |
|
| 212 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | - return ! self::is_empty_value( $value, $empty ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Get any value from the $_SERVER |
|
| 222 | - * |
|
| 223 | - * @since 2.0 |
|
| 224 | - * @param string $value |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 210 | + * @return boolean |
|
| 211 | + */ |
|
| 212 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | + return ! self::is_empty_value( $value, $empty ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Get any value from the $_SERVER |
|
| 222 | + * |
|
| 223 | + * @since 2.0 |
|
| 224 | + * @param string $value |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | 227 | public static function get_server_value( $value ) { |
| 228 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Check for the IP address in several places |
|
| 233 | - * Used by [ip] shortcode |
|
| 234 | - * |
|
| 235 | - * @return string The IP address of the current user |
|
| 236 | - */ |
|
| 237 | - public static function get_ip_address() { |
|
| 228 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Check for the IP address in several places |
|
| 233 | + * Used by [ip] shortcode |
|
| 234 | + * |
|
| 235 | + * @return string The IP address of the current user |
|
| 236 | + */ |
|
| 237 | + public static function get_ip_address() { |
|
| 238 | 238 | $ip = ''; |
| 239 | 239 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 240 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | - continue; |
|
| 242 | - } |
|
| 240 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | - $ip = trim($ip); // just to be safe |
|
| 244 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | + $ip = trim($ip); // just to be safe |
|
| 246 | 246 | |
| 247 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | - return sanitize_text_field( $ip ); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 247 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | + return sanitize_text_field( $ip ); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | return sanitize_text_field( $ip ); |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | - if ( strpos($param, '[') ) { |
|
| 258 | - $params = explode('[', $param); |
|
| 259 | - $param = $params[0]; |
|
| 260 | - } |
|
| 256 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | + if ( strpos($param, '[') ) { |
|
| 258 | + $params = explode('[', $param); |
|
| 259 | + $param = $params[0]; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | if ( $src == 'get' ) { |
| 263 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | - } |
|
| 263 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | + } |
|
| 267 | 267 | self::sanitize_value( $sanitize, $value ); |
| 268 | 268 | } else { |
| 269 | 269 | $value = self::get_simple_request( array( |
@@ -275,18 +275,18 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 278 | - foreach ( $params as $k => $p ) { |
|
| 279 | - if ( ! $k || ! is_array($value) ) { |
|
| 280 | - continue; |
|
| 281 | - } |
|
| 278 | + foreach ( $params as $k => $p ) { |
|
| 279 | + if ( ! $k || ! is_array($value) ) { |
|
| 280 | + continue; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $p = trim($p, ']'); |
|
| 284 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | - } |
|
| 286 | - } |
|
| 283 | + $p = trim($p, ']'); |
|
| 284 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - return $value; |
|
| 289 | - } |
|
| 288 | + return $value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 292 | 292 | return self::get_simple_request( array( |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | - * |
|
| 355 | - * @since 2.0.8 |
|
| 356 | - * @param string $value |
|
| 357 | - * @return string $value |
|
| 358 | - */ |
|
| 353 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | + * |
|
| 355 | + * @since 2.0.8 |
|
| 356 | + * @param string $value |
|
| 357 | + * @return string $value |
|
| 358 | + */ |
|
| 359 | 359 | public static function preserve_backslashes( $value ) { |
| 360 | 360 | // If backslashes have already been added, don't add them again |
| 361 | 361 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -377,14 +377,14 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | - $temp_values = $values; |
|
| 382 | - foreach ( $temp_values as $k => $val ) { |
|
| 383 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 380 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | + $temp_values = $values; |
|
| 382 | + foreach ( $temp_values as $k => $val ) { |
|
| 383 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 384 | 384 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | public static function sanitize_array( &$values ) { |
| 390 | 390 | $temp_values = $values; |
@@ -512,39 +512,39 @@ discard block |
||
| 512 | 512 | ); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - /** |
|
| 516 | - * Used when switching the action for a bulk action |
|
| 517 | - * @since 2.0 |
|
| 518 | - */ |
|
| 519 | - public static function remove_get_action() { |
|
| 520 | - if ( ! isset($_GET) ) { |
|
| 521 | - return; |
|
| 522 | - } |
|
| 515 | + /** |
|
| 516 | + * Used when switching the action for a bulk action |
|
| 517 | + * @since 2.0 |
|
| 518 | + */ |
|
| 519 | + public static function remove_get_action() { |
|
| 520 | + if ( ! isset($_GET) ) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 525 | - if ( ! empty( $new_action ) ) { |
|
| 524 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 525 | + if ( ! empty( $new_action ) ) { |
|
| 526 | 526 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 527 | - } |
|
| 528 | - } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - /** |
|
| 531 | - * Check the WP query for a parameter |
|
| 532 | - * |
|
| 533 | - * @since 2.0 |
|
| 534 | - * @return string|array |
|
| 535 | - */ |
|
| 536 | - public static function get_query_var( $value, $param ) { |
|
| 537 | - if ( $value != '' ) { |
|
| 538 | - return $value; |
|
| 539 | - } |
|
| 530 | + /** |
|
| 531 | + * Check the WP query for a parameter |
|
| 532 | + * |
|
| 533 | + * @since 2.0 |
|
| 534 | + * @return string|array |
|
| 535 | + */ |
|
| 536 | + public static function get_query_var( $value, $param ) { |
|
| 537 | + if ( $value != '' ) { |
|
| 538 | + return $value; |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - global $wp_query; |
|
| 542 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 543 | - $value = $wp_query->query_vars[ $param ]; |
|
| 544 | - } |
|
| 541 | + global $wp_query; |
|
| 542 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 543 | + $value = $wp_query->query_vars[ $param ]; |
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - return $value; |
|
| 547 | - } |
|
| 546 | + return $value; |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * @since 3.0 |
@@ -566,16 +566,16 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - /** |
|
| 570 | - * @param string $type |
|
| 571 | - */ |
|
| 572 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 573 | - // only load the form hooks once |
|
| 569 | + /** |
|
| 570 | + * @param string $type |
|
| 571 | + */ |
|
| 572 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 573 | + // only load the form hooks once |
|
| 574 | 574 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 575 | - if ( ! $hooks_loaded ) { |
|
| 575 | + if ( ! $hooks_loaded ) { |
|
| 576 | 576 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 577 | - } |
|
| 578 | - } |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | 581 | * Save all front-end js scripts into a single file |
@@ -597,28 +597,28 @@ discard block |
||
| 597 | 597 | $new_file->combine_files( $files ); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - /** |
|
| 601 | - * Check a value from a shortcode to see if true or false. |
|
| 602 | - * True when value is 1, true, 'true', 'yes' |
|
| 603 | - * |
|
| 604 | - * @since 1.07.10 |
|
| 605 | - * |
|
| 606 | - * @param string $value The value to compare |
|
| 607 | - * @return boolean True or False |
|
| 608 | - */ |
|
| 600 | + /** |
|
| 601 | + * Check a value from a shortcode to see if true or false. |
|
| 602 | + * True when value is 1, true, 'true', 'yes' |
|
| 603 | + * |
|
| 604 | + * @since 1.07.10 |
|
| 605 | + * |
|
| 606 | + * @param string $value The value to compare |
|
| 607 | + * @return boolean True or False |
|
| 608 | + */ |
|
| 609 | 609 | public static function is_true( $value ) { |
| 610 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 611 | - } |
|
| 610 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - /** |
|
| 614 | - * Used to filter shortcode in text widgets |
|
| 613 | + /** |
|
| 614 | + * Used to filter shortcode in text widgets |
|
| 615 | 615 | * |
| 616 | 616 | * @deprecated 2.5.4 |
| 617 | - */ |
|
| 618 | - public static function widget_text_filter_callback( $matches ) { |
|
| 617 | + */ |
|
| 618 | + public static function widget_text_filter_callback( $matches ) { |
|
| 619 | 619 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 620 | - return do_shortcode( $matches[0] ); |
|
| 621 | - } |
|
| 620 | + return do_shortcode( $matches[0] ); |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | public static function get_pages() { |
| 624 | 624 | return get_posts( array( |
@@ -630,10 +630,10 @@ discard block |
||
| 630 | 630 | ) ); |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 634 | - $pages = self::get_pages(); |
|
| 633 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 634 | + $pages = self::get_pages(); |
|
| 635 | 635 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 636 | - ?> |
|
| 636 | + ?> |
|
| 637 | 637 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 638 | 638 | <option value=""> </option> |
| 639 | 639 | <?php foreach ( $pages as $page ) { ?> |
@@ -643,16 +643,16 @@ discard block |
||
| 643 | 643 | <?php } ?> |
| 644 | 644 | </select> |
| 645 | 645 | <?php |
| 646 | - } |
|
| 646 | + } |
|
| 647 | 647 | |
| 648 | 648 | public static function post_edit_link( $post_id ) { |
| 649 | - $post = get_post($post_id); |
|
| 650 | - if ( $post ) { |
|
| 649 | + $post = get_post($post_id); |
|
| 650 | + if ( $post ) { |
|
| 651 | 651 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 652 | 652 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 653 | - } |
|
| 654 | - return ''; |
|
| 655 | - } |
|
| 653 | + } |
|
| 654 | + return ''; |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | 657 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 658 | 658 | ?> |
@@ -663,87 +663,87 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | public static function roles_options( $capability ) { |
| 666 | - global $frm_vars; |
|
| 667 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 668 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 669 | - } else { |
|
| 670 | - $editable_roles = get_editable_roles(); |
|
| 671 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - foreach ( $editable_roles as $role => $details ) { |
|
| 666 | + global $frm_vars; |
|
| 667 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 668 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 669 | + } else { |
|
| 670 | + $editable_roles = get_editable_roles(); |
|
| 671 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + foreach ( $editable_roles as $role => $details ) { |
|
| 675 | 675 | $name = translate_user_role( $details['name'] ); |
| 676 | 676 | ?> |
| 677 | 677 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 678 | 678 | <?php |
| 679 | - unset($role, $details); |
|
| 680 | - } |
|
| 681 | - } |
|
| 679 | + unset($role, $details); |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | 683 | public static function frm_capabilities( $type = 'auto' ) { |
| 684 | - $cap = array( |
|
| 685 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 686 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 687 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 688 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 689 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 690 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 691 | - ); |
|
| 684 | + $cap = array( |
|
| 685 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 686 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 687 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 688 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 689 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 690 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 691 | + ); |
|
| 692 | 692 | |
| 693 | 693 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 694 | - return $cap; |
|
| 695 | - } |
|
| 694 | + return $cap; |
|
| 695 | + } |
|
| 696 | 696 | |
| 697 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 698 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 699 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 700 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 697 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 698 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 699 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 700 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 701 | 701 | |
| 702 | - return $cap; |
|
| 703 | - } |
|
| 702 | + return $cap; |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | 705 | public static function user_has_permission( $needed_role ) { |
| 706 | - if ( $needed_role == '-1' ) { |
|
| 707 | - return false; |
|
| 706 | + if ( $needed_role == '-1' ) { |
|
| 707 | + return false; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 711 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 712 | - return true; |
|
| 713 | - } |
|
| 710 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 711 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 712 | + return true; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 716 | - foreach ( $roles as $role ) { |
|
| 715 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 716 | + foreach ( $roles as $role ) { |
|
| 717 | 717 | if ( current_user_can( $role ) ) { |
| 718 | - return true; |
|
| 718 | + return true; |
|
| 719 | 719 | } |
| 720 | - if ( $role == $needed_role ) { |
|
| 721 | - break; |
|
| 720 | + if ( $role == $needed_role ) { |
|
| 721 | + break; |
|
| 722 | 722 | } |
| 723 | - } |
|
| 724 | - return false; |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - /** |
|
| 728 | - * Make sure administrators can see Formidable menu |
|
| 729 | - * |
|
| 730 | - * @since 2.0 |
|
| 731 | - */ |
|
| 732 | - public static function maybe_add_permissions() { |
|
| 723 | + } |
|
| 724 | + return false; |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + /** |
|
| 728 | + * Make sure administrators can see Formidable menu |
|
| 729 | + * |
|
| 730 | + * @since 2.0 |
|
| 731 | + */ |
|
| 732 | + public static function maybe_add_permissions() { |
|
| 733 | 733 | self::force_capability( 'frm_view_entries' ); |
| 734 | 734 | |
| 735 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 736 | - return; |
|
| 737 | - } |
|
| 735 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 736 | + return; |
|
| 737 | + } |
|
| 738 | 738 | |
| 739 | 739 | $user_id = get_current_user_id(); |
| 740 | 740 | $user = new WP_User( $user_id ); |
| 741 | - $frm_roles = self::frm_capabilities(); |
|
| 742 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 741 | + $frm_roles = self::frm_capabilities(); |
|
| 742 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 743 | 743 | $user->add_cap( $frm_role ); |
| 744 | - unset($frm_role, $frm_role_description); |
|
| 745 | - } |
|
| 746 | - } |
|
| 744 | + unset($frm_role, $frm_role_description); |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | 747 | |
| 748 | 748 | /** |
| 749 | 749 | * Make sure admins have permission to see the menu items |
@@ -759,28 +759,28 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - /** |
|
| 763 | - * Check if the user has permision for action. |
|
| 764 | - * Return permission message and stop the action if no permission |
|
| 765 | - * @since 2.0 |
|
| 766 | - * @param string $permission |
|
| 767 | - */ |
|
| 762 | + /** |
|
| 763 | + * Check if the user has permision for action. |
|
| 764 | + * Return permission message and stop the action if no permission |
|
| 765 | + * @since 2.0 |
|
| 766 | + * @param string $permission |
|
| 767 | + */ |
|
| 768 | 768 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 769 | - $permission_error = self::permission_nonce_error($permission); |
|
| 770 | - if ( $permission_error !== false ) { |
|
| 771 | - if ( 'hide' == $show_message ) { |
|
| 772 | - $permission_error = ''; |
|
| 773 | - } |
|
| 774 | - wp_die($permission_error); |
|
| 775 | - } |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Check user permission and nonce |
|
| 780 | - * @since 2.0 |
|
| 781 | - * @param string $permission |
|
| 782 | - * @return false|string The permission message or false if allowed |
|
| 783 | - */ |
|
| 769 | + $permission_error = self::permission_nonce_error($permission); |
|
| 770 | + if ( $permission_error !== false ) { |
|
| 771 | + if ( 'hide' == $show_message ) { |
|
| 772 | + $permission_error = ''; |
|
| 773 | + } |
|
| 774 | + wp_die($permission_error); |
|
| 775 | + } |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * Check user permission and nonce |
|
| 780 | + * @since 2.0 |
|
| 781 | + * @param string $permission |
|
| 782 | + * @return false|string The permission message or false if allowed |
|
| 783 | + */ |
|
| 784 | 784 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 785 | 785 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 786 | 786 | $frm_settings = self::get_settings(); |
@@ -788,23 +788,23 @@ discard block |
||
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | $error = false; |
| 791 | - if ( empty($nonce_name) ) { |
|
| 792 | - return $error; |
|
| 793 | - } |
|
| 791 | + if ( empty($nonce_name) ) { |
|
| 792 | + return $error; |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 796 | - $frm_settings = self::get_settings(); |
|
| 797 | - $error = $frm_settings->admin_permission; |
|
| 798 | - } |
|
| 795 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 796 | + $frm_settings = self::get_settings(); |
|
| 797 | + $error = $frm_settings->admin_permission; |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - return $error; |
|
| 801 | - } |
|
| 800 | + return $error; |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - public static function checked( $values, $current ) { |
|
| 803 | + public static function checked( $values, $current ) { |
|
| 804 | 804 | if ( self::check_selected( $values, $current ) ) { |
| 805 | - echo ' checked="checked"'; |
|
| 805 | + echo ' checked="checked"'; |
|
| 806 | 806 | } |
| 807 | - } |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | 809 | public static function check_selected( $values, $current ) { |
| 810 | 810 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -842,24 +842,24 @@ discard block |
||
| 842 | 842 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - /** |
|
| 846 | - * Flatten a multi-dimensional array |
|
| 847 | - */ |
|
| 845 | + /** |
|
| 846 | + * Flatten a multi-dimensional array |
|
| 847 | + */ |
|
| 848 | 848 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 849 | - $return = array(); |
|
| 850 | - foreach ( $array as $key => $value ) { |
|
| 851 | - if ( is_array($value) ) { |
|
| 849 | + $return = array(); |
|
| 850 | + foreach ( $array as $key => $value ) { |
|
| 851 | + if ( is_array($value) ) { |
|
| 852 | 852 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 853 | - } else { |
|
| 853 | + } else { |
|
| 854 | 854 | if ( $keys == 'keep' ) { |
| 855 | 855 | $return[ $key ] = $value; |
| 856 | 856 | } else { |
| 857 | 857 | $return[] = $value; |
| 858 | 858 | } |
| 859 | - } |
|
| 860 | - } |
|
| 861 | - return $return; |
|
| 862 | - } |
|
| 859 | + } |
|
| 860 | + } |
|
| 861 | + return $return; |
|
| 862 | + } |
|
| 863 | 863 | |
| 864 | 864 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 865 | 865 | $safe_text = str_replace( '"', '"', $text ); |
@@ -870,38 +870,38 @@ discard block |
||
| 870 | 870 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - /** |
|
| 874 | - * Add auto paragraphs to text areas |
|
| 875 | - * @since 2.0 |
|
| 876 | - */ |
|
| 873 | + /** |
|
| 874 | + * Add auto paragraphs to text areas |
|
| 875 | + * @since 2.0 |
|
| 876 | + */ |
|
| 877 | 877 | public static function use_wpautop( $content ) { |
| 878 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 879 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 880 | - } |
|
| 881 | - return $content; |
|
| 882 | - } |
|
| 878 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 879 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 880 | + } |
|
| 881 | + return $content; |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | 884 | public static function replace_quotes( $val ) { |
| 885 | - //Replace double quotes |
|
| 885 | + //Replace double quotes |
|
| 886 | 886 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 887 | - //Replace single quotes |
|
| 888 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 889 | - return $val; |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - /** |
|
| 893 | - * @since 2.0 |
|
| 894 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 895 | - */ |
|
| 896 | - public static function jquery_ui_base_url() { |
|
| 887 | + //Replace single quotes |
|
| 888 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 889 | + return $val; |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + /** |
|
| 893 | + * @since 2.0 |
|
| 894 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 895 | + */ |
|
| 896 | + public static function jquery_ui_base_url() { |
|
| 897 | 897 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 898 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 899 | - return $url; |
|
| 900 | - } |
|
| 898 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 899 | + return $url; |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | - /** |
|
| 903 | - * @param string $handle |
|
| 904 | - */ |
|
| 902 | + /** |
|
| 903 | + * @param string $handle |
|
| 904 | + */ |
|
| 905 | 905 | public static function script_version( $handle, $default = 0 ) { |
| 906 | 906 | global $wp_scripts; |
| 907 | 907 | if ( ! $wp_scripts ) { |
@@ -923,75 +923,75 @@ discard block |
||
| 923 | 923 | |
| 924 | 924 | public static function js_redirect( $url ) { |
| 925 | 925 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 926 | - } |
|
| 926 | + } |
|
| 927 | 927 | |
| 928 | 928 | public static function get_user_id_param( $user_id ) { |
| 929 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 930 | - return $user_id; |
|
| 931 | - } |
|
| 929 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 930 | + return $user_id; |
|
| 931 | + } |
|
| 932 | 932 | |
| 933 | 933 | $user_id = sanitize_text_field( $user_id ); |
| 934 | 934 | if ( $user_id == 'current' ) { |
| 935 | 935 | $user_id = get_current_user_id(); |
| 936 | 936 | } else { |
| 937 | - if ( is_email($user_id) ) { |
|
| 938 | - $user = get_user_by('email', $user_id); |
|
| 939 | - } else { |
|
| 940 | - $user = get_user_by('login', $user_id); |
|
| 941 | - } |
|
| 937 | + if ( is_email($user_id) ) { |
|
| 938 | + $user = get_user_by('email', $user_id); |
|
| 939 | + } else { |
|
| 940 | + $user = get_user_by('login', $user_id); |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - if ( $user ) { |
|
| 944 | - $user_id = $user->ID; |
|
| 945 | - } |
|
| 946 | - unset($user); |
|
| 947 | - } |
|
| 943 | + if ( $user ) { |
|
| 944 | + $user_id = $user->ID; |
|
| 945 | + } |
|
| 946 | + unset($user); |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - return $user_id; |
|
| 950 | - } |
|
| 949 | + return $user_id; |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | 952 | public static function get_file_contents( $filename, $atts = array() ) { |
| 953 | - if ( ! is_file($filename) ) { |
|
| 954 | - return false; |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - extract($atts); |
|
| 958 | - ob_start(); |
|
| 959 | - include($filename); |
|
| 960 | - $contents = ob_get_contents(); |
|
| 961 | - ob_end_clean(); |
|
| 962 | - return $contents; |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - /** |
|
| 966 | - * @param string $table_name |
|
| 967 | - * @param string $column |
|
| 953 | + if ( ! is_file($filename) ) { |
|
| 954 | + return false; |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + extract($atts); |
|
| 958 | + ob_start(); |
|
| 959 | + include($filename); |
|
| 960 | + $contents = ob_get_contents(); |
|
| 961 | + ob_end_clean(); |
|
| 962 | + return $contents; |
|
| 963 | + } |
|
| 964 | + |
|
| 965 | + /** |
|
| 966 | + * @param string $table_name |
|
| 967 | + * @param string $column |
|
| 968 | 968 | * @param int $id |
| 969 | 969 | * @param int $num_chars |
| 970 | - */ |
|
| 971 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 972 | - $key = ''; |
|
| 970 | + */ |
|
| 971 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 972 | + $key = ''; |
|
| 973 | 973 | |
| 974 | - if ( ! empty( $name ) ) { |
|
| 975 | - $key = sanitize_key($name); |
|
| 976 | - } |
|
| 974 | + if ( ! empty( $name ) ) { |
|
| 975 | + $key = sanitize_key($name); |
|
| 976 | + } |
|
| 977 | 977 | |
| 978 | 978 | if ( empty( $key ) ) { |
| 979 | - $max_slug_value = pow(36, $num_chars); |
|
| 980 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 981 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 982 | - } |
|
| 979 | + $max_slug_value = pow(36, $num_chars); |
|
| 980 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 981 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 982 | + } |
|
| 983 | 983 | |
| 984 | 984 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 985 | 985 | $key = $key . 'a'; |
| 986 | - } |
|
| 986 | + } |
|
| 987 | 987 | |
| 988 | 988 | $key_check = FrmDb::get_var( $table_name, array( |
| 989 | 989 | $column => $key, |
| 990 | 990 | 'ID !' => $id, |
| 991 | 991 | ), $column ); |
| 992 | 992 | |
| 993 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 994 | - $suffix = 2; |
|
| 993 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 994 | + $suffix = 2; |
|
| 995 | 995 | do { |
| 996 | 996 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 997 | 997 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -1001,23 +1001,23 @@ discard block |
||
| 1001 | 1001 | $suffix++; |
| 1002 | 1002 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1003 | 1003 | $key = $alt_post_name; |
| 1004 | - } |
|
| 1005 | - return $key; |
|
| 1006 | - } |
|
| 1007 | - |
|
| 1008 | - /** |
|
| 1009 | - * Editing a Form or Entry |
|
| 1010 | - * @param string $table |
|
| 1011 | - * @return bool|array |
|
| 1012 | - */ |
|
| 1013 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1014 | - if ( ! $record ) { |
|
| 1015 | - return false; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - if ( empty($post_values) ) { |
|
| 1019 | - $post_values = stripslashes_deep($_POST); |
|
| 1020 | - } |
|
| 1004 | + } |
|
| 1005 | + return $key; |
|
| 1006 | + } |
|
| 1007 | + |
|
| 1008 | + /** |
|
| 1009 | + * Editing a Form or Entry |
|
| 1010 | + * @param string $table |
|
| 1011 | + * @return bool|array |
|
| 1012 | + */ |
|
| 1013 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1014 | + if ( ! $record ) { |
|
| 1015 | + return false; |
|
| 1016 | + } |
|
| 1017 | + |
|
| 1018 | + if ( empty($post_values) ) { |
|
| 1019 | + $post_values = stripslashes_deep($_POST); |
|
| 1020 | + } |
|
| 1021 | 1021 | |
| 1022 | 1022 | $values = array( |
| 1023 | 1023 | 'id' => $record->id, |
@@ -1025,25 +1025,25 @@ discard block |
||
| 1025 | 1025 | ); |
| 1026 | 1026 | |
| 1027 | 1027 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1028 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1028 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1029 | 1029 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1030 | - unset($var, $default_val); |
|
| 1031 | - } |
|
| 1030 | + unset($var, $default_val); |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1033 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1034 | 1034 | |
| 1035 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1035 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1036 | 1036 | |
| 1037 | 1037 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1038 | 1038 | |
| 1039 | - if ( $table == 'entries' ) { |
|
| 1040 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1041 | - } else if ( $table == 'forms' ) { |
|
| 1042 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1043 | - } |
|
| 1039 | + if ( $table == 'entries' ) { |
|
| 1040 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1041 | + } else if ( $table == 'forms' ) { |
|
| 1042 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1043 | + } |
|
| 1044 | 1044 | |
| 1045 | - return $values; |
|
| 1046 | - } |
|
| 1045 | + return $values; |
|
| 1046 | + } |
|
| 1047 | 1047 | |
| 1048 | 1048 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1049 | 1049 | if ( ! empty( $fields ) ) { |
@@ -1056,46 +1056,46 @@ discard block |
||
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1059 | - $post_values = $args['post_values']; |
|
| 1060 | - |
|
| 1061 | - if ( $args['default'] ) { |
|
| 1062 | - $meta_value = $field->default_value; |
|
| 1063 | - } else { |
|
| 1064 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1065 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1066 | - $field->field_options['custom_field'] = ''; |
|
| 1067 | - } |
|
| 1059 | + $post_values = $args['post_values']; |
|
| 1060 | + |
|
| 1061 | + if ( $args['default'] ) { |
|
| 1062 | + $meta_value = $field->default_value; |
|
| 1063 | + } else { |
|
| 1064 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1065 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1066 | + $field->field_options['custom_field'] = ''; |
|
| 1067 | + } |
|
| 1068 | 1068 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1069 | 1069 | 'truncate' => false, |
| 1070 | 1070 | 'type' => $field->type, |
| 1071 | 1071 | 'form_id' => $field->form_id, |
| 1072 | 1072 | 'field' => $field, |
| 1073 | 1073 | ) ); |
| 1074 | - } else { |
|
| 1074 | + } else { |
|
| 1075 | 1075 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1076 | - } |
|
| 1077 | - } |
|
| 1076 | + } |
|
| 1077 | + } |
|
| 1078 | 1078 | |
| 1079 | 1079 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1080 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1080 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1081 | 1081 | |
| 1082 | 1082 | $field_array = self::start_field_array( $field ); |
| 1083 | 1083 | $field_array['value'] = $new_value; |
| 1084 | 1084 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1085 | 1085 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1086 | 1086 | |
| 1087 | - $args['field_type'] = $field_type; |
|
| 1087 | + $args['field_type'] = $field_type; |
|
| 1088 | 1088 | |
| 1089 | 1089 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1090 | 1090 | |
| 1091 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1092 | - $field_array['unique_msg'] = ''; |
|
| 1093 | - } |
|
| 1091 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1092 | + $field_array['unique_msg'] = ''; |
|
| 1093 | + } |
|
| 1094 | 1094 | |
| 1095 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1095 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1096 | 1096 | |
| 1097 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1098 | - } |
|
| 1097 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | 1100 | /** |
| 1101 | 1101 | * @since 3.0 |
@@ -1116,48 +1116,48 @@ discard block |
||
| 1116 | 1116 | ); |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | - /** |
|
| 1120 | - * @param string $table |
|
| 1121 | - */ |
|
| 1119 | + /** |
|
| 1120 | + * @param string $table |
|
| 1121 | + */ |
|
| 1122 | 1122 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1123 | - if ( $table == 'entries' ) { |
|
| 1124 | - $form = $record->form_id; |
|
| 1123 | + if ( $table == 'entries' ) { |
|
| 1124 | + $form = $record->form_id; |
|
| 1125 | 1125 | FrmForm::maybe_get_form( $form ); |
| 1126 | - } else { |
|
| 1127 | - $form = $record; |
|
| 1128 | - } |
|
| 1126 | + } else { |
|
| 1127 | + $form = $record; |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | - if ( ! $form ) { |
|
| 1131 | - return; |
|
| 1132 | - } |
|
| 1130 | + if ( ! $form ) { |
|
| 1131 | + return; |
|
| 1132 | + } |
|
| 1133 | 1133 | |
| 1134 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1134 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1135 | 1135 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1136 | 1136 | |
| 1137 | - if ( ! is_array($form->options) ) { |
|
| 1138 | - return; |
|
| 1139 | - } |
|
| 1137 | + if ( ! is_array($form->options) ) { |
|
| 1138 | + return; |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | - foreach ( $form->options as $opt => $value ) { |
|
| 1142 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1143 | - } |
|
| 1141 | + foreach ( $form->options as $opt => $value ) { |
|
| 1142 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | - self::fill_form_defaults($post_values, $values); |
|
| 1146 | - } |
|
| 1145 | + self::fill_form_defaults($post_values, $values); |
|
| 1146 | + } |
|
| 1147 | 1147 | |
| 1148 | - /** |
|
| 1149 | - * Set to POST value or default |
|
| 1150 | - */ |
|
| 1148 | + /** |
|
| 1149 | + * Set to POST value or default |
|
| 1150 | + */ |
|
| 1151 | 1151 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1152 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1152 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1153 | 1153 | |
| 1154 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1155 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1154 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1155 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1156 | 1156 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1157 | - } |
|
| 1157 | + } |
|
| 1158 | 1158 | |
| 1159 | - unset($opt, $defaut); |
|
| 1160 | - } |
|
| 1159 | + unset($opt, $defaut); |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | 1162 | if ( ! isset( $values['custom_style'] ) ) { |
| 1163 | 1163 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1166,10 +1166,10 @@ discard block |
||
| 1166 | 1166 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1167 | 1167 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1168 | 1168 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1169 | - } |
|
| 1170 | - unset($h); |
|
| 1171 | - } |
|
| 1172 | - } |
|
| 1169 | + } |
|
| 1170 | + unset($h); |
|
| 1171 | + } |
|
| 1172 | + } |
|
| 1173 | 1173 | |
| 1174 | 1174 | /** |
| 1175 | 1175 | * @since 2.2.10 |
@@ -1192,55 +1192,55 @@ discard block |
||
| 1192 | 1192 | if ( $possible_email_field ) { |
| 1193 | 1193 | $class .= 'show_frm_not_email_to'; |
| 1194 | 1194 | } |
| 1195 | - ?> |
|
| 1195 | + ?> |
|
| 1196 | 1196 | <li> |
| 1197 | 1197 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
| 1198 | 1198 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
| 1199 | 1199 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
| 1200 | 1200 | </li> |
| 1201 | 1201 | <?php |
| 1202 | - } |
|
| 1202 | + } |
|
| 1203 | 1203 | |
| 1204 | 1204 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1205 | - if ( is_array( $str ) ) { |
|
| 1206 | - return ''; |
|
| 1205 | + if ( is_array( $str ) ) { |
|
| 1206 | + return ''; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | - $length = (int) $length; |
|
| 1209 | + $length = (int) $length; |
|
| 1210 | 1210 | $str = wp_strip_all_tags( $str ); |
| 1211 | 1211 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1212 | 1212 | |
| 1213 | 1213 | if ( $length == 0 ) { |
| 1214 | - return ''; |
|
| 1215 | - } else if ( $length <= 10 ) { |
|
| 1214 | + return ''; |
|
| 1215 | + } else if ( $length <= 10 ) { |
|
| 1216 | 1216 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1217 | 1217 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1218 | - } |
|
| 1218 | + } |
|
| 1219 | 1219 | |
| 1220 | - $sub = ''; |
|
| 1221 | - $len = 0; |
|
| 1220 | + $sub = ''; |
|
| 1221 | + $len = 0; |
|
| 1222 | 1222 | |
| 1223 | 1223 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1224 | 1224 | |
| 1225 | 1225 | foreach ( $words as $word ) { |
| 1226 | 1226 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1227 | 1227 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1228 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1229 | - break; |
|
| 1230 | - } |
|
| 1228 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1229 | + break; |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | - $sub .= $part; |
|
| 1232 | + $sub .= $part; |
|
| 1233 | 1233 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1234 | 1234 | |
| 1235 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1236 | - break; |
|
| 1237 | - } |
|
| 1235 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1236 | + break; |
|
| 1237 | + } |
|
| 1238 | 1238 | |
| 1239 | - unset($total_len, $word); |
|
| 1240 | - } |
|
| 1239 | + unset($total_len, $word); |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | 1242 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1243 | - } |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | 1245 | public static function mb_function( $function_names, $args ) { |
| 1246 | 1246 | $mb_function_name = $function_names[0]; |
@@ -1252,18 +1252,18 @@ discard block |
||
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1255 | - if ( empty($date) ) { |
|
| 1256 | - return $date; |
|
| 1257 | - } |
|
| 1255 | + if ( empty($date) ) { |
|
| 1256 | + return $date; |
|
| 1257 | + } |
|
| 1258 | 1258 | |
| 1259 | - if ( empty($date_format) ) { |
|
| 1260 | - $date_format = get_option('date_format'); |
|
| 1261 | - } |
|
| 1259 | + if ( empty($date_format) ) { |
|
| 1260 | + $date_format = get_option('date_format'); |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1264 | - $frmpro_settings = new FrmProSettings(); |
|
| 1265 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1266 | - } |
|
| 1263 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1264 | + $frmpro_settings = new FrmProSettings(); |
|
| 1265 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | 1268 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1269 | 1269 | |
@@ -1272,8 +1272,8 @@ discard block |
||
| 1272 | 1272 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - return $formatted; |
|
| 1276 | - } |
|
| 1275 | + return $formatted; |
|
| 1276 | + } |
|
| 1277 | 1277 | |
| 1278 | 1278 | private static function add_time_to_date( $time_format, $date ) { |
| 1279 | 1279 | if ( empty( $time_format ) ) { |
@@ -1355,119 +1355,119 @@ discard block |
||
| 1355 | 1355 | ); |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - // Pagination Methods |
|
| 1358 | + // Pagination Methods |
|
| 1359 | 1359 | |
| 1360 | - /** |
|
| 1361 | - * @param integer $current_p |
|
| 1362 | - */ |
|
| 1360 | + /** |
|
| 1361 | + * @param integer $current_p |
|
| 1362 | + */ |
|
| 1363 | 1363 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1364 | 1364 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - /** |
|
| 1368 | - * @param integer $current_p |
|
| 1369 | - */ |
|
| 1370 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1371 | - if ( $current_p == 1 ) { |
|
| 1372 | - return 1; |
|
| 1373 | - } else { |
|
| 1374 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1375 | - } |
|
| 1376 | - } |
|
| 1367 | + /** |
|
| 1368 | + * @param integer $current_p |
|
| 1369 | + */ |
|
| 1370 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1371 | + if ( $current_p == 1 ) { |
|
| 1372 | + return 1; |
|
| 1373 | + } else { |
|
| 1374 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1375 | + } |
|
| 1376 | + } |
|
| 1377 | 1377 | |
| 1378 | 1378 | /** |
| 1379 | 1379 | * @return array |
| 1380 | 1380 | */ |
| 1381 | 1381 | public static function json_to_array( $json_vars ) { |
| 1382 | - $vars = array(); |
|
| 1383 | - foreach ( $json_vars as $jv ) { |
|
| 1384 | - $jv_name = explode('[', $jv['name']); |
|
| 1385 | - $last = count($jv_name) - 1; |
|
| 1386 | - foreach ( $jv_name as $p => $n ) { |
|
| 1387 | - $name = trim($n, ']'); |
|
| 1388 | - if ( ! isset($l1) ) { |
|
| 1389 | - $l1 = $name; |
|
| 1390 | - } |
|
| 1391 | - |
|
| 1392 | - if ( ! isset($l2) ) { |
|
| 1393 | - $l2 = $name; |
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - if ( ! isset($l3) ) { |
|
| 1397 | - $l3 = $name; |
|
| 1398 | - } |
|
| 1399 | - |
|
| 1400 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1401 | - |
|
| 1402 | - switch ( $p ) { |
|
| 1403 | - case 0: |
|
| 1404 | - $l1 = $name; |
|
| 1405 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1382 | + $vars = array(); |
|
| 1383 | + foreach ( $json_vars as $jv ) { |
|
| 1384 | + $jv_name = explode('[', $jv['name']); |
|
| 1385 | + $last = count($jv_name) - 1; |
|
| 1386 | + foreach ( $jv_name as $p => $n ) { |
|
| 1387 | + $name = trim($n, ']'); |
|
| 1388 | + if ( ! isset($l1) ) { |
|
| 1389 | + $l1 = $name; |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + if ( ! isset($l2) ) { |
|
| 1393 | + $l2 = $name; |
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + if ( ! isset($l3) ) { |
|
| 1397 | + $l3 = $name; |
|
| 1398 | + } |
|
| 1399 | + |
|
| 1400 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1401 | + |
|
| 1402 | + switch ( $p ) { |
|
| 1403 | + case 0: |
|
| 1404 | + $l1 = $name; |
|
| 1405 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1406 | 1406 | break; |
| 1407 | 1407 | |
| 1408 | - case 1: |
|
| 1409 | - $l2 = $name; |
|
| 1410 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1408 | + case 1: |
|
| 1409 | + $l2 = $name; |
|
| 1410 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1411 | 1411 | break; |
| 1412 | 1412 | |
| 1413 | - case 2: |
|
| 1414 | - $l3 = $name; |
|
| 1415 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1413 | + case 2: |
|
| 1414 | + $l3 = $name; |
|
| 1415 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1416 | 1416 | break; |
| 1417 | 1417 | |
| 1418 | - case 3: |
|
| 1419 | - $l4 = $name; |
|
| 1420 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1421 | - } |
|
| 1418 | + case 3: |
|
| 1419 | + $l4 = $name; |
|
| 1420 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1421 | + } |
|
| 1422 | 1422 | |
| 1423 | - unset($this_val, $n); |
|
| 1424 | - } |
|
| 1423 | + unset($this_val, $n); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | - unset($last, $jv); |
|
| 1427 | - } |
|
| 1426 | + unset($last, $jv); |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | - return $vars; |
|
| 1430 | - } |
|
| 1429 | + return $vars; |
|
| 1430 | + } |
|
| 1431 | 1431 | |
| 1432 | - /** |
|
| 1433 | - * @param string $name |
|
| 1434 | - * @param string $l1 |
|
| 1435 | - */ |
|
| 1436 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1437 | - if ( $name == '' ) { |
|
| 1438 | - $vars[] = $val; |
|
| 1439 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1440 | - $vars[ $l1 ] = $val; |
|
| 1441 | - } |
|
| 1442 | - } |
|
| 1432 | + /** |
|
| 1433 | + * @param string $name |
|
| 1434 | + * @param string $l1 |
|
| 1435 | + */ |
|
| 1436 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1437 | + if ( $name == '' ) { |
|
| 1438 | + $vars[] = $val; |
|
| 1439 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1440 | + $vars[ $l1 ] = $val; |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1443 | 1443 | |
| 1444 | 1444 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1445 | - $tooltips = array( |
|
| 1446 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1447 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1448 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1449 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1450 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1451 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1453 | - ); |
|
| 1454 | - |
|
| 1455 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1456 | - return; |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - if ( 'open' == $class ) { |
|
| 1460 | - echo ' frm_help"'; |
|
| 1461 | - } else { |
|
| 1462 | - echo ' class="frm_help"'; |
|
| 1463 | - } |
|
| 1445 | + $tooltips = array( |
|
| 1446 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1447 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1448 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1449 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1450 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1451 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1453 | + ); |
|
| 1454 | + |
|
| 1455 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1456 | + return; |
|
| 1457 | + } |
|
| 1458 | + |
|
| 1459 | + if ( 'open' == $class ) { |
|
| 1460 | + echo ' frm_help"'; |
|
| 1461 | + } else { |
|
| 1462 | + echo ' class="frm_help"'; |
|
| 1463 | + } |
|
| 1464 | 1464 | |
| 1465 | 1465 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1466 | 1466 | |
| 1467 | - if ( 'open' != $class ) { |
|
| 1468 | - echo '"'; |
|
| 1469 | - } |
|
| 1470 | - } |
|
| 1467 | + if ( 'open' != $class ) { |
|
| 1468 | + echo '"'; |
|
| 1469 | + } |
|
| 1470 | + } |
|
| 1471 | 1471 | |
| 1472 | 1472 | /** |
| 1473 | 1473 | * Add the current_page class to that page in the form nav |
@@ -1483,35 +1483,35 @@ discard block |
||
| 1483 | 1483 | } |
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | - /** |
|
| 1487 | - * Prepare and json_encode post content |
|
| 1488 | - * |
|
| 1489 | - * @since 2.0 |
|
| 1490 | - * |
|
| 1491 | - * @param array $post_content |
|
| 1492 | - * @return string $post_content ( json encoded array ) |
|
| 1493 | - */ |
|
| 1494 | - public static function prepare_and_encode( $post_content ) { |
|
| 1495 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1486 | + /** |
|
| 1487 | + * Prepare and json_encode post content |
|
| 1488 | + * |
|
| 1489 | + * @since 2.0 |
|
| 1490 | + * |
|
| 1491 | + * @param array $post_content |
|
| 1492 | + * @return string $post_content ( json encoded array ) |
|
| 1493 | + */ |
|
| 1494 | + public static function prepare_and_encode( $post_content ) { |
|
| 1495 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1496 | 1496 | foreach ( $post_content as $key => $val ) { |
| 1497 | 1497 | // Replace problematic characters (like ") |
| 1498 | 1498 | $val = str_replace( '"', '"', $val ); |
| 1499 | 1499 | |
| 1500 | 1500 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1501 | - unset( $key, $val ); |
|
| 1502 | - } |
|
| 1501 | + unset( $key, $val ); |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - // json_encode the array |
|
| 1505 | - $post_content = json_encode( $post_content ); |
|
| 1504 | + // json_encode the array |
|
| 1505 | + $post_content = json_encode( $post_content ); |
|
| 1506 | 1506 | |
| 1507 | - // add extra slashes for \r\n since WP strips them |
|
| 1507 | + // add extra slashes for \r\n since WP strips them |
|
| 1508 | 1508 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1509 | 1509 | |
| 1510 | - // allow for " |
|
| 1511 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1510 | + // allow for " |
|
| 1511 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1512 | 1512 | |
| 1513 | - return $post_content; |
|
| 1514 | - } |
|
| 1513 | + return $post_content; |
|
| 1514 | + } |
|
| 1515 | 1515 | |
| 1516 | 1516 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1517 | 1517 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1533,64 +1533,64 @@ discard block |
||
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | public static function maybe_json_decode( $string ) { |
| 1536 | - if ( is_array($string) ) { |
|
| 1537 | - return $string; |
|
| 1538 | - } |
|
| 1536 | + if ( is_array($string) ) { |
|
| 1537 | + return $string; |
|
| 1538 | + } |
|
| 1539 | 1539 | |
| 1540 | - $new_string = json_decode($string, true); |
|
| 1541 | - if ( function_exists('json_last_error') ) { |
|
| 1540 | + $new_string = json_decode($string, true); |
|
| 1541 | + if ( function_exists('json_last_error') ) { |
|
| 1542 | 1542 | // php 5.3+ |
| 1543 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1544 | - $string = $new_string; |
|
| 1545 | - } |
|
| 1546 | - } else if ( isset($new_string) ) { |
|
| 1543 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1544 | + $string = $new_string; |
|
| 1545 | + } |
|
| 1546 | + } else if ( isset($new_string) ) { |
|
| 1547 | 1547 | // php < 5.3 fallback |
| 1548 | - $string = $new_string; |
|
| 1549 | - } |
|
| 1550 | - return $string; |
|
| 1551 | - } |
|
| 1552 | - |
|
| 1553 | - /** |
|
| 1554 | - * @since 1.07.10 |
|
| 1555 | - * |
|
| 1556 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1557 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1558 | - */ |
|
| 1548 | + $string = $new_string; |
|
| 1549 | + } |
|
| 1550 | + return $string; |
|
| 1551 | + } |
|
| 1552 | + |
|
| 1553 | + /** |
|
| 1554 | + * @since 1.07.10 |
|
| 1555 | + * |
|
| 1556 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1557 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1558 | + */ |
|
| 1559 | 1559 | public static function maybe_highlight_menu( $post_type ) { |
| 1560 | - global $post; |
|
| 1560 | + global $post; |
|
| 1561 | 1561 | |
| 1562 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1563 | - return; |
|
| 1564 | - } |
|
| 1562 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1563 | + return; |
|
| 1564 | + } |
|
| 1565 | 1565 | |
| 1566 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1567 | - return; |
|
| 1568 | - } |
|
| 1566 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1567 | + return; |
|
| 1568 | + } |
|
| 1569 | 1569 | |
| 1570 | - self::load_admin_wide_js(); |
|
| 1571 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1572 | - } |
|
| 1570 | + self::load_admin_wide_js(); |
|
| 1571 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1572 | + } |
|
| 1573 | 1573 | |
| 1574 | - /** |
|
| 1575 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1576 | - * @since 2.0 |
|
| 1577 | - */ |
|
| 1574 | + /** |
|
| 1575 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1576 | + * @since 2.0 |
|
| 1577 | + */ |
|
| 1578 | 1578 | public static function load_admin_wide_js( $load = true ) { |
| 1579 | - $version = FrmAppHelper::plugin_version(); |
|
| 1579 | + $version = FrmAppHelper::plugin_version(); |
|
| 1580 | 1580 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1581 | 1581 | |
| 1582 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1582 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1583 | 1583 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1584 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1584 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1585 | 1585 | 'url' => FrmAppHelper::plugin_url(), |
| 1586 | 1586 | 'loading' => __( 'Loading…' ), |
| 1587 | 1587 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1588 | - ) ); |
|
| 1588 | + ) ); |
|
| 1589 | 1589 | |
| 1590 | 1590 | if ( $load ) { |
| 1591 | 1591 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1592 | 1592 | } |
| 1593 | - } |
|
| 1593 | + } |
|
| 1594 | 1594 | |
| 1595 | 1595 | /** |
| 1596 | 1596 | * @since 2.0.9 |
@@ -1599,9 +1599,9 @@ discard block |
||
| 1599 | 1599 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | - /** |
|
| 1603 | - * @param string $location |
|
| 1604 | - */ |
|
| 1602 | + /** |
|
| 1603 | + * @param string $location |
|
| 1604 | + */ |
|
| 1605 | 1605 | public static function localize_script( $location ) { |
| 1606 | 1606 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1607 | 1607 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1657,27 +1657,27 @@ discard block |
||
| 1657 | 1657 | } |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - /** |
|
| 1660 | + /** |
|
| 1661 | 1661 | * echo the message on the plugins listing page |
| 1662 | - * @since 1.07.10 |
|
| 1663 | - * |
|
| 1664 | - * @param float $min_version The version the add-on requires |
|
| 1665 | - */ |
|
| 1662 | + * @since 1.07.10 |
|
| 1663 | + * |
|
| 1664 | + * @param float $min_version The version the add-on requires |
|
| 1665 | + */ |
|
| 1666 | 1666 | public static function min_version_notice( $min_version ) { |
| 1667 | - $frm_version = self::plugin_version(); |
|
| 1667 | + $frm_version = self::plugin_version(); |
|
| 1668 | 1668 | |
| 1669 | - // check if Formidable meets minimum requirements |
|
| 1670 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1671 | - return; |
|
| 1672 | - } |
|
| 1669 | + // check if Formidable meets minimum requirements |
|
| 1670 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1671 | + return; |
|
| 1672 | + } |
|
| 1673 | 1673 | |
| 1674 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1674 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1675 | 1675 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1676 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1677 | - '</div></td></tr>'; |
|
| 1678 | - } |
|
| 1676 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1677 | + '</div></td></tr>'; |
|
| 1678 | + } |
|
| 1679 | 1679 | |
| 1680 | - public static function locales( $type = 'date' ) { |
|
| 1680 | + public static function locales( $type = 'date' ) { |
|
| 1681 | 1681 | $locales = array( |
| 1682 | 1682 | 'en' => __( 'English', 'formidable' ), |
| 1683 | 1683 | '' => __( 'English/Western', 'formidable' ), |
@@ -1753,11 +1753,11 @@ discard block |
||
| 1753 | 1753 | $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' ); |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1757 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1756 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1757 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1758 | 1758 | |
| 1759 | - return $locales; |
|
| 1760 | - } |
|
| 1759 | + return $locales; |
|
| 1760 | + } |
|
| 1761 | 1761 | |
| 1762 | 1762 | /** |
| 1763 | 1763 | * Prepare and save settings in styles and actions |
@@ -7,9 +7,9 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | 14 | $values = self::get_default_field( $type ); |
| 15 | 15 | |
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return $values; |
|
| 33 | - } |
|
| 32 | + return $values; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | public static function get_html_id( $field, $plus = '' ) { |
| 36 | 36 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 39 | + public static function setup_edit_vars( $field, $doing_ajax = false ) { |
|
| 40 | 40 | $values = self::field_object_to_array( $field ); |
| 41 | 41 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | public static function field_object_to_array( $field ) { |
| 45 | 45 | $values = (array) $field; |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | return $field_type->get_new_field_defaults(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | - global $wpdb; |
|
| 242 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 243 | + global $wpdb; |
|
| 244 | 244 | |
| 245 | 245 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 246 | - $values['form_id'] = $form_id; |
|
| 247 | - $values['options'] = maybe_serialize($field->options); |
|
| 248 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 246 | + $values['form_id'] = $form_id; |
|
| 247 | + $values['options'] = maybe_serialize($field->options); |
|
| 248 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 249 | 249 | |
| 250 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | - $values[ $col ] = $field->{$col}; |
|
| 252 | - } |
|
| 253 | - } |
|
| 250 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 251 | + $values[ $col ] = $field->{$col}; |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * @since 2.0 |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | */ |
| 400 | 400 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 401 | 401 | _deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' ); |
| 402 | - return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 403 | - } |
|
| 402 | + return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args ); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | 405 | public static function get_checkbox_id( $field, $opt_key ) { |
| 406 | 406 | $id = $field['id']; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | public static function display_recaptcha( $field ) { |
| 417 | 417 | _deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' ); |
| 418 | - } |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | 420 | public static function show_single_option( $field ) { |
| 421 | 421 | if ( ! is_array( $field['options'] ) ) { |
@@ -426,26 +426,26 @@ discard block |
||
| 426 | 426 | $html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field ); |
| 427 | 427 | |
| 428 | 428 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 429 | - $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 430 | - $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 429 | + $field_val = self::get_value_from_array( $opt, $opt_key, $field ); |
|
| 430 | + $opt = self::get_label_from_array( $opt, $opt_key, $field ); |
|
| 431 | 431 | |
| 432 | 432 | // Get string for Other text field, if needed |
| 433 | 433 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 434 | 434 | |
| 435 | 435 | $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"' : ''; |
| 436 | 436 | |
| 437 | - // If this is an "Other" option, get the HTML for it |
|
| 437 | + // If this is an "Other" option, get the HTML for it |
|
| 438 | 438 | if ( self::is_other_opt( $opt_key ) ) { |
| 439 | 439 | if ( FrmAppHelper::pro_is_installed() ) { |
| 440 | 440 | require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' ); |
| 441 | 441 | } |
| 442 | - } else { |
|
| 442 | + } else { |
|
| 443 | 443 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 444 | - } |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | 446 | unset( $checked, $other_val ); |
| 447 | 447 | } |
| 448 | - } |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | public static function get_value_from_array( $opt, $opt_key, $field ) { |
| 451 | 451 | $opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
@@ -463,47 +463,47 @@ discard block |
||
| 463 | 463 | * @return string |
| 464 | 464 | */ |
| 465 | 465 | public static function get_term_link( $tax_id ) { |
| 466 | - $tax = get_taxonomy($tax_id); |
|
| 467 | - if ( ! $tax ) { |
|
| 468 | - return ''; |
|
| 469 | - } |
|
| 466 | + $tax = get_taxonomy($tax_id); |
|
| 467 | + if ( ! $tax ) { |
|
| 468 | + return ''; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | - $link = sprintf( |
|
| 472 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 471 | + $link = sprintf( |
|
| 472 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 473 | 473 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 474 | - ); |
|
| 475 | - unset($tax); |
|
| 474 | + ); |
|
| 475 | + unset($tax); |
|
| 476 | 476 | |
| 477 | - return $link; |
|
| 478 | - } |
|
| 477 | + return $link; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | 480 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 481 | 481 | $hide_opt = self::get_value_for_comparision( $hide_opt ); |
| 482 | 482 | $observed_value = self::get_value_for_comparision( $observed_value ); |
| 483 | 483 | |
| 484 | - if ( is_array($observed_value) ) { |
|
| 485 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - $m = false; |
|
| 489 | - if ( $cond == '==' ) { |
|
| 490 | - $m = $observed_value == $hide_opt; |
|
| 491 | - } else if ( $cond == '!=' ) { |
|
| 492 | - $m = $observed_value != $hide_opt; |
|
| 493 | - } else if ( $cond == '>' ) { |
|
| 494 | - $m = $observed_value > $hide_opt; |
|
| 495 | - } else if ( $cond == '<' ) { |
|
| 496 | - $m = $observed_value < $hide_opt; |
|
| 497 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 498 | - $m = stripos($observed_value, $hide_opt); |
|
| 499 | - if ( $cond == 'not LIKE' ) { |
|
| 500 | - $m = ( $m === false ) ? true : false; |
|
| 501 | - } else { |
|
| 502 | - $m = ( $m === false ) ? false : true; |
|
| 503 | - } |
|
| 504 | - } |
|
| 505 | - return $m; |
|
| 506 | - } |
|
| 484 | + if ( is_array($observed_value) ) { |
|
| 485 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + $m = false; |
|
| 489 | + if ( $cond == '==' ) { |
|
| 490 | + $m = $observed_value == $hide_opt; |
|
| 491 | + } else if ( $cond == '!=' ) { |
|
| 492 | + $m = $observed_value != $hide_opt; |
|
| 493 | + } else if ( $cond == '>' ) { |
|
| 494 | + $m = $observed_value > $hide_opt; |
|
| 495 | + } else if ( $cond == '<' ) { |
|
| 496 | + $m = $observed_value < $hide_opt; |
|
| 497 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 498 | + $m = stripos($observed_value, $hide_opt); |
|
| 499 | + if ( $cond == 'not LIKE' ) { |
|
| 500 | + $m = ( $m === false ) ? true : false; |
|
| 501 | + } else { |
|
| 502 | + $m = ( $m === false ) ? false : true; |
|
| 503 | + } |
|
| 504 | + } |
|
| 505 | + return $m; |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | 508 | /** |
| 509 | 509 | * Trim and sanitize the values |
@@ -519,87 +519,87 @@ discard block |
||
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 522 | - $m = false; |
|
| 523 | - if ( $cond == '==' ) { |
|
| 524 | - if ( is_array($hide_opt) ) { |
|
| 525 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 526 | - $m = empty($m) ? false : true; |
|
| 527 | - } else { |
|
| 528 | - $m = in_array($hide_opt, $observed_value); |
|
| 529 | - } |
|
| 530 | - } else if ( $cond == '!=' ) { |
|
| 531 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 532 | - } else if ( $cond == '>' ) { |
|
| 533 | - $min = min($observed_value); |
|
| 534 | - $m = $min > $hide_opt; |
|
| 535 | - } else if ( $cond == '<' ) { |
|
| 536 | - $max = max($observed_value); |
|
| 537 | - $m = $max < $hide_opt; |
|
| 538 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 539 | - foreach ( $observed_value as $ob ) { |
|
| 540 | - $m = strpos($ob, $hide_opt); |
|
| 541 | - if ( $m !== false ) { |
|
| 542 | - $m = true; |
|
| 543 | - break; |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - if ( $cond == 'not LIKE' ) { |
|
| 548 | - $m = ( $m === false ) ? true : false; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - return $m; |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * Replace a few basic shortcodes and field ids |
|
| 557 | - * @since 2.0 |
|
| 558 | - * @return string |
|
| 559 | - */ |
|
| 522 | + $m = false; |
|
| 523 | + if ( $cond == '==' ) { |
|
| 524 | + if ( is_array($hide_opt) ) { |
|
| 525 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 526 | + $m = empty($m) ? false : true; |
|
| 527 | + } else { |
|
| 528 | + $m = in_array($hide_opt, $observed_value); |
|
| 529 | + } |
|
| 530 | + } else if ( $cond == '!=' ) { |
|
| 531 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 532 | + } else if ( $cond == '>' ) { |
|
| 533 | + $min = min($observed_value); |
|
| 534 | + $m = $min > $hide_opt; |
|
| 535 | + } else if ( $cond == '<' ) { |
|
| 536 | + $max = max($observed_value); |
|
| 537 | + $m = $max < $hide_opt; |
|
| 538 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 539 | + foreach ( $observed_value as $ob ) { |
|
| 540 | + $m = strpos($ob, $hide_opt); |
|
| 541 | + if ( $m !== false ) { |
|
| 542 | + $m = true; |
|
| 543 | + break; |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + if ( $cond == 'not LIKE' ) { |
|
| 548 | + $m = ( $m === false ) ? true : false; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + return $m; |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * Replace a few basic shortcodes and field ids |
|
| 557 | + * @since 2.0 |
|
| 558 | + * @return string |
|
| 559 | + */ |
|
| 560 | 560 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 561 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 562 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 563 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 564 | - } |
|
| 561 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 562 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 563 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 567 | - $value = do_shortcode($value); |
|
| 566 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 567 | + $value = do_shortcode($value); |
|
| 568 | 568 | |
| 569 | - return $value; |
|
| 570 | - } |
|
| 569 | + return $value; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | 572 | public static function get_shortcodes( $content, $form_id ) { |
| 573 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 574 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 575 | - } |
|
| 573 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 574 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | $fields = FrmField::getAll( array( |
| 578 | 578 | 'fi.form_id' => (int) $form_id, |
| 579 | 579 | 'fi.type not' => FrmField::no_save_fields(), |
| 580 | 580 | ) ); |
| 581 | 581 | |
| 582 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 582 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 583 | 583 | |
| 584 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 584 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 585 | 585 | |
| 586 | - return $matches; |
|
| 587 | - } |
|
| 586 | + return $matches; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | 589 | public static function allowed_shortcodes( $fields = array() ) { |
| 590 | 590 | $tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' ); |
| 591 | 591 | |
| 592 | - foreach ( $fields as $field ) { |
|
| 593 | - $tagregexp[] = $field->id; |
|
| 594 | - $tagregexp[] = $field->field_key; |
|
| 595 | - } |
|
| 592 | + foreach ( $fields as $field ) { |
|
| 593 | + $tagregexp[] = $field->id; |
|
| 594 | + $tagregexp[] = $field->field_key; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | - $tagregexp = implode('|', $tagregexp); |
|
| 598 | - return $tagregexp; |
|
| 599 | - } |
|
| 597 | + $tagregexp = implode('|', $tagregexp); |
|
| 598 | + return $tagregexp; |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | 601 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 602 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 602 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 603 | 603 | if ( empty( $tag ) ) { |
| 604 | 604 | continue; |
| 605 | 605 | } |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | return $content; |
| 622 | - } |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | 625 | * @since 3.0 |
@@ -713,67 +713,67 @@ discard block |
||
| 713 | 713 | return $replace_with; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - /** |
|
| 717 | - * Get the value to replace a few standard shortcodes |
|
| 718 | - * |
|
| 719 | - * @since 2.0 |
|
| 720 | - * @return string |
|
| 721 | - */ |
|
| 722 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 723 | - $new_value = ''; |
|
| 724 | - switch ( $tag ) { |
|
| 725 | - case 'admin_email': |
|
| 726 | - $new_value = get_option('admin_email'); |
|
| 727 | - break; |
|
| 728 | - case 'siteurl': |
|
| 729 | - $new_value = FrmAppHelper::site_url(); |
|
| 730 | - break; |
|
| 731 | - case 'frmurl': |
|
| 732 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 733 | - break; |
|
| 734 | - case 'sitename': |
|
| 735 | - $new_value = FrmAppHelper::site_name(); |
|
| 736 | - break; |
|
| 737 | - case 'get': |
|
| 738 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - return $new_value; |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Process the [get] shortcode |
|
| 746 | - * |
|
| 747 | - * @since 2.0 |
|
| 748 | - * @return string|array |
|
| 749 | - */ |
|
| 750 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 751 | - if ( ! isset($atts['param']) ) { |
|
| 752 | - return ''; |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - if ( strpos($atts['param'], '[') ) { |
|
| 756 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 757 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 758 | - } |
|
| 716 | + /** |
|
| 717 | + * Get the value to replace a few standard shortcodes |
|
| 718 | + * |
|
| 719 | + * @since 2.0 |
|
| 720 | + * @return string |
|
| 721 | + */ |
|
| 722 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 723 | + $new_value = ''; |
|
| 724 | + switch ( $tag ) { |
|
| 725 | + case 'admin_email': |
|
| 726 | + $new_value = get_option('admin_email'); |
|
| 727 | + break; |
|
| 728 | + case 'siteurl': |
|
| 729 | + $new_value = FrmAppHelper::site_url(); |
|
| 730 | + break; |
|
| 731 | + case 'frmurl': |
|
| 732 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 733 | + break; |
|
| 734 | + case 'sitename': |
|
| 735 | + $new_value = FrmAppHelper::site_name(); |
|
| 736 | + break; |
|
| 737 | + case 'get': |
|
| 738 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + return $new_value; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Process the [get] shortcode |
|
| 746 | + * |
|
| 747 | + * @since 2.0 |
|
| 748 | + * @return string|array |
|
| 749 | + */ |
|
| 750 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 751 | + if ( ! isset($atts['param']) ) { |
|
| 752 | + return ''; |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + if ( strpos($atts['param'], '[') ) { |
|
| 756 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 757 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | 760 | $new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' ); |
| 761 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 761 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 762 | 762 | |
| 763 | - if ( $new_value == '' ) { |
|
| 764 | - if ( ! isset($atts['prev_val']) ) { |
|
| 765 | - $atts['prev_val'] = ''; |
|
| 766 | - } |
|
| 763 | + if ( $new_value == '' ) { |
|
| 764 | + if ( ! isset($atts['prev_val']) ) { |
|
| 765 | + $atts['prev_val'] = ''; |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 769 | - } |
|
| 768 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 772 | - $new_value = implode(', ', $new_value); |
|
| 773 | - } |
|
| 771 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 772 | + $new_value = implode(', ', $new_value); |
|
| 773 | + } |
|
| 774 | 774 | |
| 775 | - return $new_value; |
|
| 776 | - } |
|
| 775 | + return $new_value; |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | 778 | public static function get_display_value( $value, $field, $atts = array() ) { |
| 779 | 779 | |
@@ -843,27 +843,27 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 845 | 845 | |
| 846 | - $field_types = array(); |
|
| 847 | - if ( in_array($type, $single_input) ) { |
|
| 848 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 849 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 850 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 851 | - } else if ( in_array($type, $other_type) ) { |
|
| 852 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 846 | + $field_types = array(); |
|
| 847 | + if ( in_array($type, $single_input) ) { |
|
| 848 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 849 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 850 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 851 | + } else if ( in_array($type, $other_type) ) { |
|
| 852 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 853 | 853 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 854 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 855 | - } |
|
| 854 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | 857 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 858 | - return $field_types; |
|
| 859 | - } |
|
| 858 | + return $field_types; |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 862 | - foreach ( $inputs as $input ) { |
|
| 863 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 864 | - unset($input); |
|
| 865 | - } |
|
| 866 | - } |
|
| 861 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 862 | + foreach ( $inputs as $input ) { |
|
| 863 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 864 | + unset($input); |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | 867 | |
| 868 | 868 | /** |
| 869 | 869 | * Check if current field option is an "other" option |
@@ -877,14 +877,14 @@ discard block |
||
| 877 | 877 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - /** |
|
| 881 | - * Get value that belongs in "Other" text box |
|
| 882 | - * |
|
| 883 | - * @since 2.0.6 |
|
| 884 | - * |
|
| 885 | - * @param array $args |
|
| 886 | - */ |
|
| 887 | - public static function get_other_val( $args ) { |
|
| 880 | + /** |
|
| 881 | + * Get value that belongs in "Other" text box |
|
| 882 | + * |
|
| 883 | + * @since 2.0.6 |
|
| 884 | + * |
|
| 885 | + * @param array $args |
|
| 886 | + */ |
|
| 887 | + public static function get_other_val( $args ) { |
|
| 888 | 888 | $defaults = array( |
| 889 | 889 | 'opt_key' => 0, |
| 890 | 890 | 'field' => array(), |
@@ -962,20 +962,20 @@ discard block |
||
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | return $other_val; |
| 965 | - } |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 969 | - * Intended for front-end use |
|
| 970 | - * |
|
| 971 | - * @since 2.0.6 |
|
| 972 | - * |
|
| 973 | - * @param array $args should include field, opt_key and field name |
|
| 974 | - * @param boolean $other_opt |
|
| 975 | - * @param string $checked |
|
| 976 | - * @return array $other_args |
|
| 977 | - */ |
|
| 978 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 969 | + * Intended for front-end use |
|
| 970 | + * |
|
| 971 | + * @since 2.0.6 |
|
| 972 | + * |
|
| 973 | + * @param array $args should include field, opt_key and field name |
|
| 974 | + * @param boolean $other_opt |
|
| 975 | + * @param string $checked |
|
| 976 | + * @return array $other_args |
|
| 977 | + */ |
|
| 978 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 979 | 979 | //Check if this is an "Other" option |
| 980 | 980 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 981 | 981 | return; |
@@ -991,8 +991,8 @@ discard block |
||
| 991 | 991 | $checked = 'checked="checked" '; |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | - return $other_args; |
|
| 995 | - } |
|
| 994 | + return $other_args; |
|
| 995 | + } |
|
| 996 | 996 | |
| 997 | 997 | /** |
| 998 | 998 | * @param array $args |
@@ -1047,8 +1047,8 @@ discard block |
||
| 1047 | 1047 | * @since 2.0.6 |
| 1048 | 1048 | */ |
| 1049 | 1049 | public static function include_other_input( $args ) { |
| 1050 | - if ( ! $args['other_opt'] ) { |
|
| 1051 | - return; |
|
| 1050 | + if ( ! $args['other_opt'] ) { |
|
| 1051 | + return; |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | $classes = array( 'frm_other_input' ); |
@@ -1073,15 +1073,15 @@ discard block |
||
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | /** |
| 1076 | - * Get the HTML id for an "Other" text field |
|
| 1077 | - * Note: This does not affect fields in repeating sections |
|
| 1078 | - * |
|
| 1079 | - * @since 2.0.08 |
|
| 1080 | - * @param string $type - field type |
|
| 1081 | - * @param string $html_id |
|
| 1082 | - * @param string|boolean $opt_key |
|
| 1083 | - * @return string $other_id |
|
| 1084 | - */ |
|
| 1076 | + * Get the HTML id for an "Other" text field |
|
| 1077 | + * Note: This does not affect fields in repeating sections |
|
| 1078 | + * |
|
| 1079 | + * @since 2.0.08 |
|
| 1080 | + * @param string $type - field type |
|
| 1081 | + * @param string $html_id |
|
| 1082 | + * @param string|boolean $opt_key |
|
| 1083 | + * @return string $other_id |
|
| 1084 | + */ |
|
| 1085 | 1085 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1086 | 1086 | $other_id = $html_id; |
| 1087 | 1087 | |
@@ -1145,10 +1145,10 @@ discard block |
||
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | public static function switch_field_ids( $val ) { |
| 1148 | - global $frm_duplicate_ids; |
|
| 1149 | - $replace = array(); |
|
| 1150 | - $replace_with = array(); |
|
| 1151 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1148 | + global $frm_duplicate_ids; |
|
| 1149 | + $replace = array(); |
|
| 1150 | + $replace_with = array(); |
|
| 1151 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1152 | 1152 | $replace[] = '[if ' . $old . ']'; |
| 1153 | 1153 | $replace_with[] = '[if ' . $new . ']'; |
| 1154 | 1154 | $replace[] = '[if ' . $old . ' '; |
@@ -1163,19 +1163,19 @@ discard block |
||
| 1163 | 1163 | $replace_with[] = '[' . $new . ']'; |
| 1164 | 1164 | $replace[] = '[' . $old . ' '; |
| 1165 | 1165 | $replace_with[] = '[' . $new . ' '; |
| 1166 | - unset($old, $new); |
|
| 1167 | - } |
|
| 1166 | + unset($old, $new); |
|
| 1167 | + } |
|
| 1168 | 1168 | if ( is_array( $val ) ) { |
| 1169 | 1169 | foreach ( $val as $k => $v ) { |
| 1170 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1171 | - unset($k, $v); |
|
| 1172 | - } |
|
| 1173 | - } else { |
|
| 1174 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1175 | - } |
|
| 1170 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1171 | + unset($k, $v); |
|
| 1172 | + } |
|
| 1173 | + } else { |
|
| 1174 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | - return $val; |
|
| 1178 | - } |
|
| 1177 | + return $val; |
|
| 1178 | + } |
|
| 1179 | 1179 | |
| 1180 | 1180 | public static function get_us_states() { |
| 1181 | 1181 | return apply_filters( 'frm_us_states', array( |
@@ -1240,15 +1240,15 @@ discard block |
||
| 1240 | 1240 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1241 | 1241 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1242 | 1242 | |
| 1243 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1244 | - $state_abv = array_keys($states); |
|
| 1245 | - sort($state_abv); |
|
| 1243 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1244 | + $state_abv = array_keys($states); |
|
| 1245 | + sort($state_abv); |
|
| 1246 | 1246 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1247 | 1247 | |
| 1248 | - $states = array_values($states); |
|
| 1249 | - sort($states); |
|
| 1248 | + $states = array_values($states); |
|
| 1249 | + sort($states); |
|
| 1250 | 1250 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1251 | - unset($state_abv, $states); |
|
| 1251 | + unset($state_abv, $states); |
|
| 1252 | 1252 | |
| 1253 | 1253 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1254 | 1254 | __( 'Under 18', 'formidable' ), |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | ); |
| 1290 | 1290 | |
| 1291 | 1291 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1292 | - } |
|
| 1292 | + } |
|
| 1293 | 1293 | |
| 1294 | 1294 | /** |
| 1295 | 1295 | * Display a field value selector |
@@ -1299,10 +1299,10 @@ discard block |
||
| 1299 | 1299 | * @param int $selector_field_id |
| 1300 | 1300 | * @param array $selector_args |
| 1301 | 1301 | */ |
| 1302 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1303 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1304 | - $field_value_selector->display(); |
|
| 1305 | - } |
|
| 1302 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1303 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1304 | + $field_value_selector->display(); |
|
| 1305 | + } |
|
| 1306 | 1306 | |
| 1307 | 1307 | /** |
| 1308 | 1308 | * Convert a field object to a flat array |