Instant Articles for WP - Version 2.2

Version Description

Download this release

Release Info

Developer diegoquinteiro
Plugin Icon 128x128 Instant Articles for WP
Version 2.2
Comparing to
See all releases

Code changes from version 2.1 to 2.2

Files changed (22) hide show
  1. class-instant-articles-dom-transform-filter-runner.php +0 -51
  2. dom-transform-filters/class-instant-articles-dom-transform-filter-address.php +0 -77
  3. dom-transform-filters/class-instant-articles-dom-transform-filter-blockquote.php +0 -121
  4. dom-transform-filters/class-instant-articles-dom-transform-filter-emptyelements.php +0 -207
  5. dom-transform-filters/class-instant-articles-dom-transform-filter-heading.php +0 -78
  6. dom-transform-filters/class-instant-articles-dom-transform-filter-image.php +0 -151
  7. dom-transform-filters/class-instant-articles-dom-transform-filter-ordered-list.php +0 -77
  8. dom-transform-filters/class-instant-articles-dom-transform-filter-table.php +0 -83
  9. dom-transform-filters/class-instant-articles-dom-transform-filter-unordered-list.php +0 -77
  10. dom-transform-filters/class-instant-articles-dom-transform-filter-video.php +0 -80
  11. dom-transform-filters/class-instant-articles-dom-transform-filter.php +0 -111
  12. facebook-instant-articles.php +1 -1
  13. readme.txt +2 -2
  14. settings/template-settings-info.php +2 -2
  15. template.php +0 -124
  16. vendor/autoload.php +1 -1
  17. vendor/composer/autoload_real.php +3 -3
  18. vendor/composer/installed.json +6 -6
  19. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/AnimatedGIF.php +1 -1
  20. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php +2 -2
  21. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/Validators/TypeTest.php +5 -5
  22. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Rules/PullquoteRuleTest.php +102 -0
class-instant-articles-dom-transform-filter-runner.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class for handling registrating and execution of the DOM transformation filters
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Runner {
9
-
10
- /** @var array Our array for keeping the classnames of the DOM transformation filters */
11
- protected static $_stack = array();
12
-
13
- /**
14
- * Register a DOM transformation filter class
15
- *
16
- * @since 0.1
17
- * @param string $className The name of a class that extends Instant_Articles_DOM_Transform_Filter
18
- * @param int $priority Optional. Used to specify the order in which the filters are executed.
19
- * Default 10. Lower numbers correspond with earlier execution, and filters
20
- * with the same priority are executed in the order in which they were added.
21
- */
22
- static function register( $className, $priority = 10 ) {
23
- if ( ! is_array( self::$_stack[ $priority ] ) ) {
24
- self::$_stack[ $priority ] = array();
25
- }
26
- if ( ! in_array( $className, self::$_stack[ $priority ], true ) && is_subclass_of( $className, 'Instant_Articles_DOM_Transform_Filter' ) ) {
27
- self::$_stack[ $priority ][] = $className;
28
- }
29
- }
30
-
31
-
32
- /**
33
- * Run all the registered DOM tranformation filters
34
- *
35
- * @since 0.1
36
- * @param DOMDocument $DOMDocument The DOMDocument we are working on
37
- * @param int $post_id The current post ID
38
- * @return DOMDocument The modified DOMDocument
39
- */
40
- static function run( $DOMDocument, $post_id ) {
41
- ksort( self::$_stack );
42
- foreach ( self::$_stack as $priority => $filters ) {
43
- foreach ( $filters as $className ) {
44
- $obj = new $className( $DOMDocument, $post_id );
45
- $obj->run();
46
- }
47
- }
48
- return $DOMDocument;
49
- }
50
-
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-address.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Address elements
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Address extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'address' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
38
-
39
- $element = $this->_DOMDocument->createElement( 'p' );
40
- while ( $properties->childNodes->length ) {
41
- $element->appendChild( $properties->childNodes->item( 0 ) );
42
- }
43
-
44
- $DOMDocumentFragment->appendChild( $element );
45
-
46
- return $DOMDocumentFragment;
47
- }
48
-
49
- /**
50
- * Find the element properties
51
- *
52
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
53
- *
54
- * @since 0.1
55
- * @param $DOMNode $DOMNode The original domnode
56
- * @return stdClass The element properties used for building the new fragment
57
- */
58
- protected function get_properties( $DOMNode ) {
59
-
60
- $properties = new stdClass;
61
-
62
- $properties->childNodes = $DOMNode->childNodes;
63
-
64
- /**
65
- * Filter the video element properties
66
- *
67
- * @since 0.1
68
- * @param object $properties The element properties
69
- * @param int $post_id The post ID of the current post
70
- */
71
- $properties = apply_filters( 'instant_articles_address_properties', $properties, $this->_post_id );
72
-
73
- return $properties;
74
-
75
- }
76
-
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-blockquote.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Blockquotes
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Blockquote extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'blockquote' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
38
-
39
- $quoteContainerType = 'blockquote';
40
- if ( strlen( $properties->cite ) ) {
41
- $quoteContainerType = 'aside';
42
- }
43
-
44
- $quoteContainer = $this->_DOMDocument->createElement( $quoteContainerType );
45
- $quoteContainer->appendChild( $this->_DOMDocument->createTextNode( $properties->quote ) );
46
-
47
- if ( is_a( $properties->childNodes, 'DOMNodeList' ) ) {
48
- foreach( $properties->childNodes as $pNode ) {
49
- $newNode = $this->_DOMDocument->createElement( 'p' );
50
- $newNode->appendChild( $this->_DOMDocument->createTextNode( trim( $pNode->nodeValue ) ) );
51
- $quoteContainer->appendChild( $newNode );
52
- }
53
- }
54
-
55
- if ( strlen( $properties->cite ) ) {
56
- $citeNode = $this->_DOMDocument->createElement( 'cite' );
57
- $citeNode->appendChild( $this->_DOMDocument->createTextNode( $properties->cite ) );
58
- $quoteContainer->appendChild( $citeNode );
59
- }
60
-
61
- $DOMDocumentFragment->appendChild( $quoteContainer );
62
-
63
- return $DOMDocumentFragment;
64
- }
65
-
66
- /**
67
- * Find the element properties
68
- *
69
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
70
- *
71
- * @since 0.1
72
- * @param $DOMNode $DOMNode The original domnode
73
- * @return stdClass The element properties used for building the new fragment
74
- */
75
- protected function get_properties( $DOMNode ) {
76
-
77
- $properties = new stdClass;
78
-
79
- $properties->quote = $DOMNode->nodeValue;
80
- $properties->cite = '';
81
- $properties->childNodes = null;
82
-
83
- $cite = $DOMNode->getAttribute( 'cite' );
84
- if ( strlen( $cite ) ) {
85
- $properties->cite = $cite;
86
- }
87
-
88
- $citeNodeList = $DOMNode->getElementsByTagName( 'cite' );
89
- if ( $citeNodeList->length ) {
90
- $citeNode = $citeNodeList->item( 0 );
91
- if ( strlen( $citeNode->nodeValue ) ) {
92
- $properties->cite = $citeNode->nodeValue;
93
- }
94
- while ( $citeNodeList->length ) {
95
- $citeNode = $citeNodeList->item( 0 );
96
- $citeNode->parentNode->removeChild( $citeNode );
97
- }
98
- }
99
-
100
- $pNodeList = $DOMNode->getElementsByTagName( 'p' );
101
- if ( 1 === $pNodeList->length ) {
102
- $properties->quote = $pNodeList->item( 0 )->nodeValue;
103
- } elseif ( $pNodeList->length ) {
104
- $properties->quote = '';
105
- $properties->childNodes = $pNodeList;
106
- }
107
-
108
- /**
109
- * Filter the blockquote element properties
110
- *
111
- * @since 0.1
112
- * @param object $properties The element properties
113
- * @param int $post_id The post ID of the current post
114
- */
115
- $properties = apply_filters( 'instant_articles_blockquote_properties', $properties, $this->_post_id );
116
-
117
- return $properties;
118
-
119
- }
120
-
121
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-emptyelements.php DELETED
@@ -1,207 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for empty elements
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Emptyelements extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- // Elements excluded from checking: img, iframe, html, head, body, base, br, hr, link, meta, meter, script, audio, video, map, canvas, col, data, embed, input, keygen, menuitem, object, output, param, progress, source, textarea, track
11
- protected $_checkTagNames = array(
12
- 'a',
13
- 'abbr',
14
- 'address',
15
- 'article',
16
- 'aside',
17
- 'b',
18
- 'bdi',
19
- 'bdo',
20
- 'blockquote',
21
- 'button',
22
- 'caption',
23
- 'cite',
24
- 'code',
25
- 'colgroup',
26
- 'datalist',
27
- 'dd',
28
- 'del',
29
- 'details',
30
- 'dfn',
31
- 'dialog',
32
- 'div',
33
- 'dl',
34
- 'dt',
35
- 'em',
36
- 'fieldset',
37
- 'figcaption',
38
- 'figure',
39
- 'footer',
40
- 'form',
41
- 'h1',
42
- 'h2',
43
- 'h3',
44
- 'h4',
45
- 'h5',
46
- 'h6',
47
- 'header',
48
- 'hgroup',
49
- 'i',
50
- 'ins',
51
- 'kbd',
52
- 'label',
53
- 'legend',
54
- 'li ',
55
- 'main',
56
- 'map',
57
- 'mark',
58
- 'menu',
59
- 'nav',
60
- 'noscript',
61
- 'ol',
62
- 'optgroup',
63
- 'option',
64
- 'p',
65
- 'pre',
66
- 'q',
67
- 'rb',
68
- 'rp',
69
- 'rt',
70
- 'rtc',
71
- 'ruby',
72
- 's',
73
- 'samp',
74
- 'section',
75
- 'select',
76
- 'small',
77
- 'span',
78
- 'strong',
79
- 'style',
80
- 'sub',
81
- 'summary',
82
- 'sup',
83
- 'table',
84
- 'tbody',
85
- 'td',
86
- 'template',
87
- 'tfoot',
88
- 'th',
89
- 'thead',
90
- 'time',
91
- 'title',
92
- 'tr',
93
- 'u',
94
- 'ul',
95
- 'var',
96
- 'wbr',
97
- );
98
-
99
- /**
100
- * Run the transformation
101
- *
102
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
103
- *
104
- * @since 0.1
105
- * @return DOMDocument
106
- */
107
- public function run() {
108
-
109
-
110
- $xpathQuery = '//' . implode( ' | //', $this->_checkTagNames );;
111
-
112
- $xpath = new DOMXpath( $this->_DOMDocument );
113
- $DOMNodeList = $xpath->query( $xpathQuery );
114
-
115
- // Filter out empty elements
116
- $this->_filter_empty_elements( $DOMNodeList );
117
-
118
- return $this->_DOMDocument;
119
-
120
- }
121
-
122
- /**
123
- * Remove all empty elements
124
- *
125
- * @param DOMNodeList $DOMNodeList The list of all elements we are checking
126
- * @return DOMNodeList The modified list of all remaining elements
127
- */
128
- protected function _filter_empty_elements( DOMNodeList $DOMNodeList ) {
129
-
130
- $NodeListIndex = 0;
131
-
132
- // We might reduce $DOMNodeList->length during the loop
133
- for ( $NodeListIndex = 0; $NodeListIndex < $DOMNodeList->length; ++$NodeListIndex ) {
134
-
135
- $DOMNode = $DOMNodeList->item( $NodeListIndex );
136
-
137
- if ( ! isset( $DOMNode->nodeName ) || ! in_array( $DOMNode->nodeName, $this->_checkTagNames, true ) ) {
138
- continue;
139
- }
140
-
141
- // Climb up to make sure we’re not in an Instant Article element (which should have proper handling elsewhere)
142
- $parentNode = $DOMNode;
143
- while ( isset( $parentNode->nodeName ) && $parentNode->nodeName != 'body' ) {
144
- if ( 'figure' == $parentNode->nodeName && false !== strpos( $parentNode->getAttribute( 'class' ), 'op-' ) ) {
145
- // We found an element that’s likely to be an Instant Article element
146
- continue 2;
147
- }
148
- $parentNode = $parentNode->parentNode;
149
- }
150
-
151
-
152
- // Check all childnodes first
153
- if ( is_a( $DOMNode, 'DOMElement' ) && isset( $DOMNode->childNodes ) && is_a( $DOMNode->childNodes, 'DOMNodeList' ) ) {
154
- $this->_filter_empty_elements( $DOMNode->childNodes );
155
- }
156
-
157
-
158
- if ( isset( $DOMNode->nodeValue ) && '' == trim( $DOMNode->nodeValue ) ) {
159
-
160
- if ( ! isset( $DOMNode->childNodes ) || is_null( $DOMNode->childNodes ) || ( is_a( $DOMNode->childNodes, 'DOMNodeList' ) && ! $DOMNode->childNodes->length ) ) {
161
-
162
- // If the element is an empty node, remove it. But we must have a parentNode to remove a node
163
- if ( is_a( $DOMNode->parentNode, 'DOMElement' ) ) {
164
- $DOMNode->parentNode->removeChild( $DOMNode );
165
- }
166
- }
167
-
168
- }
169
-
170
- }
171
-
172
-
173
- return $DOMNodeList;
174
- }
175
-
176
- /**
177
- * Find the element properties
178
- *
179
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
180
- *
181
- * @since 0.1
182
- * @param $DOMNode $DOMNode The original domnode
183
- * @return stdClass The element properties used for building the new fragment
184
- */
185
- protected function get_properties( $DOMNode ) {
186
-
187
- $properties = new stdClass;
188
- return $properties;
189
-
190
- }
191
-
192
- /**
193
- * Build a DOMDocumentFragment for the image element
194
- *
195
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
196
- *
197
- * @since 0.1
198
- * @return DOMDocumentFragment|false The fragment ready to be inserted into the DOM. False if no replacement should happen.
199
- */
200
- protected function _build_fragment( $properties) {
201
- return false;
202
- }
203
-
204
-
205
- }
206
-
207
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-heading.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for headings
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Heading extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $xpath = new DOMXpath( $this->_DOMDocument );
21
- $DOMNodeList = $xpath->query( "//h3 | //h4 | //h5 | //h6" );
22
-
23
- // Transform all nodes found
24
- $this->_transform_elements( $DOMNodeList );
25
-
26
- return $this->_DOMDocument;
27
-
28
- }
29
-
30
- /**
31
- * Build a DOMDocumentFragment for the element
32
- *
33
- * @since 0.1
34
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
35
- */
36
- protected function _build_fragment( $properties ) {
37
-
38
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
39
- $h = $this->_DOMDocument->createElement( 'h2' );
40
-
41
- for ( $i = 0; $i < $properties->childNodes->length; ++$i ) {
42
- $h->appendChild( $properties->childNodes->item( $i ) );
43
- }
44
-
45
- $DOMDocumentFragment->appendChild( $h );
46
-
47
- return $DOMDocumentFragment;
48
- }
49
-
50
- /**
51
- * Find the element properties
52
- *
53
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
54
- *
55
- * @since 0.1
56
- * @param $DOMNode $DOMNode The original domnode
57
- * @return stdClass The element properties used for building the new fragment
58
- */
59
- protected function get_properties( $DOMNode ) {
60
-
61
- $properties = new stdClass;
62
-
63
- $properties->childNodes = $DOMNode->childNodes;
64
-
65
- /**
66
- * Filter the ol element properties
67
- *
68
- * @since 0.1
69
- * @param object $properties The element properties
70
- * @param int $post_id The post ID of the current post
71
- */
72
- $properties = apply_filters( 'instant_articles_heading_properties', $properties, $this->_post_id );
73
-
74
- return $properties;
75
-
76
- }
77
-
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-image.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Images
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Image extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'img' );
21
-
22
- // Filter out multiple uses of single images
23
- $this->_filter_multiple_uses( $DOMNodeList );
24
-
25
- // Transform all images left
26
- $this->_transform_elements( $DOMNodeList );
27
-
28
- return $this->_DOMDocument;
29
-
30
- }
31
-
32
- /**
33
- * The Instant Articles spec says we can only use each image once.
34
- *
35
- * @param DOMNodeList $DOMNodeList the list of images in the document
36
- * @return DOMNodeList The modified list of images in the document
37
- */
38
- protected function _filter_multiple_uses( DOMNodeList $DOMNodeList ) {
39
-
40
- $used_images = array();
41
-
42
- $NodeListIndex = 0;
43
-
44
- // We’ll increase $NodeListIndex and/or reduce $DOMNodeList->length
45
- while ( $NodeListIndex < $DOMNodeList->length ) {
46
-
47
- $DOMNode = $DOMNodeList->item( $NodeListIndex );
48
-
49
- $src = $DOMNode->getAttribute( 'src' );
50
-
51
- // See how far up the tree we can go
52
- $removeDOMNode = $DOMNode;
53
- while ( 'body' != $removeDOMNode->parentNode->nodeName && 1 === $removeDOMNode->parentNode->childNodes->length ) {
54
- $removeDOMNode = $removeDOMNode->parentNode;
55
- }
56
-
57
- // If the image is used already, remove it
58
- if ( in_array( $src, $used_images, true ) ) {
59
- // Please note that when we remove the node, $DOMNodeList->length is n-1. Our $NodeListIndex will thus point to the next item in the list.
60
- $removeDOMNode->parentNode->removeChild( $removeDOMNode );
61
- }
62
-
63
- // Add the src to the stack so we can check for multiple uses later
64
- $used_images[] = $src;
65
-
66
- ++$NodeListIndex;
67
-
68
- }
69
-
70
-
71
- return $DOMNodeList;
72
- }
73
-
74
- /**
75
- * Build a DOMDocumentFragment for the image element
76
- *
77
- * @since 0.1
78
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
79
- */
80
- protected function _build_fragment( $properties) {
81
-
82
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
83
- $figure = $this->_DOMDocument->createElement( 'figure' );
84
- $img = $this->_DOMDocument->createElement( 'img' );
85
- $img->setAttribute( 'src', $properties->img->url );
86
-
87
- $figure->appendChild( $img );
88
- $DOMDocumentFragment->appendChild( $figure );
89
-
90
- return $DOMDocumentFragment;
91
- }
92
-
93
- /**
94
- * Find the element properties
95
- *
96
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
97
- *
98
- * @since 0.1
99
- * @param $DOMNode $DOMNode The original domnode
100
- * @return stdClass The element properties used for building the new fragment
101
- */
102
- protected function get_properties( $DOMNode ) {
103
-
104
- $src = $DOMNode->getAttribute( 'src' );
105
- if ( function_exists( 'wpcom_vip_attachment_url_to_postid' ) ) {
106
- $attachment_id = wpcom_vip_attachment_url_to_postid( $src );
107
- } else {
108
- $attachment_id = attachment_url_to_postid( $src );
109
- }
110
-
111
- $properties = new stdClass;
112
- $properties->img = new stdClass;
113
-
114
- /* Try to use WP internals to get an image of the recommended size. Fallback to use the URL from the original img src in the post. */
115
-
116
-
117
- if ( $attachment_id ) {
118
- // The recommended resolution is 2048x2048 pixels.
119
- $img_props = wp_get_attachment_image_src( $attachment_id, array( 2048, 2048 ) ); // Returns an array (url, width, height), or false, if no image is available.
120
- } else {
121
- $imagesize = getimagesize( $src );
122
- if ( is_array( $imagesize ) ) {
123
- $img_props = array( $src, $imagesize[0], $imagesize[1] );
124
- }
125
- }
126
- if ( is_array( $img_props ) ) {
127
- list( $properties->img->url, $properties->img->width, $properties->img->height ) = $img_props;
128
- } else {
129
- $properties->img->url = $src;
130
- $properties->img->width = '';
131
- $properties->img->height = '';
132
- }
133
-
134
- /**
135
- * Filter the image properties
136
- *
137
- * @since 0.1
138
- * @param object $img_props The element properties
139
- * @param int $post_id The post ID of the current post
140
- * @param int $attachment_id The attachment ID (post ID) to the image (if reverse lookup from url to postid worked)
141
- */
142
- $properties = apply_filters( 'instant_articles_image_properties', $properties, $this->_post_id, $attachment_id );
143
-
144
- return $properties;
145
-
146
- }
147
-
148
-
149
- }
150
-
151
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-ordered-list.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for ordered List
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Ordered_List extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'ol' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
38
- $ol = $this->_DOMDocument->createElement( 'ol' );
39
-
40
- for ( $i = 0; $i < $properties->childNodes->length; ++$i ) {
41
- $ol->appendChild( $properties->childNodes->item( $i ) );
42
- }
43
-
44
- $DOMDocumentFragment->appendChild( $ol );
45
-
46
- return $DOMDocumentFragment;
47
- }
48
-
49
- /**
50
- * Find the element properties
51
- *
52
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
53
- *
54
- * @since 0.1
55
- * @param $DOMNode $DOMNode The original domnode
56
- * @return stdClass The element properties used for building the new fragment
57
- */
58
- protected function get_properties( $DOMNode ) {
59
-
60
- $properties = new stdClass;
61
-
62
- $properties->childNodes = $DOMNode->childNodes;
63
-
64
- /**
65
- * Filter the ol element properties
66
- *
67
- * @since 0.1
68
- * @param object $properties The element properties
69
- * @param int $post_id The post ID of the current post
70
- */
71
- $properties = apply_filters( 'instant_articles_ol_properties', $properties, $this->_post_id );
72
-
73
- return $properties;
74
-
75
- }
76
-
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-table.php DELETED
@@ -1,83 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Tables
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Table extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'table' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment|false The fragment ready to be inserted into the DOM. False if no replacement should happen.
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- if ( ! is_a( $properties->table, 'DOMElement' ) ) {
38
- return false;
39
- }
40
-
41
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
42
-
43
- $figure = $this->_DOMDocument->createElement( 'figure' );
44
- $figure->setAttribute( 'class', 'op-interactive' );
45
- $DOMDocumentFragment->appendChild( $figure );
46
-
47
- $iframe = $this->_DOMDocument->createElement( 'iframe' );
48
- $figure->appendChild( $iframe );
49
-
50
- $iframe->appendChild( $properties->table );
51
-
52
- return $DOMDocumentFragment;
53
- }
54
-
55
- /**
56
- * Find the element properties
57
- *
58
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
59
- *
60
- * @since 0.1
61
- * @param $DOMNode $DOMNode The original domnode
62
- * @return stdClass The element properties used for building the new fragment
63
- */
64
- protected function get_properties( $DOMNode ) {
65
-
66
- $properties = new stdClass;
67
-
68
- $properties->table = clone $DOMNode;
69
-
70
- /**
71
- * Filter the blockquote element properties
72
- *
73
- * @since 0.1
74
- * @param object $properties The element properties
75
- * @param int $post_id The post ID of the current post
76
- */
77
- $properties = apply_filters( 'instant_articles_table_properties', $properties, $this->_post_id );
78
-
79
- return $properties;
80
-
81
- }
82
-
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-unordered-list.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Unordered List
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Unordered_List extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'ul' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
38
- $ul = $this->_DOMDocument->createElement( 'ul' );
39
-
40
- for ( $i = 0; $i < $properties->childNodes->length; ++$i ) {
41
- $ul->appendChild( $properties->childNodes->item( $i ) );
42
- }
43
-
44
- $DOMDocumentFragment->appendChild( $ul );
45
-
46
- return $DOMDocumentFragment;
47
- }
48
-
49
- /**
50
- * Find the element properties
51
- *
52
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
53
- *
54
- * @since 0.1
55
- * @param $DOMNode $DOMNode The original domnode
56
- * @return stdClass The element properties used for building the new fragment
57
- */
58
- protected function get_properties( $DOMNode ) {
59
-
60
- $properties = new stdClass;
61
-
62
- $properties->childNodes = $DOMNode->childNodes;
63
-
64
- /**
65
- * Filter the ul element properties
66
- *
67
- * @since 0.1
68
- * @param object $properties The element properties
69
- * @param int $post_id The post ID of the current post
70
- */
71
- $properties = apply_filters( 'instant_articles_ul_properties', $properties, $this->_post_id );
72
-
73
- return $properties;
74
-
75
- }
76
-
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter-video.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter for Videos
5
- *
6
- * @since 0.1
7
- */
8
- class Instant_Articles_DOM_Transform_Filter_Video extends Instant_Articles_DOM_Transform_Filter {
9
-
10
- /**
11
- * Run the transformation
12
- *
13
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
14
- *
15
- * @since 0.1
16
- * @return DOMDocument The modified DOMDocument
17
- */
18
- public function run() {
19
-
20
- $DOMNodeList = $this->_DOMDocument->getElementsByTagName( 'video' );
21
-
22
- // Transform all nodes found
23
- $this->_transform_elements( $DOMNodeList );
24
-
25
- return $this->_DOMDocument;
26
-
27
- }
28
-
29
- /**
30
- * Build a DOMDocumentFragment for the element
31
- *
32
- * @since 0.1
33
- * @return DOMDocumentFragment The fragment ready to be inserted into the DOM
34
- */
35
- protected function _build_fragment( $properties ) {
36
-
37
- $DOMDocumentFragment = $this->_DOMDocument->createDocumentFragment();
38
-
39
- $wrapper = $this->_DOMDocument->createElement( 'figure' );
40
- $video = $this->_DOMDocument->createElement( 'video' );
41
- $wrapper->appendChild( $video );
42
-
43
- foreach ( $properties->childNodes as $childNode ) {
44
- $video->appendChild( $childNode );
45
- }
46
-
47
- $DOMDocumentFragment->appendChild( $wrapper );
48
-
49
- return $DOMDocumentFragment;
50
- }
51
-
52
- /**
53
- * Find the element properties
54
- *
55
- * Implements the abstract method from Instant_Articles_DOM_Transform_Filter
56
- *
57
- * @since 0.1
58
- * @param $DOMNode $DOMNode The original domnode
59
- * @return stdClass The element properties used for building the new fragment
60
- */
61
- protected function get_properties( $DOMNode ) {
62
-
63
- $properties = new stdClass;
64
-
65
- $properties->childNodes = $DOMNode->childNodes;
66
-
67
- /**
68
- * Filter the video element properties
69
- *
70
- * @since 0.1
71
- * @param object $properties The element properties
72
- * @param int $post_id The post ID of the current post
73
- */
74
- $properties = apply_filters( 'instant_articles_video_properties', $properties, $this->_post_id );
75
-
76
- return $properties;
77
-
78
- }
79
-
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dom-transform-filters/class-instant-articles-dom-transform-filter.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Instant Articles DOM Transformation Filter
5
- *
6
- * @since 0.1
7
- */
8
- abstract class Instant_Articles_DOM_Transform_Filter {
9
-
10
-
11
- protected $_DOMDocument;
12
- protected $_post_id;
13
-
14
- /**
15
- * Constructor
16
- *
17
- * @since 0.1
18
- * @param DOMDocument $DOMDocument The DOMDocument object we will be working on.
19
- * @param int $post_id The WP post ID to the current post
20
- */
21
- function __construct( $DOMDocument, $post_id ) {
22
- $this->_DOMDocument = $DOMDocument;
23
- $this->_post_id = $post_id;
24
- }
25
-
26
- /**
27
- * Run the transformation
28
- *
29
- * @since 0.1
30
- * @return DOMDocument THe transformed DOM document.
31
- */
32
- abstract public function run();
33
-
34
- /**
35
- * Dispatch each element in the nodelist to the transformer
36
- *
37
- * Note that we work directly on the DOMNodeList itself. Objects are passed by ref.
38
- *
39
- * @since 0.1
40
- * @param DOMNodeList $DOMNodeList List of images
41
- * @return DOMNodeList The DOMNodeList. If you want to chain.
42
- */
43
- protected function _transform_elements( DOMNodeList $DOMNodeList ) {
44
-
45
- // A foreach won’t work as we are changing the elements
46
- for ( $i = 0; $i < $DOMNodeList->length; ++$i ) {
47
- $origLength = $DOMNodeList->length;
48
-
49
- $this->_transform_element( $DOMNodeList->item( $i ) );
50
-
51
- if ( $origLength !== $DOMNodeList->length ) {
52
- // The element is replaced by an element of another type and is no longer in the nodelist
53
- --$i;
54
- }
55
- }
56
-
57
- return $DOMNodeList;
58
- }
59
-
60
- /**
61
- * Transform an element
62
- *
63
- * Note that we work directly on the DOMNode itself. Objects are passed by ref.
64
- *
65
- * @since 0.1
66
- * @param DOMNode $DOMNode The original DOM node
67
- * @return DOMNode The tranformed DOMNode. If you want to chain.
68
- */
69
- protected function _transform_element( DOMNode $DOMNode ) {
70
-
71
- // See how far up the tree we can go.
72
- $replaceNode = $DOMNode;
73
- while ( 'body' != $replaceNode->parentNode->nodeName && 1 === $replaceNode->parentNode->childNodes->length ) {
74
- $replaceNode = $replaceNode->parentNode;
75
- }
76
- // If we can’t go all the way to the top, we bail.
77
- if ( 'body' != $replaceNode->parentNode->nodeName ) {
78
- return $DOMNode;
79
- }
80
-
81
- $properties = $this->get_properties( $DOMNode );
82
- $DOMDocumentFragment = $this->_build_fragment( $properties );
83
-
84
- if ( is_a( $DOMDocumentFragment, 'DOMDocumentFragment' ) ) {
85
- $replaceNode->parentNode->replaceChild( $DOMDocumentFragment, $replaceNode );
86
- }
87
-
88
- return $DOMNode;
89
- }
90
-
91
- /**
92
- * Find the element properties
93
- *
94
- * @since 0.1
95
- * @param $DOMNode $DOMNode The original domnode
96
- * @return Object The properties we need to build the new fragment
97
- */
98
- abstract protected function get_properties( $DOMNode );
99
-
100
- /**
101
- * Build the new fragment
102
- *
103
- * @since 0.1
104
- * @param Object $properties The properties we need for this element
105
- * @return DOMDocumentFragment|false The fragment ready to be inserted into the DOM. False if no replacement should happen.
106
- */
107
- abstract protected function _build_fragment( $DOMNode );
108
-
109
- }
110
-
111
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
facebook-instant-articles.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: Add support for Instant Articles for Facebook to your WordPress site.
5
  * Author: Automattic, Dekode, Facebook
6
  * Author URI: https://vip.wordpress.com/plugins/instant-articles/
7
- * Version: 2.1
8
  * Text Domain: instant-articles
9
  * License: GPLv2
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
4
  * Description: Add support for Instant Articles for Facebook to your WordPress site.
5
  * Author: Automattic, Dekode, Facebook
6
  * Author URI: https://vip.wordpress.com/plugins/instant-articles/
7
+ * Version: 2.2
8
  * Text Domain: instant-articles
9
  * License: GPLv2
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
readme.txt CHANGED
@@ -3,11 +3,11 @@ Contributors: trrine, olethomas, bjornjohansen, dekode, automattic, facebook
3
  Tags: instant articles, facebook, mobile
4
  Requires at least: 4.3
5
  Tested up to: 4.5
6
- Stable tag: 2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- Enable [Instant Articles for Facebook](https://developers.facebook.com/docs/instant-articles) on your WordPress site.
11
 
12
  == Description ==
13
 
3
  Tags: instant articles, facebook, mobile
4
  Requires at least: 4.3
5
  Tested up to: 4.5
6
+ Stable tag: 2.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
+ Enable Instant Articles for Facebook on your WordPress site.
11
 
12
  == Description ==
13
 
settings/template-settings-info.php CHANGED
@@ -16,7 +16,7 @@
16
  <?php if ( isset( $fb_page_settings['page_id'] ) && ! empty ( $fb_page_settings['page_id'] ) ) : ?>
17
  Claim your URL
18
  <a
19
- href="https://www.facebook.com/<?php echo absint( $fb_page_settings['page_id'] ); ?>/settings/?tab=instant_articles" target="_blank">here</a>.
20
  <?php endif; ?>
21
  <li>Install the Pages Manager app to preview your articles and styles on <a href="http://itunes.apple.com/app/facebook-pages-manager/id514643583?ls=1&mt=8&ign-mscache=1" target="_blank">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.facebook.pages.app" target="_blank">Android</a>.
22
  <li>Create a style template for your articles, using the Style Editor. Be sure to provide the name of the template you want to use in the Plugin Configuration settings below.
@@ -25,7 +25,7 @@
25
  <?php if ( isset( $fb_page_settings['page_id'] ) && ! empty ( $fb_page_settings['page_id'] ) ) : ?>
26
  <li>
27
  <a
28
- href="https://www.facebook.com/<?php echo absint( $fb_page_settings['page_id'] ); ?>/settings/?tab=instant_articles" target="_blank">Submit your articles for review</a>.
29
  </li>
30
  <?php else : ?>
31
  <li>Submit your articles for review.</li>
16
  <?php if ( isset( $fb_page_settings['page_id'] ) && ! empty ( $fb_page_settings['page_id'] ) ) : ?>
17
  Claim your URL
18
  <a
19
+ href="https://www.facebook.com/<?php echo absint( $fb_page_settings['page_id'] ); ?>/settings/?tab=instant_articles#URL" target="_blank">here</a>.
20
  <?php endif; ?>
21
  <li>Install the Pages Manager app to preview your articles and styles on <a href="http://itunes.apple.com/app/facebook-pages-manager/id514643583?ls=1&mt=8&ign-mscache=1" target="_blank">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.facebook.pages.app" target="_blank">Android</a>.
22
  <li>Create a style template for your articles, using the Style Editor. Be sure to provide the name of the template you want to use in the Plugin Configuration settings below.
25
  <?php if ( isset( $fb_page_settings['page_id'] ) && ! empty ( $fb_page_settings['page_id'] ) ) : ?>
26
  <li>
27
  <a
28
+ href="https://www.facebook.com/<?php echo absint( $fb_page_settings['page_id'] ); ?>/settings/?tab=instant_articles#Setup-Step2" target="_blank">Submit your articles for review</a>.
29
  </li>
30
  <?php else : ?>
31
  <li>Submit your articles for review.</li>
template.php DELETED
@@ -1,124 +0,0 @@
1
- <!doctype html>
2
- <html lang="<?php echo esc_attr( get_bloginfo( 'language' ) ); ?>" prefix="op: http://media.facebook.com/op#">
3
- <head>
4
- <meta charset="<?php echo esc_attr( get_option( 'blog_charset' ) ); ?>">
5
- <link rel="canonical" href="<?php echo esc_url( $this->get_canonical_url() ); ?>">
6
- <meta property="op:markup_version" content="v1.0">
7
- <meta property="fb:article_style" content="<?php echo esc_attr( $this->get_article_style() ); ?>">
8
-
9
- <?php
10
- /**
11
- * Fires in the head element of each article
12
- *
13
- * @since 0.1
14
- *
15
- * @param Instant_Articles_Post $ia_post The current article object
16
- */
17
- do_action( 'instant_articles_article_head', $this );
18
- ?>
19
- </head>
20
-
21
- <body>
22
- <article>
23
- <header>
24
- <!-- The cover -->
25
- <?php $cover_media = $this->get_cover_media(); ?>
26
- <?php if ( 'image' === $cover_media->type ) : ?>
27
- <figure>
28
- <img src="<?php echo esc_url( $cover_media->src ); ?>" />
29
- <?php if ( strlen( $cover_media->caption ) ) : ?>
30
- <figcaption><?php echo esc_html( $cover_media->caption ); ?></figcaption>
31
- <?php endif; ?>
32
- </figure>
33
- <?php elseif ( 'video' === $cover_media->type ) : ?>
34
- <figure>
35
- <video>
36
- <source src="<?php echo esc_url( $cover_media->src ); ?>" type="<?php echo esc_attr( $cover_media->mime_type ); ?>" />
37
- </video>
38
- </figure>
39
- <?php elseif ( 'slideshow' === $cover_media->type ) : ?>
40
- <figure class="op-slideshow">
41
- <?php foreach ( $cover_media->items as $item ) : ?>
42
- <figure>
43
- <img src="<?php echo esc_url( $item->src ); ?>" />
44
- </figure>
45
- <?php endforeach; ?>
46
- </figure>
47
- <?php endif; ?>
48
-
49
- <h1><?php echo esc_html( $this->get_the_title() ); ?></h1>
50
-
51
- <?php if ( $this->has_subtitle() ) : ?>
52
- <h2><?php echo esc_html( $this->get_the_subtitle() ); ?></h2>
53
- <?php endif; ?>
54
-
55
- <!-- The date and time when your article was originally published -->
56
- <time class="op-published" datetime="<?php echo esc_attr( $this->get_the_pubdate_iso() ); ?>"><?php echo esc_html( $this->get_the_pubdate() ); ?></time>
57
-
58
- <!-- The date and time when your article was last updated -->
59
- <time class="op-modified" datetime="<?php echo esc_attr( $this->get_the_moddate_iso() ); ?>"><?php echo esc_html( $this->get_the_moddate() ); ?></time>
60
-
61
- <!-- The authors of your article -->
62
- <?php $authors = $this->get_the_authors(); ?>
63
- <?php if ( is_array( $authors ) && count( $authors ) ) : ?>
64
- <?php foreach ( $authors as $author ) : ?>
65
- <address>
66
- <?php
67
- $attributes = '';
68
- if ( strlen( $author->user_url ) ) {
69
- $attributes = ' href="' . esc_url( $author->user_url ) . '"';
70
-
71
- if ( isset( $author->role_contribution ) && strlen( $author->role_contribution ) ) {
72
- $attributes .= ' title="' . esc_attr( $author->role_contribution ) . '"';
73
- }
74
-
75
- if ( isset( $author->user_url_rel ) && strlen( $author->user_url_rel ) ) {
76
- $attributes .= ' rel="' . esc_attr( $author->user_url_rel ) . '"';
77
- }
78
- }
79
- ?>
80
- <a<?php echo $attributes; ?>>
81
- <?php echo esc_html( $author->display_name ); ?>
82
- </a>
83
- <?php if ( strlen( $author->bio ) ) : ?>
84
- <?php echo esc_html( $author->bio ); ?>
85
- <?php endif; ?>
86
- </address>
87
- <?php endforeach; ?>
88
- <?php endif; ?>
89
-
90
- <?php if ( $kicker_text = $this->get_the_kicker() ) : ?>
91
- <!-- A kicker for your article -->
92
- <h3 class="op-kicker"><?php echo esc_html( $kicker_text); ?></h3>
93
- <?php endif; ?>
94
-
95
- <?php
96
- /**
97
- * Fires in the header element of each article
98
- *
99
- * @since 0.1
100
- *
101
- * @param Instant_Articles_Post $ia_post The current article object
102
- */
103
- do_action( 'instant_articles_article_header', $this );
104
- ?>
105
-
106
- </header>
107
-
108
- <!-- Article body goes here -->
109
- <?php echo $this->get_the_content(); ?>
110
-
111
- <footer>
112
- <?php if ( $footer_credits = $this->get_the_footer_credits( ) ) : ?>
113
- <!-- Credits for your article -->
114
- <aside><?php echo esc_html( $footer_credits ); ?></aside>
115
- <?php endif; ?>
116
-
117
- <?php if ( $footer_copyright = $this->get_the_footer_copyright( ) ) : ?>
118
- <!-- Copyright details for your article -->
119
- <small><?php echo esc_html ( $footer_copyright ); ?></small>
120
- <?php endif; ?>
121
- </footer>
122
- </article>
123
- </body>
124
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit3e565f617e78b30946ba0a1809aa93f8::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit7e80597e4b240da0b6349cef6380896e::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit3e565f617e78b30946ba0a1809aa93f8
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit3e565f617e78b30946ba0a1809aa93f8
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit3e565f617e78b30946ba0a1809aa93f8', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit3e565f617e78b30946ba0a1809aa93f8', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit7e80597e4b240da0b6349cef6380896e
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit7e80597e4b240da0b6349cef6380896e', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit7e80597e4b240da0b6349cef6380896e', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
vendor/composer/installed.json CHANGED
@@ -145,17 +145,17 @@
145
  },
146
  {
147
  "name": "facebook/facebook-instant-articles-sdk-php",
148
- "version": "v1.0.0",
149
- "version_normalized": "1.0.0.0",
150
  "source": {
151
  "type": "git",
152
  "url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
153
- "reference": "d5a500c58aca210964912fac7193cfb659df0297"
154
  },
155
  "dist": {
156
  "type": "zip",
157
- "url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/d5a500c58aca210964912fac7193cfb659df0297",
158
- "reference": "d5a500c58aca210964912fac7193cfb659df0297",
159
  "shasum": ""
160
  },
161
  "require": {
@@ -167,7 +167,7 @@
167
  "require-dev": {
168
  "phpunit/phpunit": "^4.8"
169
  },
170
- "time": "2016-04-10 17:15:06",
171
  "type": "library",
172
  "installation-source": "dist",
173
  "autoload": {
145
  },
146
  {
147
  "name": "facebook/facebook-instant-articles-sdk-php",
148
+ "version": "v1.0.1",
149
+ "version_normalized": "1.0.1.0",
150
  "source": {
151
  "type": "git",
152
  "url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
153
+ "reference": "1d5414a1f5070c0fde586a7465ef6a6d70749598"
154
  },
155
  "dist": {
156
  "type": "zip",
157
+ "url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/1d5414a1f5070c0fde586a7465ef6a6d70749598",
158
+ "reference": "1d5414a1f5070c0fde586a7465ef6a6d70749598",
159
  "shasum": ""
160
  },
161
  "require": {
167
  "require-dev": {
168
  "phpunit/phpunit": "^4.8"
169
  },
170
+ "time": "2016-04-12 00:21:58",
171
  "type": "library",
172
  "installation-source": "dist",
173
  "autoload": {
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/AnimatedGIF.php CHANGED
@@ -9,7 +9,7 @@
9
  namespace Facebook\InstantArticles\Elements;
10
 
11
  /**
12
- * An AnimatedGif
13
  * Also consider to use one of the other media types for an article:
14
  * <ul>
15
  * <li>@see Audio</li>
9
  namespace Facebook\InstantArticles\Elements;
10
 
11
  /**
12
+ * An AnimatedGIF
13
  * Also consider to use one of the other media types for an article:
14
  * <ul>
15
  * <li>@see Audio</li>
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php CHANGED
@@ -33,7 +33,7 @@ use Facebook\InstantArticles\Validators\Type;
33
  */
34
  class InstantArticle extends Element
35
  {
36
- const CURRENT_VERSION = '1.0.0';
37
 
38
  /**
39
  * The meta properties that are used on <head>
@@ -193,7 +193,7 @@ class InstantArticle extends Element
193
  array(
194
  Ad::getClassName(),
195
  Analytics::getClassName(),
196
- AnimatedGif::getClassName(),
197
  Audio::getClassName(),
198
  Blockquote::getClassName(),
199
  Image::getClassName(),
33
  */
34
  class InstantArticle extends Element
35
  {
36
+ const CURRENT_VERSION = '1.0.1';
37
 
38
  /**
39
  * The meta properties that are used on <head>
193
  array(
194
  Ad::getClassName(),
195
  Analytics::getClassName(),
196
+ AnimatedGIF::getClassName(),
197
  Audio::getClassName(),
198
  Blockquote::getClassName(),
199
  Image::getClassName(),
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/Validators/TypeTest.php CHANGED
@@ -12,7 +12,7 @@ use Facebook\InstantArticles\Elements\Caption;
12
  use Facebook\InstantArticles\Elements\Image;
13
  use Facebook\InstantArticles\Elements\Video;
14
  use Facebook\InstantArticles\Elements\InstantArticle;
15
- use Facebook\InstantArticles\Elements\AnimatedGif;
16
  use Facebook\InstantArticles\Elements\Element;
17
  use Facebook\InstantArticles\Validators\Type;
18
 
@@ -136,7 +136,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
136
  public function testIsInInheritance()
137
  {
138
  $result = Type::is(
139
- AnimatedGif::create(),
140
  array(
141
  Image::getClassName()
142
  )
@@ -147,7 +147,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
147
  public function testIsNotInInheritance()
148
  {
149
  $result = Type::is(
150
- AnimatedGif::create(),
151
  array(
152
  Video::getClassName()
153
  )
@@ -159,7 +159,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
159
  {
160
  try {
161
  $result = Type::enforce(
162
- AnimatedGif::create(),
163
  array(
164
  Video::getClassName()
165
  )
@@ -223,7 +223,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
223
  public function testIsArrayInInheritance()
224
  {
225
  $result = Type::isArrayOf(
226
- array(Image::create(), AnimatedGif::create()),
227
  Image::getClassName()
228
  );
229
  $this->assertTrue($result);
12
  use Facebook\InstantArticles\Elements\Image;
13
  use Facebook\InstantArticles\Elements\Video;
14
  use Facebook\InstantArticles\Elements\InstantArticle;
15
+ use Facebook\InstantArticles\Elements\AnimatedGIF;
16
  use Facebook\InstantArticles\Elements\Element;
17
  use Facebook\InstantArticles\Validators\Type;
18
 
136
  public function testIsInInheritance()
137
  {
138
  $result = Type::is(
139
+ AnimatedGIF::create(),
140
  array(
141
  Image::getClassName()
142
  )
147
  public function testIsNotInInheritance()
148
  {
149
  $result = Type::is(
150
+ AnimatedGIF::create(),
151
  array(
152
  Video::getClassName()
153
  )
159
  {
160
  try {
161
  $result = Type::enforce(
162
+ AnimatedGIF::create(),
163
  array(
164
  Video::getClassName()
165
  )
223
  public function testIsArrayInInheritance()
224
  {
225
  $result = Type::isArrayOf(
226
+ array(Image::create(), AnimatedGIF::create()),
227
  Image::getClassName()
228
  );
229
  $this->assertTrue($result);
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Rules/PullquoteRuleTest.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) 2016-present, Facebook, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ namespace Facebook\InstantArticles\Transformer\Rules;
10
+
11
+ use Facebook\InstantArticles\Transformer\Rules\PullquoteRule;
12
+ use Facebook\InstantArticles\Transformer\Rules\PullquoteCiteRule;
13
+ use Facebook\InstantArticles\Transformer\Transformer;
14
+ use Facebook\InstantArticles\Elements\InstantArticle;
15
+
16
+ class PullquoteRuleTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ public function setUp()
19
+ {
20
+ \Logger::configure(
21
+ array(
22
+ 'rootLogger' => array(
23
+ 'appenders' => array('facebook-instantarticles-transformer')
24
+ ),
25
+ 'appenders' => array(
26
+ 'facebook-instantarticles-transformer' => array(
27
+ 'class' => 'LoggerAppenderConsole',
28
+ 'threshold' => 'INFO',
29
+ 'layout' => array(
30
+ 'class' => 'LoggerLayoutSimple'
31
+ )
32
+ )
33
+ )
34
+ )
35
+ );
36
+ }
37
+
38
+ public function testTransformPullquote()
39
+ {
40
+ $transformer_rules =
41
+ '{
42
+ "rules" :
43
+ [
44
+ {
45
+ "class": "TextNodeRule"
46
+ },
47
+ {
48
+ "class": "ItalicRule",
49
+ "selector": "em"
50
+ },
51
+ {
52
+ "class": "ParagraphRule",
53
+ "selector": "p"
54
+ },
55
+ {
56
+ "class": "PassThroughRule",
57
+ "selector": "div.field-quote > p"
58
+ },
59
+ {
60
+ "class": "PassThroughRule",
61
+ "selector" : "div.field-quote"
62
+ },
63
+ {
64
+ "class" : "PullquoteRule",
65
+ "selector" : "blockquote.pull-quote"
66
+ },
67
+ {
68
+ "class" : "PullquoteCiteRule",
69
+ "selector" : "div.field-quote-author"
70
+ }
71
+ ]
72
+ }';
73
+
74
+ $html =
75
+ '<blockquote class="pull-quote">'.
76
+ '<div class="field-quote">'.
77
+ '<p>Here is a fancy pull quote for the <em>world</em> to see it all.</p>'.
78
+ '</div>'.
79
+ '<div class="field-quote-author">Matthew Oliveira</div>'.
80
+ '</blockquote>';
81
+
82
+ $expected =
83
+ "<aside>Here is a fancy pull quote for the <i>world</i> to see it all.".
84
+ "<cite>Matthew Oliveira</cite>".
85
+ "</aside>\n";
86
+
87
+ $instant_article = InstantArticle::create();
88
+ $transformer = new Transformer();
89
+ $transformer->loadRules($transformer_rules);
90
+
91
+ $document = new \DOMDocument();
92
+ $document->loadXML($html);
93
+
94
+ $transformer->transform($instant_article, $document);
95
+
96
+ $pullquote = $instant_article->getChildren()[0];
97
+ $result = $pullquote->render('', true)."\n";
98
+
99
+ $this->assertEquals($expected, $result);
100
+ }
101
+
102
+ }