@@ -21,15 +21,15 @@ |
||
| 21 | 21 | </div> |
| 22 | 22 | <div class="widget-inside frm_hidden"> |
| 23 | 23 | <?php |
| 24 | - if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
| 25 | - // only load settings if they are just added or are open |
|
| 24 | + if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
| 25 | + // only load settings if they are just added or are open |
|
| 26 | 26 | include( dirname( __FILE__ ) . '/_action_inside.php' ); |
| 27 | - } else { |
|
| 28 | - // include hidden settings so action won't get lost on update ?> |
|
| 27 | + } else { |
|
| 28 | + // include hidden settings so action won't get lost on update ?> |
|
| 29 | 29 | <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
| 30 | 30 | <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
| 31 | 31 | <?php |
| 32 | - } ?> |
|
| 32 | + } ?> |
|
| 33 | 33 | </div> |
| 34 | 34 | <style type="text/css"> |
| 35 | 35 | .frm_no_actions{ |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | </div> |
| 22 | 22 | <div class="widget-inside frm_hidden"> |
| 23 | 23 | <?php |
| 24 | - if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
| 24 | + if ( defined( 'DOING_AJAX' ) || ! $action_control->action_options['ajax_load'] ) { |
|
| 25 | 25 | // only load settings if they are just added or are open |
| 26 | 26 | include( dirname( __FILE__ ) . '/_action_inside.php' ); |
| 27 | 27 | } else { |
| 28 | 28 | // include hidden settings so action won't get lost on update ?> |
| 29 | - <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
| 30 | - <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
| 29 | + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
| 30 | + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
| 31 | 31 | <?php |
| 32 | 32 | } ?> |
| 33 | 33 | </div> |
@@ -4,12 +4,12 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | public function __construct() { |
| 6 | 6 | $action_ops = array( |
| 7 | - 'classes' => 'frm_email_icon frm_icon_font', |
|
| 8 | - 'active' => true, |
|
| 7 | + 'classes' => 'frm_email_icon frm_icon_font', |
|
| 8 | + 'active' => true, |
|
| 9 | 9 | 'event' => array( 'create' ), |
| 10 | - 'limit' => 99, |
|
| 11 | - 'priority' => 10, |
|
| 12 | - 'ajax_load' => false, |
|
| 10 | + 'limit' => 99, |
|
| 11 | + 'priority' => 10, |
|
| 12 | + 'ajax_load' => false, |
|
| 13 | 13 | ); |
| 14 | 14 | $action_ops = apply_filters('frm_email_control_settings', $action_ops); |
| 15 | 15 | |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function form( $form_action, $args = array() ) { |
| 20 | - extract($args); |
|
| 20 | + extract($args); |
|
| 21 | 21 | |
| 22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' ); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function get_defaults() { |
| 26 | - return array( |
|
| 27 | - 'email_to' => '[admin_email]', |
|
| 28 | - 'cc' => '', |
|
| 29 | - 'bcc' => '', |
|
| 30 | - 'from' => '[sitename] <[admin_email]>', |
|
| 31 | - 'reply_to' => '', |
|
| 32 | - 'email_subject' => '', |
|
| 33 | - 'email_message' => '[default-message]', |
|
| 34 | - 'inc_user_info' => 0, |
|
| 35 | - 'plain_text' => 0, |
|
| 26 | + return array( |
|
| 27 | + 'email_to' => '[admin_email]', |
|
| 28 | + 'cc' => '', |
|
| 29 | + 'bcc' => '', |
|
| 30 | + 'from' => '[sitename] <[admin_email]>', |
|
| 31 | + 'reply_to' => '', |
|
| 32 | + 'email_subject' => '', |
|
| 33 | + 'email_message' => '[default-message]', |
|
| 34 | + 'inc_user_info' => 0, |
|
| 35 | + 'plain_text' => 0, |
|
| 36 | 36 | 'event' => array( 'create' ), |
| 37 | - ); |
|
| 37 | + ); |
|
| 38 | 38 | } |
| 39 | 39 | } |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | 'priority' => 10, |
| 12 | 12 | 'ajax_load' => false, |
| 13 | 13 | ); |
| 14 | - $action_ops = apply_filters('frm_email_control_settings', $action_ops); |
|
| 14 | + $action_ops = apply_filters( 'frm_email_control_settings', $action_ops ); |
|
| 15 | 15 | |
| 16 | - parent::__construct('email', __( 'Email Notification', 'formidable' ), $action_ops); |
|
| 16 | + parent::__construct( 'email', __( 'Email Notification', 'formidable' ), $action_ops ); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function form( $form_action, $args = array() ) { |
| 20 | - extract($args); |
|
| 20 | + extract( $args ); |
|
| 21 | 21 | |
| 22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' ); |
| 23 | 23 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | public $action_options; // Option array passed to wp_register_sidebar_widget() |
| 9 | 9 | public $control_options; // Option array passed to wp_register_widget_control() |
| 10 | 10 | |
| 11 | - public $form_id; // The ID of the form to evaluate |
|
| 11 | + public $form_id; // The ID of the form to evaluate |
|
| 12 | 12 | public $number = false; // Unique ID number of the current instance. |
| 13 | 13 | public $id = ''; // Unique ID string of the current instance (id_base-number) |
| 14 | 14 | public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * Echo the settings update form |
|
| 32 | + * Echo the settings update form |
|
| 33 | 33 | * |
| 34 | 34 | * @param array $instance Current settings |
| 35 | 35 | */ |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | * @return array of the default options |
| 43 | 43 | */ |
| 44 | 44 | public function get_defaults() { |
| 45 | - return array(); |
|
| 45 | + return array(); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function get_switch_fields() { |
| 49 | - return array(); |
|
| 49 | + return array(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function migrate_values( $action, $form ) { |
| 53 | - return $action; |
|
| 53 | + return $action; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Functions you'll need to call. |
@@ -69,24 +69,24 @@ discard block |
||
| 69 | 69 | * - height: currently not used but may be needed in the future |
| 70 | 70 | */ |
| 71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
| 72 | - if ( ! defined('ABSPATH') ) { |
|
| 73 | - die('You are not allowed to call this page directly.'); |
|
| 74 | - } |
|
| 72 | + if ( ! defined('ABSPATH') ) { |
|
| 73 | + die('You are not allowed to call this page directly.'); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | $this->id_base = strtolower($id_base); |
| 77 | 77 | $this->name = $name; |
| 78 | 78 | $this->option_name = 'frm_' . $this->id_base . '_action'; |
| 79 | 79 | |
| 80 | - $default_options = array( |
|
| 81 | - 'classes' => '', |
|
| 82 | - 'active' => true, |
|
| 80 | + $default_options = array( |
|
| 81 | + 'classes' => '', |
|
| 82 | + 'active' => true, |
|
| 83 | 83 | 'event' => array( 'create' ), |
| 84 | - 'limit' => 1, |
|
| 85 | - 'force_event' => false, |
|
| 86 | - 'priority' => 20, |
|
| 87 | - 'ajax_load' => true, |
|
| 88 | - 'tooltip' => $name, |
|
| 89 | - ); |
|
| 84 | + 'limit' => 1, |
|
| 85 | + 'force_event' => false, |
|
| 86 | + 'priority' => 20, |
|
| 87 | + 'ajax_load' => true, |
|
| 88 | + 'tooltip' => $name, |
|
| 89 | + ); |
|
| 90 | 90 | |
| 91 | 91 | $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options ); |
| 92 | 92 | $this->action_options = wp_parse_args( $action_options, $default_options ); |
@@ -135,132 +135,132 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public function prepare_new( $form_id = false ) { |
| 138 | - if ( $form_id ) { |
|
| 139 | - $this->form_id = $form_id; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $post_content = array(); |
|
| 143 | - $default_values = $this->get_global_defaults(); |
|
| 144 | - |
|
| 145 | - // fill default values |
|
| 146 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
| 147 | - |
|
| 148 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
| 149 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - $form_action = array( |
|
| 153 | - 'post_title' => $this->name, |
|
| 154 | - 'post_content' => $post_content, |
|
| 155 | - 'post_excerpt' => $this->id_base, |
|
| 156 | - 'ID' => '', |
|
| 157 | - 'post_status' => 'publish', |
|
| 158 | - 'post_type' => FrmFormActionsController::$action_post_type, |
|
| 138 | + if ( $form_id ) { |
|
| 139 | + $this->form_id = $form_id; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $post_content = array(); |
|
| 143 | + $default_values = $this->get_global_defaults(); |
|
| 144 | + |
|
| 145 | + // fill default values |
|
| 146 | + $post_content = wp_parse_args( $post_content, $default_values); |
|
| 147 | + |
|
| 148 | + if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
| 149 | + $post_content['event'] = array( reset($this->action_options['event']) ); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + $form_action = array( |
|
| 153 | + 'post_title' => $this->name, |
|
| 154 | + 'post_content' => $post_content, |
|
| 155 | + 'post_excerpt' => $this->id_base, |
|
| 156 | + 'ID' => '', |
|
| 157 | + 'post_status' => 'publish', |
|
| 158 | + 'post_type' => FrmFormActionsController::$action_post_type, |
|
| 159 | 159 | 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
| 160 | - 'menu_order' => $this->form_id, |
|
| 161 | - ); |
|
| 162 | - unset($post_content); |
|
| 160 | + 'menu_order' => $this->form_id, |
|
| 161 | + ); |
|
| 162 | + unset($post_content); |
|
| 163 | 163 | |
| 164 | - return (object) $form_action; |
|
| 165 | - } |
|
| 164 | + return (object) $form_action; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | public function create( $form_id ) { |
| 168 | - $this->form_id = $form_id; |
|
| 168 | + $this->form_id = $form_id; |
|
| 169 | 169 | |
| 170 | - $action = $this->prepare_new(); |
|
| 170 | + $action = $this->prepare_new(); |
|
| 171 | 171 | |
| 172 | - return $this->save_settings($action); |
|
| 173 | - } |
|
| 172 | + return $this->save_settings($action); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | public function duplicate_form_actions( $form_id, $old_id ) { |
| 176 | - if ( $form_id == $old_id ) { |
|
| 177 | - // don't duplicate the actions if this is a template getting updated |
|
| 178 | - return; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $this->form_id = $old_id; |
|
| 182 | - $actions = $this->get_all( $old_id ); |
|
| 183 | - |
|
| 184 | - $this->form_id = $form_id; |
|
| 185 | - foreach ( $actions as $action ) { |
|
| 186 | - $this->duplicate_one($action, $form_id); |
|
| 187 | - unset($action); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /* Check if imported action should be created or updated |
|
| 176 | + if ( $form_id == $old_id ) { |
|
| 177 | + // don't duplicate the actions if this is a template getting updated |
|
| 178 | + return; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $this->form_id = $old_id; |
|
| 182 | + $actions = $this->get_all( $old_id ); |
|
| 183 | + |
|
| 184 | + $this->form_id = $form_id; |
|
| 185 | + foreach ( $actions as $action ) { |
|
| 186 | + $this->duplicate_one($action, $form_id); |
|
| 187 | + unset($action); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /* Check if imported action should be created or updated |
|
| 192 | 192 | * |
| 193 | 193 | * Since 2.0 |
| 194 | 194 | * |
| 195 | 195 | * @param array $action |
| 196 | 196 | * @return integer $post_id |
| 197 | 197 | */ |
| 198 | - public function maybe_create_action( $action, $forms ) { |
|
| 198 | + public function maybe_create_action( $action, $forms ) { |
|
| 199 | 199 | if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
| 200 | - // Update action only |
|
| 201 | - $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
| 202 | - $post_id = $this->save_settings( $action ); |
|
| 203 | - } else { |
|
| 204 | - // Create action |
|
| 205 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
| 206 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
| 207 | - } |
|
| 208 | - return $post_id; |
|
| 209 | - } |
|
| 200 | + // Update action only |
|
| 201 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
| 202 | + $post_id = $this->save_settings( $action ); |
|
| 203 | + } else { |
|
| 204 | + // Create action |
|
| 205 | + $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
| 206 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
| 207 | + } |
|
| 208 | + return $post_id; |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | public function duplicate_one( $action, $form_id ) { |
| 212 | - global $frm_duplicate_ids; |
|
| 212 | + global $frm_duplicate_ids; |
|
| 213 | 213 | |
| 214 | - $action->menu_order = $form_id; |
|
| 215 | - $switch = $this->get_global_switch_fields(); |
|
| 216 | - foreach ( (array) $action->post_content as $key => $val ) { |
|
| 214 | + $action->menu_order = $form_id; |
|
| 215 | + $switch = $this->get_global_switch_fields(); |
|
| 216 | + foreach ( (array) $action->post_content as $key => $val ) { |
|
| 217 | 217 | if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
| 218 | 218 | $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
| 219 | - } else if ( ! is_array( $val ) ) { |
|
| 219 | + } else if ( ! is_array( $val ) ) { |
|
| 220 | 220 | $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
| 221 | 221 | } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
| 222 | - // loop through each value if empty |
|
| 222 | + // loop through each value if empty |
|
| 223 | 223 | if ( empty( $switch[ $key ] ) ) { |
| 224 | 224 | $switch[ $key ] = array_keys( $val ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | foreach ( $switch[ $key ] as $subkey ) { |
| 228 | 228 | $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
| 229 | - } |
|
| 230 | - } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - unset($key, $val); |
|
| 233 | - } |
|
| 234 | - unset($action->ID); |
|
| 232 | + unset($key, $val); |
|
| 233 | + } |
|
| 234 | + unset($action->ID); |
|
| 235 | 235 | |
| 236 | - return $this->save_settings($action); |
|
| 237 | - } |
|
| 236 | + return $this->save_settings($action); |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | 239 | private function duplicate_array_walk( $action, $subkey, $val ) { |
| 240 | - global $frm_duplicate_ids; |
|
| 240 | + global $frm_duplicate_ids; |
|
| 241 | 241 | |
| 242 | - if ( is_array($subkey) ) { |
|
| 243 | - foreach ( $subkey as $subkey2 ) { |
|
| 244 | - foreach ( (array) $val as $ck => $cv ) { |
|
| 245 | - if ( is_array($cv) ) { |
|
| 242 | + if ( is_array($subkey) ) { |
|
| 243 | + foreach ( $subkey as $subkey2 ) { |
|
| 244 | + foreach ( (array) $val as $ck => $cv ) { |
|
| 245 | + if ( is_array($cv) ) { |
|
| 246 | 246 | $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
| 247 | 247 | } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
| 248 | 248 | $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } else { |
|
| 253 | - foreach ( (array) $val as $ck => $cv ) { |
|
| 254 | - if ( is_array($cv) ) { |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } else { |
|
| 253 | + foreach ( (array) $val as $ck => $cv ) { |
|
| 254 | + if ( is_array($cv) ) { |
|
| 255 | 255 | $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
| 256 | 256 | } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
| 257 | 257 | $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
| 258 | - } |
|
| 259 | - } |
|
| 260 | - } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return $action; |
|
| 263 | - } |
|
| 262 | + return $action; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Deal with changed settings. |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | */ |
| 271 | 271 | public function update_callback( $form_id ) { |
| 272 | - $this->form_id = $form_id; |
|
| 272 | + $this->form_id = $form_id; |
|
| 273 | 273 | |
| 274 | 274 | $all_instances = $this->get_settings(); |
| 275 | 275 | |
@@ -284,25 +284,25 @@ discard block |
||
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $action_ids = array(); |
|
| 287 | + $action_ids = array(); |
|
| 288 | 288 | |
| 289 | 289 | foreach ( $settings as $number => $new_instance ) { |
| 290 | 290 | $this->_set($number); |
| 291 | 291 | |
| 292 | 292 | if ( ! isset($new_instance['post_title']) ) { |
| 293 | - // settings were never opened, so don't update |
|
| 294 | - $action_ids[] = $new_instance['ID']; |
|
| 295 | - $this->updated = true; |
|
| 296 | - continue; |
|
| 293 | + // settings were never opened, so don't update |
|
| 294 | + $action_ids[] = $new_instance['ID']; |
|
| 295 | + $this->updated = true; |
|
| 296 | + continue; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
| 300 | 300 | |
| 301 | 301 | $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
| 302 | 302 | $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
| 303 | - $new_instance['menu_order'] = $this->form_id; |
|
| 304 | - $new_instance['post_status'] = 'publish'; |
|
| 305 | - $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
|
| 303 | + $new_instance['menu_order'] = $this->form_id; |
|
| 304 | + $new_instance['post_status'] = 'publish'; |
|
| 305 | + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
|
| 306 | 306 | |
| 307 | 307 | $instance = $this->update( $new_instance, $old_instance ); |
| 308 | 308 | |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | $all_instances[ $number ] = $instance; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $action_ids[] = $this->save_settings($instance); |
|
| 331 | + $action_ids[] = $this->save_settings($instance); |
|
| 332 | 332 | |
| 333 | - $this->updated = true; |
|
| 333 | + $this->updated = true; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | return $action_ids; |
@@ -342,100 +342,100 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | public function get_single_action( $id ) { |
| 345 | - $action = get_post($id); |
|
| 345 | + $action = get_post($id); |
|
| 346 | 346 | if ( $action ) { |
| 347 | 347 | $action = $this->prepare_action( $action ); |
| 348 | 348 | $this->_set( $id ); |
| 349 | 349 | } |
| 350 | - return $action; |
|
| 350 | + return $action; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public function get_one( $form_id ) { |
| 354 | - return $this->get_all($form_id, 1); |
|
| 354 | + return $this->get_all($form_id, 1); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
|
| 358 | - $action_controls = FrmFormActionsController::get_form_actions( $type ); |
|
| 359 | - if ( empty($action_controls) ) { |
|
| 360 | - // don't continue if there are no available actions |
|
| 361 | - return array(); |
|
| 362 | - } |
|
| 357 | + public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
|
| 358 | + $action_controls = FrmFormActionsController::get_form_actions( $type ); |
|
| 359 | + if ( empty($action_controls) ) { |
|
| 360 | + // don't continue if there are no available actions |
|
| 361 | + return array(); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if ( 'all' != $type ) { |
|
| 365 | - return $action_controls->get_all( $form_id, $limit ); |
|
| 366 | - } |
|
| 364 | + if ( 'all' != $type ) { |
|
| 365 | + return $action_controls->get_all( $form_id, $limit ); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | 368 | $args = self::action_args( $form_id, $limit ); |
| 369 | 369 | $actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' ); |
| 370 | 370 | |
| 371 | - if ( ! $actions ) { |
|
| 372 | - return array(); |
|
| 373 | - } |
|
| 371 | + if ( ! $actions ) { |
|
| 372 | + return array(); |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - $settings = array(); |
|
| 376 | - foreach ( $actions as $action ) { |
|
| 375 | + $settings = array(); |
|
| 376 | + foreach ( $actions as $action ) { |
|
| 377 | 377 | // some plugins/themes are formatting the post_excerpt |
| 378 | 378 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 379 | 379 | |
| 380 | 380 | if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
| 381 | - continue; |
|
| 382 | - } |
|
| 381 | + continue; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
| 384 | + $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
| 385 | 385 | $settings[ $action->ID ] = $action; |
| 386 | 386 | |
| 387 | 387 | if ( count( $settings ) >= $limit ) { |
| 388 | 388 | break; |
| 389 | 389 | } |
| 390 | - } |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - if ( 1 === $limit ) { |
|
| 393 | - $settings = reset($settings); |
|
| 394 | - } |
|
| 392 | + if ( 1 === $limit ) { |
|
| 393 | + $settings = reset($settings); |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - return $settings; |
|
| 397 | - } |
|
| 396 | + return $settings; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | 399 | public function get_all( $form_id = false, $limit = 99 ) { |
| 400 | - if ( $form_id ) { |
|
| 401 | - $this->form_id = $form_id; |
|
| 402 | - } |
|
| 400 | + if ( $form_id ) { |
|
| 401 | + $this->form_id = $form_id; |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - $type = $this->id_base; |
|
| 404 | + $type = $this->id_base; |
|
| 405 | 405 | |
| 406 | - global $frm_vars; |
|
| 407 | - $frm_vars['action_type'] = $type; |
|
| 406 | + global $frm_vars; |
|
| 407 | + $frm_vars['action_type'] = $type; |
|
| 408 | 408 | |
| 409 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 409 | + add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 410 | 410 | $query = self::action_args( $form_id, $limit ); |
| 411 | - $query['post_status'] = 'any'; |
|
| 412 | - $query['suppress_filters'] = false; |
|
| 411 | + $query['post_status'] = 'any'; |
|
| 412 | + $query['suppress_filters'] = false; |
|
| 413 | 413 | |
| 414 | 414 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
| 415 | - unset($query); |
|
| 415 | + unset($query); |
|
| 416 | 416 | |
| 417 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 417 | + remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 418 | 418 | |
| 419 | - if ( empty($actions) ) { |
|
| 420 | - return array(); |
|
| 421 | - } |
|
| 419 | + if ( empty($actions) ) { |
|
| 420 | + return array(); |
|
| 421 | + } |
|
| 422 | 422 | |
| 423 | - $settings = array(); |
|
| 424 | - foreach ( $actions as $action ) { |
|
| 425 | - if ( count($settings) >= $limit ) { |
|
| 426 | - continue; |
|
| 427 | - } |
|
| 423 | + $settings = array(); |
|
| 424 | + foreach ( $actions as $action ) { |
|
| 425 | + if ( count($settings) >= $limit ) { |
|
| 426 | + continue; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - $action = $this->prepare_action($action); |
|
| 429 | + $action = $this->prepare_action($action); |
|
| 430 | 430 | |
| 431 | 431 | $settings[ $action->ID ] = $action; |
| 432 | - } |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - if ( 1 === $limit ) { |
|
| 435 | - $settings = reset($settings); |
|
| 436 | - } |
|
| 434 | + if ( 1 === $limit ) { |
|
| 435 | + $settings = reset($settings); |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - return $settings; |
|
| 438 | + return $settings; |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | public static function action_args( $form_id = 0, $limit = 99 ) { |
@@ -458,45 +458,45 @@ discard block |
||
| 458 | 458 | $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
| 459 | 459 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 460 | 460 | |
| 461 | - $default_values = $this->get_global_defaults(); |
|
| 461 | + $default_values = $this->get_global_defaults(); |
|
| 462 | 462 | |
| 463 | - // fill default values |
|
| 464 | - $action->post_content += $default_values; |
|
| 463 | + // fill default values |
|
| 464 | + $action->post_content += $default_values; |
|
| 465 | 465 | |
| 466 | - foreach ( $default_values as $k => $vals ) { |
|
| 467 | - if ( is_array($vals) && ! empty($vals) ) { |
|
| 466 | + foreach ( $default_values as $k => $vals ) { |
|
| 467 | + if ( is_array($vals) && ! empty($vals) ) { |
|
| 468 | 468 | if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
| 469 | - continue; |
|
| 470 | - } |
|
| 469 | + continue; |
|
| 470 | + } |
|
| 471 | 471 | $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
| 472 | - } |
|
| 473 | - } |
|
| 472 | + } |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - if ( ! is_array($action->post_content['event']) ) { |
|
| 476 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
| 477 | - } |
|
| 475 | + if ( ! is_array($action->post_content['event']) ) { |
|
| 476 | + $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | - return $action; |
|
| 479 | + return $action; |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | public function destroy( $form_id = false, $type = 'default' ) { |
| 483 | - global $wpdb; |
|
| 483 | + global $wpdb; |
|
| 484 | 484 | |
| 485 | - $this->form_id = $form_id; |
|
| 485 | + $this->form_id = $form_id; |
|
| 486 | 486 | |
| 487 | - $query = array( 'post_type' => FrmFormActionsController::$action_post_type ); |
|
| 488 | - if ( $form_id ) { |
|
| 489 | - $query['menu_order'] = $form_id; |
|
| 490 | - } |
|
| 491 | - if ( 'all' != $type ) { |
|
| 492 | - $query['post_excerpt'] = $this->id_base; |
|
| 493 | - } |
|
| 487 | + $query = array( 'post_type' => FrmFormActionsController::$action_post_type ); |
|
| 488 | + if ( $form_id ) { |
|
| 489 | + $query['menu_order'] = $form_id; |
|
| 490 | + } |
|
| 491 | + if ( 'all' != $type ) { |
|
| 492 | + $query['post_excerpt'] = $this->id_base; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
|
| 495 | + $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
|
| 496 | 496 | |
| 497 | - foreach ( $post_ids as $id ) { |
|
| 498 | - wp_delete_post($id); |
|
| 499 | - } |
|
| 497 | + foreach ( $post_ids as $id ) { |
|
| 498 | + wp_delete_post($id); |
|
| 499 | + } |
|
| 500 | 500 | self::clear_cache(); |
| 501 | 501 | } |
| 502 | 502 | |
@@ -514,69 +514,69 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | public function get_global_defaults() { |
| 517 | - $defaults = $this->get_defaults(); |
|
| 517 | + $defaults = $this->get_defaults(); |
|
| 518 | 518 | |
| 519 | - if ( ! isset($defaults['event']) ) { |
|
| 519 | + if ( ! isset($defaults['event']) ) { |
|
| 520 | 520 | $defaults['event'] = array( 'create' ); |
| 521 | - } |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - if ( ! isset($defaults['conditions']) ) { |
|
| 524 | - $defaults['conditions'] = array( |
|
| 525 | - 'send_stop' => '', |
|
| 526 | - 'any_all' => '', |
|
| 527 | - ); |
|
| 528 | - } |
|
| 523 | + if ( ! isset($defaults['conditions']) ) { |
|
| 524 | + $defaults['conditions'] = array( |
|
| 525 | + 'send_stop' => '', |
|
| 526 | + 'any_all' => '', |
|
| 527 | + ); |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - return $defaults; |
|
| 530 | + return $defaults; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | public function get_global_switch_fields() { |
| 534 | - $switch = $this->get_switch_fields(); |
|
| 534 | + $switch = $this->get_switch_fields(); |
|
| 535 | 535 | $switch['conditions'] = array( 'hide_field' ); |
| 536 | - return $switch; |
|
| 536 | + return $switch; |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
| 540 | 540 | * Migrate settings from form->options into new action. |
| 541 | 541 | */ |
| 542 | 542 | public function migrate_to_2( $form, $update = 'update' ) { |
| 543 | - $action = $this->prepare_new($form->id); |
|
| 544 | - $form->options = maybe_unserialize($form->options); |
|
| 543 | + $action = $this->prepare_new($form->id); |
|
| 544 | + $form->options = maybe_unserialize($form->options); |
|
| 545 | 545 | |
| 546 | - // fill with existing options |
|
| 547 | - foreach ( $action->post_content as $name => $val ) { |
|
| 546 | + // fill with existing options |
|
| 547 | + foreach ( $action->post_content as $name => $val ) { |
|
| 548 | 548 | if ( isset( $form->options[ $name ] ) ) { |
| 549 | 549 | $action->post_content[ $name ] = $form->options[ $name ]; |
| 550 | 550 | unset( $form->options[ $name ] ); |
| 551 | - } |
|
| 552 | - } |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - $action = $this->migrate_values($action, $form); |
|
| 554 | + $action = $this->migrate_values($action, $form); |
|
| 555 | 555 | |
| 556 | - // check if action already exists |
|
| 557 | - $post_id = get_posts( array( |
|
| 558 | - 'name' => $action->post_name, |
|
| 559 | - 'post_type' => FrmFormActionsController::$action_post_type, |
|
| 560 | - 'post_status' => $action->post_status, |
|
| 561 | - 'numberposts' => 1, |
|
| 562 | - ) ); |
|
| 556 | + // check if action already exists |
|
| 557 | + $post_id = get_posts( array( |
|
| 558 | + 'name' => $action->post_name, |
|
| 559 | + 'post_type' => FrmFormActionsController::$action_post_type, |
|
| 560 | + 'post_status' => $action->post_status, |
|
| 561 | + 'numberposts' => 1, |
|
| 562 | + ) ); |
|
| 563 | 563 | |
| 564 | - if ( empty($post_id) ) { |
|
| 565 | - // create action now |
|
| 566 | - $post_id = $this->save_settings($action); |
|
| 567 | - } |
|
| 564 | + if ( empty($post_id) ) { |
|
| 565 | + // create action now |
|
| 566 | + $post_id = $this->save_settings($action); |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - if ( $post_id && 'update' == $update ) { |
|
| 570 | - global $wpdb; |
|
| 571 | - $form->options = maybe_serialize($form->options); |
|
| 569 | + if ( $post_id && 'update' == $update ) { |
|
| 570 | + global $wpdb; |
|
| 571 | + $form->options = maybe_serialize($form->options); |
|
| 572 | 572 | |
| 573 | - // update form options |
|
| 573 | + // update form options |
|
| 574 | 574 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
| 575 | - wp_cache_delete( $form->id, 'frm_form'); |
|
| 576 | - } |
|
| 575 | + wp_cache_delete( $form->id, 'frm_form'); |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - return $post_id; |
|
| 579 | - } |
|
| 578 | + return $post_id; |
|
| 579 | + } |
|
| 580 | 580 | |
| 581 | 581 | public static function action_conditions_met( $action, $entry ) { |
| 582 | 582 | $notification = $action->post_content; |
@@ -2,16 +2,16 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFormAction { |
| 4 | 4 | |
| 5 | - public $id_base; // Root id for all actions of this type. |
|
| 6 | - public $name; // Name for this action type. |
|
| 5 | + public $id_base; // Root id for all actions of this type. |
|
| 6 | + public $name; // Name for this action type. |
|
| 7 | 7 | public $option_name; |
| 8 | - public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
| 9 | - public $control_options; // Option array passed to wp_register_widget_control() |
|
| 8 | + public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
| 9 | + public $control_options; // Option array passed to wp_register_widget_control() |
|
| 10 | 10 | |
| 11 | - public $form_id; // The ID of the form to evaluate |
|
| 12 | - public $number = false; // Unique ID number of the current instance. |
|
| 13 | - public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
| 14 | - public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
| 11 | + public $form_id; // The ID of the form to evaluate |
|
| 12 | + public $number = false; // Unique ID number of the current instance. |
|
| 13 | + public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
| 14 | + public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
| 15 | 15 | |
| 16 | 16 | // Member functions that you must over-ride. |
| 17 | 17 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * - height: currently not used but may be needed in the future |
| 70 | 70 | */ |
| 71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
| 72 | - if ( ! defined('ABSPATH') ) { |
|
| 73 | - die('You are not allowed to call this page directly.'); |
|
| 72 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 73 | + die( 'You are not allowed to call this page directly.' ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->id_base = strtolower($id_base); |
|
| 76 | + $this->id_base = strtolower( $id_base ); |
|
| 77 | 77 | $this->name = $name; |
| 78 | 78 | $this->option_name = 'frm_' . $this->id_base . '_action'; |
| 79 | 79 | |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | $default_values = $this->get_global_defaults(); |
| 144 | 144 | |
| 145 | 145 | // fill default values |
| 146 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
| 146 | + $post_content = wp_parse_args( $post_content, $default_values ); |
|
| 147 | 147 | |
| 148 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
| 149 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
| 148 | + if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) { |
|
| 149 | + $post_content['event'] = array( reset( $this->action_options['event'] ) ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $form_action = array( |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
| 160 | 160 | 'menu_order' => $this->form_id, |
| 161 | 161 | ); |
| 162 | - unset($post_content); |
|
| 162 | + unset( $post_content ); |
|
| 163 | 163 | |
| 164 | 164 | return (object) $form_action; |
| 165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | $action = $this->prepare_new(); |
| 171 | 171 | |
| 172 | - return $this->save_settings($action); |
|
| 172 | + return $this->save_settings( $action ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function duplicate_form_actions( $form_id, $old_id ) { |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $this->form_id = $form_id; |
| 185 | 185 | foreach ( $actions as $action ) { |
| 186 | - $this->duplicate_one($action, $form_id); |
|
| 187 | - unset($action); |
|
| 186 | + $this->duplicate_one( $action, $form_id ); |
|
| 187 | + unset( $action ); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | * @return integer $post_id |
| 197 | 197 | */ |
| 198 | 198 | public function maybe_create_action( $action, $forms ) { |
| 199 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
| 199 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
| 200 | 200 | // Update action only |
| 201 | 201 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
| 202 | 202 | $post_id = $this->save_settings( $action ); |
| 203 | 203 | } else { |
| 204 | 204 | // Create action |
| 205 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
| 206 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
| 205 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
| 206 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] ); |
|
| 207 | 207 | } |
| 208 | 208 | return $post_id; |
| 209 | 209 | } |
@@ -214,47 +214,47 @@ discard block |
||
| 214 | 214 | $action->menu_order = $form_id; |
| 215 | 215 | $switch = $this->get_global_switch_fields(); |
| 216 | 216 | foreach ( (array) $action->post_content as $key => $val ) { |
| 217 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
| 218 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
| 217 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
| 218 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
| 219 | 219 | } else if ( ! is_array( $val ) ) { |
| 220 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 221 | - } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
| 220 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
| 221 | + } else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
| 222 | 222 | // loop through each value if empty |
| 223 | - if ( empty( $switch[ $key ] ) ) { |
|
| 224 | - $switch[ $key ] = array_keys( $val ); |
|
| 223 | + if ( empty( $switch[$key] ) ) { |
|
| 224 | + $switch[$key] = array_keys( $val ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - foreach ( $switch[ $key ] as $subkey ) { |
|
| 228 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
| 227 | + foreach ( $switch[$key] as $subkey ) { |
|
| 228 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - unset($key, $val); |
|
| 232 | + unset( $key, $val ); |
|
| 233 | 233 | } |
| 234 | - unset($action->ID); |
|
| 234 | + unset( $action->ID ); |
|
| 235 | 235 | |
| 236 | - return $this->save_settings($action); |
|
| 236 | + return $this->save_settings( $action ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | private function duplicate_array_walk( $action, $subkey, $val ) { |
| 240 | 240 | global $frm_duplicate_ids; |
| 241 | 241 | |
| 242 | - if ( is_array($subkey) ) { |
|
| 242 | + if ( is_array( $subkey ) ) { |
|
| 243 | 243 | foreach ( $subkey as $subkey2 ) { |
| 244 | 244 | foreach ( (array) $val as $ck => $cv ) { |
| 245 | - if ( is_array($cv) ) { |
|
| 246 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
| 247 | - } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
| 248 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
| 245 | + if ( is_array( $cv ) ) { |
|
| 246 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
| 247 | + } else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
| 248 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | } else { |
| 253 | 253 | foreach ( (array) $val as $ck => $cv ) { |
| 254 | - if ( is_array($cv) ) { |
|
| 255 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
| 256 | - } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
| 257 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
| 254 | + if ( is_array( $cv ) ) { |
|
| 255 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
| 256 | + } else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
| 257 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
| 282 | - $settings = $_POST[ $this->option_name ]; |
|
| 281 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
| 282 | + $settings = $_POST[$this->option_name]; |
|
| 283 | 283 | } else { |
| 284 | 284 | return; |
| 285 | 285 | } |
@@ -287,19 +287,19 @@ discard block |
||
| 287 | 287 | $action_ids = array(); |
| 288 | 288 | |
| 289 | 289 | foreach ( $settings as $number => $new_instance ) { |
| 290 | - $this->_set($number); |
|
| 290 | + $this->_set( $number ); |
|
| 291 | 291 | |
| 292 | - if ( ! isset($new_instance['post_title']) ) { |
|
| 292 | + if ( ! isset( $new_instance['post_title'] ) ) { |
|
| 293 | 293 | // settings were never opened, so don't update |
| 294 | 294 | $action_ids[] = $new_instance['ID']; |
| 295 | 295 | $this->updated = true; |
| 296 | 296 | continue; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
| 299 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
| 300 | 300 | |
| 301 | - $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
| 302 | - $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
| 301 | + $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
| 302 | + $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
| 303 | 303 | $new_instance['menu_order'] = $this->form_id; |
| 304 | 304 | $new_instance['post_status'] = 'publish'; |
| 305 | 305 | $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this ); |
| 323 | 323 | |
| 324 | - $instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this); |
|
| 324 | + $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
|
| 325 | 325 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
| 326 | 326 | |
| 327 | 327 | if ( false !== $instance ) { |
| 328 | - $all_instances[ $number ] = $instance; |
|
| 328 | + $all_instances[$number] = $instance; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $action_ids[] = $this->save_settings($instance); |
|
| 331 | + $action_ids[] = $this->save_settings( $instance ); |
|
| 332 | 332 | |
| 333 | 333 | $this->updated = true; |
| 334 | 334 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | public function get_single_action( $id ) { |
| 345 | - $action = get_post($id); |
|
| 345 | + $action = get_post( $id ); |
|
| 346 | 346 | if ( $action ) { |
| 347 | 347 | $action = $this->prepare_action( $action ); |
| 348 | 348 | $this->_set( $id ); |
@@ -351,12 +351,12 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | public function get_one( $form_id ) { |
| 354 | - return $this->get_all($form_id, 1); |
|
| 354 | + return $this->get_all( $form_id, 1 ); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
| 358 | 358 | $action_controls = FrmFormActionsController::get_form_actions( $type ); |
| 359 | - if ( empty($action_controls) ) { |
|
| 359 | + if ( empty( $action_controls ) ) { |
|
| 360 | 360 | // don't continue if there are no available actions |
| 361 | 361 | return array(); |
| 362 | 362 | } |
@@ -377,12 +377,12 @@ discard block |
||
| 377 | 377 | // some plugins/themes are formatting the post_excerpt |
| 378 | 378 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 379 | 379 | |
| 380 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
| 380 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
| 381 | 381 | continue; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
| 385 | - $settings[ $action->ID ] = $action; |
|
| 384 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
| 385 | + $settings[$action->ID] = $action; |
|
| 386 | 386 | |
| 387 | 387 | if ( count( $settings ) >= $limit ) { |
| 388 | 388 | break; |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | if ( 1 === $limit ) { |
| 393 | - $settings = reset($settings); |
|
| 393 | + $settings = reset( $settings ); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | return $settings; |
@@ -423,33 +423,33 @@ discard block |
||
| 423 | 423 | global $frm_vars; |
| 424 | 424 | $frm_vars['action_type'] = $type; |
| 425 | 425 | |
| 426 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 426 | + add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
| 427 | 427 | $query = self::action_args( $form_id, $limit ); |
| 428 | 428 | $query['post_status'] = 'any'; |
| 429 | 429 | $query['suppress_filters'] = false; |
| 430 | 430 | |
| 431 | 431 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
| 432 | - unset($query); |
|
| 432 | + unset( $query ); |
|
| 433 | 433 | |
| 434 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
| 434 | + remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
| 435 | 435 | |
| 436 | - if ( empty($actions) ) { |
|
| 436 | + if ( empty( $actions ) ) { |
|
| 437 | 437 | return array(); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $settings = array(); |
| 441 | 441 | foreach ( $actions as $action ) { |
| 442 | - if ( count($settings) >= $limit ) { |
|
| 442 | + if ( count( $settings ) >= $limit ) { |
|
| 443 | 443 | continue; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $action = $this->prepare_action($action); |
|
| 446 | + $action = $this->prepare_action( $action ); |
|
| 447 | 447 | |
| 448 | - $settings[ $action->ID ] = $action; |
|
| 448 | + $settings[$action->ID] = $action; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | if ( 1 === $limit ) { |
| 452 | - $settings = reset($settings); |
|
| 452 | + $settings = reset( $settings ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | return $settings; |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | public function prepare_action( $action ) { |
| 475 | - $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
|
| 475 | + $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content ); |
|
| 476 | 476 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
| 477 | 477 | |
| 478 | 478 | $default_values = $this->get_global_defaults(); |
@@ -481,16 +481,16 @@ discard block |
||
| 481 | 481 | $action->post_content += $default_values; |
| 482 | 482 | |
| 483 | 483 | foreach ( $default_values as $k => $vals ) { |
| 484 | - if ( is_array($vals) && ! empty($vals) ) { |
|
| 485 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
| 484 | + if ( is_array( $vals ) && ! empty( $vals ) ) { |
|
| 485 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
| 486 | 486 | continue; |
| 487 | 487 | } |
| 488 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
| 488 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - if ( ! is_array($action->post_content['event']) ) { |
|
| 493 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
| 492 | + if ( ! is_array( $action->post_content['event'] ) ) { |
|
| 493 | + $action->post_content['event'] = explode( ',', $action->post_content['event'] ); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $action; |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
| 513 | 513 | |
| 514 | 514 | foreach ( $post_ids as $id ) { |
| 515 | - wp_delete_post($id); |
|
| 515 | + wp_delete_post( $id ); |
|
| 516 | 516 | } |
| 517 | 517 | self::clear_cache(); |
| 518 | 518 | } |
@@ -533,11 +533,11 @@ discard block |
||
| 533 | 533 | public function get_global_defaults() { |
| 534 | 534 | $defaults = $this->get_defaults(); |
| 535 | 535 | |
| 536 | - if ( ! isset($defaults['event']) ) { |
|
| 536 | + if ( ! isset( $defaults['event'] ) ) { |
|
| 537 | 537 | $defaults['event'] = array( 'create' ); |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if ( ! isset($defaults['conditions']) ) { |
|
| 540 | + if ( ! isset( $defaults['conditions'] ) ) { |
|
| 541 | 541 | $defaults['conditions'] = array( |
| 542 | 542 | 'send_stop' => '', |
| 543 | 543 | 'any_all' => '', |
@@ -557,18 +557,18 @@ discard block |
||
| 557 | 557 | * Migrate settings from form->options into new action. |
| 558 | 558 | */ |
| 559 | 559 | public function migrate_to_2( $form, $update = 'update' ) { |
| 560 | - $action = $this->prepare_new($form->id); |
|
| 561 | - $form->options = maybe_unserialize($form->options); |
|
| 560 | + $action = $this->prepare_new( $form->id ); |
|
| 561 | + $form->options = maybe_unserialize( $form->options ); |
|
| 562 | 562 | |
| 563 | 563 | // fill with existing options |
| 564 | 564 | foreach ( $action->post_content as $name => $val ) { |
| 565 | - if ( isset( $form->options[ $name ] ) ) { |
|
| 566 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
| 567 | - unset( $form->options[ $name ] ); |
|
| 565 | + if ( isset( $form->options[$name] ) ) { |
|
| 566 | + $action->post_content[$name] = $form->options[$name]; |
|
| 567 | + unset( $form->options[$name] ); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - $action = $this->migrate_values($action, $form); |
|
| 571 | + $action = $this->migrate_values( $action, $form ); |
|
| 572 | 572 | |
| 573 | 573 | // check if action already exists |
| 574 | 574 | $post_id = get_posts( array( |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | 'numberposts' => 1, |
| 579 | 579 | ) ); |
| 580 | 580 | |
| 581 | - if ( empty($post_id) ) { |
|
| 581 | + if ( empty( $post_id ) ) { |
|
| 582 | 582 | // create action now |
| 583 | - $post_id = $this->save_settings($action); |
|
| 583 | + $post_id = $this->save_settings( $action ); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | if ( $post_id && 'update' == $update ) { |
| 587 | 587 | global $wpdb; |
| 588 | - $form->options = maybe_serialize($form->options); |
|
| 588 | + $form->options = maybe_serialize( $form->options ); |
|
| 589 | 589 | |
| 590 | 590 | // update form options |
| 591 | 591 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
| 592 | - wp_cache_delete( $form->id, 'frm_form'); |
|
| 592 | + wp_cache_delete( $form->id, 'frm_form' ); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | return $post_id; |
@@ -617,18 +617,18 @@ discard block |
||
| 617 | 617 | |
| 618 | 618 | $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] ); |
| 619 | 619 | |
| 620 | - $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); |
|
| 620 | + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] ); |
|
| 621 | 621 | |
| 622 | 622 | if ( $notification['conditions']['send_stop'] == 'send' ) { |
| 623 | 623 | $stop = $stop ? false : true; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | - $met[ $stop ] = $stop; |
|
| 626 | + $met[$stop] = $stop; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
| 630 | - $stop = ($notification['conditions']['send_stop'] == 'send'); |
|
| 631 | - } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) { |
|
| 630 | + $stop = ( $notification['conditions']['send_stop'] == 'send' ); |
|
| 631 | + } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) { |
|
| 632 | 632 | $stop = false; |
| 633 | 633 | } |
| 634 | 634 | |
@@ -665,8 +665,8 @@ discard block |
||
| 665 | 665 | private static function get_value_from_entry( $entry, $field_id ) { |
| 666 | 666 | $observed_value = ''; |
| 667 | 667 | |
| 668 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
| 669 | - $observed_value = $entry->metas[ $field_id ]; |
|
| 668 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
| 669 | + $observed_value = $entry->metas[$field_id]; |
|
| 670 | 670 | } else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
| 671 | 671 | $field = FrmField::getOne( $field_id ); |
| 672 | 672 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field, array( 'links' => false, 'truncate' => false ) ); |
@@ -1,251 +1,251 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('ABSPATH') ) { |
| 3 | - die('You are not allowed to call this page directly.'); |
|
| 3 | + die('You are not allowed to call this page directly.'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmForm { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return int|boolean id on success or false on failure |
|
| 10 | - */ |
|
| 11 | - public static function create( $values ) { |
|
| 12 | - global $wpdb; |
|
| 8 | + /** |
|
| 9 | + * @return int|boolean id on success or false on failure |
|
| 10 | + */ |
|
| 11 | + public static function create( $values ) { |
|
| 12 | + global $wpdb; |
|
| 13 | 13 | |
| 14 | - $new_values = array( |
|
| 14 | + $new_values = array( |
|
| 15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 16 | - 'name' => $values['name'], |
|
| 17 | - 'description' => $values['description'], |
|
| 18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 16 | + 'name' => $values['name'], |
|
| 17 | + 'description' => $values['description'], |
|
| 18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | - ); |
|
| 22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | + ); |
|
| 26 | 26 | |
| 27 | - $options = array(); |
|
| 27 | + $options = array(); |
|
| 28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 29 | 29 | |
| 30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 33 | 33 | |
| 34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | - $new_values['options'] = serialize($options); |
|
| 34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | + $new_values['options'] = serialize($options); |
|
| 36 | 36 | |
| 37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | - // $new_values['id'] = $values['id']; |
|
| 37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | + // $new_values['id'] = $values['id']; |
|
| 39 | 39 | |
| 40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 41 | 41 | |
| 42 | - $id = $wpdb->insert_id; |
|
| 42 | + $id = $wpdb->insert_id; |
|
| 43 | 43 | |
| 44 | 44 | // Clear form caching |
| 45 | 45 | self::clear_form_cache(); |
| 46 | 46 | |
| 47 | - return $id; |
|
| 48 | - } |
|
| 47 | + return $id; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return int|boolean ID on success or false on failure |
|
| 52 | - */ |
|
| 53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | - global $wpdb; |
|
| 50 | + /** |
|
| 51 | + * @return int|boolean ID on success or false on failure |
|
| 52 | + */ |
|
| 53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | + global $wpdb; |
|
| 55 | 55 | |
| 56 | - $values = self::getOne( $id, $blog_id ); |
|
| 57 | - if ( ! $values ) { |
|
| 58 | - return false; |
|
| 59 | - } |
|
| 56 | + $values = self::getOne( $id, $blog_id ); |
|
| 57 | + if ( ! $values ) { |
|
| 58 | + return false; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
| 61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
| 62 | 62 | |
| 63 | - $new_values = array( |
|
| 63 | + $new_values = array( |
|
| 64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 65 | - 'name' => $values->name, |
|
| 66 | - 'description' => $values->description, |
|
| 67 | - 'status' => $template ? 'published' : 'draft', |
|
| 68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | - 'created_at' => current_time('mysql', 1), |
|
| 71 | - 'is_template' => $template ? 1 : 0, |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - if ( $blog_id ) { |
|
| 75 | - $new_values['status'] = 'published'; |
|
| 76 | - $new_options = maybe_unserialize($values->options); |
|
| 77 | - $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | - $new_options['copy'] = false; |
|
| 79 | - $new_values['options'] = $new_options; |
|
| 80 | - } else { |
|
| 81 | - $new_values['options'] = $values->options; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if ( is_array($new_values['options']) ) { |
|
| 85 | - $new_values['options'] = serialize($new_values['options']); |
|
| 86 | - } |
|
| 65 | + 'name' => $values->name, |
|
| 66 | + 'description' => $values->description, |
|
| 67 | + 'status' => $template ? 'published' : 'draft', |
|
| 68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | + 'created_at' => current_time('mysql', 1), |
|
| 71 | + 'is_template' => $template ? 1 : 0, |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + if ( $blog_id ) { |
|
| 75 | + $new_values['status'] = 'published'; |
|
| 76 | + $new_options = maybe_unserialize($values->options); |
|
| 77 | + $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | + $new_options['copy'] = false; |
|
| 79 | + $new_values['options'] = $new_options; |
|
| 80 | + } else { |
|
| 81 | + $new_values['options'] = $values->options; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if ( is_array($new_values['options']) ) { |
|
| 85 | + $new_values['options'] = serialize($new_values['options']); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 89 | 89 | |
| 90 | - if ( $query_results ) { |
|
| 90 | + if ( $query_results ) { |
|
| 91 | 91 | // Clear form caching |
| 92 | 92 | self::clear_form_cache(); |
| 93 | 93 | |
| 94 | - $form_id = $wpdb->insert_id; |
|
| 95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 94 | + $form_id = $wpdb->insert_id; |
|
| 95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 96 | 96 | |
| 97 | - // update form settings after fields are created |
|
| 97 | + // update form settings after fields are created |
|
| 98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
| 99 | - return $form_id; |
|
| 100 | - } |
|
| 99 | + return $form_id; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return false; |
|
| 103 | - } |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | public static function after_duplicate( $form_id, $values ) { |
| 106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
| 106 | + $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
| 107 | 107 | |
| 108 | - if ( isset($new_opts['success_msg']) ) { |
|
| 109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 110 | - } |
|
| 108 | + if ( isset($new_opts['success_msg']) ) { |
|
| 109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 112 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 113 | 113 | |
| 114 | - if ( $new_opts != $values['options'] ) { |
|
| 115 | - global $wpdb; |
|
| 114 | + if ( $new_opts != $values['options'] ) { |
|
| 115 | + global $wpdb; |
|
| 116 | 116 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
| 117 | - } |
|
| 118 | - } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * @return int|boolean |
|
| 122 | - */ |
|
| 123 | - public static function update( $id, $values, $create_link = false ) { |
|
| 124 | - global $wpdb; |
|
| 120 | + /** |
|
| 121 | + * @return int|boolean |
|
| 122 | + */ |
|
| 123 | + public static function update( $id, $values, $create_link = false ) { |
|
| 124 | + global $wpdb; |
|
| 125 | 125 | |
| 126 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 127 | - $values['status'] = 'published'; |
|
| 128 | - } |
|
| 126 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 127 | + $values['status'] = 'published'; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - if ( isset($values['form_key']) ) { |
|
| 130 | + if ( isset($values['form_key']) ) { |
|
| 131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
| 134 | + $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
| 135 | 135 | |
| 136 | - $new_values = self::set_update_options( array(), $values); |
|
| 136 | + $new_values = self::set_update_options( array(), $values); |
|
| 137 | 137 | |
| 138 | - foreach ( $values as $value_key => $value ) { |
|
| 139 | - if ( in_array($value_key, $form_fields) ) { |
|
| 138 | + foreach ( $values as $value_key => $value ) { |
|
| 139 | + if ( in_array($value_key, $form_fields) ) { |
|
| 140 | 140 | $new_values[ $value_key ] = $value; |
| 141 | - } |
|
| 142 | - } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 145 | - $new_values['status'] = $values['new_status']; |
|
| 146 | - } |
|
| 144 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 145 | + $new_values['status'] = $values['new_status']; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - if ( ! empty( $new_values ) ) { |
|
| 148 | + if ( ! empty( $new_values ) ) { |
|
| 149 | 149 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
| 150 | - if ( $query_results ) { |
|
| 150 | + if ( $query_results ) { |
|
| 151 | 151 | self::clear_form_cache(); |
| 152 | - } |
|
| 153 | - } else { |
|
| 154 | - $query_results = true; |
|
| 155 | - } |
|
| 156 | - unset($new_values); |
|
| 152 | + } |
|
| 153 | + } else { |
|
| 154 | + $query_results = true; |
|
| 155 | + } |
|
| 156 | + unset($new_values); |
|
| 157 | 157 | |
| 158 | - $values = self::update_fields($id, $values); |
|
| 158 | + $values = self::update_fields($id, $values); |
|
| 159 | 159 | |
| 160 | 160 | do_action( 'frm_update_form', $id, $values ); |
| 161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
| 162 | 162 | |
| 163 | - return $query_results; |
|
| 164 | - } |
|
| 163 | + return $query_results; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * @return array |
|
| 168 | - */ |
|
| 166 | + /** |
|
| 167 | + * @return array |
|
| 168 | + */ |
|
| 169 | 169 | public static function set_update_options( $new_values, $values ) { |
| 170 | - if ( ! isset($values['options']) ) { |
|
| 171 | - return $new_values; |
|
| 172 | - } |
|
| 170 | + if ( ! isset($values['options']) ) { |
|
| 171 | + return $new_values; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - $options = array(); |
|
| 174 | + $options = array(); |
|
| 175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 176 | 176 | |
| 177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 177 | + $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 178 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 179 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 180 | + $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 181 | 181 | |
| 182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 183 | - $new_values['options'] = serialize($options); |
|
| 182 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 183 | + $new_values['options'] = serialize($options); |
|
| 184 | 184 | |
| 185 | - return $new_values; |
|
| 186 | - } |
|
| 185 | + return $new_values; |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * @return array |
|
| 191 | - */ |
|
| 189 | + /** |
|
| 190 | + * @return array |
|
| 191 | + */ |
|
| 192 | 192 | public static function update_fields( $id, $values ) { |
| 193 | 193 | |
| 194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 195 | - return $values; |
|
| 196 | - } |
|
| 194 | + if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 195 | + return $values; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 199 | - if ( empty($all_fields) ) { |
|
| 200 | - return $values; |
|
| 201 | - } |
|
| 198 | + $all_fields = FrmField::get_all_for_form($id); |
|
| 199 | + if ( empty($all_fields) ) { |
|
| 200 | + return $values; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - if ( ! isset($values['item_meta']) ) { |
|
| 204 | - $values['item_meta'] = array(); |
|
| 205 | - } |
|
| 203 | + if ( ! isset($values['item_meta']) ) { |
|
| 204 | + $values['item_meta'] = array(); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $field_array = array(); |
|
| 208 | - $existing_keys = array_keys($values['item_meta']); |
|
| 209 | - foreach ( $all_fields as $fid ) { |
|
| 210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 207 | + $field_array = array(); |
|
| 208 | + $existing_keys = array_keys($values['item_meta']); |
|
| 209 | + foreach ( $all_fields as $fid ) { |
|
| 210 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 211 | 211 | $values['item_meta'][ $fid->id ] = ''; |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | $field_array[ $fid->id ] = $fid; |
| 214 | - } |
|
| 215 | - unset($all_fields); |
|
| 214 | + } |
|
| 215 | + unset($all_fields); |
|
| 216 | 216 | |
| 217 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 217 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 218 | 218 | if ( isset( $field_array[ $field_id ] ) ) { |
| 219 | 219 | $field = $field_array[ $field_id ]; |
| 220 | - } else { |
|
| 221 | - $field = FrmField::getOne($field_id); |
|
| 222 | - } |
|
| 220 | + } else { |
|
| 221 | + $field = FrmField::getOne($field_id); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - if ( ! $field ) { |
|
| 225 | - continue; |
|
| 226 | - } |
|
| 224 | + if ( ! $field ) { |
|
| 225 | + continue; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
| 229 | - //updating the settings page |
|
| 229 | + //updating the settings page |
|
| 230 | 230 | if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
| 231 | 231 | $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
| 232 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 232 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 233 | 233 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 234 | - } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
| 235 | - $prev_opts = $field->field_options; |
|
| 236 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 237 | - if ( $prev_opts != $field->field_options ) { |
|
| 234 | + } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
| 235 | + $prev_opts = $field->field_options; |
|
| 236 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 237 | + if ( $prev_opts != $field->field_options ) { |
|
| 238 | 238 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 239 | - } |
|
| 240 | - unset($prev_opts); |
|
| 241 | - } |
|
| 242 | - } |
|
| 239 | + } |
|
| 240 | + unset($prev_opts); |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | 244 | if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
| 245 | - continue; |
|
| 246 | - } |
|
| 245 | + continue; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - //updating the form |
|
| 248 | + //updating the form |
|
| 249 | 249 | $update_options = array( |
| 250 | 250 | 'size', 'max', 'label', 'invalid', 'blank', |
| 251 | 251 | 'classes', 'captcha_size', 'default_blank', |
@@ -254,129 +254,129 @@ discard block |
||
| 254 | 254 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 255 | 255 | foreach ( $update_options as $opt ) { |
| 256 | 256 | $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( $values['field_options'][ $opt . '_' . $field_id ] ) : ''; |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | 259 | $field->field_options['required_indicator'] = isset( $values['field_options'][ 'required_indicator_' . $field_id ] ) ? trim( $values['field_options'][ 'required_indicator_' . $field_id ] ) : '*'; |
| 260 | 260 | $field->field_options['separate_value'] = isset( $values['field_options'][ 'separate_value_' . $field_id ] ) ? trim( $values['field_options'][ 'separate_value_' . $field_id ] ) : 0; |
| 261 | 261 | |
| 262 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 262 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 263 | 263 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
| 264 | 264 | $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
| 265 | 265 | $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
| 266 | 266 | $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
| 267 | 267 | $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
| 268 | 268 | |
| 269 | - FrmField::update($field_id, array( |
|
| 270 | - 'field_key' => $field_key, 'type' => $field_type, |
|
| 271 | - 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
| 272 | - 'description' => $field_description, 'required' => $required, |
|
| 273 | - ) ); |
|
| 269 | + FrmField::update($field_id, array( |
|
| 270 | + 'field_key' => $field_key, 'type' => $field_type, |
|
| 271 | + 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
| 272 | + 'description' => $field_description, 'required' => $required, |
|
| 273 | + ) ); |
|
| 274 | 274 | |
| 275 | - FrmField::delete_form_transient($field->form_id); |
|
| 276 | - } |
|
| 275 | + FrmField::delete_form_transient($field->form_id); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - return $values; |
|
| 279 | - } |
|
| 278 | + return $values; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * @param string $status |
|
| 283 | - * @return int|boolean |
|
| 284 | - */ |
|
| 281 | + /** |
|
| 282 | + * @param string $status |
|
| 283 | + * @return int|boolean |
|
| 284 | + */ |
|
| 285 | 285 | public static function set_status( $id, $status ) { |
| 286 | - if ( 'trash' == $status ) { |
|
| 287 | - return self::trash($id); |
|
| 288 | - } |
|
| 286 | + if ( 'trash' == $status ) { |
|
| 287 | + return self::trash($id); |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | 290 | $statuses = array( 'published', 'draft', 'trash' ); |
| 291 | - if ( ! in_array( $status, $statuses ) ) { |
|
| 292 | - return false; |
|
| 293 | - } |
|
| 291 | + if ( ! in_array( $status, $statuses ) ) { |
|
| 292 | + return false; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - global $wpdb; |
|
| 295 | + global $wpdb; |
|
| 296 | 296 | |
| 297 | - if ( is_array($id) ) { |
|
| 297 | + if ( is_array($id) ) { |
|
| 298 | 298 | $where = array( 'id' => $id ); |
| 299 | 299 | FrmDb::get_where_clause_and_values( $where ); |
| 300 | 300 | array_unshift( $where['values'], $status ); |
| 301 | 301 | |
| 302 | 302 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
| 303 | - } else { |
|
| 303 | + } else { |
|
| 304 | 304 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
| 305 | - } |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - if ( $query_results ) { |
|
| 307 | + if ( $query_results ) { |
|
| 308 | 308 | self::clear_form_cache(); |
| 309 | - } |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - return $query_results; |
|
| 312 | - } |
|
| 311 | + return $query_results; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 315 | - * @return int|boolean |
|
| 316 | - */ |
|
| 314 | + /** |
|
| 315 | + * @return int|boolean |
|
| 316 | + */ |
|
| 317 | 317 | public static function trash( $id ) { |
| 318 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
| 319 | - return self::destroy( $id ); |
|
| 320 | - } |
|
| 318 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
| 319 | + return self::destroy( $id ); |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - $form = self::getOne($id); |
|
| 323 | - if ( ! $form ) { |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 322 | + $form = self::getOne($id); |
|
| 323 | + if ( ! $form ) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - $options = $form->options; |
|
| 328 | - $options['trash_time'] = time(); |
|
| 327 | + $options = $form->options; |
|
| 328 | + $options['trash_time'] = time(); |
|
| 329 | 329 | |
| 330 | - global $wpdb; |
|
| 331 | - $query_results = $wpdb->update( |
|
| 330 | + global $wpdb; |
|
| 331 | + $query_results = $wpdb->update( |
|
| 332 | 332 | $wpdb->prefix . 'frm_forms', |
| 333 | 333 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
| 334 | 334 | array( 'id' => $id ) |
| 335 | - ); |
|
| 335 | + ); |
|
| 336 | 336 | |
| 337 | - if ( $query_results ) { |
|
| 337 | + if ( $query_results ) { |
|
| 338 | 338 | self::clear_form_cache(); |
| 339 | - } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - return $query_results; |
|
| 342 | - } |
|
| 341 | + return $query_results; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * @return int|boolean |
|
| 346 | - */ |
|
| 344 | + /** |
|
| 345 | + * @return int|boolean |
|
| 346 | + */ |
|
| 347 | 347 | public static function destroy( $id ) { |
| 348 | - global $wpdb; |
|
| 348 | + global $wpdb; |
|
| 349 | 349 | |
| 350 | - $form = self::getOne($id); |
|
| 351 | - if ( ! $form ) { |
|
| 352 | - return false; |
|
| 353 | - } |
|
| 350 | + $form = self::getOne($id); |
|
| 351 | + if ( ! $form ) { |
|
| 352 | + return false; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - // Disconnect the entries from this form |
|
| 355 | + // Disconnect the entries from this form |
|
| 356 | 356 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 357 | - foreach ( $entries as $entry_id ) { |
|
| 358 | - FrmEntry::destroy($entry_id); |
|
| 359 | - unset($entry_id); |
|
| 360 | - } |
|
| 357 | + foreach ( $entries as $entry_id ) { |
|
| 358 | + FrmEntry::destroy($entry_id); |
|
| 359 | + unset($entry_id); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - // Disconnect the fields from this form |
|
| 362 | + // Disconnect the fields from this form |
|
| 363 | 363 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
| 364 | 364 | |
| 365 | 365 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
| 366 | - if ( $query_results ) { |
|
| 367 | - // Delete all form actions linked to this form |
|
| 368 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 369 | - $action_control->destroy($id, 'all'); |
|
| 366 | + if ( $query_results ) { |
|
| 367 | + // Delete all form actions linked to this form |
|
| 368 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 369 | + $action_control->destroy($id, 'all'); |
|
| 370 | 370 | |
| 371 | 371 | // Clear form caching |
| 372 | 372 | self::clear_form_cache(); |
| 373 | 373 | |
| 374 | 374 | do_action( 'frm_destroy_form', $id ); |
| 375 | 375 | do_action( 'frm_destroy_form_' . $id ); |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - return $query_results; |
|
| 379 | - } |
|
| 378 | + return $query_results; |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * Delete trashed forms based on how long they have been trashed |
@@ -408,49 +408,49 @@ discard block |
||
| 408 | 408 | return $count; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - /** |
|
| 412 | - * @return string form name |
|
| 413 | - */ |
|
| 414 | - public static function &getName( $id ) { |
|
| 415 | - global $wpdb; |
|
| 416 | - |
|
| 417 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 418 | - if ( $form ) { |
|
| 419 | - $r = stripslashes($form->name); |
|
| 420 | - return $r; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 424 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 425 | - $r = stripslashes($r); |
|
| 426 | - |
|
| 427 | - return $r; |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * @param string $key |
|
| 432 | - * @return int form id |
|
| 433 | - */ |
|
| 411 | + /** |
|
| 412 | + * @return string form name |
|
| 413 | + */ |
|
| 414 | + public static function &getName( $id ) { |
|
| 415 | + global $wpdb; |
|
| 416 | + |
|
| 417 | + $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 418 | + if ( $form ) { |
|
| 419 | + $r = stripslashes($form->name); |
|
| 420 | + return $r; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 424 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 425 | + $r = stripslashes($r); |
|
| 426 | + |
|
| 427 | + return $r; |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * @param string $key |
|
| 432 | + * @return int form id |
|
| 433 | + */ |
|
| 434 | 434 | public static function &getIdByKey( $key ) { |
| 435 | - $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
| 436 | - return $id; |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * @param int $id |
|
| 441 | - * @return string form key |
|
| 442 | - */ |
|
| 435 | + $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
| 436 | + return $id; |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * @param int $id |
|
| 441 | + * @return string form key |
|
| 442 | + */ |
|
| 443 | 443 | public static function &getKeyById( $id ) { |
| 444 | - $id = (int) $id; |
|
| 445 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 446 | - if ( $cache ) { |
|
| 447 | - return $cache->form_key; |
|
| 448 | - } |
|
| 444 | + $id = (int) $id; |
|
| 445 | + $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 446 | + if ( $cache ) { |
|
| 447 | + return $cache->form_key; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 450 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 451 | 451 | |
| 452 | - return $key; |
|
| 453 | - } |
|
| 452 | + return $key; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | /** |
| 456 | 456 | * If $form is numeric, get the form object |
@@ -463,47 +463,47 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - /** |
|
| 467 | - * @return object form |
|
| 468 | - */ |
|
| 469 | - public static function getOne( $id, $blog_id = false ) { |
|
| 470 | - global $wpdb; |
|
| 466 | + /** |
|
| 467 | + * @return object form |
|
| 468 | + */ |
|
| 469 | + public static function getOne( $id, $blog_id = false ) { |
|
| 470 | + global $wpdb; |
|
| 471 | 471 | |
| 472 | - if ( $blog_id && is_multisite() ) { |
|
| 473 | - global $wpmuBaseTablePrefix; |
|
| 472 | + if ( $blog_id && is_multisite() ) { |
|
| 473 | + global $wpmuBaseTablePrefix; |
|
| 474 | 474 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
| 475 | 475 | |
| 476 | 476 | $table_name = $prefix . 'frm_forms'; |
| 477 | - } else { |
|
| 477 | + } else { |
|
| 478 | 478 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 479 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 480 | - if ( $cache ) { |
|
| 481 | - if ( isset($cache->options) ) { |
|
| 482 | - $cache->options = maybe_unserialize($cache->options); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - return stripslashes_deep($cache); |
|
| 486 | - } |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - if ( is_numeric($id) ) { |
|
| 490 | - $where = array( 'id' => $id ); |
|
| 491 | - } else { |
|
| 492 | - $where = array( 'form_key' => $id ); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - $results = FrmDb::get_row( $table_name, $where ); |
|
| 496 | - |
|
| 497 | - if ( isset($results->options) ) { |
|
| 498 | - wp_cache_set($results->id, $results, 'frm_form'); |
|
| 499 | - $results->options = maybe_unserialize($results->options); |
|
| 500 | - } |
|
| 501 | - return stripslashes_deep($results); |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - /** |
|
| 505 | - * @return object|array of objects |
|
| 506 | - */ |
|
| 479 | + $cache = wp_cache_get($id, 'frm_form'); |
|
| 480 | + if ( $cache ) { |
|
| 481 | + if ( isset($cache->options) ) { |
|
| 482 | + $cache->options = maybe_unserialize($cache->options); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + return stripslashes_deep($cache); |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + if ( is_numeric($id) ) { |
|
| 490 | + $where = array( 'id' => $id ); |
|
| 491 | + } else { |
|
| 492 | + $where = array( 'form_key' => $id ); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + $results = FrmDb::get_row( $table_name, $where ); |
|
| 496 | + |
|
| 497 | + if ( isset($results->options) ) { |
|
| 498 | + wp_cache_set($results->id, $results, 'frm_form'); |
|
| 499 | + $results->options = maybe_unserialize($results->options); |
|
| 500 | + } |
|
| 501 | + return stripslashes_deep($results); |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + /** |
|
| 505 | + * @return object|array of objects |
|
| 506 | + */ |
|
| 507 | 507 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
| 508 | 508 | if ( is_array( $where ) && ! empty( $where ) ) { |
| 509 | 509 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) ); |
@@ -527,8 +527,8 @@ discard block |
||
| 527 | 527 | $results = reset( $results ); |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - return stripslashes_deep($results); |
|
| 531 | - } |
|
| 530 | + return stripslashes_deep($results); |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | 534 | * Get all published forms |
@@ -546,47 +546,47 @@ discard block |
||
| 546 | 546 | return $forms; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - /** |
|
| 550 | - * @return int count of forms |
|
| 551 | - */ |
|
| 552 | - public static function &get_count() { |
|
| 553 | - global $wpdb; |
|
| 549 | + /** |
|
| 550 | + * @return int count of forms |
|
| 551 | + */ |
|
| 552 | + public static function &get_count() { |
|
| 553 | + global $wpdb; |
|
| 554 | 554 | |
| 555 | - $cache_key = 'frm_form_counts'; |
|
| 555 | + $cache_key = 'frm_form_counts'; |
|
| 556 | 556 | |
| 557 | - $counts = wp_cache_get( $cache_key, 'counts' ); |
|
| 558 | - if ( false !== $counts ) { |
|
| 559 | - return $counts; |
|
| 560 | - } |
|
| 557 | + $counts = wp_cache_get( $cache_key, 'counts' ); |
|
| 558 | + if ( false !== $counts ) { |
|
| 559 | + return $counts; |
|
| 560 | + } |
|
| 561 | 561 | |
| 562 | - $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
| 562 | + $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
| 563 | 563 | |
| 564 | 564 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
| 565 | - $counts = array_fill_keys( $statuses, 0 ); |
|
| 565 | + $counts = array_fill_keys( $statuses, 0 ); |
|
| 566 | 566 | |
| 567 | - foreach ( $results as $row ) { |
|
| 568 | - if ( 'trash' != $row->status ) { |
|
| 569 | - if ( $row->is_template ) { |
|
| 567 | + foreach ( $results as $row ) { |
|
| 568 | + if ( 'trash' != $row->status ) { |
|
| 569 | + if ( $row->is_template ) { |
|
| 570 | 570 | $counts['template']++; |
| 571 | - } else { |
|
| 571 | + } else { |
|
| 572 | 572 | $counts['published']++; |
| 573 | - } |
|
| 574 | - } else { |
|
| 573 | + } |
|
| 574 | + } else { |
|
| 575 | 575 | $counts['trash']++; |
| 576 | - } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - if ( 'draft' == $row->status ) { |
|
| 578 | + if ( 'draft' == $row->status ) { |
|
| 579 | 579 | $counts['draft']++; |
| 580 | - } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - unset($row); |
|
| 583 | - } |
|
| 582 | + unset($row); |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - $counts = (object) $counts; |
|
| 586 | - wp_cache_set( $cache_key, $counts, 'counts' ); |
|
| 585 | + $counts = (object) $counts; |
|
| 586 | + wp_cache_set( $cache_key, $counts, 'counts' ); |
|
| 587 | 587 | |
| 588 | - return $counts; |
|
| 589 | - } |
|
| 588 | + return $counts; |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | 591 | /** |
| 592 | 592 | * Clear form caching |
@@ -599,14 +599,14 @@ discard block |
||
| 599 | 599 | FrmAppHelper::cache_delete_group( 'frm_form' ); |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * @return array of errors |
|
| 604 | - */ |
|
| 602 | + /** |
|
| 603 | + * @return array of errors |
|
| 604 | + */ |
|
| 605 | 605 | public static function validate( $values ) { |
| 606 | - $errors = array(); |
|
| 606 | + $errors = array(); |
|
| 607 | 607 | |
| 608 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 609 | - } |
|
| 608 | + return apply_filters('frm_validate_form', $errors, $values); |
|
| 609 | + } |
|
| 610 | 610 | |
| 611 | 611 | public static function get_params( $form = null ) { |
| 612 | 612 | global $frm_vars; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 3 | - die('You are not allowed to call this page directly.'); |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + die( 'You are not allowed to call this page directly.' ); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmForm { |
@@ -15,24 +15,24 @@ discard block |
||
| 15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 16 | 16 | 'name' => $values['name'], |
| 17 | 17 | 'description' => $values['description'], |
| 18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
| 19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
| 20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
| 21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
| 23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
| 24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | 27 | $options = array(); |
| 28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 29 | 29 | |
| 30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
| 31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
| 32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
| 33 | 33 | |
| 34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | - $new_values['options'] = serialize($options); |
|
| 34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
| 35 | + $new_values['options'] = serialize( $options ); |
|
| 36 | 36 | |
| 37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
| 38 | 38 | // $new_values['id'] = $values['id']; |
@@ -67,22 +67,22 @@ discard block |
||
| 67 | 67 | 'status' => $template ? 'published' : 'draft', |
| 68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
| 69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
| 70 | - 'created_at' => current_time('mysql', 1), |
|
| 70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
| 71 | 71 | 'is_template' => $template ? 1 : 0, |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | if ( $blog_id ) { |
| 75 | 75 | $new_values['status'] = 'published'; |
| 76 | - $new_options = maybe_unserialize($values->options); |
|
| 77 | - $new_options['email_to'] = get_option('admin_email'); |
|
| 76 | + $new_options = maybe_unserialize( $values->options ); |
|
| 77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
| 78 | 78 | $new_options['copy'] = false; |
| 79 | 79 | $new_values['options'] = $new_options; |
| 80 | 80 | } else { |
| 81 | 81 | $new_values['options'] = $values->options; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if ( is_array($new_values['options']) ) { |
|
| 85 | - $new_values['options'] = serialize($new_values['options']); |
|
| 84 | + if ( is_array( $new_values['options'] ) ) { |
|
| 85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | self::clear_form_cache(); |
| 93 | 93 | |
| 94 | 94 | $form_id = $wpdb->insert_id; |
| 95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
| 96 | 96 | |
| 97 | 97 | // update form settings after fields are created |
| 98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public static function after_duplicate( $form_id, $values ) { |
| 106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
| 106 | + $new_opts = $values['options'] = maybe_unserialize( $values['options'] ); |
|
| 107 | 107 | |
| 108 | - if ( isset($new_opts['success_msg']) ) { |
|
| 109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 108 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
| 109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 112 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
| 113 | 113 | |
| 114 | 114 | if ( $new_opts != $values['options'] ) { |
| 115 | 115 | global $wpdb; |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | $values['status'] = 'published'; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( isset($values['form_key']) ) { |
|
| 130 | + if ( isset( $values['form_key'] ) ) { |
|
| 131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
| 135 | 135 | |
| 136 | - $new_values = self::set_update_options( array(), $values); |
|
| 136 | + $new_values = self::set_update_options( array(), $values ); |
|
| 137 | 137 | |
| 138 | 138 | foreach ( $values as $value_key => $value ) { |
| 139 | - if ( in_array($value_key, $form_fields) ) { |
|
| 140 | - $new_values[ $value_key ] = $value; |
|
| 139 | + if ( in_array( $value_key, $form_fields ) ) { |
|
| 140 | + $new_values[$value_key] = $value; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | } else { |
| 154 | 154 | $query_results = true; |
| 155 | 155 | } |
| 156 | - unset($new_values); |
|
| 156 | + unset( $new_values ); |
|
| 157 | 157 | |
| 158 | - $values = self::update_fields($id, $values); |
|
| 158 | + $values = self::update_fields( $id, $values ); |
|
| 159 | 159 | |
| 160 | 160 | do_action( 'frm_update_form', $id, $values ); |
| 161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -167,20 +167,20 @@ discard block |
||
| 167 | 167 | * @return array |
| 168 | 168 | */ |
| 169 | 169 | public static function set_update_options( $new_values, $values ) { |
| 170 | - if ( ! isset($values['options']) ) { |
|
| 170 | + if ( ! isset( $values['options'] ) ) { |
|
| 171 | 171 | return $new_values; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $options = array(); |
| 175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 176 | 176 | |
| 177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 177 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
| 178 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
| 179 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
| 180 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
| 181 | 181 | |
| 182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 183 | - $new_values['options'] = serialize($options); |
|
| 182 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
| 183 | + $new_values['options'] = serialize( $options ); |
|
| 184 | 184 | |
| 185 | 185 | return $new_values; |
| 186 | 186 | } |
@@ -191,54 +191,54 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public static function update_fields( $id, $values ) { |
| 193 | 193 | |
| 194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 194 | + if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
| 195 | 195 | return $values; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 199 | - if ( empty($all_fields) ) { |
|
| 198 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
| 199 | + if ( empty( $all_fields ) ) { |
|
| 200 | 200 | return $values; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( ! isset($values['item_meta']) ) { |
|
| 203 | + if ( ! isset( $values['item_meta'] ) ) { |
|
| 204 | 204 | $values['item_meta'] = array(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $field_array = array(); |
| 208 | - $existing_keys = array_keys($values['item_meta']); |
|
| 208 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
| 209 | 209 | foreach ( $all_fields as $fid ) { |
| 210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 211 | - $values['item_meta'][ $fid->id ] = ''; |
|
| 210 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
| 211 | + $values['item_meta'][$fid->id] = ''; |
|
| 212 | 212 | } |
| 213 | - $field_array[ $fid->id ] = $fid; |
|
| 213 | + $field_array[$fid->id] = $fid; |
|
| 214 | 214 | } |
| 215 | - unset($all_fields); |
|
| 215 | + unset( $all_fields ); |
|
| 216 | 216 | |
| 217 | 217 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
| 218 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
| 219 | - $field = $field_array[ $field_id ]; |
|
| 218 | + if ( isset( $field_array[$field_id] ) ) { |
|
| 219 | + $field = $field_array[$field_id]; |
|
| 220 | 220 | } else { |
| 221 | - $field = FrmField::getOne($field_id); |
|
| 221 | + $field = FrmField::getOne( $field_id ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ( ! $field ) { |
| 225 | 225 | continue; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
| 228 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
| 229 | 229 | if ( $is_settings_page ) { |
| 230 | 230 | //updating the settings page |
| 231 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
| 232 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
| 233 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 231 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
| 232 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
| 233 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 234 | 234 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 235 | 235 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
| 236 | 236 | $prev_opts = $field->field_options; |
| 237 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 237 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 238 | 238 | if ( $prev_opts != $field->field_options ) { |
| 239 | 239 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 240 | 240 | } |
| 241 | - unset($prev_opts); |
|
| 241 | + unset( $prev_opts ); |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 253 | 253 | |
| 254 | 254 | foreach ( $update_options as $opt => $default ) { |
| 255 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
| 255 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 259 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
| 260 | - $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
|
| 261 | - $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
|
| 262 | - $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
|
| 263 | - $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
|
| 258 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
| 259 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
| 260 | + $field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key; |
|
| 261 | + $required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false; |
|
| 262 | + $field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type; |
|
| 263 | + $field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description; |
|
| 264 | 264 | |
| 265 | - FrmField::update($field_id, array( |
|
| 265 | + FrmField::update( $field_id, array( |
|
| 266 | 266 | 'field_key' => $field_key, 'type' => $field_type, |
| 267 | 267 | 'default_value' => $default_value, 'field_options' => $field->field_options, |
| 268 | 268 | 'description' => $field_description, 'required' => $required, |
| 269 | 269 | ) ); |
| 270 | 270 | |
| 271 | - FrmField::delete_form_transient($field->form_id); |
|
| 271 | + FrmField::delete_form_transient( $field->form_id ); |
|
| 272 | 272 | } |
| 273 | 273 | self::clear_form_cache(); |
| 274 | 274 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public static function set_status( $id, $status ) { |
| 283 | 283 | if ( 'trash' == $status ) { |
| 284 | - return self::trash($id); |
|
| 284 | + return self::trash( $id ); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
| 287 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
| 288 | 288 | if ( ! in_array( $status, $statuses ) ) { |
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | global $wpdb; |
| 293 | 293 | |
| 294 | - if ( is_array($id) ) { |
|
| 294 | + if ( is_array( $id ) ) { |
|
| 295 | 295 | $where = array( 'id' => $id ); |
| 296 | 296 | FrmDb::get_where_clause_and_values( $where ); |
| 297 | 297 | array_unshift( $where['values'], $status ); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | return self::destroy( $id ); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $form = self::getOne($id); |
|
| 319 | + $form = self::getOne( $id ); |
|
| 320 | 320 | if ( ! $form ) { |
| 321 | 321 | return false; |
| 322 | 322 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | public static function destroy( $id ) { |
| 345 | 345 | global $wpdb; |
| 346 | 346 | |
| 347 | - $form = self::getOne($id); |
|
| 347 | + $form = self::getOne( $id ); |
|
| 348 | 348 | if ( ! $form ) { |
| 349 | 349 | return false; |
| 350 | 350 | } |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | // Disconnect the entries from this form |
| 354 | 354 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 355 | 355 | foreach ( $entries as $entry_id ) { |
| 356 | - FrmEntry::destroy($entry_id); |
|
| 357 | - unset($entry_id); |
|
| 356 | + FrmEntry::destroy( $entry_id ); |
|
| 357 | + unset( $entry_id ); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | // Disconnect the fields from this form |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | if ( $query_results ) { |
| 365 | 365 | // Delete all form actions linked to this form |
| 366 | 366 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 367 | - $action_control->destroy($id, 'all'); |
|
| 367 | + $action_control->destroy( $id, 'all' ); |
|
| 368 | 368 | |
| 369 | 369 | // Clear form caching |
| 370 | 370 | self::clear_form_cache(); |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $form->options = maybe_unserialize( $form->options ); |
| 399 | 399 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
| 400 | 400 | self::destroy( $form->id ); |
| 401 | - $count++; |
|
| 401 | + $count ++; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | unset( $form ); |
@@ -412,15 +412,15 @@ discard block |
||
| 412 | 412 | public static function &getName( $id ) { |
| 413 | 413 | global $wpdb; |
| 414 | 414 | |
| 415 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 415 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 416 | 416 | if ( $form ) { |
| 417 | - $r = stripslashes($form->name); |
|
| 417 | + $r = stripslashes( $form->name ); |
|
| 418 | 418 | return $r; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
| 422 | 422 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
| 423 | - $r = stripslashes($r); |
|
| 423 | + $r = stripslashes( $r ); |
|
| 424 | 424 | |
| 425 | 425 | return $r; |
| 426 | 426 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | public static function &getKeyById( $id ) { |
| 442 | 442 | $id = (int) $id; |
| 443 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 443 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 444 | 444 | if ( $cache ) { |
| 445 | 445 | return $cache->form_key; |
| 446 | 446 | } |
@@ -474,17 +474,17 @@ discard block |
||
| 474 | 474 | $table_name = $prefix . 'frm_forms'; |
| 475 | 475 | } else { |
| 476 | 476 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 477 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 477 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
| 478 | 478 | if ( $cache ) { |
| 479 | - if ( isset($cache->options) ) { |
|
| 480 | - $cache->options = maybe_unserialize($cache->options); |
|
| 479 | + if ( isset( $cache->options ) ) { |
|
| 480 | + $cache->options = maybe_unserialize( $cache->options ); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - return stripslashes_deep($cache); |
|
| 483 | + return stripslashes_deep( $cache ); |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( is_numeric($id) ) { |
|
| 487 | + if ( is_numeric( $id ) ) { |
|
| 488 | 488 | $where = array( 'id' => $id ); |
| 489 | 489 | } else { |
| 490 | 490 | $where = array( 'form_key' => $id ); |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | $results = FrmDb::get_row( $table_name, $where ); |
| 494 | 494 | |
| 495 | - if ( isset($results->options) ) { |
|
| 496 | - wp_cache_set($results->id, $results, 'frm_form'); |
|
| 497 | - $results->options = maybe_unserialize($results->options); |
|
| 495 | + if ( isset( $results->options ) ) { |
|
| 496 | + wp_cache_set( $results->id, $results, 'frm_form' ); |
|
| 497 | + $results->options = maybe_unserialize( $results->options ); |
|
| 498 | 498 | } |
| 499 | - return stripslashes_deep($results); |
|
| 499 | + return stripslashes_deep( $results ); |
|
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | /** |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | $results = reset( $results ); |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - return stripslashes_deep($results); |
|
| 528 | + return stripslashes_deep( $results ); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -565,19 +565,19 @@ discard block |
||
| 565 | 565 | foreach ( $results as $row ) { |
| 566 | 566 | if ( 'trash' != $row->status ) { |
| 567 | 567 | if ( $row->is_template ) { |
| 568 | - $counts['template']++; |
|
| 568 | + $counts['template'] ++; |
|
| 569 | 569 | } else { |
| 570 | - $counts['published']++; |
|
| 570 | + $counts['published'] ++; |
|
| 571 | 571 | } |
| 572 | 572 | } else { |
| 573 | - $counts['trash']++; |
|
| 573 | + $counts['trash'] ++; |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | if ( 'draft' == $row->status ) { |
| 577 | - $counts['draft']++; |
|
| 577 | + $counts['draft'] ++; |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - unset($row); |
|
| 580 | + unset( $row ); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | $counts = (object) $counts; |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | public static function validate( $values ) { |
| 604 | 604 | $errors = array(); |
| 605 | 605 | |
| 606 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 606 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | public static function get_params( $form = null ) { |
@@ -615,11 +615,11 @@ discard block |
||
| 615 | 615 | self::maybe_get_form( $form ); |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
| 619 | - return $frm_vars['form_params'][ $form->id ]; |
|
| 618 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
| 619 | + return $frm_vars['form_params'][$form->id]; |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 622 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 623 | 623 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
| 624 | 624 | |
| 625 | 625 | $default_values = array( |
@@ -637,15 +637,15 @@ discard block |
||
| 637 | 637 | //if there are two forms on the same page, make sure not to submit both |
| 638 | 638 | foreach ( $default_values as $var => $default ) { |
| 639 | 639 | if ( $var == 'action' ) { |
| 640 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 640 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 641 | 641 | } else { |
| 642 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 642 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 643 | 643 | } |
| 644 | 644 | unset( $var, $default ); |
| 645 | 645 | } |
| 646 | 646 | } else { |
| 647 | 647 | foreach ( $default_values as $var => $default ) { |
| 648 | - $values[ $var ] = $default; |
|
| 648 | + $values[$var] = $default; |
|
| 649 | 649 | unset( $var, $default ); |
| 650 | 650 | } |
| 651 | 651 | } |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | public static function list_page_params() { |
| 661 | 661 | $values = array(); |
| 662 | 662 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
| 663 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 663 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | return $values; |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
| 681 | 681 | 'keep_post' => '', |
| 682 | 682 | ) as $var => $default ) { |
| 683 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 683 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | return $values; |
@@ -722,16 +722,16 @@ discard block |
||
| 722 | 722 | $small_form = new stdClass(); |
| 723 | 723 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
| 724 | 724 | $small_form->{$var} = $form->{$var}; |
| 725 | - unset($var); |
|
| 725 | + unset( $var ); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $frm_vars['forms_loaded'][] = $small_form; |
| 729 | 729 | |
| 730 | - if ( $this_load && empty($global_load) ) { |
|
| 730 | + if ( $this_load && empty( $global_load ) ) { |
|
| 731 | 731 | $global_load = $frm_vars['load_css'] = true; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 734 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | public static function show_submit( $form ) { |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmFormsListHelper extends FrmListHelper { |
| 7 | - var $status = ''; |
|
| 7 | + var $status = ''; |
|
| 8 | 8 | |
| 9 | 9 | public function __construct( $args ) { |
| 10 | 10 | $this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function prepare_items() { |
| 16 | - global $wpdb, $per_page, $mode; |
|
| 16 | + global $wpdb, $per_page, $mode; |
|
| 17 | 17 | |
| 18 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
| 18 | + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
| 19 | 19 | |
| 20 | 20 | $default_orderby = 'name'; |
| 21 | 21 | $default_order = 'ASC'; |
| 22 | 22 | |
| 23 | - $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
| 23 | + $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
| 24 | 24 | $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order; |
| 25 | 25 | |
| 26 | 26 | $page = $this->get_pagenum(); |
@@ -28,40 +28,40 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
| 30 | 30 | |
| 31 | - $s_query = array(); |
|
| 32 | - $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
| 31 | + $s_query = array(); |
|
| 32 | + $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
| 33 | 33 | switch ( $this->status ) { |
| 34 | - case 'template': |
|
| 35 | - $s_query['is_template'] = 1; |
|
| 36 | - $s_query['status !'] = 'trash'; |
|
| 37 | - break; |
|
| 38 | - case 'draft': |
|
| 39 | - $s_query['is_template'] = 0; |
|
| 40 | - $s_query['status'] = 'draft'; |
|
| 41 | - break; |
|
| 42 | - case 'trash': |
|
| 43 | - $s_query['status'] = 'trash'; |
|
| 44 | - break; |
|
| 45 | - default: |
|
| 46 | - $s_query['is_template'] = 0; |
|
| 47 | - $s_query['status !'] = 'trash'; |
|
| 48 | - break; |
|
| 34 | + case 'template': |
|
| 35 | + $s_query['is_template'] = 1; |
|
| 36 | + $s_query['status !'] = 'trash'; |
|
| 37 | + break; |
|
| 38 | + case 'draft': |
|
| 39 | + $s_query['is_template'] = 0; |
|
| 40 | + $s_query['status'] = 'draft'; |
|
| 41 | + break; |
|
| 42 | + case 'trash': |
|
| 43 | + $s_query['status'] = 'trash'; |
|
| 44 | + break; |
|
| 45 | + default: |
|
| 46 | + $s_query['is_template'] = 0; |
|
| 47 | + $s_query['status !'] = 'trash'; |
|
| 48 | + break; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 52 | - if ( $s != '' ) { |
|
| 53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | - $search_terms = array_map('trim', $matches[0]); |
|
| 55 | - foreach ( (array) $search_terms as $term ) { |
|
| 56 | - $s_query[] = array( |
|
| 57 | - 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
| 58 | - ); |
|
| 59 | - unset($term); |
|
| 60 | - } |
|
| 61 | - } |
|
| 51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 52 | + if ( $s != '' ) { |
|
| 53 | + preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | + $search_terms = array_map('trim', $matches[0]); |
|
| 55 | + foreach ( (array) $search_terms as $term ) { |
|
| 56 | + $s_query[] = array( |
|
| 57 | + 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
| 58 | + ); |
|
| 59 | + unset($term); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); |
| 64 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 64 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
| 65 | 65 | |
| 66 | 66 | $this->set_pagination_args( array( |
| 67 | 67 | 'total_items' => $total_items, |
@@ -70,69 +70,69 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function no_items() { |
| 73 | - if ( 'template' == $this->status ) { |
|
| 74 | - _e( 'No Templates Found.', 'formidable' ) ?> |
|
| 73 | + if ( 'template' == $this->status ) { |
|
| 74 | + _e( 'No Templates Found.', 'formidable' ) ?> |
|
| 75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
| 76 | 76 | <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
| 77 | 77 | <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
| 78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
| 79 | 79 | </ol> |
| 80 | 80 | <?php } else { |
| 81 | - _e( 'No Forms Found.', 'formidable' ) ?> |
|
| 81 | + _e( 'No Forms Found.', 'formidable' ) ?> |
|
| 82 | 82 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a> |
| 83 | 83 | <?php } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function get_bulk_actions() { |
| 87 | - $actions = array(); |
|
| 87 | + $actions = array(); |
|
| 88 | 88 | |
| 89 | 89 | if ( in_array( $this->status, array( '', 'published' ) ) ) { |
| 90 | - $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if ( 'trash' == $this->status ) { |
|
| 94 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 95 | - $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 99 | - $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 100 | - } |
|
| 101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 102 | - $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - return $actions; |
|
| 108 | - } |
|
| 90 | + $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if ( 'trash' == $this->status ) { |
|
| 94 | + if ( current_user_can('frm_edit_forms') ) { |
|
| 95 | + $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if ( current_user_can('frm_delete_forms') ) { |
|
| 99 | + $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
| 100 | + } |
|
| 101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 102 | + $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
| 103 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | + $actions['bulk_delete'] = __( 'Delete'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + return $actions; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | public function extra_tablenav( $which ) { |
| 111 | - if ( 'top' != $which ) { |
|
| 112 | - return; |
|
| 113 | - } |
|
| 111 | + if ( 'top' != $which ) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 115 | + if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 116 | 116 | ?> |
| 117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
| 118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
| 119 | 119 | </div> |
| 120 | 120 | <?php |
| 121 | - return; |
|
| 122 | - } |
|
| 121 | + return; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - if ( 'template' != $this->status ) { |
|
| 125 | - return; |
|
| 126 | - } |
|
| 124 | + if ( 'template' != $this->status ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
| 130 | 130 | |
| 131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 132 | - $args = array( |
|
| 133 | - 'frm_action' => 'duplicate', |
|
| 134 | - 'template' => true, |
|
| 135 | - ); |
|
| 131 | + $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 132 | + $args = array( |
|
| 133 | + 'frm_action' => 'duplicate', |
|
| 134 | + 'template' => true, |
|
| 135 | + ); |
|
| 136 | 136 | |
| 137 | 137 | ?> |
| 138 | 138 | <div class="alignleft actions frm_visible_overflow"> |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a> |
| 141 | 141 | <ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop"> |
| 142 | 142 | <?php |
| 143 | - if ( empty( $forms ) ) { ?> |
|
| 143 | + if ( empty( $forms ) ) { ?> |
|
| 144 | 144 | <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li> |
| 145 | 145 | <?php |
| 146 | - } else { |
|
| 147 | - foreach ( $forms as $form ) { |
|
| 148 | - $args['id'] = $form->id; ?> |
|
| 146 | + } else { |
|
| 147 | + foreach ( $forms as $form ) { |
|
| 148 | + $args['id'] = $form->id; ?> |
|
| 149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
| 150 | 150 | <?php |
| 151 | - unset($form); |
|
| 151 | + unset($form); |
|
| 152 | 152 | } |
| 153 | - } |
|
| 154 | - ?> |
|
| 153 | + } |
|
| 154 | + ?> |
|
| 155 | 155 | </ul> |
| 156 | 156 | </div> |
| 157 | 157 | </div> |
@@ -161,30 +161,30 @@ discard block |
||
| 161 | 161 | public function get_views() { |
| 162 | 162 | |
| 163 | 163 | $statuses = array( |
| 164 | - 'published' => __( 'My Forms', 'formidable' ), |
|
| 165 | - 'template' => __( 'Templates', 'formidable' ), |
|
| 166 | - 'draft' => __( 'Drafts', 'formidable' ), |
|
| 167 | - 'trash' => __( 'Trash', 'formidable' ), |
|
| 164 | + 'published' => __( 'My Forms', 'formidable' ), |
|
| 165 | + 'template' => __( 'Templates', 'formidable' ), |
|
| 166 | + 'draft' => __( 'Drafts', 'formidable' ), |
|
| 167 | + 'trash' => __( 'Trash', 'formidable' ), |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - $links = array(); |
|
| 171 | - $counts = FrmForm::get_count(); |
|
| 172 | - $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
| 170 | + $links = array(); |
|
| 171 | + $counts = FrmForm::get_count(); |
|
| 172 | + $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
| 173 | 173 | |
| 174 | - foreach ( $statuses as $status => $name ) { |
|
| 174 | + foreach ( $statuses as $status => $name ) { |
|
| 175 | 175 | |
| 176 | - if ( $status == $form_type ) { |
|
| 177 | - $class = ' class="current"'; |
|
| 178 | - } else { |
|
| 179 | - $class = ''; |
|
| 180 | - } |
|
| 176 | + if ( $status == $form_type ) { |
|
| 177 | + $class = ' class="current"'; |
|
| 178 | + } else { |
|
| 179 | + $class = ''; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - if ( $counts->{$status} || 'published' == $status ) { |
|
| 182 | + if ( $counts->{$status} || 'published' == $status ) { |
|
| 183 | 183 | $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - unset($status, $name); |
|
| 187 | - } |
|
| 186 | + unset($status, $name); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | return $links; |
| 190 | 190 | } |
@@ -200,16 +200,16 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function single_row( $item, $style = '' ) { |
| 203 | - global $frm_vars, $mode; |
|
| 203 | + global $frm_vars, $mode; |
|
| 204 | 204 | |
| 205 | 205 | // Set up the hover actions for this user |
| 206 | 206 | $actions = array(); |
| 207 | 207 | $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
| 208 | 208 | $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id; |
| 209 | 209 | |
| 210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 210 | + $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 211 | 211 | |
| 212 | - $action_links = $this->row_actions( $actions ); |
|
| 212 | + $action_links = $this->row_actions( $actions ); |
|
| 213 | 213 | |
| 214 | 214 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 215 | 215 | $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | list( $columns, $hidden ) = $this->get_column_info(); |
| 220 | 220 | |
| 221 | - $format = 'Y/m/d'; |
|
| 222 | - if ( 'list' != $mode ) { |
|
| 223 | - $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 221 | + $format = 'Y/m/d'; |
|
| 222 | + if ( 'list' != $mode ) { |
|
| 223 | + $format .= ' \<\b\r \/\> g:i:s a'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | $style = ''; |
| 230 | 230 | if ( in_array( $column_name, $hidden ) ) { |
| 231 | - $class .= ' frm_hidden'; |
|
| 231 | + $class .= ' frm_hidden'; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $class = 'class="' . esc_attr( $class ) . '"'; |
@@ -241,41 +241,41 @@ discard block |
||
| 241 | 241 | break; |
| 242 | 242 | case 'id': |
| 243 | 243 | case 'form_key': |
| 244 | - $val = $item->{$column_name}; |
|
| 245 | - break; |
|
| 244 | + $val = $item->{$column_name}; |
|
| 245 | + break; |
|
| 246 | 246 | case 'name': |
| 247 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 248 | - $val .= $action_links; |
|
| 247 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
| 248 | + $val .= $action_links; |
|
| 249 | 249 | |
| 250 | - break; |
|
| 250 | + break; |
|
| 251 | 251 | case 'created_at': |
| 252 | - $date = date($format, strtotime($item->created_at)); |
|
| 252 | + $date = date($format, strtotime($item->created_at)); |
|
| 253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
| 254 | 254 | break; |
| 255 | 255 | case 'shortcode': |
| 256 | 256 | $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>'; |
| 257 | - if ( 'excerpt' == $mode ) { |
|
| 257 | + if ( 'excerpt' == $mode ) { |
|
| 258 | 258 | $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />'; |
| 259 | - } |
|
| 260 | - break; |
|
| 261 | - case 'entries': |
|
| 259 | + } |
|
| 260 | + break; |
|
| 261 | + case 'entries': |
|
| 262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
| 263 | 263 | $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>'; |
| 264 | - } else { |
|
| 265 | - $text = FrmEntry::getRecordCount($item->id); |
|
| 264 | + } else { |
|
| 265 | + $text = FrmEntry::getRecordCount($item->id); |
|
| 266 | 266 | $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
| 267 | - unset($text); |
|
| 268 | - } |
|
| 269 | - break; |
|
| 270 | - case 'type': |
|
| 271 | - $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 272 | - break; |
|
| 267 | + unset($text); |
|
| 268 | + } |
|
| 269 | + break; |
|
| 270 | + case 'type': |
|
| 271 | + $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
| 272 | + break; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | if ( isset($val) ) { |
| 276 | - $r .= "<td $attributes>"; |
|
| 277 | - $r .= $val; |
|
| 278 | - $r .= '</td>'; |
|
| 276 | + $r .= "<td $attributes>"; |
|
| 277 | + $r .= $val; |
|
| 278 | + $r .= '</td>'; |
|
| 279 | 279 | } |
| 280 | 280 | unset($val); |
| 281 | 281 | } |
@@ -284,38 +284,38 @@ discard block |
||
| 284 | 284 | return $r; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * @param string $edit_link |
|
| 289 | - * @param string $duplicate_link |
|
| 290 | - */ |
|
| 291 | - private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
| 287 | + /** |
|
| 288 | + * @param string $edit_link |
|
| 289 | + * @param string $duplicate_link |
|
| 290 | + */ |
|
| 291 | + private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
| 292 | 292 | if ( 'trash' == $this->status ) { |
| 293 | 293 | if ( current_user_can('frm_edit_forms') ) { |
| 294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 297 | + if ( current_user_can('frm_delete_forms') ) { |
|
| 298 | 298 | $trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ); |
| 299 | 299 | $actions['trash'] = '<a href="' . esc_url( $trash_url ) .'" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
| 300 | - } |
|
| 301 | - return; |
|
| 300 | + } |
|
| 301 | + return; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | if ( current_user_can('frm_edit_forms') ) { |
| 305 | - if ( ! $item->is_template || ! $item->default_template ) { |
|
| 305 | + if ( ! $item->is_template || ! $item->default_template ) { |
|
| 306 | 306 | $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
| 307 | - } |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - if ( $item->is_template ) { |
|
| 309 | + if ( $item->is_template ) { |
|
| 310 | 310 | $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
| 311 | - } else { |
|
| 311 | + } else { |
|
| 312 | 312 | $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 313 | 313 | |
| 314 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 314 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 315 | 315 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
| 316 | - } |
|
| 317 | - } |
|
| 318 | - } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | $actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 321 | 321 | if ( empty( $actions['trash'] ) ) { |
@@ -324,52 +324,52 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
| 327 | - } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * @param string $edit_link |
|
| 331 | - */ |
|
| 329 | + /** |
|
| 330 | + * @param string $edit_link |
|
| 331 | + */ |
|
| 332 | 332 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 333 | - $form_name = $item->name; |
|
| 334 | - if ( trim($form_name) == '' ) { |
|
| 335 | - $form_name = __( '(no title)'); |
|
| 336 | - } |
|
| 333 | + $form_name = $item->name; |
|
| 334 | + if ( trim($form_name) == '' ) { |
|
| 335 | + $form_name = __( '(no title)'); |
|
| 336 | + } |
|
| 337 | 337 | $form_name = FrmAppHelper::kses( $form_name ); |
| 338 | 338 | if ( 'excerpt' != $mode ) { |
| 339 | 339 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $val = '<strong>'; |
|
| 343 | - if ( 'trash' == $this->status ) { |
|
| 344 | - $val .= $form_name; |
|
| 345 | - } else { |
|
| 342 | + $val = '<strong>'; |
|
| 343 | + if ( 'trash' == $this->status ) { |
|
| 344 | + $val .= $form_name; |
|
| 345 | + } else { |
|
| 346 | 346 | $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | - $this->add_draft_label( $item, $val ); |
|
| 350 | - $val .= '</strong>'; |
|
| 349 | + $this->add_draft_label( $item, $val ); |
|
| 350 | + $val .= '</strong>'; |
|
| 351 | 351 | |
| 352 | - $this->add_form_description( $item, $val ); |
|
| 352 | + $this->add_form_description( $item, $val ); |
|
| 353 | 353 | |
| 354 | - return $val; |
|
| 355 | - } |
|
| 354 | + return $val; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * @param string $val |
|
| 359 | - */ |
|
| 360 | - private function add_draft_label( $item, &$val ) { |
|
| 361 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 357 | + /** |
|
| 358 | + * @param string $val |
|
| 359 | + */ |
|
| 360 | + private function add_draft_label( $item, &$val ) { |
|
| 361 | + if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
| 362 | 362 | $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; |
| 363 | - } |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * @param string $val |
|
| 368 | - */ |
|
| 369 | - private function add_form_description( $item, &$val ) { |
|
| 370 | - global $mode; |
|
| 371 | - if ( 'excerpt' == $mode ) { |
|
| 372 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 373 | - } |
|
| 374 | - } |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * @param string $val |
|
| 368 | + */ |
|
| 369 | + private function add_form_description( $item, &$val ) { |
|
| 370 | + global $mode; |
|
| 371 | + if ( 'excerpt' == $mode ) { |
|
| 372 | + $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 373 | + } |
|
| 374 | + } |
|
| 375 | 375 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $page = $this->get_pagenum(); |
| 27 | 27 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' ); |
| 28 | 28 | |
| 29 | - $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
|
| 29 | + $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page ); |
|
| 30 | 30 | |
| 31 | 31 | $s_query = array(); |
| 32 | 32 | $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | break; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
| 52 | 52 | if ( $s != '' ) { |
| 53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
| 54 | - $search_terms = array_map('trim', $matches[0]); |
|
| 53 | + preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
|
| 54 | + $search_terms = array_map( 'trim', $matches[0] ); |
|
| 55 | 55 | foreach ( (array) $search_terms as $term ) { |
| 56 | 56 | $s_query[] = array( |
| 57 | 57 | 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
| 58 | 58 | ); |
| 59 | - unset($term); |
|
| 59 | + unset( $term ); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | _e( 'No Templates Found.', 'formidable' ) ?> |
| 75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
| 76 | 76 | <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
| 77 | - <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
|
| 77 | + <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li> |
|
| 78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
| 79 | 79 | </ol> |
| 80 | 80 | <?php } else { |
@@ -91,17 +91,17 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ( 'trash' == $this->status ) { |
| 94 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 94 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 95 | 95 | $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 98 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 99 | 99 | $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
| 100 | 100 | } |
| 101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
| 101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) { |
|
| 102 | 102 | $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
| 103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
| 104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
| 103 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 104 | + $actions['bulk_delete'] = __( 'Delete' ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $actions; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
| 115 | + if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { |
|
| 116 | 116 | ?> |
| 117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
| 118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
| 129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
| 130 | 130 | |
| 131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
| 131 | + $base = admin_url( 'admin.php?page=formidable&form_type=template' ); |
|
| 132 | 132 | $args = array( |
| 133 | 133 | 'frm_action' => 'duplicate', |
| 134 | 134 | 'template' => true, |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $args['id'] = $form->id; ?> |
| 149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
| 150 | 150 | <?php |
| 151 | - unset($form); |
|
| 151 | + unset( $form ); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | ?> |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | if ( $counts->{$status} || 'published' == $status ) { |
| 183 | - $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 183 | + $links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - unset($status, $name); |
|
| 186 | + unset( $status, $name ); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | return $links; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
| 208 | 208 | $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id; |
| 209 | 209 | |
| 210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
| 210 | + $this->get_actions( $actions, $item, $edit_link, $duplicate_link ); |
|
| 211 | 211 | |
| 212 | 212 | $action_links = $this->row_actions( $actions ); |
| 213 | 213 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | break; |
| 251 | 251 | case 'created_at': |
| 252 | - $date = date($format, strtotime($item->created_at)); |
|
| 252 | + $date = date( $format, strtotime( $item->created_at ) ); |
|
| 253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
| 254 | 254 | break; |
| 255 | 255 | case 'shortcode': |
@@ -260,11 +260,11 @@ discard block |
||
| 260 | 260 | break; |
| 261 | 261 | case 'entries': |
| 262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
| 263 | - $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>'; |
|
| 263 | + $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>'; |
|
| 264 | 264 | } else { |
| 265 | - $text = FrmEntry::getRecordCount($item->id); |
|
| 266 | - $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
|
| 267 | - unset($text); |
|
| 265 | + $text = FrmEntry::getRecordCount( $item->id ); |
|
| 266 | + $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
|
| 267 | + unset( $text ); |
|
| 268 | 268 | } |
| 269 | 269 | break; |
| 270 | 270 | case 'type': |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | break; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if ( isset($val) ) { |
|
| 275 | + if ( isset( $val ) ) { |
|
| 276 | 276 | $r .= "<td $attributes>"; |
| 277 | 277 | $r .= $val; |
| 278 | 278 | $r .= '</td>'; |
| 279 | 279 | } |
| 280 | - unset($val); |
|
| 280 | + unset( $val ); |
|
| 281 | 281 | } |
| 282 | 282 | $r .= '</tr>'; |
| 283 | 283 | |
@@ -290,18 +290,18 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
| 292 | 292 | if ( 'trash' == $this->status ) { |
| 293 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 293 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if ( current_user_can('frm_delete_forms') ) { |
|
| 297 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
| 298 | 298 | $trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ); |
| 299 | 299 | $actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
| 300 | 300 | } |
| 301 | 301 | return; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( current_user_can('frm_edit_forms') ) { |
|
| 304 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
| 305 | 305 | if ( ! $item->is_template || ! $item->default_template ) { |
| 306 | 306 | $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
| 307 | 307 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | unset( $actions['trash'] ); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
|
| 326 | + $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>'; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 333 | 333 | $form_name = $item->name; |
| 334 | - if ( trim($form_name) == '' ) { |
|
| 335 | - $form_name = __( '(no title)'); |
|
| 334 | + if ( trim( $form_name ) == '' ) { |
|
| 335 | + $form_name = __( '(no title)' ); |
|
| 336 | 336 | } |
| 337 | 337 | $form_name = FrmAppHelper::kses( $form_name ); |
| 338 | 338 | if ( 'excerpt' != $mode ) { |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | private function add_form_description( $item, &$val ) { |
| 370 | 370 | global $mode; |
| 371 | 371 | if ( 'excerpt' == $mode ) { |
| 372 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
| 372 | + $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
|
| 373 | 373 | } |
| 374 | 374 | } |
| 375 | 375 | } |
@@ -6,46 +6,46 @@ discard block |
||
| 6 | 6 | protected $field; |
| 7 | 7 | |
| 8 | 8 | public function prepare_items() { |
| 9 | - global $wpdb, $per_page; |
|
| 9 | + global $wpdb, $per_page; |
|
| 10 | 10 | |
| 11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
| 12 | 12 | |
| 13 | - $form_id = $this->params['form']; |
|
| 14 | - if ( ! $form_id ) { |
|
| 15 | - $this->items = array(); |
|
| 16 | - $this->set_pagination_args( array( |
|
| 17 | - 'total_items' => 0, |
|
| 13 | + $form_id = $this->params['form']; |
|
| 14 | + if ( ! $form_id ) { |
|
| 15 | + $this->items = array(); |
|
| 16 | + $this->set_pagination_args( array( |
|
| 17 | + 'total_items' => 0, |
|
| 18 | 18 | 'per_page' => $per_page, |
| 19 | - ) ); |
|
| 20 | - return; |
|
| 21 | - } |
|
| 19 | + ) ); |
|
| 20 | + return; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | $default_orderby = 'id'; |
| 24 | 24 | $default_order = 'DESC'; |
| 25 | 25 | |
| 26 | - $s_query = array( 'it.form_id' => $form_id ); |
|
| 26 | + $s_query = array( 'it.form_id' => $form_id ); |
|
| 27 | 27 | |
| 28 | 28 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
| 29 | 29 | |
| 30 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
| 31 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
| 32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
| 33 | - } |
|
| 30 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
| 31 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
| 32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
| 36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
| 37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
| 35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
| 36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
| 37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
| 38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
| 42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
| 43 | 43 | |
| 44 | - $page = $this->get_pagenum(); |
|
| 44 | + $page = $this->get_pagenum(); |
|
| 45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
| 46 | 46 | |
| 47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
| 48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
| 49 | 49 | |
| 50 | 50 | $this->set_pagination_args( array( |
| 51 | 51 | 'total_items' => $total_items, |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function no_items() { |
| 57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
| 58 | - if ( ! empty($s) ) { |
|
| 59 | - _e( 'No Entries Found', 'formidable' ); |
|
| 60 | - return; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - $form_id = $form = $this->params['form']; |
|
| 64 | - if ( $form_id ) { |
|
| 65 | - $form = FrmForm::getOne($form_id); |
|
| 66 | - } |
|
| 67 | - $colspan = $this->get_column_count(); |
|
| 57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
| 58 | + if ( ! empty($s) ) { |
|
| 59 | + _e( 'No Entries Found', 'formidable' ); |
|
| 60 | + return; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + $form_id = $form = $this->params['form']; |
|
| 64 | + if ( $form_id ) { |
|
| 65 | + $form = FrmForm::getOne($form_id); |
|
| 66 | + } |
|
| 67 | + $colspan = $this->get_column_count(); |
|
| 68 | 68 | |
| 69 | 69 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
| 70 | 70 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | - * Gets the name of the primary column in the Entries screen |
|
| 78 | - * |
|
| 79 | - * @since 2.0.14 |
|
| 80 | - * |
|
| 81 | - * @return string $primary_column |
|
| 82 | - */ |
|
| 77 | + * Gets the name of the primary column in the Entries screen |
|
| 78 | + * |
|
| 79 | + * @since 2.0.14 |
|
| 80 | + * |
|
| 81 | + * @return string $primary_column |
|
| 82 | + */ |
|
| 83 | 83 | protected function get_primary_column_name() { |
| 84 | 84 | $columns = get_column_headers( $this->screen ); |
| 85 | 85 | $hidden = get_hidden_columns( $this->screen ); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
| 105 | 105 | |
| 106 | - $action_links = $this->row_actions( $actions ); |
|
| 106 | + $action_links = $this->row_actions( $actions ); |
|
| 107 | 107 | |
| 108 | 108 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 109 | 109 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 112 | 112 | |
| 113 | 113 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
| 114 | - $action_col = false; |
|
| 114 | + $action_col = false; |
|
| 115 | 115 | |
| 116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
| 117 | 117 | $class = $column_name . ' column-' . $column_name; |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | if ( in_array( $column_name, $hidden ) ) { |
| 124 | 124 | $class .= ' frm_hidden'; |
| 125 | 125 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
| 126 | - $action_col = $column_name; |
|
| 127 | - } |
|
| 126 | + $action_col = $column_name; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 130 | 130 | unset($class); |
@@ -140,30 +140,30 @@ discard block |
||
| 140 | 140 | case 'ip': |
| 141 | 141 | case 'id': |
| 142 | 142 | case 'item_key': |
| 143 | - $val = $item->{$col_name}; |
|
| 144 | - break; |
|
| 143 | + $val = $item->{$col_name}; |
|
| 144 | + break; |
|
| 145 | 145 | case 'name': |
| 146 | 146 | case 'description': |
| 147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 148 | - break; |
|
| 147 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 148 | + break; |
|
| 149 | 149 | case 'created_at': |
| 150 | 150 | case 'updated_at': |
| 151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 151 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
| 153 | 153 | break; |
| 154 | 154 | case 'is_draft': |
| 155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 156 | - break; |
|
| 155 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 156 | + break; |
|
| 157 | 157 | case 'form_id': |
| 158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 159 | - break; |
|
| 158 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 159 | + break; |
|
| 160 | 160 | case 'post_id': |
| 161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 162 | - break; |
|
| 161 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 162 | + break; |
|
| 163 | 163 | case 'user_id': |
| 164 | - $user = get_userdata($item->user_id); |
|
| 165 | - $val = $user->user_login; |
|
| 166 | - break; |
|
| 164 | + $user = get_userdata($item->user_id); |
|
| 165 | + $val = $user->user_login; |
|
| 166 | + break; |
|
| 167 | 167 | default: |
| 168 | 168 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
| 169 | 169 | if ( $val === false ) { |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if ( isset( $val ) ) { |
| 176 | - $r .= "<td $attributes>"; |
|
| 176 | + $r .= "<td $attributes>"; |
|
| 177 | 177 | if ( $column_name == $action_col ) { |
| 178 | 178 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
| 179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
| 180 | - $r .= $action_links; |
|
| 180 | + $r .= $action_links; |
|
| 181 | 181 | } else { |
| 182 | - $r .= $val; |
|
| 183 | - } |
|
| 184 | - $r .= '</td>'; |
|
| 182 | + $r .= $val; |
|
| 183 | + } |
|
| 184 | + $r .= '</td>'; |
|
| 185 | 185 | } |
| 186 | 186 | unset($val); |
| 187 | 187 | } |
@@ -190,19 +190,19 @@ discard block |
||
| 190 | 190 | return $r; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * @param string $view_link |
|
| 195 | - */ |
|
| 196 | - private function get_actions( &$actions, $item, $view_link ) { |
|
| 193 | + /** |
|
| 194 | + * @param string $view_link |
|
| 195 | + */ |
|
| 196 | + private function get_actions( &$actions, $item, $view_link ) { |
|
| 197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 198 | 198 | |
| 199 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 199 | + if ( current_user_can('frm_delete_entries') ) { |
|
| 200 | 200 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 205 | - } |
|
| 204 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | private function get_column_value( $item, &$val ) { |
| 208 | 208 | $col_name = $this->column_name; |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $s_query = array( 'it.form_id' => $form_id ); |
| 27 | 27 | |
| 28 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
| 28 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
| 29 | 29 | |
| 30 | 30 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
| 31 | 31 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
| 32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
| 32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
| 36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
| 36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
| 37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
| 38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
| 39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
| 46 | 46 | |
| 47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
| 48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
| 48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
| 49 | 49 | |
| 50 | 50 | $this->set_pagination_args( array( |
| 51 | 51 | 'total_items' => $total_items, |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function no_items() { |
| 57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
| 58 | - if ( ! empty($s) ) { |
|
| 58 | + if ( ! empty( $s ) ) { |
|
| 59 | 59 | _e( 'No Entries Found', 'formidable' ); |
| 60 | 60 | return; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $form_id = $form = $this->params['form']; |
| 64 | 64 | if ( $form_id ) { |
| 65 | - $form = FrmForm::getOne($form_id); |
|
| 65 | + $form = FrmForm::getOne( $form_id ); |
|
| 66 | 66 | } |
| 67 | 67 | $colspan = $this->get_column_count(); |
| 68 | 68 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
| 112 | 112 | |
| 113 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
| 113 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
| 114 | 114 | $action_col = false; |
| 115 | 115 | |
| 116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
| 130 | - unset($class); |
|
| 130 | + unset( $class ); |
|
| 131 | 131 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
| 132 | 132 | |
| 133 | 133 | $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
@@ -144,24 +144,24 @@ discard block |
||
| 144 | 144 | break; |
| 145 | 145 | case 'name': |
| 146 | 146 | case 'description': |
| 147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
| 147 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
| 148 | 148 | break; |
| 149 | 149 | case 'created_at': |
| 150 | 150 | case 'updated_at': |
| 151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
| 151 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
| 152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
| 153 | 153 | break; |
| 154 | 154 | case 'is_draft': |
| 155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
| 155 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
| 156 | 156 | break; |
| 157 | 157 | case 'form_id': |
| 158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
| 158 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
| 159 | 159 | break; |
| 160 | 160 | case 'post_id': |
| 161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
| 161 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
| 162 | 162 | break; |
| 163 | 163 | case 'user_id': |
| 164 | - $user = get_userdata($item->user_id); |
|
| 164 | + $user = get_userdata( $item->user_id ); |
|
| 165 | 165 | $val = $user->user_login; |
| 166 | 166 | break; |
| 167 | 167 | default: |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | $r .= '</td>'; |
| 185 | 185 | } |
| 186 | - unset($val); |
|
| 186 | + unset( $val ); |
|
| 187 | 187 | } |
| 188 | 188 | $r .= '</tr>'; |
| 189 | 189 | |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | private function get_actions( &$actions, $item, $view_link ) { |
| 197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
| 198 | 198 | |
| 199 | - if ( current_user_can('frm_delete_entries') ) { |
|
| 199 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
| 200 | 200 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
| 201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
| 204 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | private function get_column_value( $item, &$val ) { |
@@ -1,67 +1,67 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStylesHelper { |
| 3 | 3 | |
| 4 | - public static function jquery_themes() { |
|
| 5 | - $themes = array( |
|
| 6 | - 'ui-lightness' => 'UI Lightness', |
|
| 7 | - 'ui-darkness' => 'UI Darkness', |
|
| 8 | - 'smoothness' => 'Smoothness', |
|
| 9 | - 'start' => 'Start', |
|
| 10 | - 'redmond' => 'Redmond', |
|
| 11 | - 'sunny' => 'Sunny', |
|
| 12 | - 'overcast' => 'Overcast', |
|
| 13 | - 'le-frog' => 'Le Frog', |
|
| 14 | - 'flick' => 'Flick', |
|
| 4 | + public static function jquery_themes() { |
|
| 5 | + $themes = array( |
|
| 6 | + 'ui-lightness' => 'UI Lightness', |
|
| 7 | + 'ui-darkness' => 'UI Darkness', |
|
| 8 | + 'smoothness' => 'Smoothness', |
|
| 9 | + 'start' => 'Start', |
|
| 10 | + 'redmond' => 'Redmond', |
|
| 11 | + 'sunny' => 'Sunny', |
|
| 12 | + 'overcast' => 'Overcast', |
|
| 13 | + 'le-frog' => 'Le Frog', |
|
| 14 | + 'flick' => 'Flick', |
|
| 15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
| 16 | - 'eggplant' => 'Eggplant', |
|
| 17 | - 'dark-hive' => 'Dark Hive', |
|
| 18 | - 'cupertino' => 'Cupertino', |
|
| 19 | - 'south-street' => 'South Street', |
|
| 20 | - 'blitzer' => 'Blitzer', |
|
| 21 | - 'humanity' => 'Humanity', |
|
| 22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | - 'excite-bike' => 'Excite Bike', |
|
| 24 | - 'vader' => 'Vader', |
|
| 25 | - 'dot-luv' => 'Dot Luv', |
|
| 26 | - 'mint-choc' => 'Mint Choc', |
|
| 27 | - 'black-tie' => 'Black Tie', |
|
| 28 | - 'trontastic' => 'Trontastic', |
|
| 29 | - 'swanky-purse' => 'Swanky Purse', |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | - return $themes; |
|
| 34 | - } |
|
| 16 | + 'eggplant' => 'Eggplant', |
|
| 17 | + 'dark-hive' => 'Dark Hive', |
|
| 18 | + 'cupertino' => 'Cupertino', |
|
| 19 | + 'south-street' => 'South Street', |
|
| 20 | + 'blitzer' => 'Blitzer', |
|
| 21 | + 'humanity' => 'Humanity', |
|
| 22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | + 'excite-bike' => 'Excite Bike', |
|
| 24 | + 'vader' => 'Vader', |
|
| 25 | + 'dot-luv' => 'Dot Luv', |
|
| 26 | + 'mint-choc' => 'Mint Choc', |
|
| 27 | + 'black-tie' => 'Black Tie', |
|
| 28 | + 'trontastic' => 'Trontastic', |
|
| 29 | + 'swanky-purse' => 'Swanky Purse', |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | + return $themes; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | public static function jquery_css_url( $theme_css ) { |
| 37 | - if ( $theme_css == -1 ) { |
|
| 38 | - return; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | - $css_file = $theme_css; |
|
| 45 | - } else { |
|
| 46 | - $uploads = self::get_upload_base(); |
|
| 37 | + if ( $theme_css == -1 ) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | + $css_file = $theme_css; |
|
| 45 | + } else { |
|
| 46 | + $uploads = self::get_upload_base(); |
|
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | - } else { |
|
| 48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | + } else { |
|
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
| 52 | - } |
|
| 53 | - } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $css_file; |
|
| 56 | - } |
|
| 55 | + return $css_file; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function enqueue_jquery_css() { |
|
| 58 | + public static function enqueue_jquery_css() { |
|
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | - if ( $theme_css != -1 ) { |
|
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | - } |
|
| 64 | - } |
|
| 61 | + if ( $theme_css != -1 ) { |
|
| 62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | public static function get_form_for_page() { |
| 67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | return $form_id; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public static function get_upload_base() { |
|
| 81 | - $uploads = wp_upload_dir(); |
|
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | - } |
|
| 80 | + public static function get_upload_base() { |
|
| 81 | + $uploads = wp_upload_dir(); |
|
| 82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $uploads; |
|
| 87 | - } |
|
| 86 | + return $uploads; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function style_menu( $active = '' ) { |
| 90 | 90 | ?> |
@@ -94,22 +94,22 @@ discard block |
||
| 94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public static function minus_icons() { |
|
| 100 | - return array( |
|
| 99 | + public static function minus_icons() { |
|
| 100 | + return array( |
|
| 101 | 101 | 0 => array( '-' => '62e', '+' => '62f' ), |
| 102 | 102 | 1 => array( '-' => '600', '+' => '602' ), |
| 103 | 103 | 2 => array( '-' => '604', '+' => '603' ), |
| 104 | 104 | 3 => array( '-' => '633', '+' => '632' ), |
| 105 | 105 | 4 => array( '-' => '613', '+' => '60f' ), |
| 106 | - ); |
|
| 107 | - } |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - public static function arrow_icons() { |
|
| 110 | - $minus_icons = self::minus_icons(); |
|
| 109 | + public static function arrow_icons() { |
|
| 110 | + $minus_icons = self::minus_icons(); |
|
| 111 | 111 | |
| 112 | - return array( |
|
| 112 | + return array( |
|
| 113 | 113 | 6 => array( '-' => '62d', '+' => '62a' ), |
| 114 | 114 | 0 => array( '-' => '60d', '+' => '609' ), |
| 115 | 115 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -117,44 +117,44 @@ discard block |
||
| 117 | 117 | 3 => array( '-' => '62b', '+' => '628' ), |
| 118 | 118 | 4 => array( '-' => '62c', '+' => '629' ), |
| 119 | 119 | 5 => array( '-' => '635', '+' => '634' ), |
| 120 | - 'p0' => $minus_icons[0], |
|
| 121 | - 'p1' => $minus_icons[1], |
|
| 122 | - 'p2' => $minus_icons[2], |
|
| 123 | - 'p3' => $minus_icons[3], |
|
| 124 | - 'p4' => $minus_icons[4], |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @since 2.0 |
|
| 130 | - * @return The class for this icon |
|
| 131 | - */ |
|
| 120 | + 'p0' => $minus_icons[0], |
|
| 121 | + 'p1' => $minus_icons[1], |
|
| 122 | + 'p2' => $minus_icons[2], |
|
| 123 | + 'p3' => $minus_icons[3], |
|
| 124 | + 'p4' => $minus_icons[4], |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @since 2.0 |
|
| 130 | + * @return The class for this icon |
|
| 131 | + */ |
|
| 132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 134 | - //frm_arrowup6_icon |
|
| 133 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 134 | + //frm_arrowup6_icon |
|
| 135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 136 | 136 | $class = 'frm_arrow' . $arrow[ $icon ]; |
| 137 | - } else { |
|
| 138 | - //frm_minus1_icon |
|
| 139 | - $key = str_replace('p', '', $key); |
|
| 137 | + } else { |
|
| 138 | + //frm_minus1_icon |
|
| 139 | + $key = str_replace('p', '', $key); |
|
| 140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
| 141 | 141 | $class = 'frm_' . $plus[ $icon ]; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ( $key ) { |
|
| 145 | - $class .= $key; |
|
| 146 | - } |
|
| 147 | - $class .= '_icon'; |
|
| 144 | + if ( $key ) { |
|
| 145 | + $class .= $key; |
|
| 146 | + } |
|
| 147 | + $class .= '_icon'; |
|
| 148 | 148 | |
| 149 | - return $class; |
|
| 150 | - } |
|
| 149 | + return $class; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
| 153 | 153 | $function_name = $type . '_icons'; |
| 154 | 154 | $icons = self::$function_name(); |
| 155 | 155 | unset( $function_name ); |
| 156 | 156 | |
| 157 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 157 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 158 | 158 | ?> |
| 159 | 159 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
| 160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | </ul> |
| 188 | 188 | </div> |
| 189 | 189 | <?php |
| 190 | - } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | public static function hex2rgb( $hex ) { |
| 193 | - $hex = str_replace('#', '', $hex); |
|
| 193 | + $hex = str_replace('#', '', $hex); |
|
| 194 | 194 | |
| 195 | - if ( strlen($hex) == 3 ) { |
|
| 195 | + if ( strlen($hex) == 3 ) { |
|
| 196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
| 199 | - } else { |
|
| 199 | + } else { |
|
| 200 | 200 | $r = hexdec( substr( $hex, 0, 2 ) ); |
| 201 | 201 | $g = hexdec( substr( $hex, 2, 2 ) ); |
| 202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | $rgb = array( $r, $g, $b ); |
| 205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 206 | - //return $rgb; // returns an array with the rgb values |
|
| 207 | - } |
|
| 205 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 206 | + //return $rgb; // returns an array with the rgb values |
|
| 207 | + } |
|
| 208 | 208 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'swanky-purse' => 'Swanky Purse', |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
| 33 | 33 | return $themes; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
| 42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
| 44 | 44 | $css_file = $theme_css; |
| 45 | 45 | } else { |
| 46 | 46 | $uploads = self::get_upload_base(); |
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
| 49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
| 50 | 50 | } else { |
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | 61 | if ( $theme_css != -1 ) { |
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public static function get_upload_base() { |
| 81 | 81 | $uploads = wp_upload_dir(); |
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | <h2 class="nav-tab-wrapper"> |
| 92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
| 93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
| 94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
| 130 | 130 | * @return The class for this icon |
| 131 | 131 | */ |
| 132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
| 134 | 134 | //frm_arrowup6_icon |
| 135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
| 136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
| 137 | 137 | } else { |
| 138 | 138 | //frm_minus1_icon |
| 139 | - $key = str_replace('p', '', $key); |
|
| 139 | + $key = str_replace( 'p', '', $key ); |
|
| 140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
| 141 | - $class = 'frm_' . $plus[ $icon ]; |
|
| 141 | + $class = 'frm_' . $plus[$icon]; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ( $key ) { |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
| 158 | 158 | ?> |
| 159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
| 161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
| 161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
| 162 | 162 | <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
| 163 | 163 | </option> |
| 164 | 164 | <?php } ?> |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
| 168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
| 169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
| 170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
| 169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
| 170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
| 171 | 171 | <b class="caret"></b> |
| 172 | 172 | </button> |
| 173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public static function hex2rgb( $hex ) { |
| 193 | - $hex = str_replace('#', '', $hex); |
|
| 193 | + $hex = str_replace( '#', '', $hex ); |
|
| 194 | 194 | |
| 195 | - if ( strlen($hex) == 3 ) { |
|
| 195 | + if ( strlen( $hex ) == 3 ) { |
|
| 196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 203 | 203 | } |
| 204 | 204 | $rgb = array( $r, $g, $b ); |
| 205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
| 206 | 206 | //return $rgb; // returns an array with the rgb values |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -3,23 +3,23 @@ discard block |
||
| 3 | 3 | if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) { |
| 4 | 4 | if ( isset( $_GET['frm_style_setting'] ) ) { |
| 5 | 5 | extract( $_GET['frm_style_setting']['post_content'] ); |
| 6 | - } else { |
|
| 7 | - extract($_GET); |
|
| 8 | - } |
|
| 6 | + } else { |
|
| 7 | + extract($_GET); |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - $important_style = isset($important_style) ? $important_style : 0; |
|
| 11 | - $auto_width = isset($auto_width) ? $auto_width : 0; |
|
| 12 | - $submit_style = isset($submit_style) ? $submit_style : 0; |
|
| 10 | + $important_style = isset($important_style) ? $important_style : 0; |
|
| 11 | + $auto_width = isset($auto_width) ? $auto_width : 0; |
|
| 12 | + $submit_style = isset($submit_style) ? $submit_style : 0; |
|
| 13 | 13 | |
| 14 | 14 | $style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' ); |
| 15 | 15 | if ( ! empty( $style_name ) ) { |
| 16 | 16 | $style_class = $style_name . '.with_frm_style'; |
| 17 | - } else { |
|
| 18 | - $style_class = 'with_frm_style'; |
|
| 19 | - } |
|
| 17 | + } else { |
|
| 18 | + $style_class = 'with_frm_style'; |
|
| 19 | + } |
|
| 20 | 20 | } else { |
| 21 | 21 | $style_class = 'frm_style_' . $style->post_name . '.with_frm_style'; |
| 22 | - extract($style->post_content); |
|
| 22 | + extract($style->post_content); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $important = empty($important_style) ? '' : ' !important'; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if ( ! isset($collapse_icon) ) { |
| 43 | - $collapse_icon = 0; |
|
| 43 | + $collapse_icon = 0; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if ( ! isset( $center_form ) ) { |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | color:#<?php echo esc_html( $text_color . $important ) ?>; |
| 338 | 338 | background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>; |
| 339 | 339 | <?php if ( ! empty($important) ) { |
| 340 | - echo esc_html( 'background-image:none' . $important . ';' ); |
|
| 340 | + echo esc_html( 'background-image:none' . $important . ';' ); |
|
| 341 | 341 | } |
| 342 | 342 | ?> |
| 343 | 343 | border-color:#<?php echo esc_html( $border_color . $important ) ?>; |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | color:#<?php echo esc_html( $submit_active_color . $important ) ?>; |
| 549 | 549 | } |
| 550 | 550 | <?php |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | } |
| 553 | 553 | ?> |
| 554 | 554 | |
@@ -851,11 +851,11 @@ discard block |
||
| 851 | 851 | |
| 852 | 852 | .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{ |
| 853 | 853 | <?php |
| 854 | - // calculate the top position based on field padding |
|
| 855 | - $top_pad = explode(' ', $field_pad); |
|
| 856 | - $top_pad = reset($top_pad); // the top padding is listed first |
|
| 857 | - $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem... |
|
| 858 | - $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2; |
|
| 854 | + // calculate the top position based on field padding |
|
| 855 | + $top_pad = explode(' ', $field_pad); |
|
| 856 | + $top_pad = reset($top_pad); // the top padding is listed first |
|
| 857 | + $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem... |
|
| 858 | + $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2; |
|
| 859 | 859 | ?> |
| 860 | 860 | top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>; |
| 861 | 861 | } |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( isset($_GET['frm_style_setting']) || isset($_GET['flat']) ) { |
|
| 3 | +if ( isset( $_GET['frm_style_setting'] ) || isset( $_GET['flat'] ) ) { |
|
| 4 | 4 | if ( isset( $_GET['frm_style_setting'] ) ) { |
| 5 | 5 | extract( $_GET['frm_style_setting']['post_content'] ); |
| 6 | 6 | } else { |
| 7 | - extract($_GET); |
|
| 7 | + extract( $_GET ); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - $important_style = isset($important_style) ? $important_style : 0; |
|
| 11 | - $auto_width = isset($auto_width) ? $auto_width : 0; |
|
| 12 | - $submit_style = isset($submit_style) ? $submit_style : 0; |
|
| 10 | + $important_style = isset( $important_style ) ? $important_style : 0; |
|
| 11 | + $auto_width = isset( $auto_width ) ? $auto_width : 0; |
|
| 12 | + $submit_style = isset( $submit_style ) ? $submit_style : 0; |
|
| 13 | 13 | |
| 14 | 14 | $style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' ); |
| 15 | 15 | if ( ! empty( $style_name ) ) { |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } else { |
| 21 | 21 | $style_class = 'frm_style_' . $style->post_name . '.with_frm_style'; |
| 22 | - extract($style->post_content); |
|
| 22 | + extract( $style->post_content ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -$important = empty($important_style) ? '' : ' !important'; |
|
| 25 | +$important = empty( $important_style ) ? '' : ' !important'; |
|
| 26 | 26 | $label_margin = (int) $width + 10; |
| 27 | 27 | |
| 28 | 28 | $minus_icons = FrmStylesHelper::minus_icons(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $change_margin = 650 . 'px'; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -if ( ! isset($collapse_icon) ) { |
|
| 44 | +if ( ! isset( $collapse_icon ) ) { |
|
| 45 | 45 | $collapse_icon = 0; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before{ |
| 153 | - content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['-'] : $minus_icons[1]['-'] ) ?>"; |
|
| 153 | + content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['-'] : $minus_icons[1]['-'] ) ?>"; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_plus_icon:before{ |
| 157 | - content:"\e<?php echo esc_html( isset( $minus_icons[ $repeat_icon ] ) ? $minus_icons[ $repeat_icon ]['+'] : $minus_icons[1]['+'] ) ?>"; |
|
| 157 | + content:"\e<?php echo esc_html( isset( $minus_icons[$repeat_icon] ) ? $minus_icons[$repeat_icon]['+'] : $minus_icons[1]['+'] ) ?>"; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | .<?php echo esc_html( $style_class ) ?> .frm_icon_font.frm_minus_icon:before, |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | .<?php echo esc_html( $style_class ) ?> .frm_trigger.active .frm_icon_font.frm_arrow_icon:before{ |
| 166 | - content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['-'] : $arrow_icons[1]['-'] ) ?>"; |
|
| 166 | + content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['-'] : $arrow_icons[1]['-'] ) ?>"; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | .<?php echo esc_html( $style_class ) ?> .frm_trigger .frm_icon_font.frm_arrow_icon:before{ |
| 170 | - content:"\e<?php echo esc_html( isset( $arrow_icons[ $collapse_icon ] ) ? $arrow_icons[ $collapse_icon ]['+'] : $arrow_icons[1]['+'] ) ?>"; |
|
| 170 | + content:"\e<?php echo esc_html( isset( $arrow_icons[$collapse_icon] ) ? $arrow_icons[$collapse_icon]['+'] : $arrow_icons[1]['+'] ) ?>"; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | .<?php echo esc_html( $style_class ) ?> .form-field{ |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single{ |
| 343 | 343 | color:#<?php echo esc_html( $text_color . $important ) ?>; |
| 344 | 344 | background-color:<?php echo esc_html( ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . $important ); ?>; |
| 345 | -<?php if ( ! empty($important) ) { |
|
| 345 | +<?php if ( ! empty( $important ) ) { |
|
| 346 | 346 | echo esc_html( 'background-image:none' . $important . ';' ); |
| 347 | 347 | } |
| 348 | 348 | ?> |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | line-height:normal<?php echo esc_html( $important ) ?>; |
| 501 | 501 | text-align:center; |
| 502 | 502 | background:#<?php echo esc_html( $submit_bg_color ); |
| 503 | - if ( ! empty($submit_bg_img) ) { |
|
| 503 | + if ( ! empty( $submit_bg_img ) ) { |
|
| 504 | 504 | echo esc_html( ' url(' . $submit_bg_img . ')' ); |
| 505 | 505 | } |
| 506 | 506 | echo esc_html( $important ); ?>; |
@@ -861,10 +861,10 @@ discard block |
||
| 861 | 861 | .<?php echo esc_html( $style_class ) ?> .chosen-container-single .chosen-single div{ |
| 862 | 862 | <?php |
| 863 | 863 | // calculate the top position based on field padding |
| 864 | - $top_pad = explode(' ', $field_pad); |
|
| 865 | - $top_pad = reset($top_pad); // the top padding is listed first |
|
| 866 | - $pad_unit = preg_replace('/[0-9]+/', '', $top_pad); //px, em, rem... |
|
| 867 | - $top_margin = (int) str_replace($pad_unit, '', $top_pad) / 2; |
|
| 864 | + $top_pad = explode( ' ', $field_pad ); |
|
| 865 | + $top_pad = reset( $top_pad ); // the top padding is listed first |
|
| 866 | + $pad_unit = preg_replace( '/[0-9]+/', '', $top_pad ); //px, em, rem... |
|
| 867 | + $top_margin = (int) str_replace( $pad_unit, '', $top_pad ) / 2; |
|
| 868 | 868 | ?> |
| 869 | 869 | top:<?php echo esc_html( $top_margin . $pad_unit . $important ) ?>; |
| 870 | 870 | } |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! isset($saving) ) { |
| 3 | - header( 'Content-type: text/css' ); |
|
| 3 | + header( 'Content-type: text/css' ); |
|
| 4 | 4 | |
| 5 | - if ( isset($css) && $css ) { |
|
| 6 | - echo $css; |
|
| 7 | - die(); |
|
| 8 | - } |
|
| 5 | + if ( isset($css) && $css ) { |
|
| 6 | + echo $css; |
|
| 7 | + die(); |
|
| 8 | + } |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ( ! isset($frm_style) ) { |
| 12 | - $frm_style = new FrmStyle(); |
|
| 12 | + $frm_style = new FrmStyle(); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $styles = $frm_style->get_all(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | <?php |
| 188 | 188 | foreach ( $styles as $style ) { |
| 189 | 189 | include( dirname( __FILE__ ) . '/_single_theme.css.php' ); |
| 190 | - unset($style); |
|
| 190 | + unset($style); |
|
| 191 | 191 | } |
| 192 | 192 | ?> |
| 193 | 193 | |
@@ -1,19 +1,19 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! isset($saving) ) { |
|
| 2 | +if ( ! isset( $saving ) ) { |
|
| 3 | 3 | header( 'Content-type: text/css' ); |
| 4 | 4 | |
| 5 | - if ( isset($css) && $css ) { |
|
| 5 | + if ( isset( $css ) && $css ) { |
|
| 6 | 6 | echo $css; |
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -if ( ! isset($frm_style) ) { |
|
| 11 | +if ( ! isset( $frm_style ) ) { |
|
| 12 | 12 | $frm_style = new FrmStyle(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $styles = $frm_style->get_all(); |
| 16 | -$default_style = $frm_style->get_default_style($styles); |
|
| 16 | +$default_style = $frm_style->get_default_style( $styles ); |
|
| 17 | 17 | $defaults = $default_style->post_content; |
| 18 | 18 | ?> |
| 19 | 19 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | <?php |
| 195 | 195 | foreach ( $styles as $style ) { |
| 196 | 196 | include( dirname( __FILE__ ) . '/_single_theme.css.php' ); |
| 197 | - unset($style); |
|
| 197 | + unset( $style ); |
|
| 198 | 198 | } |
| 199 | 199 | ?> |
| 200 | 200 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | overflow:hidden!important; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | -<?php include( dirname(__FILE__) . '/frm_grids.css' ); ?> |
|
| 622 | +<?php include( dirname( __FILE__ ) . '/frm_grids.css' ); ?> |
|
| 623 | 623 | |
| 624 | 624 | /* Left and right label styling for non-Formidable styling - very basic, not responsive */ |
| 625 | 625 | .frm_form_field.frm_left_container label.frm_primary_label{ |