Plugin Directory

Changeset 1973642


Ignore:
Timestamp:
11/13/2018 03:31:16 PM (7 years ago)
Author:
betterstudio
Message:

v1.9.1

Location:
better-amp/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • better-amp/trunk/better-amp.php

    r1972445 r1973642  
    55Description: Add FULL AMP support to your WordPress site.
    66Author: Better Studio
    7 Version: 1.9.0
     7Version: 1.9.1
    88Author URI: http://betterstudio.com
    99*/
     
    5353     * @since 1.0.0
    5454     */
    55     const VERSION = '1.9.0';
     55    const VERSION = '1.9.1';
    5656
    5757
     
    428428            if ( $redirect_url ) {
    429429
     430
    430431                // todo: use Better_AMP_Content_Sanitizer::transform_to_amp_url
    431432                wp_redirect( $redirect_url );
     
    454455    public function redirect_to_end_point_amp() {
    455456
    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'] );
    457459
    458460        if ( ! preg_match( '#^/?([^/]+)(.+)#', $request_url, $match ) ) {
     
    460462        }
    461463
     464        $url_path = $match[2];
     465
    462466        if ( $match[1] !== Better_AMP::SLUG ) {
    463467            return;
    464468        }
    465469
    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 ) );
    468475
    469476        if ( $new_amp_url && trim( $match[2], '/' ) !== '' ) {
  • better-amp/trunk/includes/classes/class-better-amp-content-sanitizer.php

    r1972445 r1973642  
    341341        }
    342342
    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 ) {
    344348
    345349            return false;
    346350        }
    347351
    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;
    349362    }
    350363
  • better-amp/trunk/includes/classes/class-better-amp-rewrite-rules.php

    r1956214 r1973642  
    3131     */
    3232    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,
    3636
    3737        # Woocommerce
    38         'product_variation' => TRUE,
    39         'shop_order_refund' => TRUE,
     38        'product_variation' => true,
     39        'shop_order_refund' => true,
    4040
    4141        # Visual Composer
    42         'vc_grid_item'      => TRUE,
     42        'vc_grid_item'      => true,
    4343    );
    4444
     
    9090        $post_type_archive_ep_mask = EP_ROOT; // i'm not sure!
    9191
    92         foreach ( get_post_types( array( '_builtin' => FALSE ) ) as $post_type ) {
     92        foreach ( get_post_types( array( '_builtin' => false ) ) as $post_type ) {
    9393
    9494            if ( isset( $wp_rewrite->extra_rules_top[ $post_type . '/?$' ] ) ) {
     
    182182
    183183        foreach ( (array) $permastructname as $name ) {
    184             $this->exclude_extra_permastructs[ $name ] = TRUE;
     184            $this->exclude_extra_permastructs[ $name ] = true;
    185185        }
    186186    }
     
    198198        $this->exclude_extra_permastructs = array();
    199199
    200         return TRUE;
     200        return true;
    201201    }
    202202
     
    214214     */
    215215    protected function get_current_sp_mask() {
     216
    216217        global $wp_rewrite;
    217218
     
    377378                        }
    378379
    379                         if ( $url_prefix && preg_match("#^($url_prefix)(.+)$#",$regex,$match) ) {
     380                        if ( $url_prefix && preg_match( "#^($url_prefix)(.+)$#", $regex, $match ) ) {
    380381
    381382                            $results[ $match[1] . $spregex . ltrim( $match[2], '/' ) ] = $startpint_query;
     
    435436     * @since 1.0.0
    436437     */
    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 ) {
    438439
    439440        global $wp;
    440441
    441442        // 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 ) ) {
    443444            $query_var = $name;
    444445        }
     
    476477 * @since 1.0.0
    477478 */
    478 function better_amp_add_rewrite_startpoint( $name, $places, $query_var = TRUE, $single_match = TRUE ) {
     479function better_amp_add_rewrite_startpoint( $name, $places, $query_var = true, $single_match = true ) {
    479480
    480481    global $better_amp_rewrite_rules;
  • better-amp/trunk/includes/functions/core-functions.php

    r1972445 r1973642  
    2121
    2222        if ( $wp_query instanceof WP_Query ) {
     23
    2324            return false !== $wp_query->get( Better_AMP::STARTPOINT, false );
    2425        }
     
    3031            // check the $wp_query
    3132            if ( is_null( $wp_query ) ) {
     33
    3234                return false;
    3335            }
     
    3537            return false !== $wp_query->get( Better_AMP::STARTPOINT, false );
    3638
     39
    3740        } elseif ( better_amp_using_permalink_structure() ) {
    3841
     
    4043            $amp_qv = defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR : 'amp';
    4144
    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
    4549        } else {
    4650
  • better-amp/trunk/includes/functions/theme-functions.php

    r1972445 r1973642  
    11761176        }
    11771177
    1178 
    1179         return trailingslashit( $url );
     1178        return $url;
    11801179    }
    11811180}
  • better-amp/trunk/readme.txt

    r1972445 r1973642  
    5151
    5252== 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
    5359
    5460= 1.9.0 =
Note: See TracChangeset for help on using the changeset viewer.