Completed
Pull Request — master (#605)
by Zack
05:45
created
includes/class-admin.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@  discard block
 block discarded – undo
4 4
 
5 5
 	function __construct() {
6 6
 
7
-		if( ! is_admin() ) { return; }
7
+		if (!is_admin()) { return; }
8 8
 
9 9
 		// If Gravity Forms isn't active or compatibile, stop loading
10
-		if( false === GravityView_Compatibility::is_valid() ) {
10
+		if (false === GravityView_Compatibility::is_valid()) {
11 11
 			return;
12 12
 		}
13 13
 
@@ -22,22 +22,22 @@  discard block
 block discarded – undo
22 22
 	private function include_required_files() {
23 23
 
24 24
 		// Migrate Class
25
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' );
25
+		require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-migrate.php');
26 26
 
27 27
 		// Don't load tooltips if on Gravity Forms, otherwise it overrides translations
28
-		if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) {
29
-			require_once( GFCommon::get_base_path() . '/tooltips.php' );
28
+		if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) {
29
+			require_once(GFCommon::get_base_path().'/tooltips.php');
30 30
 		}
31 31
 
32
-		require_once( GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php' );
33
-		require_once( GRAVITYVIEW_DIR . 'includes/admin/entry-list.php' );
34
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
32
+		require_once(GRAVITYVIEW_DIR.'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php');
33
+		require_once(GRAVITYVIEW_DIR.'includes/admin/entry-list.php');
34
+		require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php');
35 35
 
36 36
 		/** @since 1.15 **/
37
-		require_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php' );
37
+		require_once(GRAVITYVIEW_DIR.'includes/admin/class-gravityview-support-port.php');
38 38
 
39 39
 		/** @since 1.6 */
40
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php' );
40
+		require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-duplicate-view.php');
41 41
 	}
42 42
 
43 43
 	/**
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
 	private function add_hooks() {
48 48
 
49 49
 		// Filter Admin messages
50
-		add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
51
-		add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) );
50
+		add_filter('post_updated_messages', array($this, 'post_updated_messages'));
51
+		add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages'));
52 52
 
53
-		add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) );
53
+		add_filter('plugin_action_links_'.plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links'));
54 54
 
55
-		add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 );
55
+		add_action('plugins_loaded', array($this, 'backend_actions'), 100);
56 56
 
57 57
 		//Hooks for no-conflict functionality
58
-		add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000);
59
-		add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9);
58
+		add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000);
59
+		add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9);
60 60
 
61
-		add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000);
62
-		add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11);
63
-		add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1);
64
-		add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1);
61
+		add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000);
62
+		add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11);
63
+		add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1);
64
+		add_action('admin_footer', array($this, 'no_conflict_styles'), 1);
65 65
 
66 66
 	}
67 67
 
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	public function backend_actions() {
75 75
 
76 76
 		/** @define "GRAVITYVIEW_DIR" "../" */
77
-		include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' );
78
-		include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' );
79
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' );
80
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' );
81
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' );
82
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' );
83
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
77
+		include_once(GRAVITYVIEW_DIR.'includes/admin/class.field.type.php');
78
+		include_once(GRAVITYVIEW_DIR.'includes/admin/class.render.settings.php');
79
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin-label.php');
80
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin-views.php');
81
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin-welcome.php');
82
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin-add-shortcode.php');
83
+		include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php');
84 84
 
85 85
 		/**
86 86
 		 * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 * @param array $links Array of action links under GravityView on the plugin page
100 100
 	 * @return array Action links with Settings and Support included, if the user has the appropriate caps
101 101
 	 */
102
-	public static function plugin_action_links( $links ) {
102
+	public static function plugin_action_links($links) {
103 103
 
104 104
 		$actions = array();
105 105
 
106
-		if( GVCommon::has_cap( 'gravityview_view_settings' ) ) {
107
-			$actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) );
106
+		if (GVCommon::has_cap('gravityview_view_settings')) {
107
+			$actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview'));
108 108
 		}
109 109
 
110
-		if( GVCommon::has_cap( 'gravityview_support_port' ) ) {
111
-			$actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>';
110
+		if (GVCommon::has_cap('gravityview_support_port')) {
111
+			$actions[] = '<a href="http://docs.gravityview.co">'.esc_html__('Support', 'gravityview').'</a>';
112 112
 		}
113 113
 
114
-		return array_merge( $actions, $links );
114
+		return array_merge($actions, $links);
115 115
 	}
116 116
 
117 117
 	/**
@@ -128,70 +128,70 @@  discard block
 block discarded – undo
128 128
 	 * @param  array      $messages Existing messages
129 129
 	 * @return array                Messages with GravityView views!
130 130
 	 */
131
-	function post_updated_messages( $messages, $bulk_counts = NULL ) {
131
+	function post_updated_messages($messages, $bulk_counts = NULL) {
132 132
 		global $post;
133 133
 
134
-		$post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL );
134
+		$post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL);
135 135
 
136 136
 		// By default, there will only be one item being modified.
137 137
 		// When in the `bulk_post_updated_messages` filter, there will be passed a number
138 138
 		// of modified items that will override this array.
139
-		$bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts;
139
+		$bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts;
140 140
 
141 141
 
142 142
 		// If we're starting fresh, a new form was created.
143 143
 		// We should let the user know this is the case.
144
-		$start_fresh = get_post_meta( $post_id, '_gravityview_start_fresh', true );
144
+		$start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true);
145 145
 
146 146
 		$new_form_text = '';
147 147
 
148
-		if( !empty( $start_fresh ) ) {
148
+		if (!empty($start_fresh)) {
149 149
 
150 150
 			// Get the form that was created
151
-			$connected_form = gravityview_get_form_id( $post_id );
151
+			$connected_form = gravityview_get_form_id($post_id);
152 152
 
153
-			if( !empty( $connected_form ) ) {
154
-				$form = gravityview_get_form( $connected_form );
155
-				$form_name = esc_attr( $form['title'] );
153
+			if (!empty($connected_form)) {
154
+				$form = gravityview_get_form($connected_form);
155
+				$form_name = esc_attr($form['title']);
156 156
 				$image = self::get_floaty();
157
-				$new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>';
158
-				$new_form_text .=  sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s
157
+				$new_form_text .= '<h3>'.$image.sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name).'</h3>';
158
+				$new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s
159 159
 
160 160
 					You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don&rsquo;t forget to %scustomize the form settings%s.
161
-					', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&amp;id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&amp;id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&amp;view=settings&amp;id='.$connected_form ).'">', '</a>');
162
-				$new_form_text = wpautop( $new_form_text );
161
+					', 'gravityview'), '<strong>', '</strong>', '<a href="'.site_url('?gf_page=preview&amp;id='.$connected_form).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&amp;id='.$connected_form).'">', '</a>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&amp;view=settings&amp;id='.$connected_form).'">', '</a>');
162
+				$new_form_text = wpautop($new_form_text);
163 163
 
164
-				delete_post_meta( $post_id, '_gravityview_start_fresh' );
164
+				delete_post_meta($post_id, '_gravityview_start_fresh');
165 165
 			}
166 166
 		}
167 167
 
168 168
 		$messages['gravityview'] = array(
169 169
 			0  => '', // Unused. Messages start at index 1.
170
-			1  => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'),
171
-			2  => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'),
172
-			3  => __( 'View deleted.', 'gravityview' ),
173
-			4  => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'),
170
+			1  => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'),
171
+			2  => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'),
172
+			3  => __('View deleted.', 'gravityview'),
173
+			4  => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'),
174 174
 			/* translators: %s: date and time of the revision */
175
-			5  => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
176
-			6  => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text,
177
-			7  => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text,
178
-			8  => __( 'View submitted.', 'gravityview' ),
175
+			5  => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
176
+			6  => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text,
177
+			7  => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text,
178
+			8  => __('View submitted.', 'gravityview'),
179 179
 			9  => sprintf(
180
-				__( 'View scheduled for: %1$s.', 'gravityview' ),
180
+				__('View scheduled for: %1$s.', 'gravityview'),
181 181
 				// translators: Publish box date format, see http://php.net/date
182
-				date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL )  ) )
183
-			) . $new_form_text,
184
-			10  => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'),
182
+				date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime((isset($post->post_date) ? $post->post_date : NULL)))
183
+			).$new_form_text,
184
+			10  => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'),
185 185
 
186 186
 			/**
187 187
 			 * These apply to `bulk_post_updated_messages`
188 188
 			 * @file wp-admin/edit.php
189 189
 			 */
190
-			'updated'   => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ),
191
-			'locked'    => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ),
192
-			'deleted'   => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ),
193
-			'trashed'   => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ),
194
-			'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ),
190
+			'updated'   => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'),
191
+			'locked'    => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'),
192
+			'deleted'   => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'),
193
+			'trashed'   => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'),
194
+			'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'),
195 195
 		);
196 196
 
197 197
 		return $messages;
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	function no_conflict_scripts() {
205 205
 		global $wp_scripts;
206 206
 
207
-		if( ! gravityview_is_admin_page() ) {
207
+		if (!gravityview_is_admin_page()) {
208 208
 			return;
209 209
 		}
210 210
 
211 211
 		$no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode');
212 212
 
213
-		if( empty( $no_conflict_mode ) ) {
213
+		if (empty($no_conflict_mode)) {
214 214
 			return;
215 215
 		}
216 216
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             'jquery-ui-accordion',
251 251
 		);
252 252
 
253
-		$this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' );
253
+		$this->remove_conflicts($wp_scripts, $wp_allowed_scripts, 'scripts');
254 254
 	}
255 255
 
256 256
 	/**
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 	function no_conflict_styles() {
261 261
 		global $wp_styles;
262 262
 
263
-		if( ! gravityview_is_admin_page() ) {
263
+		if (!gravityview_is_admin_page()) {
264 264
 			return;
265 265
 		}
266 266
 
267 267
 		// Dequeue other jQuery styles even if no-conflict is off.
268 268
 		// Terrible-looking tabs help no one.
269
-		if( !empty( $wp_styles->registered ) )  {
269
+		if (!empty($wp_styles->registered)) {
270 270
 			foreach ($wp_styles->registered as $key => $style) {
271
-				if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) {
272
-					wp_dequeue_style( $key );
271
+				if (preg_match('/^(?:wp\-)?jquery/ism', $key)) {
272
+					wp_dequeue_style($key);
273 273
 				}
274 274
 			}
275 275
 		}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		$no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode');
278 278
 
279 279
 		// If no conflict is off, jQuery will suffice.
280
-		if( empty( $no_conflict_mode ) ) {
280
+		if (empty($no_conflict_mode)) {
281 281
 			return;
282 282
 		}
283 283
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	        'jquery-qtip.js',
300 300
 	    );
301 301
 
302
-		$this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' );
302
+		$this->remove_conflicts($wp_styles, $wp_allowed_styles, 'styles');
303 303
 
304 304
 		/**
305 305
 		 * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here.
@@ -315,31 +315,31 @@  discard block
 block discarded – undo
315 315
 	 * @param  string $type              Either 'styles' or 'scripts'
316 316
 	 * @return void
317 317
 	 */
318
-	private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) {
318
+	private function remove_conflicts(&$wp_objects, $required_objects, $type = 'scripts') {
319 319
 
320 320
         /**
321 321
          * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n
322 322
          * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles`
323 323
          * @param array $required_objects
324 324
          */
325
-        $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects );
325
+        $required_objects = apply_filters("gravityview_noconflict_{$type}", $required_objects);
326 326
 
327 327
         //reset queue
328 328
         $queue = array();
329
-        foreach( $wp_objects->queue as $object ) {
330
-	        if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) {
329
+        foreach ($wp_objects->queue as $object) {
330
+	        if (in_array($object, $required_objects) || preg_match('/gravityview|gf_|gravityforms/ism', $object)) {
331 331
                 $queue[] = $object;
332 332
             }
333 333
         }
334 334
         $wp_objects->queue = $queue;
335 335
 
336
-        $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects );
336
+        $required_objects = $this->add_script_dependencies($wp_objects->registered, $required_objects);
337 337
 
338 338
         //unregistering scripts
339 339
         $registered = array();
340
-        foreach( $wp_objects->registered as $handle => $script_registration ){
341
-            if( in_array( $handle, $required_objects ) ){
342
-                $registered[ $handle ] = $script_registration;
340
+        foreach ($wp_objects->registered as $handle => $script_registration) {
341
+            if (in_array($handle, $required_objects)) {
342
+                $registered[$handle] = $script_registration;
343 343
             }
344 344
         }
345 345
         $wp_objects->registered = $registered;
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 		//gets all dependent scripts linked to the $scripts array passed
357 357
 		do {
358 358
 			$dependents = array();
359
-			foreach ( $scripts as $script ) {
360
-				$deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array();
361
-				foreach ( $deps as $dep ) {
362
-					if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) {
359
+			foreach ($scripts as $script) {
360
+				$deps = isset($registered[$script]) && is_array($registered[$script]->deps) ? $registered[$script]->deps : array();
361
+				foreach ($deps as $dep) {
362
+					if (!in_array($dep, $scripts) && !in_array($dep, $dependents)) {
363 363
 						$dependents[] = $dep;
364 364
 					}
365 365
 				}
366 366
 			}
367
-			$scripts = array_merge( $scripts, $dependents );
368
-		} while ( ! empty( $dependents ) );
367
+			$scripts = array_merge($scripts, $dependents);
368
+		} while (!empty($dependents));
369 369
 
370 370
 		return $scripts;
371 371
 	}
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 	 * @deprecated since 1.12
386 386
 	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
387 387
 	 */
388
-	public static function add_notice( $notice = array() ) {
389
-		GravityView_Admin_Notices::add_notice( $notice );
388
+	public static function add_notice($notice = array()) {
389
+		GravityView_Admin_Notices::add_notice($notice);
390 390
 	}
391 391
 
392 392
 	/**
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 
409 409
 	 * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
410 410
 	 */
411
-	static function get_plugin_status( $location = '' ) {
412
-		return GravityView_Compatibility::get_plugin_status( $location );
411
+	static function get_plugin_status($location = '') {
412
+		return GravityView_Compatibility::get_plugin_status($location);
413 413
 	}
414 414
 
415 415
 	/**
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`)
423 423
 	 */
424
-	static function is_admin_page( $hook = '', $page = NULL ) {
424
+	static function is_admin_page($hook = '', $page = NULL) {
425 425
 		global $current_screen, $plugin_page, $pagenow, $post;
426 426
 
427
-		if( ! is_admin() ) { return false; }
427
+		if (!is_admin()) { return false; }
428 428
 
429 429
 		$is_page = false;
430 430
 
@@ -432,21 +432,21 @@  discard block
 block discarded – undo
432 432
 
433 433
 		$is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview');
434 434
 
435
-		$is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings';
435
+		$is_gv_settings_get = isset($_GET['page']) && $_GET['page'] === 'gravityview_settings';
436 436
 
437
-		if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) {
438
-			$gv_post = get_post( intval( $_GET['post'] ) );
437
+		if (empty($post) && $pagenow === 'post.php' && !empty($_GET['post'])) {
438
+			$gv_post = get_post(intval($_GET['post']));
439 439
 			$is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview');
440 440
 		} else {
441 441
 			$is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview');
442 442
 		}
443 443
 
444
-		if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) {
444
+		if ($is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get) {
445 445
 
446 446
 			// $_GET `post_type` variable
447
-			if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) {
447
+			if (in_array($pagenow, array('post.php', 'post-new.php'))) {
448 448
 				$is_page = 'single';
449
-			} else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) {
449
+			} else if (in_array($plugin_page, array('gravityview_settings', 'gravityview_page_gravityview_settings')) || (!empty($_GET['page']) && $_GET['page'] === 'gravityview_settings')) {
450 450
 				$is_page = 'settings';
451 451
 			} else {
452 452
 				$is_page = 'views';
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
 		 * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`)
459 459
 		 * @param[in] string $hook The name of the page to check against. Is passed to the method.
460 460
 		 */
461
-		$is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook );
461
+		$is_page = apply_filters('gravityview_is_admin_page', $is_page, $hook);
462 462
 
463 463
 		// If the current page is the same as the compared page
464
-		if( !empty( $page ) ) {
464
+		if (!empty($page)) {
465 465
 			return $is_page === $page;
466 466
 		}
467 467
 
@@ -473,5 +473,5 @@  discard block
 block discarded – undo
473 473
 new GravityView_Admin;
474 474
 
475 475
 function gravityview_is_admin_page($hook = '', $page = NULL) {
476
-	return GravityView_Admin::is_admin_page( $hook, $page );
476
+	return GravityView_Admin::is_admin_page($hook, $page);
477 477
 }
Please login to merge, or discard this patch.
includes/class-ajax.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@  discard block
 block discarded – undo
5 5
 	function __construct() {
6 6
 
7 7
 		//get field options
8
-		add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) );
8
+		add_action('wp_ajax_gv_field_options', array($this, 'get_field_options'));
9 9
 
10 10
 		// get available fields
11
-		add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) );
11
+		add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html'));
12 12
 
13 13
 		// get active areas
14
-		add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) );
14
+		add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas'));
15 15
 
16 16
 		// get preset fields
17
-		add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) );
17
+		add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config'));
18 18
 
19 19
 		// get preset fields
20
-		add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) );
20
+		add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form'));
21 21
 
22
-		add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) );
22
+		add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields'));
23 23
 	}
24 24
 
25 25
 	/**
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return bool
32 32
 	 */
33
-	private function _exit( $mixed = NULL ) {
33
+	private function _exit($mixed = NULL) {
34 34
 
35 35
 		/**
36 36
 		 * Don't exit if we're running test suite.
37 37
 		 * @since 1.15
38 38
 		 */
39
-		if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
39
+		if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) {
40 40
 			return $mixed;
41 41
 		}
42 42
 
43
-		exit( $mixed );
43
+		exit($mixed);
44 44
 	}
45 45
 
46 46
 	/** -------- AJAX ---------- */
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 */
52 52
 	function check_ajax_nonce() {
53
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) {
54
-			$this->_exit( false );
53
+		if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) {
54
+			$this->_exit(false);
55 55
 		}
56 56
 	}
57 57
 
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
 		//check nonce
68 68
 		$this->check_ajax_nonce();
69 69
 
70
-		$context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory';
70
+		$context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory';
71 71
 
72 72
 		// If Form was changed, JS sends form ID, if start fresh, JS sends template_id
73
-		if( !empty( $_POST['form_id'] ) ) {
74
-			do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context );
73
+		if (!empty($_POST['form_id'])) {
74
+			do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context);
75 75
 			$this->_exit();
76
-		} elseif( !empty( $_POST['template_id'] ) ) {
77
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
78
-			do_action( 'gravityview_render_available_fields', $form, $context );
76
+		} elseif (!empty($_POST['template_id'])) {
77
+			$form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
78
+			do_action('gravityview_render_available_fields', $form, $context);
79 79
 			$this->_exit();
80 80
 		}
81 81
 
82 82
 		//if everything fails..
83
-		$this->_exit( false );
83
+		$this->_exit(false);
84 84
 	}
85 85
 
86 86
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 	function get_active_areas() {
95 95
 		$this->check_ajax_nonce();
96 96
 
97
-		if( empty( $_POST['template_id'] ) ) {
98
-			$this->_exit( false );
97
+		if (empty($_POST['template_id'])) {
98
+			$this->_exit(false);
99 99
 		}
100 100
 
101 101
 		ob_start();
102
-		do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true );
102
+		do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true);
103 103
 		$response['directory'] = ob_get_clean();
104 104
 
105 105
 		ob_start();
106
-		do_action( 'gravityview_render_directory_active_areas',  $_POST['template_id'], 'single', '', true );
106
+		do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true);
107 107
 		$response['single'] = ob_get_clean();
108 108
 
109
-		$response = array_map( 'gravityview_strip_whitespace', $response );
109
+		$response = array_map('gravityview_strip_whitespace', $response);
110 110
 
111
-		$this->_exit( json_encode( $response ) );
111
+		$this->_exit(json_encode($response));
112 112
 	}
113 113
 
114 114
 	/**
@@ -119,49 +119,49 @@  discard block
 block discarded – undo
119 119
 
120 120
 		$this->check_ajax_nonce();
121 121
 
122
-		if( empty( $_POST['template_id'] ) ) {
123
-			$this->_exit( false );
122
+		if (empty($_POST['template_id'])) {
123
+			$this->_exit(false);
124 124
 		}
125 125
 
126 126
 		// get the fields xml config file for this specific preset
127
-		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] );
127
+		$preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']);
128 128
 		// import fields
129
-		if( !empty( $preset_fields_path ) ) {
130
-			$presets = $this->import_fields( $preset_fields_path );
129
+		if (!empty($preset_fields_path)) {
130
+			$presets = $this->import_fields($preset_fields_path);
131 131
 		} else {
132
-			$presets = array( 'widgets' => array(), 'fields' => array() );
132
+			$presets = array('widgets' => array(), 'fields' => array());
133 133
 		}
134 134
 
135
-		$template_id = esc_attr( $_POST['template_id'] );
135
+		$template_id = esc_attr($_POST['template_id']);
136 136
 
137 137
 		// template areas
138
-		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
139
-        $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' );
138
+		$template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory');
139
+        $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single');
140 140
 
141 141
 		// widget areas
142 142
 		$default_widget_areas = GravityView_Plugin::get_default_widget_areas();
143 143
 
144 144
 		ob_start();
145
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] );
145
+		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']);
146 146
 		$response['header'] = ob_get_clean();
147 147
 
148 148
 		ob_start();
149
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] );
149
+		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']);
150 150
 		$response['footer'] = ob_get_clean();
151 151
 
152 152
 		ob_start();
153
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] );
153
+		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']);
154 154
 		$response['directory'] = ob_get_clean();
155 155
 
156 156
 		ob_start();
157
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] );
157
+		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']);
158 158
 		$response['single'] = ob_get_clean();
159 159
 
160
-		$response = array_map( 'gravityview_strip_whitespace', $response );
160
+		$response = array_map('gravityview_strip_whitespace', $response);
161 161
 
162
-		do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response );
162
+		do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response);
163 163
 
164
-		$this->_exit( json_encode( $response ) );
164
+		$this->_exit(json_encode($response));
165 165
 	}
166 166
 
167 167
 	/**
@@ -173,26 +173,26 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$this->check_ajax_nonce();
175 175
 
176
-		if( empty( $_POST['template_id'] ) ) {
177
-			do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' );
178
-			$this->_exit( false );
176
+		if (empty($_POST['template_id'])) {
177
+			do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.');
178
+			$this->_exit(false);
179 179
 		}
180 180
 
181 181
 		// get the xml for this specific template_id
182
-		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] );
182
+		$preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']);
183 183
 
184 184
 		// import form
185
-		$form = $this->import_form( $preset_form_xml_path );
185
+		$form = $this->import_form($preset_form_xml_path);
186 186
 
187 187
 		// get the form ID
188
-		if( false === $form ) {
188
+		if (false === $form) {
189 189
 			// send error to user
190
-			do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] );
190
+			do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']);
191 191
 
192
-			$this->_exit( false );
192
+			$this->_exit(false);
193 193
 		}
194 194
 
195
-		$this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' );
195
+		$this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>');
196 196
 
197 197
 	}
198 198
 
@@ -202,24 +202,24 @@  discard block
 block discarded – undo
202 202
 	 * @param  string $xml_or_json_path Path to form XML or JSON file
203 203
 	 * @return int|bool       Imported form ID or false
204 204
 	 */
205
-	function import_form( $xml_or_json_path = '' ) {
205
+	function import_form($xml_or_json_path = '') {
206 206
 
207
-		do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path );
207
+		do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path);
208 208
 
209
-		if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) {
210
-			do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path );
209
+		if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) {
210
+			do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path);
211 211
 			return false;
212 212
 		}
213 213
 
214 214
 		// import form
215 215
 		$forms = '';
216
-		$count = GFExport::import_file( $xml_or_json_path, $forms );
216
+		$count = GFExport::import_file($xml_or_json_path, $forms);
217 217
 
218
-		do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count );
219
-		do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms );
218
+		do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count);
219
+		do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms);
220 220
 
221
-		if( $count != 1 || empty( $forms[0]['id'] ) ) {
222
-			do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' );
221
+		if ($count != 1 || empty($forms[0]['id'])) {
222
+			do_action('gravityview_log_error', '[import_form] Form Import Failed!');
223 223
 			return false;
224 224
 		}
225 225
 
@@ -238,26 +238,26 @@  discard block
 block discarded – undo
238 238
 	function get_field_options() {
239 239
 		$this->check_ajax_nonce();
240 240
 
241
-		if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) {
242
-			do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' );
243
-			$this->_exit( false );
241
+		if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) {
242
+			do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ');
243
+			$this->_exit(false);
244 244
 		}
245 245
 
246 246
 		// Fix apostrophes added by JSON response
247
-		$_post = array_map( 'stripslashes_deep', $_POST );
247
+		$_post = array_map('stripslashes_deep', $_POST);
248 248
 
249 249
 		// Sanitize
250
-		$_post = array_map( 'esc_attr', $_post );
250
+		$_post = array_map('esc_attr', $_post);
251 251
 
252 252
 		// The GF type of field: `product`, `name`, `creditcard`, `id`, `text`
253
-		$input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL;
254
-		$context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL;
253
+		$input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL;
254
+		$context = isset($_post['context']) ? esc_attr($_post['context']) : NULL;
255 255
 
256
-		$response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context  );
256
+		$response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context);
257 257
 
258
-		$response = gravityview_strip_whitespace( $response );
258
+		$response = gravityview_strip_whitespace($response);
259 259
 
260
-		$this->_exit( $response );
260
+		$this->_exit($response);
261 261
 	}
262 262
 
263 263
 	/**
@@ -274,23 +274,23 @@  discard block
 block discarded – undo
274 274
 		$form = '';
275 275
 
276 276
 		// if form id is set, use it, else, get form from preset
277
-		if( !empty( $_POST['form_id'] ) ) {
277
+		if (!empty($_POST['form_id'])) {
278 278
 
279
-			$form = (int) $_POST['form_id'];
279
+			$form = (int)$_POST['form_id'];
280 280
 
281 281
 		}
282 282
 		// get form from preset
283
-		elseif( !empty( $_POST['template_id'] ) ) {
283
+		elseif (!empty($_POST['template_id'])) {
284 284
 
285
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
285
+			$form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']);
286 286
 
287 287
 		}
288 288
 
289
-		$response = gravityview_get_sortable_fields( $form );
289
+		$response = gravityview_get_sortable_fields($form);
290 290
 
291
-		$response = gravityview_strip_whitespace( $response );
291
+		$response = gravityview_strip_whitespace($response);
292 292
 
293
-		$this->_exit( $response );
293
+		$this->_exit($response);
294 294
 	}
295 295
 
296 296
 	/**
@@ -298,35 +298,35 @@  discard block
 block discarded – undo
298 298
 	 * @param  string $template_id Preset template
299 299
 	 *
300 300
 	 */
301
-	static function pre_get_form_fields( $template_id = '') {
301
+	static function pre_get_form_fields($template_id = '') {
302 302
 
303
-		if( empty( $template_id ) ) {
304
-			do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' );
303
+		if (empty($template_id)) {
304
+			do_action('gravityview_log_error', __METHOD__.' - Template ID not set.');
305 305
 			return false;
306 306
 		} else {
307
-			$form_file = apply_filters( 'gravityview_template_formxml', '', $template_id );
308
-			if( !file_exists( $form_file )  ) {
309
-				do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file );
307
+			$form_file = apply_filters('gravityview_template_formxml', '', $template_id);
308
+			if (!file_exists($form_file)) {
309
+				do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file);
310 310
 				return false;
311 311
 			}
312 312
 		}
313 313
 
314 314
 		// Load xml parser (from GravityForms)
315
-		if( class_exists( 'GFCommon' ) ) {
316
-			$xml_parser = GFCommon::get_base_path() . '/xml.php';
315
+		if (class_exists('GFCommon')) {
316
+			$xml_parser = GFCommon::get_base_path().'/xml.php';
317 317
 		} else {
318
-			$xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php';
318
+			$xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php';
319 319
 		}
320 320
 
321
-		if( file_exists( $xml_parser ) ) {
322
-			require_once( $xml_parser );
321
+		if (file_exists($xml_parser)) {
322
+			require_once($xml_parser);
323 323
 		} else {
324
-			do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser );
324
+			do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser);
325 325
 			return false;
326 326
 		}
327 327
 
328 328
 		// load file
329
-		$xmlstr = file_get_contents( $form_file );
329
+		$xmlstr = file_get_contents($form_file);
330 330
 
331 331
         $options = array(
332 332
             "page" => array("unserialize_as_array" => true),
@@ -345,21 +345,21 @@  discard block
 block discarded – undo
345 345
 		$xml = new RGXML($options);
346 346
         $forms = $xml->unserialize($xmlstr);
347 347
 
348
-        if( !$forms ) {
349
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file );
348
+        if (!$forms) {
349
+        	do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file);
350 350
         	return false;
351 351
         }
352 352
 
353
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
353
+        if (!empty($forms[0]) && is_array($forms[0])) {
354 354
         	$form = $forms[0];
355 355
         }
356 356
 
357
-        if( empty( $form ) ) {
358
-        	do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms );
357
+        if (empty($form)) {
358
+        	do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms);
359 359
         	return false;
360 360
         }
361 361
 
362
-        do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form );
362
+        do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form);
363 363
 
364 364
         return $form;
365 365
 
@@ -371,46 +371,46 @@  discard block
 block discarded – undo
371 371
 	 * @param  string $file path to file
372 372
 	 * @return array       Fields config array (unserialized)
373 373
 	 */
374
-	function import_fields( $file ) {
374
+	function import_fields($file) {
375 375
 
376
-		if( empty( $file ) || !file_exists(  $file ) ) {
377
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file );
376
+		if (empty($file) || !file_exists($file)) {
377
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file);
378 378
 			return false;
379 379
 		}
380 380
 
381
-		if( !class_exists('WXR_Parser') ) {
382
-			include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php';
381
+		if (!class_exists('WXR_Parser')) {
382
+			include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php';
383 383
 		}
384 384
 
385 385
 		$parser = new WXR_Parser();
386
-		$presets = $parser->parse( $file );
386
+		$presets = $parser->parse($file);
387 387
 
388
-		if(is_wp_error( $presets )) {
389
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets );
388
+		if (is_wp_error($presets)) {
389
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets);
390 390
 			return false;
391 391
 		}
392 392
 
393
-		if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) {
394
-			do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file );
393
+		if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) {
394
+			do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file);
395 395
 			return false;
396 396
 		}
397 397
 
398
-		do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] );
398
+		do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']);
399 399
 
400 400
 		$fields = $widgets = array();
401
-		foreach( $presets['posts'][0]['postmeta'] as $meta ) {
401
+		foreach ($presets['posts'][0]['postmeta'] as $meta) {
402 402
 			switch ($meta['key']) {
403 403
 				case '_gravityview_directory_fields':
404
-					$fields = maybe_unserialize( $meta['value'] );
404
+					$fields = maybe_unserialize($meta['value']);
405 405
 					break;
406 406
 				case '_gravityview_directory_widgets':
407
-					$widgets = maybe_unserialize( $meta['value'] );
407
+					$widgets = maybe_unserialize($meta['value']);
408 408
 					break;
409 409
 			}
410 410
 		}
411 411
 
412
-		do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields );
413
-		do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets );
412
+		do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields);
413
+		do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets);
414 414
 
415 415
 		return array(
416 416
 			'fields' => $fields,
Please login to merge, or discard this patch.
includes/class-cache.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 * @since 1.13.1
33 33
 	 * @var array Columns in the database for leads
34 34
 	 */
35
-	private $lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' );
35
+	private $lead_db_columns = array('id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status');
36 36
 
37 37
 	/**
38 38
 	 *
39 39
 	 * @param array|int $form_ids Form ID or array of form IDs used in a request
40 40
 	 * @param array $args Extra request parameters used to generate the query. This is used to generate the unique transient key.
41 41
 	 */
42
-	function __construct( $form_ids = NULL, $args = array() ) {
42
+	function __construct($form_ids = NULL, $args = array()) {
43 43
 
44 44
 		$this->add_hooks();
45 45
 
46
-		if ( ! is_null( $form_ids ) ) {
46
+		if (!is_null($form_ids)) {
47 47
 
48 48
 			$this->form_ids = $form_ids;
49 49
 
@@ -59,31 +59,31 @@  discard block
 block discarded – undo
59 59
 	function add_hooks() {
60 60
 
61 61
 		// Schedule cleanup of expired transients
62
-		add_action( 'wp', array( $this, 'schedule_transient_cleanup' ) );
62
+		add_action('wp', array($this, 'schedule_transient_cleanup'));
63 63
 
64 64
 		// Hook in to the scheduled cleanup, if scheduled
65
-		add_action( 'gravityview-expired-transients', array( $this, 'delete_expired_transients' ) );
65
+		add_action('gravityview-expired-transients', array($this, 'delete_expired_transients'));
66 66
 
67 67
 		// Trigger this when you need to prevent any results from being cached with forms that have been modified
68
-		add_action( 'gravityview_clear_form_cache', array( $this, 'blacklist_add' ) );
68
+		add_action('gravityview_clear_form_cache', array($this, 'blacklist_add'));
69 69
 
70 70
 		/**
71 71
 		 * @since 1.14
72 72
 		 */
73
-		add_action( 'gravityview_clear_entry_cache', array( $this, 'entry_status_changed' ) );
73
+		add_action('gravityview_clear_entry_cache', array($this, 'entry_status_changed'));
74 74
 
75
-		add_action( 'gform_after_update_entry', array( $this, 'entry_updated' ), 10, 2 );
75
+		add_action('gform_after_update_entry', array($this, 'entry_updated'), 10, 2);
76 76
 
77
-		add_action( 'gform_entry_created', array( $this, 'entry_created' ), 10, 2 );
77
+		add_action('gform_entry_created', array($this, 'entry_created'), 10, 2);
78 78
 
79 79
 		/**
80 80
 		 * @see RGFormsModel::update_lead_property() Trigger when any entry property changes
81 81
 		 */
82
-		foreach( $this->lead_db_columns as $column ) {
83
-			add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 );
82
+		foreach ($this->lead_db_columns as $column) {
83
+			add_action('gform_update_'.$column, array($this, 'entry_status_changed'), 10, 3);
84 84
 		}
85 85
 
86
-		add_action( 'gform_delete_lead', array( $this, 'entry_status_changed' ), 10 );
86
+		add_action('gform_delete_lead', array($this, 'entry_status_changed'), 10);
87 87
 	}
88 88
 
89 89
 	/**
@@ -99,22 +99,22 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return void
101 101
 	 */
102
-	public function entry_status_changed( $lead_id, $property_value = '', $previous_value = '' ) {
102
+	public function entry_status_changed($lead_id, $property_value = '', $previous_value = '') {
103 103
 
104 104
 		/** @var array $entry */
105
-		$entry = GFAPI::get_entry( $lead_id );
105
+		$entry = GFAPI::get_entry($lead_id);
106 106
 
107
-		if ( is_wp_error( $entry ) ) {
107
+		if (is_wp_error($entry)) {
108 108
 
109 109
 			/** @var WP_Error $entry */
110
-			do_action( 'gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message() );
110
+			do_action('gravityview_log_error', __METHOD__.' Could not retrieve entry '.$lead_id.' to delete it: '.$entry->get_error_message());
111 111
 
112 112
 			return;
113 113
 		}
114 114
 
115
-		do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) );
115
+		do_action('gravityview_log_debug', __METHOD__.' adding form '.$entry['form_id'].' to blacklist because entry #'.$lead_id.' was deleted', array('value' => $property_value, 'previous' => $previous_value));
116 116
 		
117
-		$this->blacklist_add( $entry['form_id'] );
117
+		$this->blacklist_add($entry['form_id']);
118 118
 	}
119 119
 
120 120
 	/**
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return void
127 127
 	 */
128
-	public function entry_updated( $form, $lead_id ) {
128
+	public function entry_updated($form, $lead_id) {
129 129
 
130
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' );
130
+		do_action('gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form '.$form['id'].' to blacklist because entry #'.$lead_id.' was updated');
131 131
 
132
-		$this->blacklist_add( $form['id'] );
132
+		$this->blacklist_add($form['id']);
133 133
 	}
134 134
 
135 135
 	/**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return void
144 144
 	 */
145
-	public function entry_created( $entry, $form ) {
145
+	public function entry_created($entry, $form) {
146 146
 
147
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' );
147
+		do_action('gravityview_log_debug', 'GravityView_Cache[entry_created] adding form '.$form['id'].' to blacklist because entry #'.$entry['id'].' was created');
148 148
 
149
-		$this->blacklist_add( $form['id'] );
149
+		$this->blacklist_add($form['id']);
150 150
 	}
151 151
 
152 152
 	/**
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @return string           Prefix for the cache string used in set_key()
158 158
 	 */
159
-	protected function get_cache_key_prefix( $form_ids = NULL ) {
159
+	protected function get_cache_key_prefix($form_ids = NULL) {
160 160
 
161
-		if ( is_null( $form_ids ) ) {
161
+		if (is_null($form_ids)) {
162 162
 			$form_ids = $this->form_ids;
163 163
 		}
164 164
 
165 165
 		// Normally just one form, but supports multiple forms
166 166
 		//
167 167
 		// Array of IDs 12, 5, 14 would result in `f-12f-5f-14`
168
-		$forms = 'f:' . implode( '&f:', (array) $form_ids );
168
+		$forms = 'f:'.implode('&f:', (array)$form_ids);
169 169
 
170 170
 		// Prefix for transient keys
171 171
 		// Now the prefix would be: `gv-cache-f-12f-5f-14`
172
-		return 'gv-cache-' . $forms . '-';
172
+		return 'gv-cache-'.$forms.'-';
173 173
 
174 174
 	}
175 175
 
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	protected function set_key() {
180 180
 
181 181
 		// Don't set key if no forms have been set.
182
-		if ( empty( $this->form_ids ) ) {
182
+		if (empty($this->form_ids)) {
183 183
 			return;
184 184
 		}
185 185
 
186
-		$key = $this->get_cache_key_prefix() . sha1( serialize( $this->args ) );
186
+		$key = $this->get_cache_key_prefix().sha1(serialize($this->args));
187 187
 
188 188
 		// The transient name column can handle up to 64 characters.
189 189
 		// The `_transient_timeout_` prefix that is prepended to the string is 11 characters.
190 190
 		// 64 - 19 = 45
191 191
 		// We make sure the key isn't too long or else WP doesn't store data.
192
-		$this->key = substr( $key, 0, 45 );
192
+		$this->key = substr($key, 0, 45);
193 193
 	}
194 194
 
195 195
 	/**
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @return boolean           False if value was not updated and true if value was updated.
212 212
 	 */
213
-	public function blacklist_add( $form_ids ) {
213
+	public function blacklist_add($form_ids) {
214 214
 
215
-		$blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() );
215
+		$blacklist = get_option(self::BLACKLIST_OPTION_NAME, array());
216 216
 
217
-		$form_ids = is_array( $form_ids ) ? $form_ids : array( $form_ids );
217
+		$form_ids = is_array($form_ids) ? $form_ids : array($form_ids);
218 218
 
219
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array(
219
+		do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array(
220 220
 			'$form_ids'  => $form_ids,
221 221
 			'$blacklist' => $blacklist
222
-		) );
222
+		));
223 223
 
224 224
 		// Add the passed form IDs
225
-		$blacklist = array_merge( $blacklist, $form_ids );
225
+		$blacklist = array_merge($blacklist, $form_ids);
226 226
 
227 227
 		// Don't duplicate
228
-		$blacklist = array_unique( $blacklist );
228
+		$blacklist = array_unique($blacklist);
229 229
 
230
-		return update_option( self::BLACKLIST_OPTION_NAME, $blacklist );
230
+		return update_option(self::BLACKLIST_OPTION_NAME, $blacklist);
231 231
 
232 232
 	}
233 233
 
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return boolean           Whether the removal was successful
240 240
 	 */
241
-	public function blacklist_remove( $form_ids ) {
241
+	public function blacklist_remove($form_ids) {
242 242
 
243
-		$blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() );
243
+		$blacklist = get_option(self::BLACKLIST_OPTION_NAME, array());
244 244
 
245
-		$updated_list = array_diff( $blacklist, (array) $form_ids );
245
+		$updated_list = array_diff($blacklist, (array)$form_ids);
246 246
 
247
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array(
247
+		do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array(
248 248
 			'$form_ids'     => $form_ids,
249 249
 			'$blacklist'    => $blacklist,
250 250
 			'$updated_list' => $updated_list
251
-		) );
251
+		));
252 252
 
253
-		return update_option( self::BLACKLIST_OPTION_NAME, $updated_list );
253
+		return update_option(self::BLACKLIST_OPTION_NAME, $updated_list);
254 254
 	}
255 255
 
256 256
 
@@ -261,25 +261,25 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return [type] [description]
263 263
 	 */
264
-	function in_blacklist( $form_ids = NULL ) {
264
+	function in_blacklist($form_ids = NULL) {
265 265
 
266
-		$blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() );
266
+		$blacklist = get_option(self::BLACKLIST_OPTION_NAME, array());
267 267
 
268 268
 		// Use object var if exists
269
-		$form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids;
269
+		$form_ids = is_null($form_ids) ? $this->form_ids : $form_ids;
270 270
 
271
-		if ( empty( $form_ids ) ) {
271
+		if (empty($form_ids)) {
272 272
 
273
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids );
273
+			do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids);
274 274
 
275 275
 			return false;
276 276
 		}
277 277
 
278
-		foreach ( (array) $form_ids as $form_id ) {
278
+		foreach ((array)$form_ids as $form_id) {
279 279
 
280
-			if ( in_array( $form_id, $blacklist ) ) {
280
+			if (in_array($form_id, $blacklist)) {
281 281
 
282
-				do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #' . esc_attr( $form_id ) . ' is in the cache blacklist' );
282
+				do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #'.esc_attr($form_id).' is in the cache blacklist');
283 283
 
284 284
 				return true;
285 285
 			}
@@ -296,35 +296,35 @@  discard block
 block discarded – undo
296 296
 	 *
297 297
 	 * @return mixed      False: Not using cache or cache was a WP_Error object; NULL: no results found; Mixed: cache value
298 298
 	 */
299
-	public function get( $key = NULL ) {
299
+	public function get($key = NULL) {
300 300
 
301
-		$key = is_null( $key ) ? $this->key : $key;
301
+		$key = is_null($key) ? $this->key : $key;
302 302
 
303
-		if ( ! $this->use_cache() ) {
303
+		if (!$this->use_cache()) {
304 304
 
305
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results' );
305
+			do_action('gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results');
306 306
 
307 307
 			return false;
308 308
 		}
309 309
 
310
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key ' . $key );
310
+		do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key '.$key);
311 311
 
312
-		$result = get_transient( $key );
312
+		$result = get_transient($key);
313 313
 
314
-		if ( is_wp_error( $result ) ) {
314
+		if (is_wp_error($result)) {
315 315
 
316
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result );
316
+			do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result);
317 317
 
318 318
 			return false;
319 319
 
320
-		} elseif ( $result ) {
320
+		} elseif ($result) {
321 321
 
322
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Cached results found for  transient key ' . $key );
322
+			do_action('gravityview_log_debug', 'GravityView_Cache[get] Cached results found for  transient key '.$key);
323 323
 
324 324
 			return $result;
325 325
 		}
326 326
 
327
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[get] No cached results found for  transient key ' . $key );
327
+		do_action('gravityview_log_debug', 'GravityView_Cache[get] No cached results found for  transient key '.$key);
328 328
 
329 329
 		return NULL;
330 330
 
@@ -338,24 +338,24 @@  discard block
 block discarded – undo
338 338
 	 * @param [type] $content     [description]
339 339
 	 * @param [type] $filter_name Name used to modify the cache time. Will be set to `gravityview_cache_time_{$filter_name}`.
340 340
 	 */
341
-	public function set( $content, $filter_name = '' ) {
341
+	public function set($content, $filter_name = '') {
342 342
 
343 343
 		// Don't cache empty results
344
-		if ( ! empty( $content ) ) {
344
+		if (!empty($content)) {
345 345
 
346 346
 			/**
347 347
 			 * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache
348 348
 			 * @param int $time_in_seconds Default: `DAY_IN_SECONDS`
349 349
 			 */
350
-			$cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS );
350
+			$cache_time = (int)apply_filters('gravityview_cache_time_'.$filter_name, DAY_IN_SECONDS);
351 351
 
352
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' );
352
+			do_action('gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key '.$this->key.' for '.$cache_time.' seconds');
353 353
 
354
-			return set_transient( $this->key, $content, $cache_time );
354
+			return set_transient($this->key, $content, $cache_time);
355 355
 
356 356
 		}
357 357
 
358
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty' );
358
+		do_action('gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty');
359 359
 
360 360
 		return false;
361 361
 
@@ -371,39 +371,39 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return [type]           [description]
373 373
 	 */
374
-	public function delete( $form_ids = NULL ) {
374
+	public function delete($form_ids = NULL) {
375 375
 		global $wpdb;
376 376
 
377 377
 		// Use object var if exists
378
-		$form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids;
378
+		$form_ids = is_null($form_ids) ? $this->form_ids : $form_ids;
379 379
 
380
-		if ( empty( $form_ids ) ) {
381
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs' );
380
+		if (empty($form_ids)) {
381
+			do_action('gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs');
382 382
 
383 383
 			return;
384 384
 		}
385 385
 
386
-		foreach ( (array) $form_ids as $form_id ) {
386
+		foreach ((array)$form_ids as $form_id) {
387 387
 
388
-			$key = $this->get_cache_key_prefix( $form_id );
388
+			$key = $this->get_cache_key_prefix($form_id);
389 389
 
390 390
 			// WordPress 4.0+
391
-			if ( is_callable( array( $wpdb, 'esc_like' ) ) ) {
392
-				$key = $wpdb->esc_like( $key );
391
+			if (is_callable(array($wpdb, 'esc_like'))) {
392
+				$key = $wpdb->esc_like($key);
393 393
 			} else {
394
-				$key = like_escape( $key );
394
+				$key = like_escape($key);
395 395
 			}
396 396
 
397
-			$key = "%" . $key . "%";
397
+			$key = "%".$key."%";
398 398
 
399
-			$sql = $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key );
399
+			$sql = $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key);
400 400
 
401
-			$result = $wpdb->query( $sql );
401
+			$result = $wpdb->query($sql);
402 402
 
403
-			do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #' . $form_id, array(
403
+			do_action('gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #'.$form_id, array(
404 404
 				$sql,
405
-				sprintf( 'Deleted results: %d', $result )
406
-			) );
405
+				sprintf('Deleted results: %d', $result)
406
+			));
407 407
 		}
408 408
 
409 409
 	}
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 		 * @filter `gravityview_cleanup_transients` Override GravityView cleanup of transients by setting this to false
422 422
 		 * @param boolean $cleanup Whether to run the GravityView auto-cleanup of transients. Default: `true`
423 423
 		 */
424
-		$cleanup = apply_filters( 'gravityview_cleanup_transients', true );
424
+		$cleanup = apply_filters('gravityview_cleanup_transients', true);
425 425
 
426
-		if ( ! $cleanup ) {
426
+		if (!$cleanup) {
427 427
 			return;
428 428
 		}
429 429
 
430
-		if ( ! wp_next_scheduled( 'gravityview-expired-transients' ) ) {
431
-			wp_schedule_event( time(), 'daily', 'gravityview-expired-transients' );
430
+		if (!wp_next_scheduled('gravityview-expired-transients')) {
431
+			wp_schedule_event(time(), 'daily', 'gravityview-expired-transients');
432 432
 		}
433 433
 	}
434 434
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		$threshold = time() - 60;
454 454
 
455 455
 		// get table name for options on specified blog
456
-		$table = $wpdb->get_blog_prefix( $blog_id ) . 'options';
456
+		$table = $wpdb->get_blog_prefix($blog_id).'options';
457 457
 
458 458
 		// delete expired transients, using the paired timeout record to find them
459 459
 		$sql = "
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 			and t1.option_value < '$threshold'
465 465
 		";
466 466
 
467
-		$num_results = $wpdb->query( $sql );
467
+		$num_results = $wpdb->query($sql);
468 468
 
469 469
 		// delete orphaned transient expirations
470 470
 		// also delete NextGEN Gallery 2.x display cache timeout aliases
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
 			and option_value < '$threshold'
480 480
 		";
481 481
 
482
-		$num_results += $wpdb->query( $sql );
482
+		$num_results += $wpdb->query($sql);
483 483
 
484
-		do_action( 'gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted ' . $num_results . ' expired transient records from the database' );
484
+		do_action('gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted '.$num_results.' expired transient records from the database');
485 485
 	}
486 486
 
487 487
 	/**
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 
496 496
 		$use_cache = true;
497 497
 
498
-		if ( GVCommon::has_cap( 'edit_gravityviews' ) ) {
498
+		if (GVCommon::has_cap('edit_gravityviews')) {
499 499
 
500
-			if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) {
500
+			if (isset($_GET['cache']) || isset($_GET['nocache'])) {
501 501
 
502
-				do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' );
502
+				do_action('gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL');
503 503
 
504 504
 				$use_cache = false;
505 505
 			}
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 		}
508 508
 
509 509
 		// Has the form been flagged as having changed items in it?
510
-		if ( $this->in_blacklist() ) {
510
+		if ($this->in_blacklist()) {
511 511
 
512 512
 			// Delete caches for all items with form IDs XYZ
513
-			$this->delete( $this->form_ids );
513
+			$this->delete($this->form_ids);
514 514
 
515 515
 			// Remove the form from
516
-			$this->blacklist_remove( $this->form_ids );
516
+			$this->blacklist_remove($this->form_ids);
517 517
 
518 518
 		}
519 519
 
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 		 * @param[out,in]  boolean $use_cache Previous setting
525 525
 		 * @param[out] GravityView_Cache $this The GravityView_Cache object
526 526
 		 */
527
-		$use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this );
527
+		$use_cache = apply_filters('gravityview_use_cache', $use_cache, $this);
528 528
 
529
-		return (boolean) $use_cache;
529
+		return (boolean)$use_cache;
530 530
 	}
531 531
 
532 532
 }
Please login to merge, or discard this patch.
includes/class-data.php 1 patch
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @param null $passed_post
17 17
 	 */
18
-	private function __construct( $passed_post = NULL ) {
18
+	private function __construct($passed_post = NULL) {
19 19
 
20
-		if( !empty( $passed_post ) ) {
20
+		if (!empty($passed_post)) {
21 21
 
22
-			$id_or_id_array = $this->maybe_get_view_id( $passed_post );
22
+			$id_or_id_array = $this->maybe_get_view_id($passed_post);
23 23
 
24
-			if( !empty( $id_or_id_array ) ) {
25
-				$this->add_view( $id_or_id_array );
24
+			if (!empty($id_or_id_array)) {
25
+				$this->add_view($id_or_id_array);
26 26
 			}
27 27
 		}
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public function has_multiple_views() {
35 35
 
36 36
 		//multiple views
37
-		return count( $this->get_views() ) > 1 ? true : false;
37
+		return count($this->get_views()) > 1 ? true : false;
38 38
 	}
39 39
 
40 40
 
@@ -52,37 +52,37 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed.
54 54
 	 */
55
-	public function maybe_get_view_id( $passed_post ) {
55
+	public function maybe_get_view_id($passed_post) {
56 56
 
57 57
 		$ids = array();
58 58
 
59
-		if( ! empty( $passed_post ) ) {
59
+		if (!empty($passed_post)) {
60 60
 
61
-			if( is_numeric( $passed_post ) ) {
62
-				$passed_post = get_post( $passed_post );
61
+			if (is_numeric($passed_post)) {
62
+				$passed_post = get_post($passed_post);
63 63
 			}
64 64
 
65 65
 			// Convert WP_Posts into WP_Posts[] array
66
-			if( $passed_post instanceof WP_Post ) {
67
-				$passed_post = array( $passed_post );
66
+			if ($passed_post instanceof WP_Post) {
67
+				$passed_post = array($passed_post);
68 68
 			}
69 69
 
70
-			if( is_array( $passed_post ) ) {
70
+			if (is_array($passed_post)) {
71 71
 
72
-				foreach ( $passed_post as &$post) {
73
-					if( ( get_post_type( $post ) === 'gravityview' ) ) {
72
+				foreach ($passed_post as &$post) {
73
+					if ((get_post_type($post) === 'gravityview')) {
74 74
 						$ids[] = $post->ID;
75
-					} else{
75
+					} else {
76 76
 						// Parse the Post Content
77
-						$id = $this->parse_post_content( $post->post_content );
78
-						if( $id ) {
79
-							$ids = array_merge( $ids, (array) $id );
77
+						$id = $this->parse_post_content($post->post_content);
78
+						if ($id) {
79
+							$ids = array_merge($ids, (array)$id);
80 80
 						}
81 81
 
82 82
 						// Parse the Post Meta
83
-						$id = $this->parse_post_meta( $post->ID );
84
-						if( $id ) {
85
-							$ids = array_merge( $ids, (array) $id );
83
+						$id = $this->parse_post_meta($post->ID);
84
+						if ($id) {
85
+							$ids = array_merge($ids, (array)$id);
86 86
 						}
87 87
 					}
88 88
 
@@ -90,33 +90,33 @@  discard block
 block discarded – undo
90 90
 
91 91
 			} else {
92 92
 
93
-				if ( is_string( $passed_post ) ) {
93
+				if (is_string($passed_post)) {
94 94
 
95
-					$id = $this->parse_post_content( $passed_post );
96
-					if( $id ) {
97
-						$ids = array_merge( $ids, (array) $id );
95
+					$id = $this->parse_post_content($passed_post);
96
+					if ($id) {
97
+						$ids = array_merge($ids, (array)$id);
98 98
 					}
99 99
 
100 100
 				} else {
101
-					$id = $this->get_id_from_atts( $passed_post );
102
-					$ids[] = intval( $id );
101
+					$id = $this->get_id_from_atts($passed_post);
102
+					$ids[] = intval($id);
103 103
 				}
104 104
 			}
105 105
 		}
106 106
 
107
-		if( empty($ids) ) {
107
+		if (empty($ids)) {
108 108
 			return NULL;
109 109
 		}
110 110
 
111 111
 		// If it's just one ID, return that.
112 112
 		// Otherwise, return array of IDs
113
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
113
+		return (sizeof($ids) === 1) ? $ids[0] : $ids;
114 114
 	}
115 115
 
116
-	public static function getInstance( $passed_post = NULL ) {
116
+	public static function getInstance($passed_post = NULL) {
117 117
 
118
-		if( empty( self::$instance ) ) {
119
-			self::$instance = new GravityView_View_Data( $passed_post );
118
+		if (empty(self::$instance)) {
119
+			self::$instance = new GravityView_View_Data($passed_post);
120 120
 		}
121 121
 
122 122
 		return self::$instance;
@@ -126,25 +126,25 @@  discard block
 block discarded – undo
126 126
 		return $this->views;
127 127
 	}
128 128
 
129
-	function get_view( $view_id, $atts = NULL ) {
129
+	function get_view($view_id, $atts = NULL) {
130 130
 
131
-		if( ! is_numeric( $view_id) ) {
132
-			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) );
131
+		if (!is_numeric($view_id)) {
132
+			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id));
133 133
 			return false;
134 134
 		}
135 135
 
136 136
 		// Backup: the view hasn't been fetched yet. Doing it now.
137
-		if ( ! isset( $this->views[ $view_id ] ) ) {
138
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) );
139
-			return $this->add_view( $view_id, $atts );
137
+		if (!isset($this->views[$view_id])) {
138
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id));
139
+			return $this->add_view($view_id, $atts);
140 140
 		}
141 141
 
142
-		if ( empty( $this->views[ $view_id ] ) ) {
143
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) );
142
+		if (empty($this->views[$view_id])) {
143
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id));
144 144
 			return false;
145 145
 		}
146 146
 
147
-		return $this->views[ $view_id ];
147
+		return $this->views[$view_id];
148 148
 	}
149 149
 
150 150
 	/**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 * @return   bool          True if the post exists; otherwise, false.
157 157
 	 * @since    1.0.0
158 158
 	 */
159
-	function view_exists( $view_id ) {
160
-		return is_string( get_post_status( $view_id ) );
159
+	function view_exists($view_id) {
160
+		return is_string(get_post_status($view_id));
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,56 +168,56 @@  discard block
 block discarded – undo
168 168
 	 * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional)
169 169
 	 * @return type
170 170
 	 */
171
-	function add_view( $view_id, $atts = NULL ) {
171
+	function add_view($view_id, $atts = NULL) {
172 172
 
173 173
 		// Handle array of IDs
174
-		if( is_array( $view_id ) ) {
175
-			foreach( $view_id as $id ) {
174
+		if (is_array($view_id)) {
175
+			foreach ($view_id as $id) {
176 176
 
177
-				$this->add_view( $id, $atts );
177
+				$this->add_view($id, $atts);
178 178
 			}
179 179
 
180 180
 			return $this->views;
181 181
 		}
182 182
 
183 183
 		// The view has been set already; returning stored view.
184
-		if ( !empty( $this->views[ $view_id ] ) ) {
185
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) );
186
-			return $this->views[ $view_id ];
184
+		if (!empty($this->views[$view_id])) {
185
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id));
186
+			return $this->views[$view_id];
187 187
 		}
188 188
 
189
-		if( ! $this->view_exists( $view_id ) ) {
190
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) );
189
+		if (!$this->view_exists($view_id)) {
190
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id));
191 191
 			return false;
192 192
 		}
193 193
 
194
-		$form_id = gravityview_get_form_id( $view_id );
194
+		$form_id = gravityview_get_form_id($view_id);
195 195
 
196
-		if( empty( $form_id ) ) {
196
+		if (empty($form_id)) {
197 197
 
198
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) );
198
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id));
199 199
 
200 200
 			return false;
201 201
 		}
202 202
 
203 203
 		// Get the settings for the View ID
204
-		$view_settings = gravityview_get_template_settings( $view_id );
204
+		$view_settings = gravityview_get_template_settings($view_id);
205 205
 
206
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings );
206
+		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings);
207 207
 
208 208
 		// Merge the view settings with the defaults
209
-		$view_defaults = wp_parse_args( $view_settings, self::get_default_args() );
209
+		$view_defaults = wp_parse_args($view_settings, self::get_default_args());
210 210
 
211
-		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults );
211
+		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults);
212 212
 
213
-		if( ! empty( $atts ) && is_array( $atts ) ) {
213
+		if (!empty($atts) && is_array($atts)) {
214 214
 
215
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts );
215
+			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts);
216 216
 
217 217
 			// Get the settings from the shortcode and merge them with defaults.
218
-			$atts = shortcode_atts( $view_defaults, $atts );
218
+			$atts = shortcode_atts($view_defaults, $atts);
219 219
 
220
-			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts );
220
+			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts);
221 221
 
222 222
 		} else {
223 223
 
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
 
227 227
 		}
228 228
 
229
-		unset( $atts['id'], $view_defaults, $view_settings );
229
+		unset($atts['id'], $view_defaults, $view_settings);
230 230
 
231 231
 		$data = array(
232 232
 			'id' => $view_id,
233 233
 			'view_id' => $view_id,
234 234
 			'form_id' => $form_id,
235
-			'template_id' => gravityview_get_template_id( $view_id ),
235
+			'template_id' => gravityview_get_template_id($view_id),
236 236
 			'atts' => $atts,
237
-			'fields' => $this->get_fields( $view_id ),
238
-			'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ),
239
-			'form' => gravityview_get_form( $form_id ),
237
+			'fields' => $this->get_fields($view_id),
238
+			'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true),
239
+			'form' => gravityview_get_form($form_id),
240 240
 		);
241 241
 
242
-		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data );
242
+		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data);
243 243
 
244
-		$this->views[ $view_id ] = $data;
244
+		$this->views[$view_id] = $data;
245 245
 
246
-		return $this->views[ $view_id ];
246
+		return $this->views[$view_id];
247 247
 	}
248 248
 
249 249
 	/**
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	 * @param  int $view_id View ID
254 254
 	 * @return array          Array of fields as passed by `gravityview_get_directory_fields()`
255 255
 	 */
256
-	function get_fields( $view_id ) {
256
+	function get_fields($view_id) {
257 257
 
258
-		$dir_fields = gravityview_get_directory_fields( $view_id );
259
-		do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields );
258
+		$dir_fields = gravityview_get_directory_fields($view_id);
259
+		do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields);
260 260
 
261 261
 		// remove fields according to visitor visibility permissions (if logged-in)
262
-		$dir_fields = $this->filter_fields( $dir_fields );
263
-		do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields );
262
+		$dir_fields = $this->filter_fields($dir_fields);
263
+		do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields);
264 264
 
265 265
 		return $dir_fields;
266 266
 	}
@@ -272,18 +272,18 @@  discard block
 block discarded – undo
272 272
 	 * @param array $dir_fields
273 273
 	 * @return array
274 274
 	 */
275
-	private function filter_fields( $dir_fields ) {
275
+	private function filter_fields($dir_fields) {
276 276
 
277
-		if( empty( $dir_fields ) || !is_array( $dir_fields ) ) {
277
+		if (empty($dir_fields) || !is_array($dir_fields)) {
278 278
 			return $dir_fields;
279 279
 		}
280 280
 
281
-		foreach( $dir_fields as $area => $fields ) {
281
+		foreach ($dir_fields as $area => $fields) {
282 282
 
283
-			foreach( (array)$fields as $uniqid => $properties ) {
283
+			foreach ((array)$fields as $uniqid => $properties) {
284 284
 
285
-				if( $this->hide_field_check_conditions( $properties ) ) {
286
-					unset( $dir_fields[ $area ][ $uniqid ] );
285
+				if ($this->hide_field_check_conditions($properties)) {
286
+					unset($dir_fields[$area][$uniqid]);
287 287
 				}
288 288
 
289 289
 			}
@@ -301,31 +301,31 @@  discard block
 block discarded – undo
301 301
 	 * @param array $properties
302 302
 	 * @return void|boolean (field should be hidden) or false (field should be presented)
303 303
 	 */
304
-	private function hide_field_check_conditions( $properties ) {
304
+	private function hide_field_check_conditions($properties) {
305 305
 
306 306
 		// logged-in visibility
307
-		if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) {
307
+		if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) {
308 308
 			return true;
309 309
 		}
310 310
 
311 311
 		return false;
312 312
 	}
313 313
 
314
-	function get_id_from_atts( $atts ) {
314
+	function get_id_from_atts($atts) {
315 315
 
316
-		$atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts );
316
+		$atts = is_array($atts) ? $atts : shortcode_parse_atts($atts);
317 317
 
318 318
 		// Get the settings from the shortcode and merge them with defaults.
319
-		$atts = wp_parse_args( $atts, self::get_default_args() );
319
+		$atts = wp_parse_args($atts, self::get_default_args());
320 320
 
321
-		$view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL;
321
+		$view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL;
322 322
 
323
-		if( empty( $view_id ) && !empty( $atts['id'] ) ) {
323
+		if (empty($view_id) && !empty($atts['id'])) {
324 324
 			$view_id = (int)$atts['id'];
325 325
 		}
326 326
 
327
-		if( empty( $view_id ) ) {
328
-			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts );
327
+		if (empty($view_id)) {
328
+			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts);
329 329
 			return;
330 330
 		}
331 331
 
@@ -341,50 +341,50 @@  discard block
 block discarded – undo
341 341
 	 * @param  string $content $post->post_content content
342 342
 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL
343 343
 	 */
344
-	function parse_post_content( $content ) {
344
+	function parse_post_content($content) {
345 345
 
346 346
 		/**
347 347
 		 * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin
348 348
 		 * @since 1.6
349 349
 		 */
350
-		if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) {
350
+		if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) {
351 351
 			new GravityView_Shortcode;
352 352
 		}
353 353
 
354
-		$shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' );
354
+		$shortcodes = gravityview_has_shortcode_r($content, 'gravityview');
355 355
 
356
-		if( empty( $shortcodes ) ) {
356
+		if (empty($shortcodes)) {
357 357
 			return NULL;
358 358
 		}
359 359
 
360
-		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes );
360
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes);
361 361
 
362 362
 		$ids = array();
363 363
 
364 364
 		foreach ($shortcodes as $key => $shortcode) {
365 365
 
366
-			$args = shortcode_parse_atts( $shortcode[3] );
366
+			$args = shortcode_parse_atts($shortcode[3]);
367 367
 
368
-			if( empty( $args['id'] ) ) {
369
-				do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode );
368
+			if (empty($args['id'])) {
369
+				do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode);
370 370
 				continue;
371 371
 			}
372 372
 
373
-			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args );
373
+			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args);
374 374
 
375 375
 			// Store the View to the object for later fetching.
376
-			$this->add_view( $args['id'], $args );
376
+			$this->add_view($args['id'], $args);
377 377
 
378 378
 			$ids[] = $args['id'];
379 379
 		}
380 380
 
381
-		if( empty($ids) ) {
381
+		if (empty($ids)) {
382 382
 			return NULL;
383 383
 		}
384 384
 
385 385
 		// If it's just one ID, return that.
386 386
 		// Otherwise, return array of IDs
387
-		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids;
387
+		return (sizeof($ids) === 1) ? $ids[0] : $ids;
388 388
 
389 389
 	}
390 390
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @param int $post_id WP_Post ID
396 396
 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL
397 397
 	 */
398
-	private function parse_post_meta( $post_id ) {
398
+	private function parse_post_meta($post_id) {
399 399
 
400 400
 		/**
401 401
 		 * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content
@@ -403,32 +403,32 @@  discard block
 block discarded – undo
403 403
 		 * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array
404 404
 		 * @param[in] int $post_id ID of the post being checked
405 405
 		 */
406
-		$meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id );
406
+		$meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id);
407 407
 
408
-		if( empty( $meta_keys ) ) {
408
+		if (empty($meta_keys)) {
409 409
 			return NULL;
410 410
 		}
411 411
 
412
-		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys );
412
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys);
413 413
 
414 414
 		$meta_content = '';
415 415
 
416
-		foreach( $meta_keys as $key ) {
417
-			$meta = get_post_meta( $post_id, $key , true );
418
-			if( ! is_string( $meta ) ) {
416
+		foreach ($meta_keys as $key) {
417
+			$meta = get_post_meta($post_id, $key, true);
418
+			if (!is_string($meta)) {
419 419
 				continue;
420 420
 			}
421
-			$meta_content .= $meta . ' ';
421
+			$meta_content .= $meta.' ';
422 422
 		}
423 423
 
424
-		if( empty( $meta_content ) ) {
425
-			do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys );
424
+		if (empty($meta_content)) {
425
+			do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys);
426 426
 			return NULL;
427 427
 		}
428 428
 
429
-		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content );
429
+		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content);
430 430
 
431
-		return $this->parse_post_content( $meta_content );
431
+		return $this->parse_post_content($meta_content);
432 432
 
433 433
 	}
434 434
 
@@ -444,61 +444,61 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message.
446 446
 	 */
447
-	public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) {
447
+	public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) {
448 448
 
449 449
 		$message = NULL;
450 450
 
451 451
 		// Not invalid if not set!
452
-		if( empty( $post_id ) || empty( $view_id ) ) {
452
+		if (empty($post_id) || empty($view_id)) {
453 453
 
454
-			if( $empty_is_valid ) {
454
+			if ($empty_is_valid) {
455 455
 				return true;
456 456
 			}
457 457
 
458
-			$message = esc_html__( 'The ID is required.', 'gravityview' );
458
+			$message = esc_html__('The ID is required.', 'gravityview');
459 459
 		}
460 460
 
461
-		if( ! $message ) {
462
-			$status = get_post_status( $post_id );
461
+		if (!$message) {
462
+			$status = get_post_status($post_id);
463 463
 
464 464
 			// Nothing exists with that post ID.
465
-			if ( ! is_numeric( $post_id ) ) {
466
-				$message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' );
465
+			if (!is_numeric($post_id)) {
466
+				$message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview');
467 467
 
468 468
 				// @todo Convert to generic article about Embed IDs
469
-				$message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more&hellip;', 'gravityview' ), 'target=_blank' );
469
+				$message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more&hellip;', 'gravityview'), 'target=_blank');
470 470
 			}
471 471
 		}
472 472
 
473
-		if( ! $message ) {
473
+		if (!$message) {
474 474
 
475 475
 			// Nothing exists with that post ID.
476
-			if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) {
477
-				$message = esc_html__( 'There is no post or page with that ID.', 'gravityview' );
476
+			if (empty($status) || in_array($status, array('revision', 'attachment'))) {
477
+				$message = esc_html__('There is no post or page with that ID.', 'gravityview');
478 478
 			}
479 479
 
480 480
 		}
481 481
 
482
-		if( ! $message ) {
483
-			$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id );
482
+		if (!$message) {
483
+			$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id);
484 484
 
485 485
 			// The post or page specified does not contain the shortcode.
486
-			if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) {
487
-				$message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' );
486
+			if (false === in_array($view_id, (array)$view_ids_in_post)) {
487
+				$message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>');
488 488
 			}
489 489
 		}
490 490
 
491
-		if( ! $message ) {
491
+		if (!$message) {
492 492
 
493 493
 			// It's a View
494
-			if( 'gravityview' === get_post_type( $post_id ) ) {
495
-				$message = esc_html__( 'The ID is already a View.', 'gravityview' );;
494
+			if ('gravityview' === get_post_type($post_id)) {
495
+				$message = esc_html__('The ID is already a View.', 'gravityview'); ;
496 496
 			}
497 497
 
498 498
 		}
499 499
 
500
-		if( $message ) {
501
-			return new WP_Error( 'invalid_embed_id', $message );
500
+		if ($message) {
501
+			return new WP_Error('invalid_embed_id', $message);
502 502
 		}
503 503
 
504 504
 		return true;
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
 	 * @param  boolean $with_details Include details
511 511
 	 * @return mixed|array                If using $with_details, return array. Otherwise, mixed.
512 512
 	 */
513
-	public static function get_default_arg( $key, $with_details = false ) {
513
+	public static function get_default_arg($key, $with_details = false) {
514 514
 
515
-		$args = self::get_default_args( $with_details );
515
+		$args = self::get_default_args($with_details);
516 516
 
517
-		if( !isset( $args[ $key ] ) ) { return NULL; }
517
+		if (!isset($args[$key])) { return NULL; }
518 518
 
519
-		return $args[ $key ];
519
+		return $args[$key];
520 520
 	}
521 521
 
522 522
 	/**
@@ -535,13 +535,13 @@  discard block
 block discarded – undo
535 535
 	 *      @param[out] array  $options Array of values to use when generating select, multiselect, radio, or checkboxes fields
536 536
 	 *      @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering.
537 537
 	 */
538
-	public static function get_default_args( $with_details = false, $group = NULL ) {
538
+	public static function get_default_args($with_details = false, $group = NULL) {
539 539
 
540 540
 		/**
541 541
 		 * @filter `gravityview_default_args` Modify the default settings for new Views
542 542
 		 * @param[in,out] array $default_args Array of default args.
543 543
 		 */
544
-		$default_settings = apply_filters( 'gravityview_default_args', array(
544
+		$default_settings = apply_filters('gravityview_default_args', array(
545 545
 			'id' => array(
546 546
 				'label' => __('View ID', 'gravityview'),
547 547
 				'type' => 'number',
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 				'show_in_shortcode' => true,
560 560
 			),
561 561
 			'lightbox' => array(
562
-				'label' => __( 'Enable lightbox for images', 'gravityview' ),
562
+				'label' => __('Enable lightbox for images', 'gravityview'),
563 563
 				'type' => 'checkbox',
564 564
 				'group'	=> 'default',
565 565
 				'value' => 1,
@@ -567,29 +567,29 @@  discard block
 block discarded – undo
567 567
 				'show_in_shortcode' => true,
568 568
 			),
569 569
 			'show_only_approved' => array(
570
-				'label' => __( 'Show only approved entries', 'gravityview' ),
570
+				'label' => __('Show only approved entries', 'gravityview'),
571 571
 				'type' => 'checkbox',
572 572
 				'group'	=> 'default',
573 573
 				'value' => 0,
574 574
 				'show_in_shortcode' => false,
575 575
 			),
576 576
 			'hide_until_searched' => array(
577
-				'label' => __( 'Hide View data until search is performed', 'gravityview' ),
577
+				'label' => __('Hide View data until search is performed', 'gravityview'),
578 578
 				'type' => 'checkbox',
579 579
 				'group'	=> 'default',
580
-				'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ),
580
+				'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'),
581 581
 				'value' => 0,
582 582
 				'show_in_shortcode' => false,
583 583
 			),
584 584
 			'hide_empty' => array(
585
-				'label' 	=> __( 'Hide empty fields', 'gravityview' ),
585
+				'label' 	=> __('Hide empty fields', 'gravityview'),
586 586
 				'group'	=> 'default',
587 587
 				'type'	=> 'checkbox',
588 588
 				'value' => 1,
589 589
 				'show_in_shortcode' => false,
590 590
 			),
591 591
 			'user_edit' => array(
592
-				'label'	=> __( 'Allow User Edit', 'gravityview' ),
592
+				'label'	=> __('Allow User Edit', 'gravityview'),
593 593
 				'group'	=> 'default',
594 594
 				'desc'	=> __('Allow logged-in users to edit entries they created.', 'gravityview'),
595 595
 				'value'	=> 0,
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 				'show_in_shortcode' => true,
599 599
 			),
600 600
 			'user_delete' => array(
601
-				'label'	=> __( 'Allow User Delete', 'gravityview' ),
601
+				'label'	=> __('Allow User Delete', 'gravityview'),
602 602
 				'group'	=> 'default',
603 603
 				'desc'	=> __('Allow logged-in users to delete entries they created.', 'gravityview'),
604 604
 				'value'	=> 0,
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 				'value' => '',
613 613
 				'group'	=> 'sort',
614 614
 				'options' => array(
615
-					'' => __( 'Default', 'gravityview'),
616
-					'date_created' => __( 'Date Created', 'gravityview'),
615
+					'' => __('Default', 'gravityview'),
616
+					'date_created' => __('Date Created', 'gravityview'),
617 617
 				),
618 618
 				'show_in_shortcode' => true,
619 619
 			),
@@ -630,19 +630,19 @@  discard block
 block discarded – undo
630 630
 				'show_in_shortcode' => true,
631 631
 			),
632 632
 			'sort_columns' => array(
633
-				'label' 	=> __( 'Enable sorting by column', 'gravityview' ),
634
-				'left_label' => __( 'Column Sorting', 'gravityview' ),
633
+				'label' 	=> __('Enable sorting by column', 'gravityview'),
634
+				'left_label' => __('Column Sorting', 'gravityview'),
635 635
 				'type' => 'checkbox',
636 636
 				'value' => false,
637 637
 				'group'	=> 'sort',
638 638
 				'tooltip' => NULL,
639 639
 				'show_in_shortcode' => true,
640
-				'show_in_template' => array( 'default_table' ),
640
+				'show_in_template' => array('default_table'),
641 641
 			),
642 642
 			'start_date' => array(
643 643
 				'label' 	=> __('Filter by Start Date', 'gravityview'),
644 644
 				'class'	=> 'gv-datepicker',
645
-				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ),
645
+				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'),
646 646
 				'type' => 'text',
647 647
 				'value' => '',
648 648
 				'group'	=> 'filter',
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 			'end_date' => array(
652 652
 				'label' 	=> __('Filter by End Date', 'gravityview'),
653 653
 				'class'	=> 'gv-datepicker',
654
-				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ),
654
+				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'),
655 655
 				'type' => 'text',
656 656
 				'value' => '',
657 657
 				'group'	=> 'filter',
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
 		));
712 712
 
713 713
 		// By default, we only want the key => value pairing, not the whole array.
714
-		if( empty( $with_details ) ) {
714
+		if (empty($with_details)) {
715 715
 
716 716
 			$defaults = array();
717 717
 
718
-			foreach( $default_settings as $key => $value ) {
719
-				$defaults[ $key ] = $value['value'];
718
+			foreach ($default_settings as $key => $value) {
719
+				$defaults[$key] = $value['value'];
720 720
 			}
721 721
 
722 722
 			return $defaults;
@@ -729,9 +729,9 @@  discard block
 block discarded – undo
729 729
 
730 730
 				// If the $group argument is set for the method,
731 731
 				// ignore any settings that aren't in that group.
732
-				if( !empty( $group ) && is_string( $group ) ) {
733
-					if( empty( $value['group'] ) || $value['group'] !== $group ) {
734
-						unset( $default_settings[ $key ] );
732
+				if (!empty($group) && is_string($group)) {
733
+					if (empty($value['group']) || $value['group'] !== $group) {
734
+						unset($default_settings[$key]);
735 735
 					}
736 736
 				}
737 737
 
Please login to merge, or discard this patch.
includes/class-gravityview-admin-bar.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 	 * @since 1.13
24 24
 	 */
25 25
 	private function add_hooks() {
26
-		add_action( 'add_admin_bar_menus', array( $this, 'remove_links' ), 80 );
27
-		add_action( 'admin_bar_menu', array( $this, 'add_links' ), 85 );
26
+		add_action('add_admin_bar_menus', array($this, 'remove_links'), 80);
27
+		add_action('admin_bar_menu', array($this, 'add_links'), 85);
28 28
 	}
29 29
 
30 30
 	/**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 
56 56
 		$entry_id = $this->gravityview_view->getSingleEntry();
57 57
 
58
-		if ( $entry_id && GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ), $entry_id ) ) {
58
+		if ($entry_id && GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'), $entry_id)) {
59 59
 
60 60
 			$entry = $this->gravityview_view->getEntry();
61 61
 
62
-			$wp_admin_bar->add_menu( array(
62
+			$wp_admin_bar->add_menu(array(
63 63
 				'id' => 'edit-entry',
64
-				'title' => __( 'Edit Entry', 'gravityview' ),
65
-				'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&amp;screen_mode=edit&amp;view=entry&amp;id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ),
66
-			) );
64
+				'title' => __('Edit Entry', 'gravityview'),
65
+				'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_entries&amp;screen_mode=edit&amp;view=entry&amp;id=%d&lid=%d', $entry['form_id'], $entry['id']))),
66
+			));
67 67
 
68 68
 		}
69 69
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		/** @var WP_Admin_Bar $wp_admin_bar */
79 79
 		global $wp_admin_bar;
80 80
 
81
-		if( GVCommon::has_cap('edit_gravityviews') ) {
81
+		if (GVCommon::has_cap('edit_gravityviews')) {
82 82
 
83 83
 			$view_data = GravityView_View_Data::getInstance();
84 84
 
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 
87 87
 			// If there is a View embed, shor Edit View link.
88 88
 			// todo: Support multiple View embeds with a drop-down menu
89
-			if ( ! $this->gravityview_view->isGravityviewPostType() && ! empty( $views ) && ! $view_data->has_multiple_views() ) {
90
-				$view = reset( $views );
89
+			if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) {
90
+				$view = reset($views);
91 91
 
92
-				if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) ) {
93
-					$wp_admin_bar->add_menu( array(
92
+				if (GVCommon::has_cap('edit_gravityview', $view['id'])) {
93
+					$wp_admin_bar->add_menu(array(
94 94
 						'id'    => 'edit-view',
95
-						'title' => __( 'Edit View', 'gravityview' ),
96
-						'href'  => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ),
97
-					) );
95
+						'title' => __('Edit View', 'gravityview'),
96
+						'href'  => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id']))),
97
+					));
98 98
 				}
99 99
 			}
100 100
 		}
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	function remove_links() {
109 109
 
110 110
 		// If we're on the single entry page, we don't want to cause confusion.
111
-		if ( is_admin() || ( $this->gravityview_view->getSingleEntry() && ! $this->gravityview_view->isGravityviewPostType() ) ) {
112
-			remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 );
111
+		if (is_admin() || ($this->gravityview_view->getSingleEntry() && !$this->gravityview_view->isGravityviewPostType())) {
112
+			remove_action('admin_bar_menu', 'wp_admin_bar_edit_menu', 80);
113 113
 		}
114 114
 	}
115 115
 }
Please login to merge, or discard this patch.
includes/class-gravityview-admin-duplicate-view.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 	function __construct() {
16 16
 
17 17
 		// Only run on Admin
18
-		if ( !is_admin() ) {
18
+		if (!is_admin()) {
19 19
 			return;
20 20
 		}
21 21
 
22 22
 		// If the Duplicate Post plugin is active, don't run.
23
-		if( defined('DUPLICATE_POST_CURRENT_VERSION') ) {
23
+		if (defined('DUPLICATE_POST_CURRENT_VERSION')) {
24 24
 			return;
25 25
 		}
26 26
 
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
 	 * @return void
34 34
 	 */
35 35
 	private function add_hooks() {
36
-		add_filter( 'post_row_actions', array( $this, 'make_duplicate_link_row' ), 10, 2 );
36
+		add_filter('post_row_actions', array($this, 'make_duplicate_link_row'), 10, 2);
37 37
 
38 38
 		/**
39 39
 		 * Connect actions to functions
40 40
 		 */
41
-		add_action( 'admin_action_duplicate_view', array( $this, 'save_as_new_view' ) );
42
-		add_action( 'admin_action_duplicate_view_as_draft', array( $this, 'save_as_new_view_draft' ) );
41
+		add_action('admin_action_duplicate_view', array($this, 'save_as_new_view'));
42
+		add_action('admin_action_duplicate_view_as_draft', array($this, 'save_as_new_view_draft'));
43 43
 
44 44
 		// Using our action hooks to copy meta fields
45
-		add_action( 'gv_duplicate_view', array( $this, 'copy_view_meta_info' ), 10, 2 );
45
+		add_action('gv_duplicate_view', array($this, 'copy_view_meta_info'), 10, 2);
46 46
 
47
-		add_filter( 'gravityview_connected_form_links', array( $this, 'connected_form_links' ), 10, 2 );
47
+		add_filter('gravityview_connected_form_links', array($this, 'connected_form_links'), 10, 2);
48 48
 	}
49 49
 
50 50
 	/**
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return array If it's the All Views page, return unedited. Otherwise, add a link to create cloned draft of View
57 57
 	 */
58
-	function connected_form_links( $links = array(), $form = array() ) {
58
+	function connected_form_links($links = array(), $form = array()) {
59 59
 		/** @global WP_Post $post */
60 60
 		global $post;
61 61
 
62 62
 		// We only want to add Clone links to the Edit View metabox
63
-		if( !$this->is_all_views_page() ) {
63
+		if (!$this->is_all_views_page()) {
64 64
 
65
-			if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) {
66
-				$links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>';
65
+			if ($duplicate_links = $this->make_duplicate_link_row(array(), $post)) {
66
+				$links[] = '<span>'.$duplicate_links['edit_as_new_draft'].'</span>';
67 67
 			}
68 68
 
69 69
 		}
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @since 1.6
90 90
 	 */
91
-	private function current_user_can_copy( $post ) {
91
+	private function current_user_can_copy($post) {
92 92
 
93
-		$id = is_object( $post ) ? $post->ID : $post;
93
+		$id = is_object($post) ? $post->ID : $post;
94 94
 
95 95
 		// Can't edit this current View
96
-		return GVCommon::has_cap( 'copy_gravityviews', $id );
96
+		return GVCommon::has_cap('copy_gravityviews', $id);
97 97
 
98 98
 	}
99 99
 
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 * @param string $status The post status
105 105
 	 * @since 1.6
106 106
 	 */
107
-	private function create_duplicate( $post, $status = '' ) {
107
+	private function create_duplicate($post, $status = '') {
108 108
 
109 109
 		// We only want to clone Views
110
-		if ( $post->post_type !== 'gravityview' ) {
110
+		if ($post->post_type !== 'gravityview') {
111 111
 			return;
112 112
 		}
113 113
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		 * @param string|null If string, the status to set for the new View. If empty, use existing View status.
120 120
 		 * @param WP_Post $post View being cloned
121 121
 		 */
122
-		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post );
122
+		$new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post);
123 123
 
124 124
 		$new_view = array(
125 125
 			'menu_order'     => $post->menu_order,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 			'post_mime_type' => $post->post_mime_type,
132 132
 			'post_parent'    => $post->post_parent,
133 133
 			'post_password'  => $post->post_password,
134
-			'post_status'    => ( empty( $new_view_status ) ) ? $post->post_status : $new_view_status,
134
+			'post_status'    => (empty($new_view_status)) ? $post->post_status : $new_view_status,
135 135
 			'post_title'     => $post->post_title,
136 136
 			'post_type'      => $post->post_type,
137 137
 		);
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		 * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false`
143 143
 		 * @param WP_Post $post View being cloned
144 144
 		 */
145
-		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post );
145
+		$copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post);
146 146
 
147
-		if ( $copy_date ) {
147
+		if ($copy_date) {
148 148
 			$new_view['post_date']     = $new_post_date = $post->post_date;
149
-			$new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date );
149
+			$new_view['post_date_gmt'] = get_gmt_from_date($new_post_date);
150 150
 		}
151 151
 
152 152
 		/**
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 		 * @param array $new_view Array of settings to be passed to wp_insert_post()
156 156
 		 * @param WP_Post $post View being cloned
157 157
 		 */
158
-		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post );
158
+		$new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post);
159 159
 
160 160
 		// Magic happens here.
161
-		$new_view_id = wp_insert_post( $new_view );
161
+		$new_view_id = wp_insert_post($new_view);
162 162
 
163 163
 		// If the copy is published or scheduled, we have to set a proper slug.
164
-		if ( $new_view_status == 'publish' || $new_view_status == 'future' ) {
164
+		if ($new_view_status == 'publish' || $new_view_status == 'future') {
165 165
 
166
-			$view_name = wp_unique_post_slug( $post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent );
166
+			$view_name = wp_unique_post_slug($post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent);
167 167
 
168 168
 			$new_view_name_array = array(
169 169
 				'ID' => $new_view_id,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			);
172 172
 
173 173
 			// Update the post into the database
174
-			wp_update_post( $new_view_name_array );
174
+			wp_update_post($new_view_name_array);
175 175
 		}
176 176
 
177 177
 		/**
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		 * @param int $new_view_id The ID of the newly created View
182 182
 		 * @param WP_Post The View that was just cloned
183 183
 		 */
184
-		do_action( 'gv_duplicate_view', $new_view_id, $post );
184
+		do_action('gv_duplicate_view', $new_view_id, $post);
185 185
 
186
-		delete_post_meta( $new_view_id, '_dp_original' );
186
+		delete_post_meta($new_view_id, '_dp_original');
187 187
 
188
-		add_post_meta( $new_view_id, '_dp_original', $post->ID, false );
188
+		add_post_meta($new_view_id, '_dp_original', $post->ID, false);
189 189
 
190 190
 		return $new_view_id;
191 191
 	}
@@ -200,23 +200,23 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return void
202 202
 	 */
203
-	public function copy_view_meta_info( $new_id, $post ) {
203
+	public function copy_view_meta_info($new_id, $post) {
204 204
 
205
-		$post_meta_keys = get_post_custom_keys( $post->ID );
205
+		$post_meta_keys = get_post_custom_keys($post->ID);
206 206
 
207
-		if ( empty( $post_meta_keys ) ) {
207
+		if (empty($post_meta_keys)) {
208 208
 			return;
209 209
 		}
210 210
 
211
-		foreach ( $post_meta_keys as $meta_key ) {
211
+		foreach ($post_meta_keys as $meta_key) {
212 212
 
213
-			$meta_values = get_post_custom_values( $meta_key, $post->ID );
213
+			$meta_values = get_post_custom_values($meta_key, $post->ID);
214 214
 
215
-			foreach ( $meta_values as $meta_value ) {
215
+			foreach ($meta_values as $meta_value) {
216 216
 
217
-				$meta_value = maybe_unserialize( $meta_value );
217
+				$meta_value = maybe_unserialize($meta_value);
218 218
 
219
-				add_post_meta( $new_id, $meta_key, $meta_value );
219
+				add_post_meta($new_id, $meta_key, $meta_value);
220 220
 			}
221 221
 		}
222 222
 	}
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
 	 * @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View'
229 229
 	 * @param WP_Post $post
230 230
 	 */
231
-	public function make_duplicate_link_row( $actions, $post ) {
231
+	public function make_duplicate_link_row($actions, $post) {
232 232
 
233 233
 		// Only process on GravityView Views
234
-		if ( get_post_type( $post ) === 'gravityview' && $this->current_user_can_copy( $post ) ) {
234
+		if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) {
235 235
 
236
-			$clone_link = $this->get_clone_view_link( $post->ID, 'display', false );
237
-			$clone_text = __( 'Clone', 'gravityview' );
238
-			$clone_title = __( 'Clone this View', 'gravityview' );
236
+			$clone_link = $this->get_clone_view_link($post->ID, 'display', false);
237
+			$clone_text = __('Clone', 'gravityview');
238
+			$clone_title = __('Clone this View', 'gravityview');
239 239
 
240
-			$actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title );
240
+			$actions['clone'] = gravityview_get_link($clone_link, $clone_text, 'title='.$clone_title);
241 241
 
242
-			$clone_draft_link = $this->get_clone_view_link( $post->ID );
243
-			$clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' );
244
-			$clone_draft_title = __( 'Copy as a new draft View', 'gravityview' );
242
+			$clone_draft_link = $this->get_clone_view_link($post->ID);
243
+			$clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview');
244
+			$clone_draft_title = __('Copy as a new draft View', 'gravityview');
245 245
 
246
-			$actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title );
246
+			$actions['edit_as_new_draft'] = gravityview_get_link($clone_draft_link, esc_html($clone_draft_text), 'title='.$clone_draft_title);
247 247
 		}
248 248
 
249 249
 		return $actions;
@@ -259,31 +259,31 @@  discard block
 block discarded – undo
259 259
 	 * @param string $draft Optional, default to true
260 260
 	 * @return string
261 261
 	 */
262
-	private function get_clone_view_link( $id = 0, $context = 'display', $draft = true ) {
262
+	private function get_clone_view_link($id = 0, $context = 'display', $draft = true) {
263 263
 
264 264
 		// Make sure they have permission
265
-		if ( false === $this->current_user_can_copy( $id ) ) {
265
+		if (false === $this->current_user_can_copy($id)) {
266 266
 			return '';
267 267
 		}
268 268
 
269 269
 		// Verify the View exists
270
-		if ( !$view = get_post( $id ) ) {
270
+		if (!$view = get_post($id)) {
271 271
 			return '';
272 272
 		}
273 273
 
274 274
 		$action_name = $draft ? "duplicate_view_as_draft" : "duplicate_view";
275 275
 
276
-		$action = '?action=' . $action_name . '&post=' . $view->ID;
276
+		$action = '?action='.$action_name.'&post='.$view->ID;
277 277
 
278
-		if ( 'display' == $context ) {
279
-			$action = esc_html( $action );
278
+		if ('display' == $context) {
279
+			$action = esc_html($action);
280 280
 		}
281 281
 
282
-		$post_type_object = get_post_type_object( $view->post_type );
282
+		$post_type_object = get_post_type_object($view->post_type);
283 283
 
284 284
 		/** If there's no gravityview post type for some reason, abort! */
285
-		if ( !$post_type_object ) {
286
-			do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view );
285
+		if (!$post_type_object) {
286
+			do_action('gravityview_log_error', __METHOD__.' No gravityview post type exists when trying to clone the View.', $view);
287 287
 			return '';
288 288
 		}
289 289
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		 * @param int $view_id View ID
295 295
 		 * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display`
296 296
 		 */
297
-		$clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context );
297
+		$clone_view_link = apply_filters('gravityview/duplicate-view/get_clone_view_link', admin_url("admin.php".$action), $view->ID, $context);
298 298
 
299 299
 		return $clone_view_link;
300 300
 	}
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return void
309 309
 	 */
310 310
 	public function save_as_new_view_draft() {
311
-		$this->save_as_new_view( 'draft' );
311
+		$this->save_as_new_view('draft');
312 312
 	}
313 313
 
314 314
 	/**
@@ -319,38 +319,38 @@  discard block
 block discarded – undo
319 319
 	 * @param string $status The status to set for the new View
320 320
 	 * @return void
321 321
 	 */
322
-	public function save_as_new_view( $status = '' ) {
322
+	public function save_as_new_view($status = '') {
323 323
 
324
-		if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) {
325
-			wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) );
324
+		if (!(isset($_GET['post']) || isset($_POST['post']))) {
325
+			wp_die(__('No post to duplicate has been supplied!', 'gravityview'));
326 326
 		}
327 327
 
328 328
 		// Get the original post
329
-		$id   = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] );
329
+		$id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']);
330 330
 
331
-		if( ! $this->current_user_can_copy( $id ) ) {
332
-			wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) );
331
+		if (!$this->current_user_can_copy($id)) {
332
+			wp_die(__('You don\'t have permission to copy this View.', 'gravityview'));
333 333
 		}
334 334
 
335
-		$post = get_post( $id );
335
+		$post = get_post($id);
336 336
 
337 337
 		// Copy the post and insert it
338
-		if ( isset( $post ) && $post != NULL ) {
338
+		if (isset($post) && $post != NULL) {
339 339
 
340
-			$new_id = $this->create_duplicate( $post, $status );
340
+			$new_id = $this->create_duplicate($post, $status);
341 341
 
342
-			if ( $status == '' ) {
342
+			if ($status == '') {
343 343
 				// Redirect to the post list screen
344
-				wp_redirect( admin_url( 'edit.php?post_type=' . $post->post_type ) );
344
+				wp_redirect(admin_url('edit.php?post_type='.$post->post_type));
345 345
 			} else {
346 346
 				// Redirect to the edit screen for the new draft post
347
-				wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) );
347
+				wp_redirect(admin_url('post.php?action=edit&post='.$new_id));
348 348
 			}
349 349
 			exit;
350 350
 
351 351
 		} else {
352 352
 
353
-			wp_die( sprintf( esc_attr__( 'Copy creation failed, could not find original View with ID #%d', 'gravityview' ), $id ) );
353
+			wp_die(sprintf(esc_attr__('Copy creation failed, could not find original View with ID #%d', 'gravityview'), $id));
354 354
 
355 355
 		}
356 356
 	}
Please login to merge, or discard this patch.
includes/class-gravityview-admin-notices.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * When the plugin is activated, flush dismissed notices
16 16
  * @since 1.15.1
17 17
  */
18
-register_activation_hook( GRAVITYVIEW_FILE, array( 'GravityView_Admin_Notices', 'flush_dismissed_notices' ) );
18
+register_activation_hook(GRAVITYVIEW_FILE, array('GravityView_Admin_Notices', 'flush_dismissed_notices'));
19 19
 
20 20
 /**
21 21
  * Handle displaying and storing of admin notices for GravityView
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 
35 35
 	function add_hooks() {
36
-		add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 );
37
-		add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 );
38
-		add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
39
-		add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 );
36
+		add_action('network_admin_notices', array($this, 'dismiss_notice'), 50);
37
+		add_action('admin_notices', array($this, 'dismiss_notice'), 50);
38
+		add_action('admin_notices', array($this, 'admin_notice'), 100);
39
+		add_action('network_admin_notices', array($this, 'admin_notice'), 100);
40 40
 	}
41 41
 
42 42
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return void
47 47
 	 */
48 48
 	static public function flush_dismissed_notices() {
49
-		delete_transient( 'gravityview_dismissed_notices' );
49
+		delete_transient('gravityview_dismissed_notices');
50 50
 	}
51 51
 
52 52
 	/**
@@ -57,26 +57,26 @@  discard block
 block discarded – undo
57 57
 	public function dismiss_notice() {
58 58
 
59 59
 		// No dismiss sent
60
-		if( empty( $_GET['gv-dismiss'] ) ) {
60
+		if (empty($_GET['gv-dismiss'])) {
61 61
 			return;
62 62
 		}
63 63
 
64 64
 		// Invalid nonce
65
-		if( !wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) {
65
+		if (!wp_verify_nonce($_GET['gv-dismiss'], 'dismiss')) {
66 66
 			return;
67 67
 		}
68 68
 
69
-		$notice_id = esc_attr( $_GET['notice'] );
69
+		$notice_id = esc_attr($_GET['notice']);
70 70
 
71 71
 		//don't display a message if use has dismissed the message for this version
72
-		$dismissed_notices = (array)get_transient( 'gravityview_dismissed_notices' );
72
+		$dismissed_notices = (array)get_transient('gravityview_dismissed_notices');
73 73
 
74 74
 		$dismissed_notices[] = $notice_id;
75 75
 
76
-		$dismissed_notices = array_unique( $dismissed_notices );
76
+		$dismissed_notices = array_unique($dismissed_notices);
77 77
 
78 78
 		// Remind users every 16 weeks
79
-		set_transient( 'gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 );
79
+		set_transient('gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16);
80 80
 
81 81
 	}
82 82
 
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 	 * @param  string $notice            Notice array, set using `add_notice()`.
92 92
 	 * @return boolean                   True: show notice; False: hide notice
93 93
 	 */
94
-	private function is_notice_dismissed( $notice ) {
94
+	private function is_notice_dismissed($notice) {
95 95
 
96 96
 		// There are no dismissed notices.
97
-		if( empty( self::$dismissed_notices ) ) {
97
+		if (empty(self::$dismissed_notices)) {
98 98
 			return false;
99 99
 		}
100 100
 
101 101
 		// Has the
102
-		$is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices );
102
+		$is_dismissed = !empty($notice['dismiss']) && in_array($notice['dismiss'], self::$dismissed_notices);
103 103
 
104 104
 		return $is_dismissed ? true : false;
105 105
 	}
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	private function check_show_multisite_notices() {
126 126
 
127
-		if( ! is_multisite() ) {
127
+		if (!is_multisite()) {
128 128
 			return true;
129 129
 		}
130 130
 
131 131
 		// It's network activated but the user can't manage network plugins; they can't do anything about it.
132
-		if( GravityView_Plugin::is_network_activated() && ! is_main_site() ) {
132
+		if (GravityView_Plugin::is_network_activated() && !is_main_site()) {
133 133
 			return false;
134 134
 		}
135 135
 
136 136
 		// or they don't have admin capabilities
137
-		if( ! is_super_admin() ) {
137
+		if (!is_super_admin()) {
138 138
 			return false;
139 139
 		}
140 140
 
@@ -155,53 +155,53 @@  discard block
 block discarded – undo
155 155
 		 * @filter `gravityview/admin/notices` Modify the notices displayed in the admin
156 156
 		 * @since 1.12
157 157
 		 */
158
-		$notices = apply_filters( 'gravityview/admin/notices', self::$admin_notices );
158
+		$notices = apply_filters('gravityview/admin/notices', self::$admin_notices);
159 159
 
160
-		if( empty( $notices ) || ! $this->check_show_multisite_notices() ) {
160
+		if (empty($notices) || !$this->check_show_multisite_notices()) {
161 161
 			return;
162 162
 		}
163 163
 
164 164
 		//don't display a message if use has dismissed the message for this version
165 165
 		// TODO: Use get_user_meta instead of get_transient
166
-		self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' );
166
+		self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array)get_transient('gravityview_dismissed_notices');
167 167
 
168 168
 		$output = '';
169 169
 
170
-		foreach( $notices as $notice ) {
170
+		foreach ($notices as $notice) {
171 171
 
172 172
 			// If the user doesn't have the capability to see the warning
173
-			if( isset( $notice['cap'] ) && false === GVCommon::has_cap( $notice['cap'] ) ) {
174
-				do_action( 'gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice );
173
+			if (isset($notice['cap']) && false === GVCommon::has_cap($notice['cap'])) {
174
+				do_action('gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice);
175 175
 				continue;
176 176
 			}
177 177
 
178
-			if( true === $this->is_notice_dismissed( $notice ) ) {
179
-				do_action( 'gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice );
178
+			if (true === $this->is_notice_dismissed($notice)) {
179
+				do_action('gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice);
180 180
 				continue;
181 181
 			}
182 182
 
183
-			$output .= '<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice['class'] ).'">';
183
+			$output .= '<div id="message" style="position:relative" class="notice '.gravityview_sanitize_html_class($notice['class']).'">';
184 184
 
185 185
 			// Too cute to leave out.
186 186
 			$output .= gravityview_get_floaty();
187 187
 
188
-			if( !empty( $notice['title'] ) ) {
189
-				$output .= '<h3>'.esc_html( $notice['title'] ) .'</h3>';
188
+			if (!empty($notice['title'])) {
189
+				$output .= '<h3>'.esc_html($notice['title']).'</h3>';
190 190
 			}
191 191
 
192
-			$message = isset( $notice['message'] ) ? $notice['message'] : '';
192
+			$message = isset($notice['message']) ? $notice['message'] : '';
193 193
 
194
-			if( !empty( $notice['dismiss'] ) ) {
194
+			if (!empty($notice['dismiss'])) {
195 195
 
196 196
 				$dismiss = esc_attr($notice['dismiss']);
197 197
 
198
-				$url = esc_url( add_query_arg( array( 'gv-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) );
198
+				$url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss)));
199 199
 
200 200
 				$align = is_rtl() ? 'alignleft' : 'alignright';
201
-				$message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="' . $align . ' button button-link">'.esc_html__('Dismiss', 'gravityview' ).'</a></p>';
201
+				$message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="'.$align.' button button-link">'.esc_html__('Dismiss', 'gravityview').'</a></p>';
202 202
 			}
203 203
 
204
-			$output .= wpautop( $message );
204
+			$output .= wpautop($message);
205 205
 
206 206
 			$output .= '<div class="clear"></div>';
207 207
 			$output .= '</div>';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
 		echo $output;
212 212
 
213
-		unset( $output, $align, $message, $notices );
213
+		unset($output, $align, $message, $notices);
214 214
 
215 215
 		//reset the notices handler
216 216
 		self::$admin_notices = array();
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	 * @param array $notice Array with `class`, `message`, `dismiss` and `cap` keys. The message is not escaped.
224 224
 	 * @return void
225 225
 	 */
226
-	public static function add_notice( $notice = array() ) {
226
+	public static function add_notice($notice = array()) {
227 227
 
228
-		if( !isset( $notice['message'] ) ) {
229
-			do_action( 'gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice );
228
+		if (!isset($notice['message'])) {
229
+			do_action('gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice);
230 230
 			return;
231 231
 		}
232 232
 
233
-		$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
233
+		$notice['class'] = empty($notice['class']) ? 'error' : $notice['class'];
234 234
 
235 235
 		self::$admin_notices[] = $notice;
236 236
 	}
Please login to merge, or discard this patch.
includes/class-gravityview-change-entry-creator.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@  discard block
 block discarded – undo
10 10
     	/**
11 11
     	 * @since  1.5.1
12 12
     	 */
13
-    	add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 );
13
+    	add_action('gform_user_registered', array($this, 'assign_new_user_to_lead'), 10, 4);
14 14
 
15 15
     	// ONLY ADMIN FROM HERE ON.
16
-    	if( !is_admin() ) { return; }
16
+    	if (!is_admin()) { return; }
17 17
 
18 18
 	    /**
19 19
          * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality
20 20
 	     * @since 1.7.4
21 21
 	     * @param boolean $disable Disable the Change Entry Creator functionality. Default: false.
22 22
 	     */
23
-	    if( apply_filters('gravityview_disable_change_entry_creator', false ) ) {
23
+	    if (apply_filters('gravityview_disable_change_entry_creator', false)) {
24 24
 		    return;
25 25
 	    }
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
          * Use `init` to fix bbPress warning
29 29
          * @see https://bbpress.trac.wordpress.org/ticket/2309
30 30
          */
31
-    	add_action('init', array( $this, 'load'), 100 );
31
+    	add_action('init', array($this, 'load'), 100);
32 32
 
33
-    	add_action('plugins_loaded', array( $this, 'prevent_conflicts') );
33
+    	add_action('plugins_loaded', array($this, 'prevent_conflicts'));
34 34
 
35 35
     }
36 36
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param  string $password User password
46 46
      * @return void
47 47
      */
48
-    function assign_new_user_to_lead( $user_id, $config, $entry = array(), $password = '' ) {
48
+    function assign_new_user_to_lead($user_id, $config, $entry = array(), $password = '') {
49 49
 
50 50
     	/**
51 51
     	 * Disable assigning the new user to the entry by returning false.
@@ -53,27 +53,27 @@  discard block
 block discarded – undo
53 53
 	     * @param  array $config   User registration feed configuration
54 54
 	     * @param  array  $entry     GF Entry array
55 55
     	 */
56
-    	$assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry );
56
+    	$assign_to_lead = apply_filters('gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry);
57 57
 
58 58
     	// If filter returns false, do not process
59
-    	if( empty( $assign_to_lead ) ) {
59
+    	if (empty($assign_to_lead)) {
60 60
     		return;
61 61
     	}
62 62
 
63 63
     	// Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing
64
-    	$result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true );
64
+    	$result = RGFormsModel::update_lead_property($entry['id'], 'created_by', $user_id, false, true);
65 65
 
66
-    	if( empty( $result ) ) {
66
+    	if (empty($result)) {
67 67
     		$status = __('Error', 'gravityview');
68 68
     	} else {
69 69
     		$status = __('Success', 'gravityview');
70 70
     	}
71 71
 
72
-    	$note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id );
72
+    	$note = sprintf(_x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id);
73 73
 
74
-    	do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note );
74
+    	do_action('gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note);
75 75
 
76
-        GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' );
76
+        GravityView_Entry_Notes::add_note($entry['id'], -1, 'GravityView', $note, 'gravityview');
77 77
 
78 78
     }
79 79
 
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
     	remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2);
90 90
 
91 91
     	// Disable for Gravity Forms Add-ons 3.6.2 and lower
92
-    	if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) {
92
+    	if (class_exists('KWS_GF_Change_Lead_Creator')) {
93 93
 
94 94
     		$Old_Lead_Creator = new KWS_GF_Change_Lead_Creator;
95 95
 
96 96
     		// Now, no validation is required in the methods; let's hook in.
97
-    		remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) );
97
+    		remove_action('admin_init', array($Old_Lead_Creator, 'set_screen_mode'));
98 98
 
99
-    		remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2);
99
+    		remove_action("gform_entry_info", array($Old_Lead_Creator, 'add_select'), 10, 2);
100 100
 
101
-    		remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2);
101
+    		remove_action("gform_after_update_entry", array($Old_Lead_Creator, 'update_entry_creator'), 10, 2);
102 102
     	}
103 103
 
104 104
     }
@@ -110,26 +110,26 @@  discard block
 block discarded – undo
110 110
     function load() {
111 111
 
112 112
     	// Does GF exist?
113
-        if( !class_exists('GFCommon') ) {
113
+        if (!class_exists('GFCommon')) {
114 114
             return;
115 115
         }
116 116
 
117 117
         // Can the user edit entries?
118
-        if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) {
118
+        if (!GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'))) {
119 119
             return;
120 120
         }
121 121
 
122 122
         // If screen mode isn't set, then we're in the wrong place.
123
-        if( empty( $_REQUEST['screen_mode'] ) ) {
123
+        if (empty($_REQUEST['screen_mode'])) {
124 124
             return;
125 125
         }
126 126
 
127 127
         // Now, no validation is required in the methods; let's hook in.
128
-        add_action('admin_init', array( &$this, 'set_screen_mode' ) );
128
+        add_action('admin_init', array(&$this, 'set_screen_mode'));
129 129
 
130
-        add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2);
130
+        add_action("gform_entry_info", array(&$this, 'add_select'), 10, 2);
131 131
 
132
-        add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2);
132
+        add_action("gform_after_update_entry", array(&$this, 'update_entry_creator'), 10, 2);
133 133
 
134 134
     }
135 135
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     function set_screen_mode() {
141 141
 
142 142
     	// If $_GET['screen_mode'] is set to edit, set $_POST value
143
-        if( rgget('screen_mode') === 'edit' ) {
143
+        if (rgget('screen_mode') === 'edit') {
144 144
             $_POST["screen_mode"] = 'edit';
145 145
         }
146 146
 
@@ -156,38 +156,38 @@  discard block
 block discarded – undo
156 156
             global $current_user;
157 157
 
158 158
         // Update the entry
159
-        $created_by = absint( rgpost('created_by') );
159
+        $created_by = absint(rgpost('created_by'));
160 160
 
161
-        RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by );
161
+        RGFormsModel::update_lead_property($entry_id, 'created_by', $created_by);
162 162
 
163 163
         // If the creator has changed, let's add a note about who it used to be.
164 164
         $originally_created_by = rgpost('originally_created_by');
165 165
 
166 166
         // If there's no owner and there didn't used to be, keep going
167
-        if( empty( $originally_created_by ) && empty( $created_by ) ) {
167
+        if (empty($originally_created_by) && empty($created_by)) {
168 168
             return;
169 169
         }
170 170
 
171 171
         // If the values have changed
172
-        if( absint( $originally_created_by ) !== absint( $created_by ) ) {
172
+        if (absint($originally_created_by) !== absint($created_by)) {
173 173
 
174 174
             $user_data = get_userdata($current_user->ID);
175 175
 
176 176
             $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview');
177 177
 
178
-            $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview');
178
+            $original_name = $created_by_name = esc_attr_x('No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview');
179 179
 
180
-            if( !empty( $originally_created_by ) ) {
180
+            if (!empty($originally_created_by)) {
181 181
                 $originally_created_by_user_data = get_userdata($originally_created_by);
182
-                $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID );
182
+                $original_name = sprintf($user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID);
183 183
             }
184 184
 
185
-            if( !empty( $created_by ) ) {
186
-                $created_by_user_data =  get_userdata($created_by);
187
-                $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID );
185
+            if (!empty($created_by)) {
186
+                $created_by_user_data = get_userdata($created_by);
187
+                $created_by_name = sprintf($user_format, $created_by_user_data->display_name, $created_by_user_data->ID);
188 188
             }
189 189
 
190
-            GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' );
190
+            GravityView_Entry_Notes::add_note($entry_id, $current_user->ID, $user_data->display_name, sprintf(__('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name), 'note');
191 191
         }
192 192
 
193 193
     }
@@ -198,24 +198,24 @@  discard block
 block discarded – undo
198 198
      * @param array $entry    GF entry array
199 199
      * @return void
200 200
      */
201
-    function add_select($form_id, $entry ) {
201
+    function add_select($form_id, $entry) {
202 202
 
203
-        if( rgpost('screen_mode') !== 'edit' ) {
203
+        if (rgpost('screen_mode') !== 'edit') {
204 204
             return;
205 205
         }
206 206
 
207
-        $users = GVCommon::get_users( 'change_entry_creator' );
207
+        $users = GVCommon::get_users('change_entry_creator');
208 208
 
209 209
         $output = '<label for="change_created_by">';
210 210
         $output .= esc_html__('Change Entry Creator:', 'gravityview');
211 211
         $output .= '</label>
212 212
         <select name="created_by" id="change_created_by" class="widefat">';
213
-        $output .= '<option value=""> &mdash; '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' &mdash; </option>';
214
-        foreach($users as $user) {
215
-            $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>';
213
+        $output .= '<option value=""> &mdash; '.esc_attr_x('No User', 'No user assigned to the entry', 'gravityview').' &mdash; </option>';
214
+        foreach ($users as $user) {
215
+            $output .= '<option value="'.$user->ID.'"'.selected($entry['created_by'], $user->ID, false).'>'.esc_attr($user->display_name.' ('.$user->user_nicename.')').'</option>';
216 216
         }
217 217
         $output .= '</select>';
218
-        $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />';
218
+        $output .= '<input name="originally_created_by" value="'.esc_attr($entry['created_by']).'" type="hidden" />';
219 219
         echo $output;
220 220
 
221 221
     }
Please login to merge, or discard this patch.
includes/class-gravityview-compatibility.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.