@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @return string The version of PHP. |
203 | 203 | */ |
204 | 204 | private function get_php_version() { |
205 | - return ! empty( $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] ) ? |
|
206 | - $GLOBALS['GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE'] : phpversion(); |
|
205 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] ) ? |
|
206 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_PHP_VERSION_OVERRIDE' ] : phpversion(); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @return string The version of WordPress. |
215 | 215 | */ |
216 | 216 | private function get_wordpress_version() { |
217 | - return ! empty( $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] ) ? |
|
218 | - $GLOBALS['GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE'] : $GLOBALS['wp_version']; |
|
217 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] ) ? |
|
218 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_WP_VERSION_OVERRIDE' ] : $GLOBALS[ 'wp_version' ]; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | * @return string|null The version of Gravity Forms or null if inactive. |
227 | 227 | */ |
228 | 228 | private function get_gravityforms_version() { |
229 | - if ( ! class_exists( '\GFCommon' ) || ! empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE'] ) ) { |
|
229 | + if ( ! class_exists( '\GFCommon' ) || ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_INACTIVE_OVERRIDE' ] ) ) { |
|
230 | 230 | gravityview()->log->error( 'Gravity Forms is inactive or not installed.' ); |
231 | 231 | return null; |
232 | 232 | } |
233 | 233 | |
234 | - return ! empty( $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] ) ? |
|
235 | - $GLOBALS['GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE'] : \GFCommon::$version; |
|
234 | + return ! empty( $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] ) ? |
|
235 | + $GLOBALS[ 'GRAVITYVIEW_TESTS_GF_VERSION_OVERRIDE' ] : \GFCommon::$version; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | private function __clone() { } |
@@ -5,251 +5,251 @@ |
||
5 | 5 | */ |
6 | 6 | class GravityView_Change_Entry_Creator { |
7 | 7 | |
8 | - function __construct() { |
|
9 | - |
|
10 | - /** |
|
11 | - * @since 1.5.1 |
|
12 | - */ |
|
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | - |
|
15 | - // ONLY ADMIN FROM HERE ON. |
|
16 | - if( !is_admin() ) { return; } |
|
17 | - |
|
18 | - /** |
|
19 | - * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | - * @since 1.7.4 |
|
21 | - * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | - */ |
|
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | - return; |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Use `init` to fix bbPress warning |
|
29 | - * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | - */ |
|
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
32 | - |
|
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | - |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | - * |
|
40 | - * @since 1.5.1 |
|
41 | - * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | - * @param int $user_id WordPress User ID |
|
43 | - * @param array $config User registration feed configuration |
|
44 | - * @param array $entry GF Entry array |
|
45 | - * @param string $password User password |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | - |
|
50 | - /** |
|
51 | - * Disable assigning the new user to the entry by returning false. |
|
52 | - * @param int $user_id WordPress User ID |
|
53 | - * @param array $config User registration feed configuration |
|
54 | - * @param array $entry GF Entry array |
|
55 | - */ |
|
56 | - $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | - |
|
58 | - // If filter returns false, do not process |
|
59 | - if( empty( $assign_to_lead ) ) { |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
65 | - |
|
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
68 | - } else { |
|
69 | - $status = __('Success', 'gravityview'); |
|
70 | - } |
|
71 | - |
|
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
73 | - |
|
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
75 | - |
|
76 | - /** |
|
77 | - * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
78 | - * @since 1.21.5 |
|
79 | - * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
80 | - */ |
|
81 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
82 | - return; |
|
83 | - } |
|
84 | - |
|
85 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
8 | + function __construct() { |
|
9 | + |
|
10 | + /** |
|
11 | + * @since 1.5.1 |
|
12 | + */ |
|
13 | + add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
14 | + |
|
15 | + // ONLY ADMIN FROM HERE ON. |
|
16 | + if( !is_admin() ) { return; } |
|
17 | + |
|
18 | + /** |
|
19 | + * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
|
20 | + * @since 1.7.4 |
|
21 | + * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
|
22 | + */ |
|
23 | + if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
24 | + return; |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Use `init` to fix bbPress warning |
|
29 | + * @see https://bbpress.trac.wordpress.org/ticket/2309 |
|
30 | + */ |
|
31 | + add_action('init', array( $this, 'load'), 100 ); |
|
32 | + |
|
33 | + add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
34 | + |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * When an user is created using the User Registration add-on, assign the entry to them |
|
39 | + * |
|
40 | + * @since 1.5.1 |
|
41 | + * @uses RGFormsModel::update_lead_property() Modify the entry `created_by` field |
|
42 | + * @param int $user_id WordPress User ID |
|
43 | + * @param array $config User registration feed configuration |
|
44 | + * @param array $entry GF Entry array |
|
45 | + * @param string $password User password |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) { |
|
49 | + |
|
50 | + /** |
|
51 | + * Disable assigning the new user to the entry by returning false. |
|
52 | + * @param int $user_id WordPress User ID |
|
53 | + * @param array $config User registration feed configuration |
|
54 | + * @param array $entry GF Entry array |
|
55 | + */ |
|
56 | + $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
|
57 | + |
|
58 | + // If filter returns false, do not process |
|
59 | + if( empty( $assign_to_lead ) ) { |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
|
64 | + $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
65 | + |
|
66 | + if( empty( $result ) ) { |
|
67 | + $status = __('Error', 'gravityview'); |
|
68 | + } else { |
|
69 | + $status = __('Success', 'gravityview'); |
|
70 | + } |
|
71 | + |
|
72 | + $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
73 | + |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
75 | + |
|
76 | + /** |
|
77 | + * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
|
78 | + * @since 1.21.5 |
|
79 | + * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
|
80 | + */ |
|
81 | + if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
82 | + return; |
|
83 | + } |
|
84 | + |
|
85 | + GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
86 | 86 | |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Disable previous functionality; use this one as the canonical. |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - function prevent_conflicts() { |
|
89 | + /** |
|
90 | + * Disable previous functionality; use this one as the canonical. |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + function prevent_conflicts() { |
|
94 | 94 | |
95 | - // Plugin that was provided here: |
|
96 | - // @link https://gravityview.co/support/documentation/201991205/ |
|
97 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
98 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
99 | - |
|
100 | - // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
101 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
95 | + // Plugin that was provided here: |
|
96 | + // @link https://gravityview.co/support/documentation/201991205/ |
|
97 | + remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
98 | + remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
99 | + |
|
100 | + // Disable for Gravity Forms Add-ons 3.6.2 and lower |
|
101 | + if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
102 | 102 | |
103 | - $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
103 | + $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
|
104 | 104 | |
105 | - // Now, no validation is required in the methods; let's hook in. |
|
106 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
107 | - |
|
108 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
109 | - |
|
110 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
111 | - } |
|
112 | - |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @since 3.6.3 |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - function load() { |
|
105 | + // Now, no validation is required in the methods; let's hook in. |
|
106 | + remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
107 | + |
|
108 | + remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
109 | + |
|
110 | + remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
111 | + } |
|
112 | + |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @since 3.6.3 |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + function load() { |
|
120 | 120 | |
121 | - // Does GF exist? |
|
122 | - if( !class_exists('GFCommon') ) { |
|
123 | - return; |
|
124 | - } |
|
121 | + // Does GF exist? |
|
122 | + if( !class_exists('GFCommon') ) { |
|
123 | + return; |
|
124 | + } |
|
125 | 125 | |
126 | - // Can the user edit entries? |
|
127 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
128 | - return; |
|
129 | - } |
|
126 | + // Can the user edit entries? |
|
127 | + if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
128 | + return; |
|
129 | + } |
|
130 | 130 | |
131 | - // If screen mode isn't set, then we're in the wrong place. |
|
132 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
133 | - return; |
|
134 | - } |
|
131 | + // If screen mode isn't set, then we're in the wrong place. |
|
132 | + if( empty( $_REQUEST['screen_mode'] ) ) { |
|
133 | + return; |
|
134 | + } |
|
135 | 135 | |
136 | - // Now, no validation is required in the methods; let's hook in. |
|
137 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
136 | + // Now, no validation is required in the methods; let's hook in. |
|
137 | + add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
138 | 138 | |
139 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
139 | + add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
140 | 140 | |
141 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
141 | + add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
142 | 142 | |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
147 | - * @return void |
|
148 | - */ |
|
149 | - function set_screen_mode() { |
|
145 | + /** |
|
146 | + * Allows for edit links to work with a link instead of a form (GET instead of POST) |
|
147 | + * @return void |
|
148 | + */ |
|
149 | + function set_screen_mode() { |
|
150 | 150 | |
151 | - // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
152 | - if( rgget('screen_mode') === 'edit' ) { |
|
153 | - $_POST["screen_mode"] = 'edit'; |
|
154 | - } |
|
151 | + // If $_GET['screen_mode'] is set to edit, set $_POST value |
|
152 | + if( rgget('screen_mode') === 'edit' ) { |
|
153 | + $_POST["screen_mode"] = 'edit'; |
|
154 | + } |
|
155 | 155 | |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * When the entry creator is changed, add a note to the entry |
|
160 | - * @param array $form GF entry array |
|
161 | - * @param int $entry_id Entry ID |
|
162 | - * @return void |
|
163 | - */ |
|
164 | - function update_entry_creator($form, $entry_id) { |
|
165 | - global $current_user; |
|
158 | + /** |
|
159 | + * When the entry creator is changed, add a note to the entry |
|
160 | + * @param array $form GF entry array |
|
161 | + * @param int $entry_id Entry ID |
|
162 | + * @return void |
|
163 | + */ |
|
164 | + function update_entry_creator($form, $entry_id) { |
|
165 | + global $current_user; |
|
166 | 166 | |
167 | - // Update the entry |
|
168 | - $created_by = absint( rgpost('created_by') ); |
|
167 | + // Update the entry |
|
168 | + $created_by = absint( rgpost('created_by') ); |
|
169 | 169 | |
170 | - RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
170 | + RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
|
171 | 171 | |
172 | - // If the creator has changed, let's add a note about who it used to be. |
|
173 | - $originally_created_by = rgpost('originally_created_by'); |
|
172 | + // If the creator has changed, let's add a note about who it used to be. |
|
173 | + $originally_created_by = rgpost('originally_created_by'); |
|
174 | 174 | |
175 | - // If there's no owner and there didn't used to be, keep going |
|
176 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
177 | - return; |
|
178 | - } |
|
175 | + // If there's no owner and there didn't used to be, keep going |
|
176 | + if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
177 | + return; |
|
178 | + } |
|
179 | 179 | |
180 | - // If the values have changed |
|
181 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
180 | + // If the values have changed |
|
181 | + if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
182 | 182 | |
183 | - $user_data = get_userdata($current_user->ID); |
|
183 | + $user_data = get_userdata($current_user->ID); |
|
184 | 184 | |
185 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
185 | + $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
186 | 186 | |
187 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
187 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
188 | 188 | |
189 | - if( !empty( $originally_created_by ) ) { |
|
190 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
191 | - $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
192 | - } |
|
189 | + if( !empty( $originally_created_by ) ) { |
|
190 | + $originally_created_by_user_data = get_userdata($originally_created_by); |
|
191 | + $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
|
192 | + } |
|
193 | 193 | |
194 | - if( !empty( $created_by ) ) { |
|
195 | - $created_by_user_data = get_userdata($created_by); |
|
196 | - $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
197 | - } |
|
194 | + if( !empty( $created_by ) ) { |
|
195 | + $created_by_user_data = get_userdata($created_by); |
|
196 | + $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
|
197 | + } |
|
198 | 198 | |
199 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
200 | - } |
|
199 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
200 | + } |
|
201 | 201 | |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Output the select to change the entry creator |
|
206 | - * @param int $form_id GF Form ID |
|
207 | - * @param array $entry GF entry array |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - function add_select($form_id, $entry ) { |
|
204 | + /** |
|
205 | + * Output the select to change the entry creator |
|
206 | + * @param int $form_id GF Form ID |
|
207 | + * @param array $entry GF entry array |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + function add_select($form_id, $entry ) { |
|
211 | 211 | |
212 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
213 | - return; |
|
214 | - } |
|
212 | + if( rgpost('screen_mode') !== 'edit' ) { |
|
213 | + return; |
|
214 | + } |
|
215 | 215 | |
216 | - $created_by_id = rgar( $entry, 'created_by' ); |
|
216 | + $created_by_id = rgar( $entry, 'created_by' ); |
|
217 | 217 | |
218 | - $users = GVCommon::get_users( 'change_entry_creator' ); |
|
218 | + $users = GVCommon::get_users( 'change_entry_creator' ); |
|
219 | 219 | |
220 | - $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
220 | + $is_created_by_in_users = wp_list_filter( $users, array( 'ID' => $created_by_id ) ); |
|
221 | 221 | |
222 | - // Make sure that the entry creator is included in the users list. If not, add them. |
|
223 | - if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
222 | + // Make sure that the entry creator is included in the users list. If not, add them. |
|
223 | + if ( ! empty( $created_by_id ) && empty( $is_created_by_in_users ) ) { |
|
224 | 224 | |
225 | - if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
226 | - $users = array_merge( $users, $created_by_user ); |
|
227 | - } |
|
228 | - } |
|
225 | + if ( $created_by_user = GVCommon::get_users( 'change_entry_creator', array( 'include' => $created_by_id ) ) ) { |
|
226 | + $users = array_merge( $users, $created_by_user ); |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - $output = '<label for="change_created_by">'; |
|
231 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
232 | - $output .= '</label>'; |
|
230 | + $output = '<label for="change_created_by">'; |
|
231 | + $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
232 | + $output .= '</label>'; |
|
233 | 233 | |
234 | - // If there are users who are not being shown, show a warning. |
|
235 | - // TODO: Use AJAX instead of <select> |
|
236 | - $count_users = count_users(); |
|
237 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
238 | - $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
239 | - } |
|
234 | + // If there are users who are not being shown, show a warning. |
|
235 | + // TODO: Use AJAX instead of <select> |
|
236 | + $count_users = count_users(); |
|
237 | + if( sizeof( $users ) < $count_users['total_users'] ) { |
|
238 | + $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
|
239 | + } |
|
240 | 240 | |
241 | - $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
242 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
243 | - foreach($users as $user) { |
|
244 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
245 | - } |
|
246 | - $output .= '</select>'; |
|
247 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
241 | + $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
|
242 | + $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
243 | + foreach($users as $user) { |
|
244 | + $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
245 | + } |
|
246 | + $output .= '</select>'; |
|
247 | + $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
248 | 248 | |
249 | - unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
249 | + unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
|
250 | 250 | |
251 | - echo $output; |
|
252 | - } |
|
251 | + echo $output; |
|
252 | + } |
|
253 | 253 | |
254 | 254 | } |
255 | 255 |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -56,33 +56,33 @@ discard block |
||
56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if ( empty( $assign_to_lead ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_lead_property( $entry[ 'id' ], 'created_by', $user_id, false, true ); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
66 | + if ( empty( $result ) ) { |
|
67 | + $status = __( 'Error', 'gravityview' ); |
|
68 | 68 | } else { |
69 | - $status = __('Success', 'gravityview'); |
|
69 | + $status = __( 'Success', 'gravityview' ); |
|
70 | 70 | } |
71 | 71 | |
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - ' . $note ); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @filter `gravityview_disable_change_entry_creator_note` Disable adding a note when changing the entry creator |
78 | 78 | * @since 1.21.5 |
79 | 79 | * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
80 | 80 | */ |
81 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
81 | + if ( apply_filters( 'gravityview_disable_change_entry_creator_note', false ) ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
85 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -94,20 +94,20 @@ discard block |
||
94 | 94 | |
95 | 95 | // Plugin that was provided here: |
96 | 96 | // @link https://gravityview.co/support/documentation/201991205/ |
97 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
98 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
97 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
98 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
99 | 99 | |
100 | 100 | // Disable for Gravity Forms Add-ons 3.6.2 and lower |
101 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
101 | + if ( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
102 | 102 | |
103 | 103 | $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
104 | 104 | |
105 | 105 | // Now, no validation is required in the methods; let's hook in. |
106 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
106 | + remove_action( 'admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
107 | 107 | |
108 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
108 | + remove_action( "gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
109 | 109 | |
110 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
110 | + remove_action( "gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -119,26 +119,26 @@ discard block |
||
119 | 119 | function load() { |
120 | 120 | |
121 | 121 | // Does GF exist? |
122 | - if( !class_exists('GFCommon') ) { |
|
122 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | // Can the user edit entries? |
127 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
127 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // If screen mode isn't set, then we're in the wrong place. |
132 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
132 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Now, no validation is required in the methods; let's hook in. |
137 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
137 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
138 | 138 | |
139 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
139 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
140 | 140 | |
141 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
141 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | function set_screen_mode() { |
150 | 150 | |
151 | 151 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
152 | - if( rgget('screen_mode') === 'edit' ) { |
|
153 | - $_POST["screen_mode"] = 'edit'; |
|
152 | + if ( rgget( 'screen_mode' ) === 'edit' ) { |
|
153 | + $_POST[ "screen_mode" ] = 'edit'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
@@ -161,42 +161,42 @@ discard block |
||
161 | 161 | * @param int $entry_id Entry ID |
162 | 162 | * @return void |
163 | 163 | */ |
164 | - function update_entry_creator($form, $entry_id) { |
|
164 | + function update_entry_creator( $form, $entry_id ) { |
|
165 | 165 | global $current_user; |
166 | 166 | |
167 | 167 | // Update the entry |
168 | - $created_by = absint( rgpost('created_by') ); |
|
168 | + $created_by = absint( rgpost( 'created_by' ) ); |
|
169 | 169 | |
170 | 170 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
171 | 171 | |
172 | 172 | // If the creator has changed, let's add a note about who it used to be. |
173 | - $originally_created_by = rgpost('originally_created_by'); |
|
173 | + $originally_created_by = rgpost( 'originally_created_by' ); |
|
174 | 174 | |
175 | 175 | // If there's no owner and there didn't used to be, keep going |
176 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
176 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // If the values have changed |
181 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
181 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
182 | 182 | |
183 | - $user_data = get_userdata($current_user->ID); |
|
183 | + $user_data = get_userdata( $current_user->ID ); |
|
184 | 184 | |
185 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
185 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
186 | 186 | |
187 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
187 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
188 | 188 | |
189 | - if( !empty( $originally_created_by ) ) { |
|
190 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
189 | + if ( ! empty( $originally_created_by ) ) { |
|
190 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
191 | 191 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
192 | 192 | } |
193 | 193 | |
194 | - if( !empty( $created_by ) ) { |
|
195 | - $created_by_user_data = get_userdata($created_by); |
|
194 | + if ( ! empty( $created_by ) ) { |
|
195 | + $created_by_user_data = get_userdata( $created_by ); |
|
196 | 196 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
197 | 197 | } |
198 | 198 | |
199 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
199 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param array $entry GF entry array |
208 | 208 | * @return void |
209 | 209 | */ |
210 | - function add_select($form_id, $entry ) { |
|
210 | + function add_select( $form_id, $entry ) { |
|
211 | 211 | |
212 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
212 | + if ( rgpost( 'screen_mode' ) !== 'edit' ) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
@@ -228,23 +228,23 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | $output = '<label for="change_created_by">'; |
231 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
231 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
232 | 232 | $output .= '</label>'; |
233 | 233 | |
234 | 234 | // If there are users who are not being shown, show a warning. |
235 | 235 | // TODO: Use AJAX instead of <select> |
236 | 236 | $count_users = count_users(); |
237 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
237 | + if ( sizeof( $users ) < $count_users[ 'total_users' ] ) { |
|
238 | 238 | $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
239 | 239 | } |
240 | 240 | |
241 | 241 | $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
242 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
243 | - foreach($users as $user) { |
|
244 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
242 | + $output .= '<option value="' . selected( $entry[ 'created_by' ], '0', false ) . '"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
243 | + foreach ( $users as $user ) { |
|
244 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
245 | 245 | } |
246 | 246 | $output .= '</select>'; |
247 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
247 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
248 | 248 | |
249 | 249 | unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
250 | 250 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | protected $script_handles = array( |
25 | 25 | 'rcp-admin-scripts', |
26 | - 'bbq', |
|
26 | + 'bbq', |
|
27 | 27 | ); |
28 | 28 | |
29 | 29 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | $default_settings = apply_filters( 'gravityview_default_args', array( |
41 | 41 | 'id' => array( |
42 | - 'label' => __('View ID', 'gravityview'), |
|
42 | + 'label' => __( 'View ID', 'gravityview' ), |
|
43 | 43 | 'type' => 'number', |
44 | 44 | 'group' => 'default', |
45 | 45 | 'value' => NULL, |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'show_in_shortcode' => false, |
48 | 48 | ), |
49 | 49 | 'page_size' => array( |
50 | - 'label' => __('Number of entries per page', 'gravityview'), |
|
50 | + 'label' => __( 'Number of entries per page', 'gravityview' ), |
|
51 | 51 | 'type' => 'number', |
52 | 52 | 'class' => 'small-text', |
53 | 53 | 'group' => 'default', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'show_in_shortcode' => true, |
56 | 56 | ), |
57 | 57 | 'offset' => array( |
58 | - 'label' => __('Offset entries starting from', 'gravityview'), |
|
58 | + 'label' => __( 'Offset entries starting from', 'gravityview' ), |
|
59 | 59 | 'type' => 'number', |
60 | 60 | 'class' => 'small-text', |
61 | 61 | 'group' => 'default', |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | ), |
80 | 80 | 'admin_show_all_statuses' => array( |
81 | 81 | 'label' => __( 'Show all entries to administrators', 'gravityview' ), |
82 | - 'desc' => __('Administrators will be able to see entries with any approval status.', 'gravityview'), |
|
83 | - 'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), |
|
82 | + 'desc' => __( 'Administrators will be able to see entries with any approval status.', 'gravityview' ), |
|
83 | + 'tooltip' => __( 'Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview' ), |
|
84 | 84 | 'requires' => 'show_only_approved', |
85 | 85 | 'type' => 'checkbox', |
86 | 86 | 'group' => 'default', |
@@ -105,40 +105,40 @@ discard block |
||
105 | 105 | 'user_edit' => array( |
106 | 106 | 'label' => __( 'Allow User Edit', 'gravityview' ), |
107 | 107 | 'group' => 'default', |
108 | - 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
|
108 | + 'desc' => __( 'Allow logged-in users to edit entries they created.', 'gravityview' ), |
|
109 | 109 | 'value' => 0, |
110 | - 'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
110 | + 'tooltip' => __( 'Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
111 | 111 | 'type' => 'checkbox', |
112 | 112 | 'show_in_shortcode' => true, |
113 | 113 | ), |
114 | 114 | 'user_delete' => array( |
115 | 115 | 'label' => __( 'Allow User Delete', 'gravityview' ), |
116 | 116 | 'group' => 'default', |
117 | - 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
|
117 | + 'desc' => __( 'Allow logged-in users to delete entries they created.', 'gravityview' ), |
|
118 | 118 | 'value' => 0, |
119 | - 'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), |
|
119 | + 'tooltip' => __( 'Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview' ), |
|
120 | 120 | 'type' => 'checkbox', |
121 | 121 | 'show_in_shortcode' => true, |
122 | 122 | ), |
123 | 123 | 'sort_field' => array( |
124 | - 'label' => __('Sort by field', 'gravityview'), |
|
124 | + 'label' => __( 'Sort by field', 'gravityview' ), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'value' => '', |
127 | 127 | 'group' => 'sort', |
128 | 128 | 'options' => array( |
129 | - '' => __( 'Default', 'gravityview'), |
|
130 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
129 | + '' => __( 'Default', 'gravityview' ), |
|
130 | + 'date_created' => __( 'Date Created', 'gravityview' ), |
|
131 | 131 | ), |
132 | 132 | 'show_in_shortcode' => true, |
133 | 133 | ), |
134 | 134 | 'sort_direction' => array( |
135 | - 'label' => __('Sort direction', 'gravityview'), |
|
135 | + 'label' => __( 'Sort direction', 'gravityview' ), |
|
136 | 136 | 'type' => 'select', |
137 | 137 | 'value' => 'ASC', |
138 | 138 | 'group' => 'sort', |
139 | 139 | 'options' => array( |
140 | - 'ASC' => __('ASC', 'gravityview'), |
|
141 | - 'DESC' => __('DESC', 'gravityview'), |
|
140 | + 'ASC' => __( 'ASC', 'gravityview' ), |
|
141 | + 'DESC' => __( 'DESC', 'gravityview' ), |
|
142 | 142 | //'RAND' => __('Random', 'gravityview'), |
143 | 143 | ), |
144 | 144 | 'show_in_shortcode' => true, |
@@ -154,69 +154,69 @@ discard block |
||
154 | 154 | 'show_in_template' => array( 'default_table', 'preset_business_data', 'preset_issue_tracker', 'preset_resume_board', 'preset_job_board' ), |
155 | 155 | ), |
156 | 156 | 'start_date' => array( |
157 | - 'label' => __('Filter by Start Date', 'gravityview'), |
|
157 | + 'label' => __( 'Filter by Start Date', 'gravityview' ), |
|
158 | 158 | 'class' => 'gv-datepicker', |
159 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
159 | + 'desc' => __( 'Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
160 | 160 | 'type' => 'text', |
161 | 161 | 'value' => '', |
162 | 162 | 'group' => 'filter', |
163 | 163 | 'show_in_shortcode' => true, |
164 | 164 | ), |
165 | 165 | 'end_date' => array( |
166 | - 'label' => __('Filter by End Date', 'gravityview'), |
|
166 | + 'label' => __( 'Filter by End Date', 'gravityview' ), |
|
167 | 167 | 'class' => 'gv-datepicker', |
168 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
168 | + 'desc' => __( 'Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
169 | 169 | 'type' => 'text', |
170 | 170 | 'value' => '', |
171 | 171 | 'group' => 'filter', |
172 | 172 | 'show_in_shortcode' => true, |
173 | 173 | ), |
174 | 174 | 'class' => array( |
175 | - 'label' => __('CSS Class', 'gravityview'), |
|
176 | - 'desc' => __('CSS class to add to the wrapping HTML container.', 'gravityview'), |
|
175 | + 'label' => __( 'CSS Class', 'gravityview' ), |
|
176 | + 'desc' => __( 'CSS class to add to the wrapping HTML container.', 'gravityview' ), |
|
177 | 177 | 'group' => 'default', |
178 | 178 | 'type' => 'text', |
179 | 179 | 'value' => '', |
180 | 180 | 'show_in_shortcode' => false, |
181 | 181 | ), |
182 | 182 | 'search_value' => array( |
183 | - 'label' => __('Search Value', 'gravityview'), |
|
184 | - 'desc' => __('Define a default search value for the View', 'gravityview'), |
|
183 | + 'label' => __( 'Search Value', 'gravityview' ), |
|
184 | + 'desc' => __( 'Define a default search value for the View', 'gravityview' ), |
|
185 | 185 | 'type' => 'text', |
186 | 186 | 'value' => '', |
187 | 187 | 'group' => 'filter', |
188 | 188 | 'show_in_shortcode' => false, |
189 | 189 | ), |
190 | 190 | 'search_field' => array( |
191 | - 'label' => __('Search Field', 'gravityview'), |
|
192 | - 'desc' => __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), |
|
191 | + 'label' => __( 'Search Field', 'gravityview' ), |
|
192 | + 'desc' => __( 'If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview' ), |
|
193 | 193 | 'type' => 'number', |
194 | 194 | 'value' => '', |
195 | 195 | 'group' => 'filter', |
196 | 196 | 'show_in_shortcode' => false, |
197 | 197 | ), |
198 | 198 | 'single_title' => array( |
199 | - 'label' => __('Single Entry Title', 'gravityview'), |
|
199 | + 'label' => __( 'Single Entry Title', 'gravityview' ), |
|
200 | 200 | 'type' => 'text', |
201 | - 'desc' => __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), |
|
201 | + 'desc' => __( 'When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview' ), |
|
202 | 202 | 'group' => 'default', |
203 | 203 | 'value' => '', |
204 | 204 | 'show_in_shortcode' => false, |
205 | 205 | 'full_width' => true, |
206 | 206 | ), |
207 | 207 | 'back_link_label' => array( |
208 | - 'label' => __('Back Link Label', 'gravityview'), |
|
208 | + 'label' => __( 'Back Link Label', 'gravityview' ), |
|
209 | 209 | 'group' => 'default', |
210 | - 'desc' => __('The text of the link that returns to the multiple entries view.', 'gravityview'), |
|
210 | + 'desc' => __( 'The text of the link that returns to the multiple entries view.', 'gravityview' ), |
|
211 | 211 | 'type' => 'text', |
212 | 212 | 'value' => '', |
213 | 213 | 'show_in_shortcode' => false, |
214 | 214 | 'full_width' => true, |
215 | 215 | ), |
216 | 216 | 'embed_only' => array( |
217 | - 'label' => __('Prevent Direct Access', 'gravityview'), |
|
217 | + 'label' => __( 'Prevent Direct Access', 'gravityview' ), |
|
218 | 218 | 'group' => 'default', |
219 | - 'desc' => __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), |
|
219 | + 'desc' => __( 'Only allow access to this View when embedded using the shortcode.', 'gravityview' ), |
|
220 | 220 | 'type' => 'checkbox', |
221 | 221 | 'value' => '', |
222 | 222 | 'tooltip' => false, |
@@ -239,19 +239,19 @@ discard block |
||
239 | 239 | // By default, we only want the key => value pairing, not the whole array. |
240 | 240 | if ( ! $detailed ) { |
241 | 241 | $defaults = array(); |
242 | - foreach( $default_settings as $key => $value ) { |
|
243 | - $defaults[ $key ] = $value['value']; |
|
242 | + foreach ( $default_settings as $key => $value ) { |
|
243 | + $defaults[ $key ] = $value[ 'value' ]; |
|
244 | 244 | } |
245 | 245 | return $defaults; |
246 | 246 | |
247 | 247 | // But sometimes, we want all the details. |
248 | 248 | } else { |
249 | - foreach ($default_settings as $key => $value) { |
|
249 | + foreach ( $default_settings as $key => $value ) { |
|
250 | 250 | |
251 | 251 | // If the $group argument is set for the method, |
252 | 252 | // ignore any settings that aren't in that group. |
253 | 253 | if ( ! empty( $group ) && is_string( $group ) ) { |
254 | - if ( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
254 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
255 | 255 | unset( $default_settings[ $key ] ); |
256 | 256 | } |
257 | 257 | } |
@@ -26,24 +26,24 @@ |
||
26 | 26 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
27 | 27 | |
28 | 28 | // Don't link to entry; doesn't make sense. |
29 | - unset( $field_options['show_as_link'] ); |
|
29 | + unset( $field_options[ 'show_as_link' ] ); |
|
30 | 30 | |
31 | - if( 'edit' === $context ) { |
|
31 | + if ( 'edit' === $context ) { |
|
32 | 32 | return $field_options; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $add_options = array(); |
36 | - $add_options['link_to_source'] = array( |
|
36 | + $add_options[ 'link_to_source' ] = array( |
|
37 | 37 | 'type' => 'checkbox', |
38 | 38 | 'label' => __( 'Link to URL:', 'gravityview' ), |
39 | - 'desc' => __('Display as a link to the Source URL', 'gravityview'), |
|
39 | + 'desc' => __( 'Display as a link to the Source URL', 'gravityview' ), |
|
40 | 40 | 'value' => false, |
41 | 41 | 'merge_tags' => false, |
42 | 42 | ); |
43 | - $add_options['source_link_text'] = array( |
|
43 | + $add_options[ 'source_link_text' ] = array( |
|
44 | 44 | 'type' => 'text', |
45 | 45 | 'label' => __( 'Link Text:', 'gravityview' ), |
46 | - 'desc' => __('Customize the link text. If empty, the link text will be the URL.', 'gravityview'), |
|
46 | + 'desc' => __( 'Customize the link text. If empty, the link text will be the URL.', 'gravityview' ), |
|
47 | 47 | 'value' => NULL, |
48 | 48 | 'merge_tags' => true, |
49 | 49 | ); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @api |
38 | 38 | * @since future |
39 | - * @return \GV\Entry|null An instance of this entry or null if not found. |
|
39 | + * @return null|GF_Entry An instance of this entry or null if not found. |
|
40 | 40 | */ |
41 | 41 | public static function by_id( $entry_id ) { |
42 | 42 | $entry = \GFAPI::get_entry( $entry_id ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param array $entry The array ID. |
54 | 54 | * |
55 | - * @return \GV\Entry|null An instance of this entry or null if not found. |
|
55 | + * @return null|GF_Entry An instance of this entry or null if not found. |
|
56 | 56 | */ |
57 | 57 | public static function from_entry( $entry ) { |
58 | 58 | if ( empty( $entry['id'] ) ) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function by_id( $entry_id ) { |
42 | 42 | $entry = \GFAPI::get_entry( $entry_id ); |
43 | - if ( !$entry ) { |
|
43 | + if ( ! $entry ) { |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | * @return \GV\Entry|null An instance of this entry or null if not found. |
56 | 56 | */ |
57 | 57 | public static function from_entry( $entry ) { |
58 | - if ( empty( $entry['id'] ) ) { |
|
58 | + if ( empty( $entry[ 'id' ] ) ) { |
|
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $self = new self(); |
63 | 63 | $self->entry = $entry; |
64 | 64 | |
65 | - $self->ID = $self->entry['id']; |
|
65 | + $self->ID = $self->entry[ 'id' ]; |
|
66 | 66 | |
67 | 67 | return $self; |
68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return bool Whether the offset exists or not. |
77 | 77 | */ |
78 | 78 | public function offsetExists( $offset ) { |
79 | - return isset( $this->entry[$offset] ); |
|
79 | + return isset( $this->entry[ $offset ] ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return mixed The value of the requested entry data. |
92 | 92 | */ |
93 | 93 | public function offsetGet( $offset ) { |
94 | - return $this->entry[$offset]; |
|
94 | + return $this->entry[ $offset ]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function by_id( $form_id ) { |
42 | 42 | $form = \GFAPI::get_form( $form_id ); |
43 | - if ( !$form ) { |
|
43 | + if ( ! $form ) { |
|
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $self = new self(); |
48 | 48 | $self->form = $form; |
49 | 49 | |
50 | - $self->ID = $self->form['id']; |
|
50 | + $self->ID = $self->form[ 'id' ]; |
|
51 | 51 | |
52 | 52 | return $self; |
53 | 53 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | /** The offset and limit */ |
92 | 92 | if ( ! empty( $offset->limit ) ) { |
93 | - $paging['page_size'] = $offset->limit; |
|
93 | + $paging[ 'page_size' ] = $offset->limit; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ( ! empty( $offset->offset ) ) { |
97 | - $paging['offset'] = $offset->offset; |
|
97 | + $paging[ 'offset' ] = $offset->offset; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return bool Whether the offset exists or not. |
131 | 131 | */ |
132 | 132 | public function offsetExists( $offset ) { |
133 | - return isset( $this->form[$offset] ); |
|
133 | + return isset( $this->form[ $offset ] ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return mixed The value of the requested form data. |
146 | 146 | */ |
147 | 147 | public function offsetGet( $offset ) { |
148 | - return $this->form[$offset]; |
|
148 | + return $this->form[ $offset ]; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | add_action( 'gravityview_log_debug', array( $this, 'log_debug'), 10, 2 ); |
13 | 13 | |
14 | 14 | // Enable debug with Gravity Forms Logging Add-on |
15 | - add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
|
15 | + add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
|
16 | 16 | |
17 | - // Load Debug Bar integration |
|
18 | - add_filter( 'debug_bar_panels', array( $this, 'add_debug_bar' ) ); |
|
17 | + // Load Debug Bar integration |
|
18 | + add_filter( 'debug_bar_panels', array( $this, 'add_debug_bar' ) ); |
|
19 | 19 | |
20 | 20 | } |
21 | 21 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param array $supported_plugins List of plugins |
45 | 45 | */ |
46 | 46 | public function enable_gform_logging( $supported_plugins ) { |
47 | - $supported_plugins['gravityview'] = 'GravityView'; |
|
48 | - return $supported_plugins; |
|
47 | + $supported_plugins['gravityview'] = 'GravityView'; |
|
48 | + return $supported_plugins; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | |
97 | 97 | if ( class_exists("GFLogging") ) { |
98 | 98 | GFLogging::include_logger(); |
99 | - GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
100 | - } |
|
99 | + GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | static function log_error( $message = '', $data = null ) { |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | if ( class_exists("GFLogging") ) { |
118 | - GFLogging::include_logger(); |
|
119 | - GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ( $error, true), KLogger::ERROR ); |
|
118 | + GFLogging::include_logger(); |
|
119 | + GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ( $error, true), KLogger::ERROR ); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | |
8 | 8 | function __construct() { |
9 | 9 | |
10 | - add_action( 'gravityview_log_error', array( $this, 'log_error'), 10, 2 ); |
|
10 | + add_action( 'gravityview_log_error', array( $this, 'log_error' ), 10, 2 ); |
|
11 | 11 | |
12 | - add_action( 'gravityview_log_debug', array( $this, 'log_debug'), 10, 2 ); |
|
12 | + add_action( 'gravityview_log_debug', array( $this, 'log_debug' ), 10, 2 ); |
|
13 | 13 | |
14 | 14 | // Enable debug with Gravity Forms Logging Add-on |
15 | 15 | add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | include_once( GRAVITYVIEW_DIR . 'includes/class-debug-bar.php' ); |
35 | 35 | } |
36 | 36 | |
37 | - $panels[] = new GravityView_Debug_Bar; |
|
37 | + $panels[ ] = new GravityView_Debug_Bar; |
|
38 | 38 | |
39 | 39 | return $panels; |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $supported_plugins List of plugins |
45 | 45 | */ |
46 | 46 | public function enable_gform_logging( $supported_plugins ) { |
47 | - $supported_plugins['gravityview'] = 'GravityView'; |
|
47 | + $supported_plugins[ 'gravityview' ] = 'GravityView'; |
|
48 | 48 | return $supported_plugins; |
49 | 49 | } |
50 | 50 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return string "print_r" or "var_export" |
73 | 73 | */ |
74 | 74 | static function get_print_function() { |
75 | - if( ob_get_level() > 0 ) { |
|
75 | + if ( ob_get_level() > 0 ) { |
|
76 | 76 | $function = 'var_export'; |
77 | 77 | } else { |
78 | 78 | $function = 'print_r'; |
@@ -90,17 +90,17 @@ discard block |
||
90 | 90 | 'data' => $data, |
91 | 91 | ); |
92 | 92 | |
93 | - if( !in_array( $notice, self::$notices ) ) { |
|
94 | - self::$notices[] = $notice; |
|
93 | + if ( ! in_array( $notice, self::$notices ) ) { |
|
94 | + self::$notices[ ] = $notice; |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( class_exists("GFLogging") ) { |
|
97 | + if ( class_exists( "GFLogging" ) ) { |
|
98 | 98 | GFLogging::include_logger(); |
99 | - GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
99 | + GFLogging::log_message( 'gravityview', $function( $message, true ) . $function( $data, true ), KLogger::DEBUG ); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - static function log_error( $message = '', $data = null ) { |
|
103 | + static function log_error( $message = '', $data = null ) { |
|
104 | 104 | |
105 | 105 | $function = self::get_print_function(); |
106 | 106 | |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | 'backtrace' => function_exists( 'wp_debug_backtrace_summary' ) ? wp_debug_backtrace_summary( null, 3 ) : '', |
111 | 111 | ); |
112 | 112 | |
113 | - if( !in_array( $error, self::$errors ) ) { |
|
114 | - self::$errors[] = $error; |
|
113 | + if ( ! in_array( $error, self::$errors ) ) { |
|
114 | + self::$errors[ ] = $error; |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( class_exists("GFLogging") ) { |
|
117 | + if ( class_exists( "GFLogging" ) ) { |
|
118 | 118 | GFLogging::include_logger(); |
119 | - GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ( $error, true), KLogger::ERROR ); |
|
119 | + GFLogging::log_message( 'gravityview', $function( $message, true ) . $function( $error, true ), KLogger::ERROR ); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | add_action( 'init', array( $this, 'register_handler' ) ); |
36 | 36 | add_action( 'init', array( $this, 'add_provider' ) ); |
37 | 37 | |
38 | - if ( ! empty( $_GET['gv_oembed_provider'] ) && ! empty( $_GET['url'] ) ) { |
|
38 | + if ( ! empty( $_GET[ 'gv_oembed_provider' ] ) && ! empty( $_GET[ 'url' ] ) ) { |
|
39 | 39 | add_action( 'template_redirect', array( $this, 'render_provider_request' ) ); |
40 | 40 | } |
41 | 41 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | static function getInstance() { |
48 | 48 | |
49 | - if( empty( self::$instance ) ) { |
|
49 | + if ( empty( self::$instance ) ) { |
|
50 | 50 | self::$instance = new self; |
51 | 51 | |
52 | 52 | self::$instance->initialize(); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @return void |
87 | 87 | */ |
88 | 88 | function render_provider_request() { |
89 | - if ( ! empty( $_GET['url'] ) ) { |
|
90 | - $url = $_GET['url']; |
|
89 | + if ( ! empty( $_GET[ 'url' ] ) ) { |
|
90 | + $url = $_GET[ 'url' ]; |
|
91 | 91 | } else { |
92 | 92 | header( 'HTTP/1.0 404 Not Found' ); |
93 | 93 | exit; |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | preg_match( $this->get_handler_regex(), $url, $matches ); |
97 | 97 | |
98 | 98 | // If not using permalinks, re-assign values for matching groups |
99 | - if ( ! empty( $matches['entry_slug2'] ) ) { |
|
100 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
101 | - $matches['slug'] = $matches['slug2']; |
|
102 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
103 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
99 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
100 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
101 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
102 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
103 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // No Entry was found |
107 | - if ( empty( $matches['entry_slug'] ) ) { |
|
108 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
107 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
108 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
109 | 109 | header( 'HTTP/1.0 404 Not Found' ); |
110 | 110 | exit; |
111 | 111 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // Catch either |
159 | 159 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
160 | 160 | |
161 | - return '#'.$match_regex.'#i'; |
|
161 | + return '#' . $match_regex . '#i'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | |
178 | 178 | $post_id = url_to_postid( $url ); |
179 | 179 | |
180 | - if( empty( $post_id ) ) { |
|
180 | + if ( empty( $post_id ) ) { |
|
181 | 181 | |
182 | 182 | $args = array( |
183 | 183 | 'post_status' => 'publish', |
184 | 184 | 'name' => $slug, |
185 | - 'post_type' => array('any', 'gravityview'), |
|
185 | + 'post_type' => array( 'any', 'gravityview' ), |
|
186 | 186 | ); |
187 | 187 | |
188 | 188 | $posts = get_posts( $args ); |
189 | 189 | |
190 | - if( !empty( $posts ) ) { |
|
191 | - $post_id = $posts[0]->ID; |
|
190 | + if ( ! empty( $posts ) ) { |
|
191 | + $post_id = $posts[ 0 ]->ID; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -221,17 +221,17 @@ discard block |
||
221 | 221 | public function render_handler( $matches, $attr, $url, $rawattr ) { |
222 | 222 | |
223 | 223 | // If not using permalinks, re-assign values for matching groups |
224 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
225 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
226 | - $matches['slug'] = $matches['slug2']; |
|
227 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
228 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
224 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
225 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
226 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
227 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
228 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // No Entry was found |
232 | - if( empty( $matches['entry_slug'] ) ) { |
|
232 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
233 | 233 | |
234 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
234 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
235 | 235 | |
236 | 236 | return ''; |
237 | 237 | } |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | // Setup the data used |
242 | 242 | $this->set_vars( $matches, $attr, $url, $rawattr ); |
243 | 243 | |
244 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
244 | + if ( is_admin() && ! $this->is_full_oembed_preview ) { |
|
245 | 245 | $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
246 | 246 | } else { |
247 | 247 | |
248 | - if( $this->is_full_oembed_preview ) { |
|
248 | + if ( $this->is_full_oembed_preview ) { |
|
249 | 249 | $return .= $this->generate_preview_notice(); |
250 | 250 | } |
251 | 251 | |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | private function generate_preview_notice() { |
265 | 265 | $floaty = GravityView_Admin::get_floaty(); |
266 | 266 | $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
267 | - $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
268 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
267 | + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
268 | + return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | */ |
279 | 279 | private function set_vars( $matches, $attr, $url, $rawattr ) { |
280 | 280 | |
281 | - $this->entry_id = $matches['entry_slug']; |
|
281 | + $this->entry_id = $matches[ 'entry_slug' ]; |
|
282 | 282 | |
283 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
283 | + $post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] ); |
|
284 | 284 | |
285 | 285 | // The URL didn't have the View Custom Post Type structure. |
286 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
286 | + if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) { |
|
287 | 287 | |
288 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
288 | + do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
289 | 289 | |
290 | 290 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
291 | 291 | $views = \GV\View_Collection::from_post( $post ); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - $this->view_id = $views[0]->ID; |
|
301 | + $this->view_id = $views[ 0 ]->ID; |
|
302 | 302 | } |
303 | 303 | } else { |
304 | 304 | /** Deprecated. */ |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
315 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
315 | + $this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | // Floaty the astronaut |
331 | 331 | $image = GravityView_Admin::get_floaty(); |
332 | 332 | |
333 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
333 | + $embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id ); |
|
334 | 334 | |
335 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
335 | + $embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id ); |
|
336 | 336 | |
337 | 337 | return ' |
338 | 338 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
339 | - <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3> |
|
339 | + <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3> |
|
340 | 340 | <p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
341 | - '.$embed_text.' |
|
341 | + '.$embed_text . ' |
|
342 | 342 | </p> |
343 | 343 | <br style="clear: both;"> |
344 | 344 | </div>'; |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | private function render_frontend( $matches, $attr, $url, $rawattr ) { |
394 | 394 | |
395 | 395 | // If it's already been parsed, don't re-output it. |
396 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
396 | + if ( ! empty( $this->output[ $this->entry_id ] ) ) { |
|
397 | 397 | return $this->output[ $this->entry_id ]; |
398 | 398 | } |
399 | 399 | |
400 | 400 | $entry_output = $this->generate_entry_output(); |
401 | 401 | |
402 | 402 | // Wrap a container div around the output to allow for custom styling |
403 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
403 | + $output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output ); |
|
404 | 404 | |
405 | 405 | /** |
406 | 406 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @var string $url The original URL that was matched by the regex. \n |
414 | 414 | * @var array $rawattr The original unmodified attributes. |
415 | 415 | */ |
416 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
416 | + $output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
417 | 417 | |
418 | 418 | unset( $entry_output ); |
419 | 419 |