Version Description
Download this release
Release Info
| Developer | diegoquinteiro |
| Plugin | |
| Version | 3.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 3.2.2 to 3.3.0
- compat.php +4 -6
- facebook-instant-articles.php +2 -2
- readme.txt +1 -1
- rules-configuration.json +3 -130
- vendor/composer/installed.json +62 -62
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Client/Helper.php +3 -2
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Element.php +1 -1
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php +27 -1
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Parser/instant-articles-rules.json +8 -2
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ConstantGetter.php +42 -0
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ElementGetter.php +3 -3
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/GetterFactory.php +3 -0
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/StringGetter.php +53 -2
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageInsideParagraphRule.php +4 -80
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageRule.php +30 -5
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/InteractiveInsideParagraphRule.php +4 -101
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/InteractiveRule.php +30 -5
- vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/TimeRule.php +18 -6
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Client/HelperTest.php +1 -1
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/InstantArticleTest.php +59 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-ia.html +12 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-rules.json +49 -0
- vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple.html +12 -0
- vendor/symfony/css-selector/composer.json +2 -2
- wpcom-helper.php +18 -18
compat.php
CHANGED
|
@@ -42,9 +42,7 @@ if ( function_exists( 'get_the_image' ) ) {
|
|
| 42 |
$gti->init();
|
| 43 |
}
|
| 44 |
|
| 45 |
-
// Load support for Playbuzz plugin
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
$playbuzz->init();
|
| 50 |
-
}
|
| 42 |
$gti->init();
|
| 43 |
}
|
| 44 |
|
| 45 |
+
// Load support for Playbuzz plugin by default #515
|
| 46 |
+
include( dirname( __FILE__ ) . '/compat/class-instant-articles-playbuzz.php' );
|
| 47 |
+
$playbuzz = new Instant_Articles_Playbuzz;
|
| 48 |
+
$playbuzz->init();
|
|
|
|
|
|
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: 3.
|
| 8 |
* Text Domain: instant-articles
|
| 9 |
* License: GPLv2
|
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -61,7 +61,7 @@ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
|
| 61 |
|
| 62 |
defined( 'ABSPATH' ) || die( 'Shame on you' );
|
| 63 |
|
| 64 |
-
define( 'IA_PLUGIN_VERSION', '3.
|
| 65 |
define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
|
| 66 |
define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
|
| 67 |
define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
|
| 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: 3.3
|
| 8 |
* Text Domain: instant-articles
|
| 9 |
* License: GPLv2
|
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 61 |
|
| 62 |
defined( 'ABSPATH' ) || die( 'Shame on you' );
|
| 63 |
|
| 64 |
+
define( 'IA_PLUGIN_VERSION', '3.3' );
|
| 65 |
define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
|
| 66 |
define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
|
| 67 |
define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: trrine, olethomas, bjornjohansen, dekode, automattic, facebook
|
|
| 3 |
Tags: instant articles, facebook, mobile
|
| 4 |
Requires at least: 4.3
|
| 5 |
Tested up to: 4.6
|
| 6 |
-
Stable tag: 3.
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
| 3 |
Tags: instant articles, facebook, mobile
|
| 4 |
Requires at least: 4.3
|
| 5 |
Tested up to: 4.6
|
| 6 |
+
Stable tag: 3.3
|
| 7 |
License: GPLv2 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 9 |
|
rules-configuration.json
CHANGED
|
@@ -63,7 +63,7 @@
|
|
| 63 |
"class": "PassThroughRule",
|
| 64 |
"selector": "blockquote p"
|
| 65 |
}, {
|
| 66 |
-
"class": "
|
| 67 |
"selector": "img",
|
| 68 |
"properties": {
|
| 69 |
"image.url": {
|
|
@@ -72,9 +72,9 @@
|
|
| 72 |
"attribute": "src"
|
| 73 |
}
|
| 74 |
}
|
| 75 |
-
},{
|
| 76 |
"class": "ImageRule",
|
| 77 |
-
"selector": "img",
|
| 78 |
"properties": {
|
| 79 |
"image.url": {
|
| 80 |
"type": "string",
|
|
@@ -270,133 +270,6 @@
|
|
| 270 |
"attribute": "width"
|
| 271 |
}
|
| 272 |
}
|
| 273 |
-
}, {
|
| 274 |
-
"class": "InteractiveInsideParagraphRule",
|
| 275 |
-
"selector" : "iframe",
|
| 276 |
-
"properties" : {
|
| 277 |
-
"interactive.url" : {
|
| 278 |
-
"type" : "string",
|
| 279 |
-
"selector" : "iframe",
|
| 280 |
-
"attribute": "src"
|
| 281 |
-
},
|
| 282 |
-
"interactive.height" : {
|
| 283 |
-
"type" : "int",
|
| 284 |
-
"selector" : "iframe",
|
| 285 |
-
"attribute": "height"
|
| 286 |
-
},
|
| 287 |
-
"interactive.width" : {
|
| 288 |
-
"type" : "int",
|
| 289 |
-
"selector" : "iframe",
|
| 290 |
-
"attribute": "width"
|
| 291 |
-
}
|
| 292 |
-
}
|
| 293 |
-
},{
|
| 294 |
-
"class": "InteractiveInsideParagraphRule",
|
| 295 |
-
"selector" : "div.embed",
|
| 296 |
-
"properties" : {
|
| 297 |
-
"interactive.iframe" : {
|
| 298 |
-
"type" : "children",
|
| 299 |
-
"selector" : "div.embed"
|
| 300 |
-
},
|
| 301 |
-
"interactive.height" : {
|
| 302 |
-
"type" : "int",
|
| 303 |
-
"selector" : "iframe",
|
| 304 |
-
"attribute": "height"
|
| 305 |
-
},
|
| 306 |
-
"interactive.width" : {
|
| 307 |
-
"type" : "int",
|
| 308 |
-
"selector" : "iframe",
|
| 309 |
-
"attribute": "width"
|
| 310 |
-
}
|
| 311 |
-
}
|
| 312 |
-
}, {
|
| 313 |
-
"class": "InteractiveInsideParagraphRule",
|
| 314 |
-
"selector" : "div.interactive",
|
| 315 |
-
"properties" : {
|
| 316 |
-
"interactive.iframe" : {
|
| 317 |
-
"type" : "children",
|
| 318 |
-
"selector" : "div.interactive"
|
| 319 |
-
},
|
| 320 |
-
"interactive.height" : {
|
| 321 |
-
"type" : "int",
|
| 322 |
-
"selector" : "iframe",
|
| 323 |
-
"attribute": "height"
|
| 324 |
-
},
|
| 325 |
-
"interactive.width" : {
|
| 326 |
-
"type" : "int",
|
| 327 |
-
"selector" : "iframe",
|
| 328 |
-
"attribute": "width"
|
| 329 |
-
}
|
| 330 |
-
}
|
| 331 |
-
}, {
|
| 332 |
-
"class": "InteractiveInsideParagraphRule",
|
| 333 |
-
"selector" : "//div[@class='embed' and iframe]",
|
| 334 |
-
"properties" : {
|
| 335 |
-
"interactive.url" : {
|
| 336 |
-
"type" : "string",
|
| 337 |
-
"selector" : "iframe",
|
| 338 |
-
"attribute": "src"
|
| 339 |
-
},
|
| 340 |
-
"interactive.iframe" : {
|
| 341 |
-
"type" : "children",
|
| 342 |
-
"selector" : "iframe",
|
| 343 |
-
"attribute": "src"
|
| 344 |
-
},
|
| 345 |
-
"interactive.width" : {
|
| 346 |
-
"type" : "int",
|
| 347 |
-
"selector" : "iframe",
|
| 348 |
-
"attribute": "width"
|
| 349 |
-
},
|
| 350 |
-
"interactive.height" : {
|
| 351 |
-
"type" : "int",
|
| 352 |
-
"selector" : "iframe",
|
| 353 |
-
"attribute": "height"
|
| 354 |
-
}
|
| 355 |
-
}
|
| 356 |
-
}, {
|
| 357 |
-
"class": "InteractiveInsideParagraphRule",
|
| 358 |
-
"selector" : "//div[@class='interactive' and iframe]",
|
| 359 |
-
"properties" : {
|
| 360 |
-
"interactive.url" : {
|
| 361 |
-
"type" : "string",
|
| 362 |
-
"selector" : "iframe",
|
| 363 |
-
"attribute": "src"
|
| 364 |
-
},
|
| 365 |
-
"interactive.iframe" : {
|
| 366 |
-
"type" : "children",
|
| 367 |
-
"selector" : "iframe",
|
| 368 |
-
"attribute": "src"
|
| 369 |
-
},
|
| 370 |
-
"interactive.height" : {
|
| 371 |
-
"type" : "int",
|
| 372 |
-
"selector" : "iframe",
|
| 373 |
-
"attribute": "height"
|
| 374 |
-
},
|
| 375 |
-
"interactive.width" : {
|
| 376 |
-
"type" : "int",
|
| 377 |
-
"selector" : "iframe",
|
| 378 |
-
"attribute": "width"
|
| 379 |
-
}
|
| 380 |
-
}
|
| 381 |
-
}, {
|
| 382 |
-
"class": "InteractiveInsideParagraphRule",
|
| 383 |
-
"selector" : "table",
|
| 384 |
-
"properties" : {
|
| 385 |
-
"interactive.iframe" : {
|
| 386 |
-
"type" : "element",
|
| 387 |
-
"selector" : "table"
|
| 388 |
-
},
|
| 389 |
-
"interactive.height" : {
|
| 390 |
-
"type" : "int",
|
| 391 |
-
"selector" : "table",
|
| 392 |
-
"attribute": "height"
|
| 393 |
-
},
|
| 394 |
-
"interactive.width" : {
|
| 395 |
-
"type" : "int",
|
| 396 |
-
"selector" : "table",
|
| 397 |
-
"attribute": "width"
|
| 398 |
-
}
|
| 399 |
-
}
|
| 400 |
}, {
|
| 401 |
"class": "SlideshowImageRule",
|
| 402 |
"selector" : "figure",
|
| 63 |
"class": "PassThroughRule",
|
| 64 |
"selector": "blockquote p"
|
| 65 |
}, {
|
| 66 |
+
"class": "ImageRule",
|
| 67 |
"selector": "img",
|
| 68 |
"properties": {
|
| 69 |
"image.url": {
|
| 72 |
"attribute": "src"
|
| 73 |
}
|
| 74 |
}
|
| 75 |
+
}, {
|
| 76 |
"class": "ImageRule",
|
| 77 |
+
"selector": "//a[img and not(*[not(self::img)])]",
|
| 78 |
"properties": {
|
| 79 |
"image.url": {
|
| 80 |
"type": "string",
|
| 270 |
"attribute": "width"
|
| 271 |
}
|
| 272 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
}, {
|
| 274 |
"class": "SlideshowImageRule",
|
| 275 |
"selector" : "figure",
|
vendor/composer/installed.json
CHANGED
|
@@ -1,59 +1,4 @@
|
|
| 1 |
[
|
| 2 |
-
{
|
| 3 |
-
"name": "symfony/css-selector",
|
| 4 |
-
"version": "v2.8.14",
|
| 5 |
-
"version_normalized": "2.8.14.0",
|
| 6 |
-
"source": {
|
| 7 |
-
"type": "git",
|
| 8 |
-
"url": "https://github.com/symfony/css-selector.git",
|
| 9 |
-
"reference": "981abbbd6ba49af338a98490cbe29e7f39ca9fa9"
|
| 10 |
-
},
|
| 11 |
-
"dist": {
|
| 12 |
-
"type": "zip",
|
| 13 |
-
"url": "https://api.github.com/repos/symfony/css-selector/zipball/981abbbd6ba49af338a98490cbe29e7f39ca9fa9",
|
| 14 |
-
"reference": "981abbbd6ba49af338a98490cbe29e7f39ca9fa9",
|
| 15 |
-
"shasum": ""
|
| 16 |
-
},
|
| 17 |
-
"require": {
|
| 18 |
-
"php": ">=5.3.9"
|
| 19 |
-
},
|
| 20 |
-
"time": "2016-11-03 07:52:58",
|
| 21 |
-
"type": "library",
|
| 22 |
-
"extra": {
|
| 23 |
-
"branch-alias": {
|
| 24 |
-
"dev-master": "2.8-dev"
|
| 25 |
-
}
|
| 26 |
-
},
|
| 27 |
-
"installation-source": "dist",
|
| 28 |
-
"autoload": {
|
| 29 |
-
"psr-4": {
|
| 30 |
-
"Symfony\\Component\\CssSelector\\": ""
|
| 31 |
-
},
|
| 32 |
-
"exclude-from-classmap": [
|
| 33 |
-
"/Tests/"
|
| 34 |
-
]
|
| 35 |
-
},
|
| 36 |
-
"notification-url": "https://packagist.org/downloads/",
|
| 37 |
-
"license": [
|
| 38 |
-
"MIT"
|
| 39 |
-
],
|
| 40 |
-
"authors": [
|
| 41 |
-
{
|
| 42 |
-
"name": "Jean-François Simon",
|
| 43 |
-
"email": "jeanfrancois.simon@sensiolabs.com"
|
| 44 |
-
},
|
| 45 |
-
{
|
| 46 |
-
"name": "Fabien Potencier",
|
| 47 |
-
"email": "fabien@symfony.com"
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
"name": "Symfony Community",
|
| 51 |
-
"homepage": "https://symfony.com/contributors"
|
| 52 |
-
}
|
| 53 |
-
],
|
| 54 |
-
"description": "Symfony CssSelector Component",
|
| 55 |
-
"homepage": "https://symfony.com"
|
| 56 |
-
},
|
| 57 |
{
|
| 58 |
"name": "facebook/graph-sdk",
|
| 59 |
"version": "5.4.2",
|
|
@@ -146,33 +91,88 @@
|
|
| 146 |
"php"
|
| 147 |
]
|
| 148 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
{
|
| 150 |
"name": "facebook/facebook-instant-articles-sdk-php",
|
| 151 |
-
"version": "v1.5.
|
| 152 |
-
"version_normalized": "1.5.
|
| 153 |
"source": {
|
| 154 |
"type": "git",
|
| 155 |
"url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
|
| 156 |
-
"reference": "
|
| 157 |
},
|
| 158 |
"dist": {
|
| 159 |
"type": "zip",
|
| 160 |
-
"url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/
|
| 161 |
-
"reference": "
|
| 162 |
"shasum": ""
|
| 163 |
},
|
| 164 |
"require": {
|
| 165 |
"apache/log4php": "2.3.0",
|
| 166 |
"facebook/graph-sdk": "~5.0",
|
| 167 |
"php": "^5.4 || ^7.0",
|
| 168 |
-
"symfony/css-selector": "2.8.*"
|
| 169 |
},
|
| 170 |
"require-dev": {
|
| 171 |
"fzaninotto/faker": "^1.6.0",
|
| 172 |
"phpunit/phpunit": "^4.8",
|
| 173 |
"squizlabs/php_codesniffer": "^2.6.0"
|
| 174 |
},
|
| 175 |
-
"time": "2016-
|
| 176 |
"type": "library",
|
| 177 |
"installation-source": "dist",
|
| 178 |
"autoload": {
|
| 1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
{
|
| 3 |
"name": "facebook/graph-sdk",
|
| 4 |
"version": "5.4.2",
|
| 91 |
"php"
|
| 92 |
]
|
| 93 |
},
|
| 94 |
+
{
|
| 95 |
+
"name": "symfony/css-selector",
|
| 96 |
+
"version": "v3.1.7",
|
| 97 |
+
"version_normalized": "3.1.7.0",
|
| 98 |
+
"source": {
|
| 99 |
+
"type": "git",
|
| 100 |
+
"url": "https://github.com/symfony/css-selector.git",
|
| 101 |
+
"reference": "a37b3359566415a91cba55a2d95820b3fa1a9658"
|
| 102 |
+
},
|
| 103 |
+
"dist": {
|
| 104 |
+
"type": "zip",
|
| 105 |
+
"url": "https://api.github.com/repos/symfony/css-selector/zipball/a37b3359566415a91cba55a2d95820b3fa1a9658",
|
| 106 |
+
"reference": "a37b3359566415a91cba55a2d95820b3fa1a9658",
|
| 107 |
+
"shasum": ""
|
| 108 |
+
},
|
| 109 |
+
"require": {
|
| 110 |
+
"php": ">=5.5.9"
|
| 111 |
+
},
|
| 112 |
+
"time": "2016-11-03 08:04:31",
|
| 113 |
+
"type": "library",
|
| 114 |
+
"extra": {
|
| 115 |
+
"branch-alias": {
|
| 116 |
+
"dev-master": "3.1-dev"
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
"installation-source": "dist",
|
| 120 |
+
"autoload": {
|
| 121 |
+
"psr-4": {
|
| 122 |
+
"Symfony\\Component\\CssSelector\\": ""
|
| 123 |
+
},
|
| 124 |
+
"exclude-from-classmap": [
|
| 125 |
+
"/Tests/"
|
| 126 |
+
]
|
| 127 |
+
},
|
| 128 |
+
"notification-url": "https://packagist.org/downloads/",
|
| 129 |
+
"license": [
|
| 130 |
+
"MIT"
|
| 131 |
+
],
|
| 132 |
+
"authors": [
|
| 133 |
+
{
|
| 134 |
+
"name": "Jean-François Simon",
|
| 135 |
+
"email": "jeanfrancois.simon@sensiolabs.com"
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"name": "Fabien Potencier",
|
| 139 |
+
"email": "fabien@symfony.com"
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"name": "Symfony Community",
|
| 143 |
+
"homepage": "https://symfony.com/contributors"
|
| 144 |
+
}
|
| 145 |
+
],
|
| 146 |
+
"description": "Symfony CssSelector Component",
|
| 147 |
+
"homepage": "https://symfony.com"
|
| 148 |
+
},
|
| 149 |
{
|
| 150 |
"name": "facebook/facebook-instant-articles-sdk-php",
|
| 151 |
+
"version": "v1.5.3",
|
| 152 |
+
"version_normalized": "1.5.3.0",
|
| 153 |
"source": {
|
| 154 |
"type": "git",
|
| 155 |
"url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
|
| 156 |
+
"reference": "4210c2b78a4d28b0c56c0e8575db47d30e48ef54"
|
| 157 |
},
|
| 158 |
"dist": {
|
| 159 |
"type": "zip",
|
| 160 |
+
"url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/4210c2b78a4d28b0c56c0e8575db47d30e48ef54",
|
| 161 |
+
"reference": "4210c2b78a4d28b0c56c0e8575db47d30e48ef54",
|
| 162 |
"shasum": ""
|
| 163 |
},
|
| 164 |
"require": {
|
| 165 |
"apache/log4php": "2.3.0",
|
| 166 |
"facebook/graph-sdk": "~5.0",
|
| 167 |
"php": "^5.4 || ^7.0",
|
| 168 |
+
"symfony/css-selector": "2.8.* || ^3.0"
|
| 169 |
},
|
| 170 |
"require-dev": {
|
| 171 |
"fzaninotto/faker": "^1.6.0",
|
| 172 |
"phpunit/phpunit": "^4.8",
|
| 173 |
"squizlabs/php_codesniffer": "^2.6.0"
|
| 174 |
},
|
| 175 |
+
"time": "2016-11-29 15:38:03",
|
| 176 |
"type": "library",
|
| 177 |
"installation-source": "dist",
|
| 178 |
"autoload": {
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Client/Helper.php
CHANGED
|
@@ -61,12 +61,13 @@ class Helper
|
|
| 61 |
* short-lived user access token.
|
| 62 |
*
|
| 63 |
* @param AccessToken $accessToken A short-lived user access token.
|
|
|
|
| 64 |
*
|
| 65 |
* @return array
|
| 66 |
*
|
| 67 |
* @throws FacebookSDKException
|
| 68 |
*/
|
| 69 |
-
public function getPagesAndTokens($accessToken)
|
| 70 |
{
|
| 71 |
Type::enforce($accessToken, 'Facebook\Authentication\AccessToken');
|
| 72 |
|
|
@@ -89,7 +90,7 @@ class Helper
|
|
| 89 |
// Request the list of pages and associated page tokens that are
|
| 90 |
// connected to this user
|
| 91 |
try {
|
| 92 |
-
$response = $this->facebook->get('/me/accounts?fields=name,id,access_token,supports_instant_articles,picture');
|
| 93 |
} catch (FacebookResponseException $e) {
|
| 94 |
throw new FacebookSDKException('Graph API returned an error: ' . $e->getMessage());
|
| 95 |
}
|
| 61 |
* short-lived user access token.
|
| 62 |
*
|
| 63 |
* @param AccessToken $accessToken A short-lived user access token.
|
| 64 |
+
* @param int $offset Offset pages API results
|
| 65 |
*
|
| 66 |
* @return array
|
| 67 |
*
|
| 68 |
* @throws FacebookSDKException
|
| 69 |
*/
|
| 70 |
+
public function getPagesAndTokens($accessToken, $offset = 0)
|
| 71 |
{
|
| 72 |
Type::enforce($accessToken, 'Facebook\Authentication\AccessToken');
|
| 73 |
|
| 90 |
// Request the list of pages and associated page tokens that are
|
| 91 |
// connected to this user
|
| 92 |
try {
|
| 93 |
+
$response = $this->facebook->get('/me/accounts?fields=name,id,access_token,supports_instant_articles,picture&offset=' . $offset);
|
| 94 |
} catch (FacebookResponseException $e) {
|
| 95 |
throw new FacebookSDKException('Graph API returned an error: ' . $e->getMessage());
|
| 96 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Element.php
CHANGED
|
@@ -20,7 +20,7 @@ abstract class Element
|
|
| 20 |
{
|
| 21 |
private $empty_validation = true;
|
| 22 |
|
| 23 |
-
abstract public function toDOMElement();
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Renders the Element content
|
| 20 |
{
|
| 21 |
private $empty_validation = true;
|
| 22 |
|
| 23 |
+
abstract public function toDOMElement($document = null);
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Renders the Element content
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php
CHANGED
|
@@ -34,7 +34,7 @@ use Facebook\InstantArticles\Validators\Type;
|
|
| 34 |
|
| 35 |
class InstantArticle extends Element implements Container, InstantArticleInterface
|
| 36 |
{
|
| 37 |
-
const CURRENT_VERSION = '1.5.
|
| 38 |
|
| 39 |
/**
|
| 40 |
* The meta properties that are used on <head>
|
|
@@ -81,6 +81,11 @@ class InstantArticle extends Element implements Container, InstantArticleInterfa
|
|
| 81 |
*/
|
| 82 |
private $children = [];
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
/**
|
| 85 |
* Factory method
|
| 86 |
* @return InstantArticle object.
|
|
@@ -165,6 +170,24 @@ class InstantArticle extends Element implements Container, InstantArticleInterfa
|
|
| 165 |
return $this;
|
| 166 |
}
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
/**
|
| 169 |
* Sets the header content to this InstantArticle
|
| 170 |
*
|
|
@@ -326,6 +349,9 @@ class InstantArticle extends Element implements Container, InstantArticleInterfa
|
|
| 326 |
|
| 327 |
// Builds and appends head to the HTML document
|
| 328 |
$html = $document->createElement('html');
|
|
|
|
|
|
|
|
|
|
| 329 |
$head = $document->createElement('head');
|
| 330 |
$html->appendChild($head);
|
| 331 |
|
| 34 |
|
| 35 |
class InstantArticle extends Element implements Container, InstantArticleInterface
|
| 36 |
{
|
| 37 |
+
const CURRENT_VERSION = '1.5.3';
|
| 38 |
|
| 39 |
/**
|
| 40 |
* The meta properties that are used on <head>
|
| 81 |
*/
|
| 82 |
private $children = [];
|
| 83 |
|
| 84 |
+
/**
|
| 85 |
+
* @var boolean flag that indicates if this article is Right-to-left(RTL). Defaults to false.
|
| 86 |
+
*/
|
| 87 |
+
private $isRTLEnabled = false;
|
| 88 |
+
|
| 89 |
/**
|
| 90 |
* Factory method
|
| 91 |
* @return InstantArticle object.
|
| 170 |
return $this;
|
| 171 |
}
|
| 172 |
|
| 173 |
+
/**
|
| 174 |
+
* Updates article to use RTL orientation.
|
| 175 |
+
*/
|
| 176 |
+
public function enableRTL()
|
| 177 |
+
{
|
| 178 |
+
$this->isRTLEnabled = true;
|
| 179 |
+
return $this;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/**
|
| 183 |
+
* Updates article to use LTR orientation (default), disabling RTL.
|
| 184 |
+
*/
|
| 185 |
+
public function disableRTL()
|
| 186 |
+
{
|
| 187 |
+
$this->isRTLEnabled = false;
|
| 188 |
+
return $this;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
/**
|
| 192 |
* Sets the header content to this InstantArticle
|
| 193 |
*
|
| 349 |
|
| 350 |
// Builds and appends head to the HTML document
|
| 351 |
$html = $document->createElement('html');
|
| 352 |
+
if ($this->isRTLEnabled) {
|
| 353 |
+
$html->setAttribute('dir', 'rtl');
|
| 354 |
+
}
|
| 355 |
$head = $document->createElement('head');
|
| 356 |
$html->appendChild($head);
|
| 357 |
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Parser/instant-articles-rules.json
CHANGED
|
@@ -213,24 +213,30 @@
|
|
| 213 |
{
|
| 214 |
"class": "TimeRule",
|
| 215 |
"selector" : "time.op-modified",
|
| 216 |
-
"article.time_type": "op-modified",
|
| 217 |
"properties" : {
|
| 218 |
"article.time" : {
|
| 219 |
"type" : "string",
|
| 220 |
"selector" : "time",
|
| 221 |
"attribute": "datetime"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
}
|
| 224 |
},
|
| 225 |
{
|
| 226 |
"class": "TimeRule",
|
| 227 |
"selector" : "time.op-published",
|
| 228 |
-
"article.time_type": "op-published",
|
| 229 |
"properties" : {
|
| 230 |
"article.time" : {
|
| 231 |
"type" : "string",
|
| 232 |
"selector" : "time",
|
| 233 |
"attribute": "datetime"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
}
|
| 235 |
}
|
| 236 |
},
|
| 213 |
{
|
| 214 |
"class": "TimeRule",
|
| 215 |
"selector" : "time.op-modified",
|
|
|
|
| 216 |
"properties" : {
|
| 217 |
"article.time" : {
|
| 218 |
"type" : "string",
|
| 219 |
"selector" : "time",
|
| 220 |
"attribute": "datetime"
|
| 221 |
+
},
|
| 222 |
+
"article.datetype": {
|
| 223 |
+
"type": "constant",
|
| 224 |
+
"value": "op-modified"
|
| 225 |
}
|
| 226 |
}
|
| 227 |
},
|
| 228 |
{
|
| 229 |
"class": "TimeRule",
|
| 230 |
"selector" : "time.op-published",
|
|
|
|
| 231 |
"properties" : {
|
| 232 |
"article.time" : {
|
| 233 |
"type" : "string",
|
| 234 |
"selector" : "time",
|
| 235 |
"attribute": "datetime"
|
| 236 |
+
},
|
| 237 |
+
"article.datetype": {
|
| 238 |
+
"type": "constant",
|
| 239 |
+
"value": "op-published"
|
| 240 |
}
|
| 241 |
}
|
| 242 |
},
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ConstantGetter.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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\Getters;
|
| 10 |
+
|
| 11 |
+
use Facebook\InstantArticles\Validators\Type;
|
| 12 |
+
|
| 13 |
+
class ConstantGetter extends AbstractGetter
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* @var string
|
| 17 |
+
*/
|
| 18 |
+
protected $value;
|
| 19 |
+
|
| 20 |
+
public function createFrom($properties)
|
| 21 |
+
{
|
| 22 |
+
return $this->withValue($properties['value']);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @param string $value
|
| 27 |
+
*
|
| 28 |
+
* @return $this
|
| 29 |
+
*/
|
| 30 |
+
public function withValue($value)
|
| 31 |
+
{
|
| 32 |
+
Type::enforce($value, Type::STRING);
|
| 33 |
+
$this->value = $value;
|
| 34 |
+
|
| 35 |
+
return $this;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
public function get($node)
|
| 39 |
+
{
|
| 40 |
+
return $this->value;
|
| 41 |
+
}
|
| 42 |
+
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ElementGetter.php
CHANGED
|
@@ -26,14 +26,14 @@ class ElementGetter extends AbstractGetter
|
|
| 26 |
|
| 27 |
/**
|
| 28 |
* @param \DOMNode $node
|
| 29 |
-
*
|
| 30 |
* @return \DOMNodeList
|
| 31 |
*/
|
| 32 |
-
public function findAll($node)
|
| 33 |
{
|
| 34 |
$domXPath = new \DOMXPath($node->ownerDocument);
|
| 35 |
$converter = new CssSelectorConverter();
|
| 36 |
-
$xpath = $converter->toXPath($
|
| 37 |
return $domXPath->query($xpath, $node);
|
| 38 |
}
|
| 39 |
|
| 26 |
|
| 27 |
/**
|
| 28 |
* @param \DOMNode $node
|
| 29 |
+
* @param string $selector
|
| 30 |
* @return \DOMNodeList
|
| 31 |
*/
|
| 32 |
+
public function findAll($node, $selector)
|
| 33 |
{
|
| 34 |
$domXPath = new \DOMXPath($node->ownerDocument);
|
| 35 |
$converter = new CssSelectorConverter();
|
| 36 |
+
$xpath = $converter->toXPath($selector);
|
| 37 |
return $domXPath->query($xpath, $node);
|
| 38 |
}
|
| 39 |
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/GetterFactory.php
CHANGED
|
@@ -14,6 +14,7 @@ class GetterFactory
|
|
| 14 |
const TYPE_INTEGER_GETTER = 'int';
|
| 15 |
const TYPE_CHILDREN_GETTER = 'children';
|
| 16 |
const TYPE_ELEMENT_GETTER = 'element';
|
|
|
|
| 17 |
const TYPE_FRAGMENT_GETTER = 'fragment';
|
| 18 |
const TYPE_NEXTSIBLING_GETTER = 'sibling';
|
| 19 |
const TYPE_NEXTSIBLINGELEMENT_GETTER = 'next-sibling-element-of';
|
|
@@ -34,6 +35,7 @@ class GetterFactory
|
|
| 34 |
* @see ChildrenGetter
|
| 35 |
* @see IntegerGetter
|
| 36 |
* @see ElementGetter
|
|
|
|
| 37 |
* @see NextSiblingGetter
|
| 38 |
* @see ExistsGetter
|
| 39 |
* @see JSONGetter
|
|
@@ -51,6 +53,7 @@ class GetterFactory
|
|
| 51 |
self::TYPE_CHILDREN_GETTER => ChildrenGetter::getClassName(),
|
| 52 |
self::TYPE_ELEMENT_GETTER => ElementGetter::getClassName(),
|
| 53 |
self::TYPE_FRAGMENT_GETTER => FragmentGetter::getClassName(),
|
|
|
|
| 54 |
self::TYPE_NEXTSIBLING_GETTER => NextSiblingGetter::getClassName(),
|
| 55 |
self::TYPE_NEXTSIBLINGELEMENT_GETTER => NextSiblingElementGetter::getClassName(),
|
| 56 |
self::TYPE_EXISTS_GETTER => ExistsGetter::getClassName(),
|
| 14 |
const TYPE_INTEGER_GETTER = 'int';
|
| 15 |
const TYPE_CHILDREN_GETTER = 'children';
|
| 16 |
const TYPE_ELEMENT_GETTER = 'element';
|
| 17 |
+
const TYPE_CONSTANT_GETTER = 'constant';
|
| 18 |
const TYPE_FRAGMENT_GETTER = 'fragment';
|
| 19 |
const TYPE_NEXTSIBLING_GETTER = 'sibling';
|
| 20 |
const TYPE_NEXTSIBLINGELEMENT_GETTER = 'next-sibling-element-of';
|
| 35 |
* @see ChildrenGetter
|
| 36 |
* @see IntegerGetter
|
| 37 |
* @see ElementGetter
|
| 38 |
+
* @see ConstantGetter
|
| 39 |
* @see NextSiblingGetter
|
| 40 |
* @see ExistsGetter
|
| 41 |
* @see JSONGetter
|
| 53 |
self::TYPE_CHILDREN_GETTER => ChildrenGetter::getClassName(),
|
| 54 |
self::TYPE_ELEMENT_GETTER => ElementGetter::getClassName(),
|
| 55 |
self::TYPE_FRAGMENT_GETTER => FragmentGetter::getClassName(),
|
| 56 |
+
self::TYPE_CONSTANT_GETTER => ConstantGetter::getClassName(),
|
| 57 |
self::TYPE_NEXTSIBLING_GETTER => NextSiblingGetter::getClassName(),
|
| 58 |
self::TYPE_NEXTSIBLINGELEMENT_GETTER => NextSiblingElementGetter::getClassName(),
|
| 59 |
self::TYPE_EXISTS_GETTER => ExistsGetter::getClassName(),
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/StringGetter.php
CHANGED
|
@@ -17,6 +17,16 @@ class StringGetter extends ChildrenGetter
|
|
| 17 |
*/
|
| 18 |
protected $attribute;
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
public function createFrom($properties)
|
| 21 |
{
|
| 22 |
if (isset($properties['selector'])) {
|
|
@@ -25,6 +35,12 @@ class StringGetter extends ChildrenGetter
|
|
| 25 |
if (isset($properties['attribute'])) {
|
| 26 |
$this->withAttribute($properties['attribute']);
|
| 27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
/**
|
|
@@ -40,6 +56,32 @@ class StringGetter extends ChildrenGetter
|
|
| 40 |
return $this;
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
public function get($node)
|
| 44 |
{
|
| 45 |
Type::enforce($node, 'DOMNode');
|
|
@@ -47,9 +89,18 @@ class StringGetter extends ChildrenGetter
|
|
| 47 |
if (!empty($elements) && $elements->item(0)) {
|
| 48 |
$element = $elements->item(0);
|
| 49 |
if ($this->attribute) {
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
-
return $
|
| 53 |
}
|
| 54 |
return null;
|
| 55 |
}
|
| 17 |
*/
|
| 18 |
protected $attribute;
|
| 19 |
|
| 20 |
+
/**
|
| 21 |
+
* @var string
|
| 22 |
+
*/
|
| 23 |
+
protected $prefix;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @var string
|
| 27 |
+
*/
|
| 28 |
+
protected $suffix;
|
| 29 |
+
|
| 30 |
public function createFrom($properties)
|
| 31 |
{
|
| 32 |
if (isset($properties['selector'])) {
|
| 35 |
if (isset($properties['attribute'])) {
|
| 36 |
$this->withAttribute($properties['attribute']);
|
| 37 |
}
|
| 38 |
+
if (isset($properties['prefix'])) {
|
| 39 |
+
$this->withPrefix($properties['prefix']);
|
| 40 |
+
}
|
| 41 |
+
if (isset($properties['suffix'])) {
|
| 42 |
+
$this->withSuffix($properties['suffix']);
|
| 43 |
+
}
|
| 44 |
}
|
| 45 |
|
| 46 |
/**
|
| 56 |
return $this;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
/**
|
| 60 |
+
* @param string $prefix
|
| 61 |
+
*
|
| 62 |
+
* @return $this
|
| 63 |
+
*/
|
| 64 |
+
public function withPrefix($prefix)
|
| 65 |
+
{
|
| 66 |
+
Type::enforce($prefix, Type::STRING);
|
| 67 |
+
$this->prefix = $prefix;
|
| 68 |
+
|
| 69 |
+
return $this;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* @param string $suffix
|
| 74 |
+
*
|
| 75 |
+
* @return $this
|
| 76 |
+
*/
|
| 77 |
+
public function withSuffix($suffix)
|
| 78 |
+
{
|
| 79 |
+
Type::enforce($suffix, Type::STRING);
|
| 80 |
+
$this->suffix = $suffix;
|
| 81 |
+
|
| 82 |
+
return $this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
public function get($node)
|
| 86 |
{
|
| 87 |
Type::enforce($node, 'DOMNode');
|
| 89 |
if (!empty($elements) && $elements->item(0)) {
|
| 90 |
$element = $elements->item(0);
|
| 91 |
if ($this->attribute) {
|
| 92 |
+
$result = $element->getAttribute($this->attribute);
|
| 93 |
+
} else {
|
| 94 |
+
$result = $element->textContent;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
if (!Type::isTextEmpty($this->prefix)) {
|
| 98 |
+
$result = $this->prefix . $result;
|
| 99 |
+
}
|
| 100 |
+
if (!Type::isTextEmpty($this->suffix)) {
|
| 101 |
+
$result = $result . $this->suffix;
|
| 102 |
}
|
| 103 |
+
return $result;
|
| 104 |
}
|
| 105 |
return null;
|
| 106 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageInsideParagraphRule.php
CHANGED
|
@@ -8,91 +8,15 @@
|
|
| 8 |
*/
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
-
use Facebook\InstantArticles\Elements\Image;
|
| 12 |
-
use Facebook\InstantArticles\Elements\TextContainer;
|
| 13 |
use Facebook\InstantArticles\Elements\Paragraph;
|
| 14 |
-
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
| 15 |
-
use Facebook\InstantArticles\Transformer\Warnings\NoRootInstantArticleFoundWarning;
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
{
|
| 19 |
-
const PROPERTY_IMAGE_URL = 'image.url';
|
| 20 |
-
const PROPERTY_LIKE = 'image.like';
|
| 21 |
-
const PROPERTY_COMMENTS = 'image.comments';
|
| 22 |
-
|
| 23 |
public function getContextClass()
|
| 24 |
{
|
| 25 |
return Paragraph::getClassName();
|
| 26 |
}
|
| 27 |
-
|
| 28 |
-
public static function create()
|
| 29 |
-
{
|
| 30 |
-
return new ImageInsideParagraphRule();
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
public static function createFrom($configuration)
|
| 34 |
-
{
|
| 35 |
-
$image_rule = self::create();
|
| 36 |
-
$image_rule->withSelector($configuration['selector']);
|
| 37 |
-
|
| 38 |
-
$image_rule->withProperties(
|
| 39 |
-
[
|
| 40 |
-
self::PROPERTY_IMAGE_URL,
|
| 41 |
-
self::PROPERTY_LIKE,
|
| 42 |
-
self::PROPERTY_COMMENTS
|
| 43 |
-
],
|
| 44 |
-
$configuration
|
| 45 |
-
);
|
| 46 |
-
|
| 47 |
-
return $image_rule;
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
public function apply($transformer, $context, $node)
|
| 51 |
-
{
|
| 52 |
-
$image = Image::create();
|
| 53 |
-
|
| 54 |
-
// Builds the image
|
| 55 |
-
$url = $this->getProperty(self::PROPERTY_IMAGE_URL, $node);
|
| 56 |
-
if ($url) {
|
| 57 |
-
$image->withURL($url);
|
| 58 |
-
$instant_article = $transformer->getInstantArticle();
|
| 59 |
-
if ($instant_article) {
|
| 60 |
-
$instant_article->addChild($image);
|
| 61 |
-
$context->disableEmptyValidation();
|
| 62 |
-
$context = Paragraph::create();
|
| 63 |
-
$context->disableEmptyValidation();
|
| 64 |
-
$instant_article->addChild($context);
|
| 65 |
-
} else {
|
| 66 |
-
$transformer->addWarning(
|
| 67 |
-
// This new error message should be something like:
|
| 68 |
-
// Could not transform Image, as no root InstantArticle was provided.
|
| 69 |
-
new NoRootInstantArticleFoundWarning(null, $node)
|
| 70 |
-
);
|
| 71 |
-
}
|
| 72 |
-
} else {
|
| 73 |
-
$transformer->addWarning(
|
| 74 |
-
new InvalidSelector(
|
| 75 |
-
self::PROPERTY_IMAGE_URL,
|
| 76 |
-
$instant_article,
|
| 77 |
-
$node,
|
| 78 |
-
$this
|
| 79 |
-
)
|
| 80 |
-
);
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
if ($this->getProperty(self::PROPERTY_LIKE, $node)) {
|
| 84 |
-
$image->enableLike();
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
if ($this->getProperty(self::PROPERTY_COMMENTS, $node)) {
|
| 88 |
-
$image->enableComments();
|
| 89 |
-
}
|
| 90 |
-
|
| 91 |
-
$suppress_warnings = $transformer->suppress_warnings;
|
| 92 |
-
$transformer->suppress_warnings = true;
|
| 93 |
-
$transformer->transform($image, $node);
|
| 94 |
-
$transformer->suppress_warnings = $suppress_warnings;
|
| 95 |
-
|
| 96 |
-
return $context;
|
| 97 |
-
}
|
| 98 |
}
|
| 8 |
*/
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
|
|
|
|
|
|
| 11 |
use Facebook\InstantArticles\Elements\Paragraph;
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
/**
|
| 14 |
+
* @deprecated ImageRule now works inside Paragraph without a custom rule, use it instead
|
| 15 |
+
*/
|
| 16 |
+
class ImageInsideParagraphRule extends ImageRule
|
| 17 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
public function getContextClass()
|
| 19 |
{
|
| 20 |
return Paragraph::getClassName();
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ImageRule.php
CHANGED
|
@@ -9,8 +9,10 @@
|
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
use Facebook\InstantArticles\Elements\Image;
|
|
|
|
| 12 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
| 13 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
|
|
|
| 14 |
|
| 15 |
class ImageRule extends ConfigurationSelectorRule
|
| 16 |
{
|
|
@@ -25,17 +27,21 @@ class ImageRule extends ConfigurationSelectorRule
|
|
| 25 |
|
| 26 |
public function getContextClass()
|
| 27 |
{
|
| 28 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
public static function create()
|
| 32 |
{
|
| 33 |
-
return new
|
| 34 |
}
|
| 35 |
|
| 36 |
public static function createFrom($configuration)
|
| 37 |
{
|
| 38 |
-
$image_rule =
|
| 39 |
$image_rule->withSelector($configuration['selector']);
|
| 40 |
|
| 41 |
$image_rule->withProperties(
|
|
@@ -54,15 +60,34 @@ class ImageRule extends ConfigurationSelectorRule
|
|
| 54 |
return $image_rule;
|
| 55 |
}
|
| 56 |
|
| 57 |
-
public function apply($transformer, $
|
| 58 |
{
|
| 59 |
$image = Image::create();
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
// Builds the image
|
| 62 |
$url = $this->getProperty(self::PROPERTY_IMAGE_URL, $node);
|
| 63 |
if ($url) {
|
| 64 |
$image->withURL($url);
|
| 65 |
$instant_article->addChild($image);
|
|
|
|
|
|
|
|
|
|
| 66 |
} else {
|
| 67 |
$transformer->addWarning(
|
| 68 |
new InvalidSelector(
|
|
@@ -97,6 +122,6 @@ class ImageRule extends ConfigurationSelectorRule
|
|
| 97 |
$transformer->transform($image, $node);
|
| 98 |
$transformer->suppress_warnings = $suppress_warnings;
|
| 99 |
|
| 100 |
-
return $
|
| 101 |
}
|
| 102 |
}
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
use Facebook\InstantArticles\Elements\Image;
|
| 12 |
+
use Facebook\InstantArticles\Elements\Paragraph;
|
| 13 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
| 14 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
| 15 |
+
use Facebook\InstantArticles\Validators\Type;
|
| 16 |
|
| 17 |
class ImageRule extends ConfigurationSelectorRule
|
| 18 |
{
|
| 27 |
|
| 28 |
public function getContextClass()
|
| 29 |
{
|
| 30 |
+
return
|
| 31 |
+
[
|
| 32 |
+
InstantArticle::getClassName(),
|
| 33 |
+
Paragraph::getClassName()
|
| 34 |
+
];
|
| 35 |
}
|
| 36 |
|
| 37 |
public static function create()
|
| 38 |
{
|
| 39 |
+
return new static();
|
| 40 |
}
|
| 41 |
|
| 42 |
public static function createFrom($configuration)
|
| 43 |
{
|
| 44 |
+
$image_rule = static::create();
|
| 45 |
$image_rule->withSelector($configuration['selector']);
|
| 46 |
|
| 47 |
$image_rule->withProperties(
|
| 60 |
return $image_rule;
|
| 61 |
}
|
| 62 |
|
| 63 |
+
public function apply($transformer, $context, $node)
|
| 64 |
{
|
| 65 |
$image = Image::create();
|
| 66 |
|
| 67 |
+
if (Type::is($context, InstantArticle::getClassName())) {
|
| 68 |
+
$instant_article = $context;
|
| 69 |
+
} elseif ($transformer->getInstantArticle()) {
|
| 70 |
+
$instant_article = $transformer->getInstantArticle();
|
| 71 |
+
$context->disableEmptyValidation();
|
| 72 |
+
$context = Paragraph::create();
|
| 73 |
+
$context->disableEmptyValidation();
|
| 74 |
+
} else {
|
| 75 |
+
$transformer->addWarning(
|
| 76 |
+
// This new error message should be something like:
|
| 77 |
+
// Could not transform Image, as no root InstantArticle was provided.
|
| 78 |
+
new NoRootInstantArticleFoundWarning(null, $node)
|
| 79 |
+
);
|
| 80 |
+
return $context;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
// Builds the image
|
| 84 |
$url = $this->getProperty(self::PROPERTY_IMAGE_URL, $node);
|
| 85 |
if ($url) {
|
| 86 |
$image->withURL($url);
|
| 87 |
$instant_article->addChild($image);
|
| 88 |
+
if ($instant_article !== $context) {
|
| 89 |
+
$instant_article->addChild($context);
|
| 90 |
+
}
|
| 91 |
} else {
|
| 92 |
$transformer->addWarning(
|
| 93 |
new InvalidSelector(
|
| 122 |
$transformer->transform($image, $node);
|
| 123 |
$transformer->suppress_warnings = $suppress_warnings;
|
| 124 |
|
| 125 |
+
return $context;
|
| 126 |
}
|
| 127 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/InteractiveInsideParagraphRule.php
CHANGED
|
@@ -8,112 +8,15 @@
|
|
| 8 |
*/
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
-
use Facebook\InstantArticles\Elements\Interactive;
|
| 12 |
use Facebook\InstantArticles\Elements\Paragraph;
|
| 13 |
-
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
| 14 |
-
use Facebook\InstantArticles\Transformer\Warnings\NoRootInstantArticleFoundWarning;
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
{
|
| 18 |
-
const PROPERTY_IFRAME = 'interactive.iframe';
|
| 19 |
-
const PROPERTY_URL = 'interactive.url';
|
| 20 |
-
const PROPERTY_WIDTH_NO_MARGIN = Interactive::NO_MARGIN;
|
| 21 |
-
const PROPERTY_WIDTH_COLUMN_WIDTH = Interactive::COLUMN_WIDTH;
|
| 22 |
-
const PROPERTY_HEIGHT = 'interactive.height';
|
| 23 |
-
const PROPERTY_WIDTH = 'interactive.width';
|
| 24 |
-
|
| 25 |
public function getContextClass()
|
| 26 |
{
|
| 27 |
return Paragraph::getClassName();
|
| 28 |
}
|
| 29 |
-
|
| 30 |
-
public static function create()
|
| 31 |
-
{
|
| 32 |
-
return new InteractiveInsideParagraphRule();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
public static function createFrom($configuration)
|
| 36 |
-
{
|
| 37 |
-
$interactive_rule = self::create();
|
| 38 |
-
$interactive_rule->withSelector($configuration['selector']);
|
| 39 |
-
|
| 40 |
-
$interactive_rule->withProperties(
|
| 41 |
-
[
|
| 42 |
-
self::PROPERTY_IFRAME,
|
| 43 |
-
self::PROPERTY_URL,
|
| 44 |
-
self::PROPERTY_WIDTH_NO_MARGIN,
|
| 45 |
-
self::PROPERTY_WIDTH_COLUMN_WIDTH,
|
| 46 |
-
self::PROPERTY_WIDTH,
|
| 47 |
-
self::PROPERTY_HEIGHT
|
| 48 |
-
],
|
| 49 |
-
$configuration
|
| 50 |
-
);
|
| 51 |
-
|
| 52 |
-
return $interactive_rule;
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
public function apply($transformer, $context, $node)
|
| 56 |
-
{
|
| 57 |
-
$interactive = Interactive::create();
|
| 58 |
-
|
| 59 |
-
// Builds the interactive
|
| 60 |
-
$iframe = $this->getProperty(self::PROPERTY_IFRAME, $node);
|
| 61 |
-
$url = $this->getProperty(self::PROPERTY_URL, $node);
|
| 62 |
-
if ($iframe) {
|
| 63 |
-
$interactive->withHTML($iframe);
|
| 64 |
-
}
|
| 65 |
-
if ($url) {
|
| 66 |
-
$interactive->withSource($url);
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
if ($this->getProperty(self::PROPERTY_WIDTH_COLUMN_WIDTH, $node)) {
|
| 70 |
-
$interactive->withMargin(Interactive::COLUMN_WIDTH);
|
| 71 |
-
} else {
|
| 72 |
-
$interactive->withMargin(Interactive::NO_MARGIN);
|
| 73 |
-
}
|
| 74 |
-
|
| 75 |
-
$width = $this->getProperty(self::PROPERTY_WIDTH, $node);
|
| 76 |
-
if ($width) {
|
| 77 |
-
$interactive->withWidth($width);
|
| 78 |
-
}
|
| 79 |
-
|
| 80 |
-
$height = $this->getProperty(self::PROPERTY_HEIGHT, $node);
|
| 81 |
-
if ($height) {
|
| 82 |
-
$interactive->withHeight($height);
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
if ($iframe || $url) {
|
| 87 |
-
$instant_article = $transformer->getInstantArticle();
|
| 88 |
-
if ($instant_article) {
|
| 89 |
-
$instant_article->addChild($interactive);
|
| 90 |
-
$context->disableEmptyValidation();
|
| 91 |
-
$context = Paragraph::create();
|
| 92 |
-
$context->disableEmptyValidation();
|
| 93 |
-
$instant_article->addChild($context);
|
| 94 |
-
} else {
|
| 95 |
-
$transformer->addWarning(
|
| 96 |
-
// This new error message should be something like:
|
| 97 |
-
// Could not transform Interactive, as no root InstantArticle was provided.
|
| 98 |
-
new NoRootInstantArticleFoundWarning(null, $node)
|
| 99 |
-
);
|
| 100 |
-
}
|
| 101 |
-
} else {
|
| 102 |
-
$transformer->addWarning(
|
| 103 |
-
new InvalidSelector(
|
| 104 |
-
self::PROPERTY_IFRAME,
|
| 105 |
-
$instant_article,
|
| 106 |
-
$node,
|
| 107 |
-
$this
|
| 108 |
-
)
|
| 109 |
-
);
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
$suppress_warnings = $transformer->suppress_warnings;
|
| 113 |
-
$transformer->suppress_warnings = true;
|
| 114 |
-
$transformer->transform($interactive, $node);
|
| 115 |
-
$transformer->suppress_warnings = $suppress_warnings;
|
| 116 |
-
|
| 117 |
-
return $context;
|
| 118 |
-
}
|
| 119 |
}
|
| 8 |
*/
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
|
|
|
| 11 |
use Facebook\InstantArticles\Elements\Paragraph;
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
/**
|
| 14 |
+
* @deprecated InteractiveRule now works inside Paragraph without a custom rule, use it instead
|
| 15 |
+
*/
|
| 16 |
+
class InteractiveInsideParagraphRule extends InteractiveRule
|
| 17 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
public function getContextClass()
|
| 19 |
{
|
| 20 |
return Paragraph::getClassName();
|
| 21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/InteractiveRule.php
CHANGED
|
@@ -9,8 +9,10 @@
|
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
use Facebook\InstantArticles\Elements\Interactive;
|
|
|
|
| 12 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
| 13 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
|
|
|
| 14 |
|
| 15 |
class InteractiveRule extends ConfigurationSelectorRule
|
| 16 |
{
|
|
@@ -23,17 +25,21 @@ class InteractiveRule extends ConfigurationSelectorRule
|
|
| 23 |
|
| 24 |
public function getContextClass()
|
| 25 |
{
|
| 26 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
public static function create()
|
| 30 |
{
|
| 31 |
-
return new
|
| 32 |
}
|
| 33 |
|
| 34 |
public static function createFrom($configuration)
|
| 35 |
{
|
| 36 |
-
$interactive_rule =
|
| 37 |
$interactive_rule->withSelector($configuration['selector']);
|
| 38 |
|
| 39 |
$interactive_rule->withProperties(
|
|
@@ -51,10 +57,26 @@ class InteractiveRule extends ConfigurationSelectorRule
|
|
| 51 |
return $interactive_rule;
|
| 52 |
}
|
| 53 |
|
| 54 |
-
public function apply($transformer, $
|
| 55 |
{
|
| 56 |
$interactive = Interactive::create();
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
// Builds the interactive
|
| 59 |
$iframe = $this->getProperty(self::PROPERTY_IFRAME, $node);
|
| 60 |
$url = $this->getProperty(self::PROPERTY_URL, $node);
|
|
@@ -66,6 +88,9 @@ class InteractiveRule extends ConfigurationSelectorRule
|
|
| 66 |
}
|
| 67 |
if ($iframe || $url) {
|
| 68 |
$instant_article->addChild($interactive);
|
|
|
|
|
|
|
|
|
|
| 69 |
} else {
|
| 70 |
$transformer->addWarning(
|
| 71 |
new InvalidSelector(
|
|
@@ -98,6 +123,6 @@ class InteractiveRule extends ConfigurationSelectorRule
|
|
| 98 |
$transformer->transform($interactive, $node);
|
| 99 |
$transformer->suppress_warnings = $suppress_warnings;
|
| 100 |
|
| 101 |
-
return $
|
| 102 |
}
|
| 103 |
}
|
| 9 |
namespace Facebook\InstantArticles\Transformer\Rules;
|
| 10 |
|
| 11 |
use Facebook\InstantArticles\Elements\Interactive;
|
| 12 |
+
use Facebook\InstantArticles\Elements\Paragraph;
|
| 13 |
use Facebook\InstantArticles\Elements\InstantArticle;
|
| 14 |
use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
| 15 |
+
use Facebook\InstantArticles\Validators\Type;
|
| 16 |
|
| 17 |
class InteractiveRule extends ConfigurationSelectorRule
|
| 18 |
{
|
| 25 |
|
| 26 |
public function getContextClass()
|
| 27 |
{
|
| 28 |
+
return
|
| 29 |
+
[
|
| 30 |
+
InstantArticle::getClassName(),
|
| 31 |
+
Paragraph::getClassName()
|
| 32 |
+
];
|
| 33 |
}
|
| 34 |
|
| 35 |
public static function create()
|
| 36 |
{
|
| 37 |
+
return new static();
|
| 38 |
}
|
| 39 |
|
| 40 |
public static function createFrom($configuration)
|
| 41 |
{
|
| 42 |
+
$interactive_rule = static::create();
|
| 43 |
$interactive_rule->withSelector($configuration['selector']);
|
| 44 |
|
| 45 |
$interactive_rule->withProperties(
|
| 57 |
return $interactive_rule;
|
| 58 |
}
|
| 59 |
|
| 60 |
+
public function apply($transformer, $context, $node)
|
| 61 |
{
|
| 62 |
$interactive = Interactive::create();
|
| 63 |
|
| 64 |
+
if (Type::is($context, InstantArticle::getClassName())) {
|
| 65 |
+
$instant_article = $context;
|
| 66 |
+
} elseif ($transformer->getInstantArticle()) {
|
| 67 |
+
$instant_article = $transformer->getInstantArticle();
|
| 68 |
+
$context->disableEmptyValidation();
|
| 69 |
+
$context = Paragraph::create();
|
| 70 |
+
$context->disableEmptyValidation();
|
| 71 |
+
} else {
|
| 72 |
+
$transformer->addWarning(
|
| 73 |
+
// This new error message should be something like:
|
| 74 |
+
// Could not transform Image, as no root InstantArticle was provided.
|
| 75 |
+
new NoRootInstantArticleFoundWarning(null, $node)
|
| 76 |
+
);
|
| 77 |
+
return $context;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
// Builds the interactive
|
| 81 |
$iframe = $this->getProperty(self::PROPERTY_IFRAME, $node);
|
| 82 |
$url = $this->getProperty(self::PROPERTY_URL, $node);
|
| 88 |
}
|
| 89 |
if ($iframe || $url) {
|
| 90 |
$instant_article->addChild($interactive);
|
| 91 |
+
if ($instant_article !== $context) {
|
| 92 |
+
$instant_article->addChild($context);
|
| 93 |
+
}
|
| 94 |
} else {
|
| 95 |
$transformer->addWarning(
|
| 96 |
new InvalidSelector(
|
| 123 |
$transformer->transform($interactive, $node);
|
| 124 |
$transformer->suppress_warnings = $suppress_warnings;
|
| 125 |
|
| 126 |
+
return $context;
|
| 127 |
}
|
| 128 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/TimeRule.php
CHANGED
|
@@ -14,7 +14,8 @@ use Facebook\InstantArticles\Transformer\Warnings\InvalidSelector;
|
|
| 14 |
|
| 15 |
class TimeRule extends ConfigurationSelectorRule
|
| 16 |
{
|
| 17 |
-
const
|
|
|
|
| 18 |
const PROPERTY_TIME = 'article.time';
|
| 19 |
|
| 20 |
private $type = Time::PUBLISHED;
|
|
@@ -34,13 +35,17 @@ class TimeRule extends ConfigurationSelectorRule
|
|
| 34 |
$time_rule = self::create();
|
| 35 |
$time_rule->withSelector($configuration['selector']);
|
| 36 |
|
| 37 |
-
$time_rule->
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
);
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
return $time_rule;
|
|
@@ -48,6 +53,11 @@ class TimeRule extends ConfigurationSelectorRule
|
|
| 48 |
|
| 49 |
public function apply($transformer, $header, $node)
|
| 50 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
// Builds the image
|
| 52 |
$time_string = $this->getProperty(self::PROPERTY_TIME, $node);
|
| 53 |
if ($time_string) {
|
|
@@ -65,6 +75,8 @@ class TimeRule extends ConfigurationSelectorRule
|
|
| 65 |
);
|
| 66 |
}
|
| 67 |
|
|
|
|
|
|
|
| 68 |
return $header;
|
| 69 |
}
|
| 70 |
}
|
| 14 |
|
| 15 |
class TimeRule extends ConfigurationSelectorRule
|
| 16 |
{
|
| 17 |
+
const PROPERTY_TIME_TYPE_DEPRECATED = 'article.time_type';
|
| 18 |
+
const PROPERTY_DATETIME_TYPE = 'article.datetype';
|
| 19 |
const PROPERTY_TIME = 'article.time';
|
| 20 |
|
| 21 |
private $type = Time::PUBLISHED;
|
| 35 |
$time_rule = self::create();
|
| 36 |
$time_rule->withSelector($configuration['selector']);
|
| 37 |
|
| 38 |
+
$time_rule->withProperties(
|
| 39 |
+
[
|
| 40 |
+
self::PROPERTY_TIME,
|
| 41 |
+
self::PROPERTY_DATETIME_TYPE
|
| 42 |
+
],
|
| 43 |
+
$configuration
|
| 44 |
);
|
| 45 |
|
| 46 |
+
// Just for retrocompatibility - issue #172
|
| 47 |
+
if (isset($configuration[self::PROPERTY_TIME_TYPE_DEPRECATED])) {
|
| 48 |
+
$time_rule->type = $configuration[self::PROPERTY_TIME_TYPE_DEPRECATED];
|
| 49 |
}
|
| 50 |
|
| 51 |
return $time_rule;
|
| 53 |
|
| 54 |
public function apply($transformer, $header, $node)
|
| 55 |
{
|
| 56 |
+
$time_type = $this->getProperty(self::PROPERTY_DATETIME_TYPE, $node);
|
| 57 |
+
if ($time_type) {
|
| 58 |
+
$this->type = $time_type;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
// Builds the image
|
| 62 |
$time_string = $this->getProperty(self::PROPERTY_TIME, $node);
|
| 63 |
if ($time_string) {
|
| 75 |
);
|
| 76 |
}
|
| 77 |
|
| 78 |
+
|
| 79 |
+
|
| 80 |
return $header;
|
| 81 |
}
|
| 82 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Client/HelperTest.php
CHANGED
|
@@ -54,7 +54,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase
|
|
| 54 |
$this->facebook
|
| 55 |
->expects($this->once())
|
| 56 |
->method('get')
|
| 57 |
-
->with('/me/accounts?fields=name,id,access_token,supports_instant_articles,picture')
|
| 58 |
->willReturn($response);
|
| 59 |
|
| 60 |
$pagesAndTokensReturned = $this->helper->getPagesAndTokens($accessToken);
|
| 54 |
$this->facebook
|
| 55 |
->expects($this->once())
|
| 56 |
->method('get')
|
| 57 |
+
->with('/me/accounts?fields=name,id,access_token,supports_instant_articles,picture&offset=0')
|
| 58 |
->willReturn($response);
|
| 59 |
|
| 60 |
$pagesAndTokensReturned = $this->helper->getPagesAndTokens($accessToken);
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/InstantArticleTest.php
CHANGED
|
@@ -414,4 +414,63 @@ class InstantArticleTest extends \PHPUnit_Framework_TestCase
|
|
| 414 |
{
|
| 415 |
$this->assertInstanceOf('Facebook\InstantArticles\Elements\InstantArticleInterface', $this->article);
|
| 416 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
}
|
| 414 |
{
|
| 415 |
$this->assertInstanceOf('Facebook\InstantArticles\Elements\InstantArticleInterface', $this->article);
|
| 416 |
}
|
| 417 |
+
|
| 418 |
+
public function testIsRTLEnabled()
|
| 419 |
+
{
|
| 420 |
+
$article =
|
| 421 |
+
InstantArticle::create()
|
| 422 |
+
->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')
|
| 423 |
+
->enableAutomaticAdPlacement()
|
| 424 |
+
->enableRTL()
|
| 425 |
+
->withHeader(
|
| 426 |
+
Header::create()
|
| 427 |
+
->withTitle(
|
| 428 |
+
H1::create()->appendText('Peace on <b>earth</b>')
|
| 429 |
+
)
|
| 430 |
+
->addAuthor(
|
| 431 |
+
Author::create()->withName('bill')
|
| 432 |
+
)
|
| 433 |
+
->withPublishTime(
|
| 434 |
+
Time::create(Time::PUBLISHED)
|
| 435 |
+
->withDatetime(
|
| 436 |
+
\DateTime::createFromFormat(
|
| 437 |
+
'j-M-Y G:i:s',
|
| 438 |
+
'14-Aug-1984 19:30:00'
|
| 439 |
+
)
|
| 440 |
+
)
|
| 441 |
+
)
|
| 442 |
+
)
|
| 443 |
+
->addChild(
|
| 444 |
+
Paragraph::create()
|
| 445 |
+
->appendText('Yes, peace is good for everybody!')
|
| 446 |
+
->appendText(LineBreak::create())
|
| 447 |
+
->appendText(' Man kind.')
|
| 448 |
+
);
|
| 449 |
+
$result = $article->render();
|
| 450 |
+
$expected =
|
| 451 |
+
'<!doctype html>'.
|
| 452 |
+
'<html dir="rtl">'.
|
| 453 |
+
'<head>'.
|
| 454 |
+
'<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>'.
|
| 455 |
+
'<meta charset="utf-8"/>'.
|
| 456 |
+
'<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>'.
|
| 457 |
+
'<meta property="op:generator:version" content="1.5.2"/>'.
|
| 458 |
+
'<meta property="op:markup_version" content="v1.0"/>'.
|
| 459 |
+
'</head>'.
|
| 460 |
+
'<body>'.
|
| 461 |
+
'<article>'.
|
| 462 |
+
'<header>'.
|
| 463 |
+
'<h1>Peace on <b>earth</b></h1>'.
|
| 464 |
+
'<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>'.
|
| 465 |
+
'<address>'.
|
| 466 |
+
'<a>bill</a>'.
|
| 467 |
+
'</address>'.
|
| 468 |
+
'</header>'.
|
| 469 |
+
'<p>Yes, peace is good for everybody!<br/> Man kind.</p>'.
|
| 470 |
+
'</article>'.
|
| 471 |
+
'</body>'.
|
| 472 |
+
'</html>';
|
| 473 |
+
|
| 474 |
+
$this->assertEquals($expected, $result);
|
| 475 |
+
}
|
| 476 |
}
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-ia.html
CHANGED
|
@@ -36,6 +36,18 @@
|
|
| 36 |
<h1>Custom code for your social embed</h1>
|
| 37 |
<script>alert("test & more test");</script></iframe>
|
| 38 |
</figure>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</article>
|
| 40 |
</body>
|
| 41 |
</html>
|
| 36 |
<h1>Custom code for your social embed</h1>
|
| 37 |
<script>alert("test & more test");</script></iframe>
|
| 38 |
</figure>
|
| 39 |
+
<figure>
|
| 40 |
+
<img src="http://domain.com/image-header.png"/>
|
| 41 |
+
<figcaption>Some amazing moment captured by Photographer</figcaption>
|
| 42 |
+
</figure>
|
| 43 |
+
<figure>
|
| 44 |
+
<img src="http://domain.com/image-header.png?suffix=yes"/>
|
| 45 |
+
<figcaption>Some amazing moment captured by Photographer</figcaption>
|
| 46 |
+
</figure>
|
| 47 |
+
<figure>
|
| 48 |
+
<img src="http://domain.com/image-header.png?suffix=yes"/>
|
| 49 |
+
<figcaption>Some amazing moment captured by Photographer</figcaption>
|
| 50 |
+
</figure>
|
| 51 |
</article>
|
| 52 |
</body>
|
| 53 |
</html>
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-rules.json
CHANGED
|
@@ -84,6 +84,55 @@
|
|
| 84 |
}
|
| 85 |
}
|
| 86 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
{
|
| 88 |
"class": "HeaderImageRule",
|
| 89 |
"selector" : "div.hero-image",
|
| 84 |
}
|
| 85 |
}
|
| 86 |
},
|
| 87 |
+
{
|
| 88 |
+
"class": "ImageRule",
|
| 89 |
+
"selector" : "div.prefix",
|
| 90 |
+
"properties" : {
|
| 91 |
+
"image.url" : {
|
| 92 |
+
"type" : "string",
|
| 93 |
+
"selector" : "img",
|
| 94 |
+
"attribute": "src",
|
| 95 |
+
"prefix": "http:"
|
| 96 |
+
},
|
| 97 |
+
"image.caption" : {
|
| 98 |
+
"type" : "element",
|
| 99 |
+
"selector" : "div.image-caption"
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"class": "ImageRule",
|
| 105 |
+
"selector" : "div.suffix",
|
| 106 |
+
"properties" : {
|
| 107 |
+
"image.url" : {
|
| 108 |
+
"type" : "string",
|
| 109 |
+
"selector" : "img",
|
| 110 |
+
"attribute": "src",
|
| 111 |
+
"suffix": "?suffix=yes"
|
| 112 |
+
},
|
| 113 |
+
"image.caption" : {
|
| 114 |
+
"type" : "element",
|
| 115 |
+
"selector" : "div.image-caption"
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"class": "ImageRule",
|
| 121 |
+
"selector" : "div.prefixsuffix",
|
| 122 |
+
"properties" : {
|
| 123 |
+
"image.url" : {
|
| 124 |
+
"type" : "string",
|
| 125 |
+
"selector" : "img",
|
| 126 |
+
"attribute": "src",
|
| 127 |
+
"prefix" : "http:",
|
| 128 |
+
"suffix": "?suffix=yes"
|
| 129 |
+
},
|
| 130 |
+
"image.caption" : {
|
| 131 |
+
"type" : "element",
|
| 132 |
+
"selector" : "div.image-caption"
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
},
|
| 136 |
{
|
| 137 |
"class": "HeaderImageRule",
|
| 138 |
"selector" : "div.hero-image",
|
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple.html
CHANGED
|
@@ -25,5 +25,17 @@
|
|
| 25 |
<h1>Custom code for your social embed</h1>
|
| 26 |
<script>alert("test & more test");</script>
|
| 27 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
</body>
|
| 29 |
</html>
|
| 25 |
<h1>Custom code for your social embed</h1>
|
| 26 |
<script>alert("test & more test");</script>
|
| 27 |
</div>
|
| 28 |
+
<div class="prefix">
|
| 29 |
+
<img src="//domain.com/image-header.png" />
|
| 30 |
+
<div class="image-caption">Some amazing moment captured by Photographer</div>
|
| 31 |
+
</div>
|
| 32 |
+
<div class="suffix">
|
| 33 |
+
<img src="http://domain.com/image-header.png" />
|
| 34 |
+
<div class="image-caption">Some amazing moment captured by Photographer</div>
|
| 35 |
+
</div>
|
| 36 |
+
<div class="prefixsuffix">
|
| 37 |
+
<img src="//domain.com/image-header.png" />
|
| 38 |
+
<div class="image-caption">Some amazing moment captured by Photographer</div>
|
| 39 |
+
</div>
|
| 40 |
</body>
|
| 41 |
</html>
|
vendor/symfony/css-selector/composer.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
}
|
| 21 |
],
|
| 22 |
"require": {
|
| 23 |
-
"php": ">=5.
|
| 24 |
},
|
| 25 |
"autoload": {
|
| 26 |
"psr-4": { "Symfony\\Component\\CssSelector\\": "" },
|
|
@@ -31,7 +31,7 @@
|
|
| 31 |
"minimum-stability": "dev",
|
| 32 |
"extra": {
|
| 33 |
"branch-alias": {
|
| 34 |
-
"dev-master": "
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 20 |
}
|
| 21 |
],
|
| 22 |
"require": {
|
| 23 |
+
"php": ">=5.5.9"
|
| 24 |
},
|
| 25 |
"autoload": {
|
| 26 |
"psr-4": { "Symfony\\Component\\CssSelector\\": "" },
|
| 31 |
"minimum-stability": "dev",
|
| 32 |
"extra": {
|
| 33 |
"branch-alias": {
|
| 34 |
+
"dev-master": "3.1-dev"
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
wpcom-helper.php
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
| 3 |
// Wrap the wpcom tracking pixel to comply with the FBIA spec
|
| 4 |
// https://developers.facebook.com/docs/instant-articles/reference/analytics
|
| 5 |
-
function
|
| 6 |
global $post;
|
| 7 |
|
| 8 |
if ( ! defined( 'INSTANT_ARTICLES_SLUG' ) ) {
|
|
@@ -16,34 +18,32 @@ function wpcom_fbia_stats_pixel() {
|
|
| 16 |
// Stop wpcom adding the tracking pixel
|
| 17 |
remove_filter( 'the_content', 'add_bug_to_feed', 100 );
|
| 18 |
|
| 19 |
-
add_filter( 'the_content', '_wpcom_fbia_stats_pixel', 100 );
|
| 20 |
-
|
| 21 |
}
|
| 22 |
-
add_action( 'template_redirect', '
|
| 23 |
|
| 24 |
-
function
|
| 25 |
-
global $post, $current_blog;
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
}
|
| 30 |
|
|
|
|
| 31 |
$hostname = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; // input var okay
|
| 32 |
|
| 33 |
$url = 'https://pixel.wp.com/b.gif?host=' . $hostname . '&blog=' . $current_blog->blog_id . '&post=' . $post->ID . '&subd=' . str_replace( '.wordpress.com', '', $current_blog->domain ) . '&ref=&feed=1';
|
| 34 |
|
| 35 |
-
$
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
</figure>';
|
| 43 |
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
}
|
|
|
|
| 47 |
|
| 48 |
// make sure these function run in wp.com environment where `plugins_loaded` is already fired when loading the plugin
|
| 49 |
add_action( 'after_setup_theme', 'instant_articles_load_textdomain' );
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
use Facebook\InstantArticles\Elements\Analytics;
|
| 4 |
+
|
| 5 |
// Wrap the wpcom tracking pixel to comply with the FBIA spec
|
| 6 |
// https://developers.facebook.com/docs/instant-articles/reference/analytics
|
| 7 |
+
function wpcom_fbia_remove_stats_pixel() {
|
| 8 |
global $post;
|
| 9 |
|
| 10 |
if ( ! defined( 'INSTANT_ARTICLES_SLUG' ) ) {
|
| 18 |
// Stop wpcom adding the tracking pixel
|
| 19 |
remove_filter( 'the_content', 'add_bug_to_feed', 100 );
|
| 20 |
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
+
add_action( 'template_redirect', 'wpcom_fbia_remove_stats_pixel' );
|
| 23 |
|
| 24 |
+
function wpcom_fbia_add_stats_pixel( $ia_post ) {
|
|
|
|
| 25 |
|
| 26 |
+
// Get the IA article.
|
| 27 |
+
$instant_article = $ia_post->instant_article;
|
|
|
|
| 28 |
|
| 29 |
+
// Create the wpcom stats code.
|
| 30 |
$hostname = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; // input var okay
|
| 31 |
|
| 32 |
$url = 'https://pixel.wp.com/b.gif?host=' . $hostname . '&blog=' . $current_blog->blog_id . '&post=' . $post->ID . '&subd=' . str_replace( '.wordpress.com', '', $current_blog->domain ) . '&ref=&feed=1';
|
| 33 |
|
| 34 |
+
$pixel_html = '<script>
|
| 35 |
+
var x = new Image(); x.src = "' . esc_js( $url ) . '&rand=" +Math.random();
|
| 36 |
+
</script>';
|
| 37 |
+
|
| 38 |
+
// Create our FBIA markup
|
| 39 |
+
$fbia_markup = Analytics::create();
|
| 40 |
+
$fbia_markup->withHTML( $pixel_html );
|
|
|
|
| 41 |
|
| 42 |
+
// Add the FBIA-compatible stats markup to the IA content
|
| 43 |
+
$instant_article->addChild( $fbia_markup );
|
| 44 |
|
| 45 |
}
|
| 46 |
+
add_action( 'instant_articles_after_transform_post', 'wpcom_fbia_add_stats_pixel' );
|
| 47 |
|
| 48 |
// make sure these function run in wp.com environment where `plugins_loaded` is already fired when loading the plugin
|
| 49 |
add_action( 'after_setup_theme', 'instant_articles_load_textdomain' );
|
