Version Description
(11th January 2020) = * Fixed: In amp-pixel script adding automatically. #4057
Download this release
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 1.0.11 |
Comparing to | |
See all releases |
Code changes from version 1.0.10 to 1.0.11
- README.md +4 -1
- accelerated-moblie-pages.php +2 -2
- changelog.txt +3 -0
- includes/vendor/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php +1 -1
- readme.txt +4 -1
- templates/features.php +45 -9
README.md
CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
|
|
4 |
Donate link: https://www.paypal.me/Kaludi/25
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 5.3.2
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -191,6 +191,9 @@ You can contact us from [here](https://ampforwp.com/contact/)
|
|
191 |
|
192 |
== Changelog ==
|
193 |
|
|
|
|
|
|
|
194 |
= 1.0.10 (10th January 2020) =
|
195 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
196 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
4 |
Donate link: https://www.paypal.me/Kaludi/25
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 5.3.2
|
7 |
+
Stable tag: 1.0.11
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
191 |
|
192 |
== Changelog ==
|
193 |
|
194 |
+
= 1.0.11 (11th January 2020) =
|
195 |
+
* Fixed: In amp-pixel script adding automatically. #4057
|
196 |
+
|
197 |
= 1.0.10 (10th January 2020) =
|
198 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
199 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
accelerated-moblie-pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
|
5 |
Description: AMP for WP - Accelerated Mobile Pages for WordPress
|
6 |
-
Version: 1.0.
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: https://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/25
|
@@ -20,7 +20,7 @@ define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
|
|
20 |
define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
|
21 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
22 |
define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
|
23 |
-
define('AMPFORWP_VERSION','1.0.
|
24 |
define('AMPFORWP_EXTENSION_DIR',plugin_dir_path(__FILE__).'includes/options/extensions');
|
25 |
if(!defined('AMPFROWP_HOST_NAME')){
|
26 |
$urlinfo = get_bloginfo('url');
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
|
5 |
Description: AMP for WP - Accelerated Mobile Pages for WordPress
|
6 |
+
Version: 1.0.11
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: https://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/25
|
20 |
define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.html');
|
21 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
22 |
define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
|
23 |
+
define('AMPFORWP_VERSION','1.0.11');
|
24 |
define('AMPFORWP_EXTENSION_DIR',plugin_dir_path(__FILE__).'includes/options/extensions');
|
25 |
if(!defined('AMPFROWP_HOST_NAME')){
|
26 |
$urlinfo = get_bloginfo('url');
|
changelog.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
== Changelog ==
|
2 |
|
|
|
|
|
|
|
3 |
= 1.0.10 (10th January 2020) =
|
4 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
5 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.0.11 (11th January 2020) =
|
4 |
+
* Fixed: In amp-pixel script adding automatically. #4057
|
5 |
+
|
6 |
= 1.0.10 (10th January 2020) =
|
7 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
8 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
includes/vendor/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php
CHANGED
@@ -208,7 +208,7 @@ class AMP_Tag_And_Attribute_Sanitizer extends AMP_Base_Sanitizer {
|
|
208 |
$scriptArray = array_fill_keys( $this->script_components, true );
|
209 |
foreach ( $scriptArray as $ext_key=>$ext_value ) {
|
210 |
$version = 'latest';
|
211 |
-
if ( 'amp-carousel' == $ext_key ) {
|
212 |
$version = '0.1';
|
213 |
}
|
214 |
$scriptArray[$ext_key] = sprintf(
|
208 |
$scriptArray = array_fill_keys( $this->script_components, true );
|
209 |
foreach ( $scriptArray as $ext_key=>$ext_value ) {
|
210 |
$version = 'latest';
|
211 |
+
if ( 'amp-carousel' == $ext_key || 'amp-auto-ads' == $ext_key || 'amp-ad' == $ext_key ) {
|
212 |
$version = '0.1';
|
213 |
}
|
214 |
$scriptArray[$ext_key] = sprintf(
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, go
|
|
4 |
Donate link: https://www.paypal.me/Kaludi/25
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 5.3.2
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -191,6 +191,9 @@ You can contact us from [here](https://ampforwp.com/contact/)
|
|
191 |
|
192 |
== Changelog ==
|
193 |
|
|
|
|
|
|
|
194 |
= 1.0.10 (10th January 2020) =
|
195 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
196 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
4 |
Donate link: https://www.paypal.me/Kaludi/25
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 5.3.2
|
7 |
+
Stable tag: 1.0.11
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
191 |
|
192 |
== Changelog ==
|
193 |
|
194 |
+
= 1.0.11 (11th January 2020) =
|
195 |
+
* Fixed: In amp-pixel script adding automatically. #4057
|
196 |
+
|
197 |
= 1.0.10 (10th January 2020) =
|
198 |
* Improvement: Need a hook to use it in Woocomerce #4048
|
199 |
* Fixed: Scripts are not adding properly if user is adding the content through embed #4040
|
templates/features.php
CHANGED
@@ -2289,15 +2289,20 @@ function ampforwp_set_body_content_script($data){
|
|
2289 |
for($i=0;$i<count($amp_comp);$i++){
|
2290 |
$comp = $amp_comp[$i];
|
2291 |
if($comp!='img'){
|
|
|
|
|
|
|
|
|
|
|
2292 |
if(isset($matches[1][0])){
|
2293 |
$thtml = $matches1[1];
|
2294 |
if(!in_array($comp, $thtml)){
|
2295 |
-
$data['amp_component_scripts']["amp-".esc_attr($comp)] =
|
2296 |
}else{
|
2297 |
-
$data['amp_component_scripts']["amp-".esc_attr($comp)] =
|
2298 |
}
|
2299 |
} else{
|
2300 |
-
$data['amp_component_scripts']["amp-".esc_attr($comp)] =
|
2301 |
}
|
2302 |
}
|
2303 |
}
|
@@ -7614,21 +7619,52 @@ if(!function_exists('ampforwp_transposh_plugin_rtl_css')){
|
|
7614 |
}
|
7615 |
}
|
7616 |
}
|
7617 |
-
|
7618 |
-
|
7619 |
-
|
7620 |
preg_match_all('/<\/amp-(.*?)>/', $content, $matches);
|
7621 |
if(isset($matches[1][0])){
|
7622 |
$amp_comp = $matches[1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7623 |
for($i=0;$i<count($amp_comp);$i++){
|
7624 |
$comp = $amp_comp[$i];
|
7625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7626 |
if(!preg_match('/<script\scustom-element=\"amp-'.esc_attr($comp).'\"(.*?)><\/script>/', $content, $matches)){
|
7627 |
-
$script_tag = '<head><script custom-element="amp-'.esc_attr($comp).'" src="
|
7628 |
$content = str_replace('<head>', $script_tag, $content);
|
7629 |
}
|
7630 |
}
|
7631 |
}
|
7632 |
}
|
7633 |
return $content;
|
7634 |
-
}
|
2289 |
for($i=0;$i<count($amp_comp);$i++){
|
2290 |
$comp = $amp_comp[$i];
|
2291 |
if($comp!='img'){
|
2292 |
+
$script_ver = 'latest';
|
2293 |
+
if($comp == 'auto-ads' || $comp == 'ad'){
|
2294 |
+
$script_ver = '0.1';
|
2295 |
+
}
|
2296 |
+
$component_url = "https://cdn.ampproject.org/v0/amp-".esc_attr($comp)."-".esc_attr($script_ver).".js";
|
2297 |
if(isset($matches[1][0])){
|
2298 |
$thtml = $matches1[1];
|
2299 |
if(!in_array($comp, $thtml)){
|
2300 |
+
$data['amp_component_scripts']["amp-".esc_attr($comp)] = esc_url($component_url);
|
2301 |
}else{
|
2302 |
+
$data['amp_component_scripts']["amp-".esc_attr($comp)] = esc_url($component_url);
|
2303 |
}
|
2304 |
} else{
|
2305 |
+
$data['amp_component_scripts']["amp-".esc_attr($comp)] = esc_url($component_url);
|
2306 |
}
|
2307 |
}
|
2308 |
}
|
7619 |
}
|
7620 |
}
|
7621 |
}
|
7622 |
+
|
7623 |
+
add_filter('ampforwp_the_content_last_filter','ampforwp_include_required_scripts',12);
|
7624 |
+
function ampforwp_include_required_scripts($content){
|
7625 |
preg_match_all('/<\/amp-(.*?)>/', $content, $matches);
|
7626 |
if(isset($matches[1][0])){
|
7627 |
$amp_comp = $matches[1];
|
7628 |
+
$comp_to_remove_json = get_transient('ampforwp_amp_exclude_custom_element');
|
7629 |
+
$comp_to_include_json = get_transient('ampforwp_amp_included_custom_element');
|
7630 |
+
$comp_to_remove_arr = array();
|
7631 |
+
if($comp_to_remove_json){
|
7632 |
+
$comp_to_remove_arr = json_decode($comp_to_remove_json, true);
|
7633 |
+
}
|
7634 |
+
$comp_to_include_arr = array();
|
7635 |
+
if($comp_to_include_json){
|
7636 |
+
$comp_to_include_arr = json_decode($comp_to_include_json, true);
|
7637 |
+
}
|
7638 |
for($i=0;$i<count($amp_comp);$i++){
|
7639 |
$comp = $amp_comp[$i];
|
7640 |
+
$script_ver = 'latest';
|
7641 |
+
if($comp == 'auto-ads' || $comp == 'ad'){
|
7642 |
+
$script_ver = '0.1';
|
7643 |
+
}
|
7644 |
+
$comp_url = 'https://cdn.ampproject.org/v0/amp-'.esc_attr($comp).'-'.esc_attr($script_ver).'.js';
|
7645 |
+
if(!in_array($comp, $comp_to_remove_arr) && !in_array($comp, $comp_to_include_arr) ){
|
7646 |
+
$headers = get_headers($comp_url);
|
7647 |
+
if(isset($headers[0])){
|
7648 |
+
$is_script = stripos($headers[0], "200 OK") ? TRUE : FALSE;
|
7649 |
+
if($is_script){
|
7650 |
+
$comp_to_include_arr[] = $comp;
|
7651 |
+
$inc_json = json_encode($comp_to_include_arr);
|
7652 |
+
set_transient('ampforwp_amp_included_custom_element',$inc_json, 30 * DAY_IN_SECONDS);
|
7653 |
+
}else{
|
7654 |
+
$comp_to_remove_arr[] = $comp;
|
7655 |
+
$ex_json = json_encode($comp_to_remove_arr);
|
7656 |
+
set_transient('ampforwp_amp_exclude_custom_element',$ex_json, 30 * DAY_IN_SECONDS);
|
7657 |
+
}
|
7658 |
+
}
|
7659 |
+
}
|
7660 |
+
$comp_to_include_arr = apply_filters('ampforwp_amp_custom_element_to_include',$comp_to_include_arr);
|
7661 |
+
if(in_array($comp, $comp_to_include_arr)){
|
7662 |
if(!preg_match('/<script\scustom-element=\"amp-'.esc_attr($comp).'\"(.*?)><\/script>/', $content, $matches)){
|
7663 |
+
$script_tag = '<head><script custom-element="amp-'.esc_attr($comp).'" src="'.esc_url($comp_url).'" async></script>';
|
7664 |
$content = str_replace('<head>', $script_tag, $content);
|
7665 |
}
|
7666 |
}
|
7667 |
}
|
7668 |
}
|
7669 |
return $content;
|
7670 |
+
}
|