@@ -1,109 +1,109 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmFormActionsController { |
| 4 | - public static $action_post_type = 'frm_form_actions'; |
|
| 5 | - public static $registered_actions; |
|
| 6 | - |
|
| 7 | - public static function register_post_types() { |
|
| 8 | - register_post_type( self::$action_post_type, array( |
|
| 9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | - 'description' => '', |
|
| 11 | - 'public' => false, |
|
| 12 | - 'show_ui' => false, |
|
| 13 | - 'exclude_from_search' => true, |
|
| 14 | - 'show_in_nav_menus' => false, |
|
| 15 | - 'show_in_menu' => true, |
|
| 16 | - 'capability_type' => 'page', |
|
| 17 | - 'supports' => array( |
|
| 4 | + public static $action_post_type = 'frm_form_actions'; |
|
| 5 | + public static $registered_actions; |
|
| 6 | + |
|
| 7 | + public static function register_post_types() { |
|
| 8 | + register_post_type( self::$action_post_type, array( |
|
| 9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
| 10 | + 'description' => '', |
|
| 11 | + 'public' => false, |
|
| 12 | + 'show_ui' => false, |
|
| 13 | + 'exclude_from_search' => true, |
|
| 14 | + 'show_in_nav_menus' => false, |
|
| 15 | + 'show_in_menu' => true, |
|
| 16 | + 'capability_type' => 'page', |
|
| 17 | + 'supports' => array( |
|
| 18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
| 19 | 19 | 'page-attributes', |
| 20 | - ), |
|
| 21 | - 'has_archive' => false, |
|
| 22 | - ) ); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * post_content: json settings |
|
| 26 | - * menu_order: form id |
|
| 27 | - * post_excerpt: action type |
|
| 28 | - */ |
|
| 29 | - |
|
| 30 | - self::actions_init(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function actions_init() { |
|
| 34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | - self::register_actions(); |
|
| 36 | - do_action( 'frm_form_actions_init' ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - public static function register_actions() { |
|
| 40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | - 'email' => 'FrmEmailAction', |
|
| 42 | - 'wppost' => 'FrmDefPostAction', |
|
| 43 | - 'register' => 'FrmDefRegAction', |
|
| 44 | - 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | - //'aweber' => 'FrmDefAweberAction', |
|
| 46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | - 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | - 'highrise' => 'FrmDefHrsAction', |
|
| 49 | - ) ); |
|
| 50 | - |
|
| 51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | - |
|
| 54 | - foreach ( $action_classes as $action_class ) { |
|
| 55 | - self::$registered_actions->register($action_class); |
|
| 56 | - } |
|
| 57 | - } |
|
| 20 | + ), |
|
| 21 | + 'has_archive' => false, |
|
| 22 | + ) ); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * post_content: json settings |
|
| 26 | + * menu_order: form id |
|
| 27 | + * post_excerpt: action type |
|
| 28 | + */ |
|
| 29 | + |
|
| 30 | + self::actions_init(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function actions_init() { |
|
| 34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
| 35 | + self::register_actions(); |
|
| 36 | + do_action( 'frm_form_actions_init' ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + public static function register_actions() { |
|
| 40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
| 41 | + 'email' => 'FrmEmailAction', |
|
| 42 | + 'wppost' => 'FrmDefPostAction', |
|
| 43 | + 'register' => 'FrmDefRegAction', |
|
| 44 | + 'paypal' => 'FrmDefPayPalAction', |
|
| 45 | + //'aweber' => 'FrmDefAweberAction', |
|
| 46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
| 47 | + 'twilio' => 'FrmDefTwilioAction', |
|
| 48 | + 'highrise' => 'FrmDefHrsAction', |
|
| 49 | + ) ); |
|
| 50 | + |
|
| 51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
| 52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
| 53 | + |
|
| 54 | + foreach ( $action_classes as $action_class ) { |
|
| 55 | + self::$registered_actions->register($action_class); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | public static function get_form_actions( $action = 'all' ) { |
| 60 | - $temp_actions = self::$registered_actions; |
|
| 61 | - if ( empty($temp_actions) ) { |
|
| 62 | - self::actions_init(); |
|
| 63 | - $temp_actions = self::$registered_actions->actions; |
|
| 64 | - } else { |
|
| 65 | - $temp_actions = $temp_actions->actions; |
|
| 66 | - } |
|
| 60 | + $temp_actions = self::$registered_actions; |
|
| 61 | + if ( empty($temp_actions) ) { |
|
| 62 | + self::actions_init(); |
|
| 63 | + $temp_actions = self::$registered_actions->actions; |
|
| 64 | + } else { |
|
| 65 | + $temp_actions = $temp_actions->actions; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $actions = array(); |
|
| 68 | + $actions = array(); |
|
| 69 | 69 | |
| 70 | - foreach ( $temp_actions as $a ) { |
|
| 71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | - return $a; |
|
| 73 | - } |
|
| 70 | + foreach ( $temp_actions as $a ) { |
|
| 71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
| 72 | + return $a; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | $actions[ $a->id_base ] = $a; |
| 76 | - } |
|
| 77 | - unset( $temp_actions, $a ); |
|
| 78 | - |
|
| 79 | - $action_limit = 10; |
|
| 80 | - if ( count( $actions ) <= $action_limit ) { |
|
| 81 | - return $actions; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // remove the last few inactive icons if there are too many |
|
| 85 | - $temp_actions = $actions; |
|
| 86 | - arsort( $temp_actions ); |
|
| 87 | - foreach ( $temp_actions as $type => $a ) { |
|
| 88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 76 | + } |
|
| 77 | + unset( $temp_actions, $a ); |
|
| 78 | + |
|
| 79 | + $action_limit = 10; |
|
| 80 | + if ( count( $actions ) <= $action_limit ) { |
|
| 81 | + return $actions; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // remove the last few inactive icons if there are too many |
|
| 85 | + $temp_actions = $actions; |
|
| 86 | + arsort( $temp_actions ); |
|
| 87 | + foreach ( $temp_actions as $type => $a ) { |
|
| 88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
| 89 | 89 | unset( $actions[ $type ] ); |
| 90 | - if ( count( $actions ) <= $action_limit ) { |
|
| 91 | - break; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - unset( $type, $a ); |
|
| 95 | - } |
|
| 90 | + if ( count( $actions ) <= $action_limit ) { |
|
| 91 | + break; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + unset( $type, $a ); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $actions; |
|
| 98 | - } |
|
| 97 | + return $actions; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * @since 2.0 |
| 102 | 102 | */ |
| 103 | - public static function list_actions( $form, $values ) { |
|
| 104 | - if ( empty( $form ) ) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 103 | + public static function list_actions( $form, $values ) { |
|
| 104 | + if ( empty( $form ) ) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
| 115 | 115 | |
| 116 | - $action_controls = self::get_form_actions(); |
|
| 116 | + $action_controls = self::get_form_actions(); |
|
| 117 | 117 | |
| 118 | - $action_map = array(); |
|
| 118 | + $action_map = array(); |
|
| 119 | 119 | |
| 120 | 120 | foreach ( $action_controls as $key => $control ) { |
| 121 | - $action_map[ $control->id_base ] = $key; |
|
| 122 | - } |
|
| 121 | + $action_map[ $control->id_base ] = $key; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - foreach ( $form_actions as $action ) { |
|
| 125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | - // don't try and show settings if action no longer exists |
|
| 127 | - continue; |
|
| 128 | - } |
|
| 124 | + foreach ( $form_actions as $action ) { |
|
| 125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
| 126 | + // don't try and show settings if action no longer exists |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | - } |
|
| 132 | - } |
|
| 130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 135 | - $action_control->_set($action_key); |
|
| 135 | + $action_control->_set($action_key); |
|
| 136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public static function add_form_action() { |
|
| 139 | + public static function add_form_action() { |
|
| 140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 142 | 142 | |
| 143 | - global $frm_vars; |
|
| 143 | + global $frm_vars; |
|
| 144 | 144 | |
| 145 | 145 | $action_key = absint( $_POST['list_id'] ); |
| 146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
| 147 | 147 | |
| 148 | - $action_control = self::get_form_actions( $action_type ); |
|
| 149 | - $action_control->_set($action_key); |
|
| 148 | + $action_control = self::get_form_actions( $action_type ); |
|
| 149 | + $action_control->_set($action_key); |
|
| 150 | 150 | |
| 151 | - $form_id = absint( $_POST['form_id'] ); |
|
| 151 | + $form_id = absint( $_POST['form_id'] ); |
|
| 152 | 152 | |
| 153 | - $form_action = $action_control->prepare_new($form_id); |
|
| 153 | + $form_action = $action_control->prepare_new($form_id); |
|
| 154 | 154 | |
| 155 | - $values = array(); |
|
| 156 | - $form = self::fields_to_values($form_id, $values); |
|
| 155 | + $values = array(); |
|
| 156 | + $form = self::fields_to_values($form_id, $values); |
|
| 157 | 157 | |
| 158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
| 159 | - wp_die(); |
|
| 160 | - } |
|
| 159 | + wp_die(); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public static function fill_action() { |
|
| 162 | + public static function fill_action() { |
|
| 163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 165 | 165 | |
| 166 | - $action_key = absint( $_POST['action_id'] ); |
|
| 167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 166 | + $action_key = absint( $_POST['action_id'] ); |
|
| 167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
| 168 | 168 | |
| 169 | - $action_control = self::get_form_actions( $action_type ); |
|
| 170 | - if ( empty($action_control) ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 169 | + $action_control = self::get_form_actions( $action_type ); |
|
| 170 | + if ( empty($action_control) ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
| 174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
| 175 | 175 | |
| 176 | - $values = array(); |
|
| 177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 176 | + $values = array(); |
|
| 177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
| 178 | 178 | |
| 179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
| 180 | - wp_die(); |
|
| 181 | - } |
|
| 180 | + wp_die(); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
| 184 | - $form = FrmForm::getOne($form_id); |
|
| 184 | + $form = FrmForm::getOne($form_id); |
|
| 185 | 185 | |
| 186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
| 187 | 187 | |
| 188 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | - foreach ( $fields as $k => $f ) { |
|
| 190 | - $f = (array) $f; |
|
| 191 | - $opts = (array) $f['field_options']; |
|
| 192 | - $f = array_merge($opts, $f); |
|
| 193 | - if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | - $f['post_field'] = ''; |
|
| 195 | - } |
|
| 196 | - $values['fields'][] = $f; |
|
| 197 | - unset($k, $f); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $form; |
|
| 201 | - } |
|
| 188 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 189 | + foreach ( $fields as $k => $f ) { |
|
| 190 | + $f = (array) $f; |
|
| 191 | + $opts = (array) $f['field_options']; |
|
| 192 | + $f = array_merge($opts, $f); |
|
| 193 | + if ( ! isset( $f['post_field'] ) ) { |
|
| 194 | + $f['post_field'] = ''; |
|
| 195 | + } |
|
| 196 | + $values['fields'][] = $f; |
|
| 197 | + unset($k, $f); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $form; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | public static function update_settings( $form_id ) { |
| 204 | - global $wpdb; |
|
| 204 | + global $wpdb; |
|
| 205 | 205 | |
| 206 | - $registered_actions = self::$registered_actions->actions; |
|
| 206 | + $registered_actions = self::$registered_actions->actions; |
|
| 207 | 207 | |
| 208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
| 209 | - $new_actions = array(); |
|
| 209 | + $new_actions = array(); |
|
| 210 | 210 | |
| 211 | - foreach ( $registered_actions as $registered_action ) { |
|
| 212 | - $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | - if ( ! empty( $action_ids ) ) { |
|
| 214 | - $new_actions[] = $action_ids; |
|
| 215 | - } |
|
| 216 | - } |
|
| 211 | + foreach ( $registered_actions as $registered_action ) { |
|
| 212 | + $action_ids = $registered_action->update_callback($form_id); |
|
| 213 | + if ( ! empty( $action_ids ) ) { |
|
| 214 | + $new_actions[] = $action_ids; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - //Only use array_merge if there are new actions |
|
| 219 | - if ( ! empty( $new_actions ) ) { |
|
| 220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | - } |
|
| 222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 218 | + //Only use array_merge if there are new actions |
|
| 219 | + if ( ! empty( $new_actions ) ) { |
|
| 220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
| 221 | + } |
|
| 222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
| 223 | 223 | |
| 224 | 224 | self::delete_missing_actions( $old_actions ); |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | public static function delete_missing_actions( $old_actions ) { |
| 228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -242,22 +242,22 @@ discard block |
||
| 242 | 242 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * @param string $event |
|
| 247 | - */ |
|
| 245 | + /** |
|
| 246 | + * @param string $event |
|
| 247 | + */ |
|
| 248 | 248 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
| 249 | 249 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
| 250 | 250 | |
| 251 | 251 | if ( empty( $form_actions ) ) { |
| 252 | - return; |
|
| 253 | - } |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | FrmForm::maybe_get_form( $form ); |
| 256 | 256 | |
| 257 | - $link_settings = self::get_form_actions( $type ); |
|
| 258 | - if ( 'all' != $type ) { |
|
| 259 | - $link_settings = array( $type => $link_settings ); |
|
| 260 | - } |
|
| 257 | + $link_settings = self::get_form_actions( $type ); |
|
| 258 | + if ( 'all' != $type ) { |
|
| 259 | + $link_settings = array( $type => $link_settings ); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | $stored_actions = array(); |
| 263 | 263 | $action_priority = array(); |
@@ -268,17 +268,17 @@ discard block |
||
| 268 | 268 | $this_event = $event; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - foreach ( $form_actions as $action ) { |
|
| 271 | + foreach ( $form_actions as $action ) { |
|
| 272 | 272 | |
| 273 | 273 | $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); |
| 274 | 274 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
| 275 | 275 | if ( $skip_this_action ) { |
| 276 | - continue; |
|
| 277 | - } |
|
| 276 | + continue; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - if ( ! is_object( $entry ) ) { |
|
| 280 | - $entry = FrmEntry::getOne( $entry, true ); |
|
| 281 | - } |
|
| 279 | + if ( ! is_object( $entry ) ) { |
|
| 280 | + $entry = FrmEntry::getOne( $entry, true ); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
| 284 | 284 | continue; |
@@ -292,64 +292,64 @@ discard block |
||
| 292 | 292 | if ( ! $trigger_children ) { |
| 293 | 293 | continue; |
| 294 | 294 | } |
| 295 | - } |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - // check conditional logic |
|
| 297 | + // check conditional logic |
|
| 298 | 298 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
| 299 | - if ( $stop ) { |
|
| 300 | - continue; |
|
| 301 | - } |
|
| 299 | + if ( $stop ) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - // store actions so they can be triggered with the correct priority |
|
| 304 | - $stored_actions[ $action->ID ] = $action; |
|
| 305 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 303 | + // store actions so they can be triggered with the correct priority |
|
| 304 | + $stored_actions[ $action->ID ] = $action; |
|
| 305 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
| 306 | 306 | |
| 307 | - unset($action); |
|
| 308 | - } |
|
| 307 | + unset($action); |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - if ( ! empty( $stored_actions ) ) { |
|
| 311 | - asort($action_priority); |
|
| 310 | + if ( ! empty( $stored_actions ) ) { |
|
| 311 | + asort($action_priority); |
|
| 312 | 312 | |
| 313 | - // make sure hooks are loaded |
|
| 314 | - new FrmNotification(); |
|
| 313 | + // make sure hooks are loaded |
|
| 314 | + new FrmNotification(); |
|
| 315 | 315 | |
| 316 | - foreach ( $action_priority as $action_id => $priority ) { |
|
| 317 | - $action = $stored_actions[ $action_id ]; |
|
| 316 | + foreach ( $action_priority as $action_id => $priority ) { |
|
| 317 | + $action = $stored_actions[ $action_id ]; |
|
| 318 | 318 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
| 319 | 319 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
| 320 | 320 | |
| 321 | - // If post is created, get updated $entry object |
|
| 322 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 323 | - $entry = FrmEntry::getOne($entry->id, true); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } |
|
| 321 | + // If post is created, get updated $entry object |
|
| 322 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
| 323 | + $entry = FrmEntry::getOne($entry->id, true); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | 329 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
| 330 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 331 | - // continue if we know which actions to copy |
|
| 332 | - return; |
|
| 333 | - } |
|
| 330 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
| 331 | + // continue if we know which actions to copy |
|
| 332 | + return; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - $action_controls = self::get_form_actions( ); |
|
| 335 | + $action_controls = self::get_form_actions( ); |
|
| 336 | 336 | |
| 337 | - foreach ( $action_controls as $action_control ) { |
|
| 338 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 339 | - unset( $action_control ); |
|
| 340 | - } |
|
| 341 | - } |
|
| 337 | + foreach ( $action_controls as $action_control ) { |
|
| 338 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
| 339 | + unset( $action_control ); |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - public static function limit_by_type( $where ) { |
|
| 344 | - global $frm_vars, $wpdb; |
|
| 343 | + public static function limit_by_type( $where ) { |
|
| 344 | + global $frm_vars, $wpdb; |
|
| 345 | 345 | |
| 346 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 347 | - return $where; |
|
| 348 | - } |
|
| 346 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
| 347 | + return $where; |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 351 | - return $where; |
|
| 352 | - } |
|
| 350 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
| 351 | + return $where; |
|
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | foreach ( $keys as $key ) { |
| 377 | 377 | // don't register new action if old action with the same id is already registered |
| 378 | 378 | if ( ! isset( $this->actions[ $key ] ) ) { |
| 379 | - $this->actions[ $key ]->_register(); |
|
| 379 | + $this->actions[ $key ]->_register(); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -2,129 +2,129 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 61 | 61 | |
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | - // this hook will allow for multiple fields to be added at once |
|
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 64 | + // this hook will allow for multiple fields to be added at once |
|
| 65 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 66 | 66 | |
| 67 | - wp_die(); |
|
| 68 | - } |
|
| 67 | + wp_die(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Set up and create a new field |
|
| 72 | - * |
|
| 73 | - * @param string $field_type |
|
| 74 | - * @param integer $form_id |
|
| 75 | - * @return array|bool |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Set up and create a new field |
|
| 72 | + * |
|
| 73 | + * @param string $field_type |
|
| 74 | + * @param integer $form_id |
|
| 75 | + * @return array|bool |
|
| 76 | + */ |
|
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | - $values = array(); |
|
| 79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | - } |
|
| 78 | + $values = array(); |
|
| 79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 85 | 85 | |
| 86 | - $field_id = FrmField::create( $field_values ); |
|
| 86 | + $field_id = FrmField::create( $field_values ); |
|
| 87 | 87 | |
| 88 | - if ( ! $field_id ) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 88 | + if ( ! $field_id ) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 93 | 93 | |
| 94 | - return $field; |
|
| 95 | - } |
|
| 94 | + return $field; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 102 | - $field = 'name'; |
|
| 103 | - } |
|
| 101 | + if ( empty($field) ) { |
|
| 102 | + $field = 'name'; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty($id) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | - // set blank value if there is no content |
|
| 114 | - $value = ''; |
|
| 115 | - } |
|
| 112 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | + // set blank value if there is no content |
|
| 114 | + $value = ''; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
| 118 | 118 | |
| 119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 120 | 120 | |
| 121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
| 122 | - wp_die(); |
|
| 123 | - } |
|
| 122 | + wp_die(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function update_ajax_option() { |
|
| 125 | + public static function update_ajax_option() { |
|
| 126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 130 | 130 | if ( ! $field_id ) { |
@@ -139,144 +139,144 @@ discard block |
||
| 139 | 139 | unset($new_val); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - FrmField::update( $field_id, array( |
|
| 143 | - 'field_options' => $field->field_options, |
|
| 142 | + FrmField::update( $field_id, array( |
|
| 143 | + 'field_options' => $field->field_options, |
|
| 144 | 144 | 'form_id' => $field->form_id, |
| 145 | - ) ); |
|
| 146 | - wp_die(); |
|
| 147 | - } |
|
| 145 | + ) ); |
|
| 146 | + wp_die(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - public static function duplicate() { |
|
| 149 | + public static function duplicate() { |
|
| 150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 152 | 152 | |
| 153 | - global $wpdb; |
|
| 153 | + global $wpdb; |
|
| 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 ); |
| 165 | 165 | |
| 166 | 166 | $values = array(); |
| 167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 168 | 168 | |
| 169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 170 | 170 | |
| 171 | - $values['field_order'] = $field_count + 1; |
|
| 171 | + $values['field_order'] = $field_count + 1; |
|
| 172 | 172 | |
| 173 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 173 | + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 174 | 174 | |
| 175 | 175 | $field_id = FrmField::create( $values ); |
| 176 | 176 | if ( ! $field_id ) { |
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - self::include_single_field($field_id, $values); |
|
| 180 | + self::include_single_field($field_id, $values); |
|
| 181 | 181 | |
| 182 | - wp_die(); |
|
| 183 | - } |
|
| 182 | + wp_die(); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Load a single field in the form builder along with all needed variables |
|
| 187 | - */ |
|
| 188 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 185 | + /** |
|
| 186 | + * Load a single field in the form builder along with all needed variables |
|
| 187 | + */ |
|
| 188 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
| 191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | - if ( $field['type'] == 'html' ) { |
|
| 194 | - $field['stop_filter'] = true; |
|
| 195 | - } |
|
| 191 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | + if ( $field['type'] == 'html' ) { |
|
| 194 | + $field['stop_filter'] = true; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 198 | 198 | |
| 199 | - return $field; |
|
| 200 | - } |
|
| 199 | + return $field; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - public static function destroy() { |
|
| 202 | + public static function destroy() { |
|
| 203 | 203 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 204 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 204 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 205 | 205 | |
| 206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 207 | 207 | FrmField::destroy( $field_id ); |
| 208 | - wp_die(); |
|
| 209 | - } |
|
| 208 | + wp_die(); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /* Field Options */ |
|
| 211 | + /* Field Options */ |
|
| 212 | 212 | |
| 213 | - //Add Single Option or Other Option |
|
| 214 | - public static function add_option() { |
|
| 213 | + //Add Single Option or Other Option |
|
| 214 | + public static function add_option() { |
|
| 215 | 215 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 216 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 216 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 217 | 217 | |
| 218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 220 | 220 | |
| 221 | - //Get the field |
|
| 222 | - $field = FrmField::getOne($id); |
|
| 221 | + //Get the field |
|
| 222 | + $field = FrmField::getOne($id); |
|
| 223 | 223 | |
| 224 | 224 | if ( ! empty( $field->options ) ) { |
| 225 | 225 | $keys = array_keys( $field->options ); |
| 226 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 227 | - } else { |
|
| 228 | - $last = 0; |
|
| 229 | - } |
|
| 230 | - $opt_key = $last + 1; |
|
| 226 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 227 | + } else { |
|
| 228 | + $last = 0; |
|
| 229 | + } |
|
| 230 | + $opt_key = $last + 1; |
|
| 231 | 231 | |
| 232 | - if ( 'other' == $opt_type ) { |
|
| 232 | + if ( 'other' == $opt_type ) { |
|
| 233 | 233 | $opt = esc_html__( 'Other', 'formidable' ); |
| 234 | - $other_val = ''; |
|
| 235 | - $opt_key = 'other_' . $opt_key; |
|
| 236 | - |
|
| 237 | - //Update value of "other" in DB |
|
| 238 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 239 | - $field_options['other'] = 1; |
|
| 240 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 241 | - } else { |
|
| 234 | + $other_val = ''; |
|
| 235 | + $opt_key = 'other_' . $opt_key; |
|
| 236 | + |
|
| 237 | + //Update value of "other" in DB |
|
| 238 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 239 | + $field_options['other'] = 1; |
|
| 240 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 241 | + } else { |
|
| 242 | 242 | $first_opt = reset( $field->options ); |
| 243 | 243 | $next_opt = count( $field->options ); |
| 244 | - if ( $first_opt != '' ) { |
|
| 245 | - $next_opt++; |
|
| 246 | - } |
|
| 244 | + if ( $first_opt != '' ) { |
|
| 245 | + $next_opt++; |
|
| 246 | + } |
|
| 247 | 247 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 248 | - unset($next_opt); |
|
| 249 | - } |
|
| 250 | - $field_val = $opt; |
|
| 248 | + unset($next_opt); |
|
| 249 | + } |
|
| 250 | + $field_val = $opt; |
|
| 251 | 251 | $field->options[ $opt_key ] = $opt; |
| 252 | 252 | |
| 253 | - //Update options in DB |
|
| 253 | + //Update options in DB |
|
| 254 | 254 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 255 | 255 | |
| 256 | - $field_data = $field; |
|
| 257 | - $field = array( |
|
| 258 | - 'type' => $field_data->type, |
|
| 259 | - 'id' => $id, |
|
| 260 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 261 | - 'form_id' => $field_data->form_id, |
|
| 262 | - 'field_key' => $field_data->field_key, |
|
| 263 | - ); |
|
| 256 | + $field_data = $field; |
|
| 257 | + $field = array( |
|
| 258 | + 'type' => $field_data->type, |
|
| 259 | + 'id' => $id, |
|
| 260 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 261 | + 'form_id' => $field_data->form_id, |
|
| 262 | + 'field_key' => $field_data->field_key, |
|
| 263 | + ); |
|
| 264 | 264 | |
| 265 | 265 | $field_name = 'item_meta[' . $id . ']'; |
| 266 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 267 | - $checked = ''; |
|
| 266 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 267 | + $checked = ''; |
|
| 268 | 268 | |
| 269 | - if ( 'other' == $opt_type ) { |
|
| 269 | + if ( 'other' == $opt_type ) { |
|
| 270 | 270 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 271 | - } else { |
|
| 271 | + } else { |
|
| 272 | 272 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 273 | - } |
|
| 274 | - wp_die(); |
|
| 275 | - } |
|
| 273 | + } |
|
| 274 | + wp_die(); |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - public static function edit_option() { |
|
| 277 | + public static function edit_option() { |
|
| 278 | 278 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 279 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 279 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 280 | 280 | |
| 281 | 281 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 282 | 282 | $ids = explode( '-', $element_id ); |
@@ -285,43 +285,43 @@ discard block |
||
| 285 | 285 | $orig_update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
| 286 | 286 | $update_value = $orig_update_value; |
| 287 | 287 | if ( strpos( $element_id, 'key_' ) ) { |
| 288 | - $new_value = $update_value; |
|
| 289 | - } else { |
|
| 290 | - $new_label = $update_value; |
|
| 291 | - } |
|
| 288 | + $new_value = $update_value; |
|
| 289 | + } else { |
|
| 290 | + $new_label = $update_value; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - $field = FrmField::getOne($id); |
|
| 294 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 293 | + $field = FrmField::getOne($id); |
|
| 294 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 295 | 295 | |
| 296 | - $this_opt_id = end($ids); |
|
| 296 | + $this_opt_id = end($ids); |
|
| 297 | 297 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 298 | 298 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 299 | 299 | |
| 300 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 301 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 300 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 301 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 302 | 302 | |
| 303 | - if ( ! isset( $new_label ) ) { |
|
| 304 | - $new_label = $label; |
|
| 305 | - } |
|
| 303 | + if ( ! isset( $new_label ) ) { |
|
| 304 | + $new_label = $label; |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - if ( isset($new_value) || isset($value) ) { |
|
| 308 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 309 | - } |
|
| 307 | + if ( isset($new_value) || isset($value) ) { |
|
| 308 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | 311 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 312 | 312 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 313 | - } else { |
|
| 313 | + } else { |
|
| 314 | 314 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | 317 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 318 | 318 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 319 | - wp_die(); |
|
| 320 | - } |
|
| 319 | + wp_die(); |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - public static function delete_option() { |
|
| 322 | + public static function delete_option() { |
|
| 323 | 323 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 324 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 324 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 325 | 325 | |
| 326 | 326 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 327 | 327 | $field = FrmField::getOne( $field_id ); |
@@ -329,170 +329,170 @@ discard block |
||
| 329 | 329 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 330 | 330 | |
| 331 | 331 | $options = $field->options; |
| 332 | - unset( $options[ $opt_key ] ); |
|
| 333 | - $response = array( 'other' => true ); |
|
| 332 | + unset( $options[ $opt_key ] ); |
|
| 333 | + $response = array( 'other' => true ); |
|
| 334 | 334 | |
| 335 | - //If the deleted option is an "other" option |
|
| 335 | + //If the deleted option is an "other" option |
|
| 336 | 336 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 337 | - //Assume all other options are gone, unless proven otherwise |
|
| 338 | - $other = false; |
|
| 337 | + //Assume all other options are gone, unless proven otherwise |
|
| 338 | + $other = false; |
|
| 339 | 339 | |
| 340 | - //Check if all other options are really gone |
|
| 341 | - foreach ( $options as $o_key => $o_val ) { |
|
| 342 | - //If there is still an other option in the field, set other to true |
|
| 340 | + //Check if all other options are really gone |
|
| 341 | + foreach ( $options as $o_key => $o_val ) { |
|
| 342 | + //If there is still an other option in the field, set other to true |
|
| 343 | 343 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 344 | - $other = true; |
|
| 345 | - break; |
|
| 346 | - } |
|
| 347 | - unset( $o_key, $o_val ); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - //If all other options are gone |
|
| 351 | - if ( false === $other ) { |
|
| 352 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 353 | - $field_options['other'] = 0; |
|
| 344 | + $other = true; |
|
| 345 | + break; |
|
| 346 | + } |
|
| 347 | + unset( $o_key, $o_val ); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + //If all other options are gone |
|
| 351 | + if ( false === $other ) { |
|
| 352 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 353 | + $field_options['other'] = 0; |
|
| 354 | 354 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 355 | - $response = array( 'other' => false ); |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - echo json_encode( $response ); |
|
| 355 | + $response = array( 'other' => false ); |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + echo json_encode( $response ); |
|
| 359 | 359 | |
| 360 | 360 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 361 | 361 | |
| 362 | - wp_die(); |
|
| 363 | - } |
|
| 362 | + wp_die(); |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - public static function import_choices() { |
|
| 366 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 365 | + public static function import_choices() { |
|
| 366 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 367 | 367 | |
| 368 | 368 | $field_id = absint( $_REQUEST['field_id'] ); |
| 369 | 369 | |
| 370 | - global $current_screen, $hook_suffix; |
|
| 370 | + global $current_screen, $hook_suffix; |
|
| 371 | 371 | |
| 372 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 373 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 374 | - $hook_suffix = ''; |
|
| 375 | - set_current_screen(); |
|
| 376 | - } |
|
| 372 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 373 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 374 | + $hook_suffix = ''; |
|
| 375 | + set_current_screen(); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 379 | - register_admin_color_schemes(); |
|
| 380 | - } |
|
| 378 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 379 | + register_admin_color_schemes(); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | 382 | $hook_suffix = ''; |
| 383 | 383 | $admin_body_class = ''; |
| 384 | 384 | |
| 385 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 386 | - $admin_body_class .= ' folded'; |
|
| 387 | - } |
|
| 385 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 386 | + $admin_body_class .= ' folded'; |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 390 | - $admin_body_class .= ' admin-bar'; |
|
| 391 | - } |
|
| 389 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 390 | + $admin_body_class .= ' admin-bar'; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - if ( is_rtl() ) { |
|
| 394 | - $admin_body_class .= ' rtl'; |
|
| 395 | - } |
|
| 393 | + if ( is_rtl() ) { |
|
| 394 | + $admin_body_class .= ' rtl'; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 398 | - $prepop = array(); |
|
| 399 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 397 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 398 | + $prepop = array(); |
|
| 399 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 400 | 400 | |
| 401 | - $field = FrmField::getOne($field_id); |
|
| 401 | + $field = FrmField::getOne($field_id); |
|
| 402 | 402 | |
| 403 | - wp_enqueue_script( 'utils' ); |
|
| 403 | + wp_enqueue_script( 'utils' ); |
|
| 404 | 404 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 405 | - FrmAppHelper::load_admin_wide_js(); |
|
| 405 | + FrmAppHelper::load_admin_wide_js(); |
|
| 406 | 406 | |
| 407 | 407 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 408 | - wp_die(); |
|
| 409 | - } |
|
| 408 | + wp_die(); |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - public static function import_options() { |
|
| 411 | + public static function import_options() { |
|
| 412 | 412 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 413 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 413 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 414 | 414 | |
| 415 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 416 | - return; |
|
| 417 | - } |
|
| 415 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 416 | + return; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | 419 | $field_id = absint( $_POST['field_id'] ); |
| 420 | - $field = FrmField::getOne($field_id); |
|
| 420 | + $field = FrmField::getOne($field_id); |
|
| 421 | 421 | |
| 422 | 422 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 423 | - return; |
|
| 424 | - } |
|
| 423 | + return; |
|
| 424 | + } |
|
| 425 | 425 | |
| 426 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 426 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 427 | 427 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 428 | 428 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 429 | 429 | $opts = array_map( 'trim', $opts ); |
| 430 | 430 | |
| 431 | - if ( $field['separate_value'] ) { |
|
| 432 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 433 | - if ( strpos($opt, '|') !== false ) { |
|
| 434 | - $vals = explode('|', $opt); |
|
| 435 | - if ( $vals[0] != $vals[1] ) { |
|
| 436 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 437 | - } |
|
| 438 | - unset($vals); |
|
| 439 | - } |
|
| 440 | - unset($opt_key, $opt); |
|
| 441 | - } |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - //Keep other options after bulk update |
|
| 445 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 446 | - $other_array = array(); |
|
| 447 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 448 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 449 | - $other_array[ $opt_key ] = $opt; |
|
| 450 | - } |
|
| 451 | - unset($opt_key, $opt); |
|
| 452 | - } |
|
| 453 | - if ( ! empty($other_array) ) { |
|
| 454 | - $opts = array_merge( $opts, $other_array); |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 459 | - |
|
| 460 | - $field['options'] = $opts; |
|
| 461 | - $field_name = $field['name']; |
|
| 462 | - |
|
| 463 | - // Get html_id which will be used in single-option.php |
|
| 464 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 465 | - |
|
| 466 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 431 | + if ( $field['separate_value'] ) { |
|
| 432 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 433 | + if ( strpos($opt, '|') !== false ) { |
|
| 434 | + $vals = explode('|', $opt); |
|
| 435 | + if ( $vals[0] != $vals[1] ) { |
|
| 436 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 437 | + } |
|
| 438 | + unset($vals); |
|
| 439 | + } |
|
| 440 | + unset($opt_key, $opt); |
|
| 441 | + } |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + //Keep other options after bulk update |
|
| 445 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 446 | + $other_array = array(); |
|
| 447 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 448 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 449 | + $other_array[ $opt_key ] = $opt; |
|
| 450 | + } |
|
| 451 | + unset($opt_key, $opt); |
|
| 452 | + } |
|
| 453 | + if ( ! empty($other_array) ) { |
|
| 454 | + $opts = array_merge( $opts, $other_array); |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 459 | + |
|
| 460 | + $field['options'] = $opts; |
|
| 461 | + $field_name = $field['name']; |
|
| 462 | + |
|
| 463 | + // Get html_id which will be used in single-option.php |
|
| 464 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 465 | + |
|
| 466 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 467 | 467 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 468 | - } else { |
|
| 469 | - FrmFieldsHelper::show_single_option($field); |
|
| 470 | - } |
|
| 468 | + } else { |
|
| 469 | + FrmFieldsHelper::show_single_option($field); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - wp_die(); |
|
| 473 | - } |
|
| 472 | + wp_die(); |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - public static function update_order() { |
|
| 475 | + public static function update_order() { |
|
| 476 | 476 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 477 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 477 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 478 | 478 | |
| 479 | 479 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 480 | 480 | foreach ( (array) $fields as $position => $item ) { |
| 481 | 481 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 482 | 482 | } |
| 483 | - wp_die(); |
|
| 484 | - } |
|
| 483 | + wp_die(); |
|
| 484 | + } |
|
| 485 | 485 | |
| 486 | 486 | public static function change_type( $type ) { |
| 487 | - $type_switch = array( |
|
| 488 | - 'scale' => 'radio', |
|
| 489 | - '10radio' => 'radio', |
|
| 490 | - 'rte' => 'textarea', |
|
| 491 | - 'website' => 'url', |
|
| 492 | - ); |
|
| 493 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 494 | - $type = $type_switch[ $type ]; |
|
| 495 | - } |
|
| 487 | + $type_switch = array( |
|
| 488 | + 'scale' => 'radio', |
|
| 489 | + '10radio' => 'radio', |
|
| 490 | + 'rte' => 'textarea', |
|
| 491 | + 'website' => 'url', |
|
| 492 | + ); |
|
| 493 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 494 | + $type = $type_switch[ $type ]; |
|
| 495 | + } |
|
| 496 | 496 | |
| 497 | 497 | $pro_fields = FrmField::pro_field_selection(); |
| 498 | 498 | $types = array_keys( $pro_fields ); |
@@ -500,137 +500,137 @@ discard block |
||
| 500 | 500 | $type = 'text'; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - return $type; |
|
| 504 | - } |
|
| 503 | + return $type; |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | 506 | public static function display_field_options( $display ) { |
| 507 | 507 | switch ( $display['type'] ) { |
| 508 | - case 'captcha': |
|
| 509 | - $display['required'] = false; |
|
| 510 | - $display['invalid'] = true; |
|
| 511 | - $display['default_blank'] = false; |
|
| 508 | + case 'captcha': |
|
| 509 | + $display['required'] = false; |
|
| 510 | + $display['invalid'] = true; |
|
| 511 | + $display['default_blank'] = false; |
|
| 512 | 512 | $display['captcha_size'] = true; |
| 513 | - break; |
|
| 514 | - case 'radio': |
|
| 515 | - $display['default_blank'] = false; |
|
| 516 | - break; |
|
| 517 | - case 'text': |
|
| 518 | - case 'textarea': |
|
| 519 | - $display['size'] = true; |
|
| 520 | - $display['clear_on_focus'] = true; |
|
| 521 | - break; |
|
| 522 | - case 'select': |
|
| 523 | - $display['size'] = true; |
|
| 524 | - break; |
|
| 525 | - case 'url': |
|
| 526 | - case 'website': |
|
| 527 | - case 'email': |
|
| 528 | - $display['size'] = true; |
|
| 529 | - $display['clear_on_focus'] = true; |
|
| 530 | - $display['invalid'] = true; |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - return $display; |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - public static function input_html( $field, $echo = true ) { |
|
| 537 | - $class = array(); //$field['type']; |
|
| 538 | - self::add_input_classes($field, $class); |
|
| 539 | - |
|
| 540 | - $add_html = array(); |
|
| 541 | - self::add_html_size($field, $add_html); |
|
| 542 | - self::add_html_length($field, $add_html); |
|
| 543 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 513 | + break; |
|
| 514 | + case 'radio': |
|
| 515 | + $display['default_blank'] = false; |
|
| 516 | + break; |
|
| 517 | + case 'text': |
|
| 518 | + case 'textarea': |
|
| 519 | + $display['size'] = true; |
|
| 520 | + $display['clear_on_focus'] = true; |
|
| 521 | + break; |
|
| 522 | + case 'select': |
|
| 523 | + $display['size'] = true; |
|
| 524 | + break; |
|
| 525 | + case 'url': |
|
| 526 | + case 'website': |
|
| 527 | + case 'email': |
|
| 528 | + $display['size'] = true; |
|
| 529 | + $display['clear_on_focus'] = true; |
|
| 530 | + $display['invalid'] = true; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + return $display; |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + public static function input_html( $field, $echo = true ) { |
|
| 537 | + $class = array(); //$field['type']; |
|
| 538 | + self::add_input_classes($field, $class); |
|
| 539 | + |
|
| 540 | + $add_html = array(); |
|
| 541 | + self::add_html_size($field, $add_html); |
|
| 542 | + self::add_html_length($field, $add_html); |
|
| 543 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 544 | 544 | self::add_validation_messages( $field, $add_html ); |
| 545 | 545 | |
| 546 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 546 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 547 | 547 | |
| 548 | 548 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 549 | 549 | |
| 550 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 550 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 551 | 551 | |
| 552 | 552 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 553 | 553 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 554 | 554 | |
| 555 | - if ( $echo ) { |
|
| 556 | - echo $add_html; |
|
| 557 | - } |
|
| 555 | + if ( $echo ) { |
|
| 556 | + echo $add_html; |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - return $add_html; |
|
| 560 | - } |
|
| 559 | + return $add_html; |
|
| 560 | + } |
|
| 561 | 561 | |
| 562 | 562 | private static function add_input_classes( $field, array &$class ) { |
| 563 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 564 | - $class[] = $field['input_class']; |
|
| 565 | - } |
|
| 563 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 564 | + $class[] = $field['input_class']; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 568 | - return; |
|
| 569 | - } |
|
| 567 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 568 | + return; |
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 572 | - $class[] = 'auto_width'; |
|
| 573 | - } |
|
| 574 | - } |
|
| 571 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 572 | + $class[] = 'auto_width'; |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | 576 | private static function add_html_size( $field, array &$add_html ) { |
| 577 | 577 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 578 | - return; |
|
| 579 | - } |
|
| 578 | + return; |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 582 | - return; |
|
| 583 | - } |
|
| 581 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 582 | + return; |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - if ( is_numeric($field['size']) ) { |
|
| 586 | - $field['size'] .= 'px'; |
|
| 587 | - } |
|
| 585 | + if ( is_numeric($field['size']) ) { |
|
| 586 | + $field['size'] .= 'px'; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 590 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 589 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 590 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 591 | 591 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 592 | 592 | |
| 593 | - self::add_html_cols($field, $add_html); |
|
| 594 | - } |
|
| 593 | + self::add_html_cols($field, $add_html); |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | 596 | private static function add_html_cols( $field, array &$add_html ) { |
| 597 | 597 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 598 | - return; |
|
| 599 | - } |
|
| 598 | + return; |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | - // convert to cols for textareas |
|
| 602 | - $calc = array( |
|
| 603 | - '' => 9, |
|
| 604 | - 'px' => 9, |
|
| 605 | - 'rem' => 0.444, |
|
| 606 | - 'em' => 0.544, |
|
| 607 | - ); |
|
| 601 | + // convert to cols for textareas |
|
| 602 | + $calc = array( |
|
| 603 | + '' => 9, |
|
| 604 | + 'px' => 9, |
|
| 605 | + 'rem' => 0.444, |
|
| 606 | + 'em' => 0.544, |
|
| 607 | + ); |
|
| 608 | 608 | |
| 609 | - // include "col" for valid html |
|
| 610 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 609 | + // include "col" for valid html |
|
| 610 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 611 | 611 | |
| 612 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 613 | - return; |
|
| 614 | - } |
|
| 612 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 613 | + return; |
|
| 614 | + } |
|
| 615 | 615 | |
| 616 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 616 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 617 | 617 | |
| 618 | 618 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 619 | - } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | private static function add_html_length( $field, array &$add_html ) { |
| 622 | - // check for max setting and if this field accepts maxlength |
|
| 622 | + // check for max setting and if this field accepts maxlength |
|
| 623 | 623 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 624 | - return; |
|
| 625 | - } |
|
| 624 | + return; |
|
| 625 | + } |
|
| 626 | 626 | |
| 627 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 628 | - // don't load on form builder page |
|
| 629 | - return; |
|
| 630 | - } |
|
| 627 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 628 | + // don't load on form builder page |
|
| 629 | + return; |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | 632 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 633 | - } |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | 635 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 636 | 636 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -638,35 +638,35 @@ discard block |
||
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | $default_value_array = is_array( $field['default_value'] ); |
| 641 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 641 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 642 | 642 | if ( $default_value_array ) { |
| 643 | 643 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 644 | 644 | } |
| 645 | 645 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 646 | - return; |
|
| 647 | - } |
|
| 646 | + return; |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | 649 | if ( $default_value_array ) { |
| 650 | 650 | // don't include a json placeholder |
| 651 | 651 | return; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 654 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 655 | 655 | |
| 656 | 656 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 657 | - // use HMTL5 placeholder with js fallback |
|
| 657 | + // use HMTL5 placeholder with js fallback |
|
| 658 | 658 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 659 | - wp_enqueue_script('jquery-placeholder'); |
|
| 660 | - } else if ( ! $frm_settings->use_html ) { |
|
| 659 | + wp_enqueue_script('jquery-placeholder'); |
|
| 660 | + } else if ( ! $frm_settings->use_html ) { |
|
| 661 | 661 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 662 | 662 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 663 | - $class[] = 'frm_toggle_default'; |
|
| 663 | + $class[] = 'frm_toggle_default'; |
|
| 664 | 664 | |
| 665 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 666 | - $class[] = 'frm_default'; |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - } |
|
| 665 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 666 | + $class[] = 'frm_default'; |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | 671 | private static function add_validation_messages( $field, array &$add_html ) { |
| 672 | 672 | if ( FrmField::is_required( $field ) ) { |
@@ -680,44 +680,44 @@ 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 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 694 | - $add_html[] = $v; |
|
| 695 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 693 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 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 | - } |
|
| 700 | - |
|
| 701 | - unset($k, $v); |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 706 | - if ( is_array( $opt ) ) { |
|
| 707 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 708 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 709 | - } else { |
|
| 710 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 711 | - } |
|
| 712 | - } |
|
| 713 | - return $opt; |
|
| 714 | - } |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + unset($k, $v); |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 706 | + if ( is_array( $opt ) ) { |
|
| 707 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 708 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 709 | + } else { |
|
| 710 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | + return $opt; |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | 716 | public static function check_label( $opt ) { |
| 717 | - if ( is_array($opt) ) { |
|
| 718 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 719 | - } |
|
| 717 | + if ( is_array($opt) ) { |
|
| 718 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - return $opt; |
|
| 722 | - } |
|
| 721 | + return $opt; |
|
| 722 | + } |
|
| 723 | 723 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | 55 | public static function create() { |
| 56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | 64 | // this hook will allow for multiple fields to be added at once |
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 66 | 66 | |
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | 78 | $values = array(); |
| 79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 93 | 93 | |
| 94 | 94 | return $field; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 101 | + if ( empty( $field ) ) { |
|
| 102 | 102 | $field = 'name'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty( $id ) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 113 | 113 | // set blank value if there is no content |
| 114 | 114 | $value = ''; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public static function update_ajax_option() { |
| 126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
| 137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 138 | 138 | $field->field_options['separate_value'] = $new_val; |
| 139 | - unset($new_val); |
|
| 139 | + unset( $new_val ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public static function duplicate() { |
| 150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 152 | 152 | |
| 153 | 153 | global $wpdb; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - self::include_single_field($field_id, $values); |
|
| 180 | + self::include_single_field( $field_id, $values ); |
|
| 181 | 181 | |
| 182 | 182 | wp_die(); |
| 183 | 183 | } |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * Load a single field in the form builder along with all needed variables |
| 187 | 187 | */ |
| 188 | 188 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 189 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
| 191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 192 | 192 | $id = $form_id ? $form_id : $field['form_id']; |
| 193 | 193 | if ( $field['type'] == 'html' ) { |
| 194 | 194 | $field['stop_filter'] = true; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public static function destroy() { |
| 203 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 203 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 204 | 204 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 205 | 205 | |
| 206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | //Add Single Option or Other Option |
| 214 | 214 | public static function add_option() { |
| 215 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 215 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 216 | 216 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 217 | 217 | |
| 218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 220 | 220 | |
| 221 | 221 | //Get the field |
| 222 | - $field = FrmField::getOne($id); |
|
| 222 | + $field = FrmField::getOne( $id ); |
|
| 223 | 223 | |
| 224 | 224 | if ( ! empty( $field->options ) ) { |
| 225 | 225 | $keys = array_keys( $field->options ); |
@@ -242,13 +242,13 @@ discard block |
||
| 242 | 242 | $first_opt = reset( $field->options ); |
| 243 | 243 | $next_opt = count( $field->options ); |
| 244 | 244 | if ( $first_opt != '' ) { |
| 245 | - $next_opt++; |
|
| 245 | + $next_opt ++; |
|
| 246 | 246 | } |
| 247 | 247 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 248 | - unset($next_opt); |
|
| 248 | + unset( $next_opt ); |
|
| 249 | 249 | } |
| 250 | 250 | $field_val = $opt; |
| 251 | - $field->options[ $opt_key ] = $opt; |
|
| 251 | + $field->options[$opt_key] = $opt; |
|
| 252 | 252 | |
| 253 | 253 | //Update options in DB |
| 254 | 254 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | $field = array( |
| 258 | 258 | 'type' => $field_data->type, |
| 259 | 259 | 'id' => $id, |
| 260 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 260 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
| 261 | 261 | 'form_id' => $field_data->form_id, |
| 262 | 262 | 'field_key' => $field_data->field_key, |
| 263 | 263 | ); |
| 264 | 264 | |
| 265 | 265 | $field_name = 'item_meta[' . $id . ']'; |
| 266 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 266 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 267 | 267 | $checked = ''; |
| 268 | 268 | |
| 269 | 269 | if ( 'other' == $opt_type ) { |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | public static function edit_option() { |
| 278 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 278 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 279 | 279 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 280 | 280 | |
| 281 | 281 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -290,28 +290,28 @@ discard block |
||
| 290 | 290 | $new_label = $update_value; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $field = FrmField::getOne($id); |
|
| 293 | + $field = FrmField::getOne( $id ); |
|
| 294 | 294 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
| 295 | 295 | |
| 296 | - $this_opt_id = end($ids); |
|
| 297 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
| 298 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
| 296 | + $this_opt_id = end( $ids ); |
|
| 297 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
| 298 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
| 299 | 299 | |
| 300 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 301 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 300 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
| 301 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
| 302 | 302 | |
| 303 | 303 | if ( ! isset( $new_label ) ) { |
| 304 | 304 | $new_label = $label; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - if ( isset($new_value) || isset($value) ) { |
|
| 308 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 307 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
| 308 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 312 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 312 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
| 313 | 313 | } else { |
| 314 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
| 314 | + $field->options[$this_opt_id] = $orig_update_value; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | public static function delete_option() { |
| 323 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 323 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 324 | 324 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 325 | 325 | |
| 326 | 326 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 330 | 330 | |
| 331 | 331 | $options = $field->options; |
| 332 | - unset( $options[ $opt_key ] ); |
|
| 332 | + unset( $options[$opt_key] ); |
|
| 333 | 333 | $response = array( 'other' => true ); |
| 334 | 334 | |
| 335 | 335 | //If the deleted option is an "other" option |
@@ -396,9 +396,9 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 398 | 398 | $prepop = array(); |
| 399 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 399 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 400 | 400 | |
| 401 | - $field = FrmField::getOne($field_id); |
|
| 401 | + $field = FrmField::getOne( $field_id ); |
|
| 402 | 402 | |
| 403 | 403 | wp_enqueue_script( 'utils' ); |
| 404 | 404 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -409,35 +409,35 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | public static function import_options() { |
| 412 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 412 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 413 | 413 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 414 | 414 | |
| 415 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 415 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | $field_id = absint( $_POST['field_id'] ); |
| 420 | - $field = FrmField::getOne($field_id); |
|
| 420 | + $field = FrmField::getOne( $field_id ); |
|
| 421 | 421 | |
| 422 | 422 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 423 | 423 | return; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 426 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 427 | 427 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 428 | 428 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 429 | 429 | $opts = array_map( 'trim', $opts ); |
| 430 | 430 | |
| 431 | 431 | if ( $field['separate_value'] ) { |
| 432 | 432 | foreach ( $opts as $opt_key => $opt ) { |
| 433 | - if ( strpos($opt, '|') !== false ) { |
|
| 434 | - $vals = explode('|', $opt); |
|
| 433 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 434 | + $vals = explode( '|', $opt ); |
|
| 435 | 435 | if ( $vals[0] != $vals[1] ) { |
| 436 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 436 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 437 | 437 | } |
| 438 | - unset($vals); |
|
| 438 | + unset( $vals ); |
|
| 439 | 439 | } |
| 440 | - unset($opt_key, $opt); |
|
| 440 | + unset( $opt_key, $opt ); |
|
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
| 446 | 446 | $other_array = array(); |
| 447 | 447 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 448 | 448 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
| 449 | - $other_array[ $opt_key ] = $opt; |
|
| 449 | + $other_array[$opt_key] = $opt; |
|
| 450 | 450 | } |
| 451 | - unset($opt_key, $opt); |
|
| 451 | + unset( $opt_key, $opt ); |
|
| 452 | 452 | } |
| 453 | - if ( ! empty($other_array) ) { |
|
| 454 | - $opts = array_merge( $opts, $other_array); |
|
| 453 | + if ( ! empty( $other_array ) ) { |
|
| 454 | + $opts = array_merge( $opts, $other_array ); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
@@ -466,14 +466,14 @@ discard block |
||
| 466 | 466 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
| 467 | 467 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 468 | 468 | } else { |
| 469 | - FrmFieldsHelper::show_single_option($field); |
|
| 469 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | wp_die(); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | public static function update_order() { |
| 476 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 476 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 477 | 477 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 478 | 478 | |
| 479 | 479 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | 'rte' => 'textarea', |
| 491 | 491 | 'website' => 'url', |
| 492 | 492 | ); |
| 493 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 494 | - $type = $type_switch[ $type ]; |
|
| 493 | + if ( isset( $type_switch[$type] ) ) { |
|
| 494 | + $type = $type_switch[$type]; |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $pro_fields = FrmField::pro_field_selection(); |
@@ -535,19 +535,19 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | public static function input_html( $field, $echo = true ) { |
| 537 | 537 | $class = array(); //$field['type']; |
| 538 | - self::add_input_classes($field, $class); |
|
| 538 | + self::add_input_classes( $field, $class ); |
|
| 539 | 539 | |
| 540 | 540 | $add_html = array(); |
| 541 | - self::add_html_size($field, $add_html); |
|
| 542 | - self::add_html_length($field, $add_html); |
|
| 543 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 541 | + self::add_html_size( $field, $add_html ); |
|
| 542 | + self::add_html_length( $field, $add_html ); |
|
| 543 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 544 | 544 | self::add_validation_messages( $field, $add_html ); |
| 545 | 545 | |
| 546 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 546 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 547 | 547 | |
| 548 | 548 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 549 | 549 | |
| 550 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 550 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 551 | 551 | |
| 552 | 552 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 553 | 553 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | private static function add_input_classes( $field, array &$class ) { |
| 563 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 563 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 564 | 564 | $class[] = $field['input_class']; |
| 565 | 565 | } |
| 566 | 566 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | return; |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 571 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 572 | 572 | $class[] = 'auto_width'; |
| 573 | 573 | } |
| 574 | 574 | } |
@@ -578,19 +578,19 @@ discard block |
||
| 578 | 578 | return; |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 581 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 582 | 582 | return; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if ( is_numeric($field['size']) ) { |
|
| 585 | + if ( is_numeric( $field['size'] ) ) { |
|
| 586 | 586 | $field['size'] .= 'px'; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 589 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 590 | 590 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 591 | 591 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 592 | 592 | |
| 593 | - self::add_html_cols($field, $add_html); |
|
| 593 | + self::add_html_cols( $field, $add_html ); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -607,13 +607,13 @@ discard block |
||
| 607 | 607 | ); |
| 608 | 608 | |
| 609 | 609 | // include "col" for valid html |
| 610 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 610 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 611 | 611 | |
| 612 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 612 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 613 | 613 | return; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 616 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 617 | 617 | |
| 618 | 618 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 619 | 619 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | return; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 627 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 628 | 628 | // don't load on form builder page |
| 629 | 629 | return; |
| 630 | 630 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 657 | 657 | // use HMTL5 placeholder with js fallback |
| 658 | 658 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 659 | - wp_enqueue_script('jquery-placeholder'); |
|
| 659 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 660 | 660 | } else if ( ! $frm_settings->use_html ) { |
| 661 | 661 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 662 | 662 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -690,15 +690,15 @@ discard block |
||
| 690 | 690 | continue; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 693 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 694 | 694 | $add_html[] = $v; |
| 695 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 696 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 695 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 696 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 697 | 697 | } else { |
| 698 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 698 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - unset($k, $v); |
|
| 701 | + unset( $k, $v ); |
|
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | public static function check_label( $opt ) { |
| 717 | - if ( is_array($opt) ) { |
|
| 718 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 717 | + if ( is_array( $opt ) ) { |
|
| 718 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | return $opt; |
@@ -2,201 +2,201 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmEntriesController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' ); |
| 13 | 13 | add_filter( 'get_user_option_manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' ); |
| 14 | 14 | add_filter( 'manage_' . sanitize_title( $menu_name ) . '_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' ); |
| 15 | - } |
|
| 16 | - } |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /* Display in Back End */ |
|
| 19 | - public static function route() { |
|
| 18 | + /* Display in Back End */ |
|
| 19 | + public static function route() { |
|
| 20 | 20 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 21 | 21 | |
| 22 | - switch ( $action ) { |
|
| 23 | - case 'show': |
|
| 24 | - case 'destroy': |
|
| 25 | - case 'destroy_all': |
|
| 26 | - return self::$action(); |
|
| 22 | + switch ( $action ) { |
|
| 23 | + case 'show': |
|
| 24 | + case 'destroy': |
|
| 25 | + case 'destroy_all': |
|
| 26 | + return self::$action(); |
|
| 27 | 27 | |
| 28 | - default: |
|
| 29 | - do_action( 'frm_entry_action_route', $action ); |
|
| 30 | - if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 28 | + default: |
|
| 29 | + do_action( 'frm_entry_action_route', $action ); |
|
| 30 | + if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return self::display_list(); |
|
| 35 | - } |
|
| 36 | - } |
|
| 34 | + return self::display_list(); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function contextual_help( $help, $screen_id, $screen ) { |
| 39 | - // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | - if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | - return $help; |
|
| 42 | - } |
|
| 39 | + // Only add to certain screens. add_help_tab was introduced in WordPress 3.3 |
|
| 40 | + if ( ! method_exists( $screen, 'add_help_tab' ) ) { |
|
| 41 | + return $help; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 45 | 45 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
| 46 | 46 | if ( $page != 'formidable-entries' || ( ! empty( $action ) && $action != 'list' ) ) { |
| 47 | - return $help; |
|
| 48 | - } |
|
| 47 | + return $help; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | unset( $action, $page ); |
| 51 | 51 | |
| 52 | - $screen->add_help_tab( array( |
|
| 53 | - 'id' => 'formidable-entries-tab', |
|
| 54 | - 'title' => __( 'Overview', 'formidable' ), |
|
| 52 | + $screen->add_help_tab( array( |
|
| 53 | + 'id' => 'formidable-entries-tab', |
|
| 54 | + 'title' => __( 'Overview', 'formidable' ), |
|
| 55 | 55 | '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>', |
| 56 | - )); |
|
| 56 | + )); |
|
| 57 | 57 | |
| 58 | - $screen->set_help_sidebar( |
|
| 58 | + $screen->set_help_sidebar( |
|
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
| 60 | 60 | '<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>' . |
| 61 | 61 | '<p><a href="' . esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/help-desk/' ) ) . '" target="_blank">' . esc_html__( 'Support', 'formidable' ) . '</a></p>' |
| 62 | - ); |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - return $help; |
|
| 65 | - } |
|
| 64 | + return $help; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | public static function manage_columns( $columns ) { |
| 68 | - global $frm_vars, $wpdb; |
|
| 68 | + global $frm_vars, $wpdb; |
|
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | 71 | $columns[ $form_id . '_id' ] = 'ID'; |
| 72 | 72 | $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
| 73 | 73 | |
| 74 | - if ( ! $form_id ) { |
|
| 75 | - return $columns; |
|
| 76 | - } |
|
| 74 | + if ( ! $form_id ) { |
|
| 75 | + return $columns; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 79 | 79 | |
| 80 | - foreach ( $form_cols as $form_col ) { |
|
| 80 | + foreach ( $form_cols as $form_col ) { |
|
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
| 82 | - continue; |
|
| 83 | - } |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 85 | + if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) { |
|
| 86 | 86 | $sub_form_cols = FrmField::get_all_for_form( $form_col->field_options['form_select'] ); |
| 87 | 87 | |
| 88 | - if ( $sub_form_cols ) { |
|
| 89 | - foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 88 | + if ( $sub_form_cols ) { |
|
| 89 | + foreach ( $sub_form_cols as $k => $sub_form_col ) { |
|
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 92 | - continue; |
|
| 93 | - } |
|
| 91 | + unset( $sub_form_cols[ $k ] ); |
|
| 92 | + continue; |
|
| 93 | + } |
|
| 94 | 94 | $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
| 95 | - unset($sub_form_col); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - unset($sub_form_cols); |
|
| 99 | - } else { |
|
| 100 | - $col_id = $form_col->field_key; |
|
| 101 | - if ( $form_col->form_id != $form_id ) { |
|
| 95 | + unset($sub_form_col); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + unset($sub_form_cols); |
|
| 99 | + } else { |
|
| 100 | + $col_id = $form_col->field_key; |
|
| 101 | + if ( $form_col->form_id != $form_id ) { |
|
| 102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 105 | + if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | 106 | $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
| 109 | - } |
|
| 110 | - } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
| 113 | 113 | $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
| 114 | 114 | $columns[ $form_id . '_ip' ] = 'IP'; |
| 115 | 115 | |
| 116 | - $frm_vars['cols'] = $columns; |
|
| 116 | + $frm_vars['cols'] = $columns; |
|
| 117 | 117 | |
| 118 | 118 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
| 119 | 119 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) { |
| 120 | 120 | add_screen_option( 'per_page', array( 'label' => __( 'Entries', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page' ) ); |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - return $columns; |
|
| 124 | - } |
|
| 123 | + return $columns; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) { |
| 127 | 127 | $menu_name = FrmAppHelper::get_menu_name(); |
| 128 | 128 | $this_page_name = 'manage' . sanitize_title( $menu_name ) . '_page_formidable-entriescolumnshidden'; |
| 129 | 129 | if ( $meta_key != $this_page_name || $meta_value == $prev_value ) { |
| 130 | - return $check; |
|
| 131 | - } |
|
| 130 | + return $check; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | if ( empty( $prev_value ) ) { |
| 134 | 134 | $prev_value = get_metadata( 'user', $object_id, $meta_key, true ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - global $frm_vars; |
|
| 138 | - //add a check so we don't create a loop |
|
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 137 | + global $frm_vars; |
|
| 138 | + //add a check so we don't create a loop |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | - return $check; |
|
| 142 | - } |
|
| 141 | + return $check; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - //add hidden columns back from other forms |
|
| 144 | + //add hidden columns back from other forms |
|
| 145 | 145 | public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) { |
| 146 | 146 | $menu_name = FrmAppHelper::get_menu_name(); |
| 147 | 147 | $sanitized = sanitize_title( $menu_name ); |
| 148 | 148 | $this_page_name = 'manage' . $sanitized . '_page_formidable-entriescolumnshidden'; |
| 149 | 149 | if ( $meta_key != $this_page_name ) { |
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - global $frm_vars; |
|
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | - return; //don't continue if there's no previous value |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | - //remove blank values |
|
| 160 | - if ( empty( $mv ) ) { |
|
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | - $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | - $save = false; |
|
| 169 | - |
|
| 170 | - foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + global $frm_vars; |
|
| 154 | + if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | + return; //don't continue if there's no previous value |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + foreach ( $meta_value as $mk => $mv ) { |
|
| 159 | + //remove blank values |
|
| 160 | + if ( empty( $mv ) ) { |
|
| 161 | + unset( $meta_value[ $mk ] ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $cur_form_prefix = reset($meta_value); |
|
| 166 | + $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 167 | + $cur_form_prefix = $cur_form_prefix[0]; |
|
| 168 | + $save = false; |
|
| 169 | + |
|
| 170 | + foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) { |
|
| 171 | 171 | if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) { |
| 172 | - //don't add blank cols or process included cols |
|
| 173 | - continue; |
|
| 174 | - } |
|
| 172 | + //don't add blank cols or process included cols |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | $form_prefix = explode( '_', $prev_hidden ); |
| 177 | - $form_prefix = $form_prefix[0]; |
|
| 178 | - if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | - //don't add back columns that are meant to be hidden |
|
| 180 | - continue; |
|
| 181 | - } |
|
| 177 | + $form_prefix = $form_prefix[0]; |
|
| 178 | + if ( $form_prefix == $cur_form_prefix ) { |
|
| 179 | + //don't add back columns that are meant to be hidden |
|
| 180 | + continue; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - $meta_value[] = $prev_hidden; |
|
| 184 | - $save = true; |
|
| 185 | - unset($form_prefix); |
|
| 186 | - } |
|
| 183 | + $meta_value[] = $prev_hidden; |
|
| 184 | + $save = true; |
|
| 185 | + unset($form_prefix); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
| 189 | - $user = wp_get_current_user(); |
|
| 189 | + $user = wp_get_current_user(); |
|
| 190 | 190 | update_user_option( $user->ID, $this_page_name, $meta_value, true ); |
| 191 | - } |
|
| 192 | - } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | public static function save_per_page( $save, $option, $value ) { |
| 195 | - if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | - $save = (int) $value; |
|
| 197 | - } |
|
| 198 | - return $save; |
|
| 199 | - } |
|
| 195 | + if ( $option == 'formidable_page_formidable_entries_per_page' ) { |
|
| 196 | + $save = (int) $value; |
|
| 197 | + } |
|
| 198 | + return $save; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | public static function sortable_columns() { |
| 202 | 202 | $form_id = FrmForm::get_current_form_id(); |
@@ -222,122 +222,122 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | public static function hidden_columns( $result ) { |
| 225 | - global $frm_vars; |
|
| 225 | + global $frm_vars; |
|
| 226 | 226 | |
| 227 | 227 | $form_id = FrmForm::get_current_form_id(); |
| 228 | 228 | |
| 229 | - $return = false; |
|
| 230 | - foreach ( (array) $result as $r ) { |
|
| 231 | - if ( ! empty( $r ) ) { |
|
| 232 | - $form_prefix = explode( '_', $r ); |
|
| 233 | - $form_prefix = $form_prefix[0]; |
|
| 229 | + $return = false; |
|
| 230 | + foreach ( (array) $result as $r ) { |
|
| 231 | + if ( ! empty( $r ) ) { |
|
| 232 | + $form_prefix = explode( '_', $r ); |
|
| 233 | + $form_prefix = $form_prefix[0]; |
|
| 234 | 234 | |
| 235 | - if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | - $return = true; |
|
| 237 | - break; |
|
| 238 | - } |
|
| 235 | + if ( (int) $form_prefix == (int) $form_id ) { |
|
| 236 | + $return = true; |
|
| 237 | + break; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + unset($form_prefix); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - if ( $return ) { |
|
| 244 | + if ( $return ) { |
|
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | - $max_columns = 8; |
|
| 250 | - if ( $i <= $max_columns ) { |
|
| 248 | + $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 249 | + $max_columns = 8; |
|
| 250 | + if ( $i <= $max_columns ) { |
|
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - global $frm_vars; |
|
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | - } |
|
| 254 | + global $frm_vars; |
|
| 255 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | - $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | - } else { |
|
| 262 | - $cols = $frm_vars['cols']; |
|
| 263 | - $cols = array_reverse($cols, true); |
|
| 259 | + if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 260 | + $result = $frm_vars['current_form']->options['hidden_cols']; |
|
| 261 | + } else { |
|
| 262 | + $cols = $frm_vars['cols']; |
|
| 263 | + $cols = array_reverse($cols, true); |
|
| 264 | 264 | |
| 265 | 265 | $result[] = $form_id . '_id'; |
| 266 | - $i--; |
|
| 266 | + $i--; |
|
| 267 | 267 | |
| 268 | 268 | $result[] = $form_id . '_item_key'; |
| 269 | - $i--; |
|
| 269 | + $i--; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | - if ( $i > $max_columns ) { |
|
| 272 | + if ( $i > $max_columns ) { |
|
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | - //remove some columns by default |
|
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 278 | - } |
|
| 279 | - } |
|
| 275 | + //remove some columns by default |
|
| 276 | + $i--; |
|
| 277 | + unset($col_key, $col); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - return $result; |
|
| 282 | - } |
|
| 281 | + return $result; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | 284 | public static function display_list( $message = '', $errors = array() ) { |
| 285 | - global $wpdb, $frm_vars; |
|
| 285 | + global $wpdb, $frm_vars; |
|
| 286 | 286 | |
| 287 | 287 | $form = FrmForm::get_current_form(); |
| 288 | 288 | $params = FrmForm::get_admin_params( $form ); |
| 289 | 289 | |
| 290 | - if ( $form ) { |
|
| 291 | - $params['form'] = $form->id; |
|
| 292 | - $frm_vars['current_form'] = $form; |
|
| 290 | + if ( $form ) { |
|
| 291 | + $params['form'] = $form->id; |
|
| 292 | + $frm_vars['current_form'] = $form; |
|
| 293 | 293 | |
| 294 | - if ( 'trash' == $form->status ) { |
|
| 295 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | - unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | - } |
|
| 294 | + if ( 'trash' == $form->status ) { |
|
| 295 | + $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 296 | + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) ); |
|
| 297 | + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete ); |
|
| 298 | + unset( $time_to_delete, $delete_timestamp ); |
|
| 299 | + } |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 302 | + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' ); |
|
| 303 | 303 | |
| 304 | - $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 304 | + $wp_list_table = new $table_class( array( 'params' => $params ) ); |
|
| 305 | 305 | |
| 306 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 306 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 307 | 307 | |
| 308 | - $wp_list_table->prepare_items(); |
|
| 308 | + $wp_list_table->prepare_items(); |
|
| 309 | 309 | |
| 310 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 310 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 311 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | - if ( headers_sent() ) { |
|
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 315 | - } else { |
|
| 316 | - wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | - } |
|
| 318 | - die(); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | - $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | - } |
|
| 313 | + if ( headers_sent() ) { |
|
| 314 | + echo FrmAppHelper::js_redirect($url); |
|
| 315 | + } else { |
|
| 316 | + wp_redirect( esc_url_raw( $url ) ); |
|
| 317 | + } |
|
| 318 | + die(); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 322 | + $message = __( 'Your import is complete', 'formidable' ); |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | 325 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php' ); |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - /* Back End CRUD */ |
|
| 328 | + /* Back End CRUD */ |
|
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check('frm_view_entries'); |
|
| 331 | 331 | |
| 332 | - if ( ! $id ) { |
|
| 332 | + if ( ! $id ) { |
|
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
| 334 | 334 | |
| 335 | - if ( ! $id ) { |
|
| 335 | + if ( ! $id ) { |
|
| 336 | 336 | $id = FrmAppHelper::get_param( 'item_id', 0, 'get', 'absint' ); |
| 337 | - } |
|
| 338 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne($id, true); |
|
| 341 | 341 | if ( ! $entry ) { |
| 342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,110 +345,110 @@ discard block |
||
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $data = maybe_unserialize($entry->description); |
|
| 348 | + $data = maybe_unserialize($entry->description); |
|
| 349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 350 | 350 | $data = array( 'referrer' => $data ); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' ); |
| 354 | - $to_emails = array(); |
|
| 354 | + $to_emails = array(); |
|
| 355 | 355 | |
| 356 | 356 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' ); |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - public static function destroy() { |
|
| 360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 359 | + public static function destroy() { |
|
| 360 | + FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 361 | 361 | |
| 362 | 362 | $params = FrmForm::get_admin_params(); |
| 363 | 363 | |
| 364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 365 | - //unlink entry from post |
|
| 366 | - global $wpdb; |
|
| 364 | + if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 365 | + //unlink entry from post |
|
| 366 | + global $wpdb; |
|
| 367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - $message = ''; |
|
| 371 | - if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 372 | - $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 373 | - } |
|
| 370 | + $message = ''; |
|
| 371 | + if ( FrmEntry::destroy( $params['id'] ) ) { |
|
| 372 | + $message = __( 'Entry was Successfully Destroyed', 'formidable' ); |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - self::display_list( $message ); |
|
| 376 | - } |
|
| 375 | + self::display_list( $message ); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - public static function destroy_all() { |
|
| 379 | - if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 380 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 381 | - wp_die( $frm_settings->admin_permission ); |
|
| 382 | - } |
|
| 378 | + public static function destroy_all() { |
|
| 379 | + if ( ! current_user_can( 'frm_delete_entries' ) ) { |
|
| 380 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 381 | + wp_die( $frm_settings->admin_permission ); |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - global $wpdb; |
|
| 384 | + global $wpdb; |
|
| 385 | 385 | $params = FrmForm::get_admin_params(); |
| 386 | - $message = ''; |
|
| 387 | - $errors = array(); |
|
| 388 | - $form_id = (int) $params['form']; |
|
| 386 | + $message = ''; |
|
| 387 | + $errors = array(); |
|
| 388 | + $form_id = (int) $params['form']; |
|
| 389 | 389 | |
| 390 | - if ( $form_id ) { |
|
| 391 | - $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 390 | + if ( $form_id ) { |
|
| 391 | + $entry_ids = FrmDb::get_col( 'frm_items', array( 'form_id' => $form_id ) ); |
|
| 392 | 392 | $action = FrmFormAction::get_action_for_form( $form_id, 'wppost', 1 ); |
| 393 | 393 | |
| 394 | - if ( $action ) { |
|
| 395 | - // this action takes a while, so only trigger it if there are posts to delete |
|
| 396 | - foreach ( $entry_ids as $entry_id ) { |
|
| 397 | - do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 398 | - unset( $entry_id ); |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - $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 ) ); |
|
| 403 | - $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 404 | - if ( $results ) { |
|
| 394 | + if ( $action ) { |
|
| 395 | + // this action takes a while, so only trigger it if there are posts to delete |
|
| 396 | + foreach ( $entry_ids as $entry_id ) { |
|
| 397 | + do_action( 'frm_before_destroy_entry', $entry_id ); |
|
| 398 | + unset( $entry_id ); |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + $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 ) ); |
|
| 403 | + $results = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_items WHERE form_id=%d", $form_id ) ); |
|
| 404 | + if ( $results ) { |
|
| 405 | 405 | FrmEntry::clear_cache(); |
| 406 | - $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 407 | - } |
|
| 408 | - } else { |
|
| 409 | - $errors = __( 'No entries were specified', 'formidable' ); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - self::display_list( $message, $errors ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 416 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 417 | - return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - public static function get_form( $filename, $form, $title, $description ) { |
|
| 421 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 422 | - return FrmFormsController::get_form( $form, $title, $description ); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - public static function process_entry( $errors = '', $ajax = false ) { |
|
| 406 | + $message = __( 'Entries were Successfully Destroyed', 'formidable' ); |
|
| 407 | + } |
|
| 408 | + } else { |
|
| 409 | + $errors = __( 'No entries were specified', 'formidable' ); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + self::display_list( $message, $errors ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + public static function show_form( $id = '', $key = '', $title = false, $description = false ) { |
|
| 416 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' ); |
|
| 417 | + return FrmFormsController::show_form( $id, $key, $title, $description ); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + public static function get_form( $filename, $form, $title, $description ) { |
|
| 421 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' ); |
|
| 422 | + return FrmFormsController::get_form( $form, $title, $description ); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + public static function process_entry( $errors = '', $ajax = false ) { |
|
| 426 | 426 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
| 427 | 427 | if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { |
| 428 | - return; |
|
| 429 | - } |
|
| 428 | + return; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - global $frm_vars; |
|
| 431 | + global $frm_vars; |
|
| 432 | 432 | |
| 433 | 433 | $form = FrmForm::getOne( $form_id ); |
| 434 | - if ( ! $form ) { |
|
| 435 | - return; |
|
| 436 | - } |
|
| 434 | + if ( ! $form ) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | $params = FrmForm::get_params( $form ); |
| 439 | 439 | |
| 440 | - if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 441 | - $frm_vars['form_params'] = array(); |
|
| 442 | - } |
|
| 440 | + if ( ! isset( $frm_vars['form_params'] ) ) { |
|
| 441 | + $frm_vars['form_params'] = array(); |
|
| 442 | + } |
|
| 443 | 443 | $frm_vars['form_params'][ $form->id ] = $params; |
| 444 | 444 | |
| 445 | 445 | if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
| 446 | - return; |
|
| 447 | - } |
|
| 446 | + return; |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - if ( $errors == '' && ! $ajax ) { |
|
| 449 | + if ( $errors == '' && ! $ajax ) { |
|
| 450 | 450 | $errors = FrmEntryValidate::validate( $_POST ); |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | 453 | /** |
| 454 | 454 | * Use this filter to add trigger actions and add errors after |
@@ -459,54 +459,54 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
| 461 | 461 | |
| 462 | - if ( empty( $errors ) ) { |
|
| 462 | + if ( empty( $errors ) ) { |
|
| 463 | 463 | $_POST['frm_skip_cookie'] = 1; |
| 464 | - if ( $params['action'] == 'create' ) { |
|
| 464 | + if ( $params['action'] == 'create' ) { |
|
| 465 | 465 | if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
| 466 | 466 | $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
| 467 | - } |
|
| 468 | - } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 470 | + do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) ); |
|
| 471 | 471 | unset( $_POST['frm_skip_cookie'] ); |
| 472 | - } |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 476 | - self::_delete_entry( $atts['id'], $form ); |
|
| 477 | - return $url; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - //Delete entry if not redirected |
|
| 481 | - public static function delete_entry_after_save( $atts ) { |
|
| 482 | - self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - private static function _delete_entry( $entry_id, $form ) { |
|
| 486 | - if ( ! $form ) { |
|
| 487 | - return; |
|
| 488 | - } |
|
| 489 | - |
|
| 490 | - $form->options = maybe_unserialize( $form->options ); |
|
| 491 | - if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 492 | - FrmEntry::destroy( $entry_id ); |
|
| 493 | - } |
|
| 494 | - } |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + public static function delete_entry_before_redirect( $url, $form, $atts ) { |
|
| 476 | + self::_delete_entry( $atts['id'], $form ); |
|
| 477 | + return $url; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + //Delete entry if not redirected |
|
| 481 | + public static function delete_entry_after_save( $atts ) { |
|
| 482 | + self::_delete_entry( $atts['entry_id'], $atts['form'] ); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + private static function _delete_entry( $entry_id, $form ) { |
|
| 486 | + if ( ! $form ) { |
|
| 487 | + return; |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + $form->options = maybe_unserialize( $form->options ); |
|
| 491 | + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) { |
|
| 492 | + FrmEntry::destroy( $entry_id ); |
|
| 493 | + } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | public static function show_entry_shortcode( $atts ) { |
| 497 | 497 | return FrmEntryFormat::show_entry( $atts ); |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 501 | + $plain_text = add_filter('frm_plain_text_email', true); |
|
| 502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 503 | 503 | |
| 504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 505 | - return $value; |
|
| 506 | - } |
|
| 504 | + if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 505 | + return $value; |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - return $value; |
|
| 509 | - } |
|
| 508 | + return $value; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | 511 | public static function get_params( $form = null ) { |
| 512 | 512 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_params' ); |
@@ -514,15 +514,15 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public static function entry_sidebar( $entry ) { |
| 517 | - $data = maybe_unserialize($entry->description); |
|
| 518 | - $date_format = get_option('date_format'); |
|
| 519 | - $time_format = get_option('time_format'); |
|
| 517 | + $data = maybe_unserialize($entry->description); |
|
| 518 | + $date_format = get_option('date_format'); |
|
| 519 | + $time_format = get_option('time_format'); |
|
| 520 | 520 | if ( isset( $data['browser'] ) ) { |
| 521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' ); |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | /*********************************************************************** |
| 528 | 528 | * Deprecated Functions |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | public static function menu() { |
| 6 | 6 | FrmAppHelper::force_capability( 'frm_view_entries' ); |
| 7 | 7 | |
| 8 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 8 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); |
|
| 9 | 9 | |
| 10 | 10 | if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) { |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'id' => 'formidable-entries-tab', |
| 54 | 54 | 'title' => __( 'Overview', 'formidable' ), |
| 55 | 55 | '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>', |
| 56 | - )); |
|
| 56 | + ) ); |
|
| 57 | 57 | |
| 58 | 58 | $screen->set_help_sidebar( |
| 59 | 59 | '<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' . |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | global $frm_vars, $wpdb; |
| 69 | 69 | $form_id = FrmForm::get_current_form_id(); |
| 70 | 70 | |
| 71 | - $columns[ $form_id . '_id' ] = 'ID'; |
|
| 72 | - $columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 71 | + $columns[$form_id . '_id'] = 'ID'; |
|
| 72 | + $columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' ); |
|
| 73 | 73 | |
| 74 | 74 | if ( ! $form_id ) { |
| 75 | 75 | return $columns; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $form_cols = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 78 | + $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
| 79 | 79 | |
| 80 | 80 | foreach ( $form_cols as $form_col ) { |
| 81 | 81 | if ( FrmField::is_no_save_field( $form_col->type ) ) { |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | if ( $sub_form_cols ) { |
| 89 | 89 | foreach ( $sub_form_cols as $k => $sub_form_col ) { |
| 90 | 90 | if ( FrmField::is_no_save_field( $sub_form_col->type ) ) { |
| 91 | - unset( $sub_form_cols[ $k ] ); |
|
| 91 | + unset( $sub_form_cols[$k] ); |
|
| 92 | 92 | continue; |
| 93 | 93 | } |
| 94 | - $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | - unset($sub_form_col); |
|
| 94 | + $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 ); |
|
| 95 | + unset( $sub_form_col ); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | - unset($sub_form_cols); |
|
| 98 | + unset( $sub_form_cols ); |
|
| 99 | 99 | } else { |
| 100 | 100 | $col_id = $form_col->field_key; |
| 101 | 101 | if ( $form_col->form_id != $form_id ) { |
| 102 | 102 | $col_id .= '-_-form' . $form_col->form_id; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) { |
|
| 106 | - $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 105 | + if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] ) { |
|
| 106 | + $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 107 | 107 | } |
| 108 | - $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 108 | + $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 ); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | - $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' ); |
|
| 114 | - $columns[ $form_id . '_ip' ] = 'IP'; |
|
| 112 | + $columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' ); |
|
| 113 | + $columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' ); |
|
| 114 | + $columns[$form_id . '_ip'] = 'IP'; |
|
| 115 | 115 | |
| 116 | 116 | $frm_vars['cols'] = $columns; |
| 117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | global $frm_vars; |
| 138 | 138 | //add a check so we don't create a loop |
| 139 | - $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 139 | + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value; |
|
| 140 | 140 | |
| 141 | 141 | return $check; |
| 142 | 142 | } |
@@ -151,19 +151,19 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | global $frm_vars; |
| 154 | - if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 154 | + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) { |
|
| 155 | 155 | return; //don't continue if there's no previous value |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | foreach ( $meta_value as $mk => $mv ) { |
| 159 | 159 | //remove blank values |
| 160 | 160 | if ( empty( $mv ) ) { |
| 161 | - unset( $meta_value[ $mk ] ); |
|
| 161 | + unset( $meta_value[$mk] ); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $cur_form_prefix = reset($meta_value); |
|
| 166 | - $cur_form_prefix = explode('_', $cur_form_prefix); |
|
| 165 | + $cur_form_prefix = reset( $meta_value ); |
|
| 166 | + $cur_form_prefix = explode( '_', $cur_form_prefix ); |
|
| 167 | 167 | $cur_form_prefix = $cur_form_prefix[0]; |
| 168 | 168 | $save = false; |
| 169 | 169 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | $meta_value[] = $prev_hidden; |
| 184 | 184 | $save = true; |
| 185 | - unset($form_prefix); |
|
| 185 | + unset( $form_prefix ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ( $save ) { |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | foreach ( $fields as $field ) { |
| 215 | 215 | if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) { |
| 216 | 216 | // Can't sort on checkboxes because they are stored serialized, or post fields |
| 217 | - $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id; |
|
| 217 | + $columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | break; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - unset($form_prefix); |
|
| 240 | + unset( $form_prefix ); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
@@ -245,36 +245,36 @@ discard block |
||
| 245 | 245 | return $result; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0; |
|
| 248 | + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0; |
|
| 249 | 249 | $max_columns = 8; |
| 250 | 250 | if ( $i <= $max_columns ) { |
| 251 | 251 | return $result; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | global $frm_vars; |
| 255 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) { |
|
| 256 | - $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options); |
|
| 255 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) { |
|
| 256 | + $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) { |
|
| 259 | + if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) ) { |
|
| 260 | 260 | $result = $frm_vars['current_form']->options['hidden_cols']; |
| 261 | 261 | } else { |
| 262 | 262 | $cols = $frm_vars['cols']; |
| 263 | - $cols = array_reverse($cols, true); |
|
| 263 | + $cols = array_reverse( $cols, true ); |
|
| 264 | 264 | |
| 265 | 265 | $result[] = $form_id . '_id'; |
| 266 | - $i--; |
|
| 266 | + $i --; |
|
| 267 | 267 | |
| 268 | 268 | $result[] = $form_id . '_item_key'; |
| 269 | - $i--; |
|
| 269 | + $i --; |
|
| 270 | 270 | |
| 271 | 271 | foreach ( $cols as $col_key => $col ) { |
| 272 | 272 | if ( $i > $max_columns ) { |
| 273 | 273 | $result[] = $col_key; |
| 274 | 274 | } |
| 275 | 275 | //remove some columns by default |
| 276 | - $i--; |
|
| 277 | - unset($col_key, $col); |
|
| 276 | + $i --; |
|
| 277 | + unset( $col_key, $col ); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -311,14 +311,14 @@ discard block |
||
| 311 | 311 | if ( $pagenum > $total_pages && $total_pages > 0 ) { |
| 312 | 312 | $url = add_query_arg( 'paged', $total_pages ); |
| 313 | 313 | if ( headers_sent() ) { |
| 314 | - echo FrmAppHelper::js_redirect($url); |
|
| 314 | + echo FrmAppHelper::js_redirect( $url ); |
|
| 315 | 315 | } else { |
| 316 | 316 | wp_redirect( esc_url_raw( $url ) ); |
| 317 | 317 | } |
| 318 | 318 | die(); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if ( empty($message) && isset($_GET['import-message']) ) { |
|
| 321 | + if ( empty( $message ) && isset( $_GET['import-message'] ) ) { |
|
| 322 | 322 | $message = __( 'Your import is complete', 'formidable' ); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | /* Back End CRUD */ |
| 329 | 329 | public static function show( $id = 0 ) { |
| 330 | - FrmAppHelper::permission_check('frm_view_entries'); |
|
| 330 | + FrmAppHelper::permission_check( 'frm_view_entries' ); |
|
| 331 | 331 | |
| 332 | 332 | if ( ! $id ) { |
| 333 | 333 | $id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' ); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $entry = FrmEntry::getOne($id, true); |
|
| 340 | + $entry = FrmEntry::getOne( $id, true ); |
|
| 341 | 341 | if ( ! $entry ) { |
| 342 | 342 | echo '<div id="form_show_entry_page" class="wrap">' . |
| 343 | 343 | __( 'You are trying to view an entry that does not exist.', 'formidable' ) . |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | return; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $data = maybe_unserialize($entry->description); |
|
| 348 | + $data = maybe_unserialize( $entry->description ); |
|
| 349 | 349 | if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) { |
| 350 | 350 | $data = array( 'referrer' => $data ); |
| 351 | 351 | } |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | public static function destroy() { |
| 360 | - FrmAppHelper::permission_check('frm_delete_entries'); |
|
| 360 | + FrmAppHelper::permission_check( 'frm_delete_entries' ); |
|
| 361 | 361 | |
| 362 | 362 | $params = FrmForm::get_admin_params(); |
| 363 | 363 | |
| 364 | - if ( isset($params['keep_post']) && $params['keep_post'] ) { |
|
| 364 | + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) { |
|
| 365 | 365 | //unlink entry from post |
| 366 | 366 | global $wpdb; |
| 367 | 367 | $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) ); |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | if ( ! isset( $frm_vars['form_params'] ) ) { |
| 441 | 441 | $frm_vars['form_params'] = array(); |
| 442 | 442 | } |
| 443 | - $frm_vars['form_params'][ $form->id ] = $params; |
|
| 443 | + $frm_vars['form_params'][$form->id] = $params; |
|
| 444 | 444 | |
| 445 | - if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) { |
|
| 445 | + if ( isset( $frm_vars['created_entries'][$form_id] ) ) { |
|
| 446 | 446 | return; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | $errors = apply_filters( 'frm_entries_before_create', $errors, $form ); |
| 459 | 459 | |
| 460 | - $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors ); |
|
| 460 | + $frm_vars['created_entries'][$form_id] = array( 'errors' => $errors ); |
|
| 461 | 461 | |
| 462 | 462 | if ( empty( $errors ) ) { |
| 463 | 463 | $_POST['frm_skip_cookie'] = 1; |
| 464 | 464 | if ( $params['action'] == 'create' ) { |
| 465 | - if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) { |
|
| 466 | - $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 465 | + if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) { |
|
| 466 | + $frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST ); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
@@ -498,10 +498,10 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | public static function filter_shortcode_value( $value, $tag, $atts, $field ) { |
| 501 | - $plain_text = add_filter('frm_plain_text_email', true); |
|
| 501 | + $plain_text = add_filter( 'frm_plain_text_email', true ); |
|
| 502 | 502 | FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value ); |
| 503 | 503 | |
| 504 | - if ( isset($atts['show']) && $atts['show'] == 'value' ) { |
|
| 504 | + if ( isset( $atts['show'] ) && $atts['show'] == 'value' ) { |
|
| 505 | 505 | return $value; |
| 506 | 506 | } |
| 507 | 507 | |
@@ -514,9 +514,9 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public static function entry_sidebar( $entry ) { |
| 517 | - $data = maybe_unserialize($entry->description); |
|
| 518 | - $date_format = get_option('date_format'); |
|
| 519 | - $time_format = get_option('time_format'); |
|
| 517 | + $data = maybe_unserialize( $entry->description ); |
|
| 518 | + $date_format = get_option( 'date_format' ); |
|
| 519 | + $time_format = get_option( 'time_format' ); |
|
| 520 | 520 | if ( isset( $data['browser'] ) ) { |
| 521 | 521 | $browser = FrmEntryFormat::get_browser( $data['browser'] ); |
| 522 | 522 | } |
@@ -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,87 +80,87 @@ 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 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 120 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 121 | 121 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 122 | 122 | |
| 123 | 123 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 124 | - } else { |
|
| 125 | - FrmForm::update( $id, $values, true ); |
|
| 124 | + } else { |
|
| 125 | + FrmForm::update( $id, $values, true ); |
|
| 126 | 126 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
| 127 | 127 | die( FrmAppHelper::js_redirect( $url ) ); |
| 128 | - } |
|
| 129 | - } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - public static function edit( $values = false ) { |
|
| 132 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 131 | + public static function edit( $values = false ) { |
|
| 132 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 133 | 133 | |
| 134 | 134 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 135 | - return self::get_edit_vars($id); |
|
| 136 | - } |
|
| 135 | + return self::get_edit_vars($id); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - public static function settings( $id = false, $message = '' ) { |
|
| 139 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 138 | + public static function settings( $id = false, $message = '' ) { |
|
| 139 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 140 | 140 | |
| 141 | - if ( ! $id || ! is_numeric($id) ) { |
|
| 141 | + if ( ! $id || ! is_numeric($id) ) { |
|
| 142 | 142 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | return self::get_settings_vars( $id, array(), $message ); |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - public static function update_settings() { |
|
| 148 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 147 | + public static function update_settings() { |
|
| 148 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 149 | 149 | |
| 150 | 150 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 151 | 151 | |
| 152 | - $errors = FrmForm::validate($_POST); |
|
| 153 | - if ( count($errors) > 0 ) { |
|
| 154 | - return self::get_settings_vars($id, $errors); |
|
| 155 | - } |
|
| 152 | + $errors = FrmForm::validate($_POST); |
|
| 153 | + if ( count($errors) > 0 ) { |
|
| 154 | + return self::get_settings_vars($id, $errors); |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - do_action('frm_before_update_form_settings', $id); |
|
| 157 | + do_action('frm_before_update_form_settings', $id); |
|
| 158 | 158 | |
| 159 | 159 | FrmForm::update( $id, $_POST ); |
| 160 | 160 | |
| 161 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 161 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
| 162 | 162 | return self::get_settings_vars( $id, array(), $message ); |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | public static function edit_key() { |
| 166 | 166 | $values = self::edit_in_place_value( 'form_key' ); |
@@ -190,43 +190,43 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | public static function update( $values = array() ) { |
| 192 | 192 | if ( empty( $values ) ) { |
| 193 | - $values = $_POST; |
|
| 194 | - } |
|
| 193 | + $values = $_POST; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - //Set radio button and checkbox meta equal to "other" value |
|
| 197 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 198 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 199 | - } |
|
| 196 | + //Set radio button and checkbox meta equal to "other" value |
|
| 197 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 198 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - $errors = FrmForm::validate( $values ); |
|
| 202 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 203 | - if ( $permission_error !== false ) { |
|
| 204 | - $errors['form'] = $permission_error; |
|
| 205 | - } |
|
| 201 | + $errors = FrmForm::validate( $values ); |
|
| 202 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
| 203 | + if ( $permission_error !== false ) { |
|
| 204 | + $errors['form'] = $permission_error; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 208 | 208 | |
| 209 | 209 | if ( count( $errors ) > 0 ) { |
| 210 | - return self::get_edit_vars( $id, $errors ); |
|
| 210 | + return self::get_edit_vars( $id, $errors ); |
|
| 211 | 211 | } else { |
| 212 | - FrmForm::update( $id, $values ); |
|
| 213 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 214 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 212 | + FrmForm::update( $id, $values ); |
|
| 213 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 214 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 215 | 215 | wp_die( $message ); |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | return self::get_edit_vars( $id, array(), $message ); |
| 218 | - } |
|
| 219 | - } |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - public static function bulk_create_template( $ids ) { |
|
| 222 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 221 | + public static function bulk_create_template( $ids ) { |
|
| 222 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 223 | 223 | |
| 224 | - foreach ( $ids as $id ) { |
|
| 225 | - FrmForm::duplicate( $id, true, true ); |
|
| 226 | - } |
|
| 224 | + foreach ( $ids as $id ) { |
|
| 225 | + FrmForm::duplicate( $id, true, true ); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 229 | - } |
|
| 228 | + return __( 'Form template was Successfully Created', 'formidable' ); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Redirect to the url for creating from a template |
@@ -248,45 +248,45 @@ discard block |
||
| 248 | 248 | wp_die(); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - public static function duplicate() { |
|
| 252 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 251 | + public static function duplicate() { |
|
| 252 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 253 | 253 | |
| 254 | 254 | $params = FrmForm::list_page_params(); |
| 255 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 256 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 257 | - if ( $form ) { |
|
| 255 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
| 256 | + $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
| 257 | + if ( $form ) { |
|
| 258 | 258 | return self::get_edit_vars( $form, array(), $message, true ); |
| 259 | - } else { |
|
| 260 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 261 | - } |
|
| 262 | - } |
|
| 259 | + } else { |
|
| 260 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - public static function page_preview() { |
|
| 264 | + public static function page_preview() { |
|
| 265 | 265 | $params = FrmForm::list_page_params(); |
| 266 | - if ( ! $params['form'] ) { |
|
| 267 | - return; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - $form = FrmForm::getOne( $params['form'] ); |
|
| 271 | - if ( ! $form ) { |
|
| 272 | - return; |
|
| 273 | - } |
|
| 274 | - return self::show_form( $form->id, '', true, true ); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - public static function preview() { |
|
| 278 | - do_action( 'frm_wp' ); |
|
| 279 | - |
|
| 280 | - global $frm_vars; |
|
| 281 | - $frm_vars['preview'] = true; |
|
| 282 | - |
|
| 283 | - if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 284 | - global $wp; |
|
| 285 | - $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 266 | + if ( ! $params['form'] ) { |
|
| 267 | + return; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + $form = FrmForm::getOne( $params['form'] ); |
|
| 271 | + if ( ! $form ) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 274 | + return self::show_form( $form->id, '', true, true ); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + public static function preview() { |
|
| 278 | + do_action( 'frm_wp' ); |
|
| 279 | + |
|
| 280 | + global $frm_vars; |
|
| 281 | + $frm_vars['preview'] = true; |
|
| 282 | + |
|
| 283 | + if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
| 284 | + global $wp; |
|
| 285 | + $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
| 286 | 286 | include_once( $root . '/wp-config.php' ); |
| 287 | - $wp->init(); |
|
| 288 | - $wp->register_globals(); |
|
| 289 | - } |
|
| 287 | + $wp->init(); |
|
| 288 | + $wp->register_globals(); |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | self::register_pro_scripts(); |
| 292 | 292 | |
@@ -300,11 +300,11 @@ discard block |
||
| 300 | 300 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
| 301 | 301 | if ( empty( $form ) ) { |
| 302 | 302 | $form = FrmForm::getAll( array(), '', 1 ); |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
| 306 | - wp_die(); |
|
| 307 | - } |
|
| 306 | + wp_die(); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | public static function register_pro_scripts() { |
| 310 | 310 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -315,22 +315,22 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - public static function untrash() { |
|
| 318 | + public static function untrash() { |
|
| 319 | 319 | self::change_form_status( 'untrash' ); |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | 322 | public static function bulk_untrash( $ids ) { |
| 323 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 323 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 324 | 324 | |
| 325 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
| 325 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
| 326 | 326 | |
| 327 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 328 | - return $message; |
|
| 329 | - } |
|
| 327 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
| 328 | + return $message; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public static function trash() { |
|
| 331 | + public static function trash() { |
|
| 332 | 332 | self::change_form_status( 'trash' ); |
| 333 | - } |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @param string $status |
@@ -368,68 +368,68 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | public static function bulk_trash( $ids ) { |
| 371 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 371 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 372 | 372 | |
| 373 | - $count = 0; |
|
| 374 | - foreach ( $ids as $id ) { |
|
| 375 | - if ( FrmForm::trash( $id ) ) { |
|
| 376 | - $count++; |
|
| 377 | - } |
|
| 378 | - } |
|
| 373 | + $count = 0; |
|
| 374 | + foreach ( $ids as $id ) { |
|
| 375 | + if ( FrmForm::trash( $id ) ) { |
|
| 376 | + $count++; |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 380 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 381 | 381 | $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>' ); |
| 382 | 382 | |
| 383 | - return $message; |
|
| 384 | - } |
|
| 383 | + return $message; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - public static function destroy() { |
|
| 387 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 386 | + public static function destroy() { |
|
| 387 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 388 | 388 | |
| 389 | 389 | $params = FrmForm::list_page_params(); |
| 390 | 390 | |
| 391 | - //check nonce url |
|
| 392 | - check_admin_referer('destroy_form_' . $params['id']); |
|
| 391 | + //check nonce url |
|
| 392 | + check_admin_referer('destroy_form_' . $params['id']); |
|
| 393 | 393 | |
| 394 | - $count = 0; |
|
| 395 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 396 | - $count++; |
|
| 397 | - } |
|
| 394 | + $count = 0; |
|
| 395 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
| 396 | + $count++; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 399 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 400 | 400 | |
| 401 | 401 | self::display_forms_list( $params, $message ); |
| 402 | - } |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | 404 | public static function bulk_destroy( $ids ) { |
| 405 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 405 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
| 406 | 406 | |
| 407 | - $count = 0; |
|
| 408 | - foreach ( $ids as $id ) { |
|
| 409 | - $d = FrmForm::destroy( $id ); |
|
| 410 | - if ( $d ) { |
|
| 411 | - $count++; |
|
| 412 | - } |
|
| 413 | - } |
|
| 407 | + $count = 0; |
|
| 408 | + foreach ( $ids as $id ) { |
|
| 409 | + $d = FrmForm::destroy( $id ); |
|
| 410 | + if ( $d ) { |
|
| 411 | + $count++; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 415 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 416 | 416 | |
| 417 | - return $message; |
|
| 418 | - } |
|
| 417 | + return $message; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - private static function delete_all() { |
|
| 421 | - //check nonce url |
|
| 422 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 423 | - if ( $permission_error !== false ) { |
|
| 420 | + private static function delete_all() { |
|
| 421 | + //check nonce url |
|
| 422 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
| 423 | + if ( $permission_error !== false ) { |
|
| 424 | 424 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| 425 | - return; |
|
| 426 | - } |
|
| 425 | + return; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | 428 | $count = FrmForm::scheduled_delete( time() ); |
| 429 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 429 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
| 430 | 430 | |
| 431 | 431 | self::display_forms_list( array(), $message ); |
| 432 | - } |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | 434 | public static function scheduled_delete( $delete_timestamp = '' ) { |
| 435 | 435 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' ); |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | /** |
| 440 | - * Inserts Formidable button |
|
| 441 | - * Hook exists since 2.5.0 |
|
| 442 | - * |
|
| 443 | - * @since 2.0.15 |
|
| 444 | - */ |
|
| 440 | + * Inserts Formidable button |
|
| 441 | + * Hook exists since 2.5.0 |
|
| 442 | + * |
|
| 443 | + * @since 2.0.15 |
|
| 444 | + */ |
|
| 445 | 445 | public static function insert_form_button() { |
| 446 | 446 | if ( current_user_can('frm_view_forms') ) { |
| 447 | 447 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -452,49 +452,49 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - public static function insert_form_popup() { |
|
| 455 | + public static function insert_form_popup() { |
|
| 456 | 456 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
| 457 | 457 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
| 458 | - return; |
|
| 459 | - } |
|
| 458 | + return; |
|
| 459 | + } |
|
| 460 | 460 | |
| 461 | - FrmAppHelper::load_admin_wide_js(); |
|
| 461 | + FrmAppHelper::load_admin_wide_js(); |
|
| 462 | 462 | |
| 463 | - $shortcodes = array( |
|
| 463 | + $shortcodes = array( |
|
| 464 | 464 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
| 465 | - ); |
|
| 465 | + ); |
|
| 466 | 466 | |
| 467 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 467 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
| 468 | 468 | |
| 469 | 469 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - public static function get_shortcode_opts() { |
|
| 472 | + public static function get_shortcode_opts() { |
|
| 473 | 473 | FrmAppHelper::permission_check('frm_view_forms'); |
| 474 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 474 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 475 | 475 | |
| 476 | 476 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
| 477 | - if ( empty($shortcode) ) { |
|
| 478 | - wp_die(); |
|
| 479 | - } |
|
| 477 | + if ( empty($shortcode) ) { |
|
| 478 | + wp_die(); |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | 481 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
| 482 | 482 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
| 483 | 483 | |
| 484 | - $form_id = ''; |
|
| 485 | - $opts = array(); |
|
| 484 | + $form_id = ''; |
|
| 485 | + $opts = array(); |
|
| 486 | 486 | switch ( $shortcode ) { |
| 487 | - case 'formidable': |
|
| 488 | - $opts = array( |
|
| 487 | + case 'formidable': |
|
| 488 | + $opts = array( |
|
| 489 | 489 | 'form_id' => 'id', |
| 490 | - //'key' => ', |
|
| 490 | + //'key' => ', |
|
| 491 | 491 | 'title' => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ), |
| 492 | 492 | 'description' => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ), |
| 493 | 493 | 'minimize' => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ), |
| 494 | - ); |
|
| 495 | - break; |
|
| 496 | - } |
|
| 497 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 494 | + ); |
|
| 495 | + break; |
|
| 496 | + } |
|
| 497 | + $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
| 498 | 498 | |
| 499 | 499 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
| 500 | 500 | // allow other shortcodes to use the required form id option |
@@ -504,61 +504,61 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
| 506 | 506 | |
| 507 | - echo '</div>'; |
|
| 507 | + echo '</div>'; |
|
| 508 | 508 | |
| 509 | - wp_die(); |
|
| 510 | - } |
|
| 509 | + wp_die(); |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | 512 | public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) { |
| 513 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 513 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
| 514 | 514 | if ( ! empty( $deprecated_errors ) ) { |
| 515 | 515 | $errors = $deprecated_errors; |
| 516 | 516 | _deprecated_argument( 'errors', '2.0.8' ); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - global $wpdb, $frm_vars; |
|
| 519 | + global $wpdb, $frm_vars; |
|
| 520 | 520 | |
| 521 | 521 | if ( empty( $params ) ) { |
| 522 | 522 | $params = FrmForm::list_page_params(); |
| 523 | - } |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 525 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
| 526 | 526 | |
| 527 | - $pagenum = $wp_list_table->get_pagenum(); |
|
| 527 | + $pagenum = $wp_list_table->get_pagenum(); |
|
| 528 | 528 | |
| 529 | - $wp_list_table->prepare_items(); |
|
| 529 | + $wp_list_table->prepare_items(); |
|
| 530 | 530 | |
| 531 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 532 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 531 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
| 532 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
| 533 | 533 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
| 534 | - die(); |
|
| 535 | - } |
|
| 534 | + die(); |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | 537 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
| 538 | - } |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | 540 | public static function get_columns( $columns ) { |
| 541 | - $columns['cb'] = '<input type="checkbox" />'; |
|
| 542 | - $columns['id'] = 'ID'; |
|
| 541 | + $columns['cb'] = '<input type="checkbox" />'; |
|
| 542 | + $columns['id'] = 'ID'; |
|
| 543 | 543 | |
| 544 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 544 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
| 545 | 545 | |
| 546 | - if ( 'template' == $type ) { |
|
| 547 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 548 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
| 549 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 550 | - } else { |
|
| 551 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 552 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 553 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 554 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 555 | - } |
|
| 546 | + if ( 'template' == $type ) { |
|
| 547 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
| 548 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
| 549 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 550 | + } else { |
|
| 551 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
| 552 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
| 553 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
| 554 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 557 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
| 558 | 558 | |
| 559 | 559 | add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) ); |
| 560 | 560 | |
| 561 | - return $columns; |
|
| 561 | + return $columns; |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | public static function get_sortable_columns() { |
@@ -572,111 +572,111 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | public static function hidden_columns( $result ) { |
| 575 | - $return = false; |
|
| 576 | - foreach ( (array) $result as $r ) { |
|
| 577 | - if ( ! empty( $r ) ) { |
|
| 578 | - $return = true; |
|
| 579 | - break; |
|
| 580 | - } |
|
| 581 | - } |
|
| 575 | + $return = false; |
|
| 576 | + foreach ( (array) $result as $r ) { |
|
| 577 | + if ( ! empty( $r ) ) { |
|
| 578 | + $return = true; |
|
| 579 | + break; |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | - if ( $return ) { |
|
| 584 | - return $result; |
|
| 583 | + if ( $return ) { |
|
| 584 | + return $result; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 587 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
| 588 | 588 | |
| 589 | - $result[] = 'created_at'; |
|
| 590 | - if ( $type == 'template' ) { |
|
| 591 | - $result[] = 'id'; |
|
| 592 | - $result[] = 'form_key'; |
|
| 593 | - } |
|
| 589 | + $result[] = 'created_at'; |
|
| 590 | + if ( $type == 'template' ) { |
|
| 591 | + $result[] = 'id'; |
|
| 592 | + $result[] = 'form_key'; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - return $result; |
|
| 596 | - } |
|
| 595 | + return $result; |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | 598 | public static function save_per_page( $save, $option, $value ) { |
| 599 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 600 | - $save = (int) $value; |
|
| 601 | - } |
|
| 602 | - return $save; |
|
| 603 | - } |
|
| 599 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
| 600 | + $save = (int) $value; |
|
| 601 | + } |
|
| 602 | + return $save; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | 605 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
| 606 | - global $frm_vars; |
|
| 606 | + global $frm_vars; |
|
| 607 | 607 | |
| 608 | - $form = FrmForm::getOne( $id ); |
|
| 609 | - if ( ! $form ) { |
|
| 610 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 611 | - } |
|
| 608 | + $form = FrmForm::getOne( $id ); |
|
| 609 | + if ( ! $form ) { |
|
| 610 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - if ( $form->parent_form_id ) { |
|
| 613 | + if ( $form->parent_form_id ) { |
|
| 614 | 614 | 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>' )); |
| 615 | - } |
|
| 615 | + } |
|
| 616 | 616 | |
| 617 | 617 | $frm_field_selection = FrmField::field_selection(); |
| 618 | - $fields = FrmField::get_all_for_form($form->id); |
|
| 618 | + $fields = FrmField::get_all_for_form($form->id); |
|
| 619 | 619 | |
| 620 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 621 | - $reset_fields = false; |
|
| 622 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 620 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
| 621 | + $reset_fields = false; |
|
| 622 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
| 623 | 623 | |
| 624 | - if ( $reset_fields ) { |
|
| 625 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 626 | - } |
|
| 624 | + if ( $reset_fields ) { |
|
| 625 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 628 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
| 629 | 629 | |
| 630 | 630 | $args = array( 'parent_form_id' => $form->id ); |
| 631 | - $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
| 631 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
| 632 | 632 | |
| 633 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 634 | - if ( $form->is_template && $message == $edit_message ) { |
|
| 635 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 636 | - } |
|
| 633 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
| 634 | + if ( $form->is_template && $message == $edit_message ) { |
|
| 635 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
| 639 | 639 | |
| 640 | - if ( $form->default_template ) { |
|
| 641 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 642 | - } else if ( defined('DOING_AJAX') ) { |
|
| 643 | - wp_die(); |
|
| 644 | - } else if ( $create_link ) { |
|
| 640 | + if ( $form->default_template ) { |
|
| 641 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 642 | + } else if ( defined('DOING_AJAX') ) { |
|
| 643 | + wp_die(); |
|
| 644 | + } else if ( $create_link ) { |
|
| 645 | 645 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
| 646 | - } else { |
|
| 646 | + } else { |
|
| 647 | 647 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
| 648 | - } |
|
| 649 | - } |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
| 652 | 652 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 653 | 653 | |
| 654 | - global $frm_vars; |
|
| 654 | + global $frm_vars; |
|
| 655 | 655 | |
| 656 | - $form = FrmForm::getOne( $id ); |
|
| 656 | + $form = FrmForm::getOne( $id ); |
|
| 657 | 657 | |
| 658 | - $fields = FrmField::get_all_for_form($id); |
|
| 659 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 658 | + $fields = FrmField::get_all_for_form($id); |
|
| 659 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
| 660 | 660 | |
| 661 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 662 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 663 | - } |
|
| 661 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
| 662 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 665 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
| 666 | 666 | |
| 667 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 668 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 667 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
| 668 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
| 669 | 669 | |
| 670 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
| 670 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
| 671 | 671 | |
| 672 | 672 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
| 673 | - } |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 676 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 677 | - $linked_forms = array(); |
|
| 678 | - $col = 'one'; |
|
| 679 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 675 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
| 676 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
| 677 | + $linked_forms = array(); |
|
| 678 | + $col = 'one'; |
|
| 679 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
| 680 | 680 | |
| 681 | 681 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
| 682 | 682 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
| 685 | 685 | |
| 686 | 686 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | 690 | * Get an array of the options to display in the advanced tab |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | '' => '', |
| 726 | 726 | 'siteurl' => __( 'Site URL', 'formidable' ), |
| 727 | 727 | 'sitename' => __( 'Site Name', 'formidable' ), |
| 728 | - ); |
|
| 728 | + ); |
|
| 729 | 729 | |
| 730 | 730 | if ( ! FrmAppHelper::pro_is_installed() ) { |
| 731 | 731 | unset( $entry_shortcodes['post_id'] ); |
@@ -752,39 +752,39 @@ discard block |
||
| 752 | 752 | return $entry_shortcodes; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - // Insert the form class setting into the form |
|
| 755 | + // Insert the form class setting into the form |
|
| 756 | 756 | public static function form_classes( $form ) { |
| 757 | - if ( isset($form->options['form_class']) ) { |
|
| 757 | + if ( isset($form->options['form_class']) ) { |
|
| 758 | 758 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
| 759 | - } |
|
| 760 | - } |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - public static function get_email_html() { |
|
| 762 | + public static function get_email_html() { |
|
| 763 | 763 | FrmAppHelper::permission_check('frm_view_forms'); |
| 764 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 764 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 765 | 765 | echo FrmEntryFormat::show_entry( array( |
| 766 | 766 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
| 767 | - 'default_email' => true, |
|
| 767 | + 'default_email' => true, |
|
| 768 | 768 | 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
| 769 | - ) ); |
|
| 770 | - wp_die(); |
|
| 769 | + ) ); |
|
| 770 | + wp_die(); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | - public static function filter_content( $content, $form, $entry = false ) { |
|
| 773 | + public static function filter_content( $content, $form, $entry = false ) { |
|
| 774 | 774 | self::get_entry_by_param( $entry ); |
| 775 | - if ( ! $entry ) { |
|
| 776 | - return $content; |
|
| 777 | - } |
|
| 775 | + if ( ! $entry ) { |
|
| 776 | + return $content; |
|
| 777 | + } |
|
| 778 | 778 | |
| 779 | - if ( is_object( $form ) ) { |
|
| 780 | - $form = $form->id; |
|
| 781 | - } |
|
| 779 | + if ( is_object( $form ) ) { |
|
| 780 | + $form = $form->id; |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 784 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 783 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
| 784 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
| 785 | 785 | |
| 786 | - return $content; |
|
| 787 | - } |
|
| 786 | + return $content; |
|
| 787 | + } |
|
| 788 | 788 | |
| 789 | 789 | private static function get_entry_by_param( &$entry ) { |
| 790 | 790 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -796,282 +796,282 @@ discard block |
||
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 800 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 801 | - } |
|
| 799 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
| 800 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - public static function process_bulk_form_actions( $errors ) { |
|
| 804 | - if ( ! $_REQUEST ) { |
|
| 805 | - return $errors; |
|
| 806 | - } |
|
| 803 | + public static function process_bulk_form_actions( $errors ) { |
|
| 804 | + if ( ! $_REQUEST ) { |
|
| 805 | + return $errors; |
|
| 806 | + } |
|
| 807 | 807 | |
| 808 | 808 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 809 | - if ( $bulkaction == -1 ) { |
|
| 809 | + if ( $bulkaction == -1 ) { |
|
| 810 | 810 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 811 | - } |
|
| 812 | - |
|
| 813 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 814 | - FrmAppHelper::remove_get_action(); |
|
| 815 | - |
|
| 816 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 820 | - if ( empty( $ids ) ) { |
|
| 821 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 822 | - return $errors; |
|
| 823 | - } |
|
| 824 | - |
|
| 825 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 826 | - if ( $permission_error !== false ) { |
|
| 827 | - $errors[] = $permission_error; |
|
| 828 | - return $errors; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - if ( ! is_array( $ids ) ) { |
|
| 832 | - $ids = explode( ',', $ids ); |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - switch ( $bulkaction ) { |
|
| 836 | - case 'delete': |
|
| 837 | - $message = self::bulk_destroy( $ids ); |
|
| 838 | - break; |
|
| 839 | - case 'trash': |
|
| 840 | - $message = self::bulk_trash( $ids ); |
|
| 841 | - break; |
|
| 842 | - case 'untrash': |
|
| 843 | - $message = self::bulk_untrash( $ids ); |
|
| 844 | - break; |
|
| 845 | - case 'create_template': |
|
| 846 | - $message = self::bulk_create_template( $ids ); |
|
| 847 | - break; |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
| 814 | + FrmAppHelper::remove_get_action(); |
|
| 815 | + |
|
| 816 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
| 820 | + if ( empty( $ids ) ) { |
|
| 821 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
| 822 | + return $errors; |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
| 826 | + if ( $permission_error !== false ) { |
|
| 827 | + $errors[] = $permission_error; |
|
| 828 | + return $errors; |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + if ( ! is_array( $ids ) ) { |
|
| 832 | + $ids = explode( ',', $ids ); |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + switch ( $bulkaction ) { |
|
| 836 | + case 'delete': |
|
| 837 | + $message = self::bulk_destroy( $ids ); |
|
| 838 | + break; |
|
| 839 | + case 'trash': |
|
| 840 | + $message = self::bulk_trash( $ids ); |
|
| 841 | + break; |
|
| 842 | + case 'untrash': |
|
| 843 | + $message = self::bulk_untrash( $ids ); |
|
| 844 | + break; |
|
| 845 | + case 'create_template': |
|
| 846 | + $message = self::bulk_create_template( $ids ); |
|
| 847 | + break; |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
| 851 | 851 | echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; |
| 852 | - } |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | - return $errors; |
|
| 855 | - } |
|
| 854 | + return $errors; |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 858 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 857 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
| 858 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
| 859 | 859 | |
| 860 | - $path = untrailingslashit(trim($path)); |
|
| 860 | + $path = untrailingslashit(trim($path)); |
|
| 861 | 861 | $templates = glob( $path . '/*.php' ); |
| 862 | 862 | |
| 863 | 863 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
| 864 | 864 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
| 865 | 865 | $template_query = array( 'form_key' => $filename ); |
| 866 | - if ( $template ) { |
|
| 867 | - $template_query['is_template'] = 1; |
|
| 868 | - } |
|
| 869 | - if ( $default ) { |
|
| 870 | - $template_query['default_template'] = 1; |
|
| 871 | - } |
|
| 866 | + if ( $template ) { |
|
| 867 | + $template_query['is_template'] = 1; |
|
| 868 | + } |
|
| 869 | + if ( $default ) { |
|
| 870 | + $template_query['default_template'] = 1; |
|
| 871 | + } |
|
| 872 | 872 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 873 | 873 | |
| 874 | - $values = FrmFormsHelper::setup_new_vars(); |
|
| 875 | - $values['form_key'] = $filename; |
|
| 876 | - $values['is_template'] = $template; |
|
| 877 | - $values['status'] = 'published'; |
|
| 878 | - if ( $default ) { |
|
| 879 | - $values['default_template'] = 1; |
|
| 880 | - } |
|
| 881 | - |
|
| 882 | - include( $templates[ $i ] ); |
|
| 883 | - |
|
| 884 | - //get updated form |
|
| 885 | - if ( isset($form) && ! empty($form) ) { |
|
| 886 | - $old_id = $form->id; |
|
| 887 | - $form = FrmForm::getOne($form->id); |
|
| 888 | - } else { |
|
| 889 | - $old_id = false; |
|
| 874 | + $values = FrmFormsHelper::setup_new_vars(); |
|
| 875 | + $values['form_key'] = $filename; |
|
| 876 | + $values['is_template'] = $template; |
|
| 877 | + $values['status'] = 'published'; |
|
| 878 | + if ( $default ) { |
|
| 879 | + $values['default_template'] = 1; |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + include( $templates[ $i ] ); |
|
| 883 | + |
|
| 884 | + //get updated form |
|
| 885 | + if ( isset($form) && ! empty($form) ) { |
|
| 886 | + $old_id = $form->id; |
|
| 887 | + $form = FrmForm::getOne($form->id); |
|
| 888 | + } else { |
|
| 889 | + $old_id = false; |
|
| 890 | 890 | $form = FrmForm::getAll( $template_query, '', 1 ); |
| 891 | - } |
|
| 891 | + } |
|
| 892 | 892 | |
| 893 | - if ( $form ) { |
|
| 893 | + if ( $form ) { |
|
| 894 | 894 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
| 895 | - } |
|
| 896 | - } |
|
| 897 | - } |
|
| 895 | + } |
|
| 896 | + } |
|
| 897 | + } |
|
| 898 | 898 | |
| 899 | - public static function route() { |
|
| 900 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 901 | - $vars = array(); |
|
| 899 | + public static function route() { |
|
| 900 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 901 | + $vars = array(); |
|
| 902 | 902 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
| 903 | 903 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
| 904 | 904 | |
| 905 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 906 | - $json_vars = json_decode($json_vars, true); |
|
| 907 | - if ( empty($json_vars) ) { |
|
| 908 | - // json decoding failed so we should return an error message |
|
| 905 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
| 906 | + $json_vars = json_decode($json_vars, true); |
|
| 907 | + if ( empty($json_vars) ) { |
|
| 908 | + // json decoding failed so we should return an error message |
|
| 909 | 909 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 910 | - if ( 'edit' == $action ) { |
|
| 911 | - $action = 'update'; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 915 | - } else { |
|
| 916 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 917 | - $action = $vars[ $action ]; |
|
| 910 | + if ( 'edit' == $action ) { |
|
| 911 | + $action = 'update'; |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
| 915 | + } else { |
|
| 916 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
| 917 | + $action = $vars[ $action ]; |
|
| 918 | 918 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
| 919 | 919 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
| 920 | 920 | $_POST = array_merge( $_POST, $_REQUEST ); |
| 921 | - } |
|
| 922 | - } else { |
|
| 921 | + } |
|
| 922 | + } else { |
|
| 923 | 923 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 924 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 925 | - // override the action for this page |
|
| 926 | - $action = 'delete_all'; |
|
| 927 | - } |
|
| 928 | - } |
|
| 924 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
| 925 | + // override the action for this page |
|
| 926 | + $action = 'delete_all'; |
|
| 927 | + } |
|
| 928 | + } |
|
| 929 | 929 | |
| 930 | 930 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 931 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 932 | - |
|
| 933 | - switch ( $action ) { |
|
| 934 | - case 'new': |
|
| 935 | - return self::new_form($vars); |
|
| 936 | - case 'create': |
|
| 937 | - case 'edit': |
|
| 938 | - case 'update': |
|
| 939 | - case 'duplicate': |
|
| 940 | - case 'trash': |
|
| 941 | - case 'untrash': |
|
| 942 | - case 'destroy': |
|
| 943 | - case 'delete_all': |
|
| 944 | - case 'settings': |
|
| 945 | - case 'update_settings': |
|
| 931 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
| 932 | + |
|
| 933 | + switch ( $action ) { |
|
| 934 | + case 'new': |
|
| 935 | + return self::new_form($vars); |
|
| 936 | + case 'create': |
|
| 937 | + case 'edit': |
|
| 938 | + case 'update': |
|
| 939 | + case 'duplicate': |
|
| 940 | + case 'trash': |
|
| 941 | + case 'untrash': |
|
| 942 | + case 'destroy': |
|
| 943 | + case 'delete_all': |
|
| 944 | + case 'settings': |
|
| 945 | + case 'update_settings': |
|
| 946 | 946 | return self::$action( $vars ); |
| 947 | - default: |
|
| 947 | + default: |
|
| 948 | 948 | do_action( 'frm_form_action_' . $action ); |
| 949 | 949 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
| 950 | - return; |
|
| 951 | - } |
|
| 950 | + return; |
|
| 951 | + } |
|
| 952 | 952 | |
| 953 | 953 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
| 954 | - if ( $action == -1 ) { |
|
| 954 | + if ( $action == -1 ) { |
|
| 955 | 955 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
| 956 | - } |
|
| 956 | + } |
|
| 957 | 957 | |
| 958 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
| 959 | - FrmAppHelper::remove_get_action(); |
|
| 960 | - return self::list_form(); |
|
| 961 | - } |
|
| 958 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
| 959 | + FrmAppHelper::remove_get_action(); |
|
| 960 | + return self::list_form(); |
|
| 961 | + } |
|
| 962 | 962 | |
| 963 | - return self::display_forms_list(); |
|
| 964 | - } |
|
| 965 | - } |
|
| 963 | + return self::display_forms_list(); |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | 966 | |
| 967 | - public static function json_error( $errors ) { |
|
| 968 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 969 | - return $errors; |
|
| 970 | - } |
|
| 967 | + public static function json_error( $errors ) { |
|
| 968 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
| 969 | + return $errors; |
|
| 970 | + } |
|
| 971 | 971 | |
| 972 | 972 | |
| 973 | - /* FRONT-END FORMS */ |
|
| 974 | - public static function admin_bar_css() { |
|
| 973 | + /* FRONT-END FORMS */ |
|
| 974 | + public static function admin_bar_css() { |
|
| 975 | 975 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 976 | - return; |
|
| 977 | - } |
|
| 976 | + return; |
|
| 977 | + } |
|
| 978 | 978 | |
| 979 | 979 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
| 980 | 980 | FrmAppHelper::load_font_style(); |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | public static function admin_bar_configure() { |
| 984 | - global $frm_vars; |
|
| 985 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
| 986 | - return; |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - $actions = array(); |
|
| 990 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 991 | - if ( is_object($form) ) { |
|
| 992 | - $actions[ $form->id ] = $form->name; |
|
| 993 | - } |
|
| 994 | - unset($form); |
|
| 995 | - } |
|
| 996 | - |
|
| 997 | - if ( empty($actions) ) { |
|
| 998 | - return; |
|
| 999 | - } |
|
| 1000 | - |
|
| 1001 | - asort($actions); |
|
| 1002 | - |
|
| 1003 | - global $wp_admin_bar; |
|
| 1004 | - |
|
| 1005 | - if ( count($actions) == 1 ) { |
|
| 1006 | - $wp_admin_bar->add_menu( array( |
|
| 1007 | - 'title' => 'Edit Form', |
|
| 984 | + global $frm_vars; |
|
| 985 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
| 986 | + return; |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + $actions = array(); |
|
| 990 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
| 991 | + if ( is_object($form) ) { |
|
| 992 | + $actions[ $form->id ] = $form->name; |
|
| 993 | + } |
|
| 994 | + unset($form); |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + if ( empty($actions) ) { |
|
| 998 | + return; |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + asort($actions); |
|
| 1002 | + |
|
| 1003 | + global $wp_admin_bar; |
|
| 1004 | + |
|
| 1005 | + if ( count($actions) == 1 ) { |
|
| 1006 | + $wp_admin_bar->add_menu( array( |
|
| 1007 | + 'title' => 'Edit Form', |
|
| 1008 | 1008 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 1009 | - 'id' => 'frm-forms', |
|
| 1010 | - ) ); |
|
| 1011 | - } else { |
|
| 1012 | - $wp_admin_bar->add_menu( array( |
|
| 1013 | - 'id' => 'frm-forms', |
|
| 1014 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 1009 | + 'id' => 'frm-forms', |
|
| 1010 | + ) ); |
|
| 1011 | + } else { |
|
| 1012 | + $wp_admin_bar->add_menu( array( |
|
| 1013 | + 'id' => 'frm-forms', |
|
| 1014 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
| 1015 | 1015 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
| 1016 | - 'meta' => array( |
|
| 1016 | + 'meta' => array( |
|
| 1017 | 1017 | 'title' => __( 'Edit Forms', 'formidable' ), |
| 1018 | - ), |
|
| 1019 | - ) ); |
|
| 1018 | + ), |
|
| 1019 | + ) ); |
|
| 1020 | 1020 | |
| 1021 | - foreach ( $actions as $form_id => $name ) { |
|
| 1021 | + foreach ( $actions as $form_id => $name ) { |
|
| 1022 | 1022 | |
| 1023 | - $wp_admin_bar->add_menu( array( |
|
| 1024 | - 'parent' => 'frm-forms', |
|
| 1023 | + $wp_admin_bar->add_menu( array( |
|
| 1024 | + 'parent' => 'frm-forms', |
|
| 1025 | 1025 | 'id' => 'edit_form_' . $form_id, |
| 1026 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1026 | + 'title' => empty($name) ? __( '(no title)') : $name, |
|
| 1027 | 1027 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
| 1028 | - ) ); |
|
| 1029 | - } |
|
| 1030 | - } |
|
| 1031 | - } |
|
| 1028 | + ) ); |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 1031 | + } |
|
| 1032 | 1032 | |
| 1033 | - //formidable shortcode |
|
| 1033 | + //formidable shortcode |
|
| 1034 | 1034 | public static function get_form_shortcode( $atts ) { |
| 1035 | - global $frm_vars; |
|
| 1036 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1037 | - $sc = '[formidable'; |
|
| 1035 | + global $frm_vars; |
|
| 1036 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
| 1037 | + $sc = '[formidable'; |
|
| 1038 | 1038 | if ( ! empty( $atts ) ) { |
| 1039 | 1039 | foreach ( $atts as $k => $v ) { |
| 1040 | 1040 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
| 1041 | 1041 | } |
| 1042 | 1042 | } |
| 1043 | 1043 | return $sc . ']'; |
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - $shortcode_atts = shortcode_atts( array( |
|
| 1047 | - 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1048 | - 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1049 | - 'exclude_fields' => array(), 'minimize' => false, |
|
| 1050 | - ), $atts); |
|
| 1051 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1052 | - |
|
| 1053 | - return self::show_form( |
|
| 1054 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1055 | - $shortcode_atts['description'], $atts |
|
| 1056 | - ); |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1060 | - if ( empty( $id ) ) { |
|
| 1061 | - $id = $key; |
|
| 1062 | - } |
|
| 1063 | - |
|
| 1064 | - $form = self::maybe_get_form_to_show( $id ); |
|
| 1065 | - if ( ! $form ) { |
|
| 1066 | - return __( 'Please select a valid form', 'formidable' ); |
|
| 1067 | - } |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + $shortcode_atts = shortcode_atts( array( |
|
| 1047 | + 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
| 1048 | + 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
| 1049 | + 'exclude_fields' => array(), 'minimize' => false, |
|
| 1050 | + ), $atts); |
|
| 1051 | + do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
| 1052 | + |
|
| 1053 | + return self::show_form( |
|
| 1054 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
| 1055 | + $shortcode_atts['description'], $atts |
|
| 1056 | + ); |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
| 1060 | + if ( empty( $id ) ) { |
|
| 1061 | + $id = $key; |
|
| 1062 | + } |
|
| 1063 | + |
|
| 1064 | + $form = self::maybe_get_form_to_show( $id ); |
|
| 1065 | + if ( ! $form ) { |
|
| 1066 | + return __( 'Please select a valid form', 'formidable' ); |
|
| 1067 | + } |
|
| 1068 | 1068 | |
| 1069 | 1069 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1070 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1070 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
| 1071 | 1071 | |
| 1072 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1072 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
| 1073 | 1073 | |
| 1074 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1074 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1075 | 1075 | |
| 1076 | 1076 | if ( self::is_viewable_draft_form( $form ) ) { |
| 1077 | 1077 | // don't show a draft form on a page |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | return $form; |
| 1095 | - } |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | 1097 | private static function maybe_get_form_to_show( $id ) { |
| 1098 | 1098 | $form = false; |
@@ -1121,99 +1121,99 @@ discard block |
||
| 1121 | 1121 | 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'] ); |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1125 | - ob_start(); |
|
| 1124 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
| 1125 | + ob_start(); |
|
| 1126 | 1126 | |
| 1127 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1127 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
| 1128 | 1128 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
| 1129 | 1129 | |
| 1130 | - $contents = ob_get_contents(); |
|
| 1131 | - ob_end_clean(); |
|
| 1130 | + $contents = ob_get_contents(); |
|
| 1131 | + ob_end_clean(); |
|
| 1132 | 1132 | |
| 1133 | 1133 | self::maybe_minimize_form( $atts, $contents ); |
| 1134 | 1134 | |
| 1135 | - return $contents; |
|
| 1136 | - } |
|
| 1135 | + return $contents; |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | 1138 | public static function enqueue_scripts( $params ) { |
| 1139 | 1139 | do_action( 'frm_enqueue_form_scripts', $params ); |
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | public static function get_form_contents( $form, $title, $description, $atts ) { |
| 1143 | - global $frm_vars; |
|
| 1143 | + global $frm_vars; |
|
| 1144 | 1144 | |
| 1145 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 1145 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 1146 | 1146 | |
| 1147 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1147 | + $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
| 1148 | 1148 | |
| 1149 | - $user_ID = get_current_user_id(); |
|
| 1149 | + $user_ID = get_current_user_id(); |
|
| 1150 | 1150 | $params = FrmForm::get_params( $form ); |
| 1151 | 1151 | $message = ''; |
| 1152 | 1152 | $errors = ''; |
| 1153 | 1153 | |
| 1154 | - if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1155 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1156 | - } |
|
| 1154 | + if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
| 1155 | + $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
| 1156 | + } |
|
| 1157 | 1157 | |
| 1158 | 1158 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
| 1159 | - $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1159 | + $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
| 1160 | 1160 | |
| 1161 | - if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1162 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1163 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1164 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1161 | + if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
| 1162 | + do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
| 1163 | + if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
| 1164 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
| 1165 | 1165 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1166 | - } |
|
| 1167 | - return; |
|
| 1168 | - } |
|
| 1166 | + } |
|
| 1167 | + return; |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - if ( ! empty($errors) ) { |
|
| 1171 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1170 | + if ( ! empty($errors) ) { |
|
| 1171 | + $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
| 1172 | 1172 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1173 | - return; |
|
| 1174 | - } |
|
| 1173 | + return; |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1177 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1178 | - return; |
|
| 1179 | - } |
|
| 1176 | + do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
| 1177 | + if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
| 1178 | + return; |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1182 | - $created = self::just_created_entry( $form->id ); |
|
| 1183 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1181 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
| 1182 | + $created = self::just_created_entry( $form->id ); |
|
| 1183 | + $conf_method = apply_filters('frm_success_filter', 'message', $form, $form->options, 'create'); |
|
| 1184 | 1184 | |
| 1185 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1186 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1185 | + if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
| 1186 | + do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
| 1187 | 1187 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1188 | - return; |
|
| 1189 | - } |
|
| 1188 | + return; |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | - if ( $created && is_numeric($created) ) { |
|
| 1192 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1193 | - $class = 'frm_message'; |
|
| 1194 | - } else { |
|
| 1195 | - $message = $frm_settings->failed_msg; |
|
| 1196 | - $class = FrmFormsHelper::form_error_class(); |
|
| 1197 | - } |
|
| 1191 | + if ( $created && is_numeric($created) ) { |
|
| 1192 | + $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
| 1193 | + $class = 'frm_message'; |
|
| 1194 | + } else { |
|
| 1195 | + $message = $frm_settings->failed_msg; |
|
| 1196 | + $class = FrmFormsHelper::form_error_class(); |
|
| 1197 | + } |
|
| 1198 | 1198 | |
| 1199 | 1199 | $message = FrmFormsHelper::get_success_message( array( |
| 1200 | 1200 | 'message' => $message, 'form' => $form, |
| 1201 | 1201 | 'entry_id' => $created, 'class' => $class, |
| 1202 | 1202 | ) ); |
| 1203 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1203 | + $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
| 1204 | 1204 | |
| 1205 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1205 | + if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
| 1206 | 1206 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
| 1207 | - } else { |
|
| 1208 | - global $frm_vars; |
|
| 1207 | + } else { |
|
| 1208 | + global $frm_vars; |
|
| 1209 | 1209 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 1210 | 1210 | |
| 1211 | 1211 | $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
| 1212 | 1212 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
| 1213 | - } |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | 1215 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
| 1216 | - } |
|
| 1216 | + } |
|
| 1217 | 1217 | |
| 1218 | 1218 | /** |
| 1219 | 1219 | * @since 2.2.7 |
@@ -1250,10 +1250,10 @@ discard block |
||
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | 1252 | public static function defer_script_loading( $tag, $handle ) { |
| 1253 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1254 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1253 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
| 1254 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
| 1255 | 1255 | } |
| 1256 | - return $tag; |
|
| 1256 | + return $tag; |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | public static function footer_js( $location = 'footer' ) { |
@@ -14,44 +14,44 @@ |
||
| 14 | 14 | <div class="inside"> |
| 15 | 15 | <table class="form-table"><tbody> |
| 16 | 16 | <?php |
| 17 | - $first_h3 = 'frm_first_h3'; |
|
| 18 | - foreach ( $fields as $field ) { |
|
| 17 | + $first_h3 = 'frm_first_h3'; |
|
| 18 | + foreach ( $fields as $field ) { |
|
| 19 | 19 | if ( in_array( $field->type, array( 'captcha', 'html', 'end_divider', 'form' ) ) ) { |
| 20 | - continue; |
|
| 21 | - } |
|
| 20 | + continue; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | - ?> |
|
| 23 | + if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | + ?> |
|
| 25 | 25 | </tbody></table> |
| 26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
| 27 | 27 | <table class="form-table"><tbody> |
| 28 | 28 | <?php |
| 29 | - $first_h3 = ''; |
|
| 30 | - } else { |
|
| 31 | - ?> |
|
| 29 | + $first_h3 = ''; |
|
| 30 | + } else { |
|
| 31 | + ?> |
|
| 32 | 32 | <tr> |
| 33 | 33 | <th scope="row"><?php echo esc_html( $field->name ) ?>:</th> |
| 34 | 34 | <td> |
| 35 | 35 | <?php |
| 36 | 36 | $embedded_field_id = ( $entry->form_id != $field->form_id ) ? 'form' . $field->form_id : 0; |
| 37 | - $atts = array( |
|
| 38 | - 'type' => $field->type, 'post_id' => $entry->post_id, |
|
| 39 | - 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
| 40 | - 'embedded_field_id' => $embedded_field_id, |
|
| 41 | - ); |
|
| 37 | + $atts = array( |
|
| 38 | + 'type' => $field->type, 'post_id' => $entry->post_id, |
|
| 39 | + 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
| 40 | + 'embedded_field_id' => $embedded_field_id, |
|
| 41 | + ); |
|
| 42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
| 43 | 43 | echo $display_value; |
| 44 | 44 | |
| 45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 46 | - $to_emails[] = $display_value; |
|
| 47 | - } |
|
| 48 | - ?> |
|
| 45 | + if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 46 | + $to_emails[] = $display_value; |
|
| 47 | + } |
|
| 48 | + ?> |
|
| 49 | 49 | </td> |
| 50 | 50 | </tr> |
| 51 | 51 | <?php } |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - ?> |
|
| 54 | + ?> |
|
| 55 | 55 | |
| 56 | 56 | <?php if ( $entry->parent_item_id ) { ?> |
| 57 | 57 | <tr><th><?php _e( 'Parent Entry ID', 'formidable' ) ?>:</th> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <div id="form_show_entry_page" class="wrap"> |
| 2 | 2 | <h2 class="frm_no_print"><?php _e( 'View Entry', 'formidable' ) ?> |
| 3 | - <?php do_action('frm_entry_inside_h2', $entry->form_id); ?> |
|
| 3 | + <?php do_action( 'frm_entry_inside_h2', $entry->form_id ); ?> |
|
| 4 | 4 | </h2> |
| 5 | 5 | |
| 6 | 6 | <div class="frm_forms"> |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | <div id="poststuff"> |
| 9 | 9 | <div id="post-body" class="metabox-holder columns-2"> |
| 10 | 10 | <div id="post-body-content"> |
| 11 | - <?php FrmAppController::get_form_nav($entry->form_id, true); ?> |
|
| 11 | + <?php FrmAppController::get_form_nav( $entry->form_id, true ); ?> |
|
| 12 | 12 | <div class="postbox"> |
| 13 | 13 | <h3 class="hndle"><span><?php _e( 'Entry', 'formidable' ) ?></span></h3> |
| 14 | 14 | <div class="inside"> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | continue; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 23 | + if ( in_array( $field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | 24 | ?> |
| 25 | 25 | </tbody></table> |
| 26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
| 43 | 43 | echo $display_value; |
| 44 | 44 | |
| 45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 45 | + if ( is_email( $display_value ) && ! in_array( $display_value, $to_emails ) ) { |
|
| 46 | 46 | $to_emails[] = $display_value; |
| 47 | 47 | } |
| 48 | 48 | ?> |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | </td></tr> |
| 60 | 60 | <?php } ?> |
| 61 | 61 | </tbody></table> |
| 62 | - <?php do_action('frm_show_entry', $entry); ?> |
|
| 62 | + <?php do_action( 'frm_show_entry', $entry ); ?> |
|
| 63 | 63 | </div> |
| 64 | 64 | </div> |
| 65 | 65 | |
| 66 | - <?php do_action('frm_after_show_entry', $entry); ?> |
|
| 66 | + <?php do_action( 'frm_after_show_entry', $entry ); ?> |
|
| 67 | 67 | |
| 68 | 68 | </div> |
| 69 | 69 | <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-show.php' ); ?> |
@@ -5,25 +5,25 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmEntryMeta { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @param string $meta_key |
|
| 10 | - */ |
|
| 8 | + /** |
|
| 9 | + * @param string $meta_key |
|
| 10 | + */ |
|
| 11 | 11 | public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
| 12 | - global $wpdb; |
|
| 12 | + global $wpdb; |
|
| 13 | 13 | |
| 14 | - if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
| 15 | - // don't save blank fields |
|
| 16 | - return 0; |
|
| 17 | - } |
|
| 14 | + if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
| 15 | + // don't save blank fields |
|
| 16 | + return 0; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - $new_values = array( |
|
| 19 | + $new_values = array( |
|
| 20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
| 21 | - 'item_id' => $entry_id, |
|
| 22 | - 'field_id' => $field_id, |
|
| 23 | - 'created_at' => current_time('mysql', 1), |
|
| 24 | - ); |
|
| 21 | + 'item_id' => $entry_id, |
|
| 22 | + 'field_id' => $field_id, |
|
| 23 | + 'created_at' => current_time('mysql', 1), |
|
| 24 | + ); |
|
| 25 | 25 | |
| 26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
| 26 | + $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
| 27 | 27 | |
| 28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
| 29 | 29 | |
@@ -34,40 +34,40 @@ discard block |
||
| 34 | 34 | $id = 0; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - return $id; |
|
| 38 | - } |
|
| 37 | + return $id; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $meta_key |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @param string $meta_key |
|
| 42 | + */ |
|
| 43 | 43 | public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
| 44 | - if ( ! $field_id ) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 44 | + if ( ! $field_id ) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - global $wpdb; |
|
| 48 | + global $wpdb; |
|
| 49 | 49 | |
| 50 | 50 | $values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
| 51 | 51 | $where_values = $values; |
| 52 | - $values['meta_value'] = $meta_value; |
|
| 53 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
| 52 | + $values['meta_value'] = $meta_value; |
|
| 53 | + $values = apply_filters('frm_update_entry_meta', $values); |
|
| 54 | 54 | if ( is_array($values['meta_value']) ) { |
| 55 | 55 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
| 56 | 56 | } |
| 57 | - $meta_value = maybe_serialize($values['meta_value']); |
|
| 57 | + $meta_value = maybe_serialize($values['meta_value']); |
|
| 58 | 58 | |
| 59 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
| 59 | + wp_cache_delete( $entry_id, 'frm_entry'); |
|
| 60 | 60 | self::clear_cache(); |
| 61 | 61 | |
| 62 | 62 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | public static function update_entry_metas( $entry_id, $values ) { |
| 66 | - global $wpdb; |
|
| 66 | + global $wpdb; |
|
| 67 | 67 | |
| 68 | 68 | $prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
| 69 | 69 | |
| 70 | - foreach ( $values as $field_id => $meta_value ) { |
|
| 70 | + foreach ( $values as $field_id => $meta_value ) { |
|
| 71 | 71 | $field = false; |
| 72 | 72 | if ( ! empty( $field_id ) ) { |
| 73 | 73 | $field = FrmField::getOne( $field_id ); |
@@ -91,39 +91,39 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( empty($prev_values) ) { |
|
| 95 | - return; |
|
| 96 | - } |
|
| 94 | + if ( empty($prev_values) ) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
| 98 | + $prev_values = array_diff($prev_values, array_keys($values)); |
|
| 99 | 99 | |
| 100 | - if ( empty($prev_values) ) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 100 | + if ( empty($prev_values) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | // prepare the query |
| 105 | 105 | $where = array( 'item_id' => $entry_id, 'field_id' => $prev_values ); |
| 106 | 106 | FrmDb::get_where_clause_and_values( $where ); |
| 107 | 107 | |
| 108 | - // Delete any leftovers |
|
| 109 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
| 108 | + // Delete any leftovers |
|
| 109 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
| 110 | 110 | self::clear_cache(); |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
| 114 | - $metas = self::get_entry_meta_info($old_id); |
|
| 115 | - foreach ( $metas as $meta ) { |
|
| 116 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
| 117 | - unset($meta); |
|
| 118 | - } |
|
| 114 | + $metas = self::get_entry_meta_info($old_id); |
|
| 115 | + foreach ( $metas as $meta ) { |
|
| 116 | + self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
| 117 | + unset($meta); |
|
| 118 | + } |
|
| 119 | 119 | self::clear_cache(); |
| 120 | - } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | public static function delete_entry_meta( $entry_id, $field_id ) { |
| 123 | - global $wpdb; |
|
| 123 | + global $wpdb; |
|
| 124 | 124 | self::clear_cache(); |
| 125 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
| 126 | - } |
|
| 125 | + return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Clear entry meta caching |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public static function get_entry_meta_by_field( $entry_id, $field_id ) { |
| 151 | - global $wpdb; |
|
| 151 | + global $wpdb; |
|
| 152 | 152 | |
| 153 | 153 | if ( is_object( $entry_id ) ) { |
| 154 | 154 | $entry = $entry_id; |
@@ -161,137 +161,137 @@ discard block |
||
| 161 | 161 | |
| 162 | 162 | if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
| 163 | 163 | $result = $cached->metas[ $field_id ]; |
| 164 | - return stripslashes_deep($result); |
|
| 165 | - } |
|
| 164 | + return stripslashes_deep($result); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | $get_table = $wpdb->prefix . 'frm_item_metas'; |
| 168 | 168 | $query = array( 'item_id' => $entry_id ); |
| 169 | - if ( is_numeric($field_id) ) { |
|
| 169 | + if ( is_numeric($field_id) ) { |
|
| 170 | 170 | $query['field_id'] = $field_id; |
| 171 | - } else { |
|
| 171 | + } else { |
|
| 172 | 172 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
| 173 | 173 | $query['fi.field_key'] = $field_id; |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
| 177 | - $result = maybe_unserialize($result); |
|
| 178 | - $result = stripslashes_deep($result); |
|
| 177 | + $result = maybe_unserialize($result); |
|
| 178 | + $result = stripslashes_deep($result); |
|
| 179 | 179 | |
| 180 | - return $result; |
|
| 181 | - } |
|
| 180 | + return $result; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | 183 | public static function get_entry_metas( $entry_id ) { |
| 184 | - _deprecated_function( __FUNCTION__, '1.07.10'); |
|
| 184 | + _deprecated_function( __FUNCTION__, '1.07.10'); |
|
| 185 | 185 | |
| 186 | - global $wpdb; |
|
| 186 | + global $wpdb; |
|
| 187 | 187 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); |
| 188 | - } |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
| 190 | + public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
| 191 | 191 | $defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false ); |
| 192 | - $args = wp_parse_args( $args, $defaults ); |
|
| 192 | + $args = wp_parse_args( $args, $defaults ); |
|
| 193 | 193 | |
| 194 | - $query = array(); |
|
| 195 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
| 196 | - $query = implode(' ', $query); |
|
| 194 | + $query = array(); |
|
| 195 | + self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
| 196 | + $query = implode(' ', $query); |
|
| 197 | 197 | |
| 198 | 198 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); |
| 199 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
| 199 | + $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
| 200 | 200 | |
| 201 | - if ( ! $args['stripslashes'] ) { |
|
| 202 | - return $values; |
|
| 203 | - } |
|
| 201 | + if ( ! $args['stripslashes'] ) { |
|
| 202 | + return $values; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | 205 | foreach ( $values as $k => $v ) { |
| 206 | 206 | $values[ $k ] = maybe_unserialize( $v ); |
| 207 | - unset($k, $v); |
|
| 208 | - } |
|
| 207 | + unset($k, $v); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - return stripslashes_deep($values); |
|
| 211 | - } |
|
| 210 | + return stripslashes_deep($values); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - /** |
|
| 214 | - * @param string $order |
|
| 215 | - * @param string $limit |
|
| 216 | - */ |
|
| 213 | + /** |
|
| 214 | + * @param string $order |
|
| 215 | + * @param string $limit |
|
| 216 | + */ |
|
| 217 | 217 | private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) { |
| 218 | - global $wpdb; |
|
| 219 | - $query[] = 'SELECT'; |
|
| 220 | - $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
| 218 | + global $wpdb; |
|
| 219 | + $query[] = 'SELECT'; |
|
| 220 | + $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
| 221 | 221 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em '; |
| 222 | 222 | |
| 223 | - if ( ! $args['is_draft'] ) { |
|
| 223 | + if ( ! $args['is_draft'] ) { |
|
| 224 | 224 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - if ( is_numeric($field_id) ) { |
|
| 228 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
| 229 | - } else { |
|
| 227 | + if ( is_numeric($field_id) ) { |
|
| 228 | + $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
| 229 | + } else { |
|
| 230 | 230 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); |
| 231 | - } |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - if ( ! $args['is_draft'] ) { |
|
| 234 | - $query[] = 'AND e.is_draft=0'; |
|
| 235 | - } |
|
| 233 | + if ( ! $args['is_draft'] ) { |
|
| 234 | + $query[] = 'AND e.is_draft=0'; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - if ( $args['value'] ) { |
|
| 238 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
| 239 | - } |
|
| 240 | - $query[] = $order . $limit; |
|
| 241 | - } |
|
| 237 | + if ( $args['value'] ) { |
|
| 238 | + $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
| 239 | + } |
|
| 240 | + $query[] = $order . $limit; |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | 243 | public static function get_entry_meta_info( $entry_id ) { |
| 244 | 244 | return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) ); |
| 245 | - } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) { |
| 248 | - global $wpdb; |
|
| 249 | - $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
| 248 | + global $wpdb; |
|
| 249 | + $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
| 250 | 250 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
| 251 | 251 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . |
| 252 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 252 | + FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 253 | 253 | |
| 254 | 254 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; |
| 255 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
| 255 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
| 256 | 256 | |
| 257 | - if ( ! $results || ! $stripslashes ) { |
|
| 258 | - return $results; |
|
| 259 | - } |
|
| 257 | + if ( ! $results || ! $stripslashes ) { |
|
| 258 | + return $results; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - foreach ( $results as $k => $result ) { |
|
| 261 | + foreach ( $results as $k => $result ) { |
|
| 262 | 262 | $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
| 263 | - unset($k, $result); |
|
| 264 | - } |
|
| 263 | + unset($k, $result); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - return $results; |
|
| 267 | - } |
|
| 266 | + return $results; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
| 269 | + public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
| 270 | 270 | $defaults = array( |
| 271 | 271 | 'is_draft' => false, |
| 272 | 272 | 'user_id' => '', |
| 273 | 273 | 'group_by' => '', |
| 274 | 274 | ); |
| 275 | - $args = wp_parse_args($args, $defaults); |
|
| 275 | + $args = wp_parse_args($args, $defaults); |
|
| 276 | 276 | |
| 277 | - $query = array(); |
|
| 278 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
| 279 | - $query = implode(' ', $query); |
|
| 277 | + $query = array(); |
|
| 278 | + self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
| 279 | + $query = implode(' ', $query); |
|
| 280 | 280 | |
| 281 | 281 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args ); |
| 282 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
| 282 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
| 283 | 283 | |
| 284 | - return $results; |
|
| 285 | - } |
|
| 284 | + return $results; |
|
| 285 | + } |
|
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * @param string|array $where |
|
| 289 | - * @param string $order_by |
|
| 290 | - * @param string $limit |
|
| 291 | - */ |
|
| 287 | + /** |
|
| 288 | + * @param string|array $where |
|
| 289 | + * @param string $order_by |
|
| 290 | + * @param string $limit |
|
| 291 | + */ |
|
| 292 | 292 | private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { |
| 293 | - global $wpdb; |
|
| 294 | - $query[] = 'SELECT'; |
|
| 293 | + global $wpdb; |
|
| 294 | + $query[] = 'SELECT'; |
|
| 295 | 295 | |
| 296 | 296 | $defaults = array( 'return_parent_id' => false ); |
| 297 | 297 | $args = array_merge( $defaults, $args ); |
@@ -305,89 +305,89 @@ discard block |
||
| 305 | 305 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
| 306 | 306 | |
| 307 | 307 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
| 308 | - if ( is_array($where) ) { |
|
| 309 | - if ( ! $args['is_draft'] ) { |
|
| 310 | - $where['e.is_draft'] = 0; |
|
| 311 | - } else if ( $args['is_draft'] == 1 ) { |
|
| 312 | - $where['e.is_draft'] = 1; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - if ( ! empty($args['user_id']) ) { |
|
| 316 | - $where['e.user_id'] = $args['user_id']; |
|
| 317 | - } |
|
| 318 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 308 | + if ( is_array($where) ) { |
|
| 309 | + if ( ! $args['is_draft'] ) { |
|
| 310 | + $where['e.is_draft'] = 0; |
|
| 311 | + } else if ( $args['is_draft'] == 1 ) { |
|
| 312 | + $where['e.is_draft'] = 1; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + if ( ! empty($args['user_id']) ) { |
|
| 316 | + $where['e.user_id'] = $args['user_id']; |
|
| 317 | + } |
|
| 318 | + $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 319 | 319 | |
| 320 | 320 | if ( $args['group_by'] ) { |
| 321 | 321 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
| 322 | 322 | } |
| 323 | - return; |
|
| 324 | - } |
|
| 323 | + return; |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | $draft_where = ''; |
| 327 | 327 | $user_where = ''; |
| 328 | - if ( ! $args['is_draft'] ) { |
|
| 328 | + if ( ! $args['is_draft'] ) { |
|
| 329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 ); |
| 330 | - } else if ( $args['is_draft'] == 1 ) { |
|
| 330 | + } else if ( $args['is_draft'] == 1 ) { |
|
| 331 | 331 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
| 332 | - } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - if ( ! empty($args['user_id']) ) { |
|
| 335 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
| 336 | - } |
|
| 334 | + if ( ! empty($args['user_id']) ) { |
|
| 335 | + $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | - if ( strpos($where, ' GROUP BY ') ) { |
|
| 339 | - // don't inject WHERE filtering after GROUP BY |
|
| 340 | - $parts = explode(' GROUP BY ', $where); |
|
| 341 | - $where = $parts[0]; |
|
| 342 | - $where .= $draft_where . $user_where; |
|
| 338 | + if ( strpos($where, ' GROUP BY ') ) { |
|
| 339 | + // don't inject WHERE filtering after GROUP BY |
|
| 340 | + $parts = explode(' GROUP BY ', $where); |
|
| 341 | + $where = $parts[0]; |
|
| 342 | + $where .= $draft_where . $user_where; |
|
| 343 | 343 | $where .= ' GROUP BY ' . $parts[1]; |
| 344 | - } else { |
|
| 345 | - $where .= $draft_where . $user_where; |
|
| 346 | - } |
|
| 344 | + } else { |
|
| 345 | + $where .= $draft_where . $user_where; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | 348 | // The query has already been prepared |
| 349 | 349 | $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
| 352 | + public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
| 353 | 353 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
| 354 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
| 355 | - if ( false !== $results ) { |
|
| 356 | - return $results; |
|
| 357 | - } |
|
| 354 | + $results = wp_cache_get($cache_key, 'frm_entry'); |
|
| 355 | + if ( false !== $results ) { |
|
| 356 | + return $results; |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - global $wpdb; |
|
| 359 | + global $wpdb; |
|
| 360 | 360 | if ( is_array( $search ) ) { |
| 361 | - $where = ''; |
|
| 361 | + $where = ''; |
|
| 362 | 362 | foreach ( $search as $field => $value ) { |
| 363 | 363 | if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) { |
| 364 | - continue; |
|
| 365 | - } |
|
| 364 | + continue; |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - switch ( $field ) { |
|
| 368 | - case 'year': |
|
| 367 | + switch ( $field ) { |
|
| 368 | + case 'year': |
|
| 369 | 369 | $value = '%' . $value; |
| 370 | - break; |
|
| 371 | - case 'month': |
|
| 372 | - $value .= '%'; |
|
| 373 | - break; |
|
| 374 | - case 'day': |
|
| 370 | + break; |
|
| 371 | + case 'month': |
|
| 372 | + $value .= '%'; |
|
| 373 | + break; |
|
| 374 | + case 'day': |
|
| 375 | 375 | $value = '%' . $value . '%'; |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); |
| 378 | - } |
|
| 379 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
| 378 | + } |
|
| 379 | + $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
| 380 | 380 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
| 381 | - } else { |
|
| 381 | + } else { |
|
| 382 | 382 | if ( $operator == 'LIKE' ) { |
| 383 | - $search = '%' . $search . '%'; |
|
| 383 | + $search = '%' . $search . '%'; |
|
| 384 | 384 | } |
| 385 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
| 386 | - } |
|
| 385 | + $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
| 386 | + } |
|
| 387 | 387 | |
| 388 | - $results = $wpdb->get_col($query, 0); |
|
| 388 | + $results = $wpdb->get_col($query, 0); |
|
| 389 | 389 | FrmAppHelper::set_cache( $cache_key, $results, 'frm_entry' ); |
| 390 | 390 | |
| 391 | - return $results; |
|
| 392 | - } |
|
| 391 | + return $results; |
|
| 392 | + } |
|
| 393 | 393 | } |
@@ -2,80 +2,80 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmNotification { |
| 4 | 4 | public function __construct() { |
| 5 | - if ( ! defined('ABSPATH') ) { |
|
| 6 | - die('You are not allowed to call this page directly.'); |
|
| 7 | - } |
|
| 8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 9 | - } |
|
| 5 | + if ( ! defined('ABSPATH') ) { |
|
| 6 | + die('You are not allowed to call this page directly.'); |
|
| 7 | + } |
|
| 8 | + add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
| 12 | - $notification = $action->post_content; |
|
| 13 | - $email_key = $action->ID; |
|
| 12 | + $notification = $action->post_content; |
|
| 13 | + $email_key = $action->ID; |
|
| 14 | 14 | |
| 15 | - // Set the subject |
|
| 16 | - if ( empty($notification['email_subject']) ) { |
|
| 17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 18 | - } |
|
| 15 | + // Set the subject |
|
| 16 | + if ( empty($notification['email_subject']) ) { |
|
| 17 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - $plain_text = $notification['plain_text'] ? true : false; |
|
| 20 | + $plain_text = $notification['plain_text'] ? true : false; |
|
| 21 | 21 | |
| 22 | - //Filter these fields |
|
| 23 | - $filter_fields = array( |
|
| 24 | - 'email_to', 'cc', 'bcc', |
|
| 25 | - 'reply_to', 'from', |
|
| 26 | - 'email_subject', 'email_message', |
|
| 27 | - ); |
|
| 22 | + //Filter these fields |
|
| 23 | + $filter_fields = array( |
|
| 24 | + 'email_to', 'cc', 'bcc', |
|
| 25 | + 'reply_to', 'from', |
|
| 26 | + 'email_subject', 'email_message', |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 29 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 30 | 30 | |
| 31 | - //Get all values in entry in order to get User ID field ID |
|
| 32 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
| 31 | + //Get all values in entry in order to get User ID field ID |
|
| 32 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
| 33 | 33 | $user_id_field = ''; |
| 34 | 34 | $user_id_key = ''; |
| 35 | - foreach ( $values as $value ) { |
|
| 36 | - if ( $value->field_type == 'user_id' ) { |
|
| 37 | - $user_id_field = $value->field_id; |
|
| 38 | - $user_id_key = $value->field_key; |
|
| 39 | - break; |
|
| 40 | - } |
|
| 41 | - unset($value); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - //Filter and prepare the email fields |
|
| 45 | - foreach ( $filter_fields as $f ) { |
|
| 46 | - //Don't allow empty From |
|
| 35 | + foreach ( $values as $value ) { |
|
| 36 | + if ( $value->field_type == 'user_id' ) { |
|
| 37 | + $user_id_field = $value->field_id; |
|
| 38 | + $user_id_key = $value->field_key; |
|
| 39 | + break; |
|
| 40 | + } |
|
| 41 | + unset($value); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + //Filter and prepare the email fields |
|
| 45 | + foreach ( $filter_fields as $f ) { |
|
| 46 | + //Don't allow empty From |
|
| 47 | 47 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
| 48 | 48 | $notification[ $f ] = '[admin_email]'; |
| 49 | 49 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
| 50 | 50 | //Remove brackets |
| 51 | - //Add a space in case there isn't one |
|
| 51 | + //Add a space in case there isn't one |
|
| 52 | 52 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
| 53 | 53 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
| 54 | 54 | |
| 55 | - //Switch userID shortcode to email address |
|
| 55 | + //Switch userID shortcode to email address |
|
| 56 | 56 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
| 57 | 57 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
| 58 | - $user_email = $user_data->user_email; |
|
| 58 | + $user_email = $user_data->user_email; |
|
| 59 | 59 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
| 60 | - } |
|
| 61 | - } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
| 66 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
| 67 | 67 | $to_emails = self::explode_emails( $notification['email_to'] ); |
| 68 | 68 | $cc = self::explode_emails( $notification['cc'] ); |
| 69 | 69 | $bcc = self::explode_emails( $notification['bcc'] ); |
| 70 | 70 | |
| 71 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 71 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 72 | 72 | |
| 73 | - // Stop now if there aren't any recipients |
|
| 74 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
| 75 | - return; |
|
| 76 | - } |
|
| 73 | + // Stop now if there aren't any recipients |
|
| 74 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
| 75 | + return; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $to_emails = array_unique( (array) $to_emails ); |
|
| 78 | + $to_emails = array_unique( (array) $to_emails ); |
|
| 79 | 79 | |
| 80 | 80 | $prev_mail_body = $notification['email_message']; |
| 81 | 81 | $mail_body = FrmEntriesHelper::replace_default_message( $prev_mail_body, array( |
@@ -83,48 +83,48 @@ discard block |
||
| 83 | 83 | 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
| 84 | 84 | ) ); |
| 85 | 85 | |
| 86 | - // Add the user info if it isn't already included |
|
| 87 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
| 88 | - $data = maybe_unserialize($entry->description); |
|
| 86 | + // Add the user info if it isn't already included |
|
| 87 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
| 88 | + $data = maybe_unserialize($entry->description); |
|
| 89 | 89 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 90 | 90 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
| 91 | 91 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
| 92 | 92 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| 93 | - } |
|
| 94 | - unset($prev_mail_body); |
|
| 95 | - |
|
| 96 | - // Add attachments |
|
| 97 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 98 | - |
|
| 99 | - if ( ! empty($notification['email_subject']) ) { |
|
| 100 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // check for a phone number |
|
| 104 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
| 105 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 106 | - $e = explode(' ', $e); |
|
| 107 | - |
|
| 108 | - //If to_email has name <[email protected]> format |
|
| 109 | - if ( is_email(end($e)) ) { |
|
| 110 | - continue; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - do_action('frm_send_to_not_email', array( |
|
| 114 | - 'e' => $e, |
|
| 115 | - 'subject' => $notification['email_subject'], |
|
| 116 | - 'mail_body' => $mail_body, |
|
| 117 | - 'reply_to' => $notification['reply_to'], |
|
| 118 | - 'from' => $notification['from'], |
|
| 119 | - 'plain_text' => $plain_text, |
|
| 120 | - 'attachments' => $attachments, |
|
| 121 | - 'form' => $form, |
|
| 122 | - 'email_key' => $email_key, |
|
| 123 | - ) ); |
|
| 93 | + } |
|
| 94 | + unset($prev_mail_body); |
|
| 95 | + |
|
| 96 | + // Add attachments |
|
| 97 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 98 | + |
|
| 99 | + if ( ! empty($notification['email_subject']) ) { |
|
| 100 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // check for a phone number |
|
| 104 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
| 105 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 106 | + $e = explode(' ', $e); |
|
| 107 | + |
|
| 108 | + //If to_email has name <[email protected]> format |
|
| 109 | + if ( is_email(end($e)) ) { |
|
| 110 | + continue; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + do_action('frm_send_to_not_email', array( |
|
| 114 | + 'e' => $e, |
|
| 115 | + 'subject' => $notification['email_subject'], |
|
| 116 | + 'mail_body' => $mail_body, |
|
| 117 | + 'reply_to' => $notification['reply_to'], |
|
| 118 | + 'from' => $notification['from'], |
|
| 119 | + 'plain_text' => $plain_text, |
|
| 120 | + 'attachments' => $attachments, |
|
| 121 | + 'form' => $form, |
|
| 122 | + 'email_key' => $email_key, |
|
| 123 | + ) ); |
|
| 124 | 124 | |
| 125 | 125 | unset( $to_emails[ $email_key ] ); |
| 126 | - } |
|
| 127 | - } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Send a separate email for email address in the "to" section |
@@ -132,38 +132,38 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | $send_single_recipient = apply_filters( 'frm_send_separate_emails', false, compact( 'action', 'entry', 'form' ) ); |
| 134 | 134 | |
| 135 | - // Send the email now |
|
| 136 | - $sent_to = self::send_email( array( |
|
| 137 | - 'to_email' => $to_emails, |
|
| 138 | - 'subject' => $notification['email_subject'], |
|
| 139 | - 'message' => $mail_body, |
|
| 140 | - 'from' => $notification['from'], |
|
| 141 | - 'plain_text' => $plain_text, |
|
| 142 | - 'reply_to' => $notification['reply_to'], |
|
| 143 | - 'attachments' => $attachments, |
|
| 144 | - 'cc' => $cc, |
|
| 145 | - 'bcc' => $bcc, |
|
| 135 | + // Send the email now |
|
| 136 | + $sent_to = self::send_email( array( |
|
| 137 | + 'to_email' => $to_emails, |
|
| 138 | + 'subject' => $notification['email_subject'], |
|
| 139 | + 'message' => $mail_body, |
|
| 140 | + 'from' => $notification['from'], |
|
| 141 | + 'plain_text' => $plain_text, |
|
| 142 | + 'reply_to' => $notification['reply_to'], |
|
| 143 | + 'attachments' => $attachments, |
|
| 144 | + 'cc' => $cc, |
|
| 145 | + 'bcc' => $bcc, |
|
| 146 | 146 | 'single_recipient' => $send_single_recipient, |
| 147 | - ) ); |
|
| 147 | + ) ); |
|
| 148 | 148 | |
| 149 | - return $sent_to; |
|
| 150 | - } |
|
| 149 | + return $sent_to; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | public function entry_created( $entry_id, $form_id ) { |
| 153 | 153 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
| 154 | 154 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
| 155 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 156 | - } |
|
| 155 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
| 159 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
| 159 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
| 160 | 160 | |
| 161 | - return self::send_email(compact( |
|
| 162 | - 'to_email', 'subject', 'message', |
|
| 163 | - 'from', 'from_name', 'plain_text', |
|
| 164 | - 'attachments', 'reply_to' |
|
| 165 | - )); |
|
| 166 | - } |
|
| 161 | + return self::send_email(compact( |
|
| 162 | + 'to_email', 'subject', 'message', |
|
| 163 | + 'from', 'from_name', 'plain_text', |
|
| 164 | + 'attachments', 'reply_to' |
|
| 165 | + )); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -181,53 +181,53 @@ discard block |
||
| 181 | 181 | return $emails; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
| 186 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
| 187 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
| 188 | - * "First Last" <[email protected]> |
|
| 189 | - * |
|
| 190 | - * Things that won't work: First Last (with no email entered) |
|
| 191 | - * @since 2.0 |
|
| 192 | - * @param array $atts array of email fields, pass by reference |
|
| 193 | - * @param $admin_email |
|
| 194 | - */ |
|
| 195 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
| 196 | - |
|
| 197 | - // If from is empty or is set to admin_email, set it now |
|
| 198 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 199 | - |
|
| 200 | - // Filter values in these fields |
|
| 184 | + /** |
|
| 185 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
| 186 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
| 187 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
| 188 | + * "First Last" <[email protected]> |
|
| 189 | + * |
|
| 190 | + * Things that won't work: First Last (with no email entered) |
|
| 191 | + * @since 2.0 |
|
| 192 | + * @param array $atts array of email fields, pass by reference |
|
| 193 | + * @param $admin_email |
|
| 194 | + */ |
|
| 195 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
| 196 | + |
|
| 197 | + // If from is empty or is set to admin_email, set it now |
|
| 198 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 199 | + |
|
| 200 | + // Filter values in these fields |
|
| 201 | 201 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
| 202 | 202 | |
| 203 | - foreach ( $filter_fields as $f ) { |
|
| 204 | - // If empty, just skip it |
|
| 203 | + foreach ( $filter_fields as $f ) { |
|
| 204 | + // If empty, just skip it |
|
| 205 | 205 | if ( empty( $atts[ $f ] ) ) { |
| 206 | - continue; |
|
| 207 | - } |
|
| 206 | + continue; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - // to_email, cc, and bcc can be an array |
|
| 209 | + // to_email, cc, and bcc can be an array |
|
| 210 | 210 | if ( is_array( $atts[ $f ] ) ) { |
| 211 | 211 | foreach ( $atts[ $f ] as $key => $val ) { |
| 212 | - self::format_single_field( $atts, $f, $val, $key ); |
|
| 213 | - unset( $key, $val ); |
|
| 214 | - } |
|
| 215 | - unset($f); |
|
| 216 | - continue; |
|
| 217 | - } |
|
| 212 | + self::format_single_field( $atts, $f, $val, $key ); |
|
| 213 | + unset( $key, $val ); |
|
| 214 | + } |
|
| 215 | + unset($f); |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
| 220 | - } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - // If reply-to isn't set, make it match the from settings |
|
| 223 | - if ( empty( $atts['reply_to'] ) ) { |
|
| 224 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
| 225 | - } |
|
| 222 | + // If reply-to isn't set, make it match the from settings |
|
| 223 | + if ( empty( $atts['reply_to'] ) ) { |
|
| 224 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 228 | - $atts['to_email'] = $admin_email; |
|
| 229 | - } |
|
| 230 | - } |
|
| 227 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 228 | + $atts['to_email'] = $admin_email; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | private static function get_email_from_formatted_string( $value ) { |
| 233 | 233 | if ( strpos( $value, '<' ) !== false ) { |
@@ -237,48 +237,48 @@ discard block |
||
| 237 | 237 | return $value; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - /** |
|
| 241 | - * Format individual email fields |
|
| 242 | - * |
|
| 243 | - * @since 2.0 |
|
| 244 | - * @param array $atts pass by reference |
|
| 245 | - * @param string $f (to, from, reply_to, etc) |
|
| 246 | - * @param string $val value saved in field |
|
| 247 | - * @param int $key if in array, this will be set |
|
| 248 | - */ |
|
| 249 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
| 250 | - $val = trim($val); |
|
| 251 | - |
|
| 252 | - // If just a plain email is used |
|
| 253 | - if ( is_email($val) ) { |
|
| 254 | - // add sender's name if not included in $from |
|
| 255 | - if ( $f == 'from' ) { |
|
| 240 | + /** |
|
| 241 | + * Format individual email fields |
|
| 242 | + * |
|
| 243 | + * @since 2.0 |
|
| 244 | + * @param array $atts pass by reference |
|
| 245 | + * @param string $f (to, from, reply_to, etc) |
|
| 246 | + * @param string $val value saved in field |
|
| 247 | + * @param int $key if in array, this will be set |
|
| 248 | + */ |
|
| 249 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
| 250 | + $val = trim($val); |
|
| 251 | + |
|
| 252 | + // If just a plain email is used |
|
| 253 | + if ( is_email($val) ) { |
|
| 254 | + // add sender's name if not included in $from |
|
| 255 | + if ( $f == 'from' ) { |
|
| 256 | 256 | $part_2 = $atts[ $f ]; |
| 257 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 258 | - } else { |
|
| 259 | - return; |
|
| 260 | - } |
|
| 261 | - } else { |
|
| 262 | - $parts = explode(' ', $val); |
|
| 263 | - $part_2 = end($parts); |
|
| 264 | - |
|
| 265 | - // If inputted correcly, $part_2 should be an email |
|
| 266 | - if ( is_email( $part_2 ) ) { |
|
| 267 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
| 268 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
| 257 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 258 | + } else { |
|
| 259 | + return; |
|
| 260 | + } |
|
| 261 | + } else { |
|
| 262 | + $parts = explode(' ', $val); |
|
| 263 | + $part_2 = end($parts); |
|
| 264 | + |
|
| 265 | + // If inputted correcly, $part_2 should be an email |
|
| 266 | + if ( is_email( $part_2 ) ) { |
|
| 267 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
| 268 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
| 269 | 269 | // In case someone just puts a name in the From or Reply To field |
| 270 | 270 | $part_1 = $val; |
| 271 | - $part_2 = get_option('admin_email'); |
|
| 272 | - } else { |
|
| 271 | + $part_2 = get_option('admin_email'); |
|
| 272 | + } else { |
|
| 273 | 273 | // In case someone just puts a name in any other email field |
| 274 | - if ( false !== $key ) { |
|
| 274 | + if ( false !== $key ) { |
|
| 275 | 275 | unset( $atts[ $f ][ $key ] ); |
| 276 | - return; |
|
| 277 | - } |
|
| 276 | + return; |
|
| 277 | + } |
|
| 278 | 278 | $atts[ $f ] = ''; |
| 279 | - return; |
|
| 280 | - } |
|
| 281 | - } |
|
| 279 | + return; |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | // if sending the email from a yahoo address, change it to the WordPress default |
| 284 | 284 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -291,60 +291,60 @@ discard block |
||
| 291 | 291 | $part_2 = 'wordpress@' . $sitename; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - // Set up formatted value |
|
| 294 | + // Set up formatted value |
|
| 295 | 295 | $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
| 296 | 296 | |
| 297 | - // If value is an array |
|
| 298 | - if ( false !== $key ) { |
|
| 297 | + // If value is an array |
|
| 298 | + if ( false !== $key ) { |
|
| 299 | 299 | $atts[ $f ][ $key ] = $final_val; |
| 300 | - return; |
|
| 301 | - } |
|
| 300 | + return; |
|
| 301 | + } |
|
| 302 | 302 | $atts[ $f ] = $final_val; |
| 303 | - } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | 305 | public static function send_email( $atts ) { |
| 306 | - $admin_email = get_option('admin_email'); |
|
| 307 | - $defaults = array( |
|
| 308 | - 'to_email' => $admin_email, |
|
| 309 | - 'subject' => '', |
|
| 310 | - 'message' => '', |
|
| 311 | - 'from' => $admin_email, |
|
| 312 | - 'from_name' => '', |
|
| 313 | - 'cc' => '', |
|
| 314 | - 'bcc' => '', |
|
| 315 | - 'plain_text' => true, |
|
| 316 | - 'reply_to' => $admin_email, |
|
| 317 | - 'attachments' => array(), |
|
| 306 | + $admin_email = get_option('admin_email'); |
|
| 307 | + $defaults = array( |
|
| 308 | + 'to_email' => $admin_email, |
|
| 309 | + 'subject' => '', |
|
| 310 | + 'message' => '', |
|
| 311 | + 'from' => $admin_email, |
|
| 312 | + 'from_name' => '', |
|
| 313 | + 'cc' => '', |
|
| 314 | + 'bcc' => '', |
|
| 315 | + 'plain_text' => true, |
|
| 316 | + 'reply_to' => $admin_email, |
|
| 317 | + 'attachments' => array(), |
|
| 318 | 318 | 'single_recipient' => false, |
| 319 | - ); |
|
| 320 | - $atts = wp_parse_args($atts, $defaults); |
|
| 319 | + ); |
|
| 320 | + $atts = wp_parse_args($atts, $defaults); |
|
| 321 | 321 | |
| 322 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
| 323 | - self::format_email_fields( $atts, $admin_email ); |
|
| 322 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
| 323 | + self::format_email_fields( $atts, $admin_email ); |
|
| 324 | 324 | |
| 325 | - $header = array(); |
|
| 326 | - $header[] = 'From: ' . $atts['from']; |
|
| 325 | + $header = array(); |
|
| 326 | + $header[] = 'From: ' . $atts['from']; |
|
| 327 | 327 | |
| 328 | - //Allow for cc and bcc arrays |
|
| 328 | + //Allow for cc and bcc arrays |
|
| 329 | 329 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
| 330 | 330 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
| 331 | - foreach ( $array_fields as $key => $a_field ) { |
|
| 332 | - if ( empty($a_field) ) { |
|
| 333 | - continue; |
|
| 334 | - } |
|
| 331 | + foreach ( $array_fields as $key => $a_field ) { |
|
| 332 | + if ( empty($a_field) ) { |
|
| 333 | + continue; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | foreach ( (array) $a_field as $email ) { |
| 337 | 337 | $cc[ $key ][] = $email; |
| 338 | - } |
|
| 339 | - unset($key, $a_field); |
|
| 340 | - } |
|
| 338 | + } |
|
| 339 | + unset($key, $a_field); |
|
| 340 | + } |
|
| 341 | 341 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
| 342 | 342 | |
| 343 | 343 | foreach ( $cc as $k => $v ) { |
| 344 | 344 | $header[] = $k . ': ' . implode( ',', $v ); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 347 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 348 | 348 | $atts['charset'] = get_option('blog_charset'); |
| 349 | 349 | |
| 350 | 350 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | $atts['message'] = do_shortcode( $atts['message'] ); |
| 355 | 355 | |
| 356 | - if ( $atts['plain_text'] ) { |
|
| 356 | + if ( $atts['plain_text'] ) { |
|
| 357 | 357 | $atts['message'] = wp_specialchars_decode( strip_tags( $atts['message'] ), ENT_QUOTES ); |
| 358 | - } else { |
|
| 358 | + } else { |
|
| 359 | 359 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
| 360 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
| 361 | - } |
|
| 360 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
| 361 | + } |
|
| 362 | 362 | $atts['message'] = apply_filters( 'frm_email_message', $atts['message'], $atts ); |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -388,10 +388,10 @@ discard block |
||
| 388 | 388 | // remove the filter now so other emails can still use it |
| 389 | 389 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
| 390 | 390 | |
| 391 | - if ( $sent ) { |
|
| 391 | + if ( $sent ) { |
|
| 392 | 392 | return self::return_emails_sent( $atts ); |
| 393 | - } |
|
| 394 | - } |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | 396 | private static function send_single_email( $recipient, $atts, $header ) { |
| 397 | 397 | $header = apply_filters( 'frm_email_header', $header, array( |
@@ -2,10 +2,10 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmNotification { |
| 4 | 4 | public function __construct() { |
| 5 | - if ( ! defined('ABSPATH') ) { |
|
| 6 | - die('You are not allowed to call this page directly.'); |
|
| 5 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 6 | + die( 'You are not allowed to call this page directly.' ); |
|
| 7 | 7 | } |
| 8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
| 8 | + add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 ); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | $email_key = $action->ID; |
| 14 | 14 | |
| 15 | 15 | // Set the subject |
| 16 | - if ( empty($notification['email_subject']) ) { |
|
| 17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
| 16 | + if ( empty( $notification['email_subject'] ) ) { |
|
| 17 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'email_subject', 'email_message', |
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
| 29 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
| 30 | 30 | |
| 31 | 31 | //Get all values in entry in order to get User ID field ID |
| 32 | 32 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -38,29 +38,29 @@ discard block |
||
| 38 | 38 | $user_id_key = $value->field_key; |
| 39 | 39 | break; |
| 40 | 40 | } |
| 41 | - unset($value); |
|
| 41 | + unset( $value ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | //Filter and prepare the email fields |
| 45 | 45 | foreach ( $filter_fields as $f ) { |
| 46 | 46 | //Don't allow empty From |
| 47 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
| 48 | - $notification[ $f ] = '[admin_email]'; |
|
| 47 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
| 48 | + $notification[$f] = '[admin_email]'; |
|
| 49 | 49 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
| 50 | 50 | //Remove brackets |
| 51 | 51 | //Add a space in case there isn't one |
| 52 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
| 53 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
| 52 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
| 53 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
| 54 | 54 | |
| 55 | 55 | //Switch userID shortcode to email address |
| 56 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
| 57 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
| 56 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
| 57 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
| 58 | 58 | $user_email = $user_data->user_email; |
| 59 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
| 59 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
| 63 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $cc = self::explode_emails( $notification['cc'] ); |
| 69 | 69 | $bcc = self::explode_emails( $notification['bcc'] ); |
| 70 | 70 | |
| 71 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
| 71 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
| 72 | 72 | |
| 73 | 73 | // Stop now if there aren't any recipients |
| 74 | 74 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -85,32 +85,32 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | // Add the user info if it isn't already included |
| 87 | 87 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
| 88 | - $data = maybe_unserialize($entry->description); |
|
| 88 | + $data = maybe_unserialize( $entry->description ); |
|
| 89 | 89 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
| 90 | 90 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
| 91 | 91 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
| 92 | 92 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
| 93 | 93 | } |
| 94 | - unset($prev_mail_body); |
|
| 94 | + unset( $prev_mail_body ); |
|
| 95 | 95 | |
| 96 | 96 | // Add attachments |
| 97 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
| 97 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
| 98 | 98 | |
| 99 | - if ( ! empty($notification['email_subject']) ) { |
|
| 100 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
| 99 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
| 100 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // check for a phone number |
| 104 | 104 | foreach ( (array) $to_emails as $email_key => $e ) { |
| 105 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
| 106 | - $e = explode(' ', $e); |
|
| 105 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
| 106 | + $e = explode( ' ', $e ); |
|
| 107 | 107 | |
| 108 | 108 | //If to_email has name <[email protected]> format |
| 109 | - if ( is_email(end($e)) ) { |
|
| 109 | + if ( is_email( end( $e ) ) ) { |
|
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - do_action('frm_send_to_not_email', array( |
|
| 113 | + do_action( 'frm_send_to_not_email', array( |
|
| 114 | 114 | 'e' => $e, |
| 115 | 115 | 'subject' => $notification['email_subject'], |
| 116 | 116 | 'mail_body' => $mail_body, |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | 'email_key' => $email_key, |
| 123 | 123 | ) ); |
| 124 | 124 | |
| 125 | - unset( $to_emails[ $email_key ] ); |
|
| 125 | + unset( $to_emails[$email_key] ); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | public function entry_created( $entry_id, $form_id ) { |
| 153 | 153 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
| 154 | 154 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
| 155 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
| 155 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
| 159 | 159 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
| 160 | 160 | |
| 161 | - return self::send_email(compact( |
|
| 161 | + return self::send_email( compact( |
|
| 162 | 162 | 'to_email', 'subject', 'message', |
| 163 | 163 | 'from', 'from_name', 'plain_text', |
| 164 | 164 | 'attachments', 'reply_to' |
| 165 | - )); |
|
| 165 | + ) ); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -195,28 +195,28 @@ discard block |
||
| 195 | 195 | private static function format_email_fields( &$atts, $admin_email ) { |
| 196 | 196 | |
| 197 | 197 | // If from is empty or is set to admin_email, set it now |
| 198 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 198 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
| 199 | 199 | |
| 200 | 200 | // Filter values in these fields |
| 201 | 201 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
| 202 | 202 | |
| 203 | 203 | foreach ( $filter_fields as $f ) { |
| 204 | 204 | // If empty, just skip it |
| 205 | - if ( empty( $atts[ $f ] ) ) { |
|
| 205 | + if ( empty( $atts[$f] ) ) { |
|
| 206 | 206 | continue; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // to_email, cc, and bcc can be an array |
| 210 | - if ( is_array( $atts[ $f ] ) ) { |
|
| 211 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
| 210 | + if ( is_array( $atts[$f] ) ) { |
|
| 211 | + foreach ( $atts[$f] as $key => $val ) { |
|
| 212 | 212 | self::format_single_field( $atts, $f, $val, $key ); |
| 213 | 213 | unset( $key, $val ); |
| 214 | 214 | } |
| 215 | - unset($f); |
|
| 215 | + unset( $f ); |
|
| 216 | 216 | continue; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
| 219 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // If reply-to isn't set, make it match the from settings |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
| 227 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
| 228 | 228 | $atts['to_email'] = $admin_email; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -247,20 +247,20 @@ discard block |
||
| 247 | 247 | * @param int $key if in array, this will be set |
| 248 | 248 | */ |
| 249 | 249 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
| 250 | - $val = trim($val); |
|
| 250 | + $val = trim( $val ); |
|
| 251 | 251 | |
| 252 | 252 | // If just a plain email is used |
| 253 | - if ( is_email($val) ) { |
|
| 253 | + if ( is_email( $val ) ) { |
|
| 254 | 254 | // add sender's name if not included in $from |
| 255 | 255 | if ( $f == 'from' ) { |
| 256 | - $part_2 = $atts[ $f ]; |
|
| 257 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 256 | + $part_2 = $atts[$f]; |
|
| 257 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 258 | 258 | } else { |
| 259 | 259 | return; |
| 260 | 260 | } |
| 261 | 261 | } else { |
| 262 | - $parts = explode(' ', $val); |
|
| 263 | - $part_2 = end($parts); |
|
| 262 | + $parts = explode( ' ', $val ); |
|
| 263 | + $part_2 = end( $parts ); |
|
| 264 | 264 | |
| 265 | 265 | // If inputted correcly, $part_2 should be an email |
| 266 | 266 | if ( is_email( $part_2 ) ) { |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
| 269 | 269 | // In case someone just puts a name in the From or Reply To field |
| 270 | 270 | $part_1 = $val; |
| 271 | - $part_2 = get_option('admin_email'); |
|
| 271 | + $part_2 = get_option( 'admin_email' ); |
|
| 272 | 272 | } else { |
| 273 | 273 | // In case someone just puts a name in any other email field |
| 274 | 274 | if ( false !== $key ) { |
| 275 | - unset( $atts[ $f ][ $key ] ); |
|
| 275 | + unset( $atts[$f][$key] ); |
|
| 276 | 276 | return; |
| 277 | 277 | } |
| 278 | - $atts[ $f ] = ''; |
|
| 278 | + $atts[$f] = ''; |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -296,14 +296,14 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | // If value is an array |
| 298 | 298 | if ( false !== $key ) { |
| 299 | - $atts[ $f ][ $key ] = $final_val; |
|
| 299 | + $atts[$f][$key] = $final_val; |
|
| 300 | 300 | return; |
| 301 | 301 | } |
| 302 | - $atts[ $f ] = $final_val; |
|
| 302 | + $atts[$f] = $final_val; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | public static function send_email( $atts ) { |
| 306 | - $admin_email = get_option('admin_email'); |
|
| 306 | + $admin_email = get_option( 'admin_email' ); |
|
| 307 | 307 | $defaults = array( |
| 308 | 308 | 'to_email' => $admin_email, |
| 309 | 309 | 'subject' => '', |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | 'attachments' => array(), |
| 318 | 318 | 'single_recipient' => false, |
| 319 | 319 | ); |
| 320 | - $atts = wp_parse_args($atts, $defaults); |
|
| 320 | + $atts = wp_parse_args( $atts, $defaults ); |
|
| 321 | 321 | |
| 322 | 322 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
| 323 | 323 | self::format_email_fields( $atts, $admin_email ); |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
| 330 | 330 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
| 331 | 331 | foreach ( $array_fields as $key => $a_field ) { |
| 332 | - if ( empty($a_field) ) { |
|
| 332 | + if ( empty( $a_field ) ) { |
|
| 333 | 333 | continue; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | foreach ( (array) $a_field as $email ) { |
| 337 | - $cc[ $key ][] = $email; |
|
| 337 | + $cc[$key][] = $email; |
|
| 338 | 338 | } |
| 339 | - unset($key, $a_field); |
|
| 339 | + unset( $key, $a_field ); |
|
| 340 | 340 | } |
| 341 | 341 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
| 342 | 342 | |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | $header[] = $k . ': ' . implode( ',', $v ); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 348 | - $atts['charset'] = get_option('blog_charset'); |
|
| 347 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
| 348 | + $atts['charset'] = get_option( 'blog_charset' ); |
|
| 349 | 349 | |
| 350 | 350 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
| 351 | 351 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $atts['charset'] ) . '"'; |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | private static function encode_subject( $charset, &$subject ) { |
| 416 | - if ( apply_filters('frm_encode_subject', 1, $subject ) ) { |
|
| 416 | + if ( apply_filters( 'frm_encode_subject', 1, $subject ) ) { |
|
| 417 | 417 | $subject = '=?' . $charset . '?B?' . base64_encode( $subject ) . '?='; |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | |
| 430 | 430 | if ( apply_filters( 'frm_echo_emails', false ) ) { |
| 431 | 431 | $temp = str_replace( '<', '<', $sent_to ); |
| 432 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
| 432 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
| 433 | 433 | } |
| 434 | 434 | return $sent_to; |
| 435 | 435 | } |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmDb { |
| 4 | - var $fields; |
|
| 5 | - var $forms; |
|
| 6 | - var $entries; |
|
| 7 | - var $entry_metas; |
|
| 8 | - |
|
| 9 | - public function __construct() { |
|
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | - $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | - $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | - $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function upgrade( $old_db_version = false ) { |
|
| 22 | - do_action( 'frm_before_install' ); |
|
| 23 | - |
|
| 24 | - global $wpdb; |
|
| 25 | - //$frm_db_version is the version of the database we're moving to |
|
| 26 | - $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | - $old_db_version = (float) $old_db_version; |
|
| 28 | - if ( ! $old_db_version ) { |
|
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( $frm_db_version != $old_db_version ) { |
|
| 4 | + var $fields; |
|
| 5 | + var $forms; |
|
| 6 | + var $entries; |
|
| 7 | + var $entry_metas; |
|
| 8 | + |
|
| 9 | + public function __construct() { |
|
| 10 | + if ( ! defined('ABSPATH') ) { |
|
| 11 | + die('You are not allowed to call this page directly.'); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | + $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | + $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | + $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function upgrade( $old_db_version = false ) { |
|
| 22 | + do_action( 'frm_before_install' ); |
|
| 23 | + |
|
| 24 | + global $wpdb; |
|
| 25 | + //$frm_db_version is the version of the database we're moving to |
|
| 26 | + $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | + $old_db_version = (float) $old_db_version; |
|
| 28 | + if ( ! $old_db_version ) { |
|
| 29 | + $old_db_version = get_option('frm_db_version'); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( $frm_db_version != $old_db_version ) { |
|
| 33 | 33 | // update rewrite rules for views and other custom post types |
| 34 | 34 | flush_rewrite_rules(); |
| 35 | 35 | |
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | - $this->create_tables(); |
|
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 38 | + $this->create_tables(); |
|
| 39 | + $this->migrate_data($frm_db_version, $old_db_version); |
|
| 40 | 40 | |
| 41 | - /***** SAVE DB VERSION *****/ |
|
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 41 | + /***** SAVE DB VERSION *****/ |
|
| 42 | + update_option('frm_db_version', $frm_db_version); |
|
| 43 | 43 | |
| 44 | - /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | - FrmXMLController::add_default_templates(); |
|
| 46 | - } |
|
| 44 | + /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | + FrmXMLController::add_default_templates(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - do_action('frm_after_install'); |
|
| 48 | + do_action('frm_after_install'); |
|
| 49 | 49 | |
| 50 | - /**** update the styling settings ****/ |
|
| 50 | + /**** update the styling settings ****/ |
|
| 51 | 51 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
| 52 | 52 | $frm_style = new FrmStyle(); |
| 53 | 53 | $frm_style->update( 'default' ); |
| 54 | 54 | } |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function collation() { |
|
| 58 | - global $wpdb; |
|
| 59 | - if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 57 | + public function collation() { |
|
| 58 | + global $wpdb; |
|
| 59 | + if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $charset_collate = ''; |
|
| 63 | + $charset_collate = ''; |
|
| 64 | 64 | if ( ! empty( $wpdb->charset ) ) { |
| 65 | 65 | $charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset; |
| 66 | 66 | } |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | $charset_collate .= ' COLLATE ' . $wpdb->collate; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return $charset_collate; |
|
| 73 | - } |
|
| 72 | + return $charset_collate; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - private function create_tables() { |
|
| 76 | - $charset_collate = $this->collation(); |
|
| 77 | - $sql = array(); |
|
| 75 | + private function create_tables() { |
|
| 76 | + $charset_collate = $this->collation(); |
|
| 77 | + $sql = array(); |
|
| 78 | 78 | |
| 79 | - /* Create/Upgrade Fields Table */ |
|
| 79 | + /* Create/Upgrade Fields Table */ |
|
| 80 | 80 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 81 | 81 | id int(11) NOT NULL auto_increment, |
| 82 | 82 | field_key varchar(100) default NULL, |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | UNIQUE KEY field_key (field_key) |
| 96 | 96 | )'; |
| 97 | 97 | |
| 98 | - /* Create/Upgrade Forms Table */ |
|
| 98 | + /* Create/Upgrade Forms Table */ |
|
| 99 | 99 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 100 | 100 | id int(11) NOT NULL auto_increment, |
| 101 | 101 | form_key varchar(100) default NULL, |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | UNIQUE KEY form_key (form_key) |
| 114 | 114 | )'; |
| 115 | 115 | |
| 116 | - /* Create/Upgrade Items Table */ |
|
| 116 | + /* Create/Upgrade Items Table */ |
|
| 117 | 117 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 118 | 118 | id int(11) NOT NULL auto_increment, |
| 119 | 119 | item_key varchar(100) default NULL, |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | UNIQUE KEY item_key (item_key) |
| 137 | 137 | )'; |
| 138 | 138 | |
| 139 | - /* Create/Upgrade Meta Table */ |
|
| 139 | + /* Create/Upgrade Meta Table */ |
|
| 140 | 140 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 141 | 141 | id int(11) NOT NULL auto_increment, |
| 142 | 142 | meta_value longtext default NULL, |
@@ -148,43 +148,43 @@ discard block |
||
| 148 | 148 | KEY item_id (item_id) |
| 149 | 149 | )'; |
| 150 | 150 | |
| 151 | - foreach ( $sql as $q ) { |
|
| 151 | + foreach ( $sql as $q ) { |
|
| 152 | 152 | if ( function_exists( 'dbDelta' ) ) { |
| 153 | 153 | dbDelta( $q . $charset_collate . ';' ); |
| 154 | 154 | } else { |
| 155 | 155 | global $wpdb; |
| 156 | 156 | $wpdb->query( $q . $charset_collate ); |
| 157 | 157 | } |
| 158 | - unset($q); |
|
| 159 | - } |
|
| 160 | - } |
|
| 158 | + unset($q); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * @param integer $frm_db_version |
|
| 162 | + /** |
|
| 163 | + * @param integer $frm_db_version |
|
| 164 | 164 | * @param int $old_db_version |
| 165 | - */ |
|
| 165 | + */ |
|
| 166 | 166 | private function migrate_data( $frm_db_version, $old_db_version ) { |
| 167 | 167 | $migrations = array( 4, 6, 11, 16, 17, 23, 25 ); |
| 168 | - foreach ( $migrations as $migration ) { |
|
| 169 | - if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 168 | + foreach ( $migrations as $migration ) { |
|
| 169 | + if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 170 | 170 | $function_name = 'migrate_to_' . $migration; |
| 171 | - $this->$function_name(); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 171 | + $this->$function_name(); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Change array into format $wpdb->prepare can use |
|
| 176 | + /** |
|
| 177 | + * Change array into format $wpdb->prepare can use |
|
| 178 | 178 | * |
| 179 | 179 | * @param array $args |
| 180 | 180 | * @param string $starts_with |
| 181 | - */ |
|
| 182 | - public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 183 | - if ( empty($args) ) { |
|
| 181 | + */ |
|
| 182 | + public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 183 | + if ( empty($args) ) { |
|
| 184 | 184 | // add an arg to prevent prepare from failing |
| 185 | 185 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 186 | 186 | return; |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | $where = ''; |
| 190 | 190 | $values = array(); |
@@ -195,64 +195,64 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $args = compact( 'where', 'values' ); |
| 198 | - } |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - /** |
|
| 200 | + /** |
|
| 201 | 201 | * @param array $args |
| 202 | - * @param string $base_where |
|
| 203 | - * @param string $where |
|
| 202 | + * @param string $base_where |
|
| 203 | + * @param string $where |
|
| 204 | 204 | * @param array $values |
| 205 | - */ |
|
| 206 | - public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 207 | - $condition = ' AND'; |
|
| 208 | - if ( isset( $args['or'] ) ) { |
|
| 209 | - $condition = ' OR'; |
|
| 210 | - unset( $args['or'] ); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - foreach ( $args as $key => $value ) { |
|
| 214 | - $where .= empty( $where ) ? $base_where : $condition; |
|
| 215 | - $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 216 | - if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 217 | - $where .= ' ( '; |
|
| 218 | - $nested_where = ''; |
|
| 219 | - if ( $array_inc_null ) { |
|
| 220 | - foreach ( $value as $val ) { |
|
| 221 | - self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 222 | - } |
|
| 223 | - } else { |
|
| 224 | - self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 225 | - } |
|
| 226 | - $where .= $nested_where; |
|
| 227 | - $where .= ' ) '; |
|
| 228 | - } else { |
|
| 229 | - self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * @param string $key |
|
| 205 | + */ |
|
| 206 | + public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 207 | + $condition = ' AND'; |
|
| 208 | + if ( isset( $args['or'] ) ) { |
|
| 209 | + $condition = ' OR'; |
|
| 210 | + unset( $args['or'] ); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + foreach ( $args as $key => $value ) { |
|
| 214 | + $where .= empty( $where ) ? $base_where : $condition; |
|
| 215 | + $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 216 | + if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 217 | + $where .= ' ( '; |
|
| 218 | + $nested_where = ''; |
|
| 219 | + if ( $array_inc_null ) { |
|
| 220 | + foreach ( $value as $val ) { |
|
| 221 | + self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 222 | + } |
|
| 223 | + } else { |
|
| 224 | + self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 225 | + } |
|
| 226 | + $where .= $nested_where; |
|
| 227 | + $where .= ' ) '; |
|
| 228 | + } else { |
|
| 229 | + self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * @param string $key |
|
| 236 | 236 | * @param string|array $value |
| 237 | - * @param string $where |
|
| 237 | + * @param string $where |
|
| 238 | 238 | * @param array $values |
| 239 | - */ |
|
| 240 | - private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 239 | + */ |
|
| 240 | + private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 241 | 241 | $key = trim( $key ); |
| 242 | 242 | |
| 243 | 243 | if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
| 244 | - $k = explode(' ', $key); |
|
| 245 | - $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 246 | - $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 247 | - } else { |
|
| 244 | + $k = explode(' ', $key); |
|
| 245 | + $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 246 | + $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 247 | + } else { |
|
| 248 | 248 | $where .= ' ' . $key; |
| 249 | - } |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | 251 | $lowercase_key = explode( ' ', strtolower( $key ) ); |
| 252 | 252 | $lowercase_key = end( $lowercase_key ); |
| 253 | 253 | |
| 254 | - if ( is_array( $value ) ) { |
|
| 255 | - // translate array of values to "in" |
|
| 254 | + if ( is_array( $value ) ) { |
|
| 255 | + // translate array of values to "in" |
|
| 256 | 256 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 257 | 257 | $where = preg_replace('/' . $key . '$/', '', $where); |
| 258 | 258 | $where .= '('; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')'; |
| 271 | 271 | $values = array_merge( $values, $value ); |
| 272 | 272 | } |
| 273 | - } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 273 | + } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 274 | 274 | /** |
| 275 | 275 | * Allow string to start or end with the value |
| 276 | 276 | * If the key is like% then skip the first % for starts with |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | $where .= ' %s'; |
| 291 | 291 | $values[] = $start . FrmAppHelper::esc_like( $value ) . $end; |
| 292 | 292 | |
| 293 | - } else if ( $value === null ) { |
|
| 294 | - $where .= ' IS NULL'; |
|
| 295 | - } else { |
|
| 293 | + } else if ( $value === null ) { |
|
| 294 | + $where .= ' IS NULL'; |
|
| 295 | + } else { |
|
| 296 | 296 | // allow a - to prevent = from being added |
| 297 | 297 | if ( substr( $key, -1 ) == '-' ) { |
| 298 | 298 | $where = rtrim( $where, '-' ); |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | self::add_query_placeholder( $key, $value, $where ); |
| 304 | 304 | |
| 305 | - $values[] = $value; |
|
| 306 | - } |
|
| 307 | - } |
|
| 305 | + $values[] = $value; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Add %d, or %s to query |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @param int|string $value |
| 315 | 315 | * @param string $where |
| 316 | 316 | */ |
| 317 | - private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 317 | + private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 318 | 318 | if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) { |
| 319 | 319 | $where .= '%d'; |
| 320 | 320 | } else { |
@@ -322,16 +322,16 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * @param string $table |
|
| 325 | + /** |
|
| 326 | + * @param string $table |
|
| 327 | 327 | * @param array $where |
| 328 | 328 | * @param array $args |
| 329 | 329 | * @return int |
| 330 | - */ |
|
| 331 | - public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 332 | - $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 333 | - return $count; |
|
| 334 | - } |
|
| 330 | + */ |
|
| 331 | + public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 332 | + $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 333 | + return $count; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * @param string $table |
@@ -342,56 +342,56 @@ discard block |
||
| 342 | 342 | * @param string $type |
| 343 | 343 | * @return array|null|string|object |
| 344 | 344 | */ |
| 345 | - public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 346 | - $group = ''; |
|
| 347 | - self::get_group_and_table_name( $table, $group ); |
|
| 345 | + public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 346 | + $group = ''; |
|
| 347 | + self::get_group_and_table_name( $table, $group ); |
|
| 348 | 348 | self::convert_options_to_array( $args, '', $limit ); |
| 349 | 349 | |
| 350 | 350 | $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); |
| 351 | 351 | |
| 352 | 352 | $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . implode( '_', $args ) . $field . '_' . $type, ' WHERE' ) ); |
| 353 | 353 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type ); |
| 354 | - return $results; |
|
| 355 | - } |
|
| 354 | + return $results; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * @param string $table |
|
| 359 | - * @param array $where |
|
| 357 | + /** |
|
| 358 | + * @param string $table |
|
| 359 | + * @param array $where |
|
| 360 | 360 | * @param string $field |
| 361 | 361 | * @param array $args |
| 362 | 362 | * @param string $limit |
| 363 | 363 | * @return mixed |
| 364 | - */ |
|
| 365 | - public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 366 | - return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * @since 2.0 |
|
| 371 | - * @param string $table |
|
| 364 | + */ |
|
| 365 | + public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 366 | + return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * @since 2.0 |
|
| 371 | + * @param string $table |
|
| 372 | 372 | * @param array $where |
| 373 | 373 | * @param string $fields |
| 374 | 374 | * @param array $args |
| 375 | 375 | * @return mixed |
| 376 | - */ |
|
| 377 | - public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 378 | - $args['limit'] = 1; |
|
| 379 | - return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Prepare a key/value array before DB call |
|
| 376 | + */ |
|
| 377 | + public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 378 | + $args['limit'] = 1; |
|
| 379 | + return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Prepare a key/value array before DB call |
|
| 384 | 384 | * |
| 385 | - * @since 2.0 |
|
| 386 | - * @param string $table |
|
| 385 | + * @since 2.0 |
|
| 386 | + * @param string $table |
|
| 387 | 387 | * @param array $where |
| 388 | 388 | * @param string $fields |
| 389 | 389 | * @param array $args |
| 390 | 390 | * @return mixed |
| 391 | - */ |
|
| 392 | - public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 393 | - return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 394 | - } |
|
| 391 | + */ |
|
| 392 | + public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 393 | + return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | 397 | * Check for like, not like, in, not in, =, !=, >, <, <=, >= |
@@ -428,59 +428,59 @@ discard block |
||
| 428 | 428 | return ''; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - /** |
|
| 432 | - * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 433 | - * Also add the wpdb->prefix to the table if it's missing |
|
| 434 | - * |
|
| 435 | - * @param string $table |
|
| 436 | - * @param string $group |
|
| 437 | - */ |
|
| 438 | - private static function get_group_and_table_name( &$table, &$group ) { |
|
| 431 | + /** |
|
| 432 | + * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 433 | + * Also add the wpdb->prefix to the table if it's missing |
|
| 434 | + * |
|
| 435 | + * @param string $table |
|
| 436 | + * @param string $group |
|
| 437 | + */ |
|
| 438 | + private static function get_group_and_table_name( &$table, &$group ) { |
|
| 439 | 439 | global $wpdb, $wpmuBaseTablePrefix; |
| 440 | 440 | |
| 441 | - $table_parts = explode(' ', $table); |
|
| 442 | - $group = reset($table_parts); |
|
| 443 | - $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 441 | + $table_parts = explode(' ', $table); |
|
| 442 | + $group = reset($table_parts); |
|
| 443 | + $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 444 | 444 | |
| 445 | 445 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
| 446 | 446 | $group = str_replace( $prefix, '', $group ); |
| 447 | 447 | |
| 448 | - if ( $group == $table ) { |
|
| 449 | - $table = $wpdb->prefix . $table; |
|
| 450 | - } |
|
| 448 | + if ( $group == $table ) { |
|
| 449 | + $table = $wpdb->prefix . $table; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | 452 | // switch to singular group name |
| 453 | 453 | $group = rtrim( $group, 's' ); |
| 454 | - } |
|
| 454 | + } |
|
| 455 | 455 | |
| 456 | - private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 457 | - if ( ! is_array($args) ) { |
|
| 456 | + private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 457 | + if ( ! is_array($args) ) { |
|
| 458 | 458 | $args = array( 'order_by' => $args ); |
| 459 | - } |
|
| 459 | + } |
|
| 460 | 460 | |
| 461 | - if ( ! empty( $order_by ) ) { |
|
| 462 | - $args['order_by'] = $order_by; |
|
| 463 | - } |
|
| 461 | + if ( ! empty( $order_by ) ) { |
|
| 462 | + $args['order_by'] = $order_by; |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - if ( ! empty( $limit ) ) { |
|
| 466 | - $args['limit'] = $limit; |
|
| 467 | - } |
|
| 465 | + if ( ! empty( $limit ) ) { |
|
| 466 | + $args['limit'] = $limit; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $temp_args = $args; |
|
| 470 | - foreach ( $temp_args as $k => $v ) { |
|
| 471 | - if ( $v == '' ) { |
|
| 469 | + $temp_args = $args; |
|
| 470 | + foreach ( $temp_args as $k => $v ) { |
|
| 471 | + if ( $v == '' ) { |
|
| 472 | 472 | unset( $args[ $k ] ); |
| 473 | - continue; |
|
| 474 | - } |
|
| 473 | + continue; |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - if ( $k == 'limit' ) { |
|
| 476 | + if ( $k == 'limit' ) { |
|
| 477 | 477 | $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
| 478 | - } |
|
| 479 | - $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 480 | - if ( strpos( $v, $db_name ) === false ) { |
|
| 478 | + } |
|
| 479 | + $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 480 | + if ( strpos( $v, $db_name ) === false ) { |
|
| 481 | 481 | $args[ $k ] = $db_name . ' ' . $v; |
| 482 | - } |
|
| 483 | - } |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | 485 | // Make sure LIMIT is the last argument |
| 486 | 486 | if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) { |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | unset( $args['limit'] ); |
| 489 | 489 | $args['limit'] = $temp_limit; |
| 490 | 490 | } |
| 491 | - } |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | 493 | /** |
| 494 | 494 | * Get the associative array results for the given columns, table, and where query |
@@ -541,31 +541,31 @@ discard block |
||
| 541 | 541 | return $query; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - public function uninstall() { |
|
| 544 | + public function uninstall() { |
|
| 545 | 545 | if ( ! current_user_can( 'administrator' ) ) { |
| 546 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 547 | - wp_die($frm_settings->admin_permission); |
|
| 548 | - } |
|
| 546 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 547 | + wp_die($frm_settings->admin_permission); |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - global $wpdb, $wp_roles; |
|
| 550 | + global $wpdb, $wp_roles; |
|
| 551 | 551 | |
| 552 | 552 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
| 553 | 553 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
| 554 | 554 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 555 | 555 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 556 | 556 | |
| 557 | - delete_option('frm_options'); |
|
| 558 | - delete_option('frm_db_version'); |
|
| 557 | + delete_option('frm_options'); |
|
| 558 | + delete_option('frm_db_version'); |
|
| 559 | 559 | |
| 560 | - //delete roles |
|
| 561 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 562 | - $roles = get_editable_roles(); |
|
| 563 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 564 | - foreach ( $roles as $role => $details ) { |
|
| 565 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 566 | - unset($role, $details); |
|
| 567 | - } |
|
| 568 | - unset($frm_role, $frm_role_description); |
|
| 560 | + //delete roles |
|
| 561 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 562 | + $roles = get_editable_roles(); |
|
| 563 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 564 | + foreach ( $roles as $role => $details ) { |
|
| 565 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 566 | + unset($role, $details); |
|
| 567 | + } |
|
| 568 | + unset($frm_role, $frm_role_description); |
|
| 569 | 569 | } |
| 570 | 570 | unset($roles, $frm_roles); |
| 571 | 571 | |
@@ -589,9 +589,9 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 591 | 591 | |
| 592 | - do_action('frm_after_uninstall'); |
|
| 593 | - return true; |
|
| 594 | - } |
|
| 592 | + do_action('frm_after_uninstall'); |
|
| 593 | + return true; |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | 596 | /** |
| 597 | 597 | * Migrate old styling settings. If sites are using the old |
@@ -630,150 +630,150 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - /** |
|
| 634 | - * Change field size from character to pixel -- Multiply by 9 |
|
| 635 | - */ |
|
| 636 | - private function migrate_to_17() { |
|
| 637 | - global $wpdb; |
|
| 633 | + /** |
|
| 634 | + * Change field size from character to pixel -- Multiply by 9 |
|
| 635 | + */ |
|
| 636 | + private function migrate_to_17() { |
|
| 637 | + global $wpdb; |
|
| 638 | 638 | $pixel_conversion = 9; |
| 639 | 639 | |
| 640 | - // Get query arguments |
|
| 640 | + // Get query arguments |
|
| 641 | 641 | $field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' ); |
| 642 | 642 | $query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' ); |
| 643 | 643 | |
| 644 | - // Get results |
|
| 644 | + // Get results |
|
| 645 | 645 | $fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' ); |
| 646 | 646 | |
| 647 | - $updated = 0; |
|
| 648 | - foreach ( $fields as $f ) { |
|
| 649 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 650 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 651 | - continue; |
|
| 652 | - } |
|
| 647 | + $updated = 0; |
|
| 648 | + foreach ( $fields as $f ) { |
|
| 649 | + $f->field_options = maybe_unserialize($f->field_options); |
|
| 650 | + if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 651 | + continue; |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | 654 | $f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] ); |
| 655 | - $f->field_options['size'] .= 'px'; |
|
| 656 | - $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 657 | - if ( $u ) { |
|
| 658 | - $updated++; |
|
| 659 | - } |
|
| 660 | - unset($f); |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - // Change the characters in widgets to pixels |
|
| 664 | - $widgets = get_option('widget_frm_show_form'); |
|
| 665 | - if ( empty($widgets) ) { |
|
| 666 | - return; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - $widgets = maybe_unserialize($widgets); |
|
| 670 | - foreach ( $widgets as $k => $widget ) { |
|
| 671 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 672 | - continue; |
|
| 673 | - } |
|
| 655 | + $f->field_options['size'] .= 'px'; |
|
| 656 | + $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 657 | + if ( $u ) { |
|
| 658 | + $updated++; |
|
| 659 | + } |
|
| 660 | + unset($f); |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + // Change the characters in widgets to pixels |
|
| 664 | + $widgets = get_option('widget_frm_show_form'); |
|
| 665 | + if ( empty($widgets) ) { |
|
| 666 | + return; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + $widgets = maybe_unserialize($widgets); |
|
| 670 | + foreach ( $widgets as $k => $widget ) { |
|
| 671 | + if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 672 | + continue; |
|
| 673 | + } |
|
| 674 | 674 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 675 | - $size .= 'px'; |
|
| 675 | + $size .= 'px'; |
|
| 676 | 676 | $widgets[ $k ]['size'] = $size; |
| 677 | - } |
|
| 678 | - update_option('widget_frm_show_form', $widgets); |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - /** |
|
| 682 | - * Migrate post and email notification settings into actions |
|
| 683 | - */ |
|
| 684 | - private function migrate_to_16() { |
|
| 685 | - global $wpdb; |
|
| 686 | - |
|
| 687 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 688 | - |
|
| 689 | - /** |
|
| 690 | - * Old email settings format: |
|
| 691 | - * email_to: Email or field id |
|
| 692 | - * also_email_to: array of fields ids |
|
| 693 | - * reply_to: Email, field id, 'custom' |
|
| 694 | - * cust_reply_to: string |
|
| 695 | - * reply_to_name: field id, 'custom' |
|
| 696 | - * cust_reply_to_name: string |
|
| 697 | - * plain_text: 0|1 |
|
| 698 | - * email_message: string or '' |
|
| 699 | - * email_subject: string or '' |
|
| 700 | - * inc_user_info: 0|1 |
|
| 701 | - * update_email: 0, 1, 2 |
|
| 702 | - * |
|
| 703 | - * Old autoresponder settings format: |
|
| 704 | - * auto_responder: 0|1 |
|
| 705 | - * ar_email_message: string or '' |
|
| 706 | - * ar_email_to: field id |
|
| 707 | - * ar_plain_text: 0|1 |
|
| 708 | - * ar_reply_to_name: string |
|
| 709 | - * ar_reply_to: string |
|
| 710 | - * ar_email_subject: string |
|
| 711 | - * ar_update_email: 0, 1, 2 |
|
| 712 | - * |
|
| 713 | - * New email settings: |
|
| 714 | - * post_content: json settings |
|
| 715 | - * post_title: form id |
|
| 716 | - * post_excerpt: message |
|
| 717 | - * |
|
| 718 | - */ |
|
| 719 | - |
|
| 720 | - foreach ( $forms as $form ) { |
|
| 677 | + } |
|
| 678 | + update_option('widget_frm_show_form', $widgets); |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + /** |
|
| 682 | + * Migrate post and email notification settings into actions |
|
| 683 | + */ |
|
| 684 | + private function migrate_to_16() { |
|
| 685 | + global $wpdb; |
|
| 686 | + |
|
| 687 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 688 | + |
|
| 689 | + /** |
|
| 690 | + * Old email settings format: |
|
| 691 | + * email_to: Email or field id |
|
| 692 | + * also_email_to: array of fields ids |
|
| 693 | + * reply_to: Email, field id, 'custom' |
|
| 694 | + * cust_reply_to: string |
|
| 695 | + * reply_to_name: field id, 'custom' |
|
| 696 | + * cust_reply_to_name: string |
|
| 697 | + * plain_text: 0|1 |
|
| 698 | + * email_message: string or '' |
|
| 699 | + * email_subject: string or '' |
|
| 700 | + * inc_user_info: 0|1 |
|
| 701 | + * update_email: 0, 1, 2 |
|
| 702 | + * |
|
| 703 | + * Old autoresponder settings format: |
|
| 704 | + * auto_responder: 0|1 |
|
| 705 | + * ar_email_message: string or '' |
|
| 706 | + * ar_email_to: field id |
|
| 707 | + * ar_plain_text: 0|1 |
|
| 708 | + * ar_reply_to_name: string |
|
| 709 | + * ar_reply_to: string |
|
| 710 | + * ar_email_subject: string |
|
| 711 | + * ar_update_email: 0, 1, 2 |
|
| 712 | + * |
|
| 713 | + * New email settings: |
|
| 714 | + * post_content: json settings |
|
| 715 | + * post_title: form id |
|
| 716 | + * post_excerpt: message |
|
| 717 | + * |
|
| 718 | + */ |
|
| 719 | + |
|
| 720 | + foreach ( $forms as $form ) { |
|
| 721 | 721 | if ( $form->is_template && $form->default_template ) { |
| 722 | 722 | // don't migrate the default templates since the email will be added anyway |
| 723 | 723 | continue; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - // Format form options |
|
| 727 | - $form_options = maybe_unserialize($form->options); |
|
| 726 | + // Format form options |
|
| 727 | + $form_options = maybe_unserialize($form->options); |
|
| 728 | 728 | |
| 729 | - // Migrate settings to actions |
|
| 730 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 731 | - } |
|
| 732 | - } |
|
| 729 | + // Migrate settings to actions |
|
| 730 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 731 | + } |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - private function migrate_to_11() { |
|
| 735 | - global $wpdb; |
|
| 734 | + private function migrate_to_11() { |
|
| 735 | + global $wpdb; |
|
| 736 | 736 | |
| 737 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 737 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 738 | 738 | |
| 739 | - $sending = __( 'Sending', 'formidable' ); |
|
| 739 | + $sending = __( 'Sending', 'formidable' ); |
|
| 740 | 740 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 741 | - $old_default_html = <<<DEFAULT_HTML |
|
| 741 | + $old_default_html = <<<DEFAULT_HTML |
|
| 742 | 742 | <div class="frm_submit"> |
| 743 | 743 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 744 | 744 | <input type="submit" value="[button_label]" [button_action] /> |
| 745 | 745 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 746 | 746 | </div> |
| 747 | 747 | DEFAULT_HTML; |
| 748 | - unset($sending, $img); |
|
| 748 | + unset($sending, $img); |
|
| 749 | 749 | |
| 750 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 751 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 750 | + $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 751 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 752 | 752 | foreach ( $forms as $form ) { |
| 753 | - $form->options = maybe_unserialize($form->options); |
|
| 754 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 755 | - continue; |
|
| 756 | - } |
|
| 753 | + $form->options = maybe_unserialize($form->options); |
|
| 754 | + if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 755 | + continue; |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 759 | - $form->options['submit_html'] = $new_default_html; |
|
| 758 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 759 | + $form->options['submit_html'] = $new_default_html; |
|
| 760 | 760 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 761 | 761 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 762 | 762 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 763 | 763 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 764 | - } |
|
| 765 | - unset($form); |
|
| 766 | - } |
|
| 767 | - unset($forms); |
|
| 768 | - } |
|
| 764 | + } |
|
| 765 | + unset($form); |
|
| 766 | + } |
|
| 767 | + unset($forms); |
|
| 768 | + } |
|
| 769 | 769 | |
| 770 | - private function migrate_to_6() { |
|
| 771 | - global $wpdb; |
|
| 770 | + private function migrate_to_6() { |
|
| 771 | + global $wpdb; |
|
| 772 | 772 | |
| 773 | 773 | $no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) ); |
| 774 | 774 | $fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' ); |
| 775 | 775 | |
| 776 | - $default_html = <<<DEFAULT_HTML |
|
| 776 | + $default_html = <<<DEFAULT_HTML |
|
| 777 | 777 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 778 | 778 | <label class="frm_pos_[label_position]">[field_name] |
| 779 | 779 | <span class="frm_required">[required_label]</span> |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | </div> |
| 784 | 784 | DEFAULT_HTML; |
| 785 | 785 | |
| 786 | - $old_default_html = <<<DEFAULT_HTML |
|
| 786 | + $old_default_html = <<<DEFAULT_HTML |
|
| 787 | 787 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 788 | 788 | <label class="frm_pos_[label_position]">[field_name] |
| 789 | 789 | <span class="frm_required">[required_label]</span> |
@@ -793,25 +793,25 @@ discard block |
||
| 793 | 793 | </div> |
| 794 | 794 | DEFAULT_HTML; |
| 795 | 795 | |
| 796 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 797 | - foreach ( $fields as $field ) { |
|
| 798 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 796 | + $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 797 | + foreach ( $fields as $field ) { |
|
| 798 | + $field->field_options = maybe_unserialize($field->field_options); |
|
| 799 | 799 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 800 | - $field->field_options['custom_html'] = $new_default_html; |
|
| 800 | + $field->field_options['custom_html'] = $new_default_html; |
|
| 801 | 801 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 802 | - } |
|
| 803 | - unset($field); |
|
| 804 | - } |
|
| 805 | - unset($default_html, $old_default_html, $fields); |
|
| 806 | - } |
|
| 807 | - |
|
| 808 | - private function migrate_to_4() { |
|
| 809 | - global $wpdb; |
|
| 802 | + } |
|
| 803 | + unset($field); |
|
| 804 | + } |
|
| 805 | + unset($default_html, $old_default_html, $fields); |
|
| 806 | + } |
|
| 807 | + |
|
| 808 | + private function migrate_to_4() { |
|
| 809 | + global $wpdb; |
|
| 810 | 810 | $user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) ); |
| 811 | - foreach ( $user_ids as $user_id ) { |
|
| 811 | + foreach ( $user_ids as $user_id ) { |
|
| 812 | 812 | $wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) ); |
| 813 | - } |
|
| 814 | - } |
|
| 813 | + } |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | 816 | public static function get_one_record( $table, $args = array(), $fields = '*', $order_by = '' ) { |
| 817 | 817 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_row' ); |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | var $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $frm_db_version = FrmAppHelper::$db_version; |
| 27 | 27 | $old_db_version = (float) $old_db_version; |
| 28 | 28 | if ( ! $old_db_version ) { |
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 29 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( $frm_db_version != $old_db_version ) { |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | 38 | $this->create_tables(); |
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 39 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
| 40 | 40 | |
| 41 | 41 | /***** SAVE DB VERSION *****/ |
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 42 | + update_option( 'frm_db_version', $frm_db_version ); |
|
| 43 | 43 | |
| 44 | 44 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
| 45 | 45 | FrmXMLController::add_default_templates(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - do_action('frm_after_install'); |
|
| 48 | + do_action( 'frm_after_install' ); |
|
| 49 | 49 | |
| 50 | 50 | /**** update the styling settings ****/ |
| 51 | 51 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | global $wpdb; |
| 156 | 156 | $wpdb->query( $q . $charset_collate ); |
| 157 | 157 | } |
| 158 | - unset($q); |
|
| 158 | + unset( $q ); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $starts_with |
| 181 | 181 | */ |
| 182 | 182 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
| 183 | - if ( empty($args) ) { |
|
| 183 | + if ( empty( $args ) ) { |
|
| 184 | 184 | // add an arg to prevent prepare from failing |
| 185 | 185 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 186 | 186 | return; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $key = trim( $key ); |
| 242 | 242 | |
| 243 | 243 | if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
| 244 | - $k = explode(' ', $key); |
|
| 244 | + $k = explode( ' ', $key ); |
|
| 245 | 245 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
| 246 | 246 | $values[] = '%Y-%m-%d %H:%i:%s'; |
| 247 | 247 | } else { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | if ( is_array( $value ) ) { |
| 255 | 255 | // translate array of values to "in" |
| 256 | 256 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 257 | - $where = preg_replace('/' . $key . '$/', '', $where); |
|
| 257 | + $where = preg_replace( '/' . $key . '$/', '', $where ); |
|
| 258 | 258 | $where .= '('; |
| 259 | 259 | $start = true; |
| 260 | 260 | foreach ( $value as $v ) { |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | 417 | $where_is = strtolower( $where_is ); |
| 418 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
| 419 | - return ' ' . $switch_to[ $where_is ]; |
|
| 418 | + if ( isset( $switch_to[$where_is] ) ) { |
|
| 419 | + return ' ' . $switch_to[$where_is]; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | private static function get_group_and_table_name( &$table, &$group ) { |
| 439 | 439 | global $wpdb, $wpmuBaseTablePrefix; |
| 440 | 440 | |
| 441 | - $table_parts = explode(' ', $table); |
|
| 442 | - $group = reset($table_parts); |
|
| 441 | + $table_parts = explode( ' ', $table ); |
|
| 442 | + $group = reset( $table_parts ); |
|
| 443 | 443 | $group = str_replace( $wpdb->prefix, '', $group ); |
| 444 | 444 | |
| 445 | 445 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
| 457 | - if ( ! is_array($args) ) { |
|
| 457 | + if ( ! is_array( $args ) ) { |
|
| 458 | 458 | $args = array( 'order_by' => $args ); |
| 459 | 459 | } |
| 460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
| 469 | 469 | $temp_args = $args; |
| 470 | 470 | foreach ( $temp_args as $k => $v ) { |
| 471 | 471 | if ( $v == '' ) { |
| 472 | - unset( $args[ $k ] ); |
|
| 472 | + unset( $args[$k] ); |
|
| 473 | 473 | continue; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | if ( $k == 'limit' ) { |
| 477 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
| 477 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
| 478 | 478 | } |
| 479 | 479 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
| 480 | 480 | if ( strpos( $v, $db_name ) === false ) { |
| 481 | - $args[ $k ] = $db_name . ' ' . $v; |
|
| 481 | + $args[$k] = $db_name . ' ' . $v; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | $query = self::generate_query_string_from_pieces( $columns, $table, $where ); |
| 507 | 507 | |
| 508 | - $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) ); |
|
| 508 | + $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) ); |
|
| 509 | 509 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' ); |
| 510 | 510 | |
| 511 | 511 | return $results; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | public function uninstall() { |
| 545 | 545 | if ( ! current_user_can( 'administrator' ) ) { |
| 546 | 546 | $frm_settings = FrmAppHelper::get_settings(); |
| 547 | - wp_die($frm_settings->admin_permission); |
|
| 547 | + wp_die( $frm_settings->admin_permission ); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | global $wpdb, $wp_roles; |
@@ -554,8 +554,8 @@ discard block |
||
| 554 | 554 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 555 | 555 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 556 | 556 | |
| 557 | - delete_option('frm_options'); |
|
| 558 | - delete_option('frm_db_version'); |
|
| 557 | + delete_option( 'frm_options' ); |
|
| 558 | + delete_option( 'frm_db_version' ); |
|
| 559 | 559 | |
| 560 | 560 | //delete roles |
| 561 | 561 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -563,11 +563,11 @@ discard block |
||
| 563 | 563 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 564 | 564 | foreach ( $roles as $role => $details ) { |
| 565 | 565 | $wp_roles->remove_cap( $role, $frm_role ); |
| 566 | - unset($role, $details); |
|
| 566 | + unset( $role, $details ); |
|
| 567 | 567 | } |
| 568 | - unset($frm_role, $frm_role_description); |
|
| 568 | + unset( $frm_role, $frm_role_description ); |
|
| 569 | 569 | } |
| 570 | - unset($roles, $frm_roles); |
|
| 570 | + unset( $roles, $frm_roles ); |
|
| 571 | 571 | |
| 572 | 572 | // delete actions, views, and styles |
| 573 | 573 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 591 | 591 | |
| 592 | - do_action('frm_after_uninstall'); |
|
| 592 | + do_action( 'frm_after_uninstall' ); |
|
| 593 | 593 | return true; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | $updated = 0; |
| 648 | 648 | foreach ( $fields as $f ) { |
| 649 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 650 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 649 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 650 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 651 | 651 | continue; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -655,27 +655,27 @@ discard block |
||
| 655 | 655 | $f->field_options['size'] .= 'px'; |
| 656 | 656 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 657 | 657 | if ( $u ) { |
| 658 | - $updated++; |
|
| 658 | + $updated ++; |
|
| 659 | 659 | } |
| 660 | - unset($f); |
|
| 660 | + unset( $f ); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // Change the characters in widgets to pixels |
| 664 | - $widgets = get_option('widget_frm_show_form'); |
|
| 665 | - if ( empty($widgets) ) { |
|
| 664 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 665 | + if ( empty( $widgets ) ) { |
|
| 666 | 666 | return; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - $widgets = maybe_unserialize($widgets); |
|
| 669 | + $widgets = maybe_unserialize( $widgets ); |
|
| 670 | 670 | foreach ( $widgets as $k => $widget ) { |
| 671 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 671 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 672 | 672 | continue; |
| 673 | 673 | } |
| 674 | 674 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 675 | 675 | $size .= 'px'; |
| 676 | - $widgets[ $k ]['size'] = $size; |
|
| 676 | + $widgets[$k]['size'] = $size; |
|
| 677 | 677 | } |
| 678 | - update_option('widget_frm_show_form', $widgets); |
|
| 678 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | // Format form options |
| 727 | - $form_options = maybe_unserialize($form->options); |
|
| 727 | + $form_options = maybe_unserialize( $form->options ); |
|
| 728 | 728 | |
| 729 | 729 | // Migrate settings to actions |
| 730 | 730 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | private function migrate_to_11() { |
| 735 | 735 | global $wpdb; |
| 736 | 736 | |
| 737 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 737 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 738 | 738 | |
| 739 | 739 | $sending = __( 'Sending', 'formidable' ); |
| 740 | 740 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -745,13 +745,13 @@ discard block |
||
| 745 | 745 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 746 | 746 | </div> |
| 747 | 747 | DEFAULT_HTML; |
| 748 | - unset($sending, $img); |
|
| 748 | + unset( $sending, $img ); |
|
| 749 | 749 | |
| 750 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 750 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 751 | 751 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 752 | 752 | foreach ( $forms as $form ) { |
| 753 | - $form->options = maybe_unserialize($form->options); |
|
| 754 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 753 | + $form->options = maybe_unserialize( $form->options ); |
|
| 754 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 755 | 755 | continue; |
| 756 | 756 | } |
| 757 | 757 | |
@@ -762,9 +762,9 @@ discard block |
||
| 762 | 762 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 763 | 763 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 764 | 764 | } |
| 765 | - unset($form); |
|
| 765 | + unset( $form ); |
|
| 766 | 766 | } |
| 767 | - unset($forms); |
|
| 767 | + unset( $forms ); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | private function migrate_to_6() { |
@@ -793,16 +793,16 @@ discard block |
||
| 793 | 793 | </div> |
| 794 | 794 | DEFAULT_HTML; |
| 795 | 795 | |
| 796 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 796 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 797 | 797 | foreach ( $fields as $field ) { |
| 798 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 798 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 799 | 799 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 800 | 800 | $field->field_options['custom_html'] = $new_default_html; |
| 801 | 801 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 802 | 802 | } |
| 803 | - unset($field); |
|
| 803 | + unset( $field ); |
|
| 804 | 804 | } |
| 805 | - unset($default_html, $old_default_html, $fields); |
|
| 805 | + unset( $default_html, $old_default_html, $fields ); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | private function migrate_to_4() { |
@@ -820,6 +820,6 @@ discard block |
||
| 820 | 820 | |
| 821 | 821 | public static function get_records( $table, $args = array(), $order_by = '', $limit = '', $fields = '*' ) { |
| 822 | 822 | _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_results' ); |
| 823 | - return self::get_results( $table, $args, $fields, compact('order_by', 'limit') ); |
|
| 823 | + return self::get_results( $table, $args, $fields, compact( 'order_by', 'limit' ) ); |
|
| 824 | 824 | } |
| 825 | 825 | } |
@@ -1,52 +1,52 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStyle { |
| 3 | - public $number = false; // Unique ID number of the current instance. |
|
| 3 | + public $number = false; // Unique ID number of the current instance. |
|
| 4 | 4 | public $id = 0; // the id of the post |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
| 8 | 8 | */ |
| 9 | 9 | public function __construct( $id = 0 ) { |
| 10 | - $this->id = $id; |
|
| 11 | - } |
|
| 10 | + $this->id = $id; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function get_new() { |
|
| 13 | + public function get_new() { |
|
| 14 | 14 | $this->id = 0; |
| 15 | 15 | |
| 16 | - $max_slug_value = pow(36, 6); |
|
| 17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | - |
|
| 20 | - $style = array( |
|
| 21 | - 'post_type' => FrmStylesController::$post_type, |
|
| 22 | - 'ID' => '', |
|
| 23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | - 'post_name' => $key, |
|
| 25 | - 'post_content' => $this->get_defaults(), |
|
| 26 | - 'menu_order' => '', |
|
| 27 | - 'post_status' => 'publish', |
|
| 28 | - ); |
|
| 16 | + $max_slug_value = pow(36, 6); |
|
| 17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 19 | + |
|
| 20 | + $style = array( |
|
| 21 | + 'post_type' => FrmStylesController::$post_type, |
|
| 22 | + 'ID' => '', |
|
| 23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
| 24 | + 'post_name' => $key, |
|
| 25 | + 'post_content' => $this->get_defaults(), |
|
| 26 | + 'menu_order' => '', |
|
| 27 | + 'post_status' => 'publish', |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - return (object) $style; |
|
| 31 | - } |
|
| 30 | + return (object) $style; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | public function save( $settings ) { |
| 34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | public function duplicate( $id ) { |
| 38 | - // duplicating is a pro feature |
|
| 39 | - } |
|
| 38 | + // duplicating is a pro feature |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function update( $id = 'default' ) { |
|
| 41 | + public function update( $id = 'default' ) { |
|
| 42 | 42 | $all_instances = $this->get_all(); |
| 43 | 43 | |
| 44 | 44 | if ( empty($id) ) { |
| 45 | - $new_style = (array) $this->get_new(); |
|
| 46 | - $all_instances[] = $new_style; |
|
| 45 | + $new_style = (array) $this->get_new(); |
|
| 46 | + $all_instances[] = $new_style; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $action_ids = array(); |
|
| 49 | + $action_ids = array(); |
|
| 50 | 50 | |
| 51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
| 52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,42 +54,42 @@ discard block |
||
| 54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
| 55 | 55 | $all_instances[ $number ] = $new_instance; |
| 56 | 56 | |
| 57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | - // this style was set to default, so remove default setting on previous default style |
|
| 59 | - $new_instance['menu_order'] = 0; |
|
| 60 | - $action_ids[] = $this->save($new_instance); |
|
| 61 | - } |
|
| 57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
| 58 | + // this style was set to default, so remove default setting on previous default style |
|
| 59 | + $new_instance['menu_order'] = 0; |
|
| 60 | + $action_ids[] = $this->save($new_instance); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // don't continue if not saving this style |
|
| 64 | - continue; |
|
| 63 | + // don't continue if not saving this style |
|
| 64 | + continue; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
| 68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
| 69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
| 70 | - $new_instance['post_status'] = 'publish'; |
|
| 70 | + $new_instance['post_status'] = 'publish'; |
|
| 71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
| 72 | 72 | |
| 73 | - if ( empty($id) ) { |
|
| 74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | - } |
|
| 73 | + if ( empty($id) ) { |
|
| 74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $default_settings = $this->get_defaults(); |
|
| 77 | + $default_settings = $this->get_defaults(); |
|
| 78 | 78 | |
| 79 | - foreach ( $default_settings as $setting => $default ) { |
|
| 79 | + foreach ( $default_settings as $setting => $default ) { |
|
| 80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
| 81 | - //if is a color |
|
| 81 | + //if is a color |
|
| 82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
| 83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
| 84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
| 85 | - } else if ( $setting == 'font' ) { |
|
| 86 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | - } |
|
| 88 | - } |
|
| 85 | + } else if ( $setting == 'font' ) { |
|
| 86 | + $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | $all_instances[ $number ] = $new_instance; |
| 91 | 91 | |
| 92 | - $action_ids[] = $this->save($new_instance); |
|
| 92 | + $action_ids[] = $this->save($new_instance); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -98,16 +98,16 @@ discard block |
||
| 98 | 98 | return $action_ids; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Create static css file |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * Create static css file |
|
| 103 | + */ |
|
| 104 | 104 | public function save_settings() { |
| 105 | 105 | $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
| 106 | 106 | update_option( 'frm_last_style_update', date('njGi') ); |
| 107 | 107 | |
| 108 | - if ( ! is_file($filename) ) { |
|
| 109 | - return; |
|
| 110 | - } |
|
| 108 | + if ( ! is_file($filename) ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | 112 | $this->clear_cache(); |
| 113 | 113 | |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | $create_file = new FrmCreateFile( array( 'folder_name' => 'formidable/css', 'file_name' => 'formidablepro.css' ) ); |
| 117 | 117 | $create_file->create_file( $css ); |
| 118 | 118 | |
| 119 | - update_option('frmpro_css', $css); |
|
| 119 | + update_option('frmpro_css', $css); |
|
| 120 | 120 | |
| 121 | - set_transient('frmpro_css', $css); |
|
| 121 | + set_transient('frmpro_css', $css); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function get_css_content( $filename ) { |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | $saving = true; |
| 128 | 128 | $frm_style = $this; |
| 129 | 129 | |
| 130 | - ob_start(); |
|
| 131 | - include( $filename ); |
|
| 130 | + ob_start(); |
|
| 131 | + include( $filename ); |
|
| 132 | 132 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
| 133 | - ob_end_clean(); |
|
| 133 | + ob_end_clean(); |
|
| 134 | 134 | |
| 135 | 135 | return $css; |
| 136 | 136 | } |
@@ -150,273 +150,273 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function destroy( $id ) { |
| 153 | - return wp_delete_post($id); |
|
| 154 | - } |
|
| 153 | + return wp_delete_post($id); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function get_one() { |
|
| 157 | - if ( 'default' == $this->id ) { |
|
| 158 | - $style = $this->get_default_style(); |
|
| 159 | - if ( $style ) { |
|
| 160 | - $this->id = $style->ID; |
|
| 161 | - } else { |
|
| 162 | - $this->id = 0; |
|
| 163 | - } |
|
| 164 | - return $style; |
|
| 165 | - } |
|
| 156 | + public function get_one() { |
|
| 157 | + if ( 'default' == $this->id ) { |
|
| 158 | + $style = $this->get_default_style(); |
|
| 159 | + if ( $style ) { |
|
| 160 | + $this->id = $style->ID; |
|
| 161 | + } else { |
|
| 162 | + $this->id = 0; |
|
| 163 | + } |
|
| 164 | + return $style; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $style = get_post($this->id); |
|
| 167 | + $style = get_post($this->id); |
|
| 168 | 168 | |
| 169 | - if ( ! $style ) { |
|
| 170 | - return $style; |
|
| 171 | - } |
|
| 169 | + if ( ! $style ) { |
|
| 170 | + return $style; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 173 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 174 | 174 | |
| 175 | - $default_values = $this->get_defaults(); |
|
| 175 | + $default_values = $this->get_defaults(); |
|
| 176 | 176 | |
| 177 | - // fill default values |
|
| 178 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 177 | + // fill default values |
|
| 178 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 179 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 180 | 180 | |
| 181 | - return $style; |
|
| 182 | - } |
|
| 181 | + return $style; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | - $post_atts = array( |
|
| 184 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
| 185 | + $post_atts = array( |
|
| 186 | 186 | 'post_type' => FrmStylesController::$post_type, |
| 187 | 187 | 'post_status' => 'publish', |
| 188 | 188 | 'numberposts' => $limit, |
| 189 | 189 | 'orderby' => $orderby, |
| 190 | 190 | 'order' => $order, |
| 191 | - ); |
|
| 191 | + ); |
|
| 192 | 192 | |
| 193 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 193 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
| 194 | 194 | |
| 195 | - if ( empty($temp_styles) ) { |
|
| 196 | - global $wpdb; |
|
| 197 | - // make sure there wasn't a conflict with the query |
|
| 195 | + if ( empty($temp_styles) ) { |
|
| 196 | + global $wpdb; |
|
| 197 | + // make sure there wasn't a conflict with the query |
|
| 198 | 198 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
| 199 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 199 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
| 200 | 200 | |
| 201 | - if ( empty($temp_styles) ) { |
|
| 202 | - // create a new style if there are none |
|
| 203 | - $new = $this->get_new(); |
|
| 201 | + if ( empty($temp_styles) ) { |
|
| 202 | + // create a new style if there are none |
|
| 203 | + $new = $this->get_new(); |
|
| 204 | 204 | $new->post_title = __( 'Formidable Style', 'formidable' ); |
| 205 | 205 | $new->post_name = $new->post_title; |
| 206 | - $new->menu_order = 1; |
|
| 207 | - $new = $this->save( (array) $new); |
|
| 208 | - $this->update('default'); |
|
| 209 | - |
|
| 210 | - $post_atts['include'] = $new; |
|
| 211 | - |
|
| 212 | - $temp_styles = get_posts( $post_atts ); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $default_values = $this->get_defaults(); |
|
| 217 | - $default_style = false; |
|
| 218 | - |
|
| 219 | - $styles = array(); |
|
| 220 | - foreach ( $temp_styles as $style ) { |
|
| 221 | - $this->id = $style->ID; |
|
| 222 | - if ( $style->menu_order ) { |
|
| 223 | - if ( $default_style ) { |
|
| 224 | - // only return one default |
|
| 225 | - $style->menu_order = 0; |
|
| 226 | - } else { |
|
| 227 | - // check for a default style |
|
| 228 | - $default_style = $style->ID; |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 233 | - |
|
| 234 | - // fill default values |
|
| 235 | - $style->post_content = $this->override_defaults($style->post_content); |
|
| 236 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 206 | + $new->menu_order = 1; |
|
| 207 | + $new = $this->save( (array) $new); |
|
| 208 | + $this->update('default'); |
|
| 209 | + |
|
| 210 | + $post_atts['include'] = $new; |
|
| 211 | + |
|
| 212 | + $temp_styles = get_posts( $post_atts ); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $default_values = $this->get_defaults(); |
|
| 217 | + $default_style = false; |
|
| 218 | + |
|
| 219 | + $styles = array(); |
|
| 220 | + foreach ( $temp_styles as $style ) { |
|
| 221 | + $this->id = $style->ID; |
|
| 222 | + if ( $style->menu_order ) { |
|
| 223 | + if ( $default_style ) { |
|
| 224 | + // only return one default |
|
| 225 | + $style->menu_order = 0; |
|
| 226 | + } else { |
|
| 227 | + // check for a default style |
|
| 228 | + $default_style = $style->ID; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
| 233 | + |
|
| 234 | + // fill default values |
|
| 235 | + $style->post_content = $this->override_defaults($style->post_content); |
|
| 236 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
| 237 | 237 | |
| 238 | 238 | $styles[ $style->ID ] = $style; |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - if ( ! $default_style ) { |
|
| 242 | - $default_style = reset($styles); |
|
| 241 | + if ( ! $default_style ) { |
|
| 242 | + $default_style = reset($styles); |
|
| 243 | 243 | $styles[ $default_style->ID ]->menu_order = 1; |
| 244 | - } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return $styles; |
|
| 247 | - } |
|
| 246 | + return $styles; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | public function get_default_style( $styles = null ) { |
| 250 | - if ( ! isset($styles) ) { |
|
| 250 | + if ( ! isset($styles) ) { |
|
| 251 | 251 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - foreach ( $styles as $style ) { |
|
| 255 | - if ( $style->menu_order ) { |
|
| 256 | - return $style; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 254 | + foreach ( $styles as $style ) { |
|
| 255 | + if ( $style->menu_order ) { |
|
| 256 | + return $style; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | 261 | public function override_defaults( $settings ) { |
| 262 | - if ( ! is_array($settings) ) { |
|
| 263 | - return $settings; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 267 | - |
|
| 268 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 269 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 270 | - $settings['form_desc_color'] = $settings['description_color']; |
|
| 271 | - $settings['title_color'] = $settings['label_color']; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 275 | - $settings['section_color'] = $settings['label_color']; |
|
| 276 | - $settings['section_border_color'] = $settings['border_color']; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 280 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 281 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 282 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 283 | - |
|
| 284 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 285 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 286 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return $settings; |
|
| 262 | + if ( ! is_array($settings) ) { |
|
| 263 | + return $settings; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
| 267 | + |
|
| 268 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
| 269 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
| 270 | + $settings['form_desc_color'] = $settings['description_color']; |
|
| 271 | + $settings['title_color'] = $settings['label_color']; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
| 275 | + $settings['section_color'] = $settings['label_color']; |
|
| 276 | + $settings['section_border_color'] = $settings['border_color']; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
| 280 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
| 281 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
| 282 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
| 283 | + |
|
| 284 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
| 285 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
| 286 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return $settings; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | public function get_defaults() { |
| 293 | - return array( |
|
| 294 | - 'theme_css' => 'ui-lightness', |
|
| 295 | - 'theme_name' => 'UI Lightness', |
|
| 293 | + return array( |
|
| 294 | + 'theme_css' => 'ui-lightness', |
|
| 295 | + 'theme_name' => 'UI Lightness', |
|
| 296 | 296 | |
| 297 | 297 | 'center_form' => '', |
| 298 | - 'form_width' => '100%', |
|
| 299 | - 'form_align' => 'left', |
|
| 300 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 301 | - 'fieldset' => '0px', |
|
| 302 | - 'fieldset_color' => '000000', |
|
| 303 | - 'fieldset_padding' => '0 0 15px 0', |
|
| 304 | - 'fieldset_bg_color' => '', |
|
| 305 | - |
|
| 306 | - 'title_size' => '20px', |
|
| 307 | - 'title_color' => '444444', |
|
| 298 | + 'form_width' => '100%', |
|
| 299 | + 'form_align' => 'left', |
|
| 300 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
| 301 | + 'fieldset' => '0px', |
|
| 302 | + 'fieldset_color' => '000000', |
|
| 303 | + 'fieldset_padding' => '0 0 15px 0', |
|
| 304 | + 'fieldset_bg_color' => '', |
|
| 305 | + |
|
| 306 | + 'title_size' => '20px', |
|
| 307 | + 'title_color' => '444444', |
|
| 308 | 308 | 'title_margin_top' => '10px', |
| 309 | 309 | 'title_margin_bottom' => '10px', |
| 310 | - 'form_desc_size' => '14px', |
|
| 311 | - 'form_desc_color' => '666666', |
|
| 310 | + 'form_desc_size' => '14px', |
|
| 311 | + 'form_desc_color' => '666666', |
|
| 312 | 312 | 'form_desc_margin_top' => '10px', |
| 313 | 313 | 'form_desc_margin_bottom' => '25px', |
| 314 | 314 | |
| 315 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 316 | - 'font_size' => '14px', |
|
| 317 | - 'label_color' => '444444', |
|
| 318 | - 'weight' => 'bold', |
|
| 319 | - 'position' => 'none', |
|
| 320 | - 'align' => 'left', |
|
| 321 | - 'width' => '150px', |
|
| 322 | - 'required_color' => 'B94A48', |
|
| 323 | - 'required_weight' => 'bold', |
|
| 324 | - 'label_padding' => '0 0 3px 0', |
|
| 325 | - |
|
| 326 | - 'description_font_size' => '12px', |
|
| 327 | - 'description_color' => '666666', |
|
| 328 | - 'description_weight' => 'normal', |
|
| 329 | - 'description_style' => 'normal', |
|
| 330 | - 'description_align' => 'left', |
|
| 315 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
| 316 | + 'font_size' => '14px', |
|
| 317 | + 'label_color' => '444444', |
|
| 318 | + 'weight' => 'bold', |
|
| 319 | + 'position' => 'none', |
|
| 320 | + 'align' => 'left', |
|
| 321 | + 'width' => '150px', |
|
| 322 | + 'required_color' => 'B94A48', |
|
| 323 | + 'required_weight' => 'bold', |
|
| 324 | + 'label_padding' => '0 0 3px 0', |
|
| 325 | + |
|
| 326 | + 'description_font_size' => '12px', |
|
| 327 | + 'description_color' => '666666', |
|
| 328 | + 'description_weight' => 'normal', |
|
| 329 | + 'description_style' => 'normal', |
|
| 330 | + 'description_align' => 'left', |
|
| 331 | 331 | 'description_margin' => '0', |
| 332 | 332 | |
| 333 | - 'field_font_size' => '14px', |
|
| 334 | - 'field_height' => '32px', |
|
| 335 | - 'line_height' => 'normal', |
|
| 336 | - 'field_width' => '100%', |
|
| 337 | - 'auto_width' => false, |
|
| 338 | - 'field_pad' => '6px 10px', |
|
| 339 | - 'field_margin' => '20px', |
|
| 333 | + 'field_font_size' => '14px', |
|
| 334 | + 'field_height' => '32px', |
|
| 335 | + 'line_height' => 'normal', |
|
| 336 | + 'field_width' => '100%', |
|
| 337 | + 'auto_width' => false, |
|
| 338 | + 'field_pad' => '6px 10px', |
|
| 339 | + 'field_margin' => '20px', |
|
| 340 | 340 | 'field_weight' => 'normal', |
| 341 | - 'text_color' => '555555', |
|
| 342 | - //'border_color_hv' => 'cccccc', |
|
| 343 | - 'border_color' => 'cccccc', |
|
| 344 | - 'field_border_width' => '1px', |
|
| 345 | - 'field_border_style' => 'solid', |
|
| 346 | - |
|
| 347 | - 'bg_color' => 'ffffff', |
|
| 348 | - //'bg_color_hv' => 'ffffff', |
|
| 341 | + 'text_color' => '555555', |
|
| 342 | + //'border_color_hv' => 'cccccc', |
|
| 343 | + 'border_color' => 'cccccc', |
|
| 344 | + 'field_border_width' => '1px', |
|
| 345 | + 'field_border_style' => 'solid', |
|
| 346 | + |
|
| 347 | + 'bg_color' => 'ffffff', |
|
| 348 | + //'bg_color_hv' => 'ffffff', |
|
| 349 | 349 | 'remove_box_shadow' => '', |
| 350 | - 'bg_color_active' => 'ffffff', |
|
| 350 | + 'bg_color_active' => 'ffffff', |
|
| 351 | 351 | 'border_color_active' => '66afe9', |
| 352 | 352 | 'remove_box_shadow_active' => '', |
| 353 | - 'text_color_error' => '444444', |
|
| 354 | - 'bg_color_error' => 'ffffff', |
|
| 353 | + 'text_color_error' => '444444', |
|
| 354 | + 'bg_color_error' => 'ffffff', |
|
| 355 | 355 | 'border_color_error' => 'B94A48', |
| 356 | 356 | 'border_width_error' => '1px', |
| 357 | 357 | 'border_style_error' => 'solid', |
| 358 | - 'bg_color_disabled' => 'ffffff', |
|
| 359 | - 'border_color_disabled' => 'E5E5E5', |
|
| 360 | - 'text_color_disabled' => 'A1A1A1', |
|
| 361 | - |
|
| 362 | - 'radio_align' => 'block', |
|
| 363 | - 'check_align' => 'block', |
|
| 364 | - 'check_font_size' => '13px', |
|
| 365 | - 'check_label_color' => '444444', |
|
| 366 | - 'check_weight' => 'normal', |
|
| 367 | - |
|
| 368 | - 'section_font_size' => '18px', |
|
| 369 | - 'section_color' => '444444', |
|
| 370 | - 'section_weight' => 'bold', |
|
| 371 | - 'section_pad' => '15px 0 3px 0', |
|
| 372 | - 'section_mar_top' => '15px', |
|
| 358 | + 'bg_color_disabled' => 'ffffff', |
|
| 359 | + 'border_color_disabled' => 'E5E5E5', |
|
| 360 | + 'text_color_disabled' => 'A1A1A1', |
|
| 361 | + |
|
| 362 | + 'radio_align' => 'block', |
|
| 363 | + 'check_align' => 'block', |
|
| 364 | + 'check_font_size' => '13px', |
|
| 365 | + 'check_label_color' => '444444', |
|
| 366 | + 'check_weight' => 'normal', |
|
| 367 | + |
|
| 368 | + 'section_font_size' => '18px', |
|
| 369 | + 'section_color' => '444444', |
|
| 370 | + 'section_weight' => 'bold', |
|
| 371 | + 'section_pad' => '15px 0 3px 0', |
|
| 372 | + 'section_mar_top' => '15px', |
|
| 373 | 373 | 'section_mar_bottom' => '12px', |
| 374 | - 'section_bg_color' => '', |
|
| 375 | - 'section_border_color' => 'e8e8e8', |
|
| 376 | - 'section_border_width' => '2px', |
|
| 377 | - 'section_border_style' => 'solid', |
|
| 378 | - 'section_border_loc' => '-top', |
|
| 379 | - 'collapse_icon' => '6', |
|
| 380 | - 'collapse_pos' => 'after', |
|
| 381 | - 'repeat_icon' => '1', |
|
| 382 | - |
|
| 383 | - 'submit_style' => false, |
|
| 384 | - 'submit_font_size' => '14px', |
|
| 385 | - 'submit_width' => 'auto', |
|
| 386 | - 'submit_height' => 'auto', |
|
| 387 | - 'submit_bg_color' => 'ffffff', |
|
| 388 | - 'submit_border_color' => 'cccccc', |
|
| 389 | - 'submit_border_width' => '1px', |
|
| 390 | - 'submit_text_color' => '444444', |
|
| 391 | - 'submit_weight' => 'normal', |
|
| 392 | - 'submit_border_radius' => '4px', |
|
| 393 | - 'submit_bg_img' => '', |
|
| 394 | - 'submit_margin' => '10px', |
|
| 395 | - 'submit_padding' => '6px 11px', |
|
| 396 | - 'submit_shadow_color' => 'eeeeee', |
|
| 397 | - 'submit_hover_bg_color' => 'efefef', |
|
| 398 | - 'submit_hover_color' => '444444', |
|
| 399 | - 'submit_hover_border_color' => 'cccccc', |
|
| 400 | - 'submit_active_bg_color' => 'efefef', |
|
| 401 | - 'submit_active_color' => '444444', |
|
| 402 | - 'submit_active_border_color' => 'cccccc', |
|
| 403 | - |
|
| 404 | - 'border_radius' => '4px', |
|
| 405 | - 'error_bg' => 'F2DEDE', |
|
| 406 | - 'error_border' => 'EBCCD1', |
|
| 407 | - 'error_text' => 'B94A48', |
|
| 408 | - 'error_font_size' => '14px', |
|
| 409 | - |
|
| 410 | - 'success_bg_color' => 'DFF0D8', |
|
| 411 | - 'success_border_color' => 'D6E9C6', |
|
| 412 | - 'success_text_color' => '468847', |
|
| 413 | - 'success_font_size' => '14px', |
|
| 414 | - |
|
| 415 | - 'important_style' => false, |
|
| 416 | - |
|
| 417 | - 'custom_css' => '', |
|
| 418 | - ); |
|
| 419 | - } |
|
| 374 | + 'section_bg_color' => '', |
|
| 375 | + 'section_border_color' => 'e8e8e8', |
|
| 376 | + 'section_border_width' => '2px', |
|
| 377 | + 'section_border_style' => 'solid', |
|
| 378 | + 'section_border_loc' => '-top', |
|
| 379 | + 'collapse_icon' => '6', |
|
| 380 | + 'collapse_pos' => 'after', |
|
| 381 | + 'repeat_icon' => '1', |
|
| 382 | + |
|
| 383 | + 'submit_style' => false, |
|
| 384 | + 'submit_font_size' => '14px', |
|
| 385 | + 'submit_width' => 'auto', |
|
| 386 | + 'submit_height' => 'auto', |
|
| 387 | + 'submit_bg_color' => 'ffffff', |
|
| 388 | + 'submit_border_color' => 'cccccc', |
|
| 389 | + 'submit_border_width' => '1px', |
|
| 390 | + 'submit_text_color' => '444444', |
|
| 391 | + 'submit_weight' => 'normal', |
|
| 392 | + 'submit_border_radius' => '4px', |
|
| 393 | + 'submit_bg_img' => '', |
|
| 394 | + 'submit_margin' => '10px', |
|
| 395 | + 'submit_padding' => '6px 11px', |
|
| 396 | + 'submit_shadow_color' => 'eeeeee', |
|
| 397 | + 'submit_hover_bg_color' => 'efefef', |
|
| 398 | + 'submit_hover_color' => '444444', |
|
| 399 | + 'submit_hover_border_color' => 'cccccc', |
|
| 400 | + 'submit_active_bg_color' => 'efefef', |
|
| 401 | + 'submit_active_color' => '444444', |
|
| 402 | + 'submit_active_border_color' => 'cccccc', |
|
| 403 | + |
|
| 404 | + 'border_radius' => '4px', |
|
| 405 | + 'error_bg' => 'F2DEDE', |
|
| 406 | + 'error_border' => 'EBCCD1', |
|
| 407 | + 'error_text' => 'B94A48', |
|
| 408 | + 'error_font_size' => '14px', |
|
| 409 | + |
|
| 410 | + 'success_bg_color' => 'DFF0D8', |
|
| 411 | + 'success_border_color' => 'D6E9C6', |
|
| 412 | + 'success_text_color' => '468847', |
|
| 413 | + 'success_font_size' => '14px', |
|
| 414 | + |
|
| 415 | + 'important_style' => false, |
|
| 416 | + |
|
| 417 | + 'custom_css' => '', |
|
| 418 | + ); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | 421 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
| 422 | 422 | return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |