Version Description
(18th February 2020) = * Improvement: Scripts added from Options panel should have higher priority in the frontend #4064
Download this release
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 1.0.28 |
Comparing to | |
See all releases |
Code changes from version 1.0.27 to 1.0.28
- README.md +4 -1
- accelerated-moblie-pages.php +2 -2
- changelog.txt +3 -0
- includes/thirdparty-compatibility.php +5 -0
- readme.txt +4 -1
- templates/features.php +80 -40
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 |
|
@@ -194,6 +194,9 @@ Device testing done through [BrowserStack](https://www.browserstack.com)
|
|
194 |
|
195 |
== Changelog ==
|
196 |
|
|
|
|
|
|
|
197 |
= 1.0.27 (16th February 2020) =
|
198 |
* Fixed: Bugs in Imagify plugin #3908
|
199 |
* Fixed: GDPR popup not blocking header #4155
|
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.28
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
194 |
|
195 |
== Changelog ==
|
196 |
|
197 |
+
= 1.0.28 (18th February 2020) =
|
198 |
+
* Improvement: Scripts added from Options panel should have higher priority in the frontend #4064
|
199 |
+
|
200 |
= 1.0.27 (16th February 2020) =
|
201 |
* Fixed: Bugs in Imagify plugin #3908
|
202 |
* Fixed: GDPR popup not blocking header #4155
|
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.28
|
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.28');
|
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.27 (16th February 2020) =
|
4 |
* Fixed: Bugs in Imagify plugin #3908
|
5 |
* Fixed: GDPR popup not blocking header #4155
|
1 |
== Changelog ==
|
2 |
|
3 |
+
= 1.0.28 (18th February 2020) =
|
4 |
+
* Improvement: Scripts added from Options panel should have higher priority in the frontend #4064
|
5 |
+
|
6 |
= 1.0.27 (16th February 2020) =
|
7 |
* Fixed: Bugs in Imagify plugin #3908
|
8 |
* Fixed: GDPR popup not blocking header #4155
|
includes/thirdparty-compatibility.php
CHANGED
@@ -1079,4 +1079,9 @@ if(!function_exists('ampforwp_mistape_plugin_compatibility')){
|
|
1079 |
}
|
1080 |
return $content;
|
1081 |
}
|
|
|
|
|
|
|
|
|
|
|
1082 |
}
|
1079 |
}
|
1080 |
return $content;
|
1081 |
}
|
1082 |
+
}
|
1083 |
+
function ampforwp_valid_amp_componet_script(){
|
1084 |
+
$ce_valid_scripts = array('amp-3d-gltf','amp-3q-player','amp-access','amp-analytics','amp-access-laterpay','amp-access-poool','amp-accordion','amp-action-macro','amp-ad-exit','amp-ad','amp-addthis','amp-anim','amp-animation','amp-apester-media','amp-app-banner','amp-audio','amp-auto-ads','amp-autocomplete','amp-base-carousel','amp-beopinion','amp-bind','amp-bodymovin-animation','amp-brid-player','amp-brightcove','amp-byside-content','amp-call-tracking','amp-carousel','amp-connatix-player','amp-consent','amp-dailymotion','amp-date-countdown','amp-date-picker','amp-delight-player','amp-dynamic-css-classes','amp-embedly-card','amp-experiment','amp-facebook-comments','amp-facebook-like','amp-facebook-page','amp-facebook','amp-fit-text','amp-font','amp-form','amp-fx-collection','amp-fx-flying-carpet','amp-geo','amp-gfycat','amp-gist','amp-google-document-embed','amp-google-vrview-image','amp-hulu','amp-iframe','amp-ima-video','amp-image-lightbox','amp-image-slider','amp-imgur','amp-inputmask','amp-instagram','amp-install-serviceworker','amp-izlesene','amp-jwplayer','amp-kaltura-player','amp-lightbox-gallery','amp-lightbox','amp-link-rewriter','amp-list','amp-live-list','amp-mathml','amp-mega-menu','amp-megaphone','amp-minute-media-player','amp-form','amp-mustache','amp-next-page','amp-nexxtv-player','amp-o2-player','amp-ooyala-player','amp-orientation-observer','amp-pan-zoom','amp-pinterest','amp-playbuzz','amp-position-observer','amp-powr-player','amp-reach-player','amp-recaptcha-input','amp-redbull-player','amp-reddit','amp-riddle-quiz','amp-script','amp-selector','amp-sidebar','amp-skimlinks','amp-smartlinks','amp-social-share','amp-soundcloud','amp-springboard-player','amp-sticky-ad','amp-story-auto-ads','amp-story','amp-subscriptions-google','amp-subscriptions','amp-timeago','amp-truncate-text','amp-twitter','amp-user-notification','amp-video-docking','amp-video-iframe','amp-video','amp-vimeo','amp-vine','amp-viqeo-player','amp-viz-vega','amp-vk','amp-web-push','amp-wistia-player','amp-yotpo','amp-youtube');
|
1085 |
+
$ce_valid_scripts = apply_filters('ampforwp_valid_amp_component_script',$ce_valid_scripts);
|
1086 |
+
return $ce_valid_scripts;
|
1087 |
}
|
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.27 (16th February 2020) =
|
195 |
* Fixed: Bugs in Imagify plugin #3908
|
196 |
* Fixed: GDPR popup not blocking header #4155
|
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.28
|
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.28 (18th February 2020) =
|
195 |
+
* Improvement: Scripts added from Options panel should have higher priority in the frontend #4064
|
196 |
+
|
197 |
= 1.0.27 (16th February 2020) =
|
198 |
* Fixed: Bugs in Imagify plugin #3908
|
199 |
* Fixed: GDPR popup not blocking header #4155
|
templates/features.php
CHANGED
@@ -7711,24 +7711,28 @@ function ampforwp_include_required_scripts($content){
|
|
7711 |
}
|
7712 |
$comp_url = 'https://cdn.ampproject.org/v0/amp-'.esc_attr($comp).'-'.esc_attr($script_ver).'.js';
|
7713 |
$is_script = false;
|
7714 |
-
|
7715 |
if(!in_array($comp, $comp_to_remove_arr) && !in_array($comp, $comp_to_include_arr) ){
|
7716 |
-
$
|
7717 |
-
|
7718 |
-
|
7719 |
-
|
7720 |
-
|
7721 |
-
|
7722 |
-
|
7723 |
-
|
7724 |
-
$
|
7725 |
-
set_transient('ampforwp_amp_included_custom_element',$inc_json, 30 * DAY_IN_SECONDS);
|
7726 |
-
}else{
|
7727 |
-
$comp_to_remove_arr[] = $comp;
|
7728 |
-
$ex_json = json_encode($comp_to_remove_arr);
|
7729 |
-
set_transient('ampforwp_amp_exclude_custom_element',$ex_json, 30 * DAY_IN_SECONDS);
|
7730 |
}
|
7731 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7732 |
}
|
7733 |
$comp_to_include_arr = apply_filters('ampforwp_amp_custom_element_to_include',$comp_to_include_arr);
|
7734 |
if(in_array($comp, $comp_to_include_arr)){
|
@@ -7741,36 +7745,31 @@ function ampforwp_include_required_scripts($content){
|
|
7741 |
}
|
7742 |
}
|
7743 |
|
7744 |
-
|
7745 |
-
$
|
7746 |
-
|
7747 |
-
|
7748 |
-
|
7749 |
-
|
7750 |
-
|
7751 |
-
|
7752 |
-
|
7753 |
-
|
7754 |
-
|
7755 |
-
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
|
7756 |
-
$content = str_replace('<head>', $script_tag, $content);
|
7757 |
-
}
|
7758 |
-
}
|
7759 |
}
|
7760 |
-
|
7761 |
-
|
7762 |
-
|
7763 |
-
$excl_arr = array('amp-form','amp-bind','amp-access','amp-analytics','amp-access-laterpay','amp-access-poool','amp-dynamic-css-classes','amp-fx-collection','amp-inputmask','amp-lightbox-gallery','amp-inputmask','amp-mustache','amp-subscriptions-google','amp-subscriptions','amp-video-docking','amp-story');
|
7764 |
$inc_elem_arr = array();
|
7765 |
for($r=0;$r<count($comp_to_remove_arr);$r++){
|
7766 |
$inc_elem_arr[] = 'amp-'.$comp_to_remove_arr[$r];
|
7767 |
}
|
7768 |
-
for($i=0;$i<count($
|
7769 |
-
if(isset($
|
7770 |
-
$component = $
|
7771 |
if(!in_array($component,$excl_arr)){
|
7772 |
if(!preg_match("/<\/$component>/", $content) && !$is_script){
|
7773 |
-
$remove_comp = $
|
7774 |
$content = str_replace($remove_comp, '', $content);
|
7775 |
}else if(in_array($component, $inc_elem_arr )){
|
7776 |
for($rc=0;$rc<count($inc_elem_arr);$rc++){
|
@@ -7785,14 +7784,55 @@ function ampforwp_include_required_scripts($content){
|
|
7785 |
}
|
7786 |
}
|
7787 |
// REMOVING DUPLICATE SCRIPT.
|
7788 |
-
$count_elem = array_count_values($
|
7789 |
if($count_elem>1){
|
7790 |
-
$content = preg_replace('/<script(\s|\sasync\s)custom-element="'.esc_attr($component).'"(.*?)>(.*?)<\/script>/s','',$content,1,$
|
7791 |
}
|
7792 |
}
|
7793 |
}
|
7794 |
}
|
7795 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7796 |
return $content;
|
7797 |
}
|
7798 |
if(!function_exists('ampforwp_get_retina_image_settings')){
|
7711 |
}
|
7712 |
$comp_url = 'https://cdn.ampproject.org/v0/amp-'.esc_attr($comp).'-'.esc_attr($script_ver).'.js';
|
7713 |
$is_script = false;
|
7714 |
+
$check_comp = 'amp-'.esc_attr($comp);
|
7715 |
if(!in_array($comp, $comp_to_remove_arr) && !in_array($comp, $comp_to_include_arr) ){
|
7716 |
+
$ce_valid_scripts = ampforwp_valid_amp_componet_script();
|
7717 |
+
$is_script = in_array($check_comp, $ce_valid_scripts);
|
7718 |
+
if($comp=='state'){
|
7719 |
+
$is_script = true;
|
7720 |
+
}
|
7721 |
+
if($is_script==false){
|
7722 |
+
$headers = get_headers($comp_url);
|
7723 |
+
if(isset($headers[0])){
|
7724 |
+
$is_script = stripos($headers[0], "200 OK") ? TRUE : FALSE;
|
|
|
|
|
|
|
|
|
|
|
7725 |
}
|
7726 |
}
|
7727 |
+
if($is_script){
|
7728 |
+
$comp_to_include_arr[] = $comp;
|
7729 |
+
$inc_json = json_encode($comp_to_include_arr);
|
7730 |
+
set_transient('ampforwp_amp_included_custom_element',$inc_json, 30 * DAY_IN_SECONDS);
|
7731 |
+
}else{
|
7732 |
+
$comp_to_remove_arr[] = $comp;
|
7733 |
+
$ex_json = json_encode($comp_to_remove_arr);
|
7734 |
+
set_transient('ampforwp_amp_exclude_custom_element',$ex_json, 30 * DAY_IN_SECONDS);
|
7735 |
+
}
|
7736 |
}
|
7737 |
$comp_to_include_arr = apply_filters('ampforwp_amp_custom_element_to_include',$comp_to_include_arr);
|
7738 |
if(in_array($comp, $comp_to_include_arr)){
|
7745 |
}
|
7746 |
}
|
7747 |
|
7748 |
+
$comp_dom = new DOMDocument();
|
7749 |
+
$comp_dom->loadHTML($content);
|
7750 |
+
$xpath = new DOMXPath( $comp_dom );
|
7751 |
+
$elements = $xpath->query("*/script[@custom-element]");
|
7752 |
+
$component_arr = array();
|
7753 |
+
$elements_arr = array();
|
7754 |
+
if (!is_null($elements)) {
|
7755 |
+
foreach ($elements as $element) {
|
7756 |
+
$component_arr[]= $element->getAttribute('custom-element');
|
7757 |
+
$elements_arr[] = $comp_dom->saveHTML($element);
|
7758 |
+
}
|
|
|
|
|
|
|
|
|
7759 |
}
|
7760 |
+
if (!is_null($elements)) {
|
7761 |
+
if(!empty($component_arr)){
|
7762 |
+
$excl_arr = array('amp-bind','amp-access','amp-analytics','amp-access-laterpay','amp-access-poool','amp-dynamic-css-classes','amp-fx-collection','amp-inputmask','amp-lightbox-gallery','amp-inputmask','amp-mustache','amp-subscriptions-google','amp-subscriptions','amp-video-docking','amp-story');
|
|
|
7763 |
$inc_elem_arr = array();
|
7764 |
for($r=0;$r<count($comp_to_remove_arr);$r++){
|
7765 |
$inc_elem_arr[] = 'amp-'.$comp_to_remove_arr[$r];
|
7766 |
}
|
7767 |
+
for($i=0;$i<count($component_arr);$i++){
|
7768 |
+
if(isset($component_arr[$i])){
|
7769 |
+
$component = $component_arr[$i];
|
7770 |
if(!in_array($component,$excl_arr)){
|
7771 |
if(!preg_match("/<\/$component>/", $content) && !$is_script){
|
7772 |
+
$remove_comp = $elements_arr[$i];
|
7773 |
$content = str_replace($remove_comp, '', $content);
|
7774 |
}else if(in_array($component, $inc_elem_arr )){
|
7775 |
for($rc=0;$rc<count($inc_elem_arr);$rc++){
|
7784 |
}
|
7785 |
}
|
7786 |
// REMOVING DUPLICATE SCRIPT.
|
7787 |
+
$count_elem = array_count_values($component_arr)[$component];
|
7788 |
if($count_elem>1){
|
7789 |
+
$content = preg_replace('/<script(\s|\sasync\s)custom-element="'.esc_attr($component).'"(.*?)>(.*?)<\/script>/s','',$content,1,$component_arr[$i]);
|
7790 |
}
|
7791 |
}
|
7792 |
}
|
7793 |
}
|
7794 |
}
|
7795 |
+
//OTHER COMPONENT CHECK
|
7796 |
+
$other_comp_arr = array('amp-mustache'=>'amp-mustache','form'=>'amp-form');
|
7797 |
+
foreach ($other_comp_arr as $key => $value) {
|
7798 |
+
$ocomp = $value;
|
7799 |
+
$celem = 'element';
|
7800 |
+
if($ocomp=='amp-mustache'){
|
7801 |
+
$celem = 'template';
|
7802 |
+
}
|
7803 |
+
if(preg_match('/(type|template)="('.$ocomp.')"/', $content) || preg_match("/<\/$key>/", $content)){
|
7804 |
+
if(!preg_match('/<script(\s|\sasync\s)custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'"(.*?)>(.*?)<\/script>/s', $content)){
|
7805 |
+
$o_comp_url = 'https://cdn.ampproject.org/v0/'.esc_attr($ocomp).'-'.esc_attr($script_ver).'.js';
|
7806 |
+
$script_tag = '<head><script custom-'.esc_attr($celem).'="'.esc_attr($ocomp).'" src="'.esc_url($o_comp_url).'" async></script>';
|
7807 |
+
$content = str_replace('<head>', $script_tag, $content);
|
7808 |
+
}
|
7809 |
+
}
|
7810 |
+
}
|
7811 |
+
// Scripts added from Options panel should have higher priority #4064
|
7812 |
+
if( ampforwp_get_setting('amp-header-text-area-for-html') && ampforwp_get_setting('amp-header-text-area-for-html')!="") {
|
7813 |
+
$allscripts = ampforwp_get_setting('amp-header-text-area-for-html');
|
7814 |
+
preg_match_all('/<script(.*?)custom-element=\"(.*?)\"(.*?)src=\"(.*?)\"(.*?)>(.*?)<\/script>/s', $allscripts, $rep);
|
7815 |
+
if($rep){
|
7816 |
+
if(isset($rep[2]) && isset($rep[4])){
|
7817 |
+
$script_slug = $rep[2];
|
7818 |
+
$script_url = $rep[4];
|
7819 |
+
for($s=0;$s<count($script_slug);$s++){
|
7820 |
+
$slug = $script_slug[$s];
|
7821 |
+
$surl = $script_url[$s];
|
7822 |
+
if(preg_match('/amp/', $slug) && preg_match('/https/', $surl)){
|
7823 |
+
if(preg_match('/<script(.*?)custom-element=\"'.esc_attr($slug).'\"(.*?)src=\"(.*?)\"(.*?)>(.*?)<\/script>/', $content, $conmatch)){
|
7824 |
+
if(isset($conmatch[3]) && $conmatch[3]!=""){
|
7825 |
+
$rep_url = $conmatch[3];
|
7826 |
+
if(preg_match('/https/', $rep_url)){
|
7827 |
+
$content = str_replace($rep_url, $surl, $content);
|
7828 |
+
}
|
7829 |
+
}
|
7830 |
+
}
|
7831 |
+
}
|
7832 |
+
}
|
7833 |
+
}
|
7834 |
+
}
|
7835 |
+
}
|
7836 |
return $content;
|
7837 |
}
|
7838 |
if(!function_exists('ampforwp_get_retina_image_settings')){
|