@@ -275,7 +275,7 @@ |
||
275 | 275 | return $message; |
276 | 276 | } |
277 | 277 | |
278 | - public function manually_queue_update() { |
|
279 | - set_site_transient( 'update_plugins', null ); |
|
280 | - } |
|
278 | + public function manually_queue_update() { |
|
279 | + set_site_transient( 'update_plugins', null ); |
|
280 | + } |
|
281 | 281 | } |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function insert_installed_addon( $plugins ) { |
41 | - $plugins[ $this->plugin_slug ] = $this; |
|
41 | + $plugins[$this->plugin_slug] = $this; |
|
42 | 42 | return $plugins; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function get_addon( $plugin_slug ) { |
46 | 46 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
47 | 47 | $plugin = false; |
48 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
49 | - $plugin = $plugins[ $plugin_slug ]; |
|
48 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
49 | + $plugin = $plugins[$plugin_slug]; |
|
50 | 50 | } |
51 | 51 | return $plugin; |
52 | 52 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | public function show_license_message( $file, $plugin ) { |
99 | 99 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
100 | 100 | echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
101 | - echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
101 | + echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
102 | 102 | $id = sanitize_title( $plugin['Name'] ); |
103 | 103 | echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>'; |
104 | 104 | echo '</div></td></tr>'; |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | |
112 | 112 | if ( $this->is_current_version( $transient ) ) { |
113 | 113 | //make sure it doesn't show there is an update if plugin is up-to-date |
114 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
115 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
114 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
115 | + unset( $transient->response[$this->plugin_folder] ); |
|
116 | 116 | } |
117 | - } else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
117 | + } else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
118 | 118 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' ); |
119 | 119 | $version_info = get_transient( $cache_key ); |
120 | 120 | if ( $version_info !== false && version_compare( $version_info->new_version, $this->version, '>' ) ) { |
121 | - $transient->response[ $this->plugin_folder ] = $version_info; |
|
121 | + $transient->response[$this->plugin_folder] = $version_info; |
|
122 | 122 | } else { |
123 | 123 | delete_transient( $cache_key ); |
124 | 124 | if ( ! $this->has_been_cleared() ) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->manually_queue_update(); |
128 | 128 | } |
129 | 129 | |
130 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
130 | + unset( $transient->response[$this->plugin_folder] ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | private function is_current_version( $transient ) { |
138 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
138 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | return true; |
145 | 145 | } |
146 | 146 | |
147 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version; |
|
147 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | private function has_been_cleared() { |
151 | 151 | $last_cleared = get_option( 'frm_last_cleared' ); |
152 | - return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) ); |
|
152 | + return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | private function cleared_plugins() { |
156 | - update_option( 'frm_last_cleared', date('Y-m-d H:i:s') ); |
|
156 | + update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public static function activate() { |
160 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
160 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
161 | 161 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
162 | 162 | |
163 | 163 | if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | |
207 | 207 | public static function deactivate() { |
208 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
208 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
209 | 209 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
210 | 210 | |
211 | 211 | $plugin_slug = sanitize_text_field( $_POST['plugin'] ); |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | |
256 | 256 | $message = __( 'Your License Key was invalid', 'formidable' ); |
257 | 257 | if ( is_wp_error( $resp ) ) { |
258 | - $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
258 | + $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
259 | 259 | if ( is_wp_error( $resp ) ) { |
260 | - $message .= ' '. $resp->get_error_message(); |
|
260 | + $message .= ' ' . $resp->get_error_message(); |
|
261 | 261 | } |
262 | 262 | } else if ( $body == 'error' || is_wp_error( $body ) ) { |
263 | 263 | $message = __( 'You had an HTTP error connecting to Formidable Pro\'s API', 'formidable' ); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | $message = $json_res; |
271 | 271 | } |
272 | 272 | } else if ( isset( $resp['response'] ) && isset( $resp['response']['code'] ) ) { |
273 | - $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] .' '. $resp['body'] ); |
|
273 | + $message = sprintf( __( 'There was a %1$s error: %2$s', 'formidable' ), $resp['response']['code'], $resp['response']['message'] . ' ' . $resp['body'] ); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_top') ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_top' ) ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_bottom') ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_bottom' ) ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -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 | - } |
|
62 | - |
|
63 | - $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
64 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
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 | + |
|
63 | + $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
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 | - $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
208 | - $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id; |
|
207 | + $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
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,17 +218,17 @@ 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 ) { |
227 | - $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
227 | + $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
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 | - $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); |
|
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); |
|
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,37 +284,37 @@ 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') ) { |
|
298 | - $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
299 | - } |
|
300 | - return; |
|
297 | + if ( current_user_can('frm_delete_forms') ) { |
|
298 | + $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
299 | + } |
|
300 | + return; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | if ( current_user_can('frm_edit_forms') ) { |
304 | - if ( ! $item->is_template || ! $item->default_template ) { |
|
305 | - $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
306 | - } |
|
304 | + if ( ! $item->is_template || ! $item->default_template ) { |
|
305 | + $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
306 | + } |
|
307 | 307 | |
308 | - if ( $item->is_template ) { |
|
308 | + if ( $item->is_template ) { |
|
309 | 309 | $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
310 | - } else { |
|
311 | - $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
310 | + } else { |
|
311 | + $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
312 | 312 | |
313 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
313 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
314 | 314 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
315 | - } |
|
316 | - } |
|
317 | - } |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | 318 | |
319 | 319 | $actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
320 | 320 | if ( empty( $actions['trash'] ) ) { |
@@ -323,52 +323,52 @@ discard block |
||
323 | 323 | } |
324 | 324 | |
325 | 325 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
326 | - } |
|
326 | + } |
|
327 | 327 | |
328 | - /** |
|
329 | - * @param string $edit_link |
|
330 | - */ |
|
328 | + /** |
|
329 | + * @param string $edit_link |
|
330 | + */ |
|
331 | 331 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
332 | - $form_name = $item->name; |
|
333 | - if ( trim($form_name) == '' ) { |
|
334 | - $form_name = __( '(no title)'); |
|
335 | - } |
|
332 | + $form_name = $item->name; |
|
333 | + if ( trim($form_name) == '' ) { |
|
334 | + $form_name = __( '(no title)'); |
|
335 | + } |
|
336 | 336 | $form_name = FrmAppHelper::kses( $form_name ); |
337 | 337 | if ( 'excerpt' != $mode ) { |
338 | 338 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
339 | 339 | } |
340 | 340 | |
341 | - $val = '<strong>'; |
|
342 | - if ( 'trash' == $this->status ) { |
|
343 | - $val .= $form_name; |
|
344 | - } else { |
|
341 | + $val = '<strong>'; |
|
342 | + if ( 'trash' == $this->status ) { |
|
343 | + $val .= $form_name; |
|
344 | + } else { |
|
345 | 345 | $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> '; |
346 | - } |
|
347 | - |
|
348 | - $this->add_draft_label( $item, $val ); |
|
349 | - $val .= '</strong>'; |
|
350 | - |
|
351 | - $this->add_form_description( $item, $val ); |
|
352 | - |
|
353 | - return $val; |
|
354 | - } |
|
355 | - |
|
356 | - /** |
|
357 | - * @param string $val |
|
358 | - */ |
|
359 | - private function add_draft_label( $item, &$val ) { |
|
360 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
361 | - $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
362 | - } |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * @param string $val |
|
367 | - */ |
|
368 | - private function add_form_description( $item, &$val ) { |
|
369 | - global $mode; |
|
370 | - if ( 'excerpt' == $mode ) { |
|
371 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
372 | - } |
|
373 | - } |
|
346 | + } |
|
347 | + |
|
348 | + $this->add_draft_label( $item, $val ); |
|
349 | + $val .= '</strong>'; |
|
350 | + |
|
351 | + $this->add_form_description( $item, $val ); |
|
352 | + |
|
353 | + return $val; |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * @param string $val |
|
358 | + */ |
|
359 | + private function add_draft_label( $item, &$val ) { |
|
360 | + if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
361 | + $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
362 | + } |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * @param string $val |
|
367 | + */ |
|
368 | + private function add_form_description( $item, &$val ) { |
|
369 | + global $mode; |
|
370 | + if ( 'excerpt' == $mode ) { |
|
371 | + $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
372 | + } |
|
373 | + } |
|
374 | 374 | } |
@@ -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,19 +48,19 @@ 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 | |
63 | - $this->items = FrmForm::getAll($s_query, $orderby .' '. $order, $start .','. $per_page); |
|
63 | + $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); |
|
64 | 64 | $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
65 | 65 | |
66 | 66 | $this->set_pagination_args( array( |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | if ( 'template' == $this->status ) { |
74 | 74 | _e( 'No Templates Found.', 'formidable' ) ?> |
75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
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> |
|
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> |
|
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; |
@@ -204,10 +204,10 @@ discard block |
||
204 | 204 | |
205 | 205 | // Set up the hover actions for this user |
206 | 206 | $actions = array(); |
207 | - $edit_link = '?page=formidable&frm_action=edit&id='. $item->id; |
|
208 | - $duplicate_link = '?page=formidable&frm_action=duplicate&id='. $item->id; |
|
207 | + $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
|
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 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | foreach ( $columns as $column_name => $column_display_name ) { |
227 | - $class = $column_name .' column-'. $column_name . ( ('name' == $column_name) ? ' post-title page-title column-title' : '' ); |
|
227 | + $class = $column_name . ' column-' . $column_name . ( ( 'name' == $column_name ) ? ' post-title page-title column-title' : '' ); |
|
228 | 228 | |
229 | 229 | $style = ''; |
230 | 230 | if ( in_array( $column_name, $hidden ) ) { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | switch ( $column_name ) { |
239 | 239 | case 'cb': |
240 | - $r .= '<th scope="row" class="check-column">'. $checkbox .'</th>'; |
|
240 | + $r .= '<th scope="row" class="check-column">' . $checkbox . '</th>'; |
|
241 | 241 | break; |
242 | 242 | case 'id': |
243 | 243 | case 'form_key': |
@@ -249,22 +249,22 @@ 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': |
256 | - $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id .']' ) . '" /><br/>'; |
|
256 | + $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>'; |
|
257 | 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 | 259 | } |
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,25 +290,25 @@ 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') ) { |
|
298 | - $actions['trash'] = '<a href="' . esc_url(wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id='. $item->id, 'destroy_form_'. $item->id )) .'" class="submitdelete" onclick="return confirm(\''. __( 'Are you sure you want to permanently delete that?', 'formidable' ) .'\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
297 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
298 | + $actions['trash'] = '<a href="' . esc_url( wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ) ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
|
299 | 299 | } |
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | - if ( current_user_can('frm_edit_forms') ) { |
|
303 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
304 | 304 | if ( ! $item->is_template || ! $item->default_template ) { |
305 | - $actions['frm_edit'] = '<a href="'. esc_url( $edit_link ) . '">'. __( 'Edit') .'</a>'; |
|
305 | + $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | if ( $item->is_template ) { |
309 | - $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
|
309 | + $actions['frm_duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
|
310 | 310 | } else { |
311 | - $actions['frm_settings'] = '<a href="'. esc_url('?page=formidable&frm_action=settings&id='. $item->id ) . '">'. __( 'Settings', 'formidable' ) .'</a>'; |
|
311 | + $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
|
312 | 312 | |
313 | 313 | if ( FrmAppHelper::pro_is_installed() ) { |
314 | 314 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | unset( $actions['trash'] ); |
323 | 323 | } |
324 | 324 | |
325 | - $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
|
325 | + $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | */ |
331 | 331 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
332 | 332 | $form_name = $item->name; |
333 | - if ( trim($form_name) == '' ) { |
|
334 | - $form_name = __( '(no title)'); |
|
333 | + if ( trim( $form_name ) == '' ) { |
|
334 | + $form_name = __( '(no title)' ); |
|
335 | 335 | } |
336 | 336 | $form_name = FrmAppHelper::kses( $form_name ); |
337 | 337 | if ( 'excerpt' != $mode ) { |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | private function add_draft_label( $item, &$val ) { |
360 | 360 | if ( 'draft' == $item->status && 'draft' != $this->status ) { |
361 | - $val .= ' - <span class="post-state">'. __( 'Draft', 'formidable' ) .'</span>'; |
|
361 | + $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | private function add_form_description( $item, &$val ) { |
369 | 369 | global $mode; |
370 | 370 | if ( 'excerpt' == $mode ) { |
371 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
371 | + $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | } |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | class FrmAddonsController { |
4 | 4 | |
5 | 5 | public static function menu() { |
6 | - add_submenu_page( 'formidable', 'Formidable | '. __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
6 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'AddOns', 'formidable' ), __( 'AddOns', 'formidable' ), 'frm_view_forms', 'formidable-addons', 'FrmAddonsController::list_addons' ); |
|
7 | 7 | |
8 | 8 | $affiliate = FrmAppHelper::get_affiliate(); |
9 | 9 | if ( ! empty( $affiliate ) && ! FrmAppHelper::pro_is_installed() ) { |
10 | - add_submenu_page( 'formidable', 'Formidable | '. __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' ); |
|
10 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Upgrade to Pro', 'formidable' ), __( 'Upgrade to Pro', 'formidable' ), 'frm_view_forms', 'formidable-pro-upgrade', 'FrmAddonsController::upgrade_to_pro' ); |
|
11 | 11 | } |
12 | 12 | } |
13 | 13 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $keyed_addons = array(); |
41 | 41 | foreach ( $addons as $addon ) { |
42 | - $keyed_addons[ $addon['info']['slug'] ] = $addon; |
|
42 | + $keyed_addons[$addon['info']['slug']] = $addon; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $plugin_order = array( |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | ); |
49 | 49 | $ordered_addons = array(); |
50 | 50 | foreach ( $plugin_order as $plugin ) { |
51 | - if ( isset( $keyed_addons[ $plugin ] ) ) { |
|
52 | - $ordered_addons[] = $keyed_addons[ $plugin ]; |
|
53 | - unset( $keyed_addons[ $plugin ] ); |
|
51 | + if ( isset( $keyed_addons[$plugin] ) ) { |
|
52 | + $ordered_addons[] = $keyed_addons[$plugin]; |
|
53 | + unset( $keyed_addons[$plugin] ); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | $addons = $ordered_addons + $keyed_addons; |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | public static function get_licenses() { |
88 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
88 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
89 | 89 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
90 | 90 | |
91 | - $license = get_option('frmpro-credentials'); |
|
91 | + $license = get_option( 'frmpro-credentials' ); |
|
92 | 92 | if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
93 | - $url = 'http://formidablepro.com/frm-edd-api/licenses?l='. urlencode( base64_encode( $license['license'] ) ); |
|
93 | + $url = 'http://formidablepro.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
|
94 | 94 | $licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) ); |
95 | 95 | echo json_encode( $licenses ); |
96 | 96 | } |
@@ -2,137 +2,137 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | - public static function load_field() { |
|
5 | + public static function load_field() { |
|
6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
8 | 8 | |
9 | - $fields = $_POST['field']; |
|
10 | - if ( empty( $fields ) ) { |
|
11 | - wp_die(); |
|
12 | - } |
|
9 | + $fields = $_POST['field']; |
|
10 | + if ( empty( $fields ) ) { |
|
11 | + wp_die(); |
|
12 | + } |
|
13 | 13 | |
14 | - $_GET['page'] = 'formidable'; |
|
15 | - $fields = stripslashes_deep( $fields ); |
|
14 | + $_GET['page'] = 'formidable'; |
|
15 | + $fields = stripslashes_deep( $fields ); |
|
16 | 16 | |
17 | - $ajax = true; |
|
17 | + $ajax = true; |
|
18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
19 | - $path = FrmAppHelper::plugin_path(); |
|
20 | - $field_html = array(); |
|
21 | - |
|
22 | - foreach ( $fields as $field ) { |
|
23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | - $field = json_decode( $field, true ); |
|
25 | - if ( ! isset( $field['id'] ) ) { |
|
26 | - // this field may have already been loaded |
|
27 | - continue; |
|
28 | - } |
|
19 | + $path = FrmAppHelper::plugin_path(); |
|
20 | + $field_html = array(); |
|
21 | + |
|
22 | + foreach ( $fields as $field ) { |
|
23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
24 | + $field = json_decode( $field, true ); |
|
25 | + if ( ! isset( $field['id'] ) ) { |
|
26 | + // this field may have already been loaded |
|
27 | + continue; |
|
28 | + } |
|
29 | 29 | |
30 | - $field_id = absint( $field['id'] ); |
|
30 | + $field_id = absint( $field['id'] ); |
|
31 | 31 | |
32 | - if ( ! isset( $field['value'] ) ) { |
|
33 | - $field['value'] = ''; |
|
34 | - } |
|
32 | + if ( ! isset( $field['value'] ) ) { |
|
33 | + $field['value'] = ''; |
|
34 | + } |
|
35 | 35 | |
36 | - $field_name = 'item_meta['. $field_id .']'; |
|
37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
36 | + $field_name = 'item_meta['. $field_id .']'; |
|
37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
38 | 38 | |
39 | - ob_start(); |
|
40 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
42 | - ob_end_clean(); |
|
43 | - } |
|
39 | + ob_start(); |
|
40 | + include($path .'/classes/views/frm-forms/add_field.php'); |
|
41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
42 | + ob_end_clean(); |
|
43 | + } |
|
44 | 44 | |
45 | - unset($path); |
|
45 | + unset($path); |
|
46 | 46 | |
47 | - echo json_encode($field_html); |
|
47 | + echo json_encode($field_html); |
|
48 | 48 | |
49 | - wp_die(); |
|
50 | - } |
|
49 | + wp_die(); |
|
50 | + } |
|
51 | 51 | |
52 | - public static function create() { |
|
52 | + public static function create() { |
|
53 | 53 | FrmAppHelper::permission_check('frm_edit_forms'); |
54 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
54 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
55 | 55 | |
56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
58 | 58 | |
59 | - $field = self::include_new_field($field_type, $form_id); |
|
59 | + $field = self::include_new_field($field_type, $form_id); |
|
60 | 60 | |
61 | - // this hook will allow for multiple fields to be added at once |
|
62 | - do_action('frm_after_field_created', $field, $form_id); |
|
61 | + // this hook will allow for multiple fields to be added at once |
|
62 | + do_action('frm_after_field_created', $field, $form_id); |
|
63 | 63 | |
64 | - wp_die(); |
|
65 | - } |
|
64 | + wp_die(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param integer $form_id |
|
69 | - */ |
|
67 | + /** |
|
68 | + * @param integer $form_id |
|
69 | + */ |
|
70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
71 | - $values = array(); |
|
72 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
74 | - } |
|
71 | + $values = array(); |
|
72 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
73 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
74 | + } |
|
75 | 75 | |
76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
77 | - $field_id = FrmField::create( $field_values ); |
|
76 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
77 | + $field_id = FrmField::create( $field_values ); |
|
78 | 78 | |
79 | - if ( ! $field_id ) { |
|
80 | - return false; |
|
81 | - } |
|
79 | + if ( ! $field_id ) { |
|
80 | + return false; |
|
81 | + } |
|
82 | 82 | |
83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
83 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
84 | 84 | |
85 | - return $field; |
|
86 | - } |
|
85 | + return $field; |
|
86 | + } |
|
87 | 87 | |
88 | - public static function update_form_id() { |
|
88 | + public static function update_form_id() { |
|
89 | 89 | FrmAppHelper::permission_check('frm_edit_forms'); |
90 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
90 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
91 | 91 | |
92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
93 | 93 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
94 | 94 | |
95 | - if ( ! $field_id || ! $form_id ) { |
|
96 | - wp_die(); |
|
97 | - } |
|
95 | + if ( ! $field_id || ! $form_id ) { |
|
96 | + wp_die(); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
100 | 100 | echo absint( $updated ); |
101 | 101 | |
102 | - wp_die(); |
|
103 | - } |
|
102 | + wp_die(); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
106 | 106 | FrmAppHelper::permission_check('frm_edit_forms'); |
107 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
107 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
108 | 108 | |
109 | - if ( empty($field) ) { |
|
110 | - $field = 'name'; |
|
111 | - } |
|
109 | + if ( empty($field) ) { |
|
110 | + $field = 'name'; |
|
111 | + } |
|
112 | 112 | |
113 | - if ( empty($id) ) { |
|
113 | + if ( empty($id) ) { |
|
114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
116 | - } |
|
116 | + } |
|
117 | 117 | |
118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
119 | 119 | $value = trim( $value ); |
120 | - if ( trim(strip_tags($value)) == '' ) { |
|
121 | - // set blank value if there is no content |
|
122 | - $value = ''; |
|
123 | - } |
|
120 | + if ( trim(strip_tags($value)) == '' ) { |
|
121 | + // set blank value if there is no content |
|
122 | + $value = ''; |
|
123 | + } |
|
124 | 124 | |
125 | 125 | FrmField::update( $id, array( $field => $value ) ); |
126 | 126 | |
127 | 127 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
128 | 128 | |
129 | 129 | echo stripslashes( wp_kses_post( $value ) ); |
130 | - wp_die(); |
|
131 | - } |
|
130 | + wp_die(); |
|
131 | + } |
|
132 | 132 | |
133 | - public static function update_ajax_option() { |
|
133 | + public static function update_ajax_option() { |
|
134 | 134 | FrmAppHelper::permission_check('frm_edit_forms'); |
135 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
135 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
136 | 136 | |
137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
138 | 138 | if ( ! $field_id ) { |
@@ -142,155 +142,155 @@ discard block |
||
142 | 142 | $field = FrmField::getOne( $field_id ); |
143 | 143 | |
144 | 144 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
145 | - if ( isset($_POST[ $val ]) ) { |
|
145 | + if ( isset($_POST[ $val ]) ) { |
|
146 | 146 | // all three of these options are boolean |
147 | 147 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
148 | 148 | |
149 | - if ( $val == 'separate_value' ) { |
|
149 | + if ( $val == 'separate_value' ) { |
|
150 | 150 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | - $field->field_options[ $val ] = $new_val; |
|
154 | - unset($new_val); |
|
155 | - } |
|
156 | - unset($val); |
|
157 | - } |
|
153 | + $field->field_options[ $val ] = $new_val; |
|
154 | + unset($new_val); |
|
155 | + } |
|
156 | + unset($val); |
|
157 | + } |
|
158 | 158 | |
159 | - FrmField::update( $field_id, array( |
|
160 | - 'field_options' => $field->field_options, |
|
159 | + FrmField::update( $field_id, array( |
|
160 | + 'field_options' => $field->field_options, |
|
161 | 161 | 'form_id' => $field->form_id, |
162 | - ) ); |
|
163 | - wp_die(); |
|
164 | - } |
|
162 | + ) ); |
|
163 | + wp_die(); |
|
164 | + } |
|
165 | 165 | |
166 | - public static function duplicate() { |
|
166 | + public static function duplicate() { |
|
167 | 167 | FrmAppHelper::permission_check('frm_edit_forms'); |
168 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
168 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
169 | 169 | |
170 | - global $wpdb; |
|
170 | + global $wpdb; |
|
171 | 171 | |
172 | 172 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
173 | 173 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
174 | 174 | |
175 | 175 | $copy_field = FrmField::getOne( $field_id ); |
176 | - if ( ! $copy_field ) { |
|
177 | - wp_die(); |
|
178 | - } |
|
176 | + if ( ! $copy_field ) { |
|
177 | + wp_die(); |
|
178 | + } |
|
179 | 179 | |
180 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
181 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
180 | + do_action('frm_duplicate_field', $copy_field, $form_id); |
|
181 | + do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
182 | 182 | |
183 | - $values = array( 'id' => $form_id ); |
|
184 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
183 | + $values = array( 'id' => $form_id ); |
|
184 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
185 | 185 | |
186 | 186 | $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
187 | 187 | |
188 | - $values['field_order'] = $field_count + 1; |
|
188 | + $values['field_order'] = $field_count + 1; |
|
189 | 189 | |
190 | - if ( ! $field_id = FrmField::create($values) ) { |
|
191 | - wp_die(); |
|
192 | - } |
|
190 | + if ( ! $field_id = FrmField::create($values) ) { |
|
191 | + wp_die(); |
|
192 | + } |
|
193 | 193 | |
194 | - self::include_single_field($field_id, $values); |
|
194 | + self::include_single_field($field_id, $values); |
|
195 | 195 | |
196 | - wp_die(); |
|
197 | - } |
|
196 | + wp_die(); |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * Load a single field in the form builder along with all needed variables |
|
201 | - */ |
|
202 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
203 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
204 | - $field_name = 'item_meta['. $field_id .']'; |
|
205 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
206 | - $id = $form_id ? $form_id : $field['form_id']; |
|
207 | - if ( $field['type'] == 'html' ) { |
|
208 | - $field['stop_filter'] = true; |
|
209 | - } |
|
199 | + /** |
|
200 | + * Load a single field in the form builder along with all needed variables |
|
201 | + */ |
|
202 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
203 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
204 | + $field_name = 'item_meta['. $field_id .']'; |
|
205 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
206 | + $id = $form_id ? $form_id : $field['form_id']; |
|
207 | + if ( $field['type'] == 'html' ) { |
|
208 | + $field['stop_filter'] = true; |
|
209 | + } |
|
210 | 210 | |
211 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
211 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
212 | 212 | |
213 | - return $field; |
|
214 | - } |
|
213 | + return $field; |
|
214 | + } |
|
215 | 215 | |
216 | - public static function destroy() { |
|
216 | + public static function destroy() { |
|
217 | 217 | FrmAppHelper::permission_check('frm_edit_forms'); |
218 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
218 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
219 | 219 | |
220 | 220 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
221 | 221 | FrmField::destroy( $field_id ); |
222 | - wp_die(); |
|
223 | - } |
|
222 | + wp_die(); |
|
223 | + } |
|
224 | 224 | |
225 | - /* Field Options */ |
|
225 | + /* Field Options */ |
|
226 | 226 | |
227 | - //Add Single Option or Other Option |
|
228 | - public static function add_option() { |
|
227 | + //Add Single Option or Other Option |
|
228 | + public static function add_option() { |
|
229 | 229 | FrmAppHelper::permission_check('frm_edit_forms'); |
230 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
230 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
231 | 231 | |
232 | 232 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
233 | 233 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
234 | 234 | |
235 | - //Get the field |
|
236 | - $field = FrmField::getOne($id); |
|
235 | + //Get the field |
|
236 | + $field = FrmField::getOne($id); |
|
237 | 237 | |
238 | 238 | if ( ! empty( $field->options ) ) { |
239 | 239 | $keys = array_keys( $field->options ); |
240 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
241 | - } else { |
|
242 | - $last = 0; |
|
243 | - } |
|
244 | - $opt_key = $last + 1; |
|
240 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
241 | + } else { |
|
242 | + $last = 0; |
|
243 | + } |
|
244 | + $opt_key = $last + 1; |
|
245 | 245 | |
246 | - if ( 'other' == $opt_type ) { |
|
246 | + if ( 'other' == $opt_type ) { |
|
247 | 247 | $opt = esc_html__( 'Other', 'formidable' ); |
248 | - $other_val = ''; |
|
249 | - $opt_key = 'other_' . $opt_key; |
|
250 | - |
|
251 | - //Update value of "other" in DB |
|
252 | - $field_options = maybe_unserialize( $field->field_options ); |
|
253 | - $field_options['other'] = 1; |
|
254 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
255 | - } else { |
|
248 | + $other_val = ''; |
|
249 | + $opt_key = 'other_' . $opt_key; |
|
250 | + |
|
251 | + //Update value of "other" in DB |
|
252 | + $field_options = maybe_unserialize( $field->field_options ); |
|
253 | + $field_options['other'] = 1; |
|
254 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
255 | + } else { |
|
256 | 256 | $first_opt = reset( $field->options ); |
257 | 257 | $next_opt = count( $field->options ); |
258 | - if ( $first_opt != '' ) { |
|
259 | - $next_opt++; |
|
260 | - } |
|
261 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
262 | - unset($next_opt); |
|
263 | - } |
|
264 | - $field_val = $opt; |
|
258 | + if ( $first_opt != '' ) { |
|
259 | + $next_opt++; |
|
260 | + } |
|
261 | + $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
262 | + unset($next_opt); |
|
263 | + } |
|
264 | + $field_val = $opt; |
|
265 | 265 | $field->options[ $opt_key ] = $opt; |
266 | 266 | |
267 | - //Update options in DB |
|
267 | + //Update options in DB |
|
268 | 268 | FrmField::update( $id, array( 'options' => $field->options ) ); |
269 | 269 | |
270 | - $field_data = $field; |
|
271 | - $field = array( |
|
272 | - 'type' => $field_data->type, |
|
273 | - 'id' => $id, |
|
274 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
275 | - 'form_id' => $field_data->form_id, |
|
276 | - 'field_key' => $field_data->field_key, |
|
277 | - ); |
|
278 | - |
|
279 | - $field_name = 'item_meta['. $id .']'; |
|
280 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
281 | - $checked = ''; |
|
282 | - |
|
283 | - if ( 'other' == $opt_type ) { |
|
284 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
285 | - } else { |
|
286 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
287 | - } |
|
288 | - wp_die(); |
|
289 | - } |
|
290 | - |
|
291 | - public static function edit_option() { |
|
270 | + $field_data = $field; |
|
271 | + $field = array( |
|
272 | + 'type' => $field_data->type, |
|
273 | + 'id' => $id, |
|
274 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
275 | + 'form_id' => $field_data->form_id, |
|
276 | + 'field_key' => $field_data->field_key, |
|
277 | + ); |
|
278 | + |
|
279 | + $field_name = 'item_meta['. $id .']'; |
|
280 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
281 | + $checked = ''; |
|
282 | + |
|
283 | + if ( 'other' == $opt_type ) { |
|
284 | + require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
285 | + } else { |
|
286 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
287 | + } |
|
288 | + wp_die(); |
|
289 | + } |
|
290 | + |
|
291 | + public static function edit_option() { |
|
292 | 292 | FrmAppHelper::permission_check('frm_edit_forms'); |
293 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
293 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
294 | 294 | |
295 | 295 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
296 | 296 | $ids = explode( '-', $element_id ); |
@@ -298,43 +298,43 @@ discard block |
||
298 | 298 | |
299 | 299 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) ); |
300 | 300 | if ( strpos( $element_id, 'key_' ) ) { |
301 | - $new_value = $update_value; |
|
302 | - } else { |
|
303 | - $new_label = $update_value; |
|
304 | - } |
|
301 | + $new_value = $update_value; |
|
302 | + } else { |
|
303 | + $new_label = $update_value; |
|
304 | + } |
|
305 | 305 | |
306 | - $field = FrmField::getOne($id); |
|
307 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
306 | + $field = FrmField::getOne($id); |
|
307 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
308 | 308 | |
309 | - $this_opt_id = end($ids); |
|
309 | + $this_opt_id = end($ids); |
|
310 | 310 | $this_opt = (array) $field->options[ $this_opt_id ]; |
311 | 311 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
312 | 312 | |
313 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
314 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
313 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
314 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
315 | 315 | |
316 | - if ( ! isset( $new_label ) ) { |
|
317 | - $new_label = $label; |
|
318 | - } |
|
316 | + if ( ! isset( $new_label ) ) { |
|
317 | + $new_label = $label; |
|
318 | + } |
|
319 | 319 | |
320 | - if ( isset($new_value) || isset($value) ) { |
|
321 | - $update_value = isset($new_value) ? $new_value : $value; |
|
322 | - } |
|
320 | + if ( isset($new_value) || isset($value) ) { |
|
321 | + $update_value = isset($new_value) ? $new_value : $value; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
325 | 325 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
326 | - } else { |
|
326 | + } else { |
|
327 | 327 | $field->options[ $this_opt_id ] = $orig_update_value; |
328 | - } |
|
328 | + } |
|
329 | 329 | |
330 | 330 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
331 | 331 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
332 | - wp_die(); |
|
333 | - } |
|
332 | + wp_die(); |
|
333 | + } |
|
334 | 334 | |
335 | - public static function delete_option() { |
|
335 | + public static function delete_option() { |
|
336 | 336 | FrmAppHelper::permission_check('frm_edit_forms'); |
337 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
337 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
338 | 338 | |
339 | 339 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
340 | 340 | $field = FrmField::getOne( $field_id ); |
@@ -342,340 +342,340 @@ discard block |
||
342 | 342 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
343 | 343 | |
344 | 344 | $options = $field->options; |
345 | - unset( $options[ $opt_key ] ); |
|
346 | - $response = array( 'other' => true ); |
|
345 | + unset( $options[ $opt_key ] ); |
|
346 | + $response = array( 'other' => true ); |
|
347 | 347 | |
348 | - //If the deleted option is an "other" option |
|
348 | + //If the deleted option is an "other" option |
|
349 | 349 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
350 | - //Assume all other options are gone, unless proven otherwise |
|
351 | - $other = false; |
|
350 | + //Assume all other options are gone, unless proven otherwise |
|
351 | + $other = false; |
|
352 | 352 | |
353 | - //Check if all other options are really gone |
|
354 | - foreach ( $options as $o_key => $o_val ) { |
|
355 | - //If there is still an other option in the field, set other to true |
|
353 | + //Check if all other options are really gone |
|
354 | + foreach ( $options as $o_key => $o_val ) { |
|
355 | + //If there is still an other option in the field, set other to true |
|
356 | 356 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
357 | - $other = true; |
|
358 | - break; |
|
359 | - } |
|
360 | - unset( $o_key, $o_val ); |
|
361 | - } |
|
362 | - |
|
363 | - //If all other options are gone |
|
364 | - if ( false === $other ) { |
|
365 | - $field_options = maybe_unserialize( $field->field_options ); |
|
366 | - $field_options['other'] = 0; |
|
357 | + $other = true; |
|
358 | + break; |
|
359 | + } |
|
360 | + unset( $o_key, $o_val ); |
|
361 | + } |
|
362 | + |
|
363 | + //If all other options are gone |
|
364 | + if ( false === $other ) { |
|
365 | + $field_options = maybe_unserialize( $field->field_options ); |
|
366 | + $field_options['other'] = 0; |
|
367 | 367 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
368 | - $response = array( 'other' => false ); |
|
369 | - } |
|
370 | - } |
|
371 | - echo json_encode( $response ); |
|
368 | + $response = array( 'other' => false ); |
|
369 | + } |
|
370 | + } |
|
371 | + echo json_encode( $response ); |
|
372 | 372 | |
373 | 373 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
374 | 374 | |
375 | - wp_die(); |
|
376 | - } |
|
375 | + wp_die(); |
|
376 | + } |
|
377 | 377 | |
378 | - public static function import_choices() { |
|
379 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
378 | + public static function import_choices() { |
|
379 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
380 | 380 | |
381 | 381 | $field_id = absint( $_REQUEST['field_id'] ); |
382 | 382 | |
383 | - global $current_screen, $hook_suffix; |
|
383 | + global $current_screen, $hook_suffix; |
|
384 | 384 | |
385 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
386 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
387 | - $hook_suffix = ''; |
|
388 | - set_current_screen(); |
|
389 | - } |
|
385 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
386 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
387 | + $hook_suffix = ''; |
|
388 | + set_current_screen(); |
|
389 | + } |
|
390 | 390 | |
391 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
392 | - register_admin_color_schemes(); |
|
393 | - } |
|
391 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
392 | + register_admin_color_schemes(); |
|
393 | + } |
|
394 | 394 | |
395 | - $hook_suffix = $admin_body_class = ''; |
|
395 | + $hook_suffix = $admin_body_class = ''; |
|
396 | 396 | |
397 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
398 | - $admin_body_class .= ' folded'; |
|
399 | - } |
|
397 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
398 | + $admin_body_class .= ' folded'; |
|
399 | + } |
|
400 | 400 | |
401 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
402 | - $admin_body_class .= ' admin-bar'; |
|
403 | - } |
|
401 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
402 | + $admin_body_class .= ' admin-bar'; |
|
403 | + } |
|
404 | 404 | |
405 | - if ( is_rtl() ) { |
|
406 | - $admin_body_class .= ' rtl'; |
|
407 | - } |
|
405 | + if ( is_rtl() ) { |
|
406 | + $admin_body_class .= ' rtl'; |
|
407 | + } |
|
408 | 408 | |
409 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
410 | - $prepop = array(); |
|
411 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
409 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
410 | + $prepop = array(); |
|
411 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
412 | 412 | |
413 | - $field = FrmField::getOne($field_id); |
|
413 | + $field = FrmField::getOne($field_id); |
|
414 | 414 | |
415 | - wp_enqueue_script( 'utils' ); |
|
416 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
417 | - FrmAppHelper::load_admin_wide_js(); |
|
415 | + wp_enqueue_script( 'utils' ); |
|
416 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
417 | + FrmAppHelper::load_admin_wide_js(); |
|
418 | 418 | |
419 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
420 | - wp_die(); |
|
421 | - } |
|
419 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
420 | + wp_die(); |
|
421 | + } |
|
422 | 422 | |
423 | - public static function import_options() { |
|
423 | + public static function import_options() { |
|
424 | 424 | FrmAppHelper::permission_check('frm_edit_forms'); |
425 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
425 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
426 | 426 | |
427 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
428 | - return; |
|
429 | - } |
|
427 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
428 | + return; |
|
429 | + } |
|
430 | 430 | |
431 | 431 | $field_id = absint( $_POST['field_id'] ); |
432 | - $field = FrmField::getOne($field_id); |
|
432 | + $field = FrmField::getOne($field_id); |
|
433 | 433 | |
434 | 434 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
435 | - return; |
|
436 | - } |
|
437 | - |
|
438 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
439 | - $opts = stripslashes_deep($_POST['opts']); |
|
440 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
441 | - if ( $field['separate_value'] ) { |
|
442 | - foreach ( $opts as $opt_key => $opt ) { |
|
443 | - if ( strpos($opt, '|') !== false ) { |
|
444 | - $vals = explode('|', $opt); |
|
445 | - if ( $vals[0] != $vals[1] ) { |
|
446 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
447 | - } |
|
448 | - unset($vals); |
|
449 | - } |
|
450 | - unset($opt_key, $opt); |
|
451 | - } |
|
452 | - } |
|
453 | - |
|
454 | - //Keep other options after bulk update |
|
455 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
456 | - $other_array = array(); |
|
457 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
458 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
459 | - $other_array[ $opt_key ] = $opt; |
|
460 | - } |
|
461 | - unset($opt_key, $opt); |
|
462 | - } |
|
463 | - if ( ! empty($other_array) ) { |
|
464 | - $opts = array_merge( $opts, $other_array); |
|
465 | - } |
|
466 | - } |
|
467 | - |
|
468 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
469 | - |
|
470 | - $field['options'] = $opts; |
|
471 | - $field_name = $field['name']; |
|
472 | - |
|
473 | - // Get html_id which will be used in single-option.php |
|
474 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
475 | - |
|
476 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
477 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
478 | - } else { |
|
479 | - FrmFieldsHelper::show_single_option($field); |
|
480 | - } |
|
481 | - |
|
482 | - wp_die(); |
|
483 | - } |
|
484 | - |
|
485 | - public static function update_order() { |
|
435 | + return; |
|
436 | + } |
|
437 | + |
|
438 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
439 | + $opts = stripslashes_deep($_POST['opts']); |
|
440 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
441 | + if ( $field['separate_value'] ) { |
|
442 | + foreach ( $opts as $opt_key => $opt ) { |
|
443 | + if ( strpos($opt, '|') !== false ) { |
|
444 | + $vals = explode('|', $opt); |
|
445 | + if ( $vals[0] != $vals[1] ) { |
|
446 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
447 | + } |
|
448 | + unset($vals); |
|
449 | + } |
|
450 | + unset($opt_key, $opt); |
|
451 | + } |
|
452 | + } |
|
453 | + |
|
454 | + //Keep other options after bulk update |
|
455 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
456 | + $other_array = array(); |
|
457 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
458 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
459 | + $other_array[ $opt_key ] = $opt; |
|
460 | + } |
|
461 | + unset($opt_key, $opt); |
|
462 | + } |
|
463 | + if ( ! empty($other_array) ) { |
|
464 | + $opts = array_merge( $opts, $other_array); |
|
465 | + } |
|
466 | + } |
|
467 | + |
|
468 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
469 | + |
|
470 | + $field['options'] = $opts; |
|
471 | + $field_name = $field['name']; |
|
472 | + |
|
473 | + // Get html_id which will be used in single-option.php |
|
474 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
475 | + |
|
476 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
477 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
478 | + } else { |
|
479 | + FrmFieldsHelper::show_single_option($field); |
|
480 | + } |
|
481 | + |
|
482 | + wp_die(); |
|
483 | + } |
|
484 | + |
|
485 | + public static function update_order() { |
|
486 | 486 | FrmAppHelper::permission_check('frm_edit_forms'); |
487 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
487 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
488 | 488 | |
489 | 489 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
490 | 490 | foreach ( (array) $fields as $position => $item ) { |
491 | 491 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
492 | 492 | } |
493 | - wp_die(); |
|
494 | - } |
|
493 | + wp_die(); |
|
494 | + } |
|
495 | 495 | |
496 | 496 | public static function change_type( $type ) { |
497 | - $type_switch = array( |
|
498 | - 'scale' => 'radio', |
|
499 | - '10radio' => 'radio', |
|
500 | - 'rte' => 'textarea', |
|
501 | - 'website' => 'url', |
|
502 | - ); |
|
503 | - if ( isset( $type_switch[ $type ] ) ) { |
|
504 | - $type = $type_switch[ $type ]; |
|
505 | - } |
|
497 | + $type_switch = array( |
|
498 | + 'scale' => 'radio', |
|
499 | + '10radio' => 'radio', |
|
500 | + 'rte' => 'textarea', |
|
501 | + 'website' => 'url', |
|
502 | + ); |
|
503 | + if ( isset( $type_switch[ $type ] ) ) { |
|
504 | + $type = $type_switch[ $type ]; |
|
505 | + } |
|
506 | 506 | |
507 | 507 | $frm_field_selection = FrmField::field_selection(); |
508 | - $types = array_keys($frm_field_selection); |
|
509 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
510 | - $type = 'text'; |
|
511 | - } |
|
508 | + $types = array_keys($frm_field_selection); |
|
509 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
510 | + $type = 'text'; |
|
511 | + } |
|
512 | 512 | |
513 | - return $type; |
|
514 | - } |
|
513 | + return $type; |
|
514 | + } |
|
515 | 515 | |
516 | 516 | public static function display_field_options( $display ) { |
517 | 517 | switch ( $display['type'] ) { |
518 | - case 'captcha': |
|
519 | - $display['required'] = false; |
|
520 | - $display['invalid'] = true; |
|
521 | - $display['default_blank'] = false; |
|
518 | + case 'captcha': |
|
519 | + $display['required'] = false; |
|
520 | + $display['invalid'] = true; |
|
521 | + $display['default_blank'] = false; |
|
522 | 522 | $display['captcha_size'] = true; |
523 | - break; |
|
524 | - case 'radio': |
|
525 | - $display['default_blank'] = false; |
|
526 | - break; |
|
527 | - case 'text': |
|
528 | - case 'textarea': |
|
529 | - $display['size'] = true; |
|
530 | - $display['clear_on_focus'] = true; |
|
531 | - break; |
|
532 | - case 'select': |
|
533 | - $display['size'] = true; |
|
534 | - break; |
|
535 | - case 'url': |
|
536 | - case 'website': |
|
537 | - case 'email': |
|
538 | - $display['size'] = true; |
|
539 | - $display['clear_on_focus'] = true; |
|
540 | - $display['invalid'] = true; |
|
541 | - } |
|
542 | - |
|
543 | - return $display; |
|
544 | - } |
|
545 | - |
|
546 | - public static function input_html( $field, $echo = true ) { |
|
547 | - $class = array(); //$field['type']; |
|
548 | - self::add_input_classes($field, $class); |
|
549 | - |
|
550 | - $add_html = array(); |
|
551 | - self::add_html_size($field, $add_html); |
|
552 | - self::add_html_length($field, $add_html); |
|
553 | - self::add_html_placeholder($field, $add_html, $class); |
|
523 | + break; |
|
524 | + case 'radio': |
|
525 | + $display['default_blank'] = false; |
|
526 | + break; |
|
527 | + case 'text': |
|
528 | + case 'textarea': |
|
529 | + $display['size'] = true; |
|
530 | + $display['clear_on_focus'] = true; |
|
531 | + break; |
|
532 | + case 'select': |
|
533 | + $display['size'] = true; |
|
534 | + break; |
|
535 | + case 'url': |
|
536 | + case 'website': |
|
537 | + case 'email': |
|
538 | + $display['size'] = true; |
|
539 | + $display['clear_on_focus'] = true; |
|
540 | + $display['invalid'] = true; |
|
541 | + } |
|
542 | + |
|
543 | + return $display; |
|
544 | + } |
|
545 | + |
|
546 | + public static function input_html( $field, $echo = true ) { |
|
547 | + $class = array(); //$field['type']; |
|
548 | + self::add_input_classes($field, $class); |
|
549 | + |
|
550 | + $add_html = array(); |
|
551 | + self::add_html_size($field, $add_html); |
|
552 | + self::add_html_length($field, $add_html); |
|
553 | + self::add_html_placeholder($field, $add_html, $class); |
|
554 | 554 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
555 | 555 | |
556 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
556 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
557 | 557 | |
558 | 558 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
559 | 559 | |
560 | - self::add_shortcodes_to_html($field, $add_html); |
|
560 | + self::add_shortcodes_to_html($field, $add_html); |
|
561 | 561 | |
562 | 562 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
563 | 563 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
564 | 564 | |
565 | - if ( $echo ) { |
|
566 | - echo $add_html; |
|
567 | - } |
|
565 | + if ( $echo ) { |
|
566 | + echo $add_html; |
|
567 | + } |
|
568 | 568 | |
569 | - return $add_html; |
|
570 | - } |
|
569 | + return $add_html; |
|
570 | + } |
|
571 | 571 | |
572 | 572 | private static function add_input_classes( $field, array &$class ) { |
573 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
574 | - $class[] = $field['input_class']; |
|
575 | - } |
|
573 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
574 | + $class[] = $field['input_class']; |
|
575 | + } |
|
576 | 576 | |
577 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
578 | - return; |
|
579 | - } |
|
577 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
578 | + return; |
|
579 | + } |
|
580 | 580 | |
581 | - global $frm_vars; |
|
581 | + global $frm_vars; |
|
582 | 582 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
583 | - $class[] = 'dyn_default_value'; |
|
584 | - } |
|
583 | + $class[] = 'dyn_default_value'; |
|
584 | + } |
|
585 | 585 | |
586 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
587 | - $class[] = 'auto_width'; |
|
588 | - } |
|
589 | - } |
|
586 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
587 | + $class[] = 'auto_width'; |
|
588 | + } |
|
589 | + } |
|
590 | 590 | |
591 | 591 | private static function add_html_size( $field, array &$add_html ) { |
592 | 592 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
593 | - return; |
|
594 | - } |
|
593 | + return; |
|
594 | + } |
|
595 | 595 | |
596 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
597 | - return; |
|
598 | - } |
|
596 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
597 | + return; |
|
598 | + } |
|
599 | 599 | |
600 | - if ( is_numeric($field['size']) ) { |
|
601 | - $field['size'] .= 'px'; |
|
602 | - } |
|
600 | + if ( is_numeric($field['size']) ) { |
|
601 | + $field['size'] .= 'px'; |
|
602 | + } |
|
603 | 603 | |
604 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
605 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
606 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
604 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
605 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
606 | + $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
607 | 607 | |
608 | - self::add_html_cols($field, $add_html); |
|
609 | - } |
|
608 | + self::add_html_cols($field, $add_html); |
|
609 | + } |
|
610 | 610 | |
611 | 611 | private static function add_html_cols( $field, array &$add_html ) { |
612 | 612 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
613 | - return; |
|
614 | - } |
|
613 | + return; |
|
614 | + } |
|
615 | 615 | |
616 | - // convert to cols for textareas |
|
617 | - $calc = array( |
|
618 | - '' => 9, |
|
619 | - 'px' => 9, |
|
620 | - 'rem' => 0.444, |
|
621 | - 'em' => 0.544, |
|
622 | - ); |
|
616 | + // convert to cols for textareas |
|
617 | + $calc = array( |
|
618 | + '' => 9, |
|
619 | + 'px' => 9, |
|
620 | + 'rem' => 0.444, |
|
621 | + 'em' => 0.544, |
|
622 | + ); |
|
623 | 623 | |
624 | - // include "col" for valid html |
|
625 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
624 | + // include "col" for valid html |
|
625 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
626 | 626 | |
627 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
628 | - return; |
|
629 | - } |
|
627 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
628 | + return; |
|
629 | + } |
|
630 | 630 | |
631 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
631 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
632 | 632 | |
633 | 633 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
634 | - } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | private static function add_html_length( $field, array &$add_html ) { |
637 | - // check for max setting and if this field accepts maxlength |
|
637 | + // check for max setting and if this field accepts maxlength |
|
638 | 638 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
639 | - return; |
|
640 | - } |
|
639 | + return; |
|
640 | + } |
|
641 | 641 | |
642 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
643 | - // don't load on form builder page |
|
644 | - return; |
|
645 | - } |
|
642 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
643 | + // don't load on form builder page |
|
644 | + return; |
|
645 | + } |
|
646 | 646 | |
647 | 647 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
648 | - } |
|
648 | + } |
|
649 | 649 | |
650 | 650 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
651 | 651 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
652 | 652 | return; |
653 | 653 | } |
654 | 654 | |
655 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
655 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
656 | 656 | if ( is_array( $field['default_value'] ) ) { |
657 | 657 | $field['default_value'] = json_encode( $field['default_value'] ); |
658 | 658 | } |
659 | 659 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
660 | - return; |
|
661 | - } |
|
660 | + return; |
|
661 | + } |
|
662 | 662 | |
663 | - $frm_settings = FrmAppHelper::get_settings(); |
|
663 | + $frm_settings = FrmAppHelper::get_settings(); |
|
664 | 664 | |
665 | 665 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
666 | - // use HMTL5 placeholder with js fallback |
|
667 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
668 | - wp_enqueue_script('jquery-placeholder'); |
|
669 | - } else if ( ! $frm_settings->use_html ) { |
|
666 | + // use HMTL5 placeholder with js fallback |
|
667 | + $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
668 | + wp_enqueue_script('jquery-placeholder'); |
|
669 | + } else if ( ! $frm_settings->use_html ) { |
|
670 | 670 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
671 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
672 | - $class[] = 'frm_toggle_default'; |
|
671 | + $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
672 | + $class[] = 'frm_toggle_default'; |
|
673 | 673 | |
674 | - if ( $field['value'] == $field['default_value'] ) { |
|
675 | - $class[] = 'frm_default'; |
|
676 | - } |
|
677 | - } |
|
678 | - } |
|
674 | + if ( $field['value'] == $field['default_value'] ) { |
|
675 | + $class[] = 'frm_default'; |
|
676 | + } |
|
677 | + } |
|
678 | + } |
|
679 | 679 | |
680 | 680 | private static function add_validation_messages( $field, array &$add_html ) { |
681 | 681 | if ( FrmField::is_required( $field ) ) { |
@@ -696,44 +696,44 @@ discard block |
||
696 | 696 | } |
697 | 697 | } |
698 | 698 | |
699 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
700 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
701 | - return; |
|
702 | - } |
|
703 | - |
|
704 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
705 | - if ( 'opt' === $k ) { |
|
706 | - continue; |
|
707 | - } |
|
708 | - |
|
709 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
710 | - $add_html[] = $v; |
|
711 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
712 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
713 | - } else { |
|
699 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
700 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
701 | + return; |
|
702 | + } |
|
703 | + |
|
704 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
705 | + if ( 'opt' === $k ) { |
|
706 | + continue; |
|
707 | + } |
|
708 | + |
|
709 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
710 | + $add_html[] = $v; |
|
711 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
712 | + $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
713 | + } else { |
|
714 | 714 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
715 | - } |
|
716 | - |
|
717 | - unset($k, $v); |
|
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - public static function check_value( $opt, $opt_key, $field ) { |
|
722 | - if ( is_array( $opt ) ) { |
|
723 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
724 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
725 | - } else { |
|
726 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
727 | - } |
|
728 | - } |
|
729 | - return $opt; |
|
730 | - } |
|
715 | + } |
|
716 | + |
|
717 | + unset($k, $v); |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + public static function check_value( $opt, $opt_key, $field ) { |
|
722 | + if ( is_array( $opt ) ) { |
|
723 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
724 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
725 | + } else { |
|
726 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
727 | + } |
|
728 | + } |
|
729 | + return $opt; |
|
730 | + } |
|
731 | 731 | |
732 | 732 | public static function check_label( $opt ) { |
733 | - if ( is_array($opt) ) { |
|
734 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
735 | - } |
|
733 | + if ( is_array($opt) ) { |
|
734 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
735 | + } |
|
736 | 736 | |
737 | - return $opt; |
|
738 | - } |
|
737 | + return $opt; |
|
738 | + } |
|
739 | 739 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | 5 | public static function load_field() { |
6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
8 | 8 | |
9 | 9 | $fields = $_POST['field']; |
@@ -33,33 +33,33 @@ discard block |
||
33 | 33 | $field['value'] = ''; |
34 | 34 | } |
35 | 35 | |
36 | - $field_name = 'item_meta['. $field_id .']'; |
|
37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
36 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
38 | 38 | |
39 | 39 | ob_start(); |
40 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
40 | + include( $path . '/classes/views/frm-forms/add_field.php' ); |
|
41 | + $field_html[$field_id] = ob_get_contents(); |
|
42 | 42 | ob_end_clean(); |
43 | 43 | } |
44 | 44 | |
45 | - unset($path); |
|
45 | + unset( $path ); |
|
46 | 46 | |
47 | - echo json_encode($field_html); |
|
47 | + echo json_encode( $field_html ); |
|
48 | 48 | |
49 | 49 | wp_die(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function create() { |
53 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
53 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
54 | 54 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
55 | 55 | |
56 | 56 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
57 | 57 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
58 | 58 | |
59 | - $field = self::include_new_field($field_type, $form_id); |
|
59 | + $field = self::include_new_field( $field_type, $form_id ); |
|
60 | 60 | |
61 | 61 | // this hook will allow for multiple fields to be added at once |
62 | - do_action('frm_after_field_created', $field, $form_id); |
|
62 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
63 | 63 | |
64 | 64 | wp_die(); |
65 | 65 | } |
@@ -70,23 +70,23 @@ discard block |
||
70 | 70 | public static function include_new_field( $field_type, $form_id ) { |
71 | 71 | $values = array(); |
72 | 72 | if ( FrmAppHelper::pro_is_installed() ) { |
73 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
73 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
74 | 74 | } |
75 | 75 | |
76 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
76 | + $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) ); |
|
77 | 77 | $field_id = FrmField::create( $field_values ); |
78 | 78 | |
79 | 79 | if ( ! $field_id ) { |
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
83 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
84 | 84 | |
85 | 85 | return $field; |
86 | 86 | } |
87 | 87 | |
88 | 88 | public static function update_form_id() { |
89 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
89 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
90 | 90 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
91 | 91 | |
92 | 92 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | public static function edit_name( $field = 'name', $id = '' ) { |
106 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
106 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
107 | 107 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
108 | 108 | |
109 | - if ( empty($field) ) { |
|
109 | + if ( empty( $field ) ) { |
|
110 | 110 | $field = 'name'; |
111 | 111 | } |
112 | 112 | |
113 | - if ( empty($id) ) { |
|
113 | + if ( empty( $id ) ) { |
|
114 | 114 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
115 | 115 | $id = str_replace( 'field_label_', '', $id ); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
119 | 119 | $value = trim( $value ); |
120 | - if ( trim(strip_tags($value)) == '' ) { |
|
120 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
121 | 121 | // set blank value if there is no content |
122 | 122 | $value = ''; |
123 | 123 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | public static function update_ajax_option() { |
134 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
134 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
135 | 135 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
136 | 136 | |
137 | 137 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $field = FrmField::getOne( $field_id ); |
143 | 143 | |
144 | 144 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
145 | - if ( isset($_POST[ $val ]) ) { |
|
145 | + if ( isset( $_POST[$val] ) ) { |
|
146 | 146 | // all three of these options are boolean |
147 | 147 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
148 | 148 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
151 | 151 | } |
152 | 152 | |
153 | - $field->field_options[ $val ] = $new_val; |
|
154 | - unset($new_val); |
|
153 | + $field->field_options[$val] = $new_val; |
|
154 | + unset( $new_val ); |
|
155 | 155 | } |
156 | - unset($val); |
|
156 | + unset( $val ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | FrmField::update( $field_id, array( |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | public static function duplicate() { |
167 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
167 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
168 | 168 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
169 | 169 | |
170 | 170 | global $wpdb; |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
180 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
181 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
180 | + do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
|
181 | + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
|
182 | 182 | |
183 | 183 | $values = array( 'id' => $form_id ); |
184 | 184 | FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
185 | 185 | |
186 | - $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
186 | + $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
187 | 187 | |
188 | 188 | $values['field_order'] = $field_count + 1; |
189 | 189 | |
190 | - if ( ! $field_id = FrmField::create($values) ) { |
|
190 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
191 | 191 | wp_die(); |
192 | 192 | } |
193 | 193 | |
194 | - self::include_single_field($field_id, $values); |
|
194 | + self::include_single_field( $field_id, $values ); |
|
195 | 195 | |
196 | 196 | wp_die(); |
197 | 197 | } |
@@ -200,21 +200,21 @@ discard block |
||
200 | 200 | * Load a single field in the form builder along with all needed variables |
201 | 201 | */ |
202 | 202 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
203 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
204 | - $field_name = 'item_meta['. $field_id .']'; |
|
205 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
203 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
204 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
205 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
206 | 206 | $id = $form_id ? $form_id : $field['form_id']; |
207 | 207 | if ( $field['type'] == 'html' ) { |
208 | 208 | $field['stop_filter'] = true; |
209 | 209 | } |
210 | 210 | |
211 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
211 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
|
212 | 212 | |
213 | 213 | return $field; |
214 | 214 | } |
215 | 215 | |
216 | 216 | public static function destroy() { |
217 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
217 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
218 | 218 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
219 | 219 | |
220 | 220 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | |
227 | 227 | //Add Single Option or Other Option |
228 | 228 | public static function add_option() { |
229 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
229 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
230 | 230 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
231 | 231 | |
232 | 232 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
233 | 233 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
234 | 234 | |
235 | 235 | //Get the field |
236 | - $field = FrmField::getOne($id); |
|
236 | + $field = FrmField::getOne( $id ); |
|
237 | 237 | |
238 | 238 | if ( ! empty( $field->options ) ) { |
239 | 239 | $keys = array_keys( $field->options ); |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | $first_opt = reset( $field->options ); |
257 | 257 | $next_opt = count( $field->options ); |
258 | 258 | if ( $first_opt != '' ) { |
259 | - $next_opt++; |
|
259 | + $next_opt ++; |
|
260 | 260 | } |
261 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
262 | - unset($next_opt); |
|
261 | + $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
|
262 | + unset( $next_opt ); |
|
263 | 263 | } |
264 | 264 | $field_val = $opt; |
265 | - $field->options[ $opt_key ] = $opt; |
|
265 | + $field->options[$opt_key] = $opt; |
|
266 | 266 | |
267 | 267 | //Update options in DB |
268 | 268 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -271,25 +271,25 @@ discard block |
||
271 | 271 | $field = array( |
272 | 272 | 'type' => $field_data->type, |
273 | 273 | 'id' => $id, |
274 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
274 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
275 | 275 | 'form_id' => $field_data->form_id, |
276 | 276 | 'field_key' => $field_data->field_key, |
277 | 277 | ); |
278 | 278 | |
279 | - $field_name = 'item_meta['. $id .']'; |
|
280 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
279 | + $field_name = 'item_meta[' . $id . ']'; |
|
280 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
281 | 281 | $checked = ''; |
282 | 282 | |
283 | 283 | if ( 'other' == $opt_type ) { |
284 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
284 | + require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
|
285 | 285 | } else { |
286 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
286 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
|
287 | 287 | } |
288 | 288 | wp_die(); |
289 | 289 | } |
290 | 290 | |
291 | 291 | public static function edit_option() { |
292 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
292 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
293 | 293 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
294 | 294 | |
295 | 295 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
@@ -303,28 +303,28 @@ discard block |
||
303 | 303 | $new_label = $update_value; |
304 | 304 | } |
305 | 305 | |
306 | - $field = FrmField::getOne($id); |
|
306 | + $field = FrmField::getOne( $id ); |
|
307 | 307 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
308 | 308 | |
309 | - $this_opt_id = end($ids); |
|
310 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
311 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
|
309 | + $this_opt_id = end( $ids ); |
|
310 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
311 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ); |
|
312 | 312 | |
313 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
314 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
313 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
314 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
315 | 315 | |
316 | 316 | if ( ! isset( $new_label ) ) { |
317 | 317 | $new_label = $label; |
318 | 318 | } |
319 | 319 | |
320 | - if ( isset($new_value) || isset($value) ) { |
|
321 | - $update_value = isset($new_value) ? $new_value : $value; |
|
320 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
321 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
325 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
325 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
326 | 326 | } else { |
327 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
327 | + $field->options[$this_opt_id] = $orig_update_value; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | public static function delete_option() { |
336 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
336 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
337 | 337 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
338 | 338 | |
339 | 339 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
343 | 343 | |
344 | 344 | $options = $field->options; |
345 | - unset( $options[ $opt_key ] ); |
|
345 | + unset( $options[$opt_key] ); |
|
346 | 346 | $response = array( 'other' => true ); |
347 | 347 | |
348 | 348 | //If the deleted option is an "other" option |
@@ -408,46 +408,46 @@ discard block |
||
408 | 408 | |
409 | 409 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
410 | 410 | $prepop = array(); |
411 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
411 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
412 | 412 | |
413 | - $field = FrmField::getOne($field_id); |
|
413 | + $field = FrmField::getOne( $field_id ); |
|
414 | 414 | |
415 | 415 | wp_enqueue_script( 'utils' ); |
416 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
416 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
|
417 | 417 | FrmAppHelper::load_admin_wide_js(); |
418 | 418 | |
419 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
419 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
|
420 | 420 | wp_die(); |
421 | 421 | } |
422 | 422 | |
423 | 423 | public static function import_options() { |
424 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
424 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
425 | 425 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
426 | 426 | |
427 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
427 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
428 | 428 | return; |
429 | 429 | } |
430 | 430 | |
431 | 431 | $field_id = absint( $_POST['field_id'] ); |
432 | - $field = FrmField::getOne($field_id); |
|
432 | + $field = FrmField::getOne( $field_id ); |
|
433 | 433 | |
434 | 434 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
435 | 435 | return; |
436 | 436 | } |
437 | 437 | |
438 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
439 | - $opts = stripslashes_deep($_POST['opts']); |
|
440 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
438 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
439 | + $opts = stripslashes_deep( $_POST['opts'] ); |
|
440 | + $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
|
441 | 441 | if ( $field['separate_value'] ) { |
442 | 442 | foreach ( $opts as $opt_key => $opt ) { |
443 | - if ( strpos($opt, '|') !== false ) { |
|
444 | - $vals = explode('|', $opt); |
|
443 | + if ( strpos( $opt, '|' ) !== false ) { |
|
444 | + $vals = explode( '|', $opt ); |
|
445 | 445 | if ( $vals[0] != $vals[1] ) { |
446 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
446 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
447 | 447 | } |
448 | - unset($vals); |
|
448 | + unset( $vals ); |
|
449 | 449 | } |
450 | - unset($opt_key, $opt); |
|
450 | + unset( $opt_key, $opt ); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -456,12 +456,12 @@ discard block |
||
456 | 456 | $other_array = array(); |
457 | 457 | foreach ( $field['options'] as $opt_key => $opt ) { |
458 | 458 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
459 | - $other_array[ $opt_key ] = $opt; |
|
459 | + $other_array[$opt_key] = $opt; |
|
460 | 460 | } |
461 | - unset($opt_key, $opt); |
|
461 | + unset( $opt_key, $opt ); |
|
462 | 462 | } |
463 | - if ( ! empty($other_array) ) { |
|
464 | - $opts = array_merge( $opts, $other_array); |
|
463 | + if ( ! empty( $other_array ) ) { |
|
464 | + $opts = array_merge( $opts, $other_array ); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -474,16 +474,16 @@ discard block |
||
474 | 474 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
475 | 475 | |
476 | 476 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
477 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
477 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
|
478 | 478 | } else { |
479 | - FrmFieldsHelper::show_single_option($field); |
|
479 | + FrmFieldsHelper::show_single_option( $field ); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | wp_die(); |
483 | 483 | } |
484 | 484 | |
485 | 485 | public static function update_order() { |
486 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
486 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
487 | 487 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
488 | 488 | |
489 | 489 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | 'rte' => 'textarea', |
501 | 501 | 'website' => 'url', |
502 | 502 | ); |
503 | - if ( isset( $type_switch[ $type ] ) ) { |
|
504 | - $type = $type_switch[ $type ]; |
|
503 | + if ( isset( $type_switch[$type] ) ) { |
|
504 | + $type = $type_switch[$type]; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $frm_field_selection = FrmField::field_selection(); |
508 | - $types = array_keys($frm_field_selection); |
|
509 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
508 | + $types = array_keys( $frm_field_selection ); |
|
509 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
510 | 510 | $type = 'text'; |
511 | 511 | } |
512 | 512 | |
@@ -545,19 +545,19 @@ discard block |
||
545 | 545 | |
546 | 546 | public static function input_html( $field, $echo = true ) { |
547 | 547 | $class = array(); //$field['type']; |
548 | - self::add_input_classes($field, $class); |
|
548 | + self::add_input_classes( $field, $class ); |
|
549 | 549 | |
550 | 550 | $add_html = array(); |
551 | - self::add_html_size($field, $add_html); |
|
552 | - self::add_html_length($field, $add_html); |
|
553 | - self::add_html_placeholder($field, $add_html, $class); |
|
551 | + self::add_html_size( $field, $add_html ); |
|
552 | + self::add_html_length( $field, $add_html ); |
|
553 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
554 | 554 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
555 | 555 | |
556 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
556 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
557 | 557 | |
558 | 558 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
559 | 559 | |
560 | - self::add_shortcodes_to_html($field, $add_html); |
|
560 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
561 | 561 | |
562 | 562 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
563 | 563 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | } |
571 | 571 | |
572 | 572 | private static function add_input_classes( $field, array &$class ) { |
573 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
573 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
574 | 574 | $class[] = $field['input_class']; |
575 | 575 | } |
576 | 576 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $class[] = 'dyn_default_value'; |
584 | 584 | } |
585 | 585 | |
586 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
586 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
587 | 587 | $class[] = 'auto_width'; |
588 | 588 | } |
589 | 589 | } |
@@ -593,19 +593,19 @@ discard block |
||
593 | 593 | return; |
594 | 594 | } |
595 | 595 | |
596 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
596 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
597 | 597 | return; |
598 | 598 | } |
599 | 599 | |
600 | - if ( is_numeric($field['size']) ) { |
|
600 | + if ( is_numeric( $field['size'] ) ) { |
|
601 | 601 | $field['size'] .= 'px'; |
602 | 602 | } |
603 | 603 | |
604 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
604 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
605 | 605 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
606 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
606 | + $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
|
607 | 607 | |
608 | - self::add_html_cols($field, $add_html); |
|
608 | + self::add_html_cols( $field, $add_html ); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | ); |
623 | 623 | |
624 | 624 | // include "col" for valid html |
625 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
625 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
626 | 626 | |
627 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
627 | + if ( ! isset( $calc[$unit] ) ) { |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
631 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
632 | 632 | |
633 | 633 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
634 | 634 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | return; |
640 | 640 | } |
641 | 641 | |
642 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
642 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
643 | 643 | // don't load on form builder page |
644 | 644 | return; |
645 | 645 | } |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | |
665 | 665 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
666 | 666 | // use HMTL5 placeholder with js fallback |
667 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
668 | - wp_enqueue_script('jquery-placeholder'); |
|
667 | + $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
|
668 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
669 | 669 | } else if ( ! $frm_settings->use_html ) { |
670 | 670 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
671 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
671 | + $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
|
672 | 672 | $class[] = 'frm_toggle_default'; |
673 | 673 | |
674 | 674 | if ( $field['value'] == $field['default_value'] ) { |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | $format = FrmEntryValidate::phone_format( $field ); |
693 | 693 | $format = substr( $format, 2, -2 ); |
694 | 694 | $key = 'pattern'; |
695 | - $add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"'; |
|
695 | + $add_html[$key] = $key . '="' . esc_attr( $format ) . '"'; |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 | |
@@ -706,15 +706,15 @@ discard block |
||
706 | 706 | continue; |
707 | 707 | } |
708 | 708 | |
709 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
709 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
710 | 710 | $add_html[] = $v; |
711 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
712 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
711 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
712 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
713 | 713 | } else { |
714 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
714 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
715 | 715 | } |
716 | 716 | |
717 | - unset($k, $v); |
|
717 | + unset( $k, $v ); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | } |
731 | 731 | |
732 | 732 | public static function check_label( $opt ) { |
733 | - if ( is_array($opt) ) { |
|
734 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
733 | + if ( is_array( $opt ) ) { |
|
734 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | return $opt; |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class FrmAppController { |
4 | 4 | |
5 | 5 | public static function menu() { |
6 | - FrmAppHelper::maybe_add_permissions(); |
|
7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | - return; |
|
9 | - } |
|
6 | + FrmAppHelper::maybe_add_permissions(); |
|
7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | + return; |
|
9 | + } |
|
10 | 10 | |
11 | - $frm_settings = FrmAppHelper::get_settings(); |
|
12 | - add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
13 | - } |
|
11 | + $frm_settings = FrmAppHelper::get_settings(); |
|
12 | + add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
13 | + } |
|
14 | 14 | |
15 | 15 | private static function get_menu_position() { |
16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,39 +19,39 @@ discard block |
||
19 | 19 | return $pos; |
20 | 20 | } |
21 | 21 | |
22 | - public static function load_wp_admin_style() { |
|
23 | - FrmAppHelper::load_font_style(); |
|
24 | - } |
|
22 | + public static function load_wp_admin_style() { |
|
23 | + FrmAppHelper::load_font_style(); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
27 | - global $pagenow, $frm_vars; |
|
27 | + global $pagenow, $frm_vars; |
|
28 | 28 | |
29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
30 | - if ( empty( $show_nav ) ) { |
|
31 | - return; |
|
32 | - } |
|
30 | + if ( empty( $show_nav ) ) { |
|
31 | + return; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
36 | 36 | $current_page = 'frm_display'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $form ) { |
|
39 | + if ( $form ) { |
|
40 | 40 | FrmForm::maybe_get_form( $form ); |
41 | 41 | |
42 | - if ( is_object( $form ) ) { |
|
43 | - $id = $form->id; |
|
44 | - } |
|
45 | - } |
|
42 | + if ( is_object( $form ) ) { |
|
43 | + $id = $form->id; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - if ( ! isset( $id ) ) { |
|
48 | - $form = $id = false; |
|
49 | - } |
|
47 | + if ( ! isset( $id ) ) { |
|
48 | + $form = $id = false; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
52 | 52 | |
53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
54 | - } |
|
53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | private static function get_form_nav_items( $id ) { |
57 | 57 | $nav_items = array( |
@@ -82,28 +82,28 @@ discard block |
||
82 | 82 | return $nav_items; |
83 | 83 | } |
84 | 84 | |
85 | - // Adds a settings link to the plugins page |
|
86 | - public static function settings_link( $links ) { |
|
85 | + // Adds a settings link to the plugins page |
|
86 | + public static function settings_link( $links ) { |
|
87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
88 | - array_unshift( $links, $settings ); |
|
88 | + array_unshift( $links, $settings ); |
|
89 | 89 | |
90 | - return $links; |
|
91 | - } |
|
90 | + return $links; |
|
91 | + } |
|
92 | 92 | |
93 | - public static function pro_get_started_headline() { |
|
93 | + public static function pro_get_started_headline() { |
|
94 | 94 | self::maybe_show_upgrade_bar(); |
95 | 95 | |
96 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
97 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
98 | - return; |
|
99 | - } |
|
96 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
97 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
98 | + return; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
102 | - FrmAppHelper::load_admin_wide_js(); |
|
102 | + FrmAppHelper::load_admin_wide_js(); |
|
103 | 103 | |
104 | - // user is authorized, but running free version |
|
105 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
106 | - ?> |
|
104 | + // user is authorized, but running free version |
|
105 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
106 | + ?> |
|
107 | 107 | <div class="error" class="frm_previous_install"> |
108 | 108 | <?php |
109 | 109 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | ) ); ?> |
116 | 116 | </div> |
117 | 117 | <?php |
118 | - } |
|
119 | - } |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | private static function maybe_show_upgrade_bar() { |
122 | 122 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - public static function admin_js() { |
|
218 | + public static function admin_js() { |
|
219 | 219 | $version = FrmAppHelper::plugin_version(); |
220 | 220 | FrmAppHelper::load_admin_wide_js( false ); |
221 | 221 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
227 | 227 | ), $version, true ); |
228 | 228 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
229 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
229 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
230 | 230 | |
231 | 231 | // load multselect js |
232 | 232 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -237,78 +237,78 @@ discard block |
||
237 | 237 | global $pagenow; |
238 | 238 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
239 | 239 | |
240 | - wp_enqueue_script( 'admin-widgets' ); |
|
241 | - wp_enqueue_style( 'widgets' ); |
|
242 | - wp_enqueue_script( 'formidable' ); |
|
243 | - wp_enqueue_script( 'formidable_admin' ); |
|
240 | + wp_enqueue_script( 'admin-widgets' ); |
|
241 | + wp_enqueue_style( 'widgets' ); |
|
242 | + wp_enqueue_script( 'formidable' ); |
|
243 | + wp_enqueue_script( 'formidable_admin' ); |
|
244 | 244 | FrmAppHelper::localize_script( 'admin' ); |
245 | 245 | |
246 | - wp_enqueue_style( 'formidable-admin' ); |
|
247 | - add_thickbox(); |
|
246 | + wp_enqueue_style( 'formidable-admin' ); |
|
247 | + add_thickbox(); |
|
248 | 248 | |
249 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
249 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
250 | 250 | |
251 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
252 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
253 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
251 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
252 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
253 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
254 | 254 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
255 | 255 | $post = get_post( absint( $_REQUEST['post'] ) ); |
256 | - if ( ! $post ) { |
|
257 | - return; |
|
258 | - } |
|
259 | - $post_type = $post->post_type; |
|
260 | - } else { |
|
261 | - return; |
|
262 | - } |
|
263 | - |
|
264 | - if ( $post_type == 'frm_display' ) { |
|
265 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
266 | - wp_enqueue_script( 'formidable_admin' ); |
|
267 | - wp_enqueue_style( 'formidable-admin' ); |
|
256 | + if ( ! $post ) { |
|
257 | + return; |
|
258 | + } |
|
259 | + $post_type = $post->post_type; |
|
260 | + } else { |
|
261 | + return; |
|
262 | + } |
|
263 | + |
|
264 | + if ( $post_type == 'frm_display' ) { |
|
265 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
266 | + wp_enqueue_script( 'formidable_admin' ); |
|
267 | + wp_enqueue_style( 'formidable-admin' ); |
|
268 | 268 | FrmAppHelper::localize_script( 'admin' ); |
269 | - } |
|
270 | - } else if ( $pagenow == 'widgets.php' ) { |
|
271 | - FrmAppHelper::load_admin_wide_js(); |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - public static function wp_admin_body_class( $classes ) { |
|
276 | - global $wp_version; |
|
277 | - //we need this class everywhere in the admin for the menu |
|
278 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
279 | - $classes .= ' frm_38_trigger'; |
|
280 | - } |
|
281 | - |
|
282 | - return $classes; |
|
283 | - } |
|
284 | - |
|
285 | - public static function load_lang() { |
|
286 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Filter shortcodes in text widgets |
|
291 | - */ |
|
292 | - public static function widget_text_filter( $content ) { |
|
293 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
294 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
295 | - } |
|
296 | - |
|
297 | - public static function widget_text_filter_callback( $matches ) { |
|
298 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
299 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
300 | - } |
|
301 | - |
|
302 | - public static function front_head() { |
|
303 | - if ( is_multisite() ) { |
|
304 | - $old_db_version = get_option( 'frm_db_version' ); |
|
305 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
306 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
307 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
308 | - self::install( $old_db_version ); |
|
309 | - } |
|
310 | - } |
|
311 | - } |
|
269 | + } |
|
270 | + } else if ( $pagenow == 'widgets.php' ) { |
|
271 | + FrmAppHelper::load_admin_wide_js(); |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + public static function wp_admin_body_class( $classes ) { |
|
276 | + global $wp_version; |
|
277 | + //we need this class everywhere in the admin for the menu |
|
278 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
279 | + $classes .= ' frm_38_trigger'; |
|
280 | + } |
|
281 | + |
|
282 | + return $classes; |
|
283 | + } |
|
284 | + |
|
285 | + public static function load_lang() { |
|
286 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Filter shortcodes in text widgets |
|
291 | + */ |
|
292 | + public static function widget_text_filter( $content ) { |
|
293 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
294 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
295 | + } |
|
296 | + |
|
297 | + public static function widget_text_filter_callback( $matches ) { |
|
298 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
299 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
300 | + } |
|
301 | + |
|
302 | + public static function front_head() { |
|
303 | + if ( is_multisite() ) { |
|
304 | + $old_db_version = get_option( 'frm_db_version' ); |
|
305 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
306 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
307 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
308 | + self::install( $old_db_version ); |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | 312 | |
313 | 313 | public static function localize_script( $location ) { |
314 | 314 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -368,20 +368,20 @@ discard block |
||
368 | 368 | wp_die(); |
369 | 369 | } |
370 | 370 | |
371 | - public static function activation_install() { |
|
372 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
373 | - FrmFormActionsController::actions_init(); |
|
374 | - self::install(); |
|
375 | - } |
|
371 | + public static function activation_install() { |
|
372 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
373 | + FrmFormActionsController::actions_init(); |
|
374 | + self::install(); |
|
375 | + } |
|
376 | 376 | |
377 | - public static function install( $old_db_version = false ) { |
|
378 | - $frmdb = new FrmDb(); |
|
379 | - $frmdb->upgrade( $old_db_version ); |
|
380 | - } |
|
377 | + public static function install( $old_db_version = false ) { |
|
378 | + $frmdb = new FrmDb(); |
|
379 | + $frmdb->upgrade( $old_db_version ); |
|
380 | + } |
|
381 | 381 | |
382 | - public static function uninstall() { |
|
382 | + public static function uninstall() { |
|
383 | 383 | FrmAppHelper::permission_check('administrator'); |
384 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
384 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
385 | 385 | |
386 | 386 | $frmdb = new FrmDb(); |
387 | 387 | $frmdb->uninstall(); |
@@ -390,48 +390,48 @@ discard block |
||
390 | 390 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
391 | 391 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
392 | 392 | |
393 | - wp_die(); |
|
394 | - } |
|
393 | + wp_die(); |
|
394 | + } |
|
395 | 395 | |
396 | - public static function drop_tables( $tables ) { |
|
397 | - global $wpdb; |
|
398 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
399 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
400 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
401 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
402 | - return $tables; |
|
403 | - } |
|
396 | + public static function drop_tables( $tables ) { |
|
397 | + global $wpdb; |
|
398 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
399 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
400 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
401 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
402 | + return $tables; |
|
403 | + } |
|
404 | 404 | |
405 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
406 | - public static function page_route( $content ) { |
|
407 | - global $post; |
|
405 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
406 | + public static function page_route( $content ) { |
|
407 | + global $post; |
|
408 | 408 | |
409 | - $frm_settings = FrmAppHelper::get_settings(); |
|
410 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
411 | - $content = FrmFormsController::page_preview(); |
|
412 | - } |
|
409 | + $frm_settings = FrmAppHelper::get_settings(); |
|
410 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
411 | + $content = FrmFormsController::page_preview(); |
|
412 | + } |
|
413 | 413 | |
414 | - return $content; |
|
415 | - } |
|
414 | + return $content; |
|
415 | + } |
|
416 | 416 | |
417 | - public static function deauthorize() { |
|
417 | + public static function deauthorize() { |
|
418 | 418 | FrmAppHelper::permission_check('frm_change_settings'); |
419 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
420 | - |
|
421 | - delete_option( 'frmpro-credentials' ); |
|
422 | - delete_option( 'frmpro-authorized' ); |
|
423 | - delete_site_option( 'frmpro-credentials' ); |
|
424 | - delete_site_option( 'frmpro-authorized' ); |
|
425 | - wp_die(); |
|
426 | - } |
|
427 | - |
|
428 | - public static function get_form_shortcode( $atts ) { |
|
429 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
430 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
431 | - } |
|
432 | - |
|
433 | - public static function get_postbox_class() { |
|
434 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
435 | - return 'postbox-container'; |
|
436 | - } |
|
419 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
420 | + |
|
421 | + delete_option( 'frmpro-credentials' ); |
|
422 | + delete_option( 'frmpro-authorized' ); |
|
423 | + delete_site_option( 'frmpro-credentials' ); |
|
424 | + delete_site_option( 'frmpro-authorized' ); |
|
425 | + wp_die(); |
|
426 | + } |
|
427 | + |
|
428 | + public static function get_form_shortcode( $atts ) { |
|
429 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
430 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
431 | + } |
|
432 | + |
|
433 | + public static function get_postbox_class() { |
|
434 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
435 | + return 'postbox-container'; |
|
436 | + } |
|
437 | 437 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $tip = FrmTipsHelper::get_banner_tip(); |
134 | 134 | ?> |
135 | 135 | <div class="update-nag frm-update-to-pro"> |
136 | - <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip='. absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
136 | + <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
137 | 137 | </div> |
138 | 138 | <?php |
139 | 139 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | public static function uninstall() { |
384 | - FrmAppHelper::permission_check('administrator'); |
|
384 | + FrmAppHelper::permission_check( 'administrator' ); |
|
385 | 385 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
386 | 386 | |
387 | 387 | $frmdb = new FrmDb(); |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | public static function deauthorize() { |
419 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
419 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
420 | 420 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
421 | 421 | |
422 | 422 | delete_option( 'frmpro-credentials' ); |
@@ -1,109 +1,109 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmFormActionsController { |
4 | - public static $action_post_type = 'frm_form_actions'; |
|
5 | - public static $registered_actions; |
|
6 | - |
|
7 | - public static function register_post_types() { |
|
8 | - register_post_type( self::$action_post_type, array( |
|
9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | - 'description' => '', |
|
11 | - 'public' => false, |
|
12 | - 'show_ui' => false, |
|
13 | - 'exclude_from_search' => true, |
|
14 | - 'show_in_nav_menus' => false, |
|
15 | - 'show_in_menu' => true, |
|
16 | - 'capability_type' => 'page', |
|
17 | - 'supports' => array( |
|
4 | + public static $action_post_type = 'frm_form_actions'; |
|
5 | + public static $registered_actions; |
|
6 | + |
|
7 | + public static function register_post_types() { |
|
8 | + register_post_type( self::$action_post_type, array( |
|
9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | + 'description' => '', |
|
11 | + 'public' => false, |
|
12 | + 'show_ui' => false, |
|
13 | + 'exclude_from_search' => true, |
|
14 | + 'show_in_nav_menus' => false, |
|
15 | + 'show_in_menu' => true, |
|
16 | + 'capability_type' => 'page', |
|
17 | + 'supports' => array( |
|
18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
19 | 19 | 'page-attributes', |
20 | - ), |
|
21 | - 'has_archive' => false, |
|
22 | - ) ); |
|
23 | - |
|
24 | - /** |
|
25 | - * post_content: json settings |
|
26 | - * menu_order: form id |
|
27 | - * post_excerpt: action type |
|
28 | - */ |
|
29 | - |
|
30 | - self::actions_init(); |
|
31 | - } |
|
32 | - |
|
33 | - public static function actions_init() { |
|
34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | - self::register_actions(); |
|
36 | - do_action( 'frm_form_actions_init' ); |
|
37 | - } |
|
38 | - |
|
39 | - public static function register_actions() { |
|
40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | - 'email' => 'FrmEmailAction', |
|
42 | - 'wppost' => 'FrmDefPostAction', |
|
43 | - 'register' => 'FrmDefRegAction', |
|
44 | - 'paypal' => 'FrmDefPayPalAction', |
|
45 | - //'aweber' => 'FrmDefAweberAction', |
|
46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | - 'twilio' => 'FrmDefTwilioAction', |
|
48 | - 'highrise' => 'FrmDefHrsAction', |
|
49 | - ) ); |
|
50 | - |
|
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | - |
|
54 | - foreach ( $action_classes as $action_class ) { |
|
55 | - self::$registered_actions->register($action_class); |
|
56 | - } |
|
57 | - } |
|
20 | + ), |
|
21 | + 'has_archive' => false, |
|
22 | + ) ); |
|
23 | + |
|
24 | + /** |
|
25 | + * post_content: json settings |
|
26 | + * menu_order: form id |
|
27 | + * post_excerpt: action type |
|
28 | + */ |
|
29 | + |
|
30 | + self::actions_init(); |
|
31 | + } |
|
32 | + |
|
33 | + public static function actions_init() { |
|
34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | + self::register_actions(); |
|
36 | + do_action( 'frm_form_actions_init' ); |
|
37 | + } |
|
38 | + |
|
39 | + public static function register_actions() { |
|
40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | + 'email' => 'FrmEmailAction', |
|
42 | + 'wppost' => 'FrmDefPostAction', |
|
43 | + 'register' => 'FrmDefRegAction', |
|
44 | + 'paypal' => 'FrmDefPayPalAction', |
|
45 | + //'aweber' => 'FrmDefAweberAction', |
|
46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | + 'twilio' => 'FrmDefTwilioAction', |
|
48 | + 'highrise' => 'FrmDefHrsAction', |
|
49 | + ) ); |
|
50 | + |
|
51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | + |
|
54 | + foreach ( $action_classes as $action_class ) { |
|
55 | + self::$registered_actions->register($action_class); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | - $temp_actions = self::$registered_actions; |
|
61 | - if ( empty($temp_actions) ) { |
|
62 | - self::actions_init(); |
|
63 | - $temp_actions = self::$registered_actions->actions; |
|
64 | - } else { |
|
65 | - $temp_actions = $temp_actions->actions; |
|
66 | - } |
|
60 | + $temp_actions = self::$registered_actions; |
|
61 | + if ( empty($temp_actions) ) { |
|
62 | + self::actions_init(); |
|
63 | + $temp_actions = self::$registered_actions->actions; |
|
64 | + } else { |
|
65 | + $temp_actions = $temp_actions->actions; |
|
66 | + } |
|
67 | 67 | |
68 | - $actions = array(); |
|
68 | + $actions = array(); |
|
69 | 69 | |
70 | - foreach ( $temp_actions as $a ) { |
|
71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | - return $a; |
|
73 | - } |
|
70 | + foreach ( $temp_actions as $a ) { |
|
71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | + return $a; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | $actions[ $a->id_base ] = $a; |
76 | - } |
|
77 | - unset( $temp_actions, $a ); |
|
78 | - |
|
79 | - $action_limit = 10; |
|
80 | - if ( count( $actions ) <= $action_limit ) { |
|
81 | - return $actions; |
|
82 | - } |
|
83 | - |
|
84 | - // remove the last few inactive icons if there are too many |
|
85 | - $temp_actions = $actions; |
|
86 | - arsort( $temp_actions ); |
|
87 | - foreach ( $temp_actions as $type => $a ) { |
|
88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
76 | + } |
|
77 | + unset( $temp_actions, $a ); |
|
78 | + |
|
79 | + $action_limit = 10; |
|
80 | + if ( count( $actions ) <= $action_limit ) { |
|
81 | + return $actions; |
|
82 | + } |
|
83 | + |
|
84 | + // remove the last few inactive icons if there are too many |
|
85 | + $temp_actions = $actions; |
|
86 | + arsort( $temp_actions ); |
|
87 | + foreach ( $temp_actions as $type => $a ) { |
|
88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
89 | 89 | unset( $actions[ $type ] ); |
90 | - if ( count( $actions ) <= $action_limit ) { |
|
91 | - break; |
|
92 | - } |
|
93 | - } |
|
94 | - unset( $type, $a ); |
|
95 | - } |
|
90 | + if ( count( $actions ) <= $action_limit ) { |
|
91 | + break; |
|
92 | + } |
|
93 | + } |
|
94 | + unset( $type, $a ); |
|
95 | + } |
|
96 | 96 | |
97 | - return $actions; |
|
98 | - } |
|
97 | + return $actions; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @since 2.0 |
102 | 102 | */ |
103 | - public static function list_actions( $form, $values ) { |
|
104 | - if ( empty( $form ) ) { |
|
105 | - return; |
|
106 | - } |
|
103 | + public static function list_actions( $form, $values ) { |
|
104 | + if ( empty( $form ) ) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
113 | 113 | |
114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
115 | 115 | |
116 | - $action_controls = self::get_form_actions(); |
|
116 | + $action_controls = self::get_form_actions(); |
|
117 | 117 | |
118 | - $action_map = array(); |
|
118 | + $action_map = array(); |
|
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
122 | - } |
|
121 | + $action_map[ $control->id_base ] = $key; |
|
122 | + } |
|
123 | 123 | |
124 | - foreach ( $form_actions as $action ) { |
|
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | - // don't try and show settings if action no longer exists |
|
127 | - continue; |
|
128 | - } |
|
124 | + foreach ( $form_actions as $action ) { |
|
125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | + // don't try and show settings if action no longer exists |
|
127 | + continue; |
|
128 | + } |
|
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | - } |
|
132 | - } |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
137 | - } |
|
135 | + $action_control->_set($action_key); |
|
136 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
137 | + } |
|
138 | 138 | |
139 | - public static function add_form_action() { |
|
139 | + public static function add_form_action() { |
|
140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
142 | 142 | |
143 | - global $frm_vars; |
|
143 | + global $frm_vars; |
|
144 | 144 | |
145 | 145 | $action_key = absint( $_POST['list_id'] ); |
146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
147 | 147 | |
148 | - $action_control = self::get_form_actions( $action_type ); |
|
149 | - $action_control->_set($action_key); |
|
148 | + $action_control = self::get_form_actions( $action_type ); |
|
149 | + $action_control->_set($action_key); |
|
150 | 150 | |
151 | - $form_id = absint( $_POST['form_id'] ); |
|
151 | + $form_id = absint( $_POST['form_id'] ); |
|
152 | 152 | |
153 | - $form_action = $action_control->prepare_new($form_id); |
|
153 | + $form_action = $action_control->prepare_new($form_id); |
|
154 | 154 | |
155 | - $values = array(); |
|
156 | - $form = self::fields_to_values($form_id, $values); |
|
155 | + $values = array(); |
|
156 | + $form = self::fields_to_values($form_id, $values); |
|
157 | 157 | |
158 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
159 | - wp_die(); |
|
160 | - } |
|
158 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
159 | + wp_die(); |
|
160 | + } |
|
161 | 161 | |
162 | - public static function fill_action() { |
|
162 | + public static function fill_action() { |
|
163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
165 | 165 | |
166 | - $action_key = absint( $_POST['action_id'] ); |
|
167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
166 | + $action_key = absint( $_POST['action_id'] ); |
|
167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
168 | 168 | |
169 | - $action_control = self::get_form_actions( $action_type ); |
|
170 | - if ( empty($action_control) ) { |
|
171 | - wp_die(); |
|
172 | - } |
|
169 | + $action_control = self::get_form_actions( $action_type ); |
|
170 | + if ( empty($action_control) ) { |
|
171 | + wp_die(); |
|
172 | + } |
|
173 | 173 | |
174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
175 | 175 | |
176 | - $values = array(); |
|
177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
176 | + $values = array(); |
|
177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
178 | 178 | |
179 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
180 | - wp_die(); |
|
181 | - } |
|
179 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
180 | + wp_die(); |
|
181 | + } |
|
182 | 182 | |
183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
184 | - $form = FrmForm::getOne($form_id); |
|
184 | + $form = FrmForm::getOne($form_id); |
|
185 | 185 | |
186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
187 | 187 | |
188 | - $fields = FrmField::get_all_for_form($form->id); |
|
189 | - foreach ( $fields as $k => $f ) { |
|
190 | - $f = (array) $f; |
|
191 | - $opts = (array) $f['field_options']; |
|
192 | - $f = array_merge($opts, $f); |
|
193 | - if ( ! isset( $f['post_field'] ) ) { |
|
194 | - $f['post_field'] = ''; |
|
195 | - } |
|
196 | - $values['fields'][] = $f; |
|
197 | - unset($k, $f); |
|
198 | - } |
|
199 | - |
|
200 | - return $form; |
|
201 | - } |
|
188 | + $fields = FrmField::get_all_for_form($form->id); |
|
189 | + foreach ( $fields as $k => $f ) { |
|
190 | + $f = (array) $f; |
|
191 | + $opts = (array) $f['field_options']; |
|
192 | + $f = array_merge($opts, $f); |
|
193 | + if ( ! isset( $f['post_field'] ) ) { |
|
194 | + $f['post_field'] = ''; |
|
195 | + } |
|
196 | + $values['fields'][] = $f; |
|
197 | + unset($k, $f); |
|
198 | + } |
|
199 | + |
|
200 | + return $form; |
|
201 | + } |
|
202 | 202 | |
203 | 203 | public static function update_settings( $form_id ) { |
204 | - global $wpdb; |
|
204 | + global $wpdb; |
|
205 | 205 | |
206 | - $registered_actions = self::$registered_actions->actions; |
|
206 | + $registered_actions = self::$registered_actions->actions; |
|
207 | 207 | |
208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
209 | - $new_actions = array(); |
|
209 | + $new_actions = array(); |
|
210 | 210 | |
211 | - foreach ( $registered_actions as $registered_action ) { |
|
212 | - $action_ids = $registered_action->update_callback($form_id); |
|
213 | - if ( ! empty( $action_ids ) ) { |
|
214 | - $new_actions[] = $action_ids; |
|
215 | - } |
|
216 | - } |
|
211 | + foreach ( $registered_actions as $registered_action ) { |
|
212 | + $action_ids = $registered_action->update_callback($form_id); |
|
213 | + if ( ! empty( $action_ids ) ) { |
|
214 | + $new_actions[] = $action_ids; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - //Only use array_merge if there are new actions |
|
219 | - if ( ! empty( $new_actions ) ) { |
|
220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
221 | - } |
|
222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
218 | + //Only use array_merge if there are new actions |
|
219 | + if ( ! empty( $new_actions ) ) { |
|
220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
221 | + } |
|
222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
223 | 223 | |
224 | 224 | self::delete_missing_actions( $old_actions ); |
225 | - } |
|
225 | + } |
|
226 | 226 | |
227 | 227 | public static function delete_missing_actions( $old_actions ) { |
228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -237,36 +237,36 @@ discard block |
||
237 | 237 | self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args ); |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * @param string $event |
|
242 | - */ |
|
240 | + /** |
|
241 | + * @param string $event |
|
242 | + */ |
|
243 | 243 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
244 | 244 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
245 | 245 | |
246 | 246 | if ( empty( $form_actions ) ) { |
247 | - return; |
|
248 | - } |
|
247 | + return; |
|
248 | + } |
|
249 | 249 | |
250 | 250 | FrmForm::maybe_get_form( $form ); |
251 | 251 | |
252 | - $link_settings = self::get_form_actions( $type ); |
|
253 | - if ( 'all' != $type ) { |
|
254 | - $link_settings = array( $type => $link_settings ); |
|
255 | - } |
|
252 | + $link_settings = self::get_form_actions( $type ); |
|
253 | + if ( 'all' != $type ) { |
|
254 | + $link_settings = array( $type => $link_settings ); |
|
255 | + } |
|
256 | 256 | |
257 | - $stored_actions = $action_priority = array(); |
|
257 | + $stored_actions = $action_priority = array(); |
|
258 | 258 | |
259 | 259 | $importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING; |
260 | 260 | |
261 | - foreach ( $form_actions as $action ) { |
|
261 | + foreach ( $form_actions as $action ) { |
|
262 | 262 | $trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] ); |
263 | 263 | if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) { |
264 | - continue; |
|
265 | - } |
|
264 | + continue; |
|
265 | + } |
|
266 | 266 | |
267 | - if ( ! is_object( $entry ) ) { |
|
268 | - $entry = FrmEntry::getOne( $entry, true ); |
|
269 | - } |
|
267 | + if ( ! is_object( $entry ) ) { |
|
268 | + $entry = FrmEntry::getOne( $entry, true ); |
|
269 | + } |
|
270 | 270 | |
271 | 271 | if ( empty( $entry ) || $entry->is_draft ) { |
272 | 272 | continue; |
@@ -275,66 +275,66 @@ discard block |
||
275 | 275 | $child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) ); |
276 | 276 | |
277 | 277 | if ( $child_entry ) { |
278 | - //don't trigger actions for sub forms |
|
279 | - continue; |
|
280 | - } |
|
278 | + //don't trigger actions for sub forms |
|
279 | + continue; |
|
280 | + } |
|
281 | 281 | |
282 | - // check conditional logic |
|
282 | + // check conditional logic |
|
283 | 283 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
284 | - if ( $stop ) { |
|
285 | - continue; |
|
286 | - } |
|
284 | + if ( $stop ) { |
|
285 | + continue; |
|
286 | + } |
|
287 | 287 | |
288 | - // store actions so they can be triggered with the correct priority |
|
289 | - $stored_actions[ $action->ID ] = $action; |
|
290 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
288 | + // store actions so they can be triggered with the correct priority |
|
289 | + $stored_actions[ $action->ID ] = $action; |
|
290 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
291 | 291 | |
292 | - unset($action); |
|
293 | - } |
|
292 | + unset($action); |
|
293 | + } |
|
294 | 294 | |
295 | - if ( ! empty( $stored_actions ) ) { |
|
296 | - asort($action_priority); |
|
295 | + if ( ! empty( $stored_actions ) ) { |
|
296 | + asort($action_priority); |
|
297 | 297 | |
298 | - // make sure hooks are loaded |
|
299 | - new FrmNotification(); |
|
298 | + // make sure hooks are loaded |
|
299 | + new FrmNotification(); |
|
300 | 300 | |
301 | - foreach ( $action_priority as $action_id => $priority ) { |
|
302 | - $action = $stored_actions[ $action_id ]; |
|
303 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
304 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
301 | + foreach ( $action_priority as $action_id => $priority ) { |
|
302 | + $action = $stored_actions[ $action_id ]; |
|
303 | + do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
304 | + do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
305 | 305 | |
306 | - // If post is created, get updated $entry object |
|
307 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
308 | - $entry = FrmEntry::getOne($entry->id, true); |
|
309 | - } |
|
310 | - } |
|
311 | - } |
|
312 | - } |
|
306 | + // If post is created, get updated $entry object |
|
307 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
308 | + $entry = FrmEntry::getOne($entry->id, true); |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | 314 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
315 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
316 | - // continue if we know which actions to copy |
|
317 | - return; |
|
318 | - } |
|
315 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
316 | + // continue if we know which actions to copy |
|
317 | + return; |
|
318 | + } |
|
319 | 319 | |
320 | - $action_controls = self::get_form_actions( ); |
|
320 | + $action_controls = self::get_form_actions( ); |
|
321 | 321 | |
322 | - foreach ( $action_controls as $action_control ) { |
|
323 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
324 | - unset( $action_control ); |
|
325 | - } |
|
326 | - } |
|
322 | + foreach ( $action_controls as $action_control ) { |
|
323 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
324 | + unset( $action_control ); |
|
325 | + } |
|
326 | + } |
|
327 | 327 | |
328 | - public static function limit_by_type( $where ) { |
|
329 | - global $frm_vars, $wpdb; |
|
328 | + public static function limit_by_type( $where ) { |
|
329 | + global $frm_vars, $wpdb; |
|
330 | 330 | |
331 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
332 | - return $where; |
|
333 | - } |
|
331 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
332 | + return $where; |
|
333 | + } |
|
334 | 334 | |
335 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
336 | - return $where; |
|
337 | - } |
|
335 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
336 | + return $where; |
|
337 | + } |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | foreach ( $keys as $key ) { |
362 | 362 | // don't register new action if old action with the same id is already registered |
363 | 363 | if ( ! isset( $this->actions[ $key ] ) ) { |
364 | - $this->actions[ $key ]->_register(); |
|
364 | + $this->actions[ $key ]->_register(); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | } |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | 'highrise' => 'FrmDefHrsAction', |
49 | 49 | ) ); |
50 | 50 | |
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
53 | 53 | |
54 | 54 | foreach ( $action_classes as $action_class ) { |
55 | - self::$registered_actions->register($action_class); |
|
55 | + self::$registered_actions->register( $action_class ); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | 60 | $temp_actions = self::$registered_actions; |
61 | - if ( empty($temp_actions) ) { |
|
61 | + if ( empty( $temp_actions ) ) { |
|
62 | 62 | self::actions_init(); |
63 | 63 | $temp_actions = self::$registered_actions->actions; |
64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $a; |
73 | 73 | } |
74 | 74 | |
75 | - $actions[ $a->id_base ] = $a; |
|
75 | + $actions[$a->id_base] = $a; |
|
76 | 76 | } |
77 | 77 | unset( $temp_actions, $a ); |
78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | arsort( $temp_actions ); |
87 | 87 | foreach ( $temp_actions as $type => $a ) { |
88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
89 | - unset( $actions[ $type ] ); |
|
89 | + unset( $actions[$type] ); |
|
90 | 90 | if ( count( $actions ) <= $action_limit ) { |
91 | 91 | break; |
92 | 92 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | $action_map = array(); |
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
121 | + $action_map[$control->id_base] = $key; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | foreach ( $form_actions as $action ) { |
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
126 | 126 | // don't try and show settings if action no longer exists |
127 | 127 | continue; |
128 | 128 | } |
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
135 | + $action_control->_set( $action_key ); |
|
136 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public static function add_form_action() { |
140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
140 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
141 | 141 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
142 | 142 | |
143 | 143 | global $frm_vars; |
@@ -146,55 +146,55 @@ discard block |
||
146 | 146 | $action_type = sanitize_text_field( $_POST['type'] ); |
147 | 147 | |
148 | 148 | $action_control = self::get_form_actions( $action_type ); |
149 | - $action_control->_set($action_key); |
|
149 | + $action_control->_set( $action_key ); |
|
150 | 150 | |
151 | 151 | $form_id = absint( $_POST['form_id'] ); |
152 | 152 | |
153 | - $form_action = $action_control->prepare_new($form_id); |
|
153 | + $form_action = $action_control->prepare_new( $form_id ); |
|
154 | 154 | |
155 | 155 | $values = array(); |
156 | - $form = self::fields_to_values($form_id, $values); |
|
156 | + $form = self::fields_to_values( $form_id, $values ); |
|
157 | 157 | |
158 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
158 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
159 | 159 | wp_die(); |
160 | 160 | } |
161 | 161 | |
162 | 162 | public static function fill_action() { |
163 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
163 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
164 | 164 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
165 | 165 | |
166 | 166 | $action_key = absint( $_POST['action_id'] ); |
167 | 167 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
168 | 168 | |
169 | 169 | $action_control = self::get_form_actions( $action_type ); |
170 | - if ( empty($action_control) ) { |
|
170 | + if ( empty( $action_control ) ) { |
|
171 | 171 | wp_die(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | $form_action = $action_control->get_single_action( $action_key ); |
175 | 175 | |
176 | 176 | $values = array(); |
177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
177 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
178 | 178 | |
179 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
179 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
|
180 | 180 | wp_die(); |
181 | 181 | } |
182 | 182 | |
183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
184 | - $form = FrmForm::getOne($form_id); |
|
184 | + $form = FrmForm::getOne( $form_id ); |
|
185 | 185 | |
186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
187 | 187 | |
188 | - $fields = FrmField::get_all_for_form($form->id); |
|
188 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
189 | 189 | foreach ( $fields as $k => $f ) { |
190 | 190 | $f = (array) $f; |
191 | 191 | $opts = (array) $f['field_options']; |
192 | - $f = array_merge($opts, $f); |
|
192 | + $f = array_merge( $opts, $f ); |
|
193 | 193 | if ( ! isset( $f['post_field'] ) ) { |
194 | 194 | $f['post_field'] = ''; |
195 | 195 | } |
196 | 196 | $values['fields'][] = $f; |
197 | - unset($k, $f); |
|
197 | + unset( $k, $f ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $form; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $new_actions = array(); |
210 | 210 | |
211 | 211 | foreach ( $registered_actions as $registered_action ) { |
212 | - $action_ids = $registered_action->update_callback($form_id); |
|
212 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
213 | 213 | if ( ! empty( $action_ids ) ) { |
214 | 214 | $new_actions[] = $action_ids; |
215 | 215 | } |
@@ -286,33 +286,33 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | // store actions so they can be triggered with the correct priority |
289 | - $stored_actions[ $action->ID ] = $action; |
|
290 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
289 | + $stored_actions[$action->ID] = $action; |
|
290 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
291 | 291 | |
292 | - unset($action); |
|
292 | + unset( $action ); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | if ( ! empty( $stored_actions ) ) { |
296 | - asort($action_priority); |
|
296 | + asort( $action_priority ); |
|
297 | 297 | |
298 | 298 | // make sure hooks are loaded |
299 | 299 | new FrmNotification(); |
300 | 300 | |
301 | 301 | foreach ( $action_priority as $action_id => $priority ) { |
302 | - $action = $stored_actions[ $action_id ]; |
|
303 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
304 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
302 | + $action = $stored_actions[$action_id]; |
|
303 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
|
304 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
|
305 | 305 | |
306 | 306 | // If post is created, get updated $entry object |
307 | 307 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
308 | - $entry = FrmEntry::getOne($entry->id, true); |
|
308 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
309 | 309 | } |
310 | 310 | } |
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | 314 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
315 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
315 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
316 | 316 | // continue if we know which actions to copy |
317 | 317 | return; |
318 | 318 | } |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | public function register( $action_class ) { |
349 | - $this->actions[ $action_class ] = new $action_class(); |
|
349 | + $this->actions[$action_class] = new $action_class(); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | public function unregister( $action_class ) { |
353 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
354 | - unset($this->actions[ $action_class ]); |
|
353 | + if ( isset( $this->actions[$action_class] ) ) { |
|
354 | + unset( $this->actions[$action_class] ); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | 358 | public function _register_actions() { |
359 | - $keys = array_keys($this->actions); |
|
359 | + $keys = array_keys( $this->actions ); |
|
360 | 360 | |
361 | 361 | foreach ( $keys as $key ) { |
362 | 362 | // don't register new action if old action with the same id is already registered |
363 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
364 | - $this->actions[ $key ]->_register(); |
|
363 | + if ( ! isset( $this->actions[$key] ) ) { |
|
364 | + $this->actions[$key]->_register(); |
|
365 | 365 | } |
366 | 366 | } |
367 | 367 | } |
@@ -181,13 +181,13 @@ |
||
181 | 181 | ), |
182 | 182 | ); |
183 | 183 | $random = rand( 0, count( $tips ) - 1 ); |
184 | - $tip = $tips[ $random ]; |
|
184 | + $tip = $tips[$random]; |
|
185 | 185 | $tip['num'] = $random; |
186 | 186 | return $tip; |
187 | 187 | } |
188 | 188 | |
189 | 189 | public static function get_random_tip( $tips ) { |
190 | 190 | $random = rand( 0, count( $tips ) - 1 ); |
191 | - return $tips[ $random ]; |
|
191 | + return $tips[$random]; |
|
192 | 192 | } |
193 | 193 | } |