Changeset 1765337
- Timestamp:
- 11/13/2017 06:25:51 PM (8 years ago)
- Location:
- better-amp/trunk
- Files:
-
- 4 edited
-
better-amp.php (modified) (3 diffs)
-
includes/functions/core-functions.php (modified) (2 diffs)
-
includes/functions/theme-functions.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
better-amp/trunk/better-amp.php
r1764458 r1765337 5 5 Description: Add FULL AMP support to your WordPress site. 6 6 Author: Better Studio 7 Version: 1.6. 17 Version: 1.6.2 8 8 Author URI: http://betterstudio.com 9 9 */ … … 53 53 * @since 1.0.0 54 54 */ 55 const VERSION = '1.6. 1';55 const VERSION = '1.6.2'; 56 56 57 57 … … 370 370 371 371 $amp_qv = defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR : 'amp'; 372 372 373 if ( get_query_var( $amp_qv, FALSE ) === FALSE ) { 373 return; 374 } 375 376 $path = bf_get_wp_installation_slug(); 377 378 if ( preg_match( "#^$path/*(.*?)/$amp_qv/*$#", $_SERVER['REQUEST_URI'], $matched ) ) { 379 380 381 $new_amp_url = Better_AMP_Content_Sanitizer::transform_to_amp_url( site_url( $matched[1] ) ); 374 375 if ( ! is_404() ) { # /amp at the end of some urls cause 404 error 376 return; 377 } 378 } 379 380 $is_amp_available = TRUE; 381 382 if ( is_singular() ) { 383 384 if ( $post_id = get_queried_object_id() ) { 385 386 $is_amp_available = ! get_post_meta( $post_id, 'disable-better-amp', TRUE ) && ! isset( $this->excluded_posts_id[ $post_id ] ); 387 } 388 } 389 390 $path = bf_get_wp_installation_slug(); 391 $request_url = str_replace( $path, '', $_SERVER['REQUEST_URI'] ); 392 393 preg_match( "#^/*(.*?)/$amp_qv/*$#", $request_url, $automattic_amp_match ); 394 395 if ( ! $is_amp_available ) { 396 397 if ( ! empty( $automattic_amp_match[1] ) ) { 398 399 $redirect_url = site_url( $automattic_amp_match[1] ); 400 401 } elseif ( preg_match( "#^/*$amp_qv/+(.*?)/*$#", $request_url, $matched ) ) { 402 403 $redirect_url = site_url( $matched[1] ); 404 405 } else { 406 407 $redirect_url = ''; 408 } 409 410 if ( $redirect_url ) { 411 412 // todo: use Better_AMP_Content_Sanitizer::transform_to_amp_url 413 wp_redirect( $redirect_url ); 414 exit; 415 } 416 } 417 418 if ( ! empty( $automattic_amp_match[1] ) ) { 419 420 421 $new_amp_url = Better_AMP_Content_Sanitizer::transform_to_amp_url( site_url( $automattic_amp_match[1] ) ); 382 422 $new_amp_url = trailingslashit( $new_amp_url ); 383 423 384 if ( $new_amp_url && trim( str_replace( site_url(), '', $new_amp_url ), '/' ) !== trim( $ _SERVER['REQUEST_URI'], '/' ) ) {424 if ( $new_amp_url && trim( str_replace( site_url(), '', $new_amp_url ), '/' ) !== trim( $request_url, '/' ) ) { 385 425 386 426 wp_redirect( $new_amp_url, 301 ); 387 427 exit; 388 }389 }390 391 if ( is_singular() ) {392 $post_id = get_queried_object_id();393 394 if (395 get_post_meta( $post_id, 'disable-better-amp', TRUE )396 ||397 isset( $this->excluded_posts_id[ $post_id ] )398 ) {399 400 if ( preg_match( "#^$path/*$amp_qv/+(.*?)/*$#", $_SERVER['REQUEST_URI'], $matched ) ) {401 402 // todo: use Better_AMP_Content_Sanitizer::transform_to_amp_url403 wp_redirect( site_url( $matched[1] ) );404 exit;405 }406 428 } 407 429 } -
better-amp/trunk/includes/functions/core-functions.php
r1763773 r1765337 25 25 } 26 26 27 if ( did_action( 'template_redirect' ) ) {27 if ( did_action( 'template_redirect' ) && ! is_404() ) { 28 28 29 29 global $wp_query; … … 41 41 $amp_qv = defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR : 'amp'; 42 42 43 return (bool) preg_match( "#^$path/*(.*?)/$amp_qv/ +#", $_SERVER['REQUEST_URI'] );43 return (bool) preg_match( "#^$path/*(.*?)/$amp_qv/*#", $_SERVER['REQUEST_URI'] ); 44 44 } 45 45 } -
better-amp/trunk/includes/functions/theme-functions.php
r1763773 r1765337 2430 2430 } 2431 2431 2432 $sites = array_intersect_key( $sites, array( // Valid sites 2433 'facebook' => '', 2434 'twitter' => '', 2435 'google_plus' => '', 2436 'pinterest' => '', 2437 'linkedin' => '', 2438 'tumblr' => '', 2439 'reddit' => '', 2440 'stumbleupon' => '', 2432 $sites = array_intersect_key( $sites, array( 2433 // Valid sites 2434 'facebook' => '', 2435 'twitter' => '', 2436 'google_plus' => '', 2437 'pinterest' => '', 2438 'linkedin' => '', 2439 'tumblr' => '', 2440 'reddit' => '', 2441 'stumbleupon' => '', 2441 2442 ) ); 2442 2443 -
better-amp/trunk/readme.txt
r1764458 r1765337 51 51 52 52 == Changelog == 53 54 = 1.6.2 = 55 - Improved: AMP codes improved. 56 - Fixed: Infinite redirect to AMP version in subdirectory wp installations. 57 53 58 54 59 = 1.6.1 =
Note: See TracChangeset
for help on using the changeset viewer.