Completed
Pull Request — master (#1399)
by Zack
11:25 queued 09:00
created
future/includes/class-gv-oembed.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		wp_embed_register_handler( 'gravityview_entry', self::get_entry_regex(), array( __CLASS__, 'render' ), 20000 );
27 27
 		wp_oembed_add_provider( self::get_entry_regex(), self::$provider_url, true );
28 28
 
29
-		if ( ! empty( $_GET['gv_oembed_provider'] ) && ! empty( $_GET['url'] ) ) {
29
+		if ( ! empty( $_GET[ 'gv_oembed_provider' ] ) && ! empty( $_GET[ 'url' ] ) ) {
30 30
 			add_action( 'template_redirect', array( __CLASS__, 'render_provider_request' ) );
31 31
 		}
32 32
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @return void
44 44
 	 */
45 45
 	public static function render_provider_request() {
46
-		if ( ! empty( $_GET['url'] ) ) {
47
-			$url = $_GET['url'];
46
+		if ( ! empty( $_GET[ 'url' ] ) ) {
47
+			$url = $_GET[ 'url' ];
48 48
 		} else {
49 49
 			header( 'HTTP/1.0 404 Not Found' );
50 50
 			exit;
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	private static function parse_matches( $matches, $url ) {
113 113
 		// If not using permalinks, re-assign values for matching groups
114
-		if ( ! empty( $matches['entry_slug2'] ) ) {
115
-			$matches['is_cpt'] = $matches['is_cpt2'];
116
-			$matches['slug'] = $matches['slug2'];
117
-			$matches['entry_slug'] = $matches['entry_slug2'];
118
-			unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] );
114
+		if ( ! empty( $matches[ 'entry_slug2' ] ) ) {
115
+			$matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ];
116
+			$matches[ 'slug' ] = $matches[ 'slug2' ];
117
+			$matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ];
118
+			unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] );
119 119
 		}
120 120
 
121
-		if ( empty( $matches['entry_slug'] ) ) {
121
+		if ( empty( $matches[ 'entry_slug' ] ) ) {
122 122
 			gravityview()->log->error( 'Entry slug not parsed by regex.', array( 'data' => $matches ) );
123 123
 			return null;
124 124
 		} else {
125
-			$entry_id = $matches['entry_slug'];
125
+			$entry_id = $matches[ 'entry_slug' ];
126 126
 		}
127 127
 
128 128
 		if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) {
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 		if ( ! $view ) {
141 141
 
142 142
 			// If the slug doesn't work, maybe using Plain permalinks and not the slug, only ID
143
-			if( is_numeric( $matches['slug'] ) ) {
144
-				$view = \GV\View::by_id( $matches['slug'] );
143
+			if ( is_numeric( $matches[ 'slug' ] ) ) {
144
+				$view = \GV\View::by_id( $matches[ 'slug' ] );
145 145
 			}
146 146
 
147
-			if( ! $view ) {
148
-				$view = \GV\View::from_post( get_page_by_path( $matches['slug'], OBJECT, 'gravityview' ) );
147
+			if ( ! $view ) {
148
+				$view = \GV\View::from_post( get_page_by_path( $matches[ 'slug' ], OBJECT, 'gravityview' ) );
149 149
 			}
150 150
 		}
151 151
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 
177 177
 		return '
178 178
 		<div class="loading-placeholder" style="background-color:#e6f0f5;">
179
-			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3>
179
+			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3>
180 180
 			<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">
181
-				'.$embed_text.'
181
+				'.$embed_text . '
182 182
 			</p>
183 183
 			<br style="clear: both;">
184 184
 		</div>';
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	private static function render_preview_notice() {
193 193
 		$floaty = \GravityView_Admin::get_floaty();
194 194
 		$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' );
195
-		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview');
196
-		return '<div class="updated notice">'.$floaty.'<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>';
195
+		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' );
196
+		return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>';
197 197
 	}
198 198
 
199 199
 	/**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 			return __( 'You are not allowed to view this content.', 'gravityview' );
213 213
 		}
214 214
 
215
-		if ( $entry && 'active' !== $entry['status'] ) {
215
+		if ( $entry && 'active' !== $entry[ 'status' ] ) {
216 216
 			gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
217 217
 			return __( 'You are not allowed to view this content.', 'gravityview' );
218 218
 		}
219 219
 
220 220
 		if ( $view->settings->get( 'show_only_approved' ) ) {
221
-			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
221
+			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
222 222
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
223 223
 				return __( 'You are not allowed to view this content.', 'gravityview' );
224 224
 			}
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 			 * Mocks old context, etc.
250 250
 			 */
251 251
 			$loader = \GravityView_Edit_Entry::getInstance();
252
-			$render = $loader->instances['render'];
252
+			$render = $loader->instances[ 'render' ];
253 253
 
254
-			$form = \GFAPI::get_form( $entry['form_id'] );
254
+			$form = \GFAPI::get_form( $entry[ 'form_id' ] );
255 255
 
256 256
 			// @todo We really need to rewrite Edit Entry soon
257 257
 			\GravityView_View::$instance = null;
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 			$data = \GravityView_View_Data::getInstance( get_post( $view->ID ) );
261 261
 			$template = \GravityView_View::getInstance( array(
262 262
 				'form' => $form,
263
-				'form_id' => $form['id'],
263
+				'form_id' => $form[ 'id' ],
264 264
 				'view_id' => $view->ID,
265 265
 				'entries' => array( $entry->as_entry() ),
266 266
 				'atts' => \GVCommon::get_template_settings( $view->ID ),
267 267
 			) );
268 268
 
269
-			ob_start() && $render->init( $data, \GV\Entry::by_id( $entry['id'] ), $view );
269
+			ob_start() && $render->init( $data, \GV\Entry::by_id( $entry[ 'id' ] ), $view );
270 270
 			$output = ob_get_clean(); // Render :)
271 271
 		} else {
272 272
 			/** Remove the back link. */
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		// Catch either
311 311
 		$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})";
312 312
 
313
-		return '#'.$match_regex.'#i';
313
+		return '#' . $match_regex . '#i';
314 314
 	}
315 315
 
316 316
 	/**
Please login to merge, or discard this patch.