WordPress.org

Plugin Directory

Changeset 1512429


Ignore:
Timestamp:
10/11/16 05:35:37 (7 months ago)
Author:
batmoo
Message:

Sync from github (0.4.1)

  • no more the_content for featured image
  • no important for inline styles
  • no comment link when comments closed and no comments on post
Location:
amp/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • amp/trunk/amp.php

    r1510272 r1512429  
    66 * Author: Automattic 
    77 * Author URI: https://automattic.com 
    8  * Version: 0.4 
     8 * Version: 0.4.1 
    99 * Text Domain: amp 
    1010 * Domain Path: /languages/ 
     
    1414define( 'AMP__FILE__', __FILE__ ); 
    1515define( 'AMP__DIR__', dirname( __FILE__ ) ); 
    16 define( 'AMP__VERSION', '0.4' ); 
     16define( 'AMP__VERSION', '0.4.1' ); 
    1717 
    1818require_once( AMP__DIR__ . '/back-compat/back-compat.php' ); 
  • amp/trunk/includes/class-amp-content.php

    r1510272 r1512429  
    8383 
    8484    private function sanitize( $content ) { 
     85        list( $sanitized_content, $scripts, $styles ) = AMP_Content_Sanitizer::sanitize( $content, $this->sanitizer_classes, $this->args ); 
     86 
     87        $this->add_scripts( $scripts ); 
     88        $this->add_styles( $styles ); 
     89 
     90        return $sanitized_content; 
     91    } 
     92} 
     93 
     94class AMP_Content_Sanitizer { 
     95    public static function sanitize( $content, $sanitizer_classes, $args = array() ) { 
     96        $scripts = array(); 
     97        $styles = array(); 
    8598        $dom = AMP_DOM_Utils::get_dom_from_content( $content ); 
    8699 
    87         foreach ( $this->sanitizer_classes as $sanitizer_class => $args ) { 
    88             $sanitizer = new $sanitizer_class( $dom, array_merge( $this->args, $args ) ); 
     100        foreach ( $sanitizer_classes as $sanitizer_class => $args ) { 
     101            if ( ! class_exists( $sanitizer_class ) ) { 
     102                _doing_it_wrong( __METHOD__, sprintf( __( 'Sanitizer (%s) class does not exist', 'amp' ), esc_html( $sanitizer_class ) ), '0.4.1' ); 
     103                continue; 
     104            } 
     105 
     106            $sanitizer = new $sanitizer_class( $dom, array_merge( $args, $args ) ); 
    89107 
    90108            if ( ! is_subclass_of( $sanitizer, 'AMP_Base_Sanitizer' ) ) { 
     
    94112 
    95113            $sanitizer->sanitize(); 
    96             $this->add_scripts( $sanitizer->get_scripts() ); 
    97             $this->add_styles( $sanitizer->get_styles() ); 
     114 
     115            $scripts = array_merge( $scripts, $sanitizer->get_scripts() ); 
     116            $styles = array_merge( $styles, $sanitizer->get_styles() ); 
    98117        } 
    99118 
    100         return AMP_DOM_Utils::get_content_from_dom( $dom ); 
     119        $sanitized_content = AMP_DOM_Utils::get_content_from_dom( $dom ); 
     120 
     121        return array( $sanitized_content, $scripts, $styles ); 
    101122    } 
    102123} 
  • amp/trunk/includes/class-amp-post-template.php

    r1510272 r1512429  
    197197        } 
    198198 
     199        $comments_open = comments_open( $this->ID ); 
     200 
     201        // Don't show link if close and no comments  
     202        if ( ! $comments_open 
     203            && ! $this->post->comment_count ) { 
     204            return; 
     205        } 
     206 
    199207        $comments_link_url = get_comments_link( $this->ID ); 
    200         $comments_link_text = comments_open( $this->ID ) 
     208        $comments_link_text = $comments_open 
    201209            ? __( 'Leave a Comment', 'amp' ) 
    202210            : __( 'View Comments', 'amp' ); 
     
    260268        $featured_image = get_post( $featured_id ); 
    261269 
    262         remove_filter( 'the_content', 'wpautop' ); // We don't want our image wrapped in a <p> 
    263         $featured_amp_content = new AMP_Content( 
     270        list( $sanitized_html ) = AMP_Content_Sanitizer::sanitize( 
    264271            $featured_html, 
    265             array(), 
     272            array( 'AMP_Img_Sanitizer' => array() ), 
    266273            array( 
    267                  'AMP_Img_Sanitizer' => array(), 
    268             ), 
    269             array( 
    270                 'content_max_width' => $this->get( 'content_max_width' ), 
     274                'content_max_width' => $this->get( 'content_max_width' ) 
    271275            ) 
    272276        ); 
    273         add_filter( 'the_content', 'wpautop' ); 
    274277 
    275278        $this->add_data_by_key( 'featured_image', array( 
    276             'amp_html' => $featured_amp_content->get_amp_content(), 
     279            'amp_html' => $sanitized_html, 
    277280            'caption' => $featured_image->post_excerpt, 
    278281        ) ); 
  • amp/trunk/includes/sanitizers/class-amp-style-sanitizer.php

    r1510272 r1512429  
    9494        } 
    9595 
     96        // !important is not allowed 
     97        if ( false !== strpos( $value, 'important' ) ) { 
     98            $value = preg_replace( '/\s*\!\s*important$/', '', $value ); 
     99        } 
     100 
    96101        return array( $property, $value ); 
    97102    } 
  • amp/trunk/readme.txt

    r1510278 r1512429  
    44Requires at least: 4.4 
    55Tested up to: 4.6 
    6 Stable tag: 0.4 
     6Stable tag: 0.4.1 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5454== Changelog == 
    5555 
     56= 0.4.1 (2016-10-10 = 
     57 
     58- Fix: Don't fire the_content for featured image output 
     59- Fix: Don't show comment link when disabled and no comments on post (h/t neotrope) 
     60- Fix: strip `!important` from inline styles (h/t compointdesigner and enriccardonagmailcom) 
     61 
    5662= 0.4 (2016-10-06) = 
    5763 
    5864- New template: spiffy, shiny, and has the fresh theme smell (props allancole and the Automattic Theme Team). 
     65- *Warning*: The template update has potential breaking changes. Please see https://wordpress.org/support/topic/v0-4-whats-new-and-possible-breaking-changes/ 
    5966- AMP Customizer: Pick your colours and make the template your own (props DrewAPicture and 10up) 
    6067- Fix: support for inline styles (props coreymckrill). 
Note: See TracChangeset for help on using the changeset viewer.