@@ -65,6 +65,9 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | + /** |
|
69 | + * @param string $component |
|
70 | + */ |
|
68 | 71 | private function load_components( $component ) { |
69 | 72 | |
70 | 73 | $dir = trailingslashit( self::$file ); |
@@ -141,7 +144,7 @@ discard block |
||
141 | 144 | * "You can edit this post from the post page" fields, for example. |
142 | 145 | * |
143 | 146 | * @param $entry array Gravity Forms entry object |
144 | - * @param $view_id int GravityView view id |
|
147 | + * @param integer $view_id int GravityView view id |
|
145 | 148 | * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
146 | 149 | * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
147 | 150 | * @return string |
@@ -18,82 +18,82 @@ discard block |
||
18 | 18 | |
19 | 19 | class GravityView_Edit_Entry { |
20 | 20 | |
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | 24 | static $file; |
25 | 25 | |
26 | 26 | static $instance; |
27 | 27 | |
28 | - /** |
|
29 | - * Component instances. |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - public $instances = array(); |
|
28 | + /** |
|
29 | + * Component instances. |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + public $instances = array(); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path( __FILE__ ); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
41 | - } |
|
39 | + if( is_admin() ) { |
|
40 | + $this->load_components( 'admin' ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components( 'render' ); |
|
45 | 45 | |
46 | - // If GF User Registration Add-on exists |
|
47 | - if( class_exists( 'GFUser' ) ) { |
|
48 | - $this->load_components( 'user-registration' ); |
|
49 | - } |
|
46 | + // If GF User Registration Add-on exists |
|
47 | + if( class_exists( 'GFUser' ) ) { |
|
48 | + $this->load_components( 'user-registration' ); |
|
49 | + } |
|
50 | 50 | |
51 | - $this->add_hooks(); |
|
51 | + $this->add_hooks(); |
|
52 | 52 | |
53 | 53 | // Process hooks for addons that may or may not be present |
54 | 54 | $this->addon_specific_hooks(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | - static function getInstance() { |
|
58 | + static function getInstance() { |
|
59 | 59 | |
60 | - if( empty( self::$instance ) ) { |
|
61 | - self::$instance = new GravityView_Edit_Entry; |
|
62 | - } |
|
60 | + if( empty( self::$instance ) ) { |
|
61 | + self::$instance = new GravityView_Edit_Entry; |
|
62 | + } |
|
63 | 63 | |
64 | - return self::$instance; |
|
65 | - } |
|
64 | + return self::$instance; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - private function load_components( $component ) { |
|
68 | + private function load_components( $component ) { |
|
69 | 69 | |
70 | - $dir = trailingslashit( self::$file ); |
|
70 | + $dir = trailingslashit( self::$file ); |
|
71 | 71 | |
72 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
73 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | + $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
73 | + $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
74 | 74 | |
75 | - // Loads component and pass extension's instance so that component can |
|
76 | - // talk each other. |
|
77 | - require_once $filename; |
|
78 | - $this->instances[ $component ] = new $classname( $this ); |
|
79 | - $this->instances[ $component ]->load(); |
|
75 | + // Loads component and pass extension's instance so that component can |
|
76 | + // talk each other. |
|
77 | + require_once $filename; |
|
78 | + $this->instances[ $component ] = new $classname( $this ); |
|
79 | + $this->instances[ $component ]->load(); |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - private function add_hooks() { |
|
83 | + private function add_hooks() { |
|
84 | 84 | |
85 | - // Add front-end access to Gravity Forms delete file action |
|
86 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
85 | + // Add front-end access to Gravity Forms delete file action |
|
86 | + add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
87 | 87 | |
88 | - // Make sure this hook is run for non-admins |
|
89 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
88 | + // Make sure this hook is run for non-admins |
|
89 | + add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
90 | 90 | |
91 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
91 | + add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
92 | 92 | |
93 | - // add template path to check for field |
|
94 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
93 | + // add template path to check for field |
|
94 | + add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin |
@@ -107,75 +107,75 @@ discard block |
||
107 | 107 | |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Include this extension templates path |
|
112 | - * @param array $file_paths List of template paths ordered |
|
113 | - */ |
|
114 | - public function add_template_path( $file_paths ) { |
|
115 | - |
|
116 | - // Index 100 is the default GravityView template path. |
|
117 | - $file_paths[ 110 ] = self::$file; |
|
118 | - |
|
119 | - return $file_paths; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * |
|
124 | - * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
125 | - * |
|
126 | - * @param $view_id int GravityView view id |
|
127 | - * @param $form_id int Gravity Forms form id |
|
128 | - * @param $entry_id int Gravity Forms entry id |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
132 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * The edit entry link creates a secure link with a nonce |
|
138 | - * |
|
139 | - * It also mimics the URL structure Gravity Forms expects to have so that |
|
140 | - * it formats the display of the edit form like it does in the backend, like |
|
141 | - * "You can edit this post from the post page" fields, for example. |
|
142 | - * |
|
143 | - * @param $entry array Gravity Forms entry object |
|
144 | - * @param $view_id int GravityView view id |
|
145 | - * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
146 | - * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
150 | - |
|
151 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
152 | - |
|
153 | - $base = gv_entry_link( $entry, $post_id ); |
|
154 | - |
|
155 | - $url = add_query_arg( array( |
|
156 | - 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
157 | - 'view' => 'entry', // Needed for GFForms::get_page() |
|
158 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
159 | - ), $base ); |
|
160 | - |
|
161 | - /** |
|
162 | - * Allow passing params to dynamically populate entry with values |
|
163 | - * @since 1.9.2 |
|
164 | - */ |
|
165 | - if( !empty( $field_values ) ) { |
|
166 | - |
|
167 | - if( is_array( $field_values ) ) { |
|
168 | - // If already an array, no parse_str() needed |
|
169 | - $params = $field_values; |
|
170 | - } else { |
|
171 | - parse_str( $field_values, $params ); |
|
172 | - } |
|
173 | - |
|
174 | - $url = add_query_arg( $params, $url ); |
|
175 | - } |
|
176 | - |
|
177 | - return $url; |
|
178 | - } |
|
110 | + /** |
|
111 | + * Include this extension templates path |
|
112 | + * @param array $file_paths List of template paths ordered |
|
113 | + */ |
|
114 | + public function add_template_path( $file_paths ) { |
|
115 | + |
|
116 | + // Index 100 is the default GravityView template path. |
|
117 | + $file_paths[ 110 ] = self::$file; |
|
118 | + |
|
119 | + return $file_paths; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * |
|
124 | + * Return a well formatted nonce key according to GravityView Edit Entry protocol |
|
125 | + * |
|
126 | + * @param $view_id int GravityView view id |
|
127 | + * @param $form_id int Gravity Forms form id |
|
128 | + * @param $entry_id int Gravity Forms entry id |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
132 | + return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * The edit entry link creates a secure link with a nonce |
|
138 | + * |
|
139 | + * It also mimics the URL structure Gravity Forms expects to have so that |
|
140 | + * it formats the display of the edit form like it does in the backend, like |
|
141 | + * "You can edit this post from the post page" fields, for example. |
|
142 | + * |
|
143 | + * @param $entry array Gravity Forms entry object |
|
144 | + * @param $view_id int GravityView view id |
|
145 | + * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2} |
|
146 | + * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
150 | + |
|
151 | + $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
152 | + |
|
153 | + $base = gv_entry_link( $entry, $post_id ); |
|
154 | + |
|
155 | + $url = add_query_arg( array( |
|
156 | + 'page' => 'gf_entries', // Needed for GFForms::get_page() |
|
157 | + 'view' => 'entry', // Needed for GFForms::get_page() |
|
158 | + 'edit' => wp_create_nonce( $nonce_key ) |
|
159 | + ), $base ); |
|
160 | + |
|
161 | + /** |
|
162 | + * Allow passing params to dynamically populate entry with values |
|
163 | + * @since 1.9.2 |
|
164 | + */ |
|
165 | + if( !empty( $field_values ) ) { |
|
166 | + |
|
167 | + if( is_array( $field_values ) ) { |
|
168 | + // If already an array, no parse_str() needed |
|
169 | + $params = $field_values; |
|
170 | + } else { |
|
171 | + parse_str( $field_values, $params ); |
|
172 | + } |
|
173 | + |
|
174 | + $url = add_query_arg( $params, $url ); |
|
175 | + } |
|
176 | + |
|
177 | + return $url; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | |
181 | 181 | /** |
@@ -211,81 +211,81 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * checks if user has permissions to edit a specific entry |
|
216 | - * |
|
217 | - * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
218 | - * |
|
219 | - * @param array $entry Gravity Forms entry array |
|
220 | - * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
221 | - * @return bool |
|
222 | - */ |
|
223 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
214 | + /** |
|
215 | + * checks if user has permissions to edit a specific entry |
|
216 | + * |
|
217 | + * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!! |
|
218 | + * |
|
219 | + * @param array $entry Gravity Forms entry array |
|
220 | + * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
|
221 | + * @return bool |
|
222 | + */ |
|
223 | + public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
224 | 224 | |
225 | - // No permission by default |
|
226 | - $user_can_edit = false; |
|
225 | + // No permission by default |
|
226 | + $user_can_edit = false; |
|
227 | 227 | |
228 | - // If they can edit any entries (as defined in Gravity Forms) |
|
229 | - // Or if they can edit other people's entries |
|
230 | - // Then we're good. |
|
231 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
228 | + // If they can edit any entries (as defined in Gravity Forms) |
|
229 | + // Or if they can edit other people's entries |
|
230 | + // Then we're good. |
|
231 | + if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
232 | 232 | |
233 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
233 | + do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
234 | 234 | |
235 | - $user_can_edit = true; |
|
235 | + $user_can_edit = true; |
|
236 | 236 | |
237 | - } else if( !isset( $entry['created_by'] ) ) { |
|
237 | + } else if( !isset( $entry['created_by'] ) ) { |
|
238 | 238 | |
239 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
239 | + do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
|
240 | 240 | |
241 | - $user_can_edit = false; |
|
241 | + $user_can_edit = false; |
|
242 | 242 | |
243 | - } else { |
|
243 | + } else { |
|
244 | 244 | |
245 | - // get user_edit setting |
|
246 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
247 | - // if View ID not specified or is the current view |
|
248 | - $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
249 | - } else { |
|
250 | - // in case is specified and not the current view |
|
251 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
252 | - } |
|
245 | + // get user_edit setting |
|
246 | + if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
247 | + // if View ID not specified or is the current view |
|
248 | + $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
|
249 | + } else { |
|
250 | + // in case is specified and not the current view |
|
251 | + $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
252 | + } |
|
253 | 253 | |
254 | - $current_user = wp_get_current_user(); |
|
254 | + $current_user = wp_get_current_user(); |
|
255 | 255 | |
256 | - // User edit is disabled |
|
257 | - if( empty( $user_edit ) ) { |
|
256 | + // User edit is disabled |
|
257 | + if( empty( $user_edit ) ) { |
|
258 | 258 | |
259 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
259 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
260 | 260 | |
261 | - $user_can_edit = false; |
|
262 | - } |
|
261 | + $user_can_edit = false; |
|
262 | + } |
|
263 | 263 | |
264 | - // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
265 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
264 | + // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
|
265 | + else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
266 | 266 | |
267 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
267 | + do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
268 | 268 | |
269 | - $user_can_edit = true; |
|
269 | + $user_can_edit = true; |
|
270 | 270 | |
271 | - } else if( ! is_user_logged_in() ) { |
|
271 | + } else if( ! is_user_logged_in() ) { |
|
272 | 272 | |
273 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
274 | - } |
|
273 | + do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
274 | + } |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
280 | - * @since 1.15 Added `$entry` and `$view_id` parameters |
|
281 | - * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
282 | - * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
283 | - * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
284 | - */ |
|
285 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
278 | + /** |
|
279 | + * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry. |
|
280 | + * @since 1.15 Added `$entry` and `$view_id` parameters |
|
281 | + * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false) |
|
282 | + * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
|
283 | + * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
|
284 | + */ |
|
285 | + $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
286 | 286 | |
287 | - return (bool)$user_can_edit; |
|
288 | - } |
|
287 | + return (bool)$user_can_edit; |
|
288 | + } |
|
289 | 289 | |
290 | 290 | |
291 | 291 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @copyright Copyright 2014, Katz Web Services, Inc. |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'WPINC' ) ) { |
|
14 | +if (!defined('WPINC')) { |
|
15 | 15 | die; |
16 | 16 | } |
17 | 17 | |
@@ -34,18 +34,18 @@ discard block |
||
34 | 34 | |
35 | 35 | function __construct() { |
36 | 36 | |
37 | - self::$file = plugin_dir_path( __FILE__ ); |
|
37 | + self::$file = plugin_dir_path(__FILE__); |
|
38 | 38 | |
39 | - if( is_admin() ) { |
|
40 | - $this->load_components( 'admin' ); |
|
39 | + if (is_admin()) { |
|
40 | + $this->load_components('admin'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | - $this->load_components( 'render' ); |
|
44 | + $this->load_components('render'); |
|
45 | 45 | |
46 | 46 | // If GF User Registration Add-on exists |
47 | - if( class_exists( 'GFUser' ) ) { |
|
48 | - $this->load_components( 'user-registration' ); |
|
47 | + if (class_exists('GFUser')) { |
|
48 | + $this->load_components('user-registration'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $this->add_hooks(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | static function getInstance() { |
59 | 59 | |
60 | - if( empty( self::$instance ) ) { |
|
60 | + if (empty(self::$instance)) { |
|
61 | 61 | self::$instance = new GravityView_Edit_Entry; |
62 | 62 | } |
63 | 63 | |
@@ -65,33 +65,33 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | - private function load_components( $component ) { |
|
68 | + private function load_components($component) { |
|
69 | 69 | |
70 | - $dir = trailingslashit( self::$file ); |
|
70 | + $dir = trailingslashit(self::$file); |
|
71 | 71 | |
72 | - $filename = $dir . 'class-edit-entry-' . $component . '.php'; |
|
73 | - $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) ); |
|
72 | + $filename = $dir.'class-edit-entry-'.$component.'.php'; |
|
73 | + $classname = 'GravityView_Edit_Entry_'.str_replace(' ', '_', ucwords(str_replace('-', ' ', $component))); |
|
74 | 74 | |
75 | 75 | // Loads component and pass extension's instance so that component can |
76 | 76 | // talk each other. |
77 | 77 | require_once $filename; |
78 | - $this->instances[ $component ] = new $classname( $this ); |
|
79 | - $this->instances[ $component ]->load(); |
|
78 | + $this->instances[$component] = new $classname($this); |
|
79 | + $this->instances[$component]->load(); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | 83 | private function add_hooks() { |
84 | 84 | |
85 | 85 | // Add front-end access to Gravity Forms delete file action |
86 | - add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
86 | + add_action('wp_ajax_nopriv_rg_delete_file', array('RGForms', 'delete_file')); |
|
87 | 87 | |
88 | 88 | // Make sure this hook is run for non-admins |
89 | - add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') ); |
|
89 | + add_action('wp_ajax_rg_delete_file', array('RGForms', 'delete_file')); |
|
90 | 90 | |
91 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 ); |
|
91 | + add_filter('gravityview_blacklist_field_types', array($this, 'modify_field_blacklist'), 10, 2); |
|
92 | 92 | |
93 | 93 | // add template path to check for field |
94 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
94 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | private function addon_specific_hooks() { |
103 | 103 | |
104 | - if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) { |
|
105 | - add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script')); |
|
104 | + if (class_exists('GFSignature') && is_callable(array('GFSignature', 'get_instance'))) { |
|
105 | + add_filter('gform_admin_pre_render', array(GFSignature::get_instance(), 'edit_lead_script')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | } |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * Include this extension templates path |
112 | 112 | * @param array $file_paths List of template paths ordered |
113 | 113 | */ |
114 | - public function add_template_path( $file_paths ) { |
|
114 | + public function add_template_path($file_paths) { |
|
115 | 115 | |
116 | 116 | // Index 100 is the default GravityView template path. |
117 | - $file_paths[ 110 ] = self::$file; |
|
117 | + $file_paths[110] = self::$file; |
|
118 | 118 | |
119 | 119 | return $file_paths; |
120 | 120 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * @param $entry_id int Gravity Forms entry id |
129 | 129 | * @return string |
130 | 130 | */ |
131 | - public static function get_nonce_key( $view_id, $form_id, $entry_id ) { |
|
132 | - return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id ); |
|
131 | + public static function get_nonce_key($view_id, $form_id, $entry_id) { |
|
132 | + return sprintf('edit_%d_%d_%d', $view_id, $form_id, $entry_id); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -146,32 +146,32 @@ discard block |
||
146 | 146 | * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ } |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) { |
|
149 | + public static function get_edit_link($entry, $view_id, $post_id = null, $field_values = '') { |
|
150 | 150 | |
151 | - $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id'] ); |
|
151 | + $nonce_key = self::get_nonce_key($view_id, $entry['form_id'], $entry['id']); |
|
152 | 152 | |
153 | - $base = gv_entry_link( $entry, $post_id ); |
|
153 | + $base = gv_entry_link($entry, $post_id); |
|
154 | 154 | |
155 | - $url = add_query_arg( array( |
|
155 | + $url = add_query_arg(array( |
|
156 | 156 | 'page' => 'gf_entries', // Needed for GFForms::get_page() |
157 | 157 | 'view' => 'entry', // Needed for GFForms::get_page() |
158 | - 'edit' => wp_create_nonce( $nonce_key ) |
|
159 | - ), $base ); |
|
158 | + 'edit' => wp_create_nonce($nonce_key) |
|
159 | + ), $base); |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Allow passing params to dynamically populate entry with values |
163 | 163 | * @since 1.9.2 |
164 | 164 | */ |
165 | - if( !empty( $field_values ) ) { |
|
165 | + if (!empty($field_values)) { |
|
166 | 166 | |
167 | - if( is_array( $field_values ) ) { |
|
167 | + if (is_array($field_values)) { |
|
168 | 168 | // If already an array, no parse_str() needed |
169 | 169 | $params = $field_values; |
170 | 170 | } else { |
171 | - parse_str( $field_values, $params ); |
|
171 | + parse_str($field_values, $params); |
|
172 | 172 | } |
173 | 173 | |
174 | - $url = add_query_arg( $params, $url ); |
|
174 | + $url = add_query_arg($params, $url); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $url; |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | * @param string|null $context Context |
185 | 185 | * @return array If not edit context, original field blacklist. Otherwise, blacklist including post fields. |
186 | 186 | */ |
187 | - public function modify_field_blacklist( $fields = array(), $context = NULL ) { |
|
187 | + public function modify_field_blacklist($fields = array(), $context = NULL) { |
|
188 | 188 | |
189 | - if( empty( $context ) || $context !== 'edit' ) { |
|
189 | + if (empty($context) || $context !== 'edit') { |
|
190 | 190 | return $fields; |
191 | 191 | } |
192 | 192 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | // 'payment_method', This is editable in the admin, so allowing it here |
208 | 208 | ); |
209 | 209 | |
210 | - return array_merge( $fields, $add_fields ); |
|
210 | + return array_merge($fields, $add_fields); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2} |
221 | 221 | * @return bool |
222 | 222 | */ |
223 | - public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) { |
|
223 | + public static function check_user_cap_edit_entry($entry, $view_id = 0) { |
|
224 | 224 | |
225 | 225 | // No permission by default |
226 | 226 | $user_can_edit = false; |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | // If they can edit any entries (as defined in Gravity Forms) |
229 | 229 | // Or if they can edit other people's entries |
230 | 230 | // Then we're good. |
231 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) { |
|
231 | + if (GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_others_entries'), $entry['id'])) { |
|
232 | 232 | |
233 | - do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.'); |
|
233 | + do_action('gravityview_log_debug', __METHOD__.' - User has ability to edit all entries.'); |
|
234 | 234 | |
235 | 235 | $user_can_edit = true; |
236 | 236 | |
237 | - } else if( !isset( $entry['created_by'] ) ) { |
|
237 | + } else if (!isset($entry['created_by'])) { |
|
238 | 238 | |
239 | 239 | do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.'); |
240 | 240 | |
@@ -243,34 +243,34 @@ discard block |
||
243 | 243 | } else { |
244 | 244 | |
245 | 245 | // get user_edit setting |
246 | - if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) { |
|
246 | + if (empty($view_id) || $view_id == GravityView_View::getInstance()->getViewId()) { |
|
247 | 247 | // if View ID not specified or is the current view |
248 | 248 | $user_edit = GravityView_View::getInstance()->getAtts('user_edit'); |
249 | 249 | } else { |
250 | 250 | // in case is specified and not the current view |
251 | - $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' ); |
|
251 | + $user_edit = GVCommon::get_template_setting($view_id, 'user_edit'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | $current_user = wp_get_current_user(); |
255 | 255 | |
256 | 256 | // User edit is disabled |
257 | - if( empty( $user_edit ) ) { |
|
257 | + if (empty($user_edit)) { |
|
258 | 258 | |
259 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' ); |
|
259 | + do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.'); |
|
260 | 260 | |
261 | 261 | $user_can_edit = false; |
262 | 262 | } |
263 | 263 | |
264 | 264 | // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good. |
265 | - else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
265 | + else if (is_user_logged_in() && intval($current_user->ID) === intval($entry['created_by'])) { |
|
266 | 266 | |
267 | - do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) ); |
|
267 | + do_action('gravityview_log_debug', sprintf('GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID)); |
|
268 | 268 | |
269 | 269 | $user_can_edit = true; |
270 | 270 | |
271 | - } else if( ! is_user_logged_in() ) { |
|
271 | + } else if (!is_user_logged_in()) { |
|
272 | 272 | |
273 | - do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' ); |
|
273 | + do_action('gravityview_log_debug', __METHOD__.' No user defined; edit entry requires logged in user'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param[in] array $entry Gravity Forms entry array {@since 1.15} |
283 | 283 | * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15} |
284 | 284 | */ |
285 | - $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id ); |
|
285 | + $user_can_edit = apply_filters('gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id); |
|
286 | 286 | |
287 | 287 | return (bool)$user_can_edit; |
288 | 288 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | * @uses api_request() |
69 | 69 | * |
70 | 70 | * @param array $_transient_data Update array build by WordPress. |
71 | - * @return array Modified update array with custom plugin data. |
|
71 | + * @return stdClass Modified update array with custom plugin data. |
|
72 | 72 | */ |
73 | 73 | function check_update( $_transient_data ) { |
74 | 74 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if (!defined('ABSPATH')) exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Allows plugins to use their own update API. |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param string $_plugin_file Path to the plugin file. |
30 | 30 | * @param array $_api_data Optional data to send with API calls. |
31 | 31 | */ |
32 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
33 | - $this->api_url = trailingslashit( $_api_url ); |
|
32 | + function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
33 | + $this->api_url = trailingslashit($_api_url); |
|
34 | 34 | $this->api_data = $_api_data; |
35 | - $this->name = plugin_basename( $_plugin_file ); |
|
36 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
35 | + $this->name = plugin_basename($_plugin_file); |
|
36 | + $this->slug = basename($_plugin_file, '.php'); |
|
37 | 37 | $this->version = $_api_data['version']; |
38 | 38 | |
39 | 39 | // Set up hooks. |
40 | 40 | $this->init(); |
41 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
41 | + add_action('admin_init', array($this, 'show_changelog')); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | public function init() { |
53 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
54 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
53 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
54 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
55 | 55 | |
56 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 ); |
|
57 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
56 | + remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10, 2); |
|
57 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -70,32 +70,32 @@ discard block |
||
70 | 70 | * @param array $_transient_data Update array build by WordPress. |
71 | 71 | * @return array Modified update array with custom plugin data. |
72 | 72 | */ |
73 | - function check_update( $_transient_data ) { |
|
73 | + function check_update($_transient_data) { |
|
74 | 74 | |
75 | 75 | global $pagenow; |
76 | 76 | |
77 | - if( ! is_object( $_transient_data ) ) { |
|
77 | + if (!is_object($_transient_data)) { |
|
78 | 78 | $_transient_data = new stdClass; |
79 | 79 | } |
80 | 80 | |
81 | - if( 'plugins.php' == $pagenow && is_multisite() ) { |
|
81 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
82 | 82 | return $_transient_data; |
83 | 83 | } |
84 | 84 | |
85 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
85 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
86 | 86 | |
87 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
87 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
88 | 88 | |
89 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
89 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
90 | 90 | |
91 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
91 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
92 | 92 | |
93 | - $_transient_data->response[ $this->name ] = $version_info; |
|
93 | + $_transient_data->response[$this->name] = $version_info; |
|
94 | 94 | |
95 | 95 | } |
96 | 96 | |
97 | 97 | $_transient_data->last_checked = time(); |
98 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
98 | + $_transient_data->checked[$this->name] = $this->version; |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -110,86 +110,86 @@ discard block |
||
110 | 110 | * @param string $file |
111 | 111 | * @param array $plugin |
112 | 112 | */ |
113 | - public function show_update_notification( $file, $plugin ) { |
|
113 | + public function show_update_notification($file, $plugin) { |
|
114 | 114 | |
115 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
115 | + if (!current_user_can('update_plugins')) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | - if( ! is_multisite() ) { |
|
119 | + if (!is_multisite()) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $this->name != $file ) { |
|
123 | + if ($this->name != $file) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Remove our filter on the site transient |
128 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
128 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
129 | 129 | |
130 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
130 | + $update_cache = get_site_transient('update_plugins'); |
|
131 | 131 | |
132 | - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
|
132 | + $update_cache = is_object($update_cache) ? $update_cache : new stdClass(); |
|
133 | 133 | |
134 | - if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
134 | + if (empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
135 | 135 | |
136 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
137 | - $version_info = get_transient( $cache_key ); |
|
136 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
137 | + $version_info = get_transient($cache_key); |
|
138 | 138 | |
139 | - if( false === $version_info ) { |
|
139 | + if (false === $version_info) { |
|
140 | 140 | |
141 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
141 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
142 | 142 | |
143 | - set_transient( $cache_key, $version_info, 3600 ); |
|
143 | + set_transient($cache_key, $version_info, 3600); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | - if( ! is_object( $version_info ) ) { |
|
147 | + if (!is_object($version_info)) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | - if( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
151 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
152 | 152 | |
153 | - $update_cache->response[ $this->name ] = $version_info; |
|
153 | + $update_cache->response[$this->name] = $version_info; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | 157 | $update_cache->last_checked = time(); |
158 | - $update_cache->checked[ $this->name ] = $this->version; |
|
158 | + $update_cache->checked[$this->name] = $this->version; |
|
159 | 159 | |
160 | - set_site_transient( 'update_plugins', $update_cache ); |
|
160 | + set_site_transient('update_plugins', $update_cache); |
|
161 | 161 | |
162 | 162 | } else { |
163 | 163 | |
164 | - $version_info = $update_cache->response[ $this->name ]; |
|
164 | + $version_info = $update_cache->response[$this->name]; |
|
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Restore our filter |
169 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
169 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
170 | 170 | |
171 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
171 | + if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
172 | 172 | |
173 | 173 | // build a plugin list row, with update notification |
174 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
175 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
174 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
175 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
176 | 176 | |
177 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
177 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
178 | 178 | |
179 | - if ( empty( $version_info->download_link ) ) { |
|
179 | + if (empty($version_info->download_link)) { |
|
180 | 180 | printf( |
181 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview' ), |
|
182 | - esc_html( $version_info->name ), |
|
183 | - esc_url( $changelog_link ), |
|
184 | - esc_html( $version_info->new_version ) |
|
181 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview'), |
|
182 | + esc_html($version_info->name), |
|
183 | + esc_url($changelog_link), |
|
184 | + esc_html($version_info->new_version) |
|
185 | 185 | ); |
186 | 186 | } else { |
187 | 187 | printf( |
188 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview' ), |
|
189 | - esc_html( $version_info->name ), |
|
190 | - esc_url( $changelog_link ), |
|
191 | - esc_html( $version_info->new_version ), |
|
192 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
188 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview'), |
|
189 | + esc_html($version_info->name), |
|
190 | + esc_url($changelog_link), |
|
191 | + esc_html($version_info->new_version), |
|
192 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -208,16 +208,16 @@ discard block |
||
208 | 208 | * @param object $_args |
209 | 209 | * @return object $_data |
210 | 210 | */ |
211 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
211 | + function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
212 | 212 | |
213 | 213 | |
214 | - if ( $_action != 'plugin_information' ) { |
|
214 | + if ($_action != 'plugin_information') { |
|
215 | 215 | |
216 | 216 | return $_data; |
217 | 217 | |
218 | 218 | } |
219 | 219 | |
220 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
220 | + if (!isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
221 | 221 | |
222 | 222 | return $_data; |
223 | 223 | |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | ) |
233 | 233 | ); |
234 | 234 | |
235 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
235 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
236 | 236 | |
237 | - if ( false !== $api_response ) { |
|
237 | + if (false !== $api_response) { |
|
238 | 238 | $_data = $api_response; |
239 | 239 | } |
240 | 240 | |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | * @param string $url |
250 | 250 | * @return object $array |
251 | 251 | */ |
252 | - function http_request_args( $args, $url ) { |
|
252 | + function http_request_args($args, $url) { |
|
253 | 253 | // If it is an https request and we are performing a package download, disable ssl verification |
254 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
254 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
255 | 255 | $args['sslverify'] = false; |
256 | 256 | } |
257 | 257 | return $args; |
@@ -268,43 +268,43 @@ discard block |
||
268 | 268 | * @param array $_data Parameters for the API action. |
269 | 269 | * @return false|object |
270 | 270 | */ |
271 | - private function api_request( $_action, $_data ) { |
|
271 | + private function api_request($_action, $_data) { |
|
272 | 272 | |
273 | 273 | global $wp_version; |
274 | 274 | |
275 | - $data = array_merge( $this->api_data, $_data ); |
|
275 | + $data = array_merge($this->api_data, $_data); |
|
276 | 276 | |
277 | - if ( $data['slug'] != $this->slug ) { |
|
277 | + if ($data['slug'] != $this->slug) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | - if( $this->api_url == home_url() ) { |
|
281 | + if ($this->api_url == home_url()) { |
|
282 | 282 | return false; // Don't allow a plugin to ping itself |
283 | 283 | } |
284 | 284 | |
285 | 285 | $api_params = array( |
286 | 286 | 'edd_action' => 'get_version', |
287 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
288 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
289 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
287 | + 'license' => !empty($data['license']) ? $data['license'] : '', |
|
288 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
289 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
290 | 290 | 'slug' => $data['slug'], |
291 | 291 | 'author' => $data['author'], |
292 | 292 | 'url' => home_url() |
293 | 293 | ); |
294 | 294 | |
295 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
295 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
296 | 296 | |
297 | - if ( ! is_wp_error( $request ) ) { |
|
298 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
297 | + if (!is_wp_error($request)) { |
|
298 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( $request ) { |
|
302 | - if( isset( $request->sections ) ) { |
|
303 | - $request->sections = maybe_unserialize( $request->sections ); |
|
301 | + if ($request) { |
|
302 | + if (isset($request->sections)) { |
|
303 | + $request->sections = maybe_unserialize($request->sections); |
|
304 | 304 | } |
305 | 305 | |
306 | - if( isset( $request->banners ) ) { |
|
307 | - $request->banners = (array)maybe_unserialize( $request->banners ); |
|
306 | + if (isset($request->banners)) { |
|
307 | + $request->banners = (array)maybe_unserialize($request->banners); |
|
308 | 308 | } |
309 | 309 | } else { |
310 | 310 | $request = false; |
@@ -316,26 +316,26 @@ discard block |
||
316 | 316 | public function show_changelog() { |
317 | 317 | |
318 | 318 | |
319 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
319 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
323 | + if (empty($_REQUEST['plugin'])) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - if( empty( $_REQUEST['slug'] ) ) { |
|
327 | + if (empty($_REQUEST['slug'])) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
332 | - wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) ); |
|
331 | + if (!current_user_can('update_plugins')) { |
|
332 | + wp_die(__('You do not have permission to install plugin updates', 'gravityview'), __('Error', 'gravityview'), array('response' => 403)); |
|
333 | 333 | } |
334 | 334 | |
335 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
335 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
336 | 336 | |
337 | - if( $response && isset( $response->sections['changelog'] ) ) { |
|
338 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
337 | + if ($response && isset($response->sections['changelog'])) { |
|
338 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 |
@@ -4,7 +4,9 @@ |
||
4 | 4 | //set_site_transient( 'update_plugins', null ); |
5 | 5 | |
6 | 6 | // Exit if accessed directly |
7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
7 | +if ( ! defined( 'ABSPATH' ) ) { |
|
8 | + exit; |
|
9 | +} |
|
8 | 10 | |
9 | 11 | /** |
10 | 12 | * Allows plugins to use their own update API. |
@@ -10,6 +10,10 @@ discard block |
||
10 | 10 | * WordPress Importer class for managing parsing of WXR files. |
11 | 11 | */ |
12 | 12 | class WXR_Parser { |
13 | + |
|
14 | + /** |
|
15 | + * @param string $file |
|
16 | + */ |
|
13 | 17 | function parse( $file ) { |
14 | 18 | // Attempt to use proper XML parsers first |
15 | 19 | if ( extension_loaded( 'simplexml' ) ) { |
@@ -479,6 +483,9 @@ discard block |
||
479 | 483 | ); |
480 | 484 | } |
481 | 485 | |
486 | + /** |
|
487 | + * @param string $tag |
|
488 | + */ |
|
482 | 489 | function get_tag( $string, $tag ) { |
483 | 490 | preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return ); |
484 | 491 | if ( isset( $return[1] ) ) { |
@@ -500,6 +507,9 @@ discard block |
||
500 | 507 | return $return; |
501 | 508 | } |
502 | 509 | |
510 | + /** |
|
511 | + * @param string $c |
|
512 | + */ |
|
503 | 513 | function process_category( $c ) { |
504 | 514 | return array( |
505 | 515 | 'term_id' => $this->get_tag( $c, 'wp:term_id' ), |
@@ -510,6 +520,9 @@ discard block |
||
510 | 520 | ); |
511 | 521 | } |
512 | 522 | |
523 | + /** |
|
524 | + * @param string $t |
|
525 | + */ |
|
513 | 526 | function process_tag( $t ) { |
514 | 527 | return array( |
515 | 528 | 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
@@ -519,6 +532,9 @@ discard block |
||
519 | 532 | ); |
520 | 533 | } |
521 | 534 | |
535 | + /** |
|
536 | + * @param string $t |
|
537 | + */ |
|
522 | 538 | function process_term( $t ) { |
523 | 539 | return array( |
524 | 540 | 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
@@ -530,6 +546,9 @@ discard block |
||
530 | 546 | ); |
531 | 547 | } |
532 | 548 | |
549 | + /** |
|
550 | + * @param string $a |
|
551 | + */ |
|
533 | 552 | function process_author( $a ) { |
534 | 553 | return array( |
535 | 554 | 'author_id' => $this->get_tag( $a, 'wp:author_id' ), |
@@ -541,6 +560,9 @@ discard block |
||
541 | 560 | ); |
542 | 561 | } |
543 | 562 | |
563 | + /** |
|
564 | + * @param string $post |
|
565 | + */ |
|
544 | 566 | function process_post( $post ) { |
545 | 567 | $post_id = $this->get_tag( $post, 'wp:post_id' ); |
546 | 568 | $post_title = $this->get_tag( $post, 'title' ); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copied from WordPress Importer plugin |
|
4 | - * http://wordpress.org/extend/plugins/wordpress-importer/ |
|
5 | - * Version: 0.6.1 |
|
6 | - * License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|
7 | - */ |
|
3 | + * Copied from WordPress Importer plugin |
|
4 | + * http://wordpress.org/extend/plugins/wordpress-importer/ |
|
5 | + * Version: 0.6.1 |
|
6 | + * License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * WordPress Importer class for managing parsing of WXR files. |
@@ -10,42 +10,42 @@ discard block |
||
10 | 10 | * WordPress Importer class for managing parsing of WXR files. |
11 | 11 | */ |
12 | 12 | class WXR_Parser { |
13 | - function parse( $file ) { |
|
13 | + function parse($file) { |
|
14 | 14 | // Attempt to use proper XML parsers first |
15 | - if ( extension_loaded( 'simplexml' ) ) { |
|
15 | + if (extension_loaded('simplexml')) { |
|
16 | 16 | $parser = new WXR_Parser_SimpleXML; |
17 | - $result = $parser->parse( $file ); |
|
17 | + $result = $parser->parse($file); |
|
18 | 18 | |
19 | 19 | // If SimpleXML succeeds or this is an invalid WXR file then return the results |
20 | - if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) |
|
20 | + if (!is_wp_error($result) || 'SimpleXML_parse_error' != $result->get_error_code()) |
|
21 | 21 | return $result; |
22 | - } else if ( extension_loaded( 'xml' ) ) { |
|
22 | + } else if (extension_loaded('xml')) { |
|
23 | 23 | $parser = new WXR_Parser_XML; |
24 | - $result = $parser->parse( $file ); |
|
24 | + $result = $parser->parse($file); |
|
25 | 25 | |
26 | 26 | // If XMLParser succeeds or this is an invalid WXR file then return the results |
27 | - if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) |
|
27 | + if (!is_wp_error($result) || 'XML_parse_error' != $result->get_error_code()) |
|
28 | 28 | return $result; |
29 | 29 | } |
30 | 30 | |
31 | 31 | // We have a malformed XML file, so display the error and fallthrough to regex |
32 | - if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) { |
|
32 | + if (isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG) { |
|
33 | 33 | echo '<pre>'; |
34 | - if ( 'SimpleXML_parse_error' == $result->get_error_code() ) { |
|
35 | - foreach ( $result->get_error_data() as $error ) |
|
36 | - echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n"; |
|
37 | - } else if ( 'XML_parse_error' == $result->get_error_code() ) { |
|
34 | + if ('SimpleXML_parse_error' == $result->get_error_code()) { |
|
35 | + foreach ($result->get_error_data() as $error) |
|
36 | + echo $error->line.':'.$error->column.' '.esc_html($error->message)."\n"; |
|
37 | + } else if ('XML_parse_error' == $result->get_error_code()) { |
|
38 | 38 | $error = $result->get_error_data(); |
39 | - echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] ); |
|
39 | + echo $error[0].':'.$error[1].' '.esc_html($error[2]); |
|
40 | 40 | } |
41 | 41 | echo '</pre>'; |
42 | - echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />'; |
|
43 | - echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>'; |
|
42 | + echo '<p><strong>'.__('There was an error when reading this WXR file', 'wordpress-importer').'</strong><br />'; |
|
43 | + echo __('Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer').'</p>'; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // use regular expressions if nothing else available or this is bad XML |
47 | 47 | $parser = new WXR_Parser_Regex; |
48 | - return $parser->parse( $file ); |
|
48 | + return $parser->parse($file); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -53,171 +53,171 @@ discard block |
||
53 | 53 | * WXR Parser that makes use of the SimpleXML PHP extension. |
54 | 54 | */ |
55 | 55 | class WXR_Parser_SimpleXML { |
56 | - function parse( $file ) { |
|
56 | + function parse($file) { |
|
57 | 57 | $authors = $posts = $categories = $tags = $terms = array(); |
58 | 58 | |
59 | 59 | $internal_errors = libxml_use_internal_errors(true); |
60 | 60 | |
61 | 61 | $dom = new DOMDocument; |
62 | 62 | $old_value = null; |
63 | - if ( function_exists( 'libxml_disable_entity_loader' ) ) { |
|
64 | - $old_value = libxml_disable_entity_loader( true ); |
|
63 | + if (function_exists('libxml_disable_entity_loader')) { |
|
64 | + $old_value = libxml_disable_entity_loader(true); |
|
65 | 65 | } |
66 | - $success = $dom->loadXML( file_get_contents( $file ) ); |
|
67 | - if ( ! is_null( $old_value ) ) { |
|
68 | - libxml_disable_entity_loader( $old_value ); |
|
66 | + $success = $dom->loadXML(file_get_contents($file)); |
|
67 | + if (!is_null($old_value)) { |
|
68 | + libxml_disable_entity_loader($old_value); |
|
69 | 69 | } |
70 | 70 | |
71 | - if ( ! $success || isset( $dom->doctype ) ) { |
|
72 | - return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
71 | + if (!$success || isset($dom->doctype)) { |
|
72 | + return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors()); |
|
73 | 73 | } |
74 | 74 | |
75 | - $xml = simplexml_import_dom( $dom ); |
|
76 | - unset( $dom ); |
|
75 | + $xml = simplexml_import_dom($dom); |
|
76 | + unset($dom); |
|
77 | 77 | |
78 | 78 | // halt if loading produces an error |
79 | - if ( ! $xml ) |
|
80 | - return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
79 | + if (!$xml) |
|
80 | + return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors()); |
|
81 | 81 | |
82 | 82 | $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version'); |
83 | - if ( ! $wxr_version ) |
|
84 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
83 | + if (!$wxr_version) |
|
84 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
85 | 85 | |
86 | - $wxr_version = (string) trim( $wxr_version[0] ); |
|
86 | + $wxr_version = (string)trim($wxr_version[0]); |
|
87 | 87 | // confirm that we are dealing with the correct file format |
88 | - if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) |
|
89 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
88 | + if (!preg_match('/^\d+\.\d+$/', $wxr_version)) |
|
89 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
90 | 90 | |
91 | 91 | $base_url = $xml->xpath('/rss/channel/wp:base_site_url'); |
92 | - $base_url = isset($base_url[0]) ? (string) trim( $base_url[0] ) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them. |
|
92 | + $base_url = isset($base_url[0]) ? (string)trim($base_url[0]) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them. |
|
93 | 93 | |
94 | 94 | $namespaces = $xml->getDocNamespaces(); |
95 | - if ( ! isset( $namespaces['wp'] ) ) |
|
95 | + if (!isset($namespaces['wp'])) |
|
96 | 96 | $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; |
97 | - if ( ! isset( $namespaces['excerpt'] ) ) |
|
97 | + if (!isset($namespaces['excerpt'])) |
|
98 | 98 | $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; |
99 | 99 | |
100 | 100 | // grab authors |
101 | - foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) { |
|
102 | - $a = $author_arr->children( $namespaces['wp'] ); |
|
103 | - $login = (string) $a->author_login; |
|
101 | + foreach ($xml->xpath('/rss/channel/wp:author') as $author_arr) { |
|
102 | + $a = $author_arr->children($namespaces['wp']); |
|
103 | + $login = (string)$a->author_login; |
|
104 | 104 | $authors[$login] = array( |
105 | - 'author_id' => (int) $a->author_id, |
|
105 | + 'author_id' => (int)$a->author_id, |
|
106 | 106 | 'author_login' => $login, |
107 | - 'author_email' => (string) $a->author_email, |
|
108 | - 'author_display_name' => (string) $a->author_display_name, |
|
109 | - 'author_first_name' => (string) $a->author_first_name, |
|
110 | - 'author_last_name' => (string) $a->author_last_name |
|
107 | + 'author_email' => (string)$a->author_email, |
|
108 | + 'author_display_name' => (string)$a->author_display_name, |
|
109 | + 'author_first_name' => (string)$a->author_first_name, |
|
110 | + 'author_last_name' => (string)$a->author_last_name |
|
111 | 111 | ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | // grab cats, tags and terms |
115 | - foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) { |
|
116 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
115 | + foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) { |
|
116 | + $t = $term_arr->children($namespaces['wp']); |
|
117 | 117 | $categories[] = array( |
118 | - 'term_id' => (int) $t->term_id, |
|
119 | - 'category_nicename' => (string) $t->category_nicename, |
|
120 | - 'category_parent' => (string) $t->category_parent, |
|
121 | - 'cat_name' => (string) $t->cat_name, |
|
122 | - 'category_description' => (string) $t->category_description |
|
118 | + 'term_id' => (int)$t->term_id, |
|
119 | + 'category_nicename' => (string)$t->category_nicename, |
|
120 | + 'category_parent' => (string)$t->category_parent, |
|
121 | + 'cat_name' => (string)$t->cat_name, |
|
122 | + 'category_description' => (string)$t->category_description |
|
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) { |
|
127 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
126 | + foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) { |
|
127 | + $t = $term_arr->children($namespaces['wp']); |
|
128 | 128 | $tags[] = array( |
129 | - 'term_id' => (int) $t->term_id, |
|
130 | - 'tag_slug' => (string) $t->tag_slug, |
|
131 | - 'tag_name' => (string) $t->tag_name, |
|
132 | - 'tag_description' => (string) $t->tag_description |
|
129 | + 'term_id' => (int)$t->term_id, |
|
130 | + 'tag_slug' => (string)$t->tag_slug, |
|
131 | + 'tag_name' => (string)$t->tag_name, |
|
132 | + 'tag_description' => (string)$t->tag_description |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | |
136 | - foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) { |
|
137 | - $t = $term_arr->children( $namespaces['wp'] ); |
|
136 | + foreach ($xml->xpath('/rss/channel/wp:term') as $term_arr) { |
|
137 | + $t = $term_arr->children($namespaces['wp']); |
|
138 | 138 | $terms[] = array( |
139 | - 'term_id' => (int) $t->term_id, |
|
140 | - 'term_taxonomy' => (string) $t->term_taxonomy, |
|
141 | - 'slug' => (string) $t->term_slug, |
|
142 | - 'term_parent' => (string) $t->term_parent, |
|
143 | - 'term_name' => (string) $t->term_name, |
|
144 | - 'term_description' => (string) $t->term_description |
|
139 | + 'term_id' => (int)$t->term_id, |
|
140 | + 'term_taxonomy' => (string)$t->term_taxonomy, |
|
141 | + 'slug' => (string)$t->term_slug, |
|
142 | + 'term_parent' => (string)$t->term_parent, |
|
143 | + 'term_name' => (string)$t->term_name, |
|
144 | + 'term_description' => (string)$t->term_description |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // grab posts |
149 | - foreach ( $xml->channel->item as $item ) { |
|
149 | + foreach ($xml->channel->item as $item) { |
|
150 | 150 | $post = array( |
151 | - 'post_title' => (string) $item->title, |
|
152 | - 'guid' => (string) $item->guid, |
|
151 | + 'post_title' => (string)$item->title, |
|
152 | + 'guid' => (string)$item->guid, |
|
153 | 153 | ); |
154 | 154 | |
155 | - $dc = $item->children( 'http://purl.org/dc/elements/1.1/' ); |
|
156 | - $post['post_author'] = (string) $dc->creator; |
|
157 | - |
|
158 | - $content = $item->children( 'http://purl.org/rss/1.0/modules/content/' ); |
|
159 | - $excerpt = $item->children( $namespaces['excerpt'] ); |
|
160 | - $post['post_content'] = (string) $content->encoded; |
|
161 | - $post['post_excerpt'] = (string) $excerpt->encoded; |
|
162 | - |
|
163 | - $wp = $item->children( $namespaces['wp'] ); |
|
164 | - $post['post_id'] = (int) $wp->post_id; |
|
165 | - $post['post_date'] = (string) $wp->post_date; |
|
166 | - $post['post_date_gmt'] = (string) $wp->post_date_gmt; |
|
167 | - $post['comment_status'] = (string) $wp->comment_status; |
|
168 | - $post['ping_status'] = (string) $wp->ping_status; |
|
169 | - $post['post_name'] = (string) $wp->post_name; |
|
170 | - $post['status'] = (string) $wp->status; |
|
171 | - $post['post_parent'] = (int) $wp->post_parent; |
|
172 | - $post['menu_order'] = (int) $wp->menu_order; |
|
173 | - $post['post_type'] = (string) $wp->post_type; |
|
174 | - $post['post_password'] = (string) $wp->post_password; |
|
175 | - $post['is_sticky'] = (int) $wp->is_sticky; |
|
176 | - |
|
177 | - if ( isset($wp->attachment_url) ) |
|
178 | - $post['attachment_url'] = (string) $wp->attachment_url; |
|
179 | - |
|
180 | - foreach ( $item->category as $c ) { |
|
155 | + $dc = $item->children('http://purl.org/dc/elements/1.1/'); |
|
156 | + $post['post_author'] = (string)$dc->creator; |
|
157 | + |
|
158 | + $content = $item->children('http://purl.org/rss/1.0/modules/content/'); |
|
159 | + $excerpt = $item->children($namespaces['excerpt']); |
|
160 | + $post['post_content'] = (string)$content->encoded; |
|
161 | + $post['post_excerpt'] = (string)$excerpt->encoded; |
|
162 | + |
|
163 | + $wp = $item->children($namespaces['wp']); |
|
164 | + $post['post_id'] = (int)$wp->post_id; |
|
165 | + $post['post_date'] = (string)$wp->post_date; |
|
166 | + $post['post_date_gmt'] = (string)$wp->post_date_gmt; |
|
167 | + $post['comment_status'] = (string)$wp->comment_status; |
|
168 | + $post['ping_status'] = (string)$wp->ping_status; |
|
169 | + $post['post_name'] = (string)$wp->post_name; |
|
170 | + $post['status'] = (string)$wp->status; |
|
171 | + $post['post_parent'] = (int)$wp->post_parent; |
|
172 | + $post['menu_order'] = (int)$wp->menu_order; |
|
173 | + $post['post_type'] = (string)$wp->post_type; |
|
174 | + $post['post_password'] = (string)$wp->post_password; |
|
175 | + $post['is_sticky'] = (int)$wp->is_sticky; |
|
176 | + |
|
177 | + if (isset($wp->attachment_url)) |
|
178 | + $post['attachment_url'] = (string)$wp->attachment_url; |
|
179 | + |
|
180 | + foreach ($item->category as $c) { |
|
181 | 181 | $att = $c->attributes(); |
182 | - if ( isset( $att['nicename'] ) ) |
|
182 | + if (isset($att['nicename'])) |
|
183 | 183 | $post['terms'][] = array( |
184 | - 'name' => (string) $c, |
|
185 | - 'slug' => (string) $att['nicename'], |
|
186 | - 'domain' => (string) $att['domain'] |
|
184 | + 'name' => (string)$c, |
|
185 | + 'slug' => (string)$att['nicename'], |
|
186 | + 'domain' => (string)$att['domain'] |
|
187 | 187 | ); |
188 | 188 | } |
189 | 189 | |
190 | - foreach ( $wp->postmeta as $meta ) { |
|
190 | + foreach ($wp->postmeta as $meta) { |
|
191 | 191 | $post['postmeta'][] = array( |
192 | - 'key' => (string) $meta->meta_key, |
|
193 | - 'value' => (string) $meta->meta_value |
|
192 | + 'key' => (string)$meta->meta_key, |
|
193 | + 'value' => (string)$meta->meta_value |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | - foreach ( $wp->comment as $comment ) { |
|
197 | + foreach ($wp->comment as $comment) { |
|
198 | 198 | $meta = array(); |
199 | - if ( isset( $comment->commentmeta ) ) { |
|
200 | - foreach ( $comment->commentmeta as $m ) { |
|
199 | + if (isset($comment->commentmeta)) { |
|
200 | + foreach ($comment->commentmeta as $m) { |
|
201 | 201 | $meta[] = array( |
202 | - 'key' => (string) $m->meta_key, |
|
203 | - 'value' => (string) $m->meta_value |
|
202 | + 'key' => (string)$m->meta_key, |
|
203 | + 'value' => (string)$m->meta_value |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | $post['comments'][] = array( |
209 | - 'comment_id' => (int) $comment->comment_id, |
|
210 | - 'comment_author' => (string) $comment->comment_author, |
|
211 | - 'comment_author_email' => (string) $comment->comment_author_email, |
|
212 | - 'comment_author_IP' => (string) $comment->comment_author_IP, |
|
213 | - 'comment_author_url' => (string) $comment->comment_author_url, |
|
214 | - 'comment_date' => (string) $comment->comment_date, |
|
215 | - 'comment_date_gmt' => (string) $comment->comment_date_gmt, |
|
216 | - 'comment_content' => (string) $comment->comment_content, |
|
217 | - 'comment_approved' => (string) $comment->comment_approved, |
|
218 | - 'comment_type' => (string) $comment->comment_type, |
|
219 | - 'comment_parent' => (string) $comment->comment_parent, |
|
220 | - 'comment_user_id' => (int) $comment->comment_user_id, |
|
209 | + 'comment_id' => (int)$comment->comment_id, |
|
210 | + 'comment_author' => (string)$comment->comment_author, |
|
211 | + 'comment_author_email' => (string)$comment->comment_author_email, |
|
212 | + 'comment_author_IP' => (string)$comment->comment_author_IP, |
|
213 | + 'comment_author_url' => (string)$comment->comment_author_url, |
|
214 | + 'comment_date' => (string)$comment->comment_date, |
|
215 | + 'comment_date_gmt' => (string)$comment->comment_date_gmt, |
|
216 | + 'comment_content' => (string)$comment->comment_content, |
|
217 | + 'comment_approved' => (string)$comment->comment_approved, |
|
218 | + 'comment_type' => (string)$comment->comment_type, |
|
219 | + 'comment_parent' => (string)$comment->comment_parent, |
|
220 | + 'comment_user_id' => (int)$comment->comment_user_id, |
|
221 | 221 | 'commentmeta' => $meta, |
222 | 222 | ); |
223 | 223 | } |
@@ -251,32 +251,32 @@ discard block |
||
251 | 251 | ); |
252 | 252 | var $wp_sub_tags = array( |
253 | 253 | 'wp:comment_id', 'wp:comment_author', 'wp:comment_author_email', 'wp:comment_author_url', |
254 | - 'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content', |
|
254 | + 'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content', |
|
255 | 255 | 'wp:comment_approved', 'wp:comment_type', 'wp:comment_parent', 'wp:comment_user_id', |
256 | 256 | ); |
257 | 257 | |
258 | - function parse( $file ) { |
|
258 | + function parse($file) { |
|
259 | 259 | $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false; |
260 | 260 | $this->authors = $this->posts = $this->term = $this->category = $this->tag = array(); |
261 | 261 | |
262 | - $xml = xml_parser_create( 'UTF-8' ); |
|
263 | - xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 ); |
|
264 | - xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 ); |
|
265 | - xml_set_object( $xml, $this ); |
|
266 | - xml_set_character_data_handler( $xml, 'cdata' ); |
|
267 | - xml_set_element_handler( $xml, 'tag_open', 'tag_close' ); |
|
268 | - |
|
269 | - if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) { |
|
270 | - $current_line = xml_get_current_line_number( $xml ); |
|
271 | - $current_column = xml_get_current_column_number( $xml ); |
|
272 | - $error_code = xml_get_error_code( $xml ); |
|
273 | - $error_string = xml_error_string( $error_code ); |
|
274 | - return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) ); |
|
262 | + $xml = xml_parser_create('UTF-8'); |
|
263 | + xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); |
|
264 | + xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); |
|
265 | + xml_set_object($xml, $this); |
|
266 | + xml_set_character_data_handler($xml, 'cdata'); |
|
267 | + xml_set_element_handler($xml, 'tag_open', 'tag_close'); |
|
268 | + |
|
269 | + if (!xml_parse($xml, file_get_contents($file), true)) { |
|
270 | + $current_line = xml_get_current_line_number($xml); |
|
271 | + $current_column = xml_get_current_column_number($xml); |
|
272 | + $error_code = xml_get_error_code($xml); |
|
273 | + $error_string = xml_error_string($error_code); |
|
274 | + return new WP_Error('XML_parse_error', 'There was an error when reading this WXR file', array($current_line, $current_column, $error_string)); |
|
275 | 275 | } |
276 | - xml_parser_free( $xml ); |
|
276 | + xml_parser_free($xml); |
|
277 | 277 | |
278 | - if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) |
|
279 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
278 | + if (!preg_match('/^\d+\.\d+$/', $this->wxr_version)) |
|
279 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
280 | 280 | |
281 | 281 | return array( |
282 | 282 | 'authors' => $this->authors, |
@@ -289,26 +289,26 @@ discard block |
||
289 | 289 | ); |
290 | 290 | } |
291 | 291 | |
292 | - function tag_open( $parse, $tag, $attr ) { |
|
293 | - if ( in_array( $tag, $this->wp_tags ) ) { |
|
294 | - $this->in_tag = substr( $tag, 3 ); |
|
292 | + function tag_open($parse, $tag, $attr) { |
|
293 | + if (in_array($tag, $this->wp_tags)) { |
|
294 | + $this->in_tag = substr($tag, 3); |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - if ( in_array( $tag, $this->wp_sub_tags ) ) { |
|
299 | - $this->in_sub_tag = substr( $tag, 3 ); |
|
298 | + if (in_array($tag, $this->wp_sub_tags)) { |
|
299 | + $this->in_sub_tag = substr($tag, 3); |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
303 | - switch ( $tag ) { |
|
303 | + switch ($tag) { |
|
304 | 304 | case 'category': |
305 | - if ( isset($attr['domain'], $attr['nicename']) ) { |
|
305 | + if (isset($attr['domain'], $attr['nicename'])) { |
|
306 | 306 | $this->sub_data['domain'] = $attr['domain']; |
307 | 307 | $this->sub_data['slug'] = $attr['nicename']; |
308 | 308 | } |
309 | 309 | break; |
310 | 310 | case 'item': $this->in_post = true; |
311 | - case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break; |
|
311 | + case 'title': if ($this->in_post) $this->in_tag = 'post_title'; break; |
|
312 | 312 | case 'guid': $this->in_tag = 'guid'; break; |
313 | 313 | case 'dc:creator': $this->in_tag = 'post_author'; break; |
314 | 314 | case 'content:encoded': $this->in_tag = 'post_content'; break; |
@@ -320,18 +320,18 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - function cdata( $parser, $cdata ) { |
|
324 | - if ( ! trim( $cdata ) ) |
|
323 | + function cdata($parser, $cdata) { |
|
324 | + if (!trim($cdata)) |
|
325 | 325 | return; |
326 | 326 | |
327 | - $this->cdata .= trim( $cdata ); |
|
327 | + $this->cdata .= trim($cdata); |
|
328 | 328 | } |
329 | 329 | |
330 | - function tag_close( $parser, $tag ) { |
|
331 | - switch ( $tag ) { |
|
330 | + function tag_close($parser, $tag) { |
|
331 | + switch ($tag) { |
|
332 | 332 | case 'wp:comment': |
333 | - unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data |
|
334 | - if ( ! empty( $this->sub_data ) ) |
|
333 | + unset($this->sub_data['key'], $this->sub_data['value']); // remove meta sub_data |
|
334 | + if (!empty($this->sub_data)) |
|
335 | 335 | $this->data['comments'][] = $this->sub_data; |
336 | 336 | $this->sub_data = false; |
337 | 337 | break; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | ); |
343 | 343 | break; |
344 | 344 | case 'category': |
345 | - if ( ! empty( $this->sub_data ) ) { |
|
345 | + if (!empty($this->sub_data)) { |
|
346 | 346 | $this->sub_data['name'] = $this->cdata; |
347 | 347 | $this->data['terms'][] = $this->sub_data; |
348 | 348 | } |
349 | 349 | $this->sub_data = false; |
350 | 350 | break; |
351 | 351 | case 'wp:postmeta': |
352 | - if ( ! empty( $this->sub_data ) ) |
|
352 | + if (!empty($this->sub_data)) |
|
353 | 353 | $this->data['postmeta'][] = $this->sub_data; |
354 | 354 | $this->sub_data = false; |
355 | 355 | break; |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | case 'wp:category': |
361 | 361 | case 'wp:tag': |
362 | 362 | case 'wp:term': |
363 | - $n = substr( $tag, 3 ); |
|
364 | - array_push( $this->$n, $this->data ); |
|
363 | + $n = substr($tag, 3); |
|
364 | + array_push($this->$n, $this->data); |
|
365 | 365 | $this->data = false; |
366 | 366 | break; |
367 | 367 | case 'wp:author': |
368 | - if ( ! empty($this->data['author_login']) ) |
|
368 | + if (!empty($this->data['author_login'])) |
|
369 | 369 | $this->authors[$this->data['author_login']] = $this->data; |
370 | 370 | $this->data = false; |
371 | 371 | break; |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | break; |
378 | 378 | |
379 | 379 | default: |
380 | - if ( $this->in_sub_tag ) { |
|
381 | - $this->sub_data[$this->in_sub_tag] = ! empty( $this->cdata ) ? $this->cdata : ''; |
|
380 | + if ($this->in_sub_tag) { |
|
381 | + $this->sub_data[$this->in_sub_tag] = !empty($this->cdata) ? $this->cdata : ''; |
|
382 | 382 | $this->in_sub_tag = false; |
383 | - } else if ( $this->in_tag ) { |
|
384 | - $this->data[$this->in_tag] = ! empty( $this->cdata ) ? $this->cdata : ''; |
|
383 | + } else if ($this->in_tag) { |
|
384 | + $this->data[$this->in_tag] = !empty($this->cdata) ? $this->cdata : ''; |
|
385 | 385 | $this->in_tag = false; |
386 | 386 | } |
387 | 387 | } |
@@ -407,66 +407,66 @@ discard block |
||
407 | 407 | }*/ |
408 | 408 | |
409 | 409 | function __construct() { |
410 | - $this->has_gzip = is_callable( 'gzopen' ); |
|
410 | + $this->has_gzip = is_callable('gzopen'); |
|
411 | 411 | } |
412 | 412 | |
413 | - function parse( $file ) { |
|
413 | + function parse($file) { |
|
414 | 414 | $wxr_version = $in_post = false; |
415 | 415 | |
416 | - $fp = $this->fopen( $file, 'r' ); |
|
417 | - if ( $fp ) { |
|
418 | - while ( ! $this->feof( $fp ) ) { |
|
419 | - $importline = rtrim( $this->fgets( $fp ) ); |
|
416 | + $fp = $this->fopen($file, 'r'); |
|
417 | + if ($fp) { |
|
418 | + while (!$this->feof($fp)) { |
|
419 | + $importline = rtrim($this->fgets($fp)); |
|
420 | 420 | |
421 | - if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) ) |
|
421 | + if (!$wxr_version && preg_match('|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version)) |
|
422 | 422 | $wxr_version = $version[1]; |
423 | 423 | |
424 | - if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) { |
|
425 | - preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url ); |
|
424 | + if (false !== strpos($importline, '<wp:base_site_url>')) { |
|
425 | + preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url); |
|
426 | 426 | $this->base_url = $url[1]; |
427 | 427 | continue; |
428 | 428 | } |
429 | - if ( false !== strpos( $importline, '<wp:category>' ) ) { |
|
430 | - preg_match( '|<wp:category>(.*?)</wp:category>|is', $importline, $category ); |
|
431 | - $this->categories[] = $this->process_category( $category[1] ); |
|
429 | + if (false !== strpos($importline, '<wp:category>')) { |
|
430 | + preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); |
|
431 | + $this->categories[] = $this->process_category($category[1]); |
|
432 | 432 | continue; |
433 | 433 | } |
434 | - if ( false !== strpos( $importline, '<wp:tag>' ) ) { |
|
435 | - preg_match( '|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag ); |
|
436 | - $this->tags[] = $this->process_tag( $tag[1] ); |
|
434 | + if (false !== strpos($importline, '<wp:tag>')) { |
|
435 | + preg_match('|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag); |
|
436 | + $this->tags[] = $this->process_tag($tag[1]); |
|
437 | 437 | continue; |
438 | 438 | } |
439 | - if ( false !== strpos( $importline, '<wp:term>' ) ) { |
|
440 | - preg_match( '|<wp:term>(.*?)</wp:term>|is', $importline, $term ); |
|
441 | - $this->terms[] = $this->process_term( $term[1] ); |
|
439 | + if (false !== strpos($importline, '<wp:term>')) { |
|
440 | + preg_match('|<wp:term>(.*?)</wp:term>|is', $importline, $term); |
|
441 | + $this->terms[] = $this->process_term($term[1]); |
|
442 | 442 | continue; |
443 | 443 | } |
444 | - if ( false !== strpos( $importline, '<wp:author>' ) ) { |
|
445 | - preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author ); |
|
446 | - $a = $this->process_author( $author[1] ); |
|
444 | + if (false !== strpos($importline, '<wp:author>')) { |
|
445 | + preg_match('|<wp:author>(.*?)</wp:author>|is', $importline, $author); |
|
446 | + $a = $this->process_author($author[1]); |
|
447 | 447 | $this->authors[$a['author_login']] = $a; |
448 | 448 | continue; |
449 | 449 | } |
450 | - if ( false !== strpos( $importline, '<item>' ) ) { |
|
450 | + if (false !== strpos($importline, '<item>')) { |
|
451 | 451 | $post = ''; |
452 | 452 | $in_post = true; |
453 | 453 | continue; |
454 | 454 | } |
455 | - if ( false !== strpos( $importline, '</item>' ) ) { |
|
455 | + if (false !== strpos($importline, '</item>')) { |
|
456 | 456 | $in_post = false; |
457 | - $this->posts[] = $this->process_post( $post ); |
|
457 | + $this->posts[] = $this->process_post($post); |
|
458 | 458 | continue; |
459 | 459 | } |
460 | - if ( $in_post ) { |
|
461 | - $post .= $importline . "\n"; |
|
460 | + if ($in_post) { |
|
461 | + $post .= $importline."\n"; |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | 465 | $this->fclose($fp); |
466 | 466 | } |
467 | 467 | |
468 | - if ( ! $wxr_version ) |
|
469 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
468 | + if (!$wxr_version) |
|
469 | + return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); |
|
470 | 470 | |
471 | 471 | return array( |
472 | 472 | 'authors' => $this->authors, |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | ); |
480 | 480 | } |
481 | 481 | |
482 | - function get_tag( $string, $tag ) { |
|
483 | - preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return ); |
|
484 | - if ( isset( $return[1] ) ) { |
|
485 | - if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) { |
|
486 | - if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) { |
|
487 | - preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches ); |
|
482 | + function get_tag($string, $tag) { |
|
483 | + preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return); |
|
484 | + if (isset($return[1])) { |
|
485 | + if (substr($return[1], 0, 9) == '<![CDATA[') { |
|
486 | + if (strpos($return[1], ']]]]><![CDATA[>') !== false) { |
|
487 | + preg_match_all('|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches); |
|
488 | 488 | $return = ''; |
489 | - foreach( $matches[1] as $match ) |
|
489 | + foreach ($matches[1] as $match) |
|
490 | 490 | $return .= $match; |
491 | 491 | } else { |
492 | - $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] ); |
|
492 | + $return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]); |
|
493 | 493 | } |
494 | 494 | } else { |
495 | 495 | $return = $return[1]; |
@@ -500,166 +500,166 @@ discard block |
||
500 | 500 | return $return; |
501 | 501 | } |
502 | 502 | |
503 | - function process_category( $c ) { |
|
503 | + function process_category($c) { |
|
504 | 504 | return array( |
505 | - 'term_id' => $this->get_tag( $c, 'wp:term_id' ), |
|
506 | - 'cat_name' => $this->get_tag( $c, 'wp:cat_name' ), |
|
507 | - 'category_nicename' => $this->get_tag( $c, 'wp:category_nicename' ), |
|
508 | - 'category_parent' => $this->get_tag( $c, 'wp:category_parent' ), |
|
509 | - 'category_description' => $this->get_tag( $c, 'wp:category_description' ), |
|
505 | + 'term_id' => $this->get_tag($c, 'wp:term_id'), |
|
506 | + 'cat_name' => $this->get_tag($c, 'wp:cat_name'), |
|
507 | + 'category_nicename' => $this->get_tag($c, 'wp:category_nicename'), |
|
508 | + 'category_parent' => $this->get_tag($c, 'wp:category_parent'), |
|
509 | + 'category_description' => $this->get_tag($c, 'wp:category_description'), |
|
510 | 510 | ); |
511 | 511 | } |
512 | 512 | |
513 | - function process_tag( $t ) { |
|
513 | + function process_tag($t) { |
|
514 | 514 | return array( |
515 | - 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
|
516 | - 'tag_name' => $this->get_tag( $t, 'wp:tag_name' ), |
|
517 | - 'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ), |
|
518 | - 'tag_description' => $this->get_tag( $t, 'wp:tag_description' ), |
|
515 | + 'term_id' => $this->get_tag($t, 'wp:term_id'), |
|
516 | + 'tag_name' => $this->get_tag($t, 'wp:tag_name'), |
|
517 | + 'tag_slug' => $this->get_tag($t, 'wp:tag_slug'), |
|
518 | + 'tag_description' => $this->get_tag($t, 'wp:tag_description'), |
|
519 | 519 | ); |
520 | 520 | } |
521 | 521 | |
522 | - function process_term( $t ) { |
|
522 | + function process_term($t) { |
|
523 | 523 | return array( |
524 | - 'term_id' => $this->get_tag( $t, 'wp:term_id' ), |
|
525 | - 'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ), |
|
526 | - 'slug' => $this->get_tag( $t, 'wp:term_slug' ), |
|
527 | - 'term_parent' => $this->get_tag( $t, 'wp:term_parent' ), |
|
528 | - 'term_name' => $this->get_tag( $t, 'wp:term_name' ), |
|
529 | - 'term_description' => $this->get_tag( $t, 'wp:term_description' ), |
|
524 | + 'term_id' => $this->get_tag($t, 'wp:term_id'), |
|
525 | + 'term_taxonomy' => $this->get_tag($t, 'wp:term_taxonomy'), |
|
526 | + 'slug' => $this->get_tag($t, 'wp:term_slug'), |
|
527 | + 'term_parent' => $this->get_tag($t, 'wp:term_parent'), |
|
528 | + 'term_name' => $this->get_tag($t, 'wp:term_name'), |
|
529 | + 'term_description' => $this->get_tag($t, 'wp:term_description'), |
|
530 | 530 | ); |
531 | 531 | } |
532 | 532 | |
533 | - function process_author( $a ) { |
|
533 | + function process_author($a) { |
|
534 | 534 | return array( |
535 | - 'author_id' => $this->get_tag( $a, 'wp:author_id' ), |
|
536 | - 'author_login' => $this->get_tag( $a, 'wp:author_login' ), |
|
537 | - 'author_email' => $this->get_tag( $a, 'wp:author_email' ), |
|
538 | - 'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ), |
|
539 | - 'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ), |
|
540 | - 'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ), |
|
535 | + 'author_id' => $this->get_tag($a, 'wp:author_id'), |
|
536 | + 'author_login' => $this->get_tag($a, 'wp:author_login'), |
|
537 | + 'author_email' => $this->get_tag($a, 'wp:author_email'), |
|
538 | + 'author_display_name' => $this->get_tag($a, 'wp:author_display_name'), |
|
539 | + 'author_first_name' => $this->get_tag($a, 'wp:author_first_name'), |
|
540 | + 'author_last_name' => $this->get_tag($a, 'wp:author_last_name'), |
|
541 | 541 | ); |
542 | 542 | } |
543 | 543 | |
544 | - function process_post( $post ) { |
|
545 | - $post_id = $this->get_tag( $post, 'wp:post_id' ); |
|
546 | - $post_title = $this->get_tag( $post, 'title' ); |
|
547 | - $post_date = $this->get_tag( $post, 'wp:post_date' ); |
|
548 | - $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); |
|
549 | - $comment_status = $this->get_tag( $post, 'wp:comment_status' ); |
|
550 | - $ping_status = $this->get_tag( $post, 'wp:ping_status' ); |
|
551 | - $status = $this->get_tag( $post, 'wp:status' ); |
|
552 | - $post_name = $this->get_tag( $post, 'wp:post_name' ); |
|
553 | - $post_parent = $this->get_tag( $post, 'wp:post_parent' ); |
|
554 | - $menu_order = $this->get_tag( $post, 'wp:menu_order' ); |
|
555 | - $post_type = $this->get_tag( $post, 'wp:post_type' ); |
|
556 | - $post_password = $this->get_tag( $post, 'wp:post_password' ); |
|
557 | - $is_sticky = $this->get_tag( $post, 'wp:is_sticky' ); |
|
558 | - $guid = $this->get_tag( $post, 'guid' ); |
|
559 | - $post_author = $this->get_tag( $post, 'dc:creator' ); |
|
560 | - |
|
561 | - $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' ); |
|
562 | - $post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt ); |
|
563 | - $post_excerpt = str_replace( '<br>', '<br />', $post_excerpt ); |
|
564 | - $post_excerpt = str_replace( '<hr>', '<hr />', $post_excerpt ); |
|
565 | - |
|
566 | - $post_content = $this->get_tag( $post, 'content:encoded' ); |
|
567 | - $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content ); |
|
568 | - $post_content = str_replace( '<br>', '<br />', $post_content ); |
|
569 | - $post_content = str_replace( '<hr>', '<hr />', $post_content ); |
|
570 | - |
|
571 | - $postdata = compact( 'post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', |
|
544 | + function process_post($post) { |
|
545 | + $post_id = $this->get_tag($post, 'wp:post_id'); |
|
546 | + $post_title = $this->get_tag($post, 'title'); |
|
547 | + $post_date = $this->get_tag($post, 'wp:post_date'); |
|
548 | + $post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt'); |
|
549 | + $comment_status = $this->get_tag($post, 'wp:comment_status'); |
|
550 | + $ping_status = $this->get_tag($post, 'wp:ping_status'); |
|
551 | + $status = $this->get_tag($post, 'wp:status'); |
|
552 | + $post_name = $this->get_tag($post, 'wp:post_name'); |
|
553 | + $post_parent = $this->get_tag($post, 'wp:post_parent'); |
|
554 | + $menu_order = $this->get_tag($post, 'wp:menu_order'); |
|
555 | + $post_type = $this->get_tag($post, 'wp:post_type'); |
|
556 | + $post_password = $this->get_tag($post, 'wp:post_password'); |
|
557 | + $is_sticky = $this->get_tag($post, 'wp:is_sticky'); |
|
558 | + $guid = $this->get_tag($post, 'guid'); |
|
559 | + $post_author = $this->get_tag($post, 'dc:creator'); |
|
560 | + |
|
561 | + $post_excerpt = $this->get_tag($post, 'excerpt:encoded'); |
|
562 | + $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_excerpt); |
|
563 | + $post_excerpt = str_replace('<br>', '<br />', $post_excerpt); |
|
564 | + $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt); |
|
565 | + |
|
566 | + $post_content = $this->get_tag($post, 'content:encoded'); |
|
567 | + $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content); |
|
568 | + $post_content = str_replace('<br>', '<br />', $post_content); |
|
569 | + $post_content = str_replace('<hr>', '<hr />', $post_content); |
|
570 | + |
|
571 | + $postdata = compact('post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', |
|
572 | 572 | 'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', |
573 | 573 | 'menu_order', 'post_type', 'post_password', 'is_sticky' |
574 | 574 | ); |
575 | 575 | |
576 | - $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); |
|
577 | - if ( $attachment_url ) |
|
576 | + $attachment_url = $this->get_tag($post, 'wp:attachment_url'); |
|
577 | + if ($attachment_url) |
|
578 | 578 | $postdata['attachment_url'] = $attachment_url; |
579 | 579 | |
580 | - preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER ); |
|
581 | - foreach ( $terms as $t ) { |
|
580 | + preg_match_all('|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER); |
|
581 | + foreach ($terms as $t) { |
|
582 | 582 | $post_terms[] = array( |
583 | 583 | 'slug' => $t[2], |
584 | 584 | 'domain' => $t[1], |
585 | - 'name' => str_replace( array( '<![CDATA[', ']]>' ), '', $t[3] ), |
|
585 | + 'name' => str_replace(array('<![CDATA[', ']]>'), '', $t[3]), |
|
586 | 586 | ); |
587 | 587 | } |
588 | - if ( ! empty( $post_terms ) ) $postdata['terms'] = $post_terms; |
|
588 | + if (!empty($post_terms)) $postdata['terms'] = $post_terms; |
|
589 | 589 | |
590 | - preg_match_all( '|<wp:comment>(.+?)</wp:comment>|is', $post, $comments ); |
|
590 | + preg_match_all('|<wp:comment>(.+?)</wp:comment>|is', $post, $comments); |
|
591 | 591 | $comments = $comments[1]; |
592 | - if ( $comments ) { |
|
593 | - foreach ( $comments as $comment ) { |
|
594 | - preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta ); |
|
592 | + if ($comments) { |
|
593 | + foreach ($comments as $comment) { |
|
594 | + preg_match_all('|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta); |
|
595 | 595 | $commentmeta = $commentmeta[1]; |
596 | 596 | $c_meta = array(); |
597 | - foreach ( $commentmeta as $m ) { |
|
597 | + foreach ($commentmeta as $m) { |
|
598 | 598 | $c_meta[] = array( |
599 | - 'key' => $this->get_tag( $m, 'wp:meta_key' ), |
|
600 | - 'value' => $this->get_tag( $m, 'wp:meta_value' ), |
|
599 | + 'key' => $this->get_tag($m, 'wp:meta_key'), |
|
600 | + 'value' => $this->get_tag($m, 'wp:meta_value'), |
|
601 | 601 | ); |
602 | 602 | } |
603 | 603 | |
604 | 604 | $post_comments[] = array( |
605 | - 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), |
|
606 | - 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), |
|
607 | - 'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ), |
|
608 | - 'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ), |
|
609 | - 'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ), |
|
610 | - 'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ), |
|
611 | - 'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ), |
|
612 | - 'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ), |
|
613 | - 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), |
|
614 | - 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), |
|
615 | - 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), |
|
616 | - 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), |
|
605 | + 'comment_id' => $this->get_tag($comment, 'wp:comment_id'), |
|
606 | + 'comment_author' => $this->get_tag($comment, 'wp:comment_author'), |
|
607 | + 'comment_author_email' => $this->get_tag($comment, 'wp:comment_author_email'), |
|
608 | + 'comment_author_IP' => $this->get_tag($comment, 'wp:comment_author_IP'), |
|
609 | + 'comment_author_url' => $this->get_tag($comment, 'wp:comment_author_url'), |
|
610 | + 'comment_date' => $this->get_tag($comment, 'wp:comment_date'), |
|
611 | + 'comment_date_gmt' => $this->get_tag($comment, 'wp:comment_date_gmt'), |
|
612 | + 'comment_content' => $this->get_tag($comment, 'wp:comment_content'), |
|
613 | + 'comment_approved' => $this->get_tag($comment, 'wp:comment_approved'), |
|
614 | + 'comment_type' => $this->get_tag($comment, 'wp:comment_type'), |
|
615 | + 'comment_parent' => $this->get_tag($comment, 'wp:comment_parent'), |
|
616 | + 'comment_user_id' => $this->get_tag($comment, 'wp:comment_user_id'), |
|
617 | 617 | 'commentmeta' => $c_meta, |
618 | 618 | ); |
619 | 619 | } |
620 | 620 | } |
621 | - if ( ! empty( $post_comments ) ) $postdata['comments'] = $post_comments; |
|
621 | + if (!empty($post_comments)) $postdata['comments'] = $post_comments; |
|
622 | 622 | |
623 | - preg_match_all( '|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta ); |
|
623 | + preg_match_all('|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta); |
|
624 | 624 | $postmeta = $postmeta[1]; |
625 | - if ( $postmeta ) { |
|
626 | - foreach ( $postmeta as $p ) { |
|
625 | + if ($postmeta) { |
|
626 | + foreach ($postmeta as $p) { |
|
627 | 627 | $post_postmeta[] = array( |
628 | - 'key' => $this->get_tag( $p, 'wp:meta_key' ), |
|
629 | - 'value' => $this->get_tag( $p, 'wp:meta_value' ), |
|
628 | + 'key' => $this->get_tag($p, 'wp:meta_key'), |
|
629 | + 'value' => $this->get_tag($p, 'wp:meta_value'), |
|
630 | 630 | ); |
631 | 631 | } |
632 | 632 | } |
633 | - if ( ! empty( $post_postmeta ) ) $postdata['postmeta'] = $post_postmeta; |
|
633 | + if (!empty($post_postmeta)) $postdata['postmeta'] = $post_postmeta; |
|
634 | 634 | |
635 | 635 | return $postdata; |
636 | 636 | } |
637 | 637 | |
638 | - function _normalize_tag( $matches ) { |
|
639 | - return '<' . strtolower( $matches[1] ); |
|
638 | + function _normalize_tag($matches) { |
|
639 | + return '<'.strtolower($matches[1]); |
|
640 | 640 | } |
641 | 641 | |
642 | - function fopen( $filename, $mode = 'r' ) { |
|
643 | - if ( $this->has_gzip ) |
|
644 | - return gzopen( $filename, $mode ); |
|
645 | - return fopen( $filename, $mode ); |
|
642 | + function fopen($filename, $mode = 'r') { |
|
643 | + if ($this->has_gzip) |
|
644 | + return gzopen($filename, $mode); |
|
645 | + return fopen($filename, $mode); |
|
646 | 646 | } |
647 | 647 | |
648 | - function feof( $fp ) { |
|
649 | - if ( $this->has_gzip ) |
|
650 | - return gzeof( $fp ); |
|
651 | - return feof( $fp ); |
|
648 | + function feof($fp) { |
|
649 | + if ($this->has_gzip) |
|
650 | + return gzeof($fp); |
|
651 | + return feof($fp); |
|
652 | 652 | } |
653 | 653 | |
654 | - function fgets( $fp, $len = 8192 ) { |
|
655 | - if ( $this->has_gzip ) |
|
656 | - return gzgets( $fp, $len ); |
|
657 | - return fgets( $fp, $len ); |
|
654 | + function fgets($fp, $len = 8192) { |
|
655 | + if ($this->has_gzip) |
|
656 | + return gzgets($fp, $len); |
|
657 | + return fgets($fp, $len); |
|
658 | 658 | } |
659 | 659 | |
660 | - function fclose( $fp ) { |
|
661 | - if ( $this->has_gzip ) |
|
662 | - return gzclose( $fp ); |
|
663 | - return fclose( $fp ); |
|
660 | + function fclose($fp) { |
|
661 | + if ($this->has_gzip) |
|
662 | + return gzclose($fp); |
|
663 | + return fclose($fp); |
|
664 | 664 | } |
665 | 665 | } |
@@ -17,23 +17,26 @@ discard block |
||
17 | 17 | $result = $parser->parse( $file ); |
18 | 18 | |
19 | 19 | // If SimpleXML succeeds or this is an invalid WXR file then return the results |
20 | - if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) |
|
21 | - return $result; |
|
20 | + if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() ) { |
|
21 | + return $result; |
|
22 | + } |
|
22 | 23 | } else if ( extension_loaded( 'xml' ) ) { |
23 | 24 | $parser = new WXR_Parser_XML; |
24 | 25 | $result = $parser->parse( $file ); |
25 | 26 | |
26 | 27 | // If XMLParser succeeds or this is an invalid WXR file then return the results |
27 | - if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) |
|
28 | - return $result; |
|
28 | + if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() ) { |
|
29 | + return $result; |
|
30 | + } |
|
29 | 31 | } |
30 | 32 | |
31 | 33 | // We have a malformed XML file, so display the error and fallthrough to regex |
32 | 34 | if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) { |
33 | 35 | echo '<pre>'; |
34 | 36 | if ( 'SimpleXML_parse_error' == $result->get_error_code() ) { |
35 | - foreach ( $result->get_error_data() as $error ) |
|
36 | - echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n"; |
|
37 | + foreach ( $result->get_error_data() as $error ) { |
|
38 | + echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n"; |
|
39 | + } |
|
37 | 40 | } else if ( 'XML_parse_error' == $result->get_error_code() ) { |
38 | 41 | $error = $result->get_error_data(); |
39 | 42 | echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] ); |
@@ -76,26 +79,31 @@ discard block |
||
76 | 79 | unset( $dom ); |
77 | 80 | |
78 | 81 | // halt if loading produces an error |
79 | - if ( ! $xml ) |
|
80 | - return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
82 | + if ( ! $xml ) { |
|
83 | + return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() ); |
|
84 | + } |
|
81 | 85 | |
82 | 86 | $wxr_version = $xml->xpath('/rss/channel/wp:wxr_version'); |
83 | - if ( ! $wxr_version ) |
|
84 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
87 | + if ( ! $wxr_version ) { |
|
88 | + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
89 | + } |
|
85 | 90 | |
86 | 91 | $wxr_version = (string) trim( $wxr_version[0] ); |
87 | 92 | // confirm that we are dealing with the correct file format |
88 | - if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) |
|
89 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
93 | + if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) ) { |
|
94 | + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
95 | + } |
|
90 | 96 | |
91 | 97 | $base_url = $xml->xpath('/rss/channel/wp:base_site_url'); |
92 | 98 | $base_url = isset($base_url[0]) ? (string) trim( $base_url[0] ) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them. |
93 | 99 | |
94 | 100 | $namespaces = $xml->getDocNamespaces(); |
95 | - if ( ! isset( $namespaces['wp'] ) ) |
|
96 | - $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; |
|
97 | - if ( ! isset( $namespaces['excerpt'] ) ) |
|
98 | - $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; |
|
101 | + if ( ! isset( $namespaces['wp'] ) ) { |
|
102 | + $namespaces['wp'] = 'http://wordpress.org/export/1.1/'; |
|
103 | + } |
|
104 | + if ( ! isset( $namespaces['excerpt'] ) ) { |
|
105 | + $namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/'; |
|
106 | + } |
|
99 | 107 | |
100 | 108 | // grab authors |
101 | 109 | foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) { |
@@ -174,17 +182,19 @@ discard block |
||
174 | 182 | $post['post_password'] = (string) $wp->post_password; |
175 | 183 | $post['is_sticky'] = (int) $wp->is_sticky; |
176 | 184 | |
177 | - if ( isset($wp->attachment_url) ) |
|
178 | - $post['attachment_url'] = (string) $wp->attachment_url; |
|
185 | + if ( isset($wp->attachment_url) ) { |
|
186 | + $post['attachment_url'] = (string) $wp->attachment_url; |
|
187 | + } |
|
179 | 188 | |
180 | 189 | foreach ( $item->category as $c ) { |
181 | 190 | $att = $c->attributes(); |
182 | - if ( isset( $att['nicename'] ) ) |
|
183 | - $post['terms'][] = array( |
|
191 | + if ( isset( $att['nicename'] ) ) { |
|
192 | + $post['terms'][] = array( |
|
184 | 193 | 'name' => (string) $c, |
185 | 194 | 'slug' => (string) $att['nicename'], |
186 | 195 | 'domain' => (string) $att['domain'] |
187 | 196 | ); |
197 | + } |
|
188 | 198 | } |
189 | 199 | |
190 | 200 | foreach ( $wp->postmeta as $meta ) { |
@@ -275,8 +285,9 @@ discard block |
||
275 | 285 | } |
276 | 286 | xml_parser_free( $xml ); |
277 | 287 | |
278 | - if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) |
|
279 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
288 | + if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) ) { |
|
289 | + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
290 | + } |
|
280 | 291 | |
281 | 292 | return array( |
282 | 293 | 'authors' => $this->authors, |
@@ -308,7 +319,10 @@ discard block |
||
308 | 319 | } |
309 | 320 | break; |
310 | 321 | case 'item': $this->in_post = true; |
311 | - case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break; |
|
322 | + case 'title': if ( $this->in_post ) { |
|
323 | + $this->in_tag = 'post_title'; |
|
324 | + } |
|
325 | + break; |
|
312 | 326 | case 'guid': $this->in_tag = 'guid'; break; |
313 | 327 | case 'dc:creator': $this->in_tag = 'post_author'; break; |
314 | 328 | case 'content:encoded': $this->in_tag = 'post_content'; break; |
@@ -321,8 +335,9 @@ discard block |
||
321 | 335 | } |
322 | 336 | |
323 | 337 | function cdata( $parser, $cdata ) { |
324 | - if ( ! trim( $cdata ) ) |
|
325 | - return; |
|
338 | + if ( ! trim( $cdata ) ) { |
|
339 | + return; |
|
340 | + } |
|
326 | 341 | |
327 | 342 | $this->cdata .= trim( $cdata ); |
328 | 343 | } |
@@ -331,8 +346,9 @@ discard block |
||
331 | 346 | switch ( $tag ) { |
332 | 347 | case 'wp:comment': |
333 | 348 | unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data |
334 | - if ( ! empty( $this->sub_data ) ) |
|
335 | - $this->data['comments'][] = $this->sub_data; |
|
349 | + if ( ! empty( $this->sub_data ) ) { |
|
350 | + $this->data['comments'][] = $this->sub_data; |
|
351 | + } |
|
336 | 352 | $this->sub_data = false; |
337 | 353 | break; |
338 | 354 | case 'wp:commentmeta': |
@@ -349,8 +365,9 @@ discard block |
||
349 | 365 | $this->sub_data = false; |
350 | 366 | break; |
351 | 367 | case 'wp:postmeta': |
352 | - if ( ! empty( $this->sub_data ) ) |
|
353 | - $this->data['postmeta'][] = $this->sub_data; |
|
368 | + if ( ! empty( $this->sub_data ) ) { |
|
369 | + $this->data['postmeta'][] = $this->sub_data; |
|
370 | + } |
|
354 | 371 | $this->sub_data = false; |
355 | 372 | break; |
356 | 373 | case 'item': |
@@ -365,8 +382,9 @@ discard block |
||
365 | 382 | $this->data = false; |
366 | 383 | break; |
367 | 384 | case 'wp:author': |
368 | - if ( ! empty($this->data['author_login']) ) |
|
369 | - $this->authors[$this->data['author_login']] = $this->data; |
|
385 | + if ( ! empty($this->data['author_login']) ) { |
|
386 | + $this->authors[$this->data['author_login']] = $this->data; |
|
387 | + } |
|
370 | 388 | $this->data = false; |
371 | 389 | break; |
372 | 390 | case 'wp:base_site_url': |
@@ -418,8 +436,9 @@ discard block |
||
418 | 436 | while ( ! $this->feof( $fp ) ) { |
419 | 437 | $importline = rtrim( $this->fgets( $fp ) ); |
420 | 438 | |
421 | - if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) ) |
|
422 | - $wxr_version = $version[1]; |
|
439 | + if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) ) { |
|
440 | + $wxr_version = $version[1]; |
|
441 | + } |
|
423 | 442 | |
424 | 443 | if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) { |
425 | 444 | preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url ); |
@@ -465,8 +484,9 @@ discard block |
||
465 | 484 | $this->fclose($fp); |
466 | 485 | } |
467 | 486 | |
468 | - if ( ! $wxr_version ) |
|
469 | - return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
487 | + if ( ! $wxr_version ) { |
|
488 | + return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) ); |
|
489 | + } |
|
470 | 490 | |
471 | 491 | return array( |
472 | 492 | 'authors' => $this->authors, |
@@ -486,8 +506,9 @@ discard block |
||
486 | 506 | if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) { |
487 | 507 | preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches ); |
488 | 508 | $return = ''; |
489 | - foreach( $matches[1] as $match ) |
|
490 | - $return .= $match; |
|
509 | + foreach( $matches[1] as $match ) { |
|
510 | + $return .= $match; |
|
511 | + } |
|
491 | 512 | } else { |
492 | 513 | $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] ); |
493 | 514 | } |
@@ -574,8 +595,9 @@ discard block |
||
574 | 595 | ); |
575 | 596 | |
576 | 597 | $attachment_url = $this->get_tag( $post, 'wp:attachment_url' ); |
577 | - if ( $attachment_url ) |
|
578 | - $postdata['attachment_url'] = $attachment_url; |
|
598 | + if ( $attachment_url ) { |
|
599 | + $postdata['attachment_url'] = $attachment_url; |
|
600 | + } |
|
579 | 601 | |
580 | 602 | preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER ); |
581 | 603 | foreach ( $terms as $t ) { |
@@ -585,7 +607,9 @@ discard block |
||
585 | 607 | 'name' => str_replace( array( '<![CDATA[', ']]>' ), '', $t[3] ), |
586 | 608 | ); |
587 | 609 | } |
588 | - if ( ! empty( $post_terms ) ) $postdata['terms'] = $post_terms; |
|
610 | + if ( ! empty( $post_terms ) ) { |
|
611 | + $postdata['terms'] = $post_terms; |
|
612 | + } |
|
589 | 613 | |
590 | 614 | preg_match_all( '|<wp:comment>(.+?)</wp:comment>|is', $post, $comments ); |
591 | 615 | $comments = $comments[1]; |
@@ -618,7 +642,9 @@ discard block |
||
618 | 642 | ); |
619 | 643 | } |
620 | 644 | } |
621 | - if ( ! empty( $post_comments ) ) $postdata['comments'] = $post_comments; |
|
645 | + if ( ! empty( $post_comments ) ) { |
|
646 | + $postdata['comments'] = $post_comments; |
|
647 | + } |
|
622 | 648 | |
623 | 649 | preg_match_all( '|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta ); |
624 | 650 | $postmeta = $postmeta[1]; |
@@ -630,7 +656,9 @@ discard block |
||
630 | 656 | ); |
631 | 657 | } |
632 | 658 | } |
633 | - if ( ! empty( $post_postmeta ) ) $postdata['postmeta'] = $post_postmeta; |
|
659 | + if ( ! empty( $post_postmeta ) ) { |
|
660 | + $postdata['postmeta'] = $post_postmeta; |
|
661 | + } |
|
634 | 662 | |
635 | 663 | return $postdata; |
636 | 664 | } |
@@ -640,26 +668,30 @@ discard block |
||
640 | 668 | } |
641 | 669 | |
642 | 670 | function fopen( $filename, $mode = 'r' ) { |
643 | - if ( $this->has_gzip ) |
|
644 | - return gzopen( $filename, $mode ); |
|
671 | + if ( $this->has_gzip ) { |
|
672 | + return gzopen( $filename, $mode ); |
|
673 | + } |
|
645 | 674 | return fopen( $filename, $mode ); |
646 | 675 | } |
647 | 676 | |
648 | 677 | function feof( $fp ) { |
649 | - if ( $this->has_gzip ) |
|
650 | - return gzeof( $fp ); |
|
678 | + if ( $this->has_gzip ) { |
|
679 | + return gzeof( $fp ); |
|
680 | + } |
|
651 | 681 | return feof( $fp ); |
652 | 682 | } |
653 | 683 | |
654 | 684 | function fgets( $fp, $len = 8192 ) { |
655 | - if ( $this->has_gzip ) |
|
656 | - return gzgets( $fp, $len ); |
|
685 | + if ( $this->has_gzip ) { |
|
686 | + return gzgets( $fp, $len ); |
|
687 | + } |
|
657 | 688 | return fgets( $fp, $len ); |
658 | 689 | } |
659 | 690 | |
660 | 691 | function fclose( $fp ) { |
661 | - if ( $this->has_gzip ) |
|
662 | - return gzclose( $fp ); |
|
692 | + if ( $this->has_gzip ) { |
|
693 | + return gzclose( $fp ); |
|
694 | + } |
|
663 | 695 | return fclose( $fp ); |
664 | 696 | } |
665 | 697 | } |
@@ -169,7 +169,6 @@ |
||
169 | 169 | * |
170 | 170 | * @since 1.15.2 |
171 | 171 | * |
172 | - * @param array $handles Array of meta keys to check for existence of shortcodes |
|
173 | 172 | * @param int $post_id The ID being checked by GravityView |
174 | 173 | * |
175 | 174 | * @return array Meta key array, merged with existing meta keys |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | * @return void |
90 | 90 | */ |
91 | 91 | private function maybe_add_hooks() { |
92 | - $class_exists = ! $this->class_name || ( $this->class_name && class_exists( $this->class_name ) ); |
|
93 | - $function_exists = ! $this->function_name || ( $this->function_name && function_exists( $this->function_name ) ); |
|
94 | - $constant_defined = ! $this->constant_name || ( $this->constant_name && defined( $this->constant_name ) ); |
|
92 | + $class_exists = !$this->class_name || ($this->class_name && class_exists($this->class_name)); |
|
93 | + $function_exists = !$this->function_name || ($this->function_name && function_exists($this->function_name)); |
|
94 | + $constant_defined = !$this->constant_name || ($this->constant_name && defined($this->constant_name)); |
|
95 | 95 | |
96 | - if( $class_exists || $function_exists || $constant_defined ) { |
|
96 | + if ($class_exists || $function_exists || $constant_defined) { |
|
97 | 97 | $this->add_hooks(); |
98 | 98 | } |
99 | 99 | } |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | * @return void |
105 | 105 | */ |
106 | 106 | protected function add_hooks() { |
107 | - if( $this->content_meta_keys ) { |
|
108 | - add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 ); |
|
107 | + if ($this->content_meta_keys) { |
|
108 | + add_filter('gravityview/data/parse/meta_keys', array($this, 'merge_content_meta_keys'), 10, 2); |
|
109 | 109 | } |
110 | 110 | |
111 | - if( $this->script_handles ) { |
|
112 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) ); |
|
111 | + if ($this->script_handles) { |
|
112 | + add_filter('gravityview_noconflict_scripts', array($this, 'merge_noconflict_scripts')); |
|
113 | 113 | } |
114 | 114 | |
115 | - if( $this->style_handles ) { |
|
116 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) ); |
|
115 | + if ($this->style_handles) { |
|
116 | + add_filter('gravityview_noconflict_styles', array($this, 'merge_noconflict_styles')); |
|
117 | 117 | } |
118 | 118 | |
119 | - if( $this->post_type_support ) { |
|
120 | - add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 ); |
|
119 | + if ($this->post_type_support) { |
|
120 | + add_filter('gravityview_post_type_support', array($this, 'merge_post_type_support'), 10, 2); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return array Array of features associated with a functional area of the edit screen, merged with existing values |
133 | 133 | */ |
134 | - public function merge_post_type_support( $supports = array(), $is_hierarchical = false ) { |
|
135 | - $supports = array_merge( $this->post_type_support, $supports ); |
|
134 | + public function merge_post_type_support($supports = array(), $is_hierarchical = false) { |
|
135 | + $supports = array_merge($this->post_type_support, $supports); |
|
136 | 136 | return $supports; |
137 | 137 | } |
138 | 138 | |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return array Handles, merged with existing styles |
147 | 147 | */ |
148 | - public function merge_noconflict_styles( $handles ) { |
|
149 | - $handles = array_merge( $this->style_handles, $handles ); |
|
148 | + public function merge_noconflict_styles($handles) { |
|
149 | + $handles = array_merge($this->style_handles, $handles); |
|
150 | 150 | return $handles; |
151 | 151 | } |
152 | 152 | |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return array Handles, merged with existing scripts |
161 | 161 | */ |
162 | - public function merge_noconflict_scripts( $handles ) { |
|
163 | - $handles = array_merge( $this->script_handles, $handles ); |
|
162 | + public function merge_noconflict_scripts($handles) { |
|
163 | + $handles = array_merge($this->script_handles, $handles); |
|
164 | 164 | return $handles; |
165 | 165 | } |
166 | 166 | |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return array Meta key array, merged with existing meta keys |
176 | 176 | */ |
177 | - public function merge_content_meta_keys( $meta_keys = array(), $post_id = 0 ) { |
|
178 | - return array_merge( $this->content_meta_keys, $meta_keys ); |
|
177 | + public function merge_content_meta_keys($meta_keys = array(), $post_id = 0) { |
|
178 | + return array_merge($this->content_meta_keys, $meta_keys); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
182 | 182 | \ No newline at end of file |
@@ -51,6 +51,9 @@ |
||
51 | 51 | // hold widget View options |
52 | 52 | private $widget_options; |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $widget_id |
|
56 | + */ |
|
54 | 57 | function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
55 | 58 | |
56 | 59 |
@@ -116,12 +116,12 @@ |
||
116 | 116 | return $settings; |
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function get_widget_id() { |
|
123 | - return $this->widget_id; |
|
124 | - } |
|
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function get_widget_id() { |
|
123 | + return $this->widget_id; |
|
124 | + } |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Get the widget settings |
@@ -51,37 +51,37 @@ discard block |
||
51 | 51 | // hold widget View options |
52 | 52 | private $widget_options; |
53 | 53 | |
54 | - function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) { |
|
54 | + function __construct($widget_label, $widget_id, $defaults = array(), $settings = array()) { |
|
55 | 55 | |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name |
59 | 59 | * @var string |
60 | 60 | */ |
61 | - $this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name; |
|
61 | + $this->shortcode_name = !isset($this->shortcode_name) ? strtolower(get_class($this)) : $this->shortcode_name; |
|
62 | 62 | |
63 | 63 | $this->widget_label = $widget_label; |
64 | 64 | $this->widget_id = $widget_id; |
65 | - $this->defaults = array_merge( array( 'header' => 0, 'footer' => 0 ), $defaults ); |
|
65 | + $this->defaults = array_merge(array('header' => 0, 'footer' => 0), $defaults); |
|
66 | 66 | |
67 | 67 | // Make sure every widget has a title, even if empty |
68 | 68 | $this->settings = $this->get_default_settings(); |
69 | - $this->settings = wp_parse_args( $settings, $this->settings ); |
|
69 | + $this->settings = wp_parse_args($settings, $this->settings); |
|
70 | 70 | |
71 | 71 | // register widgets to be listed in the View Configuration |
72 | - add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') ); |
|
72 | + add_filter('gravityview_register_directory_widgets', array($this, 'register_widget')); |
|
73 | 73 | |
74 | 74 | // widget options |
75 | - add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 ); |
|
75 | + add_filter('gravityview_template_widget_options', array($this, 'assign_widget_options'), 10, 3); |
|
76 | 76 | |
77 | 77 | // frontend logic |
78 | - add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 ); |
|
78 | + add_action("gravityview_render_widget_{$widget_id}", array($this, 'render_frontend'), 10, 1); |
|
79 | 79 | |
80 | 80 | // register shortcodes |
81 | - add_action( 'wp', array( $this, 'add_shortcode') ); |
|
81 | + add_action('wp', array($this, 'add_shortcode')); |
|
82 | 82 | |
83 | 83 | // Use shortcodes in text widgets. |
84 | - add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) ); |
|
84 | + add_filter('widget_text', array($this, 'maybe_do_shortcode')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | * @param boolean $enable_custom_class False by default. Return true if you want to enable. |
100 | 100 | * @param GravityView_Widget $this Current instance of GravityView_Widget |
101 | 101 | */ |
102 | - $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this ); |
|
102 | + $enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this); |
|
103 | 103 | |
104 | - if( $enable_custom_class ) { |
|
104 | + if ($enable_custom_class) { |
|
105 | 105 | |
106 | 106 | $settings['custom_class'] = array( |
107 | 107 | 'type' => 'text', |
108 | - 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
|
109 | - 'desc' => __( 'This class will be added to the widget container', 'gravityview'), |
|
108 | + 'label' => __('Custom CSS Class:', 'gravityview'), |
|
109 | + 'desc' => __('This class will be added to the widget container', 'gravityview'), |
|
110 | 110 | 'value' => '', |
111 | 111 | 'merge_tags' => true, |
112 | 112 | ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array|null Settings array; NULL if not set |
129 | 129 | */ |
130 | 130 | public function get_settings() { |
131 | - return !empty( $this->settings ) ? $this->settings : NULL; |
|
131 | + return !empty($this->settings) ? $this->settings : NULL; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @param string $key Key for the setting |
137 | 137 | * @return mixed|null Value of the setting; NULL if not set |
138 | 138 | */ |
139 | - public function get_setting( $key ) { |
|
139 | + public function get_setting($key) { |
|
140 | 140 | $setting = NULL; |
141 | 141 | |
142 | - if( isset( $this->settings ) && is_array( $this->settings ) ) { |
|
143 | - $setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL; |
|
142 | + if (isset($this->settings) && is_array($this->settings)) { |
|
143 | + $setting = isset($this->settings[$key]) ? $this->settings[$key] : NULL; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return $setting; |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * @param null|WP_Widget Empty if not called by WP_Widget, or a WP_Widget instance |
153 | 153 | * @return string Widget text |
154 | 154 | */ |
155 | - function maybe_do_shortcode( $text, $widget = NULL ) { |
|
155 | + function maybe_do_shortcode($text, $widget = NULL) { |
|
156 | 156 | |
157 | - if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) { |
|
158 | - return do_shortcode( $text ); |
|
157 | + if (!empty($this->shortcode_name) && has_shortcode($text, $this->shortcode_name)) { |
|
158 | + return do_shortcode($text); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $text; |
162 | 162 | } |
163 | 163 | |
164 | - function render_shortcode( $atts, $content = '', $context = '' ) { |
|
164 | + function render_shortcode($atts, $content = '', $context = '') { |
|
165 | 165 | |
166 | 166 | ob_start(); |
167 | 167 | |
168 | - $this->render_frontend( $atts, $content, $context ); |
|
168 | + $this->render_frontend($atts, $content, $context); |
|
169 | 169 | |
170 | 170 | return ob_get_clean(); |
171 | 171 | } |
@@ -173,31 +173,31 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Add $this->shortcode_name shortcode to output self::render_frontend() |
175 | 175 | */ |
176 | - function add_shortcode( $run_on_singular = true ) { |
|
176 | + function add_shortcode($run_on_singular = true) { |
|
177 | 177 | global $post; |
178 | 178 | |
179 | - if( GravityView_Plugin::is_admin() ) { return; } |
|
179 | + if (GravityView_Plugin::is_admin()) { return; } |
|
180 | 180 | |
181 | - if( empty( $this->shortcode_name ) ) { return; } |
|
181 | + if (empty($this->shortcode_name)) { return; } |
|
182 | 182 | |
183 | 183 | // If the widget shouldn't output on single entries, don't show it |
184 | - if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) { |
|
185 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) ); |
|
184 | + if (empty($this->show_on_single) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry()) { |
|
185 | + do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this))); |
|
186 | 186 | |
187 | - add_shortcode( $this->shortcode_name, '__return_null' ); |
|
187 | + add_shortcode($this->shortcode_name, '__return_null'); |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | 191 | |
192 | - if( !has_gravityview_shortcode( $post ) ) { |
|
192 | + if (!has_gravityview_shortcode($post)) { |
|
193 | 193 | |
194 | - do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) ); |
|
194 | + do_action('gravityview_log_debug', sprintf('%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this))); |
|
195 | 195 | |
196 | - add_shortcode( $this->shortcode_name, '__return_null' ); |
|
196 | + add_shortcode($this->shortcode_name, '__return_null'); |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | - add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') ); |
|
200 | + add_shortcode($this->shortcode_name, array($this, 'render_shortcode')); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * @param array $widgets |
206 | 206 | * @return array $widgets |
207 | 207 | */ |
208 | - function register_widget( $widgets ) { |
|
209 | - $widgets[ $this->widget_id ] = array( |
|
210 | - 'label' => $this->widget_label , |
|
208 | + function register_widget($widgets) { |
|
209 | + $widgets[$this->widget_id] = array( |
|
210 | + 'label' => $this->widget_label, |
|
211 | 211 | 'description' => $this->widget_description, |
212 | 212 | 'subtitle' => $this->widget_subtitle, |
213 | 213 | ); |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | * @param string $template (default: '') |
223 | 223 | * @return array |
224 | 224 | */ |
225 | - public function assign_widget_options( $options = array(), $template = '', $widget = '' ) { |
|
225 | + public function assign_widget_options($options = array(), $template = '', $widget = '') { |
|
226 | 226 | |
227 | - if( $this->widget_id === $widget ) { |
|
228 | - $options = array_merge( $options, $this->settings ); |
|
227 | + if ($this->widget_id === $widget) { |
|
228 | + $options = array_merge($options, $this->settings); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | return $options; |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
240 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
241 | 241 | // to be defined by child class |
242 | - if( !$this->pre_render_frontend() ) { |
|
242 | + if (!$this->pre_render_frontend()) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | public function pre_render_frontend() { |
252 | 252 | $gravityview_view = GravityView_View::getInstance(); |
253 | 253 | |
254 | - if( empty( $gravityview_view ) ) { |
|
255 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) ); |
|
254 | + if (empty($gravityview_view)) { |
|
255 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
256 | 256 | return false; |
257 | 257 | } |
258 | 258 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * @param boolean $hide_until_searched Hide until search? |
262 | 262 | * @param GravityView_Widget $this Widget instance |
263 | 263 | */ |
264 | - $hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this ); |
|
264 | + $hide_until_search = apply_filters('gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this); |
|
265 | 265 | |
266 | - if( $hide_until_search ) { |
|
267 | - do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) ); |
|
266 | + if ($hide_until_search) { |
|
267 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: Hide View data until search is performed', get_class($this))); |
|
268 | 268 | return false; |
269 | 269 | } |
270 | 270 |
@@ -993,7 +993,7 @@ |
||
993 | 993 | /** |
994 | 994 | * Modify the array passed to wp_localize_script() |
995 | 995 | * |
996 | - * @param array $js_localization The data padded to the Javascript file |
|
996 | + * @param array $localizations The data padded to the Javascript file |
|
997 | 997 | * @param array $view_data View data array with View settings |
998 | 998 | * |
999 | 999 | * @return array |
@@ -384,16 +384,16 @@ |
||
384 | 384 | $curr_start = esc_attr( rgget( 'gv_start' ) ); |
385 | 385 | $curr_end = esc_attr( rgget( 'gv_end' ) ); |
386 | 386 | |
387 | - /** |
|
388 | - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
389 | - * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
390 | - * @since 1.12 |
|
391 | - * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
392 | - * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
393 | - */ |
|
394 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
395 | - $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
396 | - $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
387 | + /** |
|
388 | + * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
|
389 | + * date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php) |
|
390 | + * @since 1.12 |
|
391 | + * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
|
392 | + * @param[in] string $context Where the filter is being called from. `search` in this case. |
|
393 | + */ |
|
394 | + $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
395 | + $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
396 | + $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
397 | 397 | |
398 | 398 | |
399 | 399 | // search for a specific entry ID |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @copyright Copyright 2014, Katz Web Services, Inc. |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'WPINC' ) ) { |
|
12 | +if (!defined('WPINC')) { |
|
13 | 13 | die; |
14 | 14 | } |
15 | 15 | |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() { |
24 | 24 | |
25 | - $this->widget_description = esc_html__( 'Search form for searching entries.', 'gravityview' ); |
|
25 | + $this->widget_description = esc_html__('Search form for searching entries.', 'gravityview'); |
|
26 | 26 | |
27 | 27 | self::$instance = &$this; |
28 | 28 | |
29 | - self::$file = plugin_dir_path( __FILE__ ); |
|
29 | + self::$file = plugin_dir_path(__FILE__); |
|
30 | 30 | |
31 | - $default_values = array( 'header' => 0, 'footer' => 0 ); |
|
31 | + $default_values = array('header' => 0, 'footer' => 0); |
|
32 | 32 | |
33 | 33 | $settings = array( |
34 | 34 | 'search_layout' => array( |
35 | 35 | 'type' => 'radio', |
36 | 36 | 'full_width' => true, |
37 | - 'label' => esc_html__( 'Search Layout', 'gravityview' ), |
|
37 | + 'label' => esc_html__('Search Layout', 'gravityview'), |
|
38 | 38 | 'value' => 'horizontal', |
39 | 39 | 'options' => array( |
40 | - 'horizontal' => esc_html__( 'Horizontal', 'gravityview' ), |
|
41 | - 'vertical' => esc_html__( 'Vertical', 'gravityview' ), |
|
40 | + 'horizontal' => esc_html__('Horizontal', 'gravityview'), |
|
41 | + 'vertical' => esc_html__('Vertical', 'gravityview'), |
|
42 | 42 | ), |
43 | 43 | ), |
44 | 44 | 'search_clear' => array( |
45 | 45 | 'type' => 'checkbox', |
46 | - 'label' => __( 'Show Clear button', 'gravityview' ), |
|
46 | + 'label' => __('Show Clear button', 'gravityview'), |
|
47 | 47 | 'value' => false, |
48 | 48 | ), |
49 | 49 | 'search_fields' => array( |
@@ -55,33 +55,33 @@ discard block |
||
55 | 55 | 'search_mode' => array( |
56 | 56 | 'type' => 'radio', |
57 | 57 | 'full_width' => true, |
58 | - 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
|
58 | + 'label' => esc_html__('Search Mode', 'gravityview'), |
|
59 | 59 | 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
60 | 60 | 'value' => 'any', |
61 | 61 | 'class' => 'hide-if-js', |
62 | 62 | 'options' => array( |
63 | - 'any' => esc_html__( 'Match Any Fields', 'gravityview' ), |
|
64 | - 'all' => esc_html__( 'Match All Fields', 'gravityview' ), |
|
63 | + 'any' => esc_html__('Match Any Fields', 'gravityview'), |
|
64 | + 'all' => esc_html__('Match All Fields', 'gravityview'), |
|
65 | 65 | ), |
66 | 66 | ), |
67 | 67 | ); |
68 | - parent::__construct( esc_html__( 'Search Bar', 'gravityview' ), 'search_bar', $default_values, $settings ); |
|
68 | + parent::__construct(esc_html__('Search Bar', 'gravityview'), 'search_bar', $default_values, $settings); |
|
69 | 69 | |
70 | 70 | // frontend - filter entries |
71 | - add_filter( 'gravityview_fe_search_criteria', array( $this, 'filter_entries' ), 10, 1 ); |
|
71 | + add_filter('gravityview_fe_search_criteria', array($this, 'filter_entries'), 10, 1); |
|
72 | 72 | |
73 | 73 | // frontend - add template path |
74 | - add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
|
74 | + add_filter('gravityview_template_paths', array($this, 'add_template_path')); |
|
75 | 75 | |
76 | 76 | // Add hidden fields for "Default" permalink structure |
77 | - add_filter( 'gravityview_widget_search_filters', array( $this, 'add_no_permalink_fields' ), 10, 3 ); |
|
77 | + add_filter('gravityview_widget_search_filters', array($this, 'add_no_permalink_fields'), 10, 3); |
|
78 | 78 | |
79 | 79 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
80 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
|
81 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
80 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_and_styles'), 1100); |
|
81 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
82 | 82 | |
83 | 83 | // ajax - get the searchable fields |
84 | - add_action( 'wp_ajax_gv_searchable_fields', array( 'GravityView_Widget_Search', 'get_searchable_fields' ) ); |
|
84 | + add_action('wp_ajax_gv_searchable_fields', array('GravityView_Widget_Search', 'get_searchable_fields')); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return GravityView_Widget_Search |
90 | 90 | */ |
91 | 91 | public static function getInstance() { |
92 | - if ( empty( self::$instance ) ) { |
|
92 | + if (empty(self::$instance)) { |
|
93 | 93 | self::$instance = new GravityView_Widget_Search; |
94 | 94 | } |
95 | 95 | return self::$instance; |
@@ -100,18 +100,18 @@ discard block |
||
100 | 100 | * Add script to Views edit screen (admin) |
101 | 101 | * @param mixed $hook |
102 | 102 | */ |
103 | - public function add_scripts_and_styles( $hook ) { |
|
103 | + public function add_scripts_and_styles($hook) { |
|
104 | 104 | global $pagenow; |
105 | 105 | |
106 | 106 | // Don't process any scripts below here if it's not a GravityView page or the widgets screen |
107 | - if ( ! gravityview_is_admin_page( $hook ) && ( 'widgets.php' !== $pagenow ) ) { |
|
107 | + if (!gravityview_is_admin_page($hook) && ('widgets.php' !== $pagenow)) { |
|
108 | 108 | return; |
109 | 109 | } |
110 | 110 | |
111 | - $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
112 | - $script_source = empty( $script_min ) ? '/source' : ''; |
|
111 | + $script_min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
112 | + $script_source = empty($script_min) ? '/source' : ''; |
|
113 | 113 | |
114 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version ); |
|
114 | + wp_enqueue_script('gravityview_searchwidget_admin', plugins_url('assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__), array('jquery', 'gravityview_views_scripts'), GravityView_Plugin::version); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | * @var array |
121 | 121 | */ |
122 | 122 | $input_labels = array( |
123 | - 'input_text' => esc_html__( 'Text', 'gravityview' ), |
|
124 | - 'date' => esc_html__( 'Date', 'gravityview' ), |
|
125 | - 'select' => esc_html__( 'Select', 'gravityview' ), |
|
126 | - 'multiselect' => esc_html__( 'Select (multiple values)', 'gravityview' ), |
|
127 | - 'radio' => esc_html__( 'Radio', 'gravityview' ), |
|
128 | - 'checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
129 | - 'single_checkbox' => esc_html__( 'Checkbox', 'gravityview' ), |
|
130 | - 'link' => esc_html__( 'Links', 'gravityview' ), |
|
131 | - 'date_range' => esc_html__( 'Date range', 'gravityview' ), |
|
123 | + 'input_text' => esc_html__('Text', 'gravityview'), |
|
124 | + 'date' => esc_html__('Date', 'gravityview'), |
|
125 | + 'select' => esc_html__('Select', 'gravityview'), |
|
126 | + 'multiselect' => esc_html__('Select (multiple values)', 'gravityview'), |
|
127 | + 'radio' => esc_html__('Radio', 'gravityview'), |
|
128 | + 'checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
129 | + 'single_checkbox' => esc_html__('Checkbox', 'gravityview'), |
|
130 | + 'link' => esc_html__('Links', 'gravityview'), |
|
131 | + 'date_range' => esc_html__('Date range', 'gravityview'), |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | /** |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | * @var array |
138 | 138 | */ |
139 | 139 | $input_types = array( |
140 | - 'text' => array( 'input_text' ), |
|
141 | - 'address' => array( 'input_text' ), |
|
142 | - 'date' => array( 'date', 'date_range' ), |
|
143 | - 'boolean' => array( 'single_checkbox' ), |
|
144 | - 'select' => array( 'select', 'radio', 'link' ), |
|
145 | - 'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ), |
|
140 | + 'text' => array('input_text'), |
|
141 | + 'address' => array('input_text'), |
|
142 | + 'date' => array('date', 'date_range'), |
|
143 | + 'boolean' => array('single_checkbox'), |
|
144 | + 'select' => array('select', 'radio', 'link'), |
|
145 | + 'multi' => array('select', 'multiselect', 'radio', 'checkbox', 'link'), |
|
146 | 146 | ); |
147 | 147 | |
148 | - wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
149 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
|
150 | - 'label_nofields' => esc_html__( 'No search fields configured yet.', 'gravityview' ), |
|
151 | - 'label_addfield' => esc_html__( 'Add Search Field', 'gravityview' ), |
|
152 | - 'label_label' => esc_html__( 'Label', 'gravityview' ), |
|
153 | - 'label_searchfield' => esc_html__( 'Search Field', 'gravityview' ), |
|
154 | - 'label_inputtype' => esc_html__( 'Input Type', 'gravityview' ), |
|
155 | - 'label_ajaxerror' => esc_html__( 'There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview' ), |
|
156 | - 'input_labels' => json_encode( $input_labels ), |
|
157 | - 'input_types' => json_encode( $input_types ), |
|
158 | - ) ); |
|
148 | + wp_localize_script('gravityview_searchwidget_admin', 'gvSearchVar', array( |
|
149 | + 'nonce' => wp_create_nonce('gravityview_ajaxsearchwidget'), |
|
150 | + 'label_nofields' => esc_html__('No search fields configured yet.', 'gravityview'), |
|
151 | + 'label_addfield' => esc_html__('Add Search Field', 'gravityview'), |
|
152 | + 'label_label' => esc_html__('Label', 'gravityview'), |
|
153 | + 'label_searchfield' => esc_html__('Search Field', 'gravityview'), |
|
154 | + 'label_inputtype' => esc_html__('Input Type', 'gravityview'), |
|
155 | + 'label_ajaxerror' => esc_html__('There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gravityview'), |
|
156 | + 'input_labels' => json_encode($input_labels), |
|
157 | + 'input_types' => json_encode($input_types), |
|
158 | + )); |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Add admin script to the whitelist |
164 | 164 | */ |
165 | - public function register_no_conflict( $required ) { |
|
165 | + public function register_no_conflict($required) { |
|
166 | 166 | $required[] = 'gravityview_searchwidget_admin'; |
167 | 167 | return $required; |
168 | 168 | } |
@@ -176,31 +176,31 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function get_searchable_fields() { |
178 | 178 | |
179 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
180 | - exit( '0' ); |
|
179 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxsearchwidget')) { |
|
180 | + exit('0'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $form = ''; |
184 | 184 | |
185 | 185 | // Fetch the form for the current View |
186 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
186 | + if (!empty($_POST['view_id'])) { |
|
187 | 187 | |
188 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
188 | + $form = gravityview_get_form_id($_POST['view_id']); |
|
189 | 189 | |
190 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
190 | + } elseif (!empty($_POST['formid'])) { |
|
191 | 191 | |
192 | - $form = (int) $_POST['formid']; |
|
192 | + $form = (int)$_POST['formid']; |
|
193 | 193 | |
194 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
194 | + } elseif (!empty($_POST['template_id']) && class_exists('GravityView_Ajax')) { |
|
195 | 195 | |
196 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
196 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | 200 | // fetch form id assigned to the view |
201 | - $response = self::render_searchable_fields( $form ); |
|
201 | + $response = self::render_searchable_fields($form); |
|
202 | 202 | |
203 | - exit( $response ); |
|
203 | + exit($response); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | * @param string $current (for future use) |
210 | 210 | * @return string |
211 | 211 | */ |
212 | - public static function render_searchable_fields( $form_id = null, $current = '' ) { |
|
212 | + public static function render_searchable_fields($form_id = null, $current = '') { |
|
213 | 213 | |
214 | - if ( is_null( $form_id ) ) { |
|
214 | + if (is_null($form_id)) { |
|
215 | 215 | return ''; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Get fields with sub-inputs and no parent |
219 | - $fields = gravityview_get_form_fields( $form_id, true, true ); |
|
219 | + $fields = gravityview_get_form_fields($form_id, true, true); |
|
220 | 220 | |
221 | 221 | // start building output |
222 | 222 | |
@@ -224,40 +224,40 @@ discard block |
||
224 | 224 | |
225 | 225 | $custom_fields = array( |
226 | 226 | 'search_all' => array( |
227 | - 'text' => esc_html__( 'Search Everything', 'gravityview' ), |
|
227 | + 'text' => esc_html__('Search Everything', 'gravityview'), |
|
228 | 228 | 'type' => 'text', |
229 | 229 | ), |
230 | 230 | 'entry_date' => array( |
231 | - 'text' => esc_html__( 'Entry Date', 'gravityview' ), |
|
231 | + 'text' => esc_html__('Entry Date', 'gravityview'), |
|
232 | 232 | 'type' => 'date', |
233 | 233 | ), |
234 | 234 | 'entry_id' => array( |
235 | - 'text' => esc_html__( 'Entry ID', 'gravityview' ), |
|
235 | + 'text' => esc_html__('Entry ID', 'gravityview'), |
|
236 | 236 | 'type' => 'text', |
237 | 237 | ), |
238 | 238 | 'created_by' => array( |
239 | - 'text' => esc_html__( 'Entry Creator', 'gravityview' ), |
|
239 | + 'text' => esc_html__('Entry Creator', 'gravityview'), |
|
240 | 240 | 'type' => 'select', |
241 | 241 | ) |
242 | 242 | ); |
243 | 243 | |
244 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
245 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
244 | + foreach ($custom_fields as $custom_field_key => $custom_field) { |
|
245 | + $output .= sprintf('<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected($custom_field_key, $current, false), $custom_field['type'], self::get_field_label(array('field' => $custom_field_key)), $custom_field['text']); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! empty( $fields ) ) { |
|
248 | + if (!empty($fields)) { |
|
249 | 249 | |
250 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'fileupload', 'post_image', 'post_id' ), null ); |
|
250 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('fileupload', 'post_image', 'post_id'), null); |
|
251 | 251 | |
252 | - foreach ( $fields as $id => $field ) { |
|
252 | + foreach ($fields as $id => $field) { |
|
253 | 253 | |
254 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
254 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | |
258 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
258 | + $types = self::get_search_input_types($id, $field['type']); |
|
259 | 259 | |
260 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
260 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'data-inputtypes="'.esc_attr($types).'">'.esc_html($field['label']).'</option>'; |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
@@ -276,21 +276,21 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text') |
278 | 278 | */ |
279 | - public static function get_search_input_types( $id = '', $field_type = null ) { |
|
279 | + public static function get_search_input_types($id = '', $field_type = null) { |
|
280 | 280 | |
281 | 281 | // @todo - This needs to be improved - many fields have . including products and addresses |
282 | - if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) { |
|
282 | + if (false !== strpos((string)$id, '.') && in_array($field_type, array('checkbox')) || in_array($id, array('is_fulfilled'))) { |
|
283 | 283 | // on/off checkbox |
284 | 284 | $input_type = 'boolean'; |
285 | - } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
|
285 | + } elseif (in_array($field_type, array('checkbox', 'post_category', 'multiselect'))) { |
|
286 | 286 | //multiselect |
287 | 287 | $input_type = 'multi'; |
288 | 288 | |
289 | - } elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) { |
|
289 | + } elseif (in_array($field_type, array('select', 'radio'))) { |
|
290 | 290 | //single select |
291 | 291 | $input_type = 'select'; |
292 | 292 | |
293 | - } elseif ( in_array( $field_type, array( 'date' ) ) || in_array( $id, array( 'payment_date' ) ) ) { |
|
293 | + } elseif (in_array($field_type, array('date')) || in_array($id, array('payment_date'))) { |
|
294 | 294 | // date |
295 | 295 | $input_type = 'date'; |
296 | 296 | } else { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param string $field_type Gravity Forms field type |
305 | 305 | * @since 1.2 |
306 | 306 | */ |
307 | - $input_type = apply_filters( 'gravityview/extension/search/input_type', $input_type, $field_type ); |
|
307 | + $input_type = apply_filters('gravityview/extension/search/input_type', $input_type, $field_type); |
|
308 | 308 | |
309 | 309 | return $input_type; |
310 | 310 | } |
@@ -315,29 +315,29 @@ discard block |
||
315 | 315 | * @since 1.8 |
316 | 316 | * @return array Search fields, modified if not using permalinks |
317 | 317 | */ |
318 | - public function add_no_permalink_fields( $search_fields, $object, $widget_args = array() ) { |
|
318 | + public function add_no_permalink_fields($search_fields, $object, $widget_args = array()) { |
|
319 | 319 | /** @global WP_Rewrite $wp_rewrite */ |
320 | 320 | global $wp_rewrite; |
321 | 321 | |
322 | 322 | // Support default permalink structure |
323 | - if ( false === $wp_rewrite->using_permalinks() ) { |
|
323 | + if (false === $wp_rewrite->using_permalinks()) { |
|
324 | 324 | |
325 | 325 | // By default, use current post. |
326 | 326 | $post_id = 0; |
327 | 327 | |
328 | 328 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
329 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
330 | - $post_id = absint( $widget_args['post_id'] ); |
|
329 | + if (!empty($widget_args['post_id'])) { |
|
330 | + $post_id = absint($widget_args['post_id']); |
|
331 | 331 | } |
332 | 332 | // We're in the WordPress Widget context, and the base View ID should be used |
333 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
334 | - $post_id = absint( $widget_args['view_id'] ); |
|
333 | + else if (!empty($widget_args['view_id'])) { |
|
334 | + $post_id = absint($widget_args['view_id']); |
|
335 | 335 | } |
336 | 336 | |
337 | - $args = gravityview_get_permalink_query_args( $post_id ); |
|
337 | + $args = gravityview_get_permalink_query_args($post_id); |
|
338 | 338 | |
339 | 339 | // Add hidden fields to the search form |
340 | - foreach ( $args as $key => $value ) { |
|
340 | + foreach ($args as $key => $value) { |
|
341 | 341 | $search_fields[] = array( |
342 | 342 | 'name' => $key, |
343 | 343 | 'input' => 'hidden', |
@@ -357,23 +357,23 @@ discard block |
||
357 | 357 | * @param array $search_criteria |
358 | 358 | * @return array |
359 | 359 | */ |
360 | - public function filter_entries( $search_criteria ) { |
|
360 | + public function filter_entries($search_criteria) { |
|
361 | 361 | |
362 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Requested $_GET: ', get_class( $this ) ), $_GET ); |
|
362 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Requested $_GET: ', get_class($this)), $_GET); |
|
363 | 363 | |
364 | - if ( empty( $_GET ) || ! is_array( $_GET ) ) { |
|
364 | + if (empty($_GET) || !is_array($_GET)) { |
|
365 | 365 | return $search_criteria; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // add free search |
369 | - if ( ! empty( $_GET['gv_search'] ) ) { |
|
369 | + if (!empty($_GET['gv_search'])) { |
|
370 | 370 | |
371 | 371 | // Search for a piece |
372 | - $words = explode( ' ', stripslashes_deep( urldecode( $_GET['gv_search'] ) ) ); |
|
372 | + $words = explode(' ', stripslashes_deep(urldecode($_GET['gv_search']))); |
|
373 | 373 | |
374 | - $words = array_filter( $words ); |
|
374 | + $words = array_filter($words); |
|
375 | 375 | |
376 | - foreach ( $words as $word ) { |
|
376 | + foreach ($words as $word) { |
|
377 | 377 | $search_criteria['field_filters'][] = array( |
378 | 378 | 'key' => null, // The field ID to search |
379 | 379 | 'value' => $word, // The value to search |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | } |
384 | 384 | |
385 | 385 | //start date & end date |
386 | - $curr_start = esc_attr( rgget( 'gv_start' ) ); |
|
387 | - $curr_end = esc_attr( rgget( 'gv_end' ) ); |
|
386 | + $curr_start = esc_attr(rgget('gv_start')); |
|
387 | + $curr_end = esc_attr(rgget('gv_end')); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n |
@@ -393,51 +393,51 @@ discard block |
||
393 | 393 | * @param[out,in] boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default: true |
394 | 394 | * @param[in] string $context Where the filter is being called from. `search` in this case. |
395 | 395 | */ |
396 | - $adjust_tz = apply_filters( 'gravityview_date_created_adjust_timezone', true, 'search' ); |
|
397 | - $search_criteria['start_date'] = ( $adjust_tz && !empty( $curr_start ) ) ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
398 | - $search_criteria['end_date'] = ( $adjust_tz && !empty( $curr_end ) ) ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
396 | + $adjust_tz = apply_filters('gravityview_date_created_adjust_timezone', true, 'search'); |
|
397 | + $search_criteria['start_date'] = ($adjust_tz && !empty($curr_start)) ? get_gmt_from_date($curr_start) : $curr_start; |
|
398 | + $search_criteria['end_date'] = ($adjust_tz && !empty($curr_end)) ? get_gmt_from_date($curr_end) : $curr_end; |
|
399 | 399 | |
400 | 400 | |
401 | 401 | // search for a specific entry ID |
402 | - if ( ! empty( $_GET[ 'gv_id' ] ) ) { |
|
402 | + if (!empty($_GET['gv_id'])) { |
|
403 | 403 | $search_criteria['field_filters'][] = array( |
404 | 404 | 'key' => 'id', |
405 | - 'value' => absint( $_GET[ 'gv_id' ] ), |
|
405 | + 'value' => absint($_GET['gv_id']), |
|
406 | 406 | 'operator' => '=', |
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
410 | 410 | // search for a specific Created_by ID |
411 | - if ( ! empty( $_GET[ 'gv_by' ] ) ) { |
|
411 | + if (!empty($_GET['gv_by'])) { |
|
412 | 412 | $search_criteria['field_filters'][] = array( |
413 | 413 | 'key' => 'created_by', |
414 | - 'value' => absint( $_GET['gv_by'] ), |
|
414 | + 'value' => absint($_GET['gv_by']), |
|
415 | 415 | 'operator' => '=', |
416 | 416 | ); |
417 | 417 | } |
418 | 418 | |
419 | 419 | |
420 | 420 | // Get search mode passed in URL |
421 | - $mode = in_array( rgget( 'mode' ), array( 'any', 'all' ) ) ? esc_attr( rgget( 'mode' ) ) : 'any'; |
|
421 | + $mode = in_array(rgget('mode'), array('any', 'all')) ? esc_attr(rgget('mode')) : 'any'; |
|
422 | 422 | |
423 | 423 | // get the other search filters |
424 | - foreach ( $_GET as $key => $value ) { |
|
424 | + foreach ($_GET as $key => $value) { |
|
425 | 425 | |
426 | - if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) { |
|
426 | + if (0 !== strpos($key, 'filter_') || empty($value) || (is_array($value) && count($value) === 1 && empty($value[0]))) { |
|
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // could return simple filter or multiple filters |
431 | - $filter = $this->prepare_field_filter( $key, $value ); |
|
431 | + $filter = $this->prepare_field_filter($key, $value); |
|
432 | 432 | |
433 | - if ( isset( $filter[0]['value'] ) ) { |
|
434 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
433 | + if (isset($filter[0]['value'])) { |
|
434 | + $search_criteria['field_filters'] = array_merge($search_criteria['field_filters'], $filter); |
|
435 | 435 | |
436 | 436 | // if date range type, set search mode to ALL |
437 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) { |
|
437 | + if (!empty($filter[0]['operator']) && in_array($filter[0]['operator'], array('>', '<'))) { |
|
438 | 438 | $mode = 'all'; |
439 | 439 | } |
440 | - } elseif( !empty( $filter ) ) { |
|
440 | + } elseif (!empty($filter)) { |
|
441 | 441 | $search_criteria['field_filters'][] = $filter; |
442 | 442 | } |
443 | 443 | } |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | * @since 1.5.1 |
448 | 448 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
449 | 449 | */ |
450 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
450 | + $search_criteria['field_filters']['mode'] = apply_filters('gravityview/search/mode', $mode); |
|
451 | 451 | |
452 | - do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria ); |
|
452 | + do_action('gravityview_log_debug', sprintf('%s[filter_entries] Returned Search Criteria: ', get_class($this)), $search_criteria); |
|
453 | 453 | |
454 | 454 | return $search_criteria; |
455 | 455 | } |
@@ -464,16 +464,16 @@ discard block |
||
464 | 464 | * @param string $value $_GET search value |
465 | 465 | * @return array 1 or 2 deph levels |
466 | 466 | */ |
467 | - public function prepare_field_filter( $key, $value ) { |
|
467 | + public function prepare_field_filter($key, $value) { |
|
468 | 468 | |
469 | 469 | $gravityview_view = GravityView_View::getInstance(); |
470 | 470 | |
471 | 471 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
472 | - $field_id = str_replace( '_', '.', str_replace( 'filter_', '', $key ) ); |
|
472 | + $field_id = str_replace('_', '.', str_replace('filter_', '', $key)); |
|
473 | 473 | |
474 | 474 | // get form field array |
475 | 475 | $form = $gravityview_view->getForm(); |
476 | - $form_field = gravityview_get_field( $form, $field_id ); |
|
476 | + $form_field = gravityview_get_field($form, $field_id); |
|
477 | 477 | |
478 | 478 | // default filter array |
479 | 479 | $filter = array( |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | 'value' => $value, |
482 | 482 | ); |
483 | 483 | |
484 | - switch ( $form_field['type'] ) { |
|
484 | + switch ($form_field['type']) { |
|
485 | 485 | |
486 | 486 | case 'select': |
487 | 487 | case 'radio': |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | |
491 | 491 | case 'post_category': |
492 | 492 | |
493 | - if ( ! is_array( $value ) ) { |
|
494 | - $value = array( $value ); |
|
493 | + if (!is_array($value)) { |
|
494 | + $value = array($value); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | // Reset filter variable |
498 | 498 | $filter = array(); |
499 | 499 | |
500 | - foreach ( $value as $val ) { |
|
501 | - $cat = get_term( $val, 'category' ); |
|
500 | + foreach ($value as $val) { |
|
501 | + $cat = get_term($val, 'category'); |
|
502 | 502 | $filter[] = array( |
503 | 503 | 'key' => $field_id, |
504 | - 'value' => esc_attr( $cat->name ) . ':' . $val, |
|
504 | + 'value' => esc_attr($cat->name).':'.$val, |
|
505 | 505 | 'operator' => 'is', |
506 | 506 | ); |
507 | 507 | } |
@@ -510,35 +510,35 @@ discard block |
||
510 | 510 | |
511 | 511 | case 'multiselect': |
512 | 512 | |
513 | - if ( ! is_array( $value ) ) { |
|
513 | + if (!is_array($value)) { |
|
514 | 514 | break; |
515 | 515 | } |
516 | 516 | |
517 | 517 | // Reset filter variable |
518 | 518 | $filter = array(); |
519 | 519 | |
520 | - foreach ( $value as $val ) { |
|
521 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
520 | + foreach ($value as $val) { |
|
521 | + $filter[] = array('key' => $field_id, 'value' => $val); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'checkbox': |
527 | 527 | // convert checkbox on/off into the correct search filter |
528 | - if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) { |
|
529 | - foreach ( $form_field['inputs'] as $k => $input ) { |
|
530 | - if ( $input['id'] == $field_id ) { |
|
531 | - $filter['value'] = $form_field['choices'][ $k ]['value']; |
|
528 | + if (false !== strpos($field_id, '.') && !empty($form_field['inputs']) && !empty($form_field['choices'])) { |
|
529 | + foreach ($form_field['inputs'] as $k => $input) { |
|
530 | + if ($input['id'] == $field_id) { |
|
531 | + $filter['value'] = $form_field['choices'][$k]['value']; |
|
532 | 532 | $filter['operator'] = 'is'; |
533 | 533 | break; |
534 | 534 | } |
535 | 535 | } |
536 | - } elseif ( is_array( $value ) ) { |
|
536 | + } elseif (is_array($value)) { |
|
537 | 537 | |
538 | 538 | // Reset filter variable |
539 | 539 | $filter = array(); |
540 | 540 | |
541 | - foreach ( $value as $val ) { |
|
541 | + foreach ($value as $val) { |
|
542 | 542 | $filter[] = array( |
543 | 543 | 'key' => $field_id, |
544 | 544 | 'value' => $val, |
@@ -552,13 +552,13 @@ discard block |
||
552 | 552 | case 'name': |
553 | 553 | case 'address': |
554 | 554 | |
555 | - if ( false === strpos( $field_id, '.' ) ) { |
|
555 | + if (false === strpos($field_id, '.')) { |
|
556 | 556 | |
557 | - $words = explode( ' ', $value ); |
|
557 | + $words = explode(' ', $value); |
|
558 | 558 | |
559 | 559 | $filters = array(); |
560 | - foreach ( $words as $word ) { |
|
561 | - if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
|
560 | + foreach ($words as $word) { |
|
561 | + if (!empty($word) && strlen($word) > 1) { |
|
562 | 562 | // Keep the same key for each filter |
563 | 563 | $filter['value'] = $word; |
564 | 564 | // Add a search for the value |
@@ -573,25 +573,25 @@ discard block |
||
573 | 573 | |
574 | 574 | case 'date': |
575 | 575 | |
576 | - if ( is_array( $value ) ) { |
|
576 | + if (is_array($value)) { |
|
577 | 577 | |
578 | 578 | // Reset filter variable |
579 | 579 | $filter = array(); |
580 | 580 | |
581 | - foreach ( $value as $k => $date ) { |
|
582 | - if ( empty( $date ) ) { |
|
581 | + foreach ($value as $k => $date) { |
|
582 | + if (empty($date)) { |
|
583 | 583 | continue; |
584 | 584 | } |
585 | 585 | $operator = 'start' === $k ? '>' : '<'; |
586 | 586 | |
587 | 587 | $filter[] = array( |
588 | 588 | 'key' => $field_id, |
589 | - 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
|
589 | + 'value' => self::get_formatted_date($date, 'Y-m-d'), |
|
590 | 590 | 'operator' => $operator, |
591 | 591 | ); |
592 | 592 | } |
593 | 593 | } else { |
594 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
594 | + $filter['value'] = self::get_formatted_date($value, 'Y-m-d'); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | break; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string Format of the date in the database |
612 | 612 | */ |
613 | - public static function get_date_field_format( GF_Field_Date $field ) { |
|
613 | + public static function get_date_field_format(GF_Field_Date $field) { |
|
614 | 614 | $format = 'm/d/Y'; |
615 | 615 | $datepicker = array( |
616 | 616 | 'mdy' => 'm/d/Y', |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | 'ymd_dot' => 'Y.m.d', |
623 | 623 | ); |
624 | 624 | |
625 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
626 | - $format = $datepicker[ $field->dateFormat ]; |
|
625 | + if (!empty($field->dateFormat) && isset($datepicker[$field->dateFormat])) { |
|
626 | + $format = $datepicker[$field->dateFormat]; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | return $format; |
@@ -636,13 +636,13 @@ discard block |
||
636 | 636 | * @param string $format Wanted formatted date |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function get_formatted_date( $value = '', $format = 'Y-m-d' ) { |
|
640 | - $date = date_create( $value ); |
|
641 | - if ( empty( $date ) ) { |
|
642 | - do_action( 'gravityview_log_debug', sprintf( '%s[get_formatted_date] Date format not valid: ', get_class( self::$instance ) ), $value ); |
|
639 | + public static function get_formatted_date($value = '', $format = 'Y-m-d') { |
|
640 | + $date = date_create($value); |
|
641 | + if (empty($date)) { |
|
642 | + do_action('gravityview_log_debug', sprintf('%s[get_formatted_date] Date format not valid: ', get_class(self::$instance)), $value); |
|
643 | 643 | return ''; |
644 | 644 | } |
645 | - return $date->format( $format ); |
|
645 | + return $date->format($format); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | * Include this extension templates path |
651 | 651 | * @param array $file_paths List of template paths ordered |
652 | 652 | */ |
653 | - public function add_template_path( $file_paths ) { |
|
653 | + public function add_template_path($file_paths) { |
|
654 | 654 | |
655 | 655 | // Index 100 is the default GravityView template path. |
656 | - $file_paths[102] = self::$file . 'templates/'; |
|
656 | + $file_paths[102] = self::$file.'templates/'; |
|
657 | 657 | |
658 | 658 | return $file_paths; |
659 | 659 | } |
@@ -665,50 +665,50 @@ discard block |
||
665 | 665 | * @param type $context |
666 | 666 | * @return type |
667 | 667 | */ |
668 | - public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
668 | + public function render_frontend($widget_args, $content = '', $context = '') { |
|
669 | 669 | /** @var GravityView_View $gravityview_view */ |
670 | 670 | $gravityview_view = GravityView_View::getInstance(); |
671 | 671 | |
672 | - if ( empty( $gravityview_view ) ) { |
|
673 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) ); |
|
672 | + if (empty($gravityview_view)) { |
|
673 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this))); |
|
674 | 674 | return; |
675 | 675 | } |
676 | 676 | |
677 | 677 | // get configured search fields |
678 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
678 | + $search_fields = !empty($widget_args['search_fields']) ? json_decode($widget_args['search_fields'], true) : ''; |
|
679 | 679 | |
680 | - if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
|
681 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args ); |
|
680 | + if (empty($search_fields) || !is_array($search_fields)) { |
|
681 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] No search fields configured for widget:', get_class($this)), $widget_args); |
|
682 | 682 | return; |
683 | 683 | } |
684 | 684 | |
685 | 685 | $has_date = false; |
686 | 686 | |
687 | 687 | // prepare fields |
688 | - foreach ( $search_fields as $k => $field ) { |
|
688 | + foreach ($search_fields as $k => $field) { |
|
689 | 689 | |
690 | 690 | $updated_field = $field; |
691 | 691 | |
692 | - if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) { |
|
692 | + if (in_array($field['input'], array('date', 'date_range'))) { |
|
693 | 693 | $has_date = true; |
694 | 694 | } |
695 | 695 | |
696 | - $updated_field = $this->get_search_filter_details( $updated_field ); |
|
696 | + $updated_field = $this->get_search_filter_details($updated_field); |
|
697 | 697 | |
698 | - switch ( $field['field'] ) { |
|
698 | + switch ($field['field']) { |
|
699 | 699 | |
700 | 700 | case 'search_all': |
701 | 701 | $updated_field['key'] = 'search_all'; |
702 | 702 | $updated_field['input'] = 'search_all'; |
703 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) ); |
|
703 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_search'))); |
|
704 | 704 | break; |
705 | 705 | |
706 | 706 | case 'entry_date': |
707 | 707 | $updated_field['key'] = 'entry_date'; |
708 | 708 | $updated_field['input'] = 'entry_date'; |
709 | 709 | $updated_field['value'] = array( |
710 | - 'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ), |
|
711 | - 'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ), |
|
710 | + 'start' => esc_attr(stripslashes_deep(rgget('gv_start'))), |
|
711 | + 'end' => esc_attr(stripslashes_deep(rgget('gv_end'))), |
|
712 | 712 | ); |
713 | 713 | $has_date = true; |
714 | 714 | break; |
@@ -716,21 +716,21 @@ discard block |
||
716 | 716 | case 'entry_id': |
717 | 717 | $updated_field['key'] = 'entry_id'; |
718 | 718 | $updated_field['input'] = 'entry_id'; |
719 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) ); |
|
719 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_id'))); |
|
720 | 720 | break; |
721 | 721 | |
722 | 722 | case 'created_by': |
723 | 723 | $updated_field['key'] = 'created_by'; |
724 | 724 | $updated_field['name'] = 'gv_by'; |
725 | - $updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) ); |
|
725 | + $updated_field['value'] = esc_attr(stripslashes_deep(rgget('gv_by'))); |
|
726 | 726 | $updated_field['choices'] = self::get_created_by_choices(); |
727 | 727 | break; |
728 | 728 | } |
729 | 729 | |
730 | - $search_fields[ $k ] = $updated_field; |
|
730 | + $search_fields[$k] = $updated_field; |
|
731 | 731 | } |
732 | 732 | |
733 | - do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] Calculated Search Fields: ', get_class( $this ) ), $search_fields ); |
|
733 | + do_action('gravityview_log_debug', sprintf('%s[render_frontend] Calculated Search Fields: ', get_class($this)), $search_fields); |
|
734 | 734 | |
735 | 735 | /** |
736 | 736 | * @filter `gravityview_widget_search_filters` Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget. |
@@ -739,25 +739,25 @@ discard block |
||
739 | 739 | * @param array $widget_args Args passed to this method. {@since 1.8} |
740 | 740 | * @var array |
741 | 741 | */ |
742 | - $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args ); |
|
742 | + $gravityview_view->search_fields = apply_filters('gravityview_widget_search_filters', $search_fields, $this, $widget_args); |
|
743 | 743 | |
744 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
744 | + $gravityview_view->search_layout = !empty($widget_args['search_layout']) ? $widget_args['search_layout'] : 'horizontal'; |
|
745 | 745 | |
746 | 746 | /** @since 1.14 */ |
747 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
747 | + $gravityview_view->search_mode = !empty($widget_args['search_mode']) ? $widget_args['search_mode'] : 'any'; |
|
748 | 748 | |
749 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
749 | + $custom_class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : ''; |
|
750 | 750 | |
751 | - $gravityview_view->search_class = self::get_search_class( $custom_class ); |
|
751 | + $gravityview_view->search_class = self::get_search_class($custom_class); |
|
752 | 752 | |
753 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
753 | + $gravityview_view->search_clear = !empty($widget_args['search_clear']) ? $widget_args['search_clear'] : false; |
|
754 | 754 | |
755 | - if ( $has_date ) { |
|
755 | + if ($has_date) { |
|
756 | 756 | // enqueue datepicker stuff only if needed! |
757 | 757 | $this->enqueue_datepicker(); |
758 | 758 | } |
759 | 759 | |
760 | - $gravityview_view->render( 'widget', 'search', false ); |
|
760 | + $gravityview_view->render('widget', 'search', false); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -767,12 +767,12 @@ discard block |
||
767 | 767 | * |
768 | 768 | * @return string Sanitized CSS class for the search form |
769 | 769 | */ |
770 | - public static function get_search_class( $custom_class = '' ) { |
|
770 | + public static function get_search_class($custom_class = '') { |
|
771 | 771 | $gravityview_view = GravityView_View::getInstance(); |
772 | 772 | |
773 | 773 | $search_class = 'gv-search-'.$gravityview_view->search_layout; |
774 | 774 | |
775 | - if ( ! empty( $custom_class ) ) { |
|
775 | + if (!empty($custom_class)) { |
|
776 | 776 | $search_class .= ' '.$custom_class; |
777 | 777 | } |
778 | 778 | |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @param string $search_class The CSS class for the search form |
783 | 783 | */ |
784 | - $search_class = apply_filters( 'gravityview_search_class', $search_class ); |
|
784 | + $search_class = apply_filters('gravityview_search_class', $search_class); |
|
785 | 785 | |
786 | 786 | // Is there an active search being performed? Used by fe-views.js |
787 | 787 | $search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : ''; |
788 | 788 | |
789 | - return gravityview_sanitize_html_class( $search_class ); |
|
789 | + return gravityview_sanitize_html_class($search_class); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | |
@@ -801,9 +801,9 @@ discard block |
||
801 | 801 | |
802 | 802 | $post_id = $gravityview_view->getPostId() ? $gravityview_view->getPostId() : $gravityview_view->getViewId(); |
803 | 803 | |
804 | - $url = add_query_arg( array(), get_permalink( $post_id ) ); |
|
804 | + $url = add_query_arg(array(), get_permalink($post_id)); |
|
805 | 805 | |
806 | - return esc_url( $url ); |
|
806 | + return esc_url($url); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -812,42 +812,42 @@ discard block |
||
812 | 812 | * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
813 | 813 | * @return string Label for the search form |
814 | 814 | */ |
815 | - private static function get_field_label( $field, $form_field = array() ) { |
|
815 | + private static function get_field_label($field, $form_field = array()) { |
|
816 | 816 | |
817 | - $label = rgget( 'label', $field ); |
|
817 | + $label = rgget('label', $field); |
|
818 | 818 | |
819 | - if( '' === $label ) { |
|
819 | + if ('' === $label) { |
|
820 | 820 | |
821 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
821 | + $label = isset($form_field['label']) ? $form_field['label'] : ''; |
|
822 | 822 | |
823 | - switch( $field['field'] ) { |
|
823 | + switch ($field['field']) { |
|
824 | 824 | case 'search_all': |
825 | - $label = __( 'Search Entries:', 'gravityview' ); |
|
825 | + $label = __('Search Entries:', 'gravityview'); |
|
826 | 826 | break; |
827 | 827 | case 'entry_date': |
828 | - $label = __( 'Filter by date:', 'gravityview' ); |
|
828 | + $label = __('Filter by date:', 'gravityview'); |
|
829 | 829 | break; |
830 | 830 | case 'entry_id': |
831 | - $label = __( 'Entry ID:', 'gravityview' ); |
|
831 | + $label = __('Entry ID:', 'gravityview'); |
|
832 | 832 | break; |
833 | 833 | case 'created_by': |
834 | - $label = __( 'Submitted by:', 'gravityview' ); |
|
834 | + $label = __('Submitted by:', 'gravityview'); |
|
835 | 835 | break; |
836 | 836 | case 'is_fulfilled': |
837 | - $label = __( 'Is Fulfilled', 'gravityview' ); |
|
837 | + $label = __('Is Fulfilled', 'gravityview'); |
|
838 | 838 | break; |
839 | 839 | default: |
840 | 840 | // If this is a field input, not a field |
841 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
841 | + if (strpos($field['field'], '.') > 0 && !empty($form_field['inputs'])) { |
|
842 | 842 | |
843 | 843 | // Get the label for the field in question, which returns an array |
844 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
844 | + $items = wp_list_filter($form_field['inputs'], array('id' => $field['field'])); |
|
845 | 845 | |
846 | 846 | // Get the item with the `label` key |
847 | - $values = wp_list_pluck( $items, 'label' ); |
|
847 | + $values = wp_list_pluck($items, 'label'); |
|
848 | 848 | |
849 | 849 | // There will only one item in the array, but this is easier |
850 | - foreach ( $values as $value ) { |
|
850 | + foreach ($values as $value) { |
|
851 | 851 | $label = $value; |
852 | 852 | break; |
853 | 853 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | * @param[in,out] string $label Existing label text, sanitized. |
861 | 861 | * @param[in] array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` |
862 | 862 | */ |
863 | - $label = apply_filters( 'gravityview_search_field_label', esc_attr( $label ), $form_field ); |
|
863 | + $label = apply_filters('gravityview_search_field_label', esc_attr($label), $form_field); |
|
864 | 864 | |
865 | 865 | return $label; |
866 | 866 | } |
@@ -871,39 +871,39 @@ discard block |
||
871 | 871 | * @param array $field |
872 | 872 | * @return array |
873 | 873 | */ |
874 | - private function get_search_filter_details( $field ) { |
|
874 | + private function get_search_filter_details($field) { |
|
875 | 875 | |
876 | 876 | $gravityview_view = GravityView_View::getInstance(); |
877 | 877 | |
878 | 878 | $form = $gravityview_view->getForm(); |
879 | 879 | |
880 | 880 | // for advanced field ids (eg, first name / last name ) |
881 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
881 | + $name = 'filter_'.str_replace('.', '_', $field['field']); |
|
882 | 882 | |
883 | 883 | // get searched value from $_GET (string or array) |
884 | - $value = rgget( $name ); |
|
884 | + $value = rgget($name); |
|
885 | 885 | |
886 | 886 | // get form field details |
887 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
887 | + $form_field = gravityview_get_field($form, $field['field']); |
|
888 | 888 | |
889 | 889 | $filter = array( |
890 | 890 | 'key' => $field['field'], |
891 | 891 | 'name' => $name, |
892 | - 'label' => self::get_field_label( $field, $form_field ), |
|
892 | + 'label' => self::get_field_label($field, $form_field), |
|
893 | 893 | 'input' => $field['input'], |
894 | 894 | 'value' => $value, |
895 | 895 | 'type' => $form_field['type'], |
896 | 896 | ); |
897 | 897 | |
898 | 898 | // collect choices |
899 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
899 | + if ('post_category' === $form_field['type'] && !empty($form_field['displayAllCategories']) && empty($form_field['choices'])) { |
|
900 | 900 | $filter['choices'] = gravityview_get_terms_choices(); |
901 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
901 | + } elseif (!empty($form_field['choices'])) { |
|
902 | 902 | $filter['choices'] = $form_field['choices']; |
903 | 903 | } |
904 | 904 | |
905 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
906 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
905 | + if ('date_range' === $field['input'] && empty($value)) { |
|
906 | + $filter['value'] = array('start' => '', 'end' => ''); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | return $filter; |
@@ -923,10 +923,10 @@ discard block |
||
923 | 923 | * filter gravityview/get_users/search_widget |
924 | 924 | * @see \GVCommon::get_users |
925 | 925 | */ |
926 | - $users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) ); |
|
926 | + $users = GVCommon::get_users('search_widget', array('fields' => array('ID', 'display_name'))); |
|
927 | 927 | |
928 | 928 | $choices = array(); |
929 | - foreach ( $users as $user ) { |
|
929 | + foreach ($users as $user) { |
|
930 | 930 | $choices[] = array( |
931 | 931 | 'value' => $user->ID, |
932 | 932 | 'text' => $user->display_name, |
@@ -944,11 +944,11 @@ discard block |
||
944 | 944 | public static function the_clear_search_button() { |
945 | 945 | $gravityview_view = GravityView_View::getInstance(); |
946 | 946 | |
947 | - if ( $gravityview_view->search_clear ) { |
|
947 | + if ($gravityview_view->search_clear) { |
|
948 | 948 | |
949 | - $url = strtok( add_query_arg( array() ), '?' ); |
|
949 | + $url = strtok(add_query_arg(array()), '?'); |
|
950 | 950 | |
951 | - echo gravityview_get_link( $url, esc_html__( 'Clear', 'gravityview' ), 'class=button gv-search-clear' ); |
|
951 | + echo gravityview_get_link($url, esc_html__('Clear', 'gravityview'), 'class=button gv-search-clear'); |
|
952 | 952 | |
953 | 953 | } |
954 | 954 | } |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * Require the datepicker script for the frontend GV script |
960 | 960 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
961 | 961 | */ |
962 | - public function add_datepicker_js_dependency( $js_dependencies ) { |
|
962 | + public function add_datepicker_js_dependency($js_dependencies) { |
|
963 | 963 | |
964 | 964 | $js_dependencies[] = 'jquery-ui-datepicker'; |
965 | 965 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * |
975 | 975 | * @return array |
976 | 976 | */ |
977 | - public function add_datepicker_localization( $localizations = array(), $view_data = array() ) { |
|
977 | + public function add_datepicker_localization($localizations = array(), $view_data = array()) { |
|
978 | 978 | global $wp_locale; |
979 | 979 | |
980 | 980 | /** |
@@ -984,26 +984,26 @@ discard block |
||
984 | 984 | * @param array $js_localization The data padded to the Javascript file |
985 | 985 | * @param array $view_data View data array with View settings |
986 | 986 | */ |
987 | - $datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array( |
|
987 | + $datepicker_settings = apply_filters('gravityview_datepicker_settings', array( |
|
988 | 988 | 'yearRange' => '-5:+5', |
989 | 989 | 'changeMonth' => true, |
990 | 990 | 'changeYear' => true, |
991 | - 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gravityview' ), |
|
992 | - 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gravityview' ), |
|
993 | - 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gravityview' ), |
|
994 | - 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gravityview' ), |
|
995 | - 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gravityview' ), |
|
996 | - 'monthStatus' => __( 'Show a different month', 'gravityview' ), |
|
997 | - 'monthNames' => array_values( $wp_locale->month ), |
|
998 | - 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
|
999 | - 'dayNames' => array_values( $wp_locale->weekday ), |
|
1000 | - 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
|
1001 | - 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
|
991 | + 'closeText' => esc_attr_x('Close', 'Close calendar', 'gravityview'), |
|
992 | + 'prevText' => esc_attr_x('Prev', 'Previous month in calendar', 'gravityview'), |
|
993 | + 'nextText' => esc_attr_x('Next', 'Next month in calendar', 'gravityview'), |
|
994 | + 'currentText' => esc_attr_x('Today', 'Today in calendar', 'gravityview'), |
|
995 | + 'weekHeader' => esc_attr_x('Week', 'Week in calendar', 'gravityview'), |
|
996 | + 'monthStatus' => __('Show a different month', 'gravityview'), |
|
997 | + 'monthNames' => array_values($wp_locale->month), |
|
998 | + 'monthNamesShort' => array_values($wp_locale->month_abbrev), |
|
999 | + 'dayNames' => array_values($wp_locale->weekday), |
|
1000 | + 'dayNamesShort' => array_values($wp_locale->weekday_abbrev), |
|
1001 | + 'dayNamesMin' => array_values($wp_locale->weekday_initial), |
|
1002 | 1002 | // get the start of week from WP general setting |
1003 | - 'firstDay' => get_option( 'start_of_week' ), |
|
1003 | + 'firstDay' => get_option('start_of_week'), |
|
1004 | 1004 | // is Right to left language? default is false |
1005 | 1005 | 'isRTL' => is_rtl(), |
1006 | - ), $view_data ); |
|
1006 | + ), $view_data); |
|
1007 | 1007 | |
1008 | 1008 | $localizations['datepicker'] = $datepicker_settings; |
1009 | 1009 | |
@@ -1022,13 +1022,13 @@ discard block |
||
1022 | 1022 | public function enqueue_datepicker() { |
1023 | 1023 | $gravityview_view = GravityView_View::getInstance(); |
1024 | 1024 | |
1025 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1025 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1026 | 1026 | |
1027 | - add_filter( 'gravityview_js_dependencies', array( $this, 'add_datepicker_js_dependency' ) ); |
|
1028 | - add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
|
1027 | + add_filter('gravityview_js_dependencies', array($this, 'add_datepicker_js_dependency')); |
|
1028 | + add_filter('gravityview_js_localization', array($this, 'add_datepicker_localization'), 10, 2); |
|
1029 | 1029 | |
1030 | 1030 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1031 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1031 | + wp_enqueue_style('jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css'); |
|
1032 | 1032 | |
1033 | 1033 | /** |
1034 | 1034 | * @filter `gravityview_search_datepicker_class` |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * - `ymd_dash` (yyyy-mm-dd) |
1044 | 1044 | * - `ymp_dot` (yyyy.mm.dd) |
1045 | 1045 | */ |
1046 | - $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy' ); |
|
1046 | + $datepicker_class = apply_filters('gravityview_search_datepicker_class', 'gv-datepicker datepicker mdy'); |
|
1047 | 1047 | |
1048 | 1048 | $gravityview_view->datepicker_class = $datepicker_class; |
1049 | 1049 |
@@ -176,6 +176,7 @@ |
||
176 | 176 | * Get the entries that will be shown in the current widget |
177 | 177 | * |
178 | 178 | * @param array $instance Settings for the current widget |
179 | + * @param string $form_id |
|
179 | 180 | * |
180 | 181 | * @return array $entries Multidimensional array of Gravity Forms entries |
181 | 182 | */ |
@@ -15,19 +15,19 @@ discard block |
||
15 | 15 | $name = __('GravityView Recent Entries', 'gravityview'); |
16 | 16 | |
17 | 17 | $widget_options = array( |
18 | - 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
|
18 | + 'description' => __('Display the most recent entries for a View', 'gravityview'), |
|
19 | 19 | ); |
20 | 20 | |
21 | - parent::__construct( 'gv_recent_entries', $name, $widget_options ); |
|
21 | + parent::__construct('gv_recent_entries', $name, $widget_options); |
|
22 | 22 | |
23 | 23 | $this->initialize(); |
24 | 24 | } |
25 | 25 | |
26 | 26 | private function initialize() { |
27 | 27 | |
28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
28 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
29 | 29 | |
30 | - add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
|
30 | + add_action('wp_ajax_gv_get_view_merge_tag_data', array($this, 'ajax_get_view_merge_tag_data')); |
|
31 | 31 | |
32 | 32 | } |
33 | 33 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function ajax_get_view_merge_tag_data() { |
40 | 40 | |
41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
42 | - exit( false ); |
|
41 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajax_widget')) { |
|
42 | + exit(false); |
|
43 | 43 | } |
44 | 44 | |
45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
45 | + $form_id = gravityview_get_form_id($_POST['view_id']); |
|
46 | 46 | |
47 | - $form = RGFormsModel::get_form_meta( $form_id ); |
|
47 | + $form = RGFormsModel::get_form_meta($form_id); |
|
48 | 48 | |
49 | 49 | $output = array( |
50 | 50 | 'form' => array( |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | 'title' => $form['title'], |
53 | 53 | 'fields' => $form['fields'], |
54 | 54 | ), |
55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
55 | + 'mergeTags' => GFCommon::get_merge_tags($form['fields'], '', false), |
|
56 | 56 | ); |
57 | 57 | |
58 | - echo json_encode( $output ); |
|
58 | + echo json_encode($output); |
|
59 | 59 | |
60 | 60 | exit; |
61 | 61 | } |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | function admin_enqueue_scripts() { |
69 | 69 | global $pagenow; |
70 | 70 | |
71 | - if( $pagenow === 'widgets.php' ) { |
|
71 | + if ($pagenow === 'widgets.php') { |
|
72 | 72 | |
73 | 73 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
74 | 74 | |
75 | 75 | GravityView_Admin_Views::enqueue_gravity_forms_scripts(); |
76 | 76 | |
77 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
77 | + wp_enqueue_script('gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery', 'gform_gravityforms'), GravityView_Plugin::version); |
|
78 | 78 | |
79 | - wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
|
80 | - 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
|
79 | + wp_localize_script('gravityview_widgets', 'GVWidgets', array( |
|
80 | + 'nonce' => wp_create_nonce('gravityview_ajax_widget') |
|
81 | 81 | )); |
82 | 82 | |
83 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
83 | + wp_enqueue_style('gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons'), GravityView_Plugin::version); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
@@ -92,22 +92,22 @@ discard block |
||
92 | 92 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
93 | 93 | * @param array $instance The settings for the particular instance of the widget. |
94 | 94 | */ |
95 | - function widget( $args, $instance ) { |
|
95 | + function widget($args, $instance) { |
|
96 | 96 | |
97 | 97 | // Don't have the Customizer render too soon. |
98 | - if( empty( $instance['view_id'] ) ) { |
|
98 | + if (empty($instance['view_id'])) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
103 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
102 | + $args['id'] = (isset($args['id'])) ? $args['id'] : 'gv_recent_entries'; |
|
103 | + $instance['title'] = (isset($instance['title'])) ? $instance['title'] : ''; |
|
104 | 104 | |
105 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
105 | + $title = apply_filters('widget_title', $instance['title'], $instance, $args['id']); |
|
106 | 106 | |
107 | 107 | echo $args['before_widget']; |
108 | 108 | |
109 | - if ( !empty( $title ) ) { |
|
110 | - echo $args['before_title'] . $title . $args['after_title']; |
|
109 | + if (!empty($title)) { |
|
110 | + echo $args['before_title'].$title.$args['after_title']; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
116 | 116 | * @param array $instance The settings for the particular instance of the widget. |
117 | 117 | */ |
118 | - do_action( 'gravityview/widget/recent-entries/before_widget', $args, $instance ); |
|
118 | + do_action('gravityview/widget/recent-entries/before_widget', $args, $instance); |
|
119 | 119 | |
120 | 120 | // Print the entry list |
121 | - echo $this->get_output( $instance ); |
|
121 | + echo $this->get_output($instance); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @action `gravityview/widget/recent-entries/after_widget` After recent entries are displayed in the WordPress widget |
125 | 125 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
126 | 126 | * @param array $instance The settings for the particular instance of the widget. |
127 | 127 | */ |
128 | - do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
|
128 | + do_action('gravityview/widget/recent-entries/after_widget', $args, $instance); |
|
129 | 129 | |
130 | 130 | echo $args['after_widget']; |
131 | 131 | } |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - private function get_output( $instance ) { |
|
142 | + private function get_output($instance) { |
|
143 | 143 | |
144 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
144 | + $form_id = gravityview_get_form_id($instance['view_id']); |
|
145 | 145 | |
146 | - $form = gravityview_get_form( $form_id ); |
|
146 | + $form = gravityview_get_form($form_id); |
|
147 | 147 | |
148 | - $entries = $this->get_entries( $instance, $form_id ); |
|
148 | + $entries = $this->get_entries($instance, $form_id); |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * @since 1.6.1 |
152 | 152 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
153 | 153 | */ |
154 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
154 | + $entry_link_post_id = (empty($instance['error_post_id']) && !empty($instance['post_id'])) ? $instance['post_id'] : $instance['view_id']; |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Generate list output |
158 | 158 | * @since 1.7.2 |
159 | 159 | */ |
160 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget' ); |
|
160 | + $List = new GravityView_Entry_List($entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget'); |
|
161 | 161 | |
162 | 162 | $output = $List->get_output(); |
163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param string $output HTML to be displayed |
167 | 167 | * @param array $instance Widget settings |
168 | 168 | */ |
169 | - $output = apply_filters( 'gravityview/widget/recent-entries/output', $output, $instance ); |
|
169 | + $output = apply_filters('gravityview/widget/recent-entries/output', $output, $instance); |
|
170 | 170 | |
171 | 171 | return $output; |
172 | 172 | } |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return array $entries Multidimensional array of Gravity Forms entries |
181 | 181 | */ |
182 | - private function get_entries( $instance, $form_id ) { |
|
182 | + private function get_entries($instance, $form_id) { |
|
183 | 183 | |
184 | 184 | // Get the settings for the View ID |
185 | - $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
|
185 | + $view_settings = gravityview_get_template_settings($instance['view_id']); |
|
186 | 186 | |
187 | 187 | // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
188 | 188 | $criteria['context_view_id'] = $instance['view_id']; |
189 | 189 | |
190 | - $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
190 | + $instance['limit'] = isset($instance['limit']) ? $instance['limit'] : 10; |
|
191 | 191 | $view_settings['id'] = $instance['view_id']; |
192 | 192 | $view_settings['page_size'] = $instance['limit']; |
193 | 193 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | ); |
199 | 199 | |
200 | 200 | // Prepare Search Criteria |
201 | - $criteria['search_criteria'] = array( 'field_filters' => array() ); |
|
202 | - $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria['search_criteria']); |
|
203 | - $criteria['search_criteria']['status'] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
201 | + $criteria['search_criteria'] = array('field_filters' => array()); |
|
202 | + $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved($view_settings, $criteria['search_criteria']); |
|
203 | + $criteria['search_criteria']['status'] = apply_filters('gravityview_status', 'active', $view_settings); |
|
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Modify the search parameters before the entries are fetched |
207 | 207 | */ |
208 | - $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
208 | + $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id); |
|
209 | 209 | |
210 | - $results = GVCommon::get_entries( $form_id, $criteria ); |
|
210 | + $results = GVCommon::get_entries($form_id, $criteria); |
|
211 | 211 | |
212 | 212 | return $results; |
213 | 213 | } |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array Calculated widget settings after processing |
223 | 223 | */ |
224 | - public function update( $new_instance, $old_instance ) { |
|
224 | + public function update($new_instance, $old_instance) { |
|
225 | 225 | |
226 | 226 | $instance = $new_instance; |
227 | 227 | |
228 | 228 | // Force positive number |
229 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
229 | + $instance['limit'] = empty($instance['limit']) ? 10 : absint($instance['limit']); |
|
230 | 230 | |
231 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
231 | + $instance['view_id'] = intval($instance['view_id']); |
|
232 | 232 | |
233 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
233 | + $instance['link_format'] = trim(rtrim($instance['link_format'])); |
|
234 | 234 | |
235 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
235 | + $instance['link_format'] = empty($instance['link_format']) ? $old_instance['link_format'] : $instance['link_format']; |
|
236 | 236 | |
237 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
237 | + $instance['post_id'] = empty($instance['post_id']) ? '' : intval($instance['post_id']); |
|
238 | 238 | |
239 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'] ); |
|
239 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id($instance['post_id'], $instance['view_id']); |
|
240 | 240 | |
241 | 241 | //check if post_id is a valid post with embedded View |
242 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
242 | + $instance['error_post_id'] = is_wp_error($is_valid_embed_id) ? $is_valid_embed_id->get_error_message() : NULL; |
|
243 | 243 | |
244 | 244 | // Share that the widget isn't brand new |
245 | - $instance['updated'] = 1; |
|
245 | + $instance['updated'] = 1; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param array $new_instance Widget form settings after update |
252 | 252 | * @param array $old_instance Widget form settings before update |
253 | 253 | */ |
254 | - $instance = apply_filters( 'gravityview/widget/update', $instance, $new_instance, $old_instance ); |
|
254 | + $instance = apply_filters('gravityview/widget/update', $instance, $new_instance, $old_instance); |
|
255 | 255 | |
256 | 256 | return $instance; |
257 | 257 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @since 1.6 |
261 | 261 | * @see WP_Widget::form() |
262 | 262 | */ |
263 | - public function form( $instance ) { |
|
263 | + public function form($instance) { |
|
264 | 264 | |
265 | 265 | // Set up some default widget settings. |
266 | 266 | $defaults = array( |
@@ -272,14 +272,14 @@ discard block |
||
272 | 272 | 'after_link' => '' |
273 | 273 | ); |
274 | 274 | |
275 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
275 | + $instance = wp_parse_args((array)$instance, $defaults); |
|
276 | 276 | |
277 | 277 | ?> |
278 | 278 | |
279 | 279 | <!-- Title --> |
280 | 280 | <p> |
281 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
|
282 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
281 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title:', 'gravityview') ?></label> |
|
282 | + <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" /> |
|
283 | 283 | </p> |
284 | 284 | |
285 | 285 | <!-- Download --> |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | 'posts_per_page' => -1, |
290 | 290 | 'post_status' => 'publish', |
291 | 291 | ); |
292 | - $views = get_posts( $args ); |
|
292 | + $views = get_posts($args); |
|
293 | 293 | |
294 | 294 | // If there are no views set up yet, we get outta here. |
295 | - if( empty( $views ) ) { |
|
296 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
295 | + if (empty($views)) { |
|
296 | + echo '<div id="select_gravityview_view"><div class="wrap">'.GravityView_Post_Types::no_views_text().'</div></div>'; |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
@@ -304,25 +304,25 @@ discard block |
||
304 | 304 | * Display errors generated for invalid embed IDs |
305 | 305 | * @see GravityView_View_Data::is_valid_embed_id |
306 | 306 | */ |
307 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
307 | + if (isset($instance['updated']) && empty($instance['view_id'])) { |
|
308 | 308 | ?> |
309 | 309 | <div class="error inline hide-on-view-change"> |
310 | 310 | <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
311 | 311 | </div> |
312 | 312 | <?php |
313 | - unset ( $error ); |
|
313 | + unset ($error); |
|
314 | 314 | } |
315 | 315 | ?> |
316 | 316 | |
317 | 317 | <p> |
318 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
319 | - <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
|
320 | - <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
|
318 | + <label for="<?php echo esc_attr($this->get_field_id('view_id')); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
319 | + <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr($this->get_field_name('view_id')); ?>" id="<?php echo esc_attr($this->get_field_id('view_id')); ?>"> |
|
320 | + <option value=""><?php esc_html_e('— Select a View as Entries Source —', 'gravityview'); ?></option> |
|
321 | 321 | <?php |
322 | 322 | |
323 | - foreach( $views as $view ) { |
|
324 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
325 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
323 | + foreach ($views as $view) { |
|
324 | + $title = empty($view->post_title) ? __('(no title)', 'gravityview') : $view->post_title; |
|
325 | + echo '<option value="'.$view->ID.'"'.selected(absint($instance['view_id']), $view->ID).'>'.esc_html(sprintf('%s #%d', $title, $view->ID)).'</option>'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | ?> |
@@ -334,44 +334,44 @@ discard block |
||
334 | 334 | * Display errors generated for invalid embed IDs |
335 | 335 | * @see GravityView_View_Data::is_valid_embed_id |
336 | 336 | */ |
337 | - if( !empty( $instance['error_post_id'] ) ) { |
|
337 | + if (!empty($instance['error_post_id'])) { |
|
338 | 338 | ?> |
339 | 339 | <div class="error inline"> |
340 | 340 | <p><?php echo $instance['error_post_id']; ?></p> |
341 | 341 | </div> |
342 | 342 | <?php |
343 | - unset ( $error ); |
|
343 | + unset ($error); |
|
344 | 344 | } |
345 | 345 | ?> |
346 | 346 | |
347 | 347 | <p> |
348 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
349 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
348 | + <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e('If Embedded, Page ID:', 'gravityview'); ?></label> |
|
349 | + <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr($instance['post_id']); ?>" /> |
|
350 | 350 | <span class="howto"><?php |
351 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
352 | - echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
351 | + esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview'); |
|
352 | + echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
353 | 353 | ?></span> |
354 | 354 | </p> |
355 | 355 | |
356 | 356 | <p> |
357 | - <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
|
358 | - <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
|
357 | + <label for="<?php echo $this->get_field_id('limit'); ?>"> |
|
358 | + <span><?php _e('Number of entries to show:', 'gravityview'); ?></span> |
|
359 | 359 | </label> |
360 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
360 | + <input class="code" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="number" value="<?php echo intval($instance['limit']); ?>" size="3" /> |
|
361 | 361 | </p> |
362 | 362 | |
363 | 363 | <p> |
364 | - <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
|
365 | - <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
|
364 | + <label for="<?php echo $this->get_field_id('link_format'); ?>"> |
|
365 | + <span><?php _e('Entry link text (required)', 'gravityview'); ?></span> |
|
366 | 366 | </label> |
367 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
367 | + <input id="<?php echo $this->get_field_id('link_format'); ?>" name="<?php echo $this->get_field_name('link_format'); ?>" type="text" value="<?php echo esc_attr($instance['link_format']); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
368 | 368 | </p> |
369 | 369 | |
370 | 370 | <p> |
371 | - <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
|
372 | - <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
|
371 | + <label for="<?php echo $this->get_field_id('after_link'); ?>"> |
|
372 | + <span><?php _e('Text or HTML to display after the link (optional)', 'gravityview'); ?></span> |
|
373 | 373 | </label> |
374 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
374 | + <textarea id="<?php echo $this->get_field_id('after_link'); ?>" name="<?php echo $this->get_field_name('after_link'); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea($instance['after_link']); ?></textarea> |
|
375 | 375 | </p> |
376 | 376 | |
377 | 377 | <?php |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
382 | 382 | * @param array $instance Current widget instance |
383 | 383 | */ |
384 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
384 | + do_action('gravityview_recent_entries_widget_form', $this, $instance); |
|
385 | 385 | |
386 | 386 | ?> |
387 | 387 | |
388 | 388 | <script> |
389 | 389 | // When the widget is saved or added, refresh the Merge Tags (here for backward compatibility) |
390 | 390 | // WordPress 3.9 added widget-added and widget-updated actions |
391 | - jQuery('#<?php echo $this->get_field_id( 'view_id' ); ?>').trigger( 'change' ); |
|
391 | + jQuery('#<?php echo $this->get_field_id('view_id'); ?>').trigger( 'change' ); |
|
392 | 392 | </script> |
393 | 393 | <?php } |
394 | 394 |
@@ -184,8 +184,8 @@ |
||
184 | 184 | // Get the settings for the View ID |
185 | 185 | $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
186 | 186 | |
187 | - // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
|
188 | - $criteria['context_view_id'] = $instance['view_id']; |
|
187 | + // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
|
188 | + $criteria['context_view_id'] = $instance['view_id']; |
|
189 | 189 | |
190 | 190 | $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
191 | 191 | $view_settings['id'] = $instance['view_id']; |
@@ -312,11 +312,11 @@ discard block |
||
312 | 312 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
313 | 313 | |
314 | 314 | |
315 | - /** |
|
316 | - * When an entry is created, check if we need to update the custom slug meta |
|
317 | - * todo: move this to its own class.. |
|
318 | - */ |
|
319 | - add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
315 | + /** |
|
316 | + * When an entry is created, check if we need to update the custom slug meta |
|
317 | + * todo: move this to its own class.. |
|
318 | + */ |
|
319 | + add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded |
@@ -347,34 +347,34 @@ discard block |
||
347 | 347 | |
348 | 348 | /** DEBUG */ |
349 | 349 | |
350 | - /** |
|
351 | - * Logs messages using Gravity Forms logging add-on |
|
352 | - * @param string $message log message |
|
353 | - * @param mixed $data Additional data to display |
|
354 | - * @return void |
|
355 | - */ |
|
356 | - public static function log_debug( $message, $data = null ){ |
|
357 | - /** |
|
358 | - * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
359 | - * @param string $message Message to display |
|
360 | - * @param mixed $data Supporting data to print alongside it |
|
361 | - */ |
|
362 | - do_action( 'gravityview_log_debug', $message, $data ); |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Logs messages using Gravity Forms logging add-on |
|
367 | - * @param string $message log message |
|
368 | - * @return void |
|
369 | - */ |
|
370 | - public static function log_error( $message, $data = null ){ |
|
371 | - /** |
|
372 | - * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
373 | - * @param string $message Error message to display |
|
374 | - * @param mixed $data Supporting data to print alongside it |
|
375 | - */ |
|
376 | - do_action( 'gravityview_log_error', $message, $data ); |
|
377 | - } |
|
350 | + /** |
|
351 | + * Logs messages using Gravity Forms logging add-on |
|
352 | + * @param string $message log message |
|
353 | + * @param mixed $data Additional data to display |
|
354 | + * @return void |
|
355 | + */ |
|
356 | + public static function log_debug( $message, $data = null ){ |
|
357 | + /** |
|
358 | + * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
359 | + * @param string $message Message to display |
|
360 | + * @param mixed $data Supporting data to print alongside it |
|
361 | + */ |
|
362 | + do_action( 'gravityview_log_debug', $message, $data ); |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Logs messages using Gravity Forms logging add-on |
|
367 | + * @param string $message log message |
|
368 | + * @return void |
|
369 | + */ |
|
370 | + public static function log_error( $message, $data = null ){ |
|
371 | + /** |
|
372 | + * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
|
373 | + * @param string $message Error message to display |
|
374 | + * @param mixed $data Supporting data to print alongside it |
|
375 | + */ |
|
376 | + do_action( 'gravityview_log_error', $message, $data ); |
|
377 | + } |
|
378 | 378 | |
379 | 379 | } // end class GravityView_Plugin |
380 | 380 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | |
28 | 28 | /** If this file is called directly, abort. */ |
29 | -if ( ! defined( 'ABSPATH' ) ) { |
|
29 | +if (!defined('ABSPATH')) { |
|
30 | 30 | die; |
31 | 31 | } |
32 | 32 | |
@@ -36,52 +36,52 @@ discard block |
||
36 | 36 | * Full path to the GravityView file |
37 | 37 | * @define "GRAVITYVIEW_FILE" "./gravityview.php" |
38 | 38 | */ |
39 | -define( 'GRAVITYVIEW_FILE', __FILE__ ); |
|
39 | +define('GRAVITYVIEW_FILE', __FILE__); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * The URL to this file |
43 | 43 | */ |
44 | -define( 'GRAVITYVIEW_URL', plugin_dir_url( __FILE__ ) ); |
|
44 | +define('GRAVITYVIEW_URL', plugin_dir_url(__FILE__)); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | /** @define "GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory */ |
48 | -define( 'GRAVITYVIEW_DIR', plugin_dir_path( __FILE__ ) ); |
|
48 | +define('GRAVITYVIEW_DIR', plugin_dir_path(__FILE__)); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * GravityView requires at least this version of Gravity Forms to function properly. |
52 | 52 | */ |
53 | -define( 'GV_MIN_GF_VERSION', '1.9.9.10' ); |
|
53 | +define('GV_MIN_GF_VERSION', '1.9.9.10'); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * GravityView requires at least this version of WordPress to function properly. |
57 | 57 | * @since 1.12 |
58 | 58 | */ |
59 | -define( 'GV_MIN_WP_VERSION', '3.3' ); |
|
59 | +define('GV_MIN_WP_VERSION', '3.3'); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * GravityView requires at least this version of PHP to function properly. |
63 | 63 | * @since 1.12 |
64 | 64 | */ |
65 | -define( 'GV_MIN_PHP_VERSION', '5.2.4' ); |
|
65 | +define('GV_MIN_PHP_VERSION', '5.2.4'); |
|
66 | 66 | |
67 | 67 | /** Load common & connector functions */ |
68 | -require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' ); |
|
69 | -require_once( GRAVITYVIEW_DIR . 'includes/class-common.php'); |
|
70 | -require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php'); |
|
71 | -require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' ); |
|
72 | -require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' ); |
|
73 | -require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' ); |
|
68 | +require_once(GRAVITYVIEW_DIR.'includes/helper-functions.php'); |
|
69 | +require_once(GRAVITYVIEW_DIR.'includes/class-common.php'); |
|
70 | +require_once(GRAVITYVIEW_DIR.'includes/connector-functions.php'); |
|
71 | +require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-compatibility.php'); |
|
72 | +require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-roles-capabilities.php'); |
|
73 | +require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-notices.php'); |
|
74 | 74 | |
75 | 75 | /** Register Post Types and Rewrite Rules */ |
76 | -require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php'); |
|
76 | +require_once(GRAVITYVIEW_DIR.'includes/class-post-types.php'); |
|
77 | 77 | |
78 | 78 | /** Add Cache Class */ |
79 | -require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php'); |
|
79 | +require_once(GRAVITYVIEW_DIR.'includes/class-cache.php'); |
|
80 | 80 | |
81 | 81 | /** Register hooks that are fired when the plugin is activated and deactivated. */ |
82 | -if( is_admin() ) { |
|
83 | - register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) ); |
|
84 | - register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) ); |
|
82 | +if (is_admin()) { |
|
83 | + register_activation_hook(__FILE__, array('GravityView_Plugin', 'activate')); |
|
84 | + register_deactivation_hook(__FILE__, array('GravityView_Plugin', 'deactivate')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public static function getInstance() { |
102 | 102 | |
103 | - if( empty( self::$instance ) ) { |
|
103 | + if (empty(self::$instance)) { |
|
104 | 104 | self::$instance = new self; |
105 | 105 | } |
106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function __construct() { |
111 | 111 | |
112 | 112 | |
113 | - if( ! GravityView_Compatibility::is_valid() ) { |
|
113 | + if (!GravityView_Compatibility::is_valid()) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | */ |
127 | 127 | private function add_hooks() { |
128 | 128 | // Load plugin text domain |
129 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ), 1 ); |
|
129 | + add_action('init', array($this, 'load_plugin_textdomain'), 1); |
|
130 | 130 | |
131 | 131 | // Load frontend files |
132 | - add_action( 'init', array( $this, 'frontend_actions' ), 20 ); |
|
132 | + add_action('init', array($this, 'frontend_actions'), 20); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -139,48 +139,48 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function include_files() { |
141 | 141 | |
142 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
|
142 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin.php'); |
|
143 | 143 | |
144 | 144 | // Load fields |
145 | - include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-fields.php' ); |
|
146 | - include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
145 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-fields.php'); |
|
146 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php'); |
|
147 | 147 | |
148 | 148 | // Load all field files automatically |
149 | - foreach ( glob( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field*.php' ) as $gv_field_filename ) { |
|
150 | - include_once( $gv_field_filename ); |
|
149 | + foreach (glob(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field*.php') as $gv_field_filename) { |
|
150 | + include_once($gv_field_filename); |
|
151 | 151 | } |
152 | 152 | |
153 | - include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' ); |
|
154 | - include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' ); |
|
153 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-notes.php'); |
|
154 | + include_once(GRAVITYVIEW_DIR.'includes/load-plugin-and-theme-hooks.php'); |
|
155 | 155 | |
156 | 156 | // Load Extensions |
157 | 157 | // @todo: Convert to a scan of the directory or a method where this all lives |
158 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
159 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
158 | + include_once(GRAVITYVIEW_DIR.'includes/extensions/edit-entry/class-edit-entry.php'); |
|
159 | + include_once(GRAVITYVIEW_DIR.'includes/extensions/delete-entry/class-delete-entry.php'); |
|
160 | 160 | |
161 | 161 | // Load WordPress Widgets |
162 | - include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
162 | + include_once(GRAVITYVIEW_DIR.'includes/wordpress-widgets/register-wordpress-widgets.php'); |
|
163 | 163 | |
164 | 164 | // Load GravityView Widgets |
165 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' ); |
|
165 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/register-gravityview-widgets.php'); |
|
166 | 166 | |
167 | 167 | // Add oEmbed |
168 | - include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' ); |
|
168 | + include_once(GRAVITYVIEW_DIR.'includes/class-oembed.php'); |
|
169 | 169 | |
170 | 170 | // Add logging |
171 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-logging.php' ); |
|
172 | - |
|
173 | - include_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' ); |
|
174 | - include_once( GRAVITYVIEW_DIR . 'includes/class-settings.php'); |
|
175 | - include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
|
176 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' ); |
|
177 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' ); |
|
178 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
|
179 | - include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' ); |
|
180 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' ); |
|
181 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' ); |
|
182 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gvlogic-shortcode.php' ); |
|
183 | - include_once( GRAVITYVIEW_DIR . 'includes/presets/register-default-templates.php' ); |
|
171 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-logging.php'); |
|
172 | + |
|
173 | + include_once(GRAVITYVIEW_DIR.'includes/class-ajax.php'); |
|
174 | + include_once(GRAVITYVIEW_DIR.'includes/class-settings.php'); |
|
175 | + include_once(GRAVITYVIEW_DIR.'includes/class-frontend-views.php'); |
|
176 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-bar.php'); |
|
177 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-list.php'); |
|
178 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
|
179 | + include_once(GRAVITYVIEW_DIR.'includes/class-data.php'); |
|
180 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-shortcode.php'); |
|
181 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-entry-link-shortcode.php'); |
|
182 | + include_once(GRAVITYVIEW_DIR.'includes/class-gvlogic-shortcode.php'); |
|
183 | + include_once(GRAVITYVIEW_DIR.'includes/presets/register-default-templates.php'); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return bool |
191 | 191 | */ |
192 | 192 | public static function is_network_activated() { |
193 | - return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
193 | + return is_multisite() && (function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('gravityview/gravityview.php')); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | flush_rewrite_rules(); |
213 | 213 | |
214 | 214 | // Update the current GV version |
215 | - update_option( 'gv_version', self::version ); |
|
215 | + update_option('gv_version', self::version); |
|
216 | 216 | |
217 | 217 | // Add the transient to redirect to configuration page |
218 | - set_transient( '_gv_activation_redirect', true, 60 ); |
|
218 | + set_transient('_gv_activation_redirect', true, 60); |
|
219 | 219 | |
220 | 220 | // Clear settings transient |
221 | - delete_transient( 'redux_edd_license_license_valid' ); |
|
221 | + delete_transient('redux_edd_license_license_valid'); |
|
222 | 222 | |
223 | 223 | GravityView_Roles_Capabilities::get_instance()->add_caps(); |
224 | 224 | } |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | public static function include_extension_framework() { |
247 | - if ( ! class_exists( 'GravityView_Extension' ) ) { |
|
248 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-extension.php' ); |
|
247 | + if (!class_exists('GravityView_Extension')) { |
|
248 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-extension.php'); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @since 1.7.5.1 |
256 | 256 | */ |
257 | 257 | public static function include_widget_class() { |
258 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
258 | + include_once(GRAVITYVIEW_DIR.'includes/widgets/class-gravityview-widget.php'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function load_plugin_textdomain() { |
269 | 269 | |
270 | - $loaded = load_plugin_textdomain( 'gravityview', false, '/languages/' ); |
|
271 | - if ( ! $loaded ) { |
|
272 | - $loaded = load_muplugin_textdomain( 'gravityview', '/languages/' ); |
|
270 | + $loaded = load_plugin_textdomain('gravityview', false, '/languages/'); |
|
271 | + if (!$loaded) { |
|
272 | + $loaded = load_muplugin_textdomain('gravityview', '/languages/'); |
|
273 | 273 | } |
274 | - if ( ! $loaded ) { |
|
275 | - $loaded = load_theme_textdomain( 'gravityview', '/languages/' ); |
|
274 | + if (!$loaded) { |
|
275 | + $loaded = load_theme_textdomain('gravityview', '/languages/'); |
|
276 | 276 | } |
277 | - if ( ! $loaded ) { |
|
278 | - $locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' ); |
|
279 | - $mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo'; |
|
280 | - load_textdomain( 'gravityview', $mofile ); |
|
277 | + if (!$loaded) { |
|
278 | + $locale = apply_filters('plugin_locale', get_locale(), 'gravityview'); |
|
279 | + $mofile = dirname(__FILE__).'/languages/gravityview-'.$locale.'.mo'; |
|
280 | + load_textdomain('gravityview', $mofile); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | } |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public static function is_admin() { |
291 | 291 | |
292 | - $doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false; |
|
292 | + $doing_ajax = defined('DOING_AJAX') ? DOING_AJAX : false; |
|
293 | 293 | |
294 | - return is_admin() && ! $doing_ajax; |
|
294 | + return is_admin() && !$doing_ajax; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -302,27 +302,27 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function frontend_actions() { |
304 | 304 | |
305 | - if( self::is_admin() ) { return; } |
|
305 | + if (self::is_admin()) { return; } |
|
306 | 306 | |
307 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' ); |
|
308 | - include_once( GRAVITYVIEW_DIR .'includes/class-template.php' ); |
|
309 | - include_once( GRAVITYVIEW_DIR .'includes/class-api.php' ); |
|
310 | - include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' ); |
|
311 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
|
307 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-image.php'); |
|
308 | + include_once(GRAVITYVIEW_DIR.'includes/class-template.php'); |
|
309 | + include_once(GRAVITYVIEW_DIR.'includes/class-api.php'); |
|
310 | + include_once(GRAVITYVIEW_DIR.'includes/class-frontend-views.php'); |
|
311 | + include_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php'); |
|
312 | 312 | |
313 | 313 | |
314 | 314 | /** |
315 | 315 | * When an entry is created, check if we need to update the custom slug meta |
316 | 316 | * todo: move this to its own class.. |
317 | 317 | */ |
318 | - add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
318 | + add_action('gform_entry_created', array('GravityView_API', 'entry_create_custom_slug'), 10, 2); |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded |
322 | 322 | * |
323 | 323 | * Nice place to insert extensions' frontend stuff |
324 | 324 | */ |
325 | - do_action( 'gravityview_include_frontend_actions' ); |
|
325 | + do_action('gravityview_include_frontend_actions'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public static function get_default_widget_areas() { |
334 | 334 | $default_areas = array( |
335 | - array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
336 | - array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ), |
|
335 | + array('1-1' => array(array('areaid' => 'top', 'title' => __('Top', 'gravityview'), 'subtitle' => ''))), |
|
336 | + array('1-2' => array(array('areaid' => 'left', 'title' => __('Left', 'gravityview'), 'subtitle' => '')), '2-2' => array(array('areaid' => 'right', 'title' => __('Right', 'gravityview'), 'subtitle' => ''))), |
|
337 | 337 | ); |
338 | 338 | |
339 | 339 | /** |
340 | 340 | * @filter `gravityview_widget_active_areas` Array of zones available for widgets to be dropped into |
341 | 341 | * @param array $default_areas Definition for default widget areas |
342 | 342 | */ |
343 | - return apply_filters( 'gravityview_widget_active_areas', $default_areas ); |
|
343 | + return apply_filters('gravityview_widget_active_areas', $default_areas); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** DEBUG */ |
@@ -351,13 +351,13 @@ discard block |
||
351 | 351 | * @param mixed $data Additional data to display |
352 | 352 | * @return void |
353 | 353 | */ |
354 | - public static function log_debug( $message, $data = null ){ |
|
354 | + public static function log_debug($message, $data = null) { |
|
355 | 355 | /** |
356 | 356 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
357 | 357 | * @param string $message Message to display |
358 | 358 | * @param mixed $data Supporting data to print alongside it |
359 | 359 | */ |
360 | - do_action( 'gravityview_log_debug', $message, $data ); |
|
360 | + do_action('gravityview_log_debug', $message, $data); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @param string $message log message |
366 | 366 | * @return void |
367 | 367 | */ |
368 | - public static function log_error( $message, $data = null ){ |
|
368 | + public static function log_error($message, $data = null) { |
|
369 | 369 | /** |
370 | 370 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
371 | 371 | * @param string $message Error message to display |
372 | 372 | * @param mixed $data Supporting data to print alongside it |
373 | 373 | */ |
374 | - do_action( 'gravityview_log_error', $message, $data ); |
|
374 | + do_action('gravityview_log_error', $message, $data); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | } // end class GravityView_Plugin |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | function __construct() { |
9 | 9 | |
10 | 10 | // Add Edit link to the entry actions |
11 | - add_action( 'gform_entries_first_column_actions', array( $this, 'add_edit_link' ), 10, 5 ); |
|
11 | + add_action('gform_entries_first_column_actions', array($this, 'add_edit_link'), 10, 5); |
|
12 | 12 | |
13 | 13 | // Add script to enable edit link |
14 | - add_action( 'admin_head-forms_page_gf_entries', array( $this, 'add_edit_script') ); |
|
14 | + add_action('admin_head-forms_page_gf_entries', array($this, 'add_edit_script')); |
|
15 | 15 | |
16 | 16 | } |
17 | 17 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public function add_edit_script() { |
27 | 27 | |
28 | 28 | // We're on a single entry page, or at least not the Entries page. |
29 | - if( !empty( $_GET['view'] ) && $_GET['view'] !== 'entries' ) { return; } |
|
29 | + if (!empty($_GET['view']) && $_GET['view'] !== 'entries') { return; } |
|
30 | 30 | ?> |
31 | 31 | <script> |
32 | 32 | jQuery( document ).ready( function( $ ) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param array $lead The current entry data |
51 | 51 | * @param string $query_string URL query string for a link to the current entry. Missing the `?page=` part, which is strange. Example: `gf_entries&view=entry&id=35&lid=5212&filter=&paged=1` |
52 | 52 | */ |
53 | - function add_edit_link( $form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL ) { |
|
53 | + function add_edit_link($form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL) { |
|
54 | 54 | |
55 | 55 | $params = array( |
56 | 56 | 'page' => 'gf_entries', |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | <span class="edit edit_entry"> |
65 | 65 | | |
66 | - <a title="<?php esc_attr_e( 'Edit this entry', 'gravityview'); ?>" href="<?php echo esc_url( add_query_arg( $params, admin_url( 'admin.php?page='.$query_string ) ) ); ?>"><?php esc_html_e( 'Edit', 'gravityview' ); ?></a> |
|
66 | + <a title="<?php esc_attr_e('Edit this entry', 'gravityview'); ?>" href="<?php echo esc_url(add_query_arg($params, admin_url('admin.php?page='.$query_string))); ?>"><?php esc_html_e('Edit', 'gravityview'); ?></a> |
|
67 | 67 | </span> |
68 | 68 | <?php |
69 | 69 | } |