Changeset 1973642
- Timestamp:
- 11/13/2018 03:31:16 PM (7 years ago)
- Location:
- better-amp/trunk
- Files:
-
- 6 edited
-
better-amp.php (modified) (5 diffs)
-
includes/classes/class-better-amp-content-sanitizer.php (modified) (1 diff)
-
includes/classes/class-better-amp-rewrite-rules.php (modified) (8 diffs)
-
includes/functions/core-functions.php (modified) (4 diffs)
-
includes/functions/theme-functions.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
better-amp/trunk/better-amp.php
r1972445 r1973642 5 5 Description: Add FULL AMP support to your WordPress site. 6 6 Author: Better Studio 7 Version: 1.9. 07 Version: 1.9.1 8 8 Author URI: http://betterstudio.com 9 9 */ … … 53 53 * @since 1.0.0 54 54 */ 55 const VERSION = '1.9. 0';55 const VERSION = '1.9.1'; 56 56 57 57 … … 428 428 if ( $redirect_url ) { 429 429 430 430 431 // todo: use Better_AMP_Content_Sanitizer::transform_to_amp_url 431 432 wp_redirect( $redirect_url ); … … 454 455 public function redirect_to_end_point_amp() { 455 456 456 $request_url = str_replace( bf_get_wp_installation_slug(), '', $_SERVER['REQUEST_URI'] ); 457 $url = parse_url( $_SERVER['REQUEST_URI'] ); 458 $request_url = str_replace( bf_get_wp_installation_slug(), '', $url['path'] ); 457 459 458 460 if ( ! preg_match( '#^/?([^/]+)(.+)#', $request_url, $match ) ) { … … 460 462 } 461 463 464 $url_path = $match[2]; 465 462 466 if ( $match[1] !== Better_AMP::SLUG ) { 463 467 return; 464 468 } 465 469 466 $new_amp_url = Better_AMP_Content_Sanitizer::transform_to_amp_url( home_url( $match[2] ) ); 467 $new_amp_url = trailingslashit( $new_amp_url ); 470 if ( ! empty( $url['query'] ) ) { 471 $url_path = trailingslashit( $url_path ) . '?' . $url['query']; 472 } 473 474 $new_amp_url = Better_AMP_Content_Sanitizer::transform_to_amp_url( home_url( $url_path ) ); 468 475 469 476 if ( $new_amp_url && trim( $match[2], '/' ) !== '' ) { -
better-amp/trunk/includes/classes/class-better-amp-content-sanitizer.php
r1972445 r1973642 341 341 } 342 342 343 if ( basename( $url ) === Better_AMP::SLUG ) { 343 $parsed = parse_url( $url ); 344 $path = isset( $parsed['path'] ) ? $parsed['path'] : '/'; 345 $query = isset( $parsed['query'] ) ? $parsed['query'] : ''; 346 347 if ( basename( $path ) === Better_AMP::SLUG ) { 344 348 345 349 return false; 346 350 } 347 351 348 return trailingslashit( $url ) . Better_AMP::SLUG . '/'; 352 353 $url = sprintf( '%s://%s/%s', $parsed['scheme'], $parsed['host'], ltrim( $parsed['path'], '/' ) ); 354 $url = trailingslashit( $url ) . Better_AMP::SLUG . '/'; 355 356 if ( $query ) { 357 $url .= '?'; 358 $url .= $parsed['query']; 359 } 360 361 return $url; 349 362 } 350 363 -
better-amp/trunk/includes/classes/class-better-amp-rewrite-rules.php
r1956214 r1973642 31 31 */ 32 32 protected $exclude_extra_permastructs = array( 33 'category' => TRUE,34 'post_tag' => TRUE,35 'post_format' => TRUE,33 'category' => true, 34 'post_tag' => true, 35 'post_format' => true, 36 36 37 37 # Woocommerce 38 'product_variation' => TRUE,39 'shop_order_refund' => TRUE,38 'product_variation' => true, 39 'shop_order_refund' => true, 40 40 41 41 # Visual Composer 42 'vc_grid_item' => TRUE,42 'vc_grid_item' => true, 43 43 ); 44 44 … … 90 90 $post_type_archive_ep_mask = EP_ROOT; // i'm not sure! 91 91 92 foreach ( get_post_types( array( '_builtin' => FALSE) ) as $post_type ) {92 foreach ( get_post_types( array( '_builtin' => false ) ) as $post_type ) { 93 93 94 94 if ( isset( $wp_rewrite->extra_rules_top[ $post_type . '/?$' ] ) ) { … … 182 182 183 183 foreach ( (array) $permastructname as $name ) { 184 $this->exclude_extra_permastructs[ $name ] = TRUE;184 $this->exclude_extra_permastructs[ $name ] = true; 185 185 } 186 186 } … … 198 198 $this->exclude_extra_permastructs = array(); 199 199 200 return TRUE;200 return true; 201 201 } 202 202 … … 214 214 */ 215 215 protected function get_current_sp_mask() { 216 216 217 global $wp_rewrite; 217 218 … … 377 378 } 378 379 379 if ( $url_prefix && preg_match( "#^($url_prefix)(.+)$#",$regex,$match) ) {380 if ( $url_prefix && preg_match( "#^($url_prefix)(.+)$#", $regex, $match ) ) { 380 381 381 382 $results[ $match[1] . $spregex . ltrim( $match[2], '/' ) ] = $startpint_query; … … 435 436 * @since 1.0.0 436 437 */ 437 public function add_startpint( $name, $places, $query_var = TRUE, $single_match = TRUE) {438 public function add_startpint( $name, $places, $query_var = true, $single_match = true ) { 438 439 439 440 global $wp; 440 441 441 442 // For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`. 442 if ( TRUE === $query_var || NULL=== func_get_arg( 2 ) ) {443 if ( true === $query_var || null === func_get_arg( 2 ) ) { 443 444 $query_var = $name; 444 445 } … … 476 477 * @since 1.0.0 477 478 */ 478 function better_amp_add_rewrite_startpoint( $name, $places, $query_var = TRUE, $single_match = TRUE) {479 function better_amp_add_rewrite_startpoint( $name, $places, $query_var = true, $single_match = true ) { 479 480 480 481 global $better_amp_rewrite_rules; -
better-amp/trunk/includes/functions/core-functions.php
r1972445 r1973642 21 21 22 22 if ( $wp_query instanceof WP_Query ) { 23 23 24 return false !== $wp_query->get( Better_AMP::STARTPOINT, false ); 24 25 } … … 30 31 // check the $wp_query 31 32 if ( is_null( $wp_query ) ) { 33 32 34 return false; 33 35 } … … 35 37 return false !== $wp_query->get( Better_AMP::STARTPOINT, false ); 36 38 39 37 40 } elseif ( better_amp_using_permalink_structure() ) { 38 41 … … 40 43 $amp_qv = defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR : 'amp'; 41 44 42 return preg_match( "#^$path/*(.*?)/$amp_qv/*$#", $_SERVER['REQUEST_URI'] ) 43 || 44 preg_match( "#^$path/*$amp_qv/*#", $_SERVER['REQUEST_URI'] ); 45 return preg_match( "#^/?$path/*(.*?)/$amp_qv/*$#", $_SERVER['REQUEST_URI'] ) 46 || 47 preg_match( "#^/?$path/*$amp_qv/*#", $_SERVER['REQUEST_URI'] ); 48 45 49 } else { 46 50 -
better-amp/trunk/includes/functions/theme-functions.php
r1972445 r1973642 1176 1176 } 1177 1177 1178 1179 return trailingslashit( $url ); 1178 return $url; 1180 1179 } 1181 1180 } -
better-amp/trunk/readme.txt
r1972445 r1973642 51 51 52 52 == Changelog == 53 54 = 1.9.1 = 55 - Improved: The endpoint URL feature improved. 56 - Fixed: Issue on search page and some other pages in the endpoint AMP flag fixed. 57 - Fixed: Conflict with the Amazon Affiliate Links plugin. 58 53 59 54 60 = 1.9.0 =
Note: See TracChangeset
for help on using the changeset viewer.