@@ -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 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | private function add_hooks() { |
26 | 26 | |
27 | 27 | // Shortcode to render view (directory) |
28 | - add_shortcode( 'gravityview', array( $this, 'shortcode' ) ); |
|
28 | + add_shortcode('gravityview', array($this, 'shortcode')); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | * @param string|null $content Content passed inside the shortcode |
40 | 40 | * @return null|string If admin, null. Otherwise, output of $this->render_view() |
41 | 41 | */ |
42 | - function shortcode( $passed_atts, $content = null ) { |
|
42 | + function shortcode($passed_atts, $content = null) { |
|
43 | 43 | |
44 | 44 | // Don't process when saving post. |
45 | - if ( is_admin() ) { |
|
45 | + if (is_admin()) { |
|
46 | 46 | return null; |
47 | 47 | } |
48 | 48 | |
49 | - do_action( 'gravityview_log_debug', __FUNCTION__ . ' $passed_atts: ', $passed_atts ); |
|
49 | + do_action('gravityview_log_debug', __FUNCTION__.' $passed_atts: ', $passed_atts); |
|
50 | 50 | |
51 | 51 | // Get details about the current View |
52 | - if( !empty( $passed_atts['detail'] ) ) { |
|
53 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
52 | + if (!empty($passed_atts['detail'])) { |
|
53 | + return $this->get_view_detail($passed_atts['detail']); |
|
54 | 54 | } |
55 | 55 | |
56 | - $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
|
56 | + $atts = $this->parse_and_sanitize_atts($passed_atts); |
|
57 | 57 | |
58 | - return GravityView_frontend::getInstance()->render_view( $atts ); |
|
58 | + return GravityView_frontend::getInstance()->render_view($atts); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -76,26 +76,26 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array Valid and sanitized attribute pairs |
78 | 78 | */ |
79 | - private function parse_and_sanitize_atts( $passed_atts ) { |
|
79 | + private function parse_and_sanitize_atts($passed_atts) { |
|
80 | 80 | |
81 | - $defaults = GravityView_View_Data::get_default_args( true ); |
|
81 | + $defaults = GravityView_View_Data::get_default_args(true); |
|
82 | 82 | |
83 | - $supported_atts = array_fill_keys( array_keys( $defaults ), '' ); |
|
83 | + $supported_atts = array_fill_keys(array_keys($defaults), ''); |
|
84 | 84 | |
85 | 85 | // Whittle down the attributes to only valid pairs |
86 | - $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
|
86 | + $filtered_atts = shortcode_atts($supported_atts, $passed_atts, 'gravityview'); |
|
87 | 87 | |
88 | 88 | // Only keep the passed attributes after making sure that they're valid pairs |
89 | - $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $passed_atts, $filtered_atts ) : $filtered_atts; |
|
89 | + $filtered_atts = function_exists('array_intersect_key') ? array_intersect_key($passed_atts, $filtered_atts) : $filtered_atts; |
|
90 | 90 | |
91 | 91 | $atts = array(); |
92 | 92 | |
93 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
93 | + foreach ($filtered_atts as $key => $passed_value) { |
|
94 | 94 | |
95 | 95 | // Allow using {get} merge tags in shortcode attributes |
96 | - $passed_value = GravityView_Merge_Tags::replace_get_variables( $passed_value ); |
|
96 | + $passed_value = GravityView_Merge_Tags::replace_get_variables($passed_value); |
|
97 | 97 | |
98 | - switch( $defaults[ $key ]['type'] ) { |
|
98 | + switch ($defaults[$key]['type']) { |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Make sure number fields are numeric. |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
104 | 104 | */ |
105 | 105 | case 'number': |
106 | - if( is_numeric( $passed_value ) ) { |
|
107 | - $atts[ $key ] = ( $passed_value + 0 ); |
|
106 | + if (is_numeric($passed_value)) { |
|
107 | + $atts[$key] = ($passed_value + 0); |
|
108 | 108 | } |
109 | 109 | break; |
110 | 110 | |
111 | 111 | // Checkboxes should be 1 or 0 |
112 | 112 | case 'checkbox': |
113 | - $atts[ $key ] = gv_empty( $passed_value ) ? 0 : 1; |
|
113 | + $atts[$key] = gv_empty($passed_value) ? 0 : 1; |
|
114 | 114 | break; |
115 | 115 | |
116 | 116 | /** |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | */ |
119 | 119 | case 'select': |
120 | 120 | case 'radio': |
121 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
122 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
123 | - $atts[ $key ] = $passed_value; |
|
121 | + $options = isset($defaults[$key]['choices']) ? $defaults[$key]['choices'] : $defaults[$key]['options']; |
|
122 | + if (in_array($passed_value, array_keys($options))) { |
|
123 | + $atts[$key] = $passed_value; |
|
124 | 124 | } |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'text': |
128 | 128 | default: |
129 | - $atts[ $key ] = $passed_value; |
|
129 | + $atts[$key] = $passed_value; |
|
130 | 130 | break; |
131 | 131 | } |
132 | 132 | } |
@@ -143,26 +143,26 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Detail information |
145 | 145 | */ |
146 | - private function get_view_detail( $detail = '' ) { |
|
146 | + private function get_view_detail($detail = '') { |
|
147 | 147 | |
148 | 148 | $gravityview_view = GravityView_View::getInstance(); |
149 | 149 | $return = ''; |
150 | 150 | |
151 | - switch( $detail ) { |
|
151 | + switch ($detail) { |
|
152 | 152 | case 'total_entries': |
153 | - $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
|
153 | + $return = number_format_i18n($gravityview_view->getTotalEntries()); |
|
154 | 154 | break; |
155 | 155 | case 'first_entry': |
156 | 156 | $paging = $gravityview_view->getPaginationCounts(); |
157 | - $return = empty( $paging ) ? '' : number_format_i18n( $paging['first'] ); |
|
157 | + $return = empty($paging) ? '' : number_format_i18n($paging['first']); |
|
158 | 158 | break; |
159 | 159 | case 'last_entry': |
160 | 160 | $paging = $gravityview_view->getPaginationCounts(); |
161 | - $return = empty( $paging ) ? '' : number_format_i18n( $paging['last'] ); |
|
161 | + $return = empty($paging) ? '' : number_format_i18n($paging['last']); |
|
162 | 162 | break; |
163 | 163 | case 'page_size': |
164 | 164 | $paging = $gravityview_view->getPaging(); |
165 | - $return = number_format_i18n( $paging['page_size'] ); |
|
165 | + $return = number_format_i18n($paging['page_size']); |
|
166 | 166 | break; |
167 | 167 | } |
168 | 168 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @since 1.13 |
172 | 172 | * @param string $return Existing output |
173 | 173 | */ |
174 | - $return = apply_filters( 'gravityview/shortcode/detail/' . $detail, $return ); |
|
174 | + $return = apply_filters('gravityview/shortcode/detail/'.$detail, $return); |
|
175 | 175 | |
176 | 176 | return $return; |
177 | 177 | } |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | public $active_areas; |
38 | 38 | |
39 | 39 | |
40 | - function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
|
40 | + function __construct($id, $settings = array(), $field_options = array(), $areas = array()) { |
|
41 | 41 | |
42 | - if ( empty( $id ) ) { |
|
42 | + if (empty($id)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->template_id = $id; |
47 | 47 | |
48 | - $this->merge_defaults( $settings ); |
|
48 | + $this->merge_defaults($settings); |
|
49 | 49 | |
50 | 50 | $this->field_options = $field_options; |
51 | 51 | $this->active_areas = $areas; |
@@ -60,25 +60,25 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function add_hooks() { |
62 | 62 | |
63 | - add_filter( 'gravityview_register_directory_template', array( $this, 'register_template' ) ); |
|
63 | + add_filter('gravityview_register_directory_template', array($this, 'register_template')); |
|
64 | 64 | |
65 | 65 | // presets hooks: |
66 | 66 | // form xml |
67 | - add_filter( 'gravityview_template_formxml', array( $this, 'assign_form_xml' ), 10, 2 ); |
|
67 | + add_filter('gravityview_template_formxml', array($this, 'assign_form_xml'), 10, 2); |
|
68 | 68 | // fields config xml |
69 | - add_filter( 'gravityview_template_fieldsxml', array( $this, 'assign_fields_xml' ), 10, 2 ); |
|
69 | + add_filter('gravityview_template_fieldsxml', array($this, 'assign_fields_xml'), 10, 2); |
|
70 | 70 | |
71 | 71 | // assign active areas |
72 | - add_filter( 'gravityview_template_active_areas', array( $this, 'assign_active_areas' ), 10, 3 ); |
|
72 | + add_filter('gravityview_template_active_areas', array($this, 'assign_active_areas'), 10, 3); |
|
73 | 73 | |
74 | 74 | // field options |
75 | - add_filter( 'gravityview_template_field_options', array( $this, 'assign_field_options' ), 10, 4 ); |
|
75 | + add_filter('gravityview_template_field_options', array($this, 'assign_field_options'), 10, 4); |
|
76 | 76 | |
77 | 77 | // template slug |
78 | - add_filter( "gravityview_template_slug_{$this->template_id}", array( $this, 'assign_view_slug' ), 10, 2 ); |
|
78 | + add_filter("gravityview_template_slug_{$this->template_id}", array($this, 'assign_view_slug'), 10, 2); |
|
79 | 79 | |
80 | 80 | // register template CSS |
81 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
81 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return array Merged template settings. |
92 | 92 | */ |
93 | - private function merge_defaults( $settings = array() ) { |
|
93 | + private function merge_defaults($settings = array()) { |
|
94 | 94 | |
95 | 95 | $defaults = array( |
96 | 96 | 'slug' => '', |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'preset_fields' => '' |
106 | 106 | ); |
107 | 107 | |
108 | - $this->settings = wp_parse_args( $settings, $defaults ); |
|
108 | + $this->settings = wp_parse_args($settings, $defaults); |
|
109 | 109 | |
110 | 110 | return $this->settings; |
111 | 111 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return array Array of templates available for GV |
121 | 121 | */ |
122 | - public function register_template( $templates ) { |
|
123 | - $templates[ $this->template_id ] = $this->settings; |
|
122 | + public function register_template($templates) { |
|
123 | + $templates[$this->template_id] = $this->settings; |
|
124 | 124 | |
125 | 125 | return $templates; |
126 | 126 | } |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return array Array of active areas |
138 | 138 | */ |
139 | - public function assign_active_areas( $areas, $template = '', $context = 'directory' ) { |
|
140 | - if ( $this->template_id === $template ) { |
|
141 | - $areas = $this->get_active_areas( $context ); |
|
139 | + public function assign_active_areas($areas, $template = '', $context = 'directory') { |
|
140 | + if ($this->template_id === $template) { |
|
141 | + $areas = $this->get_active_areas($context); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return $areas; |
145 | 145 | } |
146 | 146 | |
147 | - public function get_active_areas( $context ) { |
|
148 | - if ( isset( $this->active_areas[ $context ] ) ) { |
|
149 | - return $this->active_areas[ $context ]; |
|
147 | + public function get_active_areas($context) { |
|
148 | + if (isset($this->active_areas[$context])) { |
|
149 | + return $this->active_areas[$context]; |
|
150 | 150 | } else { |
151 | 151 | return $this->active_areas; |
152 | 152 | } |
@@ -163,21 +163,21 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Array of field options |
165 | 165 | */ |
166 | - public function assign_field_options( $field_options, $template_id, $field_id = NULL, $context = 'directory' ) { |
|
166 | + public function assign_field_options($field_options, $template_id, $field_id = NULL, $context = 'directory') { |
|
167 | 167 | |
168 | - if ( $this->template_id === $template_id ) { |
|
168 | + if ($this->template_id === $template_id) { |
|
169 | 169 | |
170 | - foreach ( $this->field_options as $key => $field_option ) { |
|
170 | + foreach ($this->field_options as $key => $field_option) { |
|
171 | 171 | |
172 | - $field_context = rgar( $field_option, 'context' ); |
|
172 | + $field_context = rgar($field_option, 'context'); |
|
173 | 173 | |
174 | 174 | // Does the field option only apply to a certain context? |
175 | 175 | // You can define multiple contexts as an array: `context => array("directory", "single")` |
176 | - $context_matches = is_array( $field_context ) ? in_array( $context, $field_context ) : $context === $field_context; |
|
176 | + $context_matches = is_array($field_context) ? in_array($context, $field_context) : $context === $field_context; |
|
177 | 177 | |
178 | 178 | // If the context matches (or isn't defined), add the field options. |
179 | - if ( $context_matches ) { |
|
180 | - $field_options[ $key ] = $field_option; |
|
179 | + if ($context_matches) { |
|
180 | + $field_options[$key] = $field_option; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | } |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @see GravityView_Admin_Views::create_preset_form() |
193 | 193 | * @return string Path to XML file |
194 | 194 | */ |
195 | - public function assign_form_xml( $xml = '', $template = '' ) { |
|
196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
195 | + public function assign_form_xml($xml = '', $template = '') { |
|
196 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_form']) && $this->template_id === $template) { |
|
197 | 197 | return $this->settings['preset_form']; |
198 | 198 | } |
199 | 199 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @see GravityView_Admin_Views::pre_get_form_fields() |
207 | 207 | * @return string Path to XML file |
208 | 208 | */ |
209 | - public function assign_fields_xml( $xml = '', $template = '' ) { |
|
210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
209 | + public function assign_fields_xml($xml = '', $template = '') { |
|
210 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_fields']) && $this->template_id === $template) { |
|
211 | 211 | return $this->settings['preset_fields']; |
212 | 212 | } |
213 | 213 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function assign_view_slug( $default, $context ) { |
|
227 | + public function assign_view_slug($default, $context) { |
|
228 | 228 | |
229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
229 | + if (!empty($this->settings['slug'])) { |
|
230 | 230 | return $this->settings['slug']; |
231 | 231 | } |
232 | - if ( ! empty( $default ) ) { |
|
232 | + if (!empty($default)) { |
|
233 | 233 | return $default; |
234 | 234 | } |
235 | 235 | |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | public function register_styles() { |
247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
247 | + if (!empty($this->settings['css_source'])) { |
|
248 | + wp_register_style('gravityview_style_'.$this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all'); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 |