WordPress.org

Plugin Directory

Changeset 1514204


Ignore:
Timestamp:
10/13/16 21:29:47 (13 months ago)
Author:
batmoo
Message:

Sync from github: 0.4.2

Location:
amp/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • amp/trunk/amp.php

    r1512429 r1514204  
    66 * Author: Automattic 
    77 * Author URI: https://automattic.com 
    8  * Version: 0.4.1 
     8 * Version: 0.4.2 
    99 * Text Domain: amp 
    1010 * Domain Path: /languages/ 
     
    1414define( 'AMP__FILE__', __FILE__ ); 
    1515define( 'AMP__DIR__', dirname( __FILE__ ) ); 
    16 define( 'AMP__VERSION', '0.4.1' ); 
     16define( 'AMP__VERSION', '0.4.2' ); 
    1717 
    1818require_once( AMP__DIR__ . '/back-compat/back-compat.php' ); 
     
    114114function amp_add_post_template_actions() { 
    115115    require_once( AMP__DIR__ . '/includes/amp-post-template-actions.php' ); 
     116    require_once( AMP__DIR__ . '/includes/amp-post-template-functions.php' ); 
    116117} 
    117118 
  • amp/trunk/includes/class-amp-content.php

    r1512429 r1514204  
    9393 
    9494class AMP_Content_Sanitizer { 
    95     public static function sanitize( $content, $sanitizer_classes, $args = array() ) { 
     95    public static function sanitize( $content, $sanitizer_classes, $global_args = array() ) { 
    9696        $scripts = array(); 
    9797        $styles = array(); 
     
    104104            } 
    105105 
    106             $sanitizer = new $sanitizer_class( $dom, array_merge( $args, $args ) ); 
     106            $sanitizer = new $sanitizer_class( $dom, array_merge( $global_args, $args ) ); 
    107107 
    108108            if ( ! is_subclass_of( $sanitizer, 'AMP_Base_Sanitizer' ) ) { 
  • amp/trunk/includes/class-amp-post-template.php

    r1512429 r1514204  
    5151            'home_url' => home_url(), 
    5252            'blog_name' => get_bloginfo( 'name' ), 
     53 
     54            'html_tag_attributes' => array(), 
    5355            'body_class' => '', 
    5456 
     
    8587        $this->build_post_data(); 
    8688        $this->build_customizer_settings(); 
     89        $this->build_html_tag_attributes(); 
    8790 
    8891        $this->data = apply_filters( 'amp_post_template_data', $this->data, $this->post ); 
     
    199202        $comments_open = comments_open( $this->ID ); 
    200203 
    201         // Don't show link if close and no comments  
     204        // Don't show link if close and no comments 
    202205        if ( ! $comments_open 
    203206            && ! $this->post->comment_count ) { 
     
    268271        $featured_image = get_post( $featured_id ); 
    269272 
    270         list( $sanitized_html ) = AMP_Content_Sanitizer::sanitize( 
     273        list( $sanitized_html, $featured_scripts, $featured_styles ) = AMP_Content_Sanitizer::sanitize( 
    271274            $featured_html, 
    272275            array( 'AMP_Img_Sanitizer' => array() ), 
     
    280283            'caption' => $featured_image->post_excerpt, 
    281284        ) ); 
     285 
     286        if ( $featured_scripts ) { 
     287            $this->merge_data_for_key( 'amp_component_scripts', $featured_scripts ); 
     288        } 
     289 
     290        if ( $featured_styles ) { 
     291            $this->add_data_by_key( 'post_amp_styles', $featured_styles ); 
     292        } 
    282293    } 
    283294 
     
    348359    } 
    349360 
     361    private function build_html_tag_attributes() { 
     362        $attributes = array(); 
     363 
     364        if ( function_exists( 'is_rtl' ) && is_rtl() ) { 
     365            $attributes['dir'] = 'rtl'; 
     366        } 
     367 
     368        $lang = get_bloginfo( 'language' ); 
     369        if ( $lang ) { 
     370            $attributes['lang'] = $lang; 
     371        } 
     372 
     373        $this->add_data_by_key( 'html_tag_attributes', $attributes ); 
     374    } 
     375 
    350376    private function verify_and_include( $file, $template_type ) { 
    351377        $located_file = $this->locate_template( $file ); 
  • amp/trunk/includes/utils/class-amp-dom-utils.php

    r1510272 r1514204  
    4646    public static function get_node_attributes_as_assoc_array( $node ) { 
    4747        $attributes = array(); 
     48        if ( ! $node->hasAttributes() ) { 
     49            return $attributes; 
     50        } 
     51 
    4852        foreach ( $node->attributes as $attribute ) { 
    4953            $attributes[ $attribute->nodeName ] = $attribute->nodeValue; 
  • amp/trunk/readme.md

    r1510272 r1514204  
    193193``` 
    194194 
    195 ##### Example: Remove Author from `meta` 
     195##### Example: Remove Author from `header_meta` 
    196196 
    197197This will completely remove the author section: 
    198198 
    199199```php 
    200 add_filter( 'amp_post_template_meta_parts', 'xyz_amp_remove_author_meta' ); 
     200add_filter( 'amp_post_article_header_meta', 'xyz_amp_remove_author_meta' ); 
    201201 
    202202function xyz_amp_remove_author_meta( $meta_parts ) { 
     
    208208``` 
    209209 
    210 ##### Example: Add Comment Count to `meta` 
     210##### Example: Add Comment Count to `footer_meta` 
    211211 
    212212This adds a new section to display the comment count: 
    213213 
    214214```php 
    215 add_filter( 'amp_post_template_meta_parts', 'xyz_amp_add_comment_count_meta' ); 
     215add_filter( 'amp_post_article_footer_meta', 'xyz_amp_add_comment_count_meta' ); 
    216216 
    217217function xyz_amp_add_comment_count_meta( $meta_parts ) { 
  • amp/trunk/readme.txt

    r1512429 r1514204  
    44Requires at least: 4.4 
    55Tested up to: 4.6 
    6 Stable tag: 0.4.1 
     6Stable tag: 0.4.2 
    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 = 
     56= 0.4.2 (2016-10-13) = 
     57 
     58- Fix: Prevent validation errors for `html` tag (h/t Maxime2 and everyone else that reported this error) 
     59- Fix: Handle variable name conflict that was causing content_max_width to be ignored (h/t mimancillas) 
     60- Fix: Prevent errors when nodes don't have attributes (h/t stephenmax) 
     61- Fix: Back-compat for 4.5 (add sanitize_hex_color function, h/t xotihcan) 
     62- Fix: Handle gif featured images (h/t protocolil) 
     63- Documentation updates (props troyxmccall) 
     64 
     65= 0.4.1 (2016-10-10) = 
    5766 
    5867- Fix: Don't fire the_content for featured image output 
  • amp/trunk/templates/single.php

    r1510272 r1514204  
    11<!doctype html> 
    2 <html amp <?php language_attributes(); ?>> 
     2<html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>> 
    33<head> 
    44    <meta charset="utf-8"> 
Note: See TracChangeset for help on using the changeset viewer.