@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | function add_hooks() { |
59 | 59 | |
60 | - add_filter( 'gravityview/admin/notices', array( $this, 'insert_admin_notices' ) ); |
|
60 | + add_filter('gravityview/admin/notices', array($this, 'insert_admin_notices')); |
|
61 | 61 | |
62 | 62 | $this->add_fallback_shortcode(); |
63 | 63 | } |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - function insert_admin_notices( $notices = array() ) { |
|
72 | - return array_merge( $notices, self::$notices ); |
|
71 | + function insert_admin_notices($notices = array()) { |
|
72 | + return array_merge($notices, self::$notices); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @return GravityView_Compatibility |
77 | 77 | */ |
78 | 78 | public static function getInstance() { |
79 | - if( self::$instance ) { |
|
79 | + if (self::$instance) { |
|
80 | 80 | return self::$instance; |
81 | 81 | } |
82 | 82 | return new self; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return bool |
88 | 88 | */ |
89 | 89 | public static function is_valid() { |
90 | - return ( self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php() ); |
|
90 | + return (self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | // If Gravity Forms doesn't exist or is outdated, load the admin view class to |
124 | 124 | // show the notice, but not load any post types or process shortcodes. |
125 | 125 | // Without Gravity Forms, there is no GravityView. Beautiful, really. |
126 | - if( ! self::is_valid() ) { |
|
126 | + if (!self::is_valid()) { |
|
127 | 127 | |
128 | 128 | // If the plugin's not loaded, might as well hide the shortcode for people. |
129 | - add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') ); |
|
129 | + add_shortcode('gravityview', array($this, '_shortcode_gf_notice')); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | } |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return null|string NULL returned if user can't activate plugins. Notice shown with a warning that GF isn't supported. |
152 | 152 | */ |
153 | - public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) { |
|
153 | + public function _shortcode_gf_notice($atts = array(), $content = null, $shortcode = 'gravityview') { |
|
154 | 154 | |
155 | - if( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
155 | + if (!GVCommon::has_cap('activate_plugins')) { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
159 | 159 | $notices = self::get_notices(); |
160 | 160 | |
161 | - $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>'; |
|
162 | - foreach( (array)$notices as $notice ) { |
|
163 | - $message .= wpautop( $notice['message'] ); |
|
161 | + $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>'.esc_html__('You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview').'</em></p>'; |
|
162 | + foreach ((array)$notices as $notice) { |
|
163 | + $message .= wpautop($notice['message']); |
|
164 | 164 | } |
165 | 165 | $message .= '</div>'; |
166 | 166 | |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * @return boolean |
176 | 176 | */ |
177 | 177 | public static function check_php() { |
178 | - if( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) ) { |
|
178 | + if (false === version_compare(phpversion(), GV_MIN_PHP_VERSION, '>=')) { |
|
179 | 179 | |
180 | 180 | self::$notices['php_version'] = array( |
181 | 181 | 'class' => 'error', |
182 | - 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
182 | + 'message' => sprintf(__("%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview'), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>'), |
|
183 | 183 | 'cap' => 'manage_options', |
184 | 184 | 'dismiss' => 'php_version', |
185 | 185 | ); |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | public static function check_wordpress() { |
200 | 200 | global $wp_version; |
201 | 201 | |
202 | - if( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) { |
|
202 | + if (version_compare($wp_version, GV_MIN_WP_VERSION) <= 0) { |
|
203 | 203 | |
204 | 204 | self::$notices['wp_version'] = array( |
205 | 205 | 'class' => 'error', |
206 | - 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
|
206 | + 'message' => sprintf(__("%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview'), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>'), |
|
207 | 207 | 'cap' => 'update_core', |
208 | 208 | 'dismiss' => 'wp_version', |
209 | 209 | ); |
@@ -226,17 +226,17 @@ discard block |
||
226 | 226 | public static function check_gravityforms() { |
227 | 227 | |
228 | 228 | // Bypass other checks: if the class exists |
229 | - if( class_exists( 'GFCommon' ) ) { |
|
229 | + if (class_exists('GFCommon')) { |
|
230 | 230 | |
231 | 231 | // and the version's right, we're good. |
232 | - if( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) { |
|
232 | + if (true === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=")) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | |
236 | 236 | // Or the version's wrong |
237 | 237 | self::$notices['gf_version'] = array( |
238 | 238 | 'class' => 'error', |
239 | - 'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
239 | + 'message' => sprintf(__("%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview'), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'), |
|
240 | 240 | 'cap' => 'update_plugins', |
241 | 241 | 'dismiss' => 'gf_version', |
242 | 242 | ); |
@@ -244,40 +244,40 @@ discard block |
||
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | |
247 | - $gf_status = self::get_plugin_status( 'gravityforms/gravityforms.php' ); |
|
247 | + $gf_status = self::get_plugin_status('gravityforms/gravityforms.php'); |
|
248 | 248 | |
249 | 249 | /** |
250 | 250 | * The plugin is activated and yet somehow GFCommon didn't get picked up... |
251 | 251 | * OR |
252 | 252 | * It's the Network Admin and we just don't know whether the sites have GF activated themselves. |
253 | 253 | */ |
254 | - if( true === $gf_status || is_network_admin() ) { |
|
254 | + if (true === $gf_status || is_network_admin()) { |
|
255 | 255 | return true; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // If GFCommon doesn't exist, assume GF not active |
259 | 259 | $return = false; |
260 | 260 | |
261 | - switch( $gf_status ) { |
|
261 | + switch ($gf_status) { |
|
262 | 262 | case 'inactive': |
263 | 263 | |
264 | 264 | // Required for multisite |
265 | - if( ! function_exists('wp_create_nonce') ) { |
|
266 | - require_once ABSPATH . WPINC . '/pluggable.php'; |
|
265 | + if (!function_exists('wp_create_nonce')) { |
|
266 | + require_once ABSPATH.WPINC.'/pluggable.php'; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" |
270 | - if( is_multisite() ) { |
|
270 | + if (is_multisite()) { |
|
271 | 271 | wp_cookie_constants(); |
272 | 272 | } |
273 | 273 | |
274 | 274 | $return = false; |
275 | 275 | |
276 | - $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; |
|
276 | + $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'.wp_nonce_url(admin_url('plugins.php?action=activate&plugin=gravityforms/gravityforms.php'), 'activate-plugin_gravityforms/gravityforms.php').'" class="button button-large">'; |
|
277 | 277 | |
278 | 278 | self::$notices['gf_inactive'] = array( |
279 | 279 | 'class' => 'error', |
280 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ), |
|
280 | + 'message' => sprintf(__('%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview'), '<h3>', "</h3>\n\n".$button, '</a></strong>'), |
|
281 | 281 | 'cap' => 'activate_plugins', |
282 | 282 | 'dismiss' => 'gf_inactive', |
283 | 283 | ); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | default: |
287 | 287 | self::$notices['gf_installed'] = array( |
288 | 288 | 'class' => 'error', |
289 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
289 | + 'message' => sprintf(__('%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview'), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'), |
|
290 | 290 | 'cap' => 'install_plugins', |
291 | 291 | 'dismiss' => 'gf_installed', |
292 | 292 | ); |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | */ |
304 | 304 | private static function check_gf_directory() { |
305 | 305 | |
306 | - if( class_exists( 'GFDirectory' ) ) { |
|
306 | + if (class_exists('GFDirectory')) { |
|
307 | 307 | self::$notices['gf_directory'] = array( |
308 | 308 | 'class' => 'error is-dismissible', |
309 | - 'title' => __('Potential Conflict', 'gravityview' ), |
|
310 | - 'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ), |
|
309 | + 'title' => __('Potential Conflict', 'gravityview'), |
|
310 | + 'message' => __('GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview'), |
|
311 | 311 | 'dismiss' => 'gf_directory', |
312 | 312 | 'cap' => 'activate_plugins', |
313 | 313 | ); |
@@ -323,23 +323,23 @@ discard block |
||
323 | 323 | * @param string $location (default: '') |
324 | 324 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
325 | 325 | */ |
326 | - public static function get_plugin_status( $location = '' ) { |
|
326 | + public static function get_plugin_status($location = '') { |
|
327 | 327 | |
328 | - if( ! function_exists('is_plugin_active') ) { |
|
329 | - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
|
328 | + if (!function_exists('is_plugin_active')) { |
|
329 | + include_once(ABSPATH.'/wp-admin/includes/plugin.php'); |
|
330 | 330 | } |
331 | 331 | |
332 | - if( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
332 | + if (is_network_admin() && is_plugin_active_for_network($location)) { |
|
333 | 333 | return true; |
334 | 334 | } |
335 | 335 | |
336 | - if( !is_network_admin() && is_plugin_active( $location ) ) { |
|
336 | + if (!is_network_admin() && is_plugin_active($location)) { |
|
337 | 337 | return true; |
338 | 338 | } |
339 | 339 | |
340 | - if( |
|
341 | - !file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
342 | - !file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
340 | + if ( |
|
341 | + !file_exists(trailingslashit(WP_PLUGIN_DIR).$location) && |
|
342 | + !file_exists(trailingslashit(WPMU_PLUGIN_DIR).$location) |
|
343 | 343 | ) { |
344 | 344 | return false; |
345 | 345 | } |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | * @since 1.15 |
52 | 52 | */ |
53 | 53 | private function add_hooks() { |
54 | - add_shortcode( 'gv_entry_link', array( $this, 'read_shortcode' ) ); |
|
55 | - add_shortcode( 'gv_edit_entry_link', array( $this, 'edit_shortcode' ) ); |
|
56 | - add_shortcode( 'gv_delete_entry_link', array( $this, 'delete_shortcode' ) ); |
|
54 | + add_shortcode('gv_entry_link', array($this, 'read_shortcode')); |
|
55 | + add_shortcode('gv_edit_entry_link', array($this, 'edit_shortcode')); |
|
56 | + add_shortcode('gv_delete_entry_link', array($this, 'delete_shortcode')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @since 1.15 |
61 | 61 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
62 | 62 | */ |
63 | - public function read_shortcode( $atts, $content = null, $context = 'gv_entry_link' ) { |
|
64 | - return $this->shortcode( $atts, $content, $context ); |
|
63 | + public function read_shortcode($atts, $content = null, $context = 'gv_entry_link') { |
|
64 | + return $this->shortcode($atts, $content, $context); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * @since 1.15 |
72 | 72 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
73 | 73 | */ |
74 | - public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) { |
|
74 | + public function edit_shortcode($atts, $content = null, $context = 'gv_edit_entry_link') { |
|
75 | 75 | $atts['action'] = 'edit'; |
76 | 76 | |
77 | - return $this->shortcode( $atts, $content, $context ); |
|
77 | + return $this->shortcode($atts, $content, $context); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | * @since 1.15 |
85 | 85 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
86 | 86 | */ |
87 | - public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) { |
|
87 | + public function delete_shortcode($atts, $content = null, $context = 'gv_delete_entry_link') { |
|
88 | 88 | $atts['action'] = 'delete'; |
89 | 89 | |
90 | - return $this->shortcode( $atts, $content, $context ); |
|
90 | + return $this->shortcode($atts, $content, $context); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -110,58 +110,58 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return null|string If admin or an error occurred, returns null. Otherwise, returns entry link output. If `$atts['return']` is 'url', the entry link URL. Otherwise, entry link `<a>` HTML tag. |
112 | 112 | */ |
113 | - private function shortcode( $atts, $content = null, $context = 'gv_entry_link' ) { |
|
113 | + private function shortcode($atts, $content = null, $context = 'gv_entry_link') { |
|
114 | 114 | |
115 | 115 | // Don't process when saving post. Keep processing if it's admin-ajax.php |
116 | - if ( ! class_exists( 'GravityView_Plugin' ) || GravityView_Plugin::is_admin() ) { |
|
116 | + if (!class_exists('GravityView_Plugin') || GravityView_Plugin::is_admin()) { |
|
117 | 117 | return null; |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Make sure GV is loaded |
121 | - if ( ! class_exists( 'GravityView_frontend' ) || ! class_exists( 'GravityView_View' ) ) { |
|
122 | - do_action( 'gravityview_log_error', __METHOD__ . ' GravityView_frontend or GravityView_View do not exist.' ); |
|
121 | + if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) { |
|
122 | + do_action('gravityview_log_error', __METHOD__.' GravityView_frontend or GravityView_View do not exist.'); |
|
123 | 123 | |
124 | 124 | return null; |
125 | 125 | } |
126 | 126 | |
127 | - $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
|
127 | + $this->settings = shortcode_atts(self::$defaults, $atts, $context); |
|
128 | 128 | |
129 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
129 | + $this->view_id = empty($this->settings['view_id']) ? GravityView_View::getInstance()->getViewId() : absint($this->settings['view_id']); |
|
130 | 130 | |
131 | - if ( empty( $this->view_id ) ) { |
|
132 | - do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' ); |
|
131 | + if (empty($this->view_id)) { |
|
132 | + do_action('gravityview_log_error', __METHOD__.' A View ID was not defined and we are not inside a View'); |
|
133 | 133 | |
134 | 134 | return null; |
135 | 135 | } |
136 | 136 | |
137 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
137 | + $this->entry = $this->get_entry($this->settings['entry_id']); |
|
138 | 138 | |
139 | - do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts ); |
|
139 | + do_action('gravityview_log_debug', __METHOD__.' '.$context.' $atts: ', $atts); |
|
140 | 140 | |
141 | - if ( ! $this->has_cap() ) { |
|
142 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings['action'] ) . ' this entry: ' . $this->entry['id'] ); |
|
141 | + if (!$this->has_cap()) { |
|
142 | + do_action('gravityview_log_error', __METHOD__.' User does not have the capability to '.esc_attr($this->settings['action']).' this entry: '.$this->entry['id']); |
|
143 | 143 | |
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $url = $this->get_url(); |
148 | 148 | |
149 | - if ( ! $url ) { |
|
150 | - do_action( 'gravityview_log_error', __METHOD__ . ' Link returned false; View or Post may not exist.' ); |
|
149 | + if (!$url) { |
|
150 | + do_action('gravityview_log_error', __METHOD__.' Link returned false; View or Post may not exist.'); |
|
151 | 151 | |
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | // Get just the URL, not the tag |
156 | - if ( 'url' === $this->settings['return'] ) { |
|
156 | + if ('url' === $this->settings['return']) { |
|
157 | 157 | return $url; |
158 | 158 | } |
159 | 159 | |
160 | 160 | $link_atts = $this->get_link_atts(); |
161 | 161 | |
162 | - $link_text = $this->get_anchor_text( $content ); |
|
162 | + $link_text = $this->get_anchor_text($content); |
|
163 | 163 | |
164 | - return gravityview_get_link( $url, $link_text, $link_atts ); |
|
164 | + return gravityview_get_link($url, $link_text, $link_atts); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -174,13 +174,13 @@ discard block |
||
174 | 174 | */ |
175 | 175 | private function get_link_atts() { |
176 | 176 | |
177 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
177 | + wp_parse_str($this->settings['link_atts'], $link_atts); |
|
178 | 178 | |
179 | - if ( 'delete' === $this->settings['action'] ) { |
|
180 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
179 | + if ('delete' === $this->settings['action']) { |
|
180 | + $link_atts['onclick'] = isset($link_atts['onclick']) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
181 | 181 | } |
182 | 182 | |
183 | - return (array) $link_atts; |
|
183 | + return (array)$link_atts; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -194,21 +194,21 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @return string Text to use for HTML anchor |
196 | 196 | */ |
197 | - private function get_anchor_text( $content = null ) { |
|
197 | + private function get_anchor_text($content = null) { |
|
198 | 198 | |
199 | - if ( $content ) { |
|
199 | + if ($content) { |
|
200 | 200 | return $content; |
201 | 201 | } |
202 | 202 | |
203 | - switch ( $this->settings['action'] ) { |
|
203 | + switch ($this->settings['action']) { |
|
204 | 204 | case 'edit': |
205 | - $anchor_text = __( 'Edit Entry', 'gravityview' ); |
|
205 | + $anchor_text = __('Edit Entry', 'gravityview'); |
|
206 | 206 | break; |
207 | 207 | case 'delete': |
208 | - $anchor_text = __( 'Delete Entry', 'gravityview' ); |
|
208 | + $anchor_text = __('Delete Entry', 'gravityview'); |
|
209 | 209 | break; |
210 | 210 | default: |
211 | - $anchor_text = __( 'View Details', 'gravityview' ); |
|
211 | + $anchor_text = __('View Details', 'gravityview'); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | return $anchor_text; |
@@ -228,21 +228,21 @@ discard block |
||
228 | 228 | private function get_url() { |
229 | 229 | |
230 | 230 | // if post_id is not defined, default to view_id |
231 | - $post_id = empty( $this->settings['post_id'] ) ? $this->view_id : absint( $this->settings['post_id'] ); |
|
231 | + $post_id = empty($this->settings['post_id']) ? $this->view_id : absint($this->settings['post_id']); |
|
232 | 232 | |
233 | - switch ( $this->settings['action'] ) { |
|
233 | + switch ($this->settings['action']) { |
|
234 | 234 | case 'edit': |
235 | - $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
|
235 | + $url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id); |
|
236 | 236 | break; |
237 | 237 | case 'delete': |
238 | - $url = GravityView_Delete_Entry::get_delete_link( $this->entry, $this->view_id, $post_id ); |
|
238 | + $url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id); |
|
239 | 239 | break; |
240 | 240 | case 'read': |
241 | 241 | default: |
242 | - $url = GravityView_API::entry_link( $this->entry, $post_id ); |
|
242 | + $url = GravityView_API::entry_link($this->entry, $post_id); |
|
243 | 243 | } |
244 | 244 | |
245 | - $url = $this->maybe_add_field_values_query_args( $url ); |
|
245 | + $url = $this->maybe_add_field_values_query_args($url); |
|
246 | 246 | |
247 | 247 | return $url; |
248 | 248 | } |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | */ |
256 | 256 | private function has_cap() { |
257 | 257 | |
258 | - switch ( $this->settings['action'] ) { |
|
258 | + switch ($this->settings['action']) { |
|
259 | 259 | case 'edit': |
260 | - $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
|
260 | + $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry($this->entry, $this->view_id); |
|
261 | 261 | break; |
262 | 262 | case 'delete': |
263 | - $has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry( $this->entry, array(), $this->view_id ); |
|
263 | + $has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry($this->entry, array(), $this->view_id); |
|
264 | 264 | break; |
265 | 265 | case 'read': |
266 | 266 | default: |
@@ -281,28 +281,28 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return array|bool Gravity Forms array, if found. Otherwise, false. |
283 | 283 | */ |
284 | - private function get_entry( $entry_id = 0 ) { |
|
284 | + private function get_entry($entry_id = 0) { |
|
285 | 285 | |
286 | 286 | $backup_entry = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getEntry() : GravityView_View::getInstance()->getCurrentEntry(); |
287 | 287 | |
288 | - if ( empty( $entry_id ) ) { |
|
289 | - if ( ! $backup_entry ) { |
|
290 | - do_action( 'gravityview_log_error', __METHOD__ . ' No entry defined (or entry id not valid number)', $this->settings ); |
|
288 | + if (empty($entry_id)) { |
|
289 | + if (!$backup_entry) { |
|
290 | + do_action('gravityview_log_error', __METHOD__.' No entry defined (or entry id not valid number)', $this->settings); |
|
291 | 291 | |
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | $entry = $backup_entry; |
295 | 295 | } else { |
296 | - $entry = wp_cache_get( 'gv_entry_link_entry_' . $entry_id, 'gravityview_entry_link_shortcode' ); |
|
297 | - if ( false === $entry ) { |
|
298 | - $entry = GVCommon::get_entry( $entry_id, true, false ); |
|
299 | - wp_cache_add( 'gv_entry_link_entry_' . $entry_id, $entry, 'gravityview_entry_link_shortcode' ); |
|
296 | + $entry = wp_cache_get('gv_entry_link_entry_'.$entry_id, 'gravityview_entry_link_shortcode'); |
|
297 | + if (false === $entry) { |
|
298 | + $entry = GVCommon::get_entry($entry_id, true, false); |
|
299 | + wp_cache_add('gv_entry_link_entry_'.$entry_id, $entry, 'gravityview_entry_link_shortcode'); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | 303 | // No search results |
304 | - if ( false === $entry ) { |
|
305 | - do_action( 'gravityview_log_error', __METHOD__ . ' No entries match the entry ID defined', $entry_id ); |
|
304 | + if (false === $entry) { |
|
305 | + do_action('gravityview_log_error', __METHOD__.' No entries match the entry ID defined', $entry_id); |
|
306 | 306 | |
307 | 307 | return false; |
308 | 308 | } |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param string $href URL |
320 | 320 | */ |
321 | - private function maybe_add_field_values_query_args( $url ) { |
|
321 | + private function maybe_add_field_values_query_args($url) { |
|
322 | 322 | |
323 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
323 | + if ($url && !empty($this->settings['field_values'])) { |
|
324 | 324 | |
325 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
325 | + wp_parse_str($this->settings['field_values'], $field_values); |
|
326 | 326 | |
327 | - $url = add_query_arg( $field_values, $url ); |
|
327 | + $url = add_query_arg($field_values, $url); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | return $url; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** If this file is called directly, abort. */ |
4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | +if (!defined('ABSPATH')) { |
|
5 | 5 | die; |
6 | 6 | } |
7 | 7 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $link_format |
76 | 76 | * @param string $after_link |
77 | 77 | */ |
78 | - function __construct( $entries = array(), $post_id = 0, $form = array(), $link_format = '', $after_link = '', $context = '' ) { |
|
78 | + function __construct($entries = array(), $post_id = 0, $form = array(), $link_format = '', $after_link = '', $context = '') { |
|
79 | 79 | |
80 | 80 | $this->entries = $entries; |
81 | 81 | $this->post_id = $post_id; |
@@ -90,28 +90,28 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @param int $post_id |
92 | 92 | */ |
93 | - public function set_post_id( $post_id ) { |
|
93 | + public function set_post_id($post_id) { |
|
94 | 94 | $this->post_id = $post_id; |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @param string $link_format |
99 | 99 | */ |
100 | - public function set_link_format( $link_format ) { |
|
100 | + public function set_link_format($link_format) { |
|
101 | 101 | $this->link_format = $link_format; |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @param boolean $skip_current_entry |
106 | 106 | */ |
107 | - public function set_skip_current_entry( $skip_current_entry ) { |
|
107 | + public function set_skip_current_entry($skip_current_entry) { |
|
108 | 108 | $this->skip_current_entry = (bool)$skip_current_entry; |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @param string $after_link |
113 | 113 | */ |
114 | - public function set_after_link( $after_link ) { |
|
114 | + public function set_after_link($after_link) { |
|
115 | 115 | $this->after_link = $after_link; |
116 | 116 | } |
117 | 117 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * Set the message when there are no entries to display |
120 | 120 | * @param string $empty_message |
121 | 121 | */ |
122 | - public function set_empty_message( $empty_message ) { |
|
122 | + public function set_empty_message($empty_message) { |
|
123 | 123 | $this->empty_message = $empty_message; |
124 | 124 | } |
125 | 125 | |
@@ -127,23 +127,23 @@ discard block |
||
127 | 127 | * Set the context in which this entry list is being displayed. |
128 | 128 | * @param string $context |
129 | 129 | */ |
130 | - public function set_context( $context ) { |
|
130 | + public function set_context($context) { |
|
131 | 131 | $this->context = $context; |
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | 135 | * @param string $wrapper_tag |
136 | 136 | */ |
137 | - public function set_wrapper_tag( $wrapper_tag ) { |
|
138 | - $this->wrapper_tag = esc_attr( $wrapper_tag ); |
|
137 | + public function set_wrapper_tag($wrapper_tag) { |
|
138 | + $this->wrapper_tag = esc_attr($wrapper_tag); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * |
143 | 143 | * @param string $item_tag |
144 | 144 | */ |
145 | - public function set_item_tag( $item_tag ) { |
|
146 | - $this->item_tag = esc_attr( $item_tag ); |
|
145 | + public function set_item_tag($item_tag) { |
|
146 | + $this->item_tag = esc_attr($item_tag); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -170,32 +170,32 @@ discard block |
||
170 | 170 | public function get_output() { |
171 | 171 | |
172 | 172 | // No Entries |
173 | - if( empty( $this->entries ) ) { |
|
173 | + if (empty($this->entries)) { |
|
174 | 174 | return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $output = ''; |
178 | 178 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
179 | 179 | |
180 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
180 | + $output .= '<'.$this->wrapper_tag.'>'; |
|
181 | 181 | |
182 | - foreach( $this->entries as $entry ) { |
|
182 | + foreach ($this->entries as $entry) { |
|
183 | 183 | |
184 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
184 | + if ($this->skip_entry($entry, $current_entry)) { |
|
185 | 185 | continue; |
186 | 186 | } |
187 | 187 | |
188 | - $output .= $this->get_item_output( $entry ); |
|
188 | + $output .= $this->get_item_output($entry); |
|
189 | 189 | } |
190 | 190 | |
191 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
191 | + $output .= '</'.$this->wrapper_tag.'>'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
195 | 195 | * @param string $output HTML to be displayed |
196 | 196 | * @param GravityView_Entry_List $this The current class instance |
197 | 197 | */ |
198 | - $output = apply_filters( 'gravityview/widget/recent-entries/output', $output, $this ); |
|
198 | + $output = apply_filters('gravityview/widget/recent-entries/output', $output, $this); |
|
199 | 199 | |
200 | 200 | return $output; |
201 | 201 | } |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return bool True: Skip entry; False: don't skip entry |
210 | 210 | */ |
211 | - private function skip_entry( $entry, $current_entry ) { |
|
211 | + private function skip_entry($entry, $current_entry) { |
|
212 | 212 | |
213 | 213 | // If skip entry is off, or there's no current entry, return false |
214 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
214 | + if (empty($this->skip_current_entry) || empty($current_entry)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // If in Single or Edit mode, $current_entry will be an array. |
219 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
219 | + $current_entry_id = is_array($current_entry) ? $current_entry['id'] : $current_entry; |
|
220 | 220 | |
221 | 221 | // If the entry ID matches the current entry, yes: skip |
222 | - if( $entry['id'] === $current_entry_id ) { |
|
222 | + if ($entry['id'] === $current_entry_id) { |
|
223 | 223 | return true; |
224 | 224 | } |
225 | 225 | |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return string HTML output for the entry |
242 | 242 | */ |
243 | - private function get_item_output( $entry ) { |
|
243 | + private function get_item_output($entry) { |
|
244 | 244 | |
245 | - $link = GravityView_API::entry_link( $entry, $this->post_id ); |
|
245 | + $link = GravityView_API::entry_link($entry, $this->post_id); |
|
246 | 246 | |
247 | - $item_output = gravityview_get_link( $link, $this->link_format ); |
|
247 | + $item_output = gravityview_get_link($link, $this->link_format); |
|
248 | 248 | |
249 | - if( !empty( $this->after_link ) ) { |
|
249 | + if (!empty($this->after_link)) { |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | * @param array $entry Gravity Forms entry array |
256 | 256 | * @param GravityView_Entry_List $this The current class instance |
257 | 257 | */ |
258 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
258 | + $after_link = apply_filters('gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this); |
|
259 | 259 | |
260 | 260 | $item_output .= $after_link; |
261 | 261 | } |
262 | 262 | |
263 | - $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
|
263 | + $item_output = GravityView_API::replace_variables($item_output, $this->form, $entry); |
|
264 | 264 | |
265 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
265 | + $item_output = '<'.$this->item_tag.'>'.$item_output.'</'.$this->item_tag.'>'; |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param array $entry Gravity Forms entry array |
272 | 272 | * @param GravityView_Entry_List $this The current class instance |
273 | 273 | */ |
274 | - $item_output = apply_filters( 'gravityview/entry-list/item', $item_output, $entry, $this ); |
|
274 | + $item_output = apply_filters('gravityview/entry-list/item', $item_output, $entry, $this); |
|
275 | 275 | |
276 | 276 | return $item_output; |
277 | 277 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @since 1.15 |
18 | 18 | */ |
19 | 19 | private function add_hooks() { |
20 | - add_filter( 'gform_notes_avatar', array( 'GravityView_Entry_Notes', 'filter_avatar' ), 10, 2 ); |
|
20 | + add_filter('gform_notes_avatar', array('GravityView_Entry_Notes', 'filter_avatar'), 10, 2); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $note Note content. |
32 | 32 | * @param string $note_type Type of note. Default: `gravityview` |
33 | 33 | */ |
34 | - public static function add_note( $lead_id, $user_id, $user_name, $note = '', $note_type = 'gravityview' ) { |
|
34 | + public static function add_note($lead_id, $user_id, $user_name, $note = '', $note_type = 'gravityview') { |
|
35 | 35 | |
36 | 36 | $default_note = array( |
37 | 37 | 'lead_id' => 0, |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @since 1.15.2 |
48 | 48 | * @param array $note Array with `lead_id`, `user_id`, `user_name`, `note`, and `note_type` key value pairs |
49 | 49 | */ |
50 | - $note = apply_filters( 'gravityview/entry_notes/add_note', compact( 'lead_id', 'user_id', 'user_name', 'note', 'note_type' ) ); |
|
50 | + $note = apply_filters('gravityview/entry_notes/add_note', compact('lead_id', 'user_id', 'user_name', 'note', 'note_type')); |
|
51 | 51 | |
52 | 52 | // Make sure the keys are all set |
53 | - $note = wp_parse_args( $note, $default_note ); |
|
53 | + $note = wp_parse_args($note, $default_note); |
|
54 | 54 | |
55 | - GFFormsModel::add_note( intval( $note['lead_id'] ), intval( $note['user_id'] ), esc_attr( $note['user_name'] ), $note['note'], esc_attr( $note['note_type'] ) ); |
|
55 | + GFFormsModel::add_note(intval($note['lead_id']), intval($note['user_id']), esc_attr($note['user_name']), $note['note'], esc_attr($note['note_type'])); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @see GFFormsModel::delete_note() |
61 | 61 | * @param int $note_id Entry note ID |
62 | 62 | */ |
63 | - public static function delete_note( $note_id ) { |
|
64 | - GFFormsModel::delete_note( $note_id ); |
|
63 | + public static function delete_note($note_id) { |
|
64 | + GFFormsModel::delete_note($note_id); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | * @todo Write more efficient delete note method using SQL |
71 | 71 | * @param int[] $note_ids Array of entry note ids |
72 | 72 | */ |
73 | - public static function delete_notes( $note_ids = array() ) { |
|
73 | + public static function delete_notes($note_ids = array()) { |
|
74 | 74 | |
75 | - if( !is_array( $note_ids ) ) { |
|
76 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Note IDs not an array', $note_ids ); |
|
75 | + if (!is_array($note_ids)) { |
|
76 | + do_action('gravityview_log_error', __METHOD__.' - Note IDs not an array', $note_ids); |
|
77 | 77 | } |
78 | 78 | |
79 | - GFFormsModel::delete_notes( $note_ids ); |
|
79 | + GFFormsModel::delete_notes($note_ids); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return stdClass[] Integer-keyed array of note objects |
89 | 89 | */ |
90 | - public static function get_notes( $entry_id ) { |
|
91 | - $notes = GFFormsModel::get_lead_notes( $entry_id ); |
|
90 | + public static function get_notes($entry_id) { |
|
91 | + $notes = GFFormsModel::get_lead_notes($entry_id); |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @filter `gravityview/entry_notes/get_notes` Modify the notes array for an entry |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param stdClass[] $notes Integer-keyed array of note objects |
97 | 97 | * @param int $entry_id Entry to get notes for |
98 | 98 | */ |
99 | - $notes = apply_filters( 'gravityview/entry_notes/get_notes', $notes, $entry_id ); |
|
99 | + $notes = apply_filters('gravityview/entry_notes/get_notes', $notes, $entry_id); |
|
100 | 100 | |
101 | 101 | return $notes; |
102 | 102 | } |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | * @param object $note Note object with id, user_id, date_created, value, note_type, user_name, user_email vars |
110 | 110 | * @return string Possibly-modified avatar |
111 | 111 | */ |
112 | - public static function filter_avatar( $avatar = '', $note ) { |
|
112 | + public static function filter_avatar($avatar = '', $note) { |
|
113 | 113 | |
114 | - if( 'gravityview' === $note->note_type && -1 === (int)$note->user_id ) { |
|
115 | - $avatar = sprintf( '<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw( plugins_url( 'assets/images/floaty-avatar.png', GRAVITYVIEW_FILE ) ) ); |
|
114 | + if ('gravityview' === $note->note_type && -1 === (int)$note->user_id) { |
|
115 | + $avatar = sprintf('<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw(plugins_url('assets/images/floaty-avatar.png', GRAVITYVIEW_FILE))); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $avatar; |
@@ -69,22 +69,22 @@ discard block |
||
69 | 69 | |
70 | 70 | function __construct() { |
71 | 71 | |
72 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
72 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
73 | 73 | |
74 | - add_action( 'admin_init', array( $this, 'settings') ); |
|
74 | + add_action('admin_init', array($this, 'settings')); |
|
75 | 75 | |
76 | - add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
76 | + add_action('admin_notices', array($this, 'admin_notice'), 100); |
|
77 | 77 | |
78 | - add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) ); |
|
78 | + add_action('gravityview/metaboxes/before_render', array($this, 'add_metabox_tab')); |
|
79 | 79 | |
80 | - if( false === $this->is_extension_supported() ) { |
|
80 | + if (false === $this->is_extension_supported()) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
|
84 | + add_filter('gravityview_tooltips', array($this, 'tooltips')); |
|
85 | 85 | |
86 | 86 | // Save the form configuration. Run at 14 so that View metadata is already saved (at 10) |
87 | - add_action( 'save_post', array( $this, 'save_post' ), 14 ); |
|
87 | + add_action('save_post', array($this, 'save_post'), 14); |
|
88 | 88 | |
89 | 89 | $this->add_hooks(); |
90 | 90 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $tab_settings = $this->tab_settings(); |
117 | 117 | |
118 | 118 | // Don't add a tab if it's empty. |
119 | - if( empty( $tab_settings ) ) { |
|
119 | + if (empty($tab_settings)) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | 'priority' => 'default', |
132 | 132 | ); |
133 | 133 | |
134 | - $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
|
134 | + $tab = wp_parse_args($tab_settings, $tab_defaults); |
|
135 | 135 | |
136 | 136 | // Force the screen to be GravityView |
137 | 137 | $tab['screen'] = 'gravityview'; |
138 | 138 | |
139 | - if( class_exists('GravityView_Metabox_Tab') ) { |
|
139 | + if (class_exists('GravityView_Metabox_Tab')) { |
|
140 | 140 | |
141 | - $metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
141 | + $metabox = new GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']); |
|
142 | 142 | |
143 | - GravityView_Metabox_Tabs::add( $metabox ); |
|
143 | + GravityView_Metabox_Tabs::add($metabox); |
|
144 | 144 | |
145 | 145 | } else { |
146 | 146 | |
147 | - add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
147 | + add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | } |
@@ -160,37 +160,37 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function load_plugin_textdomain() { |
162 | 162 | |
163 | - if( empty( $this->_text_domain ) ) { |
|
164 | - do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this ); |
|
163 | + if (empty($this->_text_domain)) { |
|
164 | + do_action('gravityview_log_debug', __METHOD__.': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this); |
|
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Backward compat for Ratings & Reviews / Maps |
169 | - $path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file : '' ); |
|
169 | + $path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : ''); |
|
170 | 170 | |
171 | 171 | // Set filter for plugin's languages directory |
172 | - $lang_dir = dirname( plugin_basename( $path ) ) . '/languages/'; |
|
172 | + $lang_dir = dirname(plugin_basename($path)).'/languages/'; |
|
173 | 173 | |
174 | 174 | // Traditional WordPress plugin locale filter |
175 | - $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
175 | + $locale = apply_filters('plugin_locale', get_locale(), $this->_text_domain); |
|
176 | 176 | |
177 | - $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
|
177 | + $mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale); |
|
178 | 178 | |
179 | 179 | // Setup paths to current locale file |
180 | - $mofile_local = $lang_dir . $mofile; |
|
181 | - $mofile_global = WP_LANG_DIR . '/' . $this->_text_domain . '/' . $mofile; |
|
180 | + $mofile_local = $lang_dir.$mofile; |
|
181 | + $mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile; |
|
182 | 182 | |
183 | - if ( file_exists( $mofile_global ) ) { |
|
183 | + if (file_exists($mofile_global)) { |
|
184 | 184 | // Look in global /wp-content/languages/[plugin-dir]/ folder |
185 | - load_textdomain( $this->_text_domain, $mofile_global ); |
|
185 | + load_textdomain($this->_text_domain, $mofile_global); |
|
186 | 186 | } |
187 | - elseif ( file_exists( $mofile_local ) ) { |
|
187 | + elseif (file_exists($mofile_local)) { |
|
188 | 188 | // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder |
189 | - load_textdomain( $this->_text_domain, $mofile_local ); |
|
189 | + load_textdomain($this->_text_domain, $mofile_local); |
|
190 | 190 | } |
191 | 191 | else { |
192 | 192 | // Load the default language files |
193 | - load_plugin_textdomain( $this->_text_domain, false, $lang_dir ); |
|
193 | + load_plugin_textdomain($this->_text_domain, false, $lang_dir); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function get_license() { |
204 | 204 | |
205 | - if( !class_exists( 'GravityView_Settings' ) ) { |
|
205 | + if (!class_exists('GravityView_Settings')) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | public function settings() { |
220 | 220 | |
221 | 221 | // If doing ajax, get outta here |
222 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
222 | + if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
226 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
227 | 227 | |
228 | - $file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php'; |
|
228 | + $file_path = plugin_dir_path(__FILE__).'lib/EDD_SL_Plugin_Updater.php'; |
|
229 | 229 | |
230 | 230 | // This file may be in the lib/ directory already |
231 | - if( ! file_exists( $file_path ) ) { |
|
232 | - $file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php'; |
|
231 | + if (!file_exists($file_path)) { |
|
232 | + $file_path = plugin_dir_path(__FILE__).'/EDD_SL_Plugin_Updater.php'; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | include_once $file_path; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $license = $this->get_license(); |
239 | 239 | |
240 | 240 | // Don't update if invalid license. |
241 | - if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; } |
|
241 | + if (false === $license || empty($license['status']) || strtolower($license['status']) !== 'valid') { return; } |
|
242 | 242 | |
243 | 243 | new EDD_SL_Plugin_Updater( |
244 | 244 | $this->_remote_update_url, |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | 'version' => $this->_version, // current version number |
248 | 248 | 'license' => $license['license'], |
249 | 249 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
250 | - 'item_name' => $this->_title, // name of this plugin |
|
251 | - 'author' => strip_tags( $this->_author ) // author of this plugin |
|
250 | + 'item_name' => $this->_title, // name of this plugin |
|
251 | + 'author' => strip_tags($this->_author) // author of this plugin |
|
252 | 252 | ) |
253 | 253 | ); |
254 | 254 | } |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function admin_notice() { |
262 | 262 | |
263 | - if( empty( self::$admin_notices ) ) { |
|
263 | + if (empty(self::$admin_notices)) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - foreach( self::$admin_notices as $key => $notice ) { |
|
267 | + foreach (self::$admin_notices as $key => $notice) { |
|
268 | 268 | |
269 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
270 | - echo wpautop( $notice['message'] ); |
|
269 | + echo '<div id="message" class="'.esc_attr($notice['class']).'">'; |
|
270 | + echo wpautop($notice['message']); |
|
271 | 271 | echo '<div class="clear"></div>'; |
272 | 272 | echo '</div>'; |
273 | 273 | } |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | * Add a notice to be displayed in the admin. |
281 | 281 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
282 | 282 | */ |
283 | - public static function add_notice( $notice = array() ) { |
|
283 | + public static function add_notice($notice = array()) { |
|
284 | 284 | |
285 | - if( is_array( $notice ) && !isset( $notice['message'] ) ) { |
|
286 | - do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice ); |
|
285 | + if (is_array($notice) && !isset($notice['message'])) { |
|
286 | + do_action('gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice); |
|
287 | 287 | return; |
288 | - } else if( is_string( $notice ) ) { |
|
289 | - $notice = array( 'message' => $notice ); |
|
288 | + } else if (is_string($notice)) { |
|
289 | + $notice = array('message' => $notice); |
|
290 | 290 | } |
291 | 291 | |
292 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
292 | + $notice['class'] = empty($notice['class']) ? 'error' : $notice['class']; |
|
293 | 293 | |
294 | 294 | self::$admin_notices[] = $notice; |
295 | 295 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param int $post_id Post ID |
305 | 305 | * @return void |
306 | 306 | */ |
307 | - public function save_post( $post_id ) {} |
|
307 | + public function save_post($post_id) {} |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * Add tooltips for the extension. |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param array $tooltips Existing GV tooltips, with `title` and `value` keys |
324 | 324 | * @return array Modified tooltips |
325 | 325 | */ |
326 | - public function tooltips( $tooltips = array() ) { |
|
326 | + public function tooltips($tooltips = array()) { |
|
327 | 327 | |
328 | 328 | return $tooltips; |
329 | 329 | |
@@ -346,17 +346,17 @@ discard block |
||
346 | 346 | |
347 | 347 | $message = ''; |
348 | 348 | |
349 | - if( !class_exists( 'GravityView_Plugin' ) ) { |
|
349 | + if (!class_exists('GravityView_Plugin')) { |
|
350 | 350 | |
351 | - $message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title ); |
|
351 | + $message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title); |
|
352 | 352 | |
353 | - } else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) { |
|
353 | + } else if (false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version, ">=")) { |
|
354 | 354 | |
355 | - $message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
355 | + $message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>'); |
|
356 | 356 | |
357 | - } else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) { |
|
357 | + } else if (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, ">=")) { |
|
358 | 358 | |
359 | - $message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' ); |
|
359 | + $message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), $this->_title, '<tt>'.$this->_min_php_version.'</tt>'); |
|
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | |
365 | 365 | } |
366 | 366 | |
367 | - if ( ! empty( $message ) ) { |
|
367 | + if (!empty($message)) { |
|
368 | 368 | |
369 | - self::add_notice( $message ); |
|
369 | + self::add_notice($message); |
|
370 | 370 | |
371 | - do_action( 'gravityview_log_error', __METHOD__. ' ' . $message ); |
|
371 | + do_action('gravityview_log_error', __METHOD__.' '.$message); |
|
372 | 372 | |
373 | 373 | self::$is_compatible = false; |
374 | 374 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | - function __construct( $atts = array() ) { |
|
52 | + function __construct($atts = array()) { |
|
53 | 53 | |
54 | 54 | $defaults = array( |
55 | 55 | 'width' => $this->width, |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | 'validate_src' => true |
64 | 64 | ); |
65 | 65 | |
66 | - $atts = wp_parse_args( $atts, $defaults ); |
|
66 | + $atts = wp_parse_args($atts, $defaults); |
|
67 | 67 | |
68 | - foreach( $atts as $key => $val ) { |
|
68 | + foreach ($atts as $key => $val) { |
|
69 | 69 | $this->{$key} = $val; |
70 | 70 | } |
71 | 71 | |
72 | - $this->class = !empty( $this->class ) ? esc_attr( implode( ' ', (array)$this->class ) ) : $this->class; |
|
72 | + $this->class = !empty($this->class) ? esc_attr(implode(' ', (array)$this->class)) : $this->class; |
|
73 | 73 | |
74 | 74 | $this->set_image_size(); |
75 | 75 | |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function validate_image_src() { |
87 | 87 | |
88 | - if ( !$this->validate_src ) { return true; } |
|
88 | + if (!$this->validate_src) { return true; } |
|
89 | 89 | |
90 | - $info = pathinfo( $this->src ); |
|
90 | + $info = pathinfo($this->src); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @filter `gravityview_image_extensions` Extensions that GravityView recognizes as valid images to be shown in an `img` tag |
94 | 94 | * @param array $image_exts Default: `['jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico']` |
95 | 95 | */ |
96 | - $image_exts = apply_filters( 'gravityview_image_extensions', array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' )); |
|
96 | + $image_exts = apply_filters('gravityview_image_extensions', array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico')); |
|
97 | 97 | |
98 | - return isset( $info['extension'] ) && in_array( strtolower( $info['extension'] ), $image_exts); |
|
98 | + return isset($info['extension']) && in_array(strtolower($info['extension']), $image_exts); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return void |
105 | 105 | */ |
106 | - public function set_image_size( $string = NULL, $width = NULL, $height = NULL ) { |
|
106 | + public function set_image_size($string = NULL, $width = NULL, $height = NULL) { |
|
107 | 107 | |
108 | 108 | |
109 | 109 | // If there is no width or height passed |
110 | - if ( empty( $width ) || empty( $height ) ) { |
|
110 | + if (empty($width) || empty($height)) { |
|
111 | 111 | |
112 | 112 | // And there is no string size passed |
113 | 113 | // And we want to get the image size using PHP |
114 | - if ( empty( $string ) && !empty( $this->getimagesize ) ) { |
|
114 | + if (empty($string) && !empty($this->getimagesize)) { |
|
115 | 115 | |
116 | - $image_size = getimagesize( $this->src ); |
|
116 | + $image_size = getimagesize($this->src); |
|
117 | 117 | |
118 | - if ( !empty( $image_size ) ) { |
|
119 | - list( $width, $height ) = $image_size; |
|
118 | + if (!empty($image_size)) { |
|
119 | + list($width, $height) = $image_size; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | } |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | * @filter `gravityview_image_sizes` Modify the image size presets used by GravityView_Image class |
128 | 128 | * @param array $image_sizes Array of image sizes with the key being the size slug, and the value being an array with `width` and `height` defined, in pixels |
129 | 129 | */ |
130 | - $image_sizes = apply_filters( 'gravityview_image_sizes', array( |
|
130 | + $image_sizes = apply_filters('gravityview_image_sizes', array( |
|
131 | 131 | 'tiny' => array('width' => 40, 'height' => 30), |
132 | 132 | 'small' => array('width' => 100, 'height' => 75), |
133 | 133 | 'medium' => array('width' => 250, 'height' => 188), |
134 | 134 | 'large' => array('width' => 448, 'height' => 336), |
135 | - ) ); |
|
135 | + )); |
|
136 | 136 | |
137 | - switch( $this->size ) { |
|
137 | + switch ($this->size) { |
|
138 | 138 | case 'tiny': |
139 | 139 | extract($image_sizes['tiny']); |
140 | 140 | break; |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | break; |
154 | 154 | default: |
155 | 155 | // Verify that the passed sizes are integers. |
156 | - $width = !empty( $width ) ? intval( $width ) : intval( $this->width ); |
|
157 | - $height = !empty( $height ) ? intval( $height ) : intval( $this->height ); |
|
156 | + $width = !empty($width) ? intval($width) : intval($this->width); |
|
157 | + $height = !empty($height) ? intval($height) : intval($this->height); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function html() { |
173 | 173 | |
174 | - if ( ! $this->validate_image_src() ) { |
|
174 | + if (!$this->validate_image_src()) { |
|
175 | 175 | $html = ''; |
176 | 176 | } else { |
177 | 177 | $atts = ''; |
178 | - foreach ( array( 'width', 'height', 'alt', 'title', 'class' ) as $attr ) { |
|
178 | + foreach (array('width', 'height', 'alt', 'title', 'class') as $attr) { |
|
179 | 179 | |
180 | - if ( empty( $this->{$attr} ) ) { continue; } |
|
180 | + if (empty($this->{$attr} )) { continue; } |
|
181 | 181 | |
182 | - $atts .= sprintf( ' %s="%s"', $attr, esc_attr( $this->{$attr} ) ); |
|
182 | + $atts .= sprintf(' %s="%s"', $attr, esc_attr($this->{$attr} )); |
|
183 | 183 | } |
184 | 184 | |
185 | - $html = sprintf( '<img src="%s" %s />', esc_url_raw( $this->src ), $atts ); |
|
185 | + $html = sprintf('<img src="%s" %s />', esc_url_raw($this->src), $atts); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -190,6 +190,6 @@ discard block |
||
190 | 190 | * @param string $html the generated image html |
191 | 191 | * @param GravityView_Image $this The current image object |
192 | 192 | */ |
193 | - return apply_filters( 'gravityview_image_html', $html, $this ); |
|
193 | + return apply_filters('gravityview_image_html', $html, $this); |
|
194 | 194 | } |
195 | 195 | } |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | |
8 | 8 | function __construct() { |
9 | 9 | |
10 | - add_action( 'gravityview_log_error', array( $this, 'log_error'), 10, 2 ); |
|
10 | + add_action('gravityview_log_error', array($this, 'log_error'), 10, 2); |
|
11 | 11 | |
12 | - add_action( 'gravityview_log_debug', array( $this, 'log_debug'), 10, 2 ); |
|
12 | + add_action('gravityview_log_debug', array($this, 'log_debug'), 10, 2); |
|
13 | 13 | |
14 | 14 | // Enable debug with Gravity Forms Logging Add-on |
15 | - add_filter( 'gform_logging_supported', array( $this, 'enable_gform_logging' ) ); |
|
15 | + add_filter('gform_logging_supported', array($this, 'enable_gform_logging')); |
|
16 | 16 | |
17 | 17 | // Load Debug Bar integration |
18 | - add_filter( 'debug_bar_panels', array( $this, 'add_debug_bar' ) ); |
|
18 | + add_filter('debug_bar_panels', array($this, 'add_debug_bar')); |
|
19 | 19 | |
20 | 20 | } |
21 | 21 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @see http://wordpress.org/plugins/debug-bar/ |
26 | 26 | */ |
27 | - public function add_debug_bar( $panels ) { |
|
27 | + public function add_debug_bar($panels) { |
|
28 | 28 | |
29 | - if ( ! class_exists( 'Debug_Bar_Panel' ) ) { |
|
29 | + if (!class_exists('Debug_Bar_Panel')) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | - if ( ! class_exists( 'GravityView_Debug_Bar' ) ) { |
|
34 | - include_once( GRAVITYVIEW_DIR . 'includes/class-debug-bar.php' ); |
|
33 | + if (!class_exists('GravityView_Debug_Bar')) { |
|
34 | + include_once(GRAVITYVIEW_DIR.'includes/class-debug-bar.php'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $panels[] = new GravityView_Debug_Bar; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * Enables debug with Gravity Forms logging add-on |
44 | 44 | * @param array $supported_plugins List of plugins |
45 | 45 | */ |
46 | - public function enable_gform_logging( $supported_plugins ) { |
|
46 | + public function enable_gform_logging($supported_plugins) { |
|
47 | 47 | $supported_plugins['gravityview'] = 'GravityView'; |
48 | 48 | return $supported_plugins; |
49 | 49 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @return string "print_r" or "var_export" |
73 | 73 | */ |
74 | 74 | static function get_print_function() { |
75 | - if( ob_get_level() > 0 ) { |
|
75 | + if (ob_get_level() > 0) { |
|
76 | 76 | $function = 'var_export'; |
77 | 77 | } else { |
78 | 78 | $function = 'print_r'; |
@@ -81,43 +81,43 @@ discard block |
||
81 | 81 | return $function; |
82 | 82 | } |
83 | 83 | |
84 | - static function log_debug( $message = '', $data = null ) { |
|
84 | + static function log_debug($message = '', $data = null) { |
|
85 | 85 | |
86 | 86 | $function = self::get_print_function(); |
87 | 87 | |
88 | 88 | $notice = array( |
89 | - 'message' => $function( $message, true ), |
|
89 | + 'message' => $function($message, true), |
|
90 | 90 | 'data' => $data, |
91 | - 'backtrace' => function_exists('wp_debug_backtrace_summary') ? wp_debug_backtrace_summary( null, 3 ) : '', |
|
91 | + 'backtrace' => function_exists('wp_debug_backtrace_summary') ? wp_debug_backtrace_summary(null, 3) : '', |
|
92 | 92 | ); |
93 | 93 | |
94 | - if( !in_array( $notice, self::$notices ) ) { |
|
94 | + if (!in_array($notice, self::$notices)) { |
|
95 | 95 | self::$notices[] = $notice; |
96 | 96 | } |
97 | 97 | |
98 | - if ( class_exists("GFLogging") ) { |
|
98 | + if (class_exists("GFLogging")) { |
|
99 | 99 | GFLogging::include_logger(); |
100 | - GFLogging::log_message( 'gravityview', $function( $message, true ) . $function($data, true), KLogger::DEBUG ); |
|
100 | + GFLogging::log_message('gravityview', $function($message, true).$function($data, true), KLogger::DEBUG); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - static function log_error( $message = '', $data = null ) { |
|
104 | + static function log_error($message = '', $data = null) { |
|
105 | 105 | |
106 | 106 | $function = self::get_print_function(); |
107 | 107 | |
108 | 108 | $error = array( |
109 | 109 | 'message' => $message, |
110 | 110 | 'data' => $data, |
111 | - 'backtrace' => function_exists('wp_debug_backtrace_summary') ? wp_debug_backtrace_summary( null, 3 ) : '', |
|
111 | + 'backtrace' => function_exists('wp_debug_backtrace_summary') ? wp_debug_backtrace_summary(null, 3) : '', |
|
112 | 112 | ); |
113 | 113 | |
114 | - if( !in_array( $error, self::$errors ) ) { |
|
114 | + if (!in_array($error, self::$errors)) { |
|
115 | 115 | self::$errors[] = $error; |
116 | 116 | } |
117 | 117 | |
118 | - if ( class_exists("GFLogging") ) { |
|
118 | + if (class_exists("GFLogging")) { |
|
119 | 119 | GFLogging::include_logger(); |
120 | - GFLogging::log_message( 'gravityview', $function ( $message, true ) . $function ($data, true), KLogger::ERROR ); |
|
120 | + GFLogging::log_message('gravityview', $function($message, true).$function($data, true), KLogger::ERROR); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | class GravityView_Migrate { |
16 | 16 | |
17 | 17 | function __construct() { |
18 | - add_action( 'admin_init', array( $this, 'update_settings' ), 1 ); |
|
18 | + add_action('admin_init', array($this, 'update_settings'), 1); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function update_settings() { |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | private function maybe_migrate_search_widget() { |
33 | 33 | |
34 | 34 | // check if search migration is already performed |
35 | - $is_updated = get_option( 'gv_migrate_searchwidget' ); |
|
36 | - if ( $is_updated ) { |
|
35 | + $is_updated = get_option('gv_migrate_searchwidget'); |
|
36 | + if ($is_updated) { |
|
37 | 37 | return; |
38 | 38 | } else { |
39 | 39 | $this->update_search_on_views(); |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | $redux_settings = $this->get_redux_settings(); |
52 | 52 | |
53 | 53 | // No need to process |
54 | - if( false === $redux_settings ) { |
|
54 | + if (false === $redux_settings) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | - if( empty( $redux_settings['license_key_status'] ) ) { |
|
59 | - $redux_settings = $this->get_redux_license_status( $redux_settings ); |
|
58 | + if (empty($redux_settings['license_key_status'])) { |
|
59 | + $redux_settings = $this->get_redux_license_status($redux_settings); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Get the current app settings (just defaults) |
63 | 63 | $current = GravityView_Settings::get_instance()->get_app_settings(); |
64 | 64 | |
65 | 65 | // Merge the redux settings with the defaults |
66 | - $updated_settings = wp_parse_args( $redux_settings, $current ); |
|
66 | + $updated_settings = wp_parse_args($redux_settings, $current); |
|
67 | 67 | |
68 | 68 | // Update the defaults to the new merged |
69 | - GravityView_Settings::get_instance()->update_app_settings( $updated_settings ); |
|
69 | + GravityView_Settings::get_instance()->update_app_settings($updated_settings); |
|
70 | 70 | |
71 | 71 | // And now remove the previous option, so this is a one-time thing. |
72 | 72 | delete_option('gravityview_settings'); |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - function get_redux_license_status( $redux_settings = array() ) { |
|
85 | + function get_redux_license_status($redux_settings = array()) { |
|
86 | 86 | |
87 | 87 | $data = array( |
88 | 88 | 'edd_action' => 'check_license', |
89 | - 'license' => rgget('license_key', $redux_settings ), |
|
89 | + 'license' => rgget('license_key', $redux_settings), |
|
90 | 90 | 'update' => false, |
91 | 91 | 'format' => 'object', |
92 | 92 | ); |
93 | 93 | |
94 | - $license_call = GravityView_Settings::get_instance()->get_license_handler()->license_call( $data ); |
|
94 | + $license_call = GravityView_Settings::get_instance()->get_license_handler()->license_call($data); |
|
95 | 95 | |
96 | - if( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
96 | + if (is_object($license_call) && isset($license_call->license)) { |
|
97 | 97 | $redux_settings['license_key_status'] = $license_call->license; |
98 | - $redux_settings['license_key_response'] = json_encode( $license_call ); |
|
98 | + $redux_settings['license_key_response'] = json_encode($license_call); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $redux_settings; |
@@ -112,31 +112,31 @@ discard block |
||
112 | 112 | $redux_option = get_option('gravityview_settings'); |
113 | 113 | |
114 | 114 | // No Redux settings? Don't proceed. |
115 | - if( false === $redux_option ) { |
|
115 | + if (false === $redux_option) { |
|
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | 120 | $redux_settings = array( |
121 | - 'support-email' => rgget( 'support-email', $redux_option ), |
|
122 | - 'no-conflict-mode' => ( rgget( 'no-conflict-mode', $redux_option ) ? '1' : '0' ), |
|
121 | + 'support-email' => rgget('support-email', $redux_option), |
|
122 | + 'no-conflict-mode' => (rgget('no-conflict-mode', $redux_option) ? '1' : '0'), |
|
123 | 123 | ); |
124 | 124 | |
125 | - if( $license_array = rgget( 'license', $redux_option ) ) { |
|
125 | + if ($license_array = rgget('license', $redux_option)) { |
|
126 | 126 | |
127 | - $redux_settings['license_key'] = $license_key = rgget( 'license', $license_array ); |
|
127 | + $redux_settings['license_key'] = $license_key = rgget('license', $license_array); |
|
128 | 128 | |
129 | 129 | $redux_last_changed_values = get_option('gravityview_settings-transients'); |
130 | 130 | |
131 | 131 | // This contains the last response for license validation |
132 | - if( !empty( $redux_last_changed_values ) && $saved_values = rgget( 'changed_values', $redux_last_changed_values ) ) { |
|
132 | + if (!empty($redux_last_changed_values) && $saved_values = rgget('changed_values', $redux_last_changed_values)) { |
|
133 | 133 | |
134 | - $saved_license = rgget('license', $saved_values ); |
|
134 | + $saved_license = rgget('license', $saved_values); |
|
135 | 135 | |
136 | 136 | // Only use the last-saved values if they are for the same license |
137 | - if( $saved_license && rgget( 'license', $saved_license ) === $license_key ) { |
|
138 | - $redux_settings['license_key_status'] = rgget( 'status', $saved_license ); |
|
139 | - $redux_settings['license_key_response'] = rgget( 'response', $saved_license ); |
|
137 | + if ($saved_license && rgget('license', $saved_license) === $license_key) { |
|
138 | + $redux_settings['license_key_status'] = rgget('status', $saved_license); |
|
139 | + $redux_settings['license_key_response'] = rgget('response', $saved_license); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | /** ---- Migrate from old search widget to new search widget ---- */ |
149 | 149 | function update_search_on_views() { |
150 | 150 | |
151 | - if( !class_exists('GravityView_Widget_Search') ) { |
|
152 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' ); |
|
151 | + if (!class_exists('GravityView_Widget_Search')) { |
|
152 | + include_once(GRAVITYVIEW_DIR.'includes/extensions/search-widget/class-search-widget.php'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // Loop through all the views |
@@ -159,94 +159,94 @@ discard block |
||
159 | 159 | 'posts_per_page' => -1, |
160 | 160 | ); |
161 | 161 | |
162 | - $views = get_posts( $query_args ); |
|
162 | + $views = get_posts($query_args); |
|
163 | 163 | |
164 | - foreach( $views as $view ) { |
|
164 | + foreach ($views as $view) { |
|
165 | 165 | |
166 | - $widgets = get_post_meta( $view->ID, '_gravityview_directory_widgets', true ); |
|
166 | + $widgets = get_post_meta($view->ID, '_gravityview_directory_widgets', true); |
|
167 | 167 | $search_fields = null; |
168 | 168 | |
169 | - if( empty( $widgets ) || !is_array( $widgets ) ) { continue; } |
|
169 | + if (empty($widgets) || !is_array($widgets)) { continue; } |
|
170 | 170 | |
171 | - do_action( 'gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Loading View ID: ', $view->ID ); |
|
171 | + do_action('gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Loading View ID: ', $view->ID); |
|
172 | 172 | |
173 | - foreach( $widgets as $area => $ws ) { |
|
174 | - foreach( $ws as $k => $widget ) { |
|
175 | - if( $widget['id'] !== 'search_bar' ) { continue; } |
|
173 | + foreach ($widgets as $area => $ws) { |
|
174 | + foreach ($ws as $k => $widget) { |
|
175 | + if ($widget['id'] !== 'search_bar') { continue; } |
|
176 | 176 | |
177 | - if( is_null( $search_fields ) ) { |
|
178 | - $search_fields = $this->get_search_fields( $view->ID ); |
|
177 | + if (is_null($search_fields)) { |
|
178 | + $search_fields = $this->get_search_fields($view->ID); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // check widget settings: |
182 | 182 | // [search_free] => 1 |
183 | 183 | // [search_date] => 1 |
184 | 184 | $search_generic = array(); |
185 | - if( !empty( $widget['search_free'] ) ) { |
|
186 | - $search_generic[] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
185 | + if (!empty($widget['search_free'])) { |
|
186 | + $search_generic[] = array('field' => 'search_all', 'input' => 'input_text'); |
|
187 | 187 | } |
188 | - if( !empty( $widget['search_date'] ) ) { |
|
189 | - $search_generic[] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
188 | + if (!empty($widget['search_date'])) { |
|
189 | + $search_generic[] = array('field' => 'entry_date', 'input' => 'date'); |
|
190 | 190 | } |
191 | 191 | |
192 | - $search_config = array_merge( $search_generic, $search_fields ); |
|
192 | + $search_config = array_merge($search_generic, $search_fields); |
|
193 | 193 | |
194 | 194 | // don't throw '[]' when json_encode an empty array |
195 | - if( empty( $search_config ) ) { |
|
195 | + if (empty($search_config)) { |
|
196 | 196 | $search_config = ''; |
197 | 197 | } else { |
198 | - $search_config = json_encode( $search_config ); |
|
198 | + $search_config = json_encode($search_config); |
|
199 | 199 | } |
200 | 200 | |
201 | - $widgets[ $area ][ $k ]['search_fields'] = $search_config; |
|
202 | - $widgets[ $area ][ $k ]['search_layout'] = 'horizontal'; |
|
201 | + $widgets[$area][$k]['search_fields'] = $search_config; |
|
202 | + $widgets[$area][$k]['search_layout'] = 'horizontal'; |
|
203 | 203 | |
204 | - do_action( 'gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Updated Widget: ', $widgets[ $area ][ $k ] ); |
|
204 | + do_action('gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] Updated Widget: ', $widgets[$area][$k]); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | // update widgets view |
209 | - update_post_meta( $view->ID, '_gravityview_directory_widgets', $widgets ); |
|
209 | + update_post_meta($view->ID, '_gravityview_directory_widgets', $widgets); |
|
210 | 210 | |
211 | 211 | } // foreach Views |
212 | 212 | |
213 | 213 | // all done! enjoy the new Search Widget! |
214 | - update_option( 'gv_migrate_searchwidget', true ); |
|
214 | + update_option('gv_migrate_searchwidget', true); |
|
215 | 215 | |
216 | - do_action( 'gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] All done! enjoy the new Search Widget!' ); |
|
216 | + do_action('gravityview_log_debug', '[GravityView_Migrate/update_search_on_views] All done! enjoy the new Search Widget!'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
220 | - function get_search_fields( $view_id ) { |
|
220 | + function get_search_fields($view_id) { |
|
221 | 221 | |
222 | - $form_id = gravityview_get_form_id( $view_id ); |
|
223 | - $form = gravityview_get_form( $form_id ); |
|
222 | + $form_id = gravityview_get_form_id($view_id); |
|
223 | + $form = gravityview_get_form($form_id); |
|
224 | 224 | |
225 | 225 | $search_fields = array(); |
226 | 226 | |
227 | 227 | // check view fields' settings |
228 | - $fields = get_post_meta( $view_id, '_gravityview_directory_fields', true ); |
|
228 | + $fields = get_post_meta($view_id, '_gravityview_directory_fields', true); |
|
229 | 229 | |
230 | - if( !empty( $fields ) && is_array( $fields ) ) { |
|
230 | + if (!empty($fields) && is_array($fields)) { |
|
231 | 231 | |
232 | - foreach( $fields as $t => $fs ) { |
|
232 | + foreach ($fields as $t => $fs) { |
|
233 | 233 | |
234 | - foreach( $fs as $k => $field ) { |
|
234 | + foreach ($fs as $k => $field) { |
|
235 | 235 | // is field a search_filter ? |
236 | - if( empty( $field['search_filter'] ) ) { continue; } |
|
236 | + if (empty($field['search_filter'])) { continue; } |
|
237 | 237 | |
238 | 238 | // get field type & calculate the input type (by default) |
239 | - $form_field = gravityview_get_field( $form, $field['id'] ); |
|
239 | + $form_field = gravityview_get_field($form, $field['id']); |
|
240 | 240 | |
241 | - if( empty( $form_field['type'] ) ) { |
|
241 | + if (empty($form_field['type'])) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // depending on the field type assign a group of possible search field types |
246 | - $type = GravityView_Widget_Search::get_search_input_types( $field['id'], $form_field['type'] ); |
|
246 | + $type = GravityView_Widget_Search::get_search_input_types($field['id'], $form_field['type']); |
|
247 | 247 | |
248 | 248 | // add field to config |
249 | - $search_fields[] = array( 'field' => $field['id'], 'input' => $type ); |
|
249 | + $search_fields[] = array('field' => $field['id'], 'input' => $type); |
|
250 | 250 | |
251 | 251 | } |
252 | 252 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -defined( 'ABSPATH' ) || exit; |
|
14 | +defined('ABSPATH') || exit; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * GravityView Roles Class |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function get_instance() { |
35 | 35 | |
36 | - if( ! self::$instance ) { |
|
36 | + if (!self::$instance) { |
|
37 | 37 | self::$instance = new self; |
38 | 38 | } |
39 | 39 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * @since 1.15 |
54 | 54 | */ |
55 | 55 | private function add_hooks() { |
56 | - add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
|
57 | - add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
|
58 | - add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
|
59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
56 | + add_filter('members_get_capabilities', array('GravityView_Roles_Capabilities', 'merge_with_all_caps')); |
|
57 | + add_action('members_register_cap_groups', array($this, 'members_register_cap_group'), 20); |
|
58 | + add_filter('user_has_cap', array($this, 'filter_user_has_cap'), 10, 4); |
|
59 | + add_action('admin_init', array($this, 'add_caps')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
|
77 | + public function filter_user_has_cap($usercaps = array(), $caps = array(), $args = array(), $user = NULL) { |
|
78 | 78 | |
79 | 79 | // Empty caps_to_check array |
80 | - if( ! $usercaps || ! $caps ) { |
|
80 | + if (!$usercaps || !$caps) { |
|
81 | 81 | return $usercaps; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
86 | 86 | */ |
87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
87 | + if (!empty($usercaps['gravityview_full_access'])) { |
|
88 | 88 | |
89 | 89 | $all_gravityview_caps = self::all_caps(); |
90 | 90 | |
91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
92 | - $usercaps[ $gv_cap ] = true; |
|
91 | + foreach ($all_gravityview_caps as $gv_cap) { |
|
92 | + $usercaps[$gv_cap] = true; |
|
93 | 93 | } |
94 | 94 | |
95 | - unset( $all_gravityview_caps ); |
|
95 | + unset($all_gravityview_caps); |
|
96 | 96 | } |
97 | 97 | |
98 | - $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ); |
|
98 | + $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps($usercaps); |
|
99 | 99 | |
100 | 100 | return $usercaps; |
101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - private function add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ) { |
|
117 | + private function add_gravity_forms_usercaps_to_gravityview_caps($usercaps) { |
|
118 | 118 | |
119 | 119 | $gf_to_gv_caps = array( |
120 | 120 | 'gravityforms_edit_entries' => 'gravityview_edit_others_entries', |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | 'gravityforms_edit_entry_notes' => 'gravityview_edit_others_entry_notes', |
123 | 123 | ); |
124 | 124 | |
125 | - foreach ( $gf_to_gv_caps as $gf_cap => $gv_cap ) { |
|
126 | - if ( isset( $usercaps[ $gf_cap ] ) && ! isset( $usercaps[ $gv_cap ] ) ) { |
|
127 | - $usercaps[ $gv_cap ] = $usercaps[ $gf_cap ]; |
|
125 | + foreach ($gf_to_gv_caps as $gf_cap => $gv_cap) { |
|
126 | + if (isset($usercaps[$gf_cap]) && !isset($usercaps[$gv_cap])) { |
|
127 | + $usercaps[$gv_cap] = $usercaps[$gf_cap]; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | function members_register_cap_group() { |
141 | - if ( function_exists( 'members_register_cap_group' ) ) { |
|
141 | + if (function_exists('members_register_cap_group')) { |
|
142 | 142 | |
143 | 143 | $args = array( |
144 | - 'label' => __( 'GravityView', 'gravityview' ), |
|
144 | + 'label' => __('GravityView', 'gravityview'), |
|
145 | 145 | 'icon' => 'gv-icon-astronaut-head', |
146 | 146 | 'caps' => self::all_caps(), |
147 | 147 | 'merge_added' => true, |
148 | 148 | 'diff_added' => false, |
149 | 149 | ); |
150 | 150 | |
151 | - members_register_cap_group( 'gravityview', $args ); |
|
151 | + members_register_cap_group('gravityview', $args); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | * @param array $caps Existing capabilities |
160 | 160 | * @return array Modified capabilities array |
161 | 161 | */ |
162 | - public static function merge_with_all_caps( $caps ) { |
|
162 | + public static function merge_with_all_caps($caps) { |
|
163 | 163 | |
164 | - $return_caps = array_merge( $caps, self::all_caps() ); |
|
164 | + $return_caps = array_merge($caps, self::all_caps()); |
|
165 | 165 | |
166 | - return array_unique( $return_caps ); |
|
166 | + return array_unique($return_caps); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | private function wp_roles() { |
179 | 179 | global $wp_roles; |
180 | 180 | |
181 | - if ( ! isset( $wp_roles ) ) { |
|
181 | + if (!isset($wp_roles)) { |
|
182 | 182 | $wp_roles = new WP_Roles(); |
183 | 183 | } |
184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $wp_roles = $this->wp_roles(); |
198 | 198 | |
199 | - if ( is_object( $wp_roles ) ) { |
|
199 | + if (is_object($wp_roles)) { |
|
200 | 200 | |
201 | 201 | $_use_db_backup = $wp_roles->use_db; |
202 | 202 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | */ |
207 | 207 | $wp_roles->use_db = false; |
208 | 208 | |
209 | - $capabilities = self::all_caps( false, false ); |
|
209 | + $capabilities = self::all_caps(false, false); |
|
210 | 210 | |
211 | - foreach ( $capabilities as $role_slug => $role_caps ) { |
|
212 | - foreach ( $role_caps as $cap ) { |
|
213 | - $wp_roles->add_cap( $role_slug, $cap ); |
|
211 | + foreach ($capabilities as $role_slug => $role_caps) { |
|
212 | + foreach ($role_caps as $cap) { |
|
213 | + $wp_roles->add_cap($role_slug, $cap); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @see WP_Roles::add_cap() Original code |
221 | 221 | */ |
222 | - update_option( $wp_roles->role_key, $wp_roles->roles ); |
|
222 | + update_option($wp_roles->role_key, $wp_roles->roles); |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Restore previous $use_db setting |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return array If $role is set, flat array of caps_to_check. Otherwise, a multi-dimensional array of roles and their caps_to_check with the following keys: 'administrator', 'editor', 'author', 'contributor', 'subscriber' |
242 | 242 | */ |
243 | - public static function all_caps( $single_role = false, $flat_array = true ) { |
|
243 | + public static function all_caps($single_role = false, $flat_array = true) { |
|
244 | 244 | |
245 | 245 | // Change settings |
246 | 246 | $administrator_caps = array( |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | ); |
298 | 298 | |
299 | 299 | $subscriber = $subscriber_caps; |
300 | - $contributor = array_merge( $contributor_caps, $subscriber_caps ); |
|
301 | - $author = array_merge( $author_caps, $contributor_caps, $subscriber_caps ); |
|
302 | - $editor = array_merge( $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
303 | - $administrator = array_merge( $administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
300 | + $contributor = array_merge($contributor_caps, $subscriber_caps); |
|
301 | + $author = array_merge($author_caps, $contributor_caps, $subscriber_caps); |
|
302 | + $editor = array_merge($editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
303 | + $administrator = array_merge($administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
304 | 304 | $all = $administrator; |
305 | 305 | |
306 | 306 | // If role is set, return caps_to_check for just that role. |
307 | - if( $single_role ) { |
|
308 | - $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
|
309 | - return $flat_array ? $caps : array( $single_role => $caps ); |
|
307 | + if ($single_role) { |
|
308 | + $caps = isset(${$single_role} ) ? ${$single_role} : false; |
|
309 | + return $flat_array ? $caps : array($single_role => $caps); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Otherwise, return multi-dimensional array of all caps_to_check |
313 | - return $flat_array ? $all : compact( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
313 | + return $flat_array ? $all : compact('administrator', 'editor', 'author', 'contributor', 'subscriber'); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
332 | 332 | */ |
333 | - public static function has_cap( $caps_to_check = '', $object_id = null, $user_id = null ) { |
|
333 | + public static function has_cap($caps_to_check = '', $object_id = null, $user_id = null) { |
|
334 | 334 | |
335 | 335 | $has_cap = false; |
336 | 336 | |
337 | - if( empty( $caps_to_check ) ) { |
|
337 | + if (empty($caps_to_check)) { |
|
338 | 338 | return $has_cap; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // Add full access caps for GV & GF |
342 | - $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
|
342 | + $caps_to_check = self::maybe_add_full_access_caps($caps_to_check); |
|
343 | 343 | |
344 | - foreach ( $caps_to_check as $cap ) { |
|
345 | - if( ! is_null( $object_id ) ) { |
|
346 | - $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
|
344 | + foreach ($caps_to_check as $cap) { |
|
345 | + if (!is_null($object_id)) { |
|
346 | + $has_cap = $user_id ? user_can($user_id, $cap, $object_id) : current_user_can($cap, $object_id); |
|
347 | 347 | } else { |
348 | - $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
|
348 | + $has_cap = $user_id ? user_can($user_id, $cap) : current_user_can($cap); |
|
349 | 349 | } |
350 | 350 | // At the first successful response, stop checking |
351 | - if( $has_cap ) { |
|
351 | + if ($has_cap) { |
|
352 | 352 | break; |
353 | 353 | } |
354 | 354 | } |
@@ -365,25 +365,25 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @return array |
367 | 367 | */ |
368 | - public static function maybe_add_full_access_caps( $caps_to_check = array() ) { |
|
368 | + public static function maybe_add_full_access_caps($caps_to_check = array()) { |
|
369 | 369 | |
370 | 370 | $caps_to_check = (array)$caps_to_check; |
371 | 371 | |
372 | 372 | $all_gravityview_caps = self::all_caps(); |
373 | 373 | |
374 | 374 | // Are there any $caps_to_check that are from GravityView? |
375 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
375 | + if ($has_gravityview_caps = array_intersect($caps_to_check, $all_gravityview_caps)) { |
|
376 | 376 | $caps_to_check[] = 'gravityview_full_access'; |
377 | 377 | } |
378 | 378 | |
379 | - $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
|
379 | + $all_gravity_forms_caps = class_exists('GFCommon') ? GFCommon::all_caps() : array(); |
|
380 | 380 | |
381 | 381 | // Are there any $caps_to_check that are from Gravity Forms? |
382 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
382 | + if ($all_gravity_forms_caps = array_intersect($caps_to_check, $all_gravity_forms_caps)) { |
|
383 | 383 | $caps_to_check[] = 'gform_full_access'; |
384 | 384 | } |
385 | 385 | |
386 | - return array_unique( $caps_to_check ); |
|
386 | + return array_unique($caps_to_check); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -396,19 +396,19 @@ discard block |
||
396 | 396 | |
397 | 397 | $wp_roles = $this->wp_roles(); |
398 | 398 | |
399 | - if ( is_object( $wp_roles ) ) { |
|
399 | + if (is_object($wp_roles)) { |
|
400 | 400 | |
401 | 401 | /** Remove all GravityView caps_to_check from all roles */ |
402 | 402 | $capabilities = self::all_caps(); |
403 | 403 | |
404 | 404 | // Loop through each role and remove GV caps_to_check |
405 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
406 | - foreach ( $capabilities as $cap ) { |
|
407 | - $wp_roles->remove_cap( $role_slug, $cap ); |
|
405 | + foreach ($wp_roles->get_names() as $role_slug => $role_name) { |
|
406 | + foreach ($capabilities as $cap) { |
|
407 | + $wp_roles->remove_cap($role_slug, $cap); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | -add_action( 'init', array( 'GravityView_Roles_Capabilities', 'get_instance' ), 1 ); |
|
415 | 414 | \ No newline at end of file |
415 | +add_action('init', array('GravityView_Roles_Capabilities', 'get_instance'), 1); |
|
416 | 416 | \ No newline at end of file |