Version Description
[15th Jan 2017] = * Full details at https://ampforwp.com/debug-errors-shortcodes/ * Mobile was not working with Newspaper theme by Tagdiv [Bugfix] * Debug errors fixed, Code is now much cleaner. * New rewrite rules for homepage pagination. It had some paginated URLs with wrong amphtml tag. * Extra analytics file was loading. Better compatibility with Yoast & Monster analytics. * Properly removes AMP if turned off from Post panel * z-index position improved on Sticky Social bar * Better compatibility with shortcodes. * Divi Standard Layouts Compatibility * Properly Hide AMP posts if excluded. #367 * Mobile redirection was causing loop issues which are now fixed. * Some plugins were loading in core AMP js file, which was causing the issues, which is now fixed. [Better Validation] * onclick was getting added in the links on AMP version. Issue fixed. [Better Validation] * thrive_headline tag was getting added in the Title tag which was causing validation issues. Fixed. [Better Validation] * Some interactive plugins were using place, state, city and imap tags which are now fixed. [Better Validation]
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 0.9.33 |
Comparing to | |
See all releases |
Code changes from version 0.9.32 to 0.9.33
- accelerated-moblie-pages.php +32 -18
- includes/options/redux-framework/framework.php +47 -29
- readme.txt +18 -1
- templates/design-manager.php +1 -9
- templates/design-manager/design-1/elements/related-posts.php +5 -5
- templates/design-manager/design-1/index.php +32 -22
- templates/design-manager/design-1/style.php +1 -1
- templates/design-manager/design-2/elements/related-posts.php +5 -4
- templates/design-manager/design-2/footer.php +2 -0
- templates/design-manager/design-2/index.php +27 -13
- templates/design-manager/design-2/style.php +1 -1
- templates/design-manager/empty-filter.php +1 -0
- templates/features.php +127 -54
@@ -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: 0.9.
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: http://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/5
|
@@ -26,8 +26,7 @@ add_action( 'init', 'ampforwp_add_custom_post_support',11);
|
|
26 |
|
27 |
define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
|
28 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
29 |
-
define('AMPFORWP_VERSION','0.9.
|
30 |
-
|
31 |
/*
|
32 |
* Load Files only in the backend
|
33 |
* As we don't need plugin activation code to run everytime the site loads
|
@@ -37,12 +36,12 @@ if ( is_admin() ) {
|
|
37 |
add_action('init','ampforwp_plugin_notice');
|
38 |
function ampforwp_plugin_notice() {
|
39 |
|
40 |
-
if ( ! defined( 'AMP__FILE__' ) ) {
|
41 |
add_action( 'admin_notices', 'ampforwp_plugin_not_found_notice' );
|
42 |
-
function ampforwp_plugin_not_found_notice() { ?>
|
43 |
|
44 |
<div class="notice notice-error is-dismissible">
|
45 |
-
|
46 |
<?php add_thickbox(); ?>
|
47 |
<p>
|
48 |
<strong><?php _e( 'AMP Installation requires one last step:', 'ampforwp' ); ?></strong> <?php _e( 'AMP by Automattic plugin is not active', 'ampforwp' ); ?>
|
@@ -54,7 +53,7 @@ if ( is_admin() ) {
|
|
54 |
|
55 |
add_action('admin_head','ampforwp_required_plugin_styling');
|
56 |
function ampforwp_required_plugin_styling() { ?>
|
57 |
-
<style>
|
58 |
.plugin-card.plugin-card-amp:before{
|
59 |
content: "Install & Activate this plugin ↓";
|
60 |
font-weight: bold;
|
@@ -71,17 +70,17 @@ if ( is_admin() ) {
|
|
71 |
color: #fff;
|
72 |
}
|
73 |
.plugin-card.plugin-card-amp .column-name a,
|
74 |
-
.plugin-card.plugin-card-amp .column-description a,
|
75 |
.plugin-card.plugin-card-amp .column-description p {
|
76 |
color: #fff;
|
77 |
}
|
78 |
-
.plugin-card-amp .plugin-card-bottom {
|
79 |
background: rgba(229, 255, 80, 0);
|
80 |
}
|
81 |
</style> <?php
|
82 |
}
|
83 |
}
|
84 |
-
|
85 |
}
|
86 |
|
87 |
// Add Settings Button in Plugin backend
|
@@ -144,8 +143,8 @@ function ampforwp_page_template_redirect() {
|
|
144 |
global $redux_builder_amp;
|
145 |
if($redux_builder_amp['amp-mobile-redirection']){
|
146 |
if ( wp_is_mobile() ) {
|
147 |
-
if (
|
148 |
-
return;
|
149 |
} else {
|
150 |
if ( is_home() ) {
|
151 |
wp_redirect( trailingslashit( esc_url( home_url() ) ) .'?'. AMP_QUERY_VAR , 301 );
|
@@ -161,21 +160,36 @@ function ampforwp_page_template_redirect() {
|
|
161 |
}
|
162 |
}
|
163 |
|
164 |
-
add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
|
165 |
|
166 |
-
add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
|
167 |
function ampforwp_page_template_redirect_archive() {
|
168 |
|
169 |
if ( is_archive() || is_404() ) {
|
170 |
-
if(
|
171 |
global $wp;
|
172 |
-
$archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
|
173 |
$archive_current_url = trailingslashit($archive_current_url );
|
174 |
if (is_404() ) {
|
175 |
$archive_current_url = dirname($archive_current_url);
|
176 |
-
}
|
177 |
wp_redirect( esc_url( $archive_current_url ) , 301 );
|
178 |
exit();
|
179 |
}
|
180 |
}
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 0.9.33
|
7 |
Author: Ahmed Kaludi, Mohammed Kaludi
|
8 |
Author URI: http://ampforwp.com/
|
9 |
Donate link: https://www.paypal.me/Kaludi/5
|
26 |
|
27 |
define('AMPFORWP_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
|
28 |
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
|
29 |
+
define('AMPFORWP_VERSION','0.9.33');
|
|
|
30 |
/*
|
31 |
* Load Files only in the backend
|
32 |
* As we don't need plugin activation code to run everytime the site loads
|
36 |
add_action('init','ampforwp_plugin_notice');
|
37 |
function ampforwp_plugin_notice() {
|
38 |
|
39 |
+
if ( ! defined( 'AMP__FILE__' ) ) {
|
40 |
add_action( 'admin_notices', 'ampforwp_plugin_not_found_notice' );
|
41 |
+
function ampforwp_plugin_not_found_notice() { ?>
|
42 |
|
43 |
<div class="notice notice-error is-dismissible">
|
44 |
+
|
45 |
<?php add_thickbox(); ?>
|
46 |
<p>
|
47 |
<strong><?php _e( 'AMP Installation requires one last step:', 'ampforwp' ); ?></strong> <?php _e( 'AMP by Automattic plugin is not active', 'ampforwp' ); ?>
|
53 |
|
54 |
add_action('admin_head','ampforwp_required_plugin_styling');
|
55 |
function ampforwp_required_plugin_styling() { ?>
|
56 |
+
<style>
|
57 |
.plugin-card.plugin-card-amp:before{
|
58 |
content: "Install & Activate this plugin ↓";
|
59 |
font-weight: bold;
|
70 |
color: #fff;
|
71 |
}
|
72 |
.plugin-card.plugin-card-amp .column-name a,
|
73 |
+
.plugin-card.plugin-card-amp .column-description a,
|
74 |
.plugin-card.plugin-card-amp .column-description p {
|
75 |
color: #fff;
|
76 |
}
|
77 |
+
.plugin-card-amp .plugin-card-bottom {
|
78 |
background: rgba(229, 255, 80, 0);
|
79 |
}
|
80 |
</style> <?php
|
81 |
}
|
82 |
}
|
83 |
+
|
84 |
}
|
85 |
|
86 |
// Add Settings Button in Plugin backend
|
143 |
global $redux_builder_amp;
|
144 |
if($redux_builder_amp['amp-mobile-redirection']){
|
145 |
if ( wp_is_mobile() ) {
|
146 |
+
if ( ampforwp_is_amp_endpoint() ) {
|
147 |
+
return;
|
148 |
} else {
|
149 |
if ( is_home() ) {
|
150 |
wp_redirect( trailingslashit( esc_url( home_url() ) ) .'?'. AMP_QUERY_VAR , 301 );
|
160 |
}
|
161 |
}
|
162 |
|
163 |
+
add_action( 'template_redirect', 'ampforwp_page_template_redirect', 30 );
|
164 |
|
165 |
+
add_action( 'template_redirect', 'ampforwp_page_template_redirect_archive', 10 );
|
166 |
function ampforwp_page_template_redirect_archive() {
|
167 |
|
168 |
if ( is_archive() || is_404() ) {
|
169 |
+
if( ampforwp_is_amp_endpoint() ) {
|
170 |
global $wp;
|
171 |
+
$archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
|
172 |
$archive_current_url = trailingslashit($archive_current_url );
|
173 |
if (is_404() ) {
|
174 |
$archive_current_url = dirname($archive_current_url);
|
175 |
+
}
|
176 |
wp_redirect( esc_url( $archive_current_url ) , 301 );
|
177 |
exit();
|
178 |
}
|
179 |
}
|
180 |
+
}
|
181 |
+
|
182 |
+
// Add Custom Rewrite Rule to make sure pagination & redirection is working correctly
|
183 |
+
function ampforwp_add_custom_rewrite_rules() {
|
184 |
+
add_rewrite_rule(
|
185 |
+
'amp/page/([0-9]{1,})/?$',
|
186 |
+
'index.php?amp&paged=$matches[1]',
|
187 |
+
'top'
|
188 |
+
);
|
189 |
+
}
|
190 |
+
add_action( 'init', 'ampforwp_add_custom_rewrite_rules' );
|
191 |
+
|
192 |
+
|
193 |
+
function ampforwp_is_amp_endpoint() {
|
194 |
+
return false !== get_query_var( 'amp', false );
|
195 |
+
}
|
@@ -1143,15 +1143,21 @@
|
|
1143 |
|
1144 |
public function field_default_values( $field ) {
|
1145 |
// Detect what field types are being used
|
1146 |
-
if
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
|
|
|
|
|
|
1151 |
if ( isset ( $field['default'] ) ) {
|
1152 |
$this->options_defaults[ $field['id'] ] = apply_filters( "redux/{$this->args['opt_name']}/field/{$field['type']}/defaults", $field['default'], $field );
|
1153 |
-
|
|
|
1154 |
// Sorter data filter
|
|
|
|
|
1155 |
|
1156 |
if ( isset( $field['data'] ) && ! empty( $field['data'] ) ) {
|
1157 |
if ( ! isset( $field['args'] ) ) {
|
@@ -1195,8 +1201,8 @@
|
|
1195 |
}
|
1196 |
}
|
1197 |
}
|
1198 |
-
}
|
1199 |
-
|
1200 |
/**
|
1201 |
* Get default options into an array suitable for the settings API
|
1202 |
*
|
@@ -1222,19 +1228,20 @@
|
|
1222 |
if ( empty ( $field['id'] ) && empty ( $field['type'] ) ) {
|
1223 |
continue;
|
1224 |
}
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
|
|
1236 |
$this->field_default_values( $field );
|
1237 |
-
}
|
1238 |
}
|
1239 |
}
|
1240 |
}
|
@@ -1271,10 +1278,10 @@
|
|
1271 |
}
|
1272 |
$this->dev_mode_forced = true;
|
1273 |
$this->args['dev_mode'] = true;
|
1274 |
-
if ( isset( $this->args['forced_dev_mode_off'] ) && $this->args['forced_dev_mode_off'] == true ) {
|
1275 |
-
|
1276 |
-
|
1277 |
-
}
|
1278 |
}
|
1279 |
|
1280 |
// Auto create the page_slug appropriately
|
@@ -1739,7 +1746,7 @@
|
|
1739 |
$hint_status = get_user_meta( $current_user->ID, 'ignore_hints' ) ? get_user_meta( $current_user->ID, 'ignore_hints', true ) : 'true';
|
1740 |
|
1741 |
// current page parameters
|
1742 |
-
$curPage = $_GET['page'];
|
1743 |
|
1744 |
$curTab = '0';
|
1745 |
if ( isset ( $_GET['tab'] ) ) {
|
@@ -2950,6 +2957,10 @@
|
|
2950 |
}
|
2951 |
}
|
2952 |
|
|
|
|
|
|
|
|
|
2953 |
// Default 'not_empty 'flag to false.
|
2954 |
$isNotEmpty = false;
|
2955 |
|
@@ -2974,7 +2985,10 @@
|
|
2974 |
if ( ! $isNotEmpty ) {
|
2975 |
|
2976 |
// Empty id and not checking for 'not_empty. Bail out...
|
2977 |
-
|
|
|
|
|
|
|
2978 |
}
|
2979 |
}
|
2980 |
|
@@ -3054,10 +3068,14 @@
|
|
3054 |
}
|
3055 |
}
|
3056 |
} else {
|
3057 |
-
if (
|
3058 |
-
|
|
|
|
|
|
|
|
|
3059 |
} else {
|
3060 |
-
$pofi =
|
3061 |
}
|
3062 |
|
3063 |
$validation = new $validate ( $this, $field, $pofi, $options[ $field['id'] ] );
|
1143 |
|
1144 |
public function field_default_values( $field ) {
|
1145 |
// Detect what field types are being used
|
1146 |
+
if( isset ( $field['type'] ) ) {// Line of code added by Khaled
|
1147 |
+
if ( ! isset ( $this->fields[ $field['type'] ][ $field['id'] ] ) ) {
|
1148 |
+
$this->fields[ $field['type'] ][ $field['id'] ] = 1;
|
1149 |
+
} else {
|
1150 |
+
$this->fields[ $field['type'] ] = array( $field['id'] => 1 );
|
1151 |
+
}
|
1152 |
+
}// Line of code added by Khaled
|
1153 |
+
|
1154 |
if ( isset ( $field['default'] ) ) {
|
1155 |
$this->options_defaults[ $field['id'] ] = apply_filters( "redux/{$this->args['opt_name']}/field/{$field['type']}/defaults", $field['default'], $field );
|
1156 |
+
|
1157 |
+
} elseif ( isset ( $field['type'] ) ) { // Line of code added by Khaled
|
1158 |
// Sorter data filter
|
1159 |
+
if( $field['type'] != "ace_editor" ) {
|
1160 |
+
|
1161 |
|
1162 |
if ( isset( $field['data'] ) && ! empty( $field['data'] ) ) {
|
1163 |
if ( ! isset( $field['args'] ) ) {
|
1201 |
}
|
1202 |
}
|
1203 |
}
|
1204 |
+
} // Line of code added by Khaled
|
1205 |
+
}
|
1206 |
/**
|
1207 |
* Get default options into an array suitable for the settings API
|
1208 |
*
|
1228 |
if ( empty ( $field['id'] ) && empty ( $field['type'] ) ) {
|
1229 |
continue;
|
1230 |
}
|
1231 |
+
if( isset ( $field['type'] ) ) { // Line of code added by Khaled
|
1232 |
+
if ( in_array( $field['type'] , array( 'ace_editor' ) ) && isset ( $field['options'] ) ) {
|
1233 |
+
$this->sections[ $sk ]['fields'][ $k ]['args'] = $field['options'];
|
1234 |
+
unset ( $this->sections[ $sk ]['fields'][ $k ]['options'] );
|
1235 |
+
}
|
1236 |
+
|
1237 |
+
if ( $field['type'] == "section" && isset ( $field['indent'] ) && $field['indent'] == "true" ) {
|
1238 |
+
$field['class'] = isset ( $field['class'] ) ? $field['class'] : '';
|
1239 |
+
$field['class'] .= " redux-section-indent-start";
|
1240 |
+
$this->sections[ $sk ]['fields'][ $k ] = $field;
|
1241 |
+
}
|
1242 |
+
} // Line of code added by Khaled
|
1243 |
$this->field_default_values( $field );
|
1244 |
+
}//end of foreach
|
1245 |
}
|
1246 |
}
|
1247 |
}
|
1278 |
}
|
1279 |
$this->dev_mode_forced = true;
|
1280 |
$this->args['dev_mode'] = true;
|
1281 |
+
// if ( isset( $this->args['forced_dev_mode_off'] ) && $this->args['forced_dev_mode_off'] == true ) {
|
1282 |
+
// $this->dev_mode_forced = false;
|
1283 |
+
// $this->args['dev_mode'] = false;
|
1284 |
+
// }
|
1285 |
}
|
1286 |
|
1287 |
// Auto create the page_slug appropriately
|
1746 |
$hint_status = get_user_meta( $current_user->ID, 'ignore_hints' ) ? get_user_meta( $current_user->ID, 'ignore_hints', true ) : 'true';
|
1747 |
|
1748 |
// current page parameters
|
1749 |
+
$curPage = esc_attr( $_GET['page'] );
|
1750 |
|
1751 |
$curTab = '0';
|
1752 |
if ( isset ( $_GET['tab'] ) ) {
|
2957 |
}
|
2958 |
}
|
2959 |
|
2960 |
+
if ( isset( $this->extensions[ $field['type'] ] ) && method_exists( $this->extensions[ $field['type'] ], '_validate_values' ) ) {
|
2961 |
+
$plugin_options = $this->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections );
|
2962 |
+
}
|
2963 |
+
|
2964 |
// Default 'not_empty 'flag to false.
|
2965 |
$isNotEmpty = false;
|
2966 |
|
2985 |
if ( ! $isNotEmpty ) {
|
2986 |
|
2987 |
// Empty id and not checking for 'not_empty. Bail out...
|
2988 |
+
if (!isset($field['validate_callback'])) {
|
2989 |
+
continue;
|
2990 |
+
}
|
2991 |
+
//continue;
|
2992 |
}
|
2993 |
}
|
2994 |
|
3068 |
}
|
3069 |
}
|
3070 |
} else {
|
3071 |
+
if ( isset( $plugin_options[ $field['id'] ] ) ) {
|
3072 |
+
if ( is_array( $plugin_options[ $field['id'] ] ) ) {
|
3073 |
+
$pofi = $plugin_options[ $field['id'] ];
|
3074 |
+
} else {
|
3075 |
+
$pofi = trim( $plugin_options[ $field['id'] ] );
|
3076 |
+
}
|
3077 |
} else {
|
3078 |
+
$pofi = null;
|
3079 |
}
|
3080 |
|
3081 |
$validation = new $validate ( $this, $field, $pofi, $options[ $field['id'] ] );
|
@@ -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/5
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 0.9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -122,6 +122,23 @@ You can contact me using this url: http://ampforwp.com/contact/
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= 0.9.32 [7th Jan 2017] =
|
126 |
* Full details at https://ampforwp.com/first-wave-of-polishing-in-2017/
|
127 |
* Rel=canonical issue fixed: AMP URL redirect to the normal URL #293 & #332.
|
4 |
Donate link: https://www.paypal.me/Kaludi/5
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 0.9.33
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 0.9.33 [15th Jan 2017] =
|
126 |
+
* Full details at https://ampforwp.com/debug-errors-shortcodes/
|
127 |
+
* Mobile was not working with Newspaper theme by Tagdiv [Bugfix]
|
128 |
+
* Debug errors fixed, Code is now much cleaner.
|
129 |
+
* New rewrite rules for homepage pagination. It had some paginated URLs with wrong amphtml tag.
|
130 |
+
* Extra analytics file was loading. Better compatibility with Yoast & Monster analytics.
|
131 |
+
* Properly removes AMP if turned off from Post panel
|
132 |
+
* z-index position improved on Sticky Social bar
|
133 |
+
* Better compatibility with shortcodes.
|
134 |
+
* Divi Standard Layouts Compatibility
|
135 |
+
* Properly Hide AMP posts if excluded. #367
|
136 |
+
* Mobile redirection was causing loop issues which are now fixed.
|
137 |
+
* Some plugins were loading in core AMP js file, which was causing the issues, which is now fixed. [Better Validation]
|
138 |
+
* onclick was getting added in the links on AMP version. Issue fixed. [Better Validation]
|
139 |
+
* thrive_headline tag was getting added in the Title tag which was causing validation issues. Fixed. [Better Validation]
|
140 |
+
* Some interactive plugins were using place, state, city and imap tags which are now fixed. [Better Validation]
|
141 |
+
|
142 |
= 0.9.32 [7th Jan 2017] =
|
143 |
* Full details at https://ampforwp.com/first-wave-of-polishing-in-2017/
|
144 |
* Rel=canonical issue fixed: AMP URL redirect to the normal URL #293 & #332.
|
@@ -1,8 +1,5 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
if ( is_customize_preview() ) {
|
5 |
-
|
6 |
// Load all the elements in the customizer as we want all the elements in design-manager
|
7 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_title' );
|
8 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_info' );
|
@@ -14,7 +11,6 @@ if ( is_customize_preview() ) {
|
|
14 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_related_posts' );
|
15 |
}
|
16 |
|
17 |
-
|
18 |
$data = get_option( 'ampforwp_design' );
|
19 |
|
20 |
// Adding default Value
|
@@ -206,8 +202,4 @@ function ampforwp_design_element_related_posts( $file, $type, $post ) {
|
|
206 |
}
|
207 |
return $file;
|
208 |
}
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
?>
|
1 |
<?php
|
|
|
|
|
2 |
if ( is_customize_preview() ) {
|
|
|
3 |
// Load all the elements in the customizer as we want all the elements in design-manager
|
4 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_the_title' );
|
5 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_meta_info' );
|
11 |
add_filter( 'ampforwp_design_elements', 'ampforwp_add_element_related_posts' );
|
12 |
}
|
13 |
|
|
|
14 |
$data = get_option( 'ampforwp_design' );
|
15 |
|
16 |
// Adding default Value
|
202 |
}
|
203 |
return $file;
|
204 |
}
|
205 |
+
?>
|
|
|
|
|
|
|
|
@@ -1,9 +1,11 @@
|
|
1 |
<?php
|
2 |
-
$orig_post = $post;
|
3 |
global $post, $redux_builder_amp;
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
|
5 |
$int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
6 |
|
|
|
|
|
|
|
7 |
if($redux_builder_amp['ampforwp-single-select-type-of-related']==2) {
|
8 |
$categories = get_the_category($post->ID);
|
9 |
if ($categories) {
|
@@ -13,7 +15,7 @@
|
|
13 |
'category__in' => $category_ids,
|
14 |
'post__not_in' => array($post->ID),
|
15 |
'posts_per_page'=> $int_number_of_related_posts,
|
16 |
-
'
|
17 |
);
|
18 |
}
|
19 |
} //end of block for categories
|
@@ -27,11 +29,10 @@
|
|
27 |
'tag__in' => $tag_ids,
|
28 |
'post__not_in' => array($post->ID),
|
29 |
'posts_per_page'=> $int_number_of_related_posts,
|
30 |
-
'
|
31 |
);
|
32 |
}
|
33 |
}//end of block for tags
|
34 |
-
|
35 |
$my_query = new wp_query( $args );
|
36 |
if( $my_query->have_posts() ) { ?>
|
37 |
<div class="amp-wp-content relatedpost">
|
@@ -72,6 +73,5 @@
|
|
72 |
</div>
|
73 |
</div> <?php
|
74 |
}
|
75 |
-
$post = $orig_post;
|
76 |
wp_reset_postdata();
|
77 |
?>
|
1 |
<?php
|
|
|
2 |
global $post, $redux_builder_amp;
|
3 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts'];
|
4 |
$int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
5 |
|
6 |
+
// declaring this variable here to prevent debug errors
|
7 |
+
$args = null;
|
8 |
+
|
9 |
if($redux_builder_amp['ampforwp-single-select-type-of-related']==2) {
|
10 |
$categories = get_the_category($post->ID);
|
11 |
if ($categories) {
|
15 |
'category__in' => $category_ids,
|
16 |
'post__not_in' => array($post->ID),
|
17 |
'posts_per_page'=> $int_number_of_related_posts,
|
18 |
+
'ignore_sticky_posts'=>1
|
19 |
);
|
20 |
}
|
21 |
} //end of block for categories
|
29 |
'tag__in' => $tag_ids,
|
30 |
'post__not_in' => array($post->ID),
|
31 |
'posts_per_page'=> $int_number_of_related_posts,
|
32 |
+
'ignore_sticky_posts'=>1
|
33 |
);
|
34 |
}
|
35 |
}//end of block for tags
|
|
|
36 |
$my_query = new wp_query( $args );
|
37 |
if( $my_query->have_posts() ) { ?>
|
38 |
<div class="amp-wp-content relatedpost">
|
73 |
</div>
|
74 |
</div> <?php
|
75 |
}
|
|
|
76 |
wp_reset_postdata();
|
77 |
?>
|
@@ -28,23 +28,37 @@ if ( is_home() || is_front_page() ){
|
|
28 |
|
29 |
<?php do_action('ampforwp_post_before_design_elements') ?>
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
<div class="amp-wp-content-loop">
|
45 |
<div class="amp-wp-meta">
|
46 |
-
|
47 |
-
|
48 |
|
49 |
|
50 |
<?php if ( has_post_thumbnail() ) { ?>
|
@@ -58,19 +72,15 @@ if ( is_home() || is_front_page() ){
|
|
58 |
<amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
|
59 |
</a>
|
60 |
</div>
|
61 |
-
<?php }
|
62 |
-
<?php
|
63 |
if(has_excerpt()){
|
64 |
$content = get_the_excerpt();
|
65 |
}else{
|
66 |
$content = get_the_content();
|
67 |
-
}
|
68 |
-
|
69 |
-
<p><?php echo wp_trim_words( $content , '20'); ?></p>
|
70 |
-
|
71 |
</div>
|
72 |
-
|
73 |
-
</div>
|
74 |
<?php endwhile; ?>
|
75 |
|
76 |
<div class="amp-wp-content pagination-holder">
|
28 |
|
29 |
<?php do_action('ampforwp_post_before_design_elements') ?>
|
30 |
|
31 |
+
<?php
|
32 |
+
if ( get_query_var( 'paged' ) ) {
|
33 |
+
$paged = get_query_var('paged');
|
34 |
+
} elseif ( get_query_var( 'page' ) ) {
|
35 |
+
$paged = get_query_var('page');
|
36 |
+
} else {
|
37 |
+
$paged = 1;
|
38 |
+
}
|
39 |
+
|
40 |
+
$exclude_ids = get_option('ampforwp_exclude_post');
|
41 |
+
|
42 |
+
$q = new WP_Query( array(
|
43 |
+
'post_type' => 'post',
|
44 |
+
'orderby' => 'date',
|
45 |
+
'offset' => esc_attr($fn_offset),
|
46 |
+
'ignore_sticky_posts' => 1,
|
47 |
+
'paged' => esc_attr($paged),
|
48 |
+
'post__not_in' => $exclude_ids
|
49 |
+
) ); ?>
|
50 |
+
<?php if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); ?>
|
51 |
+
<div class="amp-wp-content amp-wp-article-header amp-loop-list">
|
52 |
+
|
53 |
+
<h1 class="amp-wp-title">
|
54 |
+
<?php $ampforwp_post_url = get_permalink(); ?>
|
55 |
+
<a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>"><?php the_title() ?></a>
|
56 |
+
</h1>
|
57 |
|
58 |
<div class="amp-wp-content-loop">
|
59 |
<div class="amp-wp-meta">
|
60 |
+
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author', 'meta-time' ) ) ); ?>
|
61 |
+
</div>
|
62 |
|
63 |
|
64 |
<?php if ( has_post_thumbnail() ) { ?>
|
72 |
<amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
|
73 |
</a>
|
74 |
</div>
|
75 |
+
<?php }
|
|
|
76 |
if(has_excerpt()){
|
77 |
$content = get_the_excerpt();
|
78 |
}else{
|
79 |
$content = get_the_content();
|
80 |
+
} ?>
|
81 |
+
<p><?php echo wp_trim_words( $content , '20'); ?></p>
|
|
|
|
|
82 |
</div>
|
83 |
+
</div>
|
|
|
84 |
<?php endwhile; ?>
|
85 |
|
86 |
<div class="amp-wp-content pagination-holder">
|
@@ -754,7 +754,7 @@ amp-carousel > amp-img > img {
|
|
754 |
padding: 7px 0px 0px 0px;
|
755 |
position: fixed;
|
756 |
margin: 0;
|
757 |
-
z-index:
|
758 |
text-align: center;
|
759 |
}
|
760 |
.whatsapp-share-icon {
|
754 |
padding: 7px 0px 0px 0px;
|
755 |
position: fixed;
|
756 |
margin: 0;
|
757 |
+
z-index: 10;
|
758 |
text-align: center;
|
759 |
}
|
760 |
.whatsapp-share-icon {
|
@@ -1,8 +1,10 @@
|
|
1 |
<?php
|
2 |
-
$orig_post = $post;
|
3 |
global $post, $redux_builder_amp;
|
4 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
5 |
|
|
|
|
|
|
|
6 |
if($redux_builder_amp['ampforwp-single-select-type-of-related']==2){
|
7 |
$categories = get_the_category($post->ID);
|
8 |
if ($categories) {
|
@@ -12,7 +14,7 @@
|
|
12 |
'category__in' => $category_ids,
|
13 |
'post__not_in' => array($post->ID),
|
14 |
'posts_per_page'=> $int_number_of_related_posts,
|
15 |
-
'
|
16 |
);
|
17 |
}
|
18 |
} //end of block for categories
|
@@ -26,7 +28,7 @@
|
|
26 |
'tag__in' => $tag_ids,
|
27 |
'post__not_in' => array($post->ID),
|
28 |
'posts_per_page'=> $int_number_of_related_posts,
|
29 |
-
'
|
30 |
);
|
31 |
}
|
32 |
}//end of block for tags
|
@@ -73,7 +75,6 @@
|
|
73 |
</ol>
|
74 |
</div>
|
75 |
</div> <?php
|
76 |
-
$post = $orig_post;
|
77 |
wp_reset_postdata();
|
78 |
//related posts code ends here
|
79 |
?>
|
1 |
<?php
|
|
|
2 |
global $post, $redux_builder_amp;
|
3 |
$string_number_of_related_posts = $redux_builder_amp['ampforwp-number-of-related-posts']; $int_number_of_related_posts = round(abs(floatval($string_number_of_related_posts)));
|
4 |
|
5 |
+
// declaring this variable here to prevent debug errors
|
6 |
+
$args = null;
|
7 |
+
|
8 |
if($redux_builder_amp['ampforwp-single-select-type-of-related']==2){
|
9 |
$categories = get_the_category($post->ID);
|
10 |
if ($categories) {
|
14 |
'category__in' => $category_ids,
|
15 |
'post__not_in' => array($post->ID),
|
16 |
'posts_per_page'=> $int_number_of_related_posts,
|
17 |
+
'ignore_sticky_posts'=>1
|
18 |
);
|
19 |
}
|
20 |
} //end of block for categories
|
28 |
'tag__in' => $tag_ids,
|
29 |
'post__not_in' => array($post->ID),
|
30 |
'posts_per_page'=> $int_number_of_related_posts,
|
31 |
+
'ignore_sticky_posts'=>1,
|
32 |
);
|
33 |
}
|
34 |
}//end of block for tags
|
75 |
</ol>
|
76 |
</div>
|
77 |
</div> <?php
|
|
|
78 |
wp_reset_postdata();
|
79 |
//related posts code ends here
|
80 |
?>
|
@@ -6,9 +6,11 @@
|
|
6 |
$ampforwp_backto_nonamp = home_url();
|
7 |
}
|
8 |
if ( is_single() ){
|
|
|
9 |
$ampforwp_backto_nonamp = get_permalink( $post->ID );
|
10 |
}
|
11 |
if ( is_page() ){
|
|
|
12 |
$ampforwp_backto_nonamp = get_permalink( $post->ID );
|
13 |
}
|
14 |
if( is_archive() ) {
|
6 |
$ampforwp_backto_nonamp = home_url();
|
7 |
}
|
8 |
if ( is_single() ){
|
9 |
+
global $post;
|
10 |
$ampforwp_backto_nonamp = get_permalink( $post->ID );
|
11 |
}
|
12 |
if ( is_page() ){
|
13 |
+
global $post;
|
14 |
$ampforwp_backto_nonamp = get_permalink( $post->ID );
|
15 |
}
|
16 |
if( is_archive() ) {
|
@@ -27,18 +27,33 @@
|
|
27 |
|
28 |
<main>
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
<?php if ( is_archive() ) {
|
32 |
the_archive_title( '<h3 class="page-title">', '</h3>' );
|
33 |
the_archive_description( '<div class="taxonomy-description">', '</div>' );
|
34 |
} ?>
|
35 |
|
36 |
-
<?php if ( have_posts() ) :
|
37 |
-
|
38 |
-
|
39 |
-
$ampforwp_amp_post_url = trailingslashit( get_permalink() ) . AMP_QUERY_VAR ;
|
40 |
-
|
41 |
-
?>
|
42 |
|
43 |
<div class="amp-wp-content amp-loop-list">
|
44 |
<?php if ( has_post_thumbnail() ) { ?>
|
@@ -55,12 +70,11 @@
|
|
55 |
<h2 class="amp-wp-title"> <a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"> <?php the_title(); ?></a></h2>
|
56 |
|
57 |
<?php
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
}
|
64 |
?>
|
65 |
<p><?php echo wp_trim_words( $content , '15' ); ?></p>
|
66 |
|
@@ -70,7 +84,6 @@
|
|
70 |
|
71 |
<?php endwhile; ?>
|
72 |
|
73 |
-
|
74 |
<div class="amp-wp-content pagination-holder">
|
75 |
|
76 |
<div id="pagination">
|
@@ -82,6 +95,7 @@
|
|
82 |
</div>
|
83 |
|
84 |
<?php endif; ?>
|
|
|
85 |
</main>
|
86 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
87 |
<?php do_action( 'amp_post_template_footer', $this ); ?>
|
27 |
|
28 |
<main>
|
29 |
|
30 |
+
<?php
|
31 |
+
if ( get_query_var( 'paged' ) ) {
|
32 |
+
$paged = get_query_var('paged');
|
33 |
+
} elseif ( get_query_var( 'page' ) ) {
|
34 |
+
$paged = get_query_var('page');
|
35 |
+
} else {
|
36 |
+
$paged = 1;
|
37 |
+
}
|
38 |
+
|
39 |
+
$exclude_ids = get_option('ampforwp_exclude_post');
|
40 |
+
|
41 |
+
$q = new WP_Query( array(
|
42 |
+
'post_type' => 'post',
|
43 |
+
'orderby' => 'date',
|
44 |
+
'offset' => esc_attr($fn_offset),
|
45 |
+
'ignore_sticky_posts' => 1,
|
46 |
+
'paged' => esc_attr($paged),
|
47 |
+
'post__not_in' => $exclude_ids
|
48 |
+
) ); ?>
|
49 |
|
50 |
<?php if ( is_archive() ) {
|
51 |
the_archive_title( '<h3 class="page-title">', '</h3>' );
|
52 |
the_archive_description( '<div class="taxonomy-description">', '</div>' );
|
53 |
} ?>
|
54 |
|
55 |
+
<?php if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
|
56 |
+
$ampforwp_amp_post_url = trailingslashit( get_permalink() ) . AMP_QUERY_VAR ; ?>
|
|
|
|
|
|
|
|
|
57 |
|
58 |
<div class="amp-wp-content amp-loop-list">
|
59 |
<?php if ( has_post_thumbnail() ) { ?>
|
70 |
<h2 class="amp-wp-title"> <a href="<?php echo esc_url( $ampforwp_amp_post_url ); ?>"> <?php the_title(); ?></a></h2>
|
71 |
|
72 |
<?php
|
73 |
+
if(has_excerpt()){
|
74 |
+
$content = get_the_excerpt();
|
75 |
+
}else{
|
76 |
+
$content = get_the_content();
|
77 |
+
}
|
|
|
78 |
?>
|
79 |
<p><?php echo wp_trim_words( $content , '15' ); ?></p>
|
80 |
|
84 |
|
85 |
<?php endwhile; ?>
|
86 |
|
|
|
87 |
<div class="amp-wp-content pagination-holder">
|
88 |
|
89 |
<div id="pagination">
|
95 |
</div>
|
96 |
|
97 |
<?php endif; ?>
|
98 |
+
<?php wp_reset_postdata(); ?>
|
99 |
</main>
|
100 |
<?php $this->load_parts( array( 'footer' ) ); ?>
|
101 |
<?php do_action( 'amp_post_template_footer', $this ); ?>
|
@@ -202,7 +202,7 @@ amp-sidebar {
|
|
202 |
padding: 7px 0px 0px 0px;
|
203 |
position: fixed;
|
204 |
margin: 0;
|
205 |
-
z-index:
|
206 |
text-align: center;
|
207 |
}
|
208 |
.whatsapp-share-icon {
|
202 |
padding: 7px 0px 0px 0px;
|
203 |
position: fixed;
|
204 |
margin: 0;
|
205 |
+
z-index: 10;
|
206 |
text-align: center;
|
207 |
}
|
208 |
.whatsapp-share-icon {
|
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php //This file kept empty deliberately ?>
|
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
/* This file will contain all the Extra FEATURES.
|
3 |
-
|
4 |
0.9. AMP Design Manager Files
|
5 |
1. Add Home REL canonical
|
6 |
2. Custom Design
|
@@ -11,6 +10,7 @@
|
|
11 |
4.5 Added hook to add more layout.
|
12 |
5. Customize with Width of the site
|
13 |
6. Add required Javascripts for extra AMP features
|
|
|
14 |
7. Footer for AMP Pages
|
15 |
8. Add Main tag as a Wrapper ( removed in 0.8.9 )
|
16 |
9. Advertisement code
|
@@ -34,6 +34,9 @@
|
|
34 |
24. Seperate Sticky Single Social Icons
|
35 |
25. Yoast meta Support
|
36 |
26. Extending Title Tagand De-Hooking the Standard one from AMP
|
|
|
|
|
|
|
37 |
*/
|
38 |
// Adding AMP-related things to the main theme
|
39 |
global $redux_builder_amp;
|
@@ -42,10 +45,12 @@
|
|
42 |
// 0.9. AMP Design Manager Files
|
43 |
require 'design-manager.php';
|
44 |
require 'customizer/customizer.php';
|
45 |
-
|
46 |
// Custom AMP Content
|
47 |
require 'custom-amp-content.php';
|
48 |
|
|
|
|
|
|
|
49 |
// 1. Add Home REL canonical
|
50 |
// Add AMP rel-canonical for home and archive pages
|
51 |
|
@@ -57,9 +62,9 @@
|
|
57 |
function ampforwp_add_endpoint_actions() {
|
58 |
// if ( is_home() ) {
|
59 |
|
60 |
-
$
|
61 |
|
62 |
-
if ( $
|
63 |
amp_prepare_render();
|
64 |
} else {
|
65 |
add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
|
@@ -146,6 +151,14 @@
|
|
146 |
return $file;
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
// 4. Custom Header files
|
150 |
add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 );
|
151 |
function ampforwp_custom_header( $file, $type, $post ) {
|
@@ -159,7 +172,7 @@
|
|
159 |
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 );
|
160 |
function ampforwp_set_custom_meta_author( $file, $type, $post ) {
|
161 |
if ( 'meta-author' === $type ) {
|
162 |
-
$file = AMPFORWP_PLUGIN_DIR . '/templates/
|
163 |
}
|
164 |
return $file;
|
165 |
}
|
@@ -167,7 +180,7 @@
|
|
167 |
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 );
|
168 |
function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) {
|
169 |
if ( 'meta-taxonomy' === $type ) {
|
170 |
-
$file = AMPFORWP_PLUGIN_DIR . '
|
171 |
}
|
172 |
return $file;
|
173 |
}
|
@@ -186,15 +199,6 @@
|
|
186 |
add_action('amp_post_template_head','ampforwp_register_additional_scripts', 20);
|
187 |
function ampforwp_register_additional_scripts() {
|
188 |
global $redux_builder_amp;
|
189 |
-
|
190 |
-
if ( class_exists('WPSEO_Options') && class_exists('YoastSEO_AMP') ) {
|
191 |
-
$yoast_glue_seo = get_option('wpseo_amp');
|
192 |
-
}
|
193 |
-
if ( empty( $yoast_glue_seo['analytics-extra'] ) ) { ?>
|
194 |
-
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
|
195 |
-
<?php
|
196 |
-
}
|
197 |
-
|
198 |
if( is_page() ) { ?>
|
199 |
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
|
200 |
<?php } ?>
|
@@ -205,15 +209,22 @@ function ampforwp_register_additional_scripts() {
|
|
205 |
<?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
|
206 |
<?php if( is_singular() ) { ?>
|
207 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
208 |
-
<?php }
|
209 |
} ?>
|
210 |
<?php if($redux_builder_amp['amp-frontpage-select-option'] == 1) { ?>
|
211 |
<?php if( is_home() ) { ?>
|
212 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
213 |
<?php }
|
214 |
} ?>
|
215 |
-
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script><?php
|
216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
// 7. Footer for AMP Pages
|
219 |
add_filter( 'amp_post_template_file', 'ampforwp_custom_footer', 10, 3 );
|
@@ -411,7 +422,7 @@ function ampforwp_register_additional_scripts() {
|
|
411 |
add_action('amp_post_template_footer','ampforwp_analytics',11);
|
412 |
function ampforwp_analytics() {
|
413 |
|
414 |
-
|
415 |
global $redux_builder_amp;
|
416 |
if ( $redux_builder_amp['amp-analytics-select-option']=='1' ){ ?>
|
417 |
<amp-analytics type="googleanalytics" id="analytics1">
|
@@ -432,7 +443,7 @@ function ampforwp_register_additional_scripts() {
|
|
432 |
<?php
|
433 |
}//code ends for supporting Google Analytics
|
434 |
|
435 |
-
|
436 |
if ( $redux_builder_amp['amp-analytics-select-option']=='2' ) { ?>
|
437 |
<amp-analytics type="segment">
|
438 |
<script>
|
@@ -447,7 +458,7 @@ function ampforwp_register_additional_scripts() {
|
|
447 |
<?php
|
448 |
}
|
449 |
|
450 |
-
|
451 |
if( $redux_builder_amp['amp-analytics-select-option']=='3' ) { ?>
|
452 |
<amp-pixel src="<?php global $redux_builder_amp; echo $redux_builder_amp['pa-feild']; ?>"></amp-pixel>
|
453 |
<?php }
|
@@ -461,12 +472,12 @@ function ampforwp_register_additional_scripts() {
|
|
461 |
function ampforwp_the_content_filter( $content ) {
|
462 |
$content = preg_replace('/property=[^>]*/', '', $content);
|
463 |
$content = preg_replace('/vocab=[^>]*/', '', $content);
|
464 |
-
|
465 |
$content = preg_replace('/value=[^>]*/', '', $content);
|
466 |
-
|
467 |
$content = preg_replace('/noshade=[^>]*/', '', $content);
|
468 |
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
|
469 |
-
|
470 |
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
|
471 |
$content = preg_replace('/security=[^>]*/', '', $content);
|
472 |
$content = preg_replace('/deposit=[^>]*/', '', $content);
|
@@ -489,6 +500,9 @@ function ampforwp_register_additional_scripts() {
|
|
489 |
*/
|
490 |
$content = preg_replace('/(<[^>]+) rel=".*?"/', '$1', $content);
|
491 |
$content = preg_replace('/(<[^>]+) ref=".*?"/', '$1', $content);
|
|
|
|
|
|
|
492 |
$content = preg_replace('/(<[^>]+) date/', '$1', $content);
|
493 |
$content = preg_replace('/(<[^>]+) spellcheck/', '$1', $content);
|
494 |
|
@@ -496,15 +510,15 @@ function ampforwp_register_additional_scripts() {
|
|
496 |
//issue #268
|
497 |
$content = str_replace(' rel="nofollow"',"",$content);
|
498 |
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
|
499 |
-
/// simpy add more elements to simply strip tag but not the content as so
|
500 |
-
/// Array ("p","font");
|
501 |
-
$tags_to_strip = Array("thrive_headline" );
|
502 |
-
foreach ($tags_to_strip as $tag)
|
503 |
-
{
|
504 |
-
|
505 |
-
}
|
506 |
|
507 |
-
// $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
|
508 |
return $content;
|
509 |
}
|
510 |
|
@@ -634,8 +648,35 @@ add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' );
|
|
634 |
*/
|
635 |
function ampforwp_title_callback( $post ) {
|
636 |
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
|
637 |
-
$ampforwp_stored_meta = get_post_meta( $post->ID );
|
638 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
<p>
|
640 |
<div class="prfx-row-content">
|
641 |
<label for="meta-radio-one">
|
@@ -692,7 +733,7 @@ if ( ! function_exists('ampforwp_disable_new_relic_scripts') ) {
|
|
692 |
if ( ! function_exists( 'newrelic_disable_autorum' ) ) {
|
693 |
return $data;
|
694 |
}
|
695 |
-
if ( function_exists( '
|
696 |
newrelic_disable_autorum();
|
697 |
}
|
698 |
return $data;
|
@@ -700,7 +741,7 @@ if ( ! function_exists('ampforwp_disable_new_relic_scripts') ) {
|
|
700 |
}
|
701 |
|
702 |
// 16. Remove Unwanted Scripts
|
703 |
-
if ( function_exists( '
|
704 |
add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 );
|
705 |
}
|
706 |
function ampforwp_remove_unwanted_scripts() {
|
@@ -708,7 +749,7 @@ function ampforwp_remove_unwanted_scripts() {
|
|
708 |
}
|
709 |
// Remove Print Scripts and styles
|
710 |
function ampforwp_remove_print_scripts() {
|
711 |
-
if (
|
712 |
|
713 |
function ampforwp_remove_all_scripts() {
|
714 |
global $wp_scripts;
|
@@ -779,8 +820,8 @@ function ampforwp_remove_schema_data() {
|
|
779 |
// 22. Removing author links from comments Issue #180
|
780 |
if( ! function_exists( "disable_comment_author_links" ) ) {
|
781 |
function ampforwp_disable_comment_author_links( $author_link ){
|
782 |
-
$
|
783 |
-
if ( $
|
784 |
return strip_tags( $author_link );
|
785 |
} else {
|
786 |
return $author_link;
|
@@ -870,24 +911,21 @@ add_action( 'amp_post_template_head', 'ampforwp_custom_yoast_meta' );
|
|
870 |
|
871 |
|
872 |
//26. Extending Title Tagand De-Hooking the Standard one from AMP
|
873 |
-
add_action('amp_post_template_include_single','
|
874 |
-
function
|
875 |
remove_action('amp_post_template_head','amp_post_template_add_title');
|
876 |
-
add_action('amp_post_template_head','
|
877 |
-
|
878 |
-
function ampforwp_custom_title_tag(){
|
879 |
-
?>
|
880 |
-
<title>
|
881 |
-
<?php
|
882 |
-
global $redux_builder_amp;
|
883 |
|
|
|
|
|
|
|
|
|
884 |
// title for a single post and single page
|
885 |
if( is_single() || is_page() ){
|
886 |
global $post;
|
887 |
$title = $post->post_title;
|
888 |
echo $title . ' | ' . get_option( 'blogname' ) ;
|
889 |
}
|
890 |
-
|
891 |
$site_title = get_bloginfo('name') . ' | ' . get_option( 'blogdescription' ) ;
|
892 |
if ( is_home() ) {
|
893 |
if ( $redux_builder_amp['amp-frontpage-select-option']== 1) {
|
@@ -896,20 +934,55 @@ function remove_this(){
|
|
896 |
}
|
897 |
echo $site_title ;
|
898 |
} ?>
|
899 |
-
|
900 |
<?php
|
901 |
}
|
902 |
}
|
903 |
-
//End of 26
|
904 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
905 |
|
906 |
-
// 27.
|
907 |
-
add_filter( 'amp_skip_post', 'ampforwp_skip_amp_post', 10, 3 );
|
908 |
|
|
|
|
|
|
|
909 |
function ampforwp_skip_amp_post( $skip, $post_id, $post ) {
|
910 |
-
$ampforwp_amp_post_on_off_meta = get_post_meta( $post->ID );
|
911 |
-
if( $ampforwp_amp_post_on_off_meta
|
912 |
$skip = true;
|
913 |
}
|
914 |
return $skip;
|
915 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/* This file will contain all the Extra FEATURES.
|
|
|
3 |
0.9. AMP Design Manager Files
|
4 |
1. Add Home REL canonical
|
5 |
2. Custom Design
|
10 |
4.5 Added hook to add more layout.
|
11 |
5. Customize with Width of the site
|
12 |
6. Add required Javascripts for extra AMP features
|
13 |
+
6.1 Adding Analytics Scripts
|
14 |
7. Footer for AMP Pages
|
15 |
8. Add Main tag as a Wrapper ( removed in 0.8.9 )
|
16 |
9. Advertisement code
|
34 |
24. Seperate Sticky Single Social Icons
|
35 |
25. Yoast meta Support
|
36 |
26. Extending Title Tagand De-Hooking the Standard one from AMP
|
37 |
+
27. Fixing the defer tag issue [Finally!]
|
38 |
+
28. Properly removes AMP if turned off from Post panel
|
39 |
+
29. Remove analytics code if Already added by Glue or Yoast SEO
|
40 |
*/
|
41 |
// Adding AMP-related things to the main theme
|
42 |
global $redux_builder_amp;
|
45 |
// 0.9. AMP Design Manager Files
|
46 |
require 'design-manager.php';
|
47 |
require 'customizer/customizer.php';
|
|
|
48 |
// Custom AMP Content
|
49 |
require 'custom-amp-content.php';
|
50 |
|
51 |
+
//0.
|
52 |
+
|
53 |
+
|
54 |
// 1. Add Home REL canonical
|
55 |
// Add AMP rel-canonical for home and archive pages
|
56 |
|
62 |
function ampforwp_add_endpoint_actions() {
|
63 |
// if ( is_home() ) {
|
64 |
|
65 |
+
$ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
|
66 |
|
67 |
+
if ( $ampforwp_is_amp_endpoint ) {
|
68 |
amp_prepare_render();
|
69 |
} else {
|
70 |
add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical' );
|
151 |
return $file;
|
152 |
}
|
153 |
|
154 |
+
//3.5
|
155 |
+
add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 );
|
156 |
+
function ampforwp_empty_filter( $file, $type, $post ) {
|
157 |
+
if ( 'empty-filter' === $type ) {
|
158 |
+
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
|
159 |
+
}
|
160 |
+
return $file;
|
161 |
+
}
|
162 |
// 4. Custom Header files
|
163 |
add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 );
|
164 |
function ampforwp_custom_header( $file, $type, $post ) {
|
172 |
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 );
|
173 |
function ampforwp_set_custom_meta_author( $file, $type, $post ) {
|
174 |
if ( 'meta-author' === $type ) {
|
175 |
+
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
|
176 |
}
|
177 |
return $file;
|
178 |
}
|
180 |
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 );
|
181 |
function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) {
|
182 |
if ( 'meta-taxonomy' === $type ) {
|
183 |
+
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php';
|
184 |
}
|
185 |
return $file;
|
186 |
}
|
199 |
add_action('amp_post_template_head','ampforwp_register_additional_scripts', 20);
|
200 |
function ampforwp_register_additional_scripts() {
|
201 |
global $redux_builder_amp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
if( is_page() ) { ?>
|
203 |
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
|
204 |
<?php } ?>
|
209 |
<?php if( $redux_builder_amp['enable-single-social-icons'] == true || AMPFORWP_DM_SOCIAL_CHECK === 'true' ) { ?>
|
210 |
<?php if( is_singular() ) { ?>
|
211 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
212 |
+
<?php }
|
213 |
} ?>
|
214 |
<?php if($redux_builder_amp['amp-frontpage-select-option'] == 1) { ?>
|
215 |
<?php if( is_home() ) { ?>
|
216 |
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
|
217 |
<?php }
|
218 |
} ?>
|
219 |
+
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script><?php
|
220 |
}
|
221 |
+
// 6.1 Adding Analytics Scripts
|
222 |
+
add_action('amp_post_template_head','ampforwp_register_analytics_script', 20);
|
223 |
+
function ampforwp_register_analytics_script(){ ?>
|
224 |
+
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
|
225 |
+
<?php
|
226 |
+
|
227 |
+
}
|
228 |
|
229 |
// 7. Footer for AMP Pages
|
230 |
add_filter( 'amp_post_template_file', 'ampforwp_custom_footer', 10, 3 );
|
422 |
add_action('amp_post_template_footer','ampforwp_analytics',11);
|
423 |
function ampforwp_analytics() {
|
424 |
|
425 |
+
// 10.1 Analytics Support added for Google Analytics
|
426 |
global $redux_builder_amp;
|
427 |
if ( $redux_builder_amp['amp-analytics-select-option']=='1' ){ ?>
|
428 |
<amp-analytics type="googleanalytics" id="analytics1">
|
443 |
<?php
|
444 |
}//code ends for supporting Google Analytics
|
445 |
|
446 |
+
// 10.2 Analytics Support added for segment.com
|
447 |
if ( $redux_builder_amp['amp-analytics-select-option']=='2' ) { ?>
|
448 |
<amp-analytics type="segment">
|
449 |
<script>
|
458 |
<?php
|
459 |
}
|
460 |
|
461 |
+
// 10.3 Analytics Support added for Piwik
|
462 |
if( $redux_builder_amp['amp-analytics-select-option']=='3' ) { ?>
|
463 |
<amp-pixel src="<?php global $redux_builder_amp; echo $redux_builder_amp['pa-feild']; ?>"></amp-pixel>
|
464 |
<?php }
|
472 |
function ampforwp_the_content_filter( $content ) {
|
473 |
$content = preg_replace('/property=[^>]*/', '', $content);
|
474 |
$content = preg_replace('/vocab=[^>]*/', '', $content);
|
475 |
+
// $content = preg_replace('/type=[^>]*/', '', $content);
|
476 |
$content = preg_replace('/value=[^>]*/', '', $content);
|
477 |
+
// $content = preg_replace('/date=[^>]*/', '', $content);
|
478 |
$content = preg_replace('/noshade=[^>]*/', '', $content);
|
479 |
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
|
480 |
+
// $content = preg_replace('/time=[^>]*/', '', $content);
|
481 |
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
|
482 |
$content = preg_replace('/security=[^>]*/', '', $content);
|
483 |
$content = preg_replace('/deposit=[^>]*/', '', $content);
|
500 |
*/
|
501 |
$content = preg_replace('/(<[^>]+) rel=".*?"/', '$1', $content);
|
502 |
$content = preg_replace('/(<[^>]+) ref=".*?"/', '$1', $content);
|
503 |
+
$content = preg_replace('/(<[^>]+) date=".*?"/', '$1', $content);
|
504 |
+
$content = preg_replace('/(<[^>]+) time=".*?"/', '$1', $content);
|
505 |
+
$content = preg_replace('/(<[^>]+) imap=".*?"/', '$1', $content);
|
506 |
$content = preg_replace('/(<[^>]+) date/', '$1', $content);
|
507 |
$content = preg_replace('/(<[^>]+) spellcheck/', '$1', $content);
|
508 |
|
510 |
//issue #268
|
511 |
$content = str_replace(' rel="nofollow"',"",$content);
|
512 |
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
|
513 |
+
/// simpy add more elements to simply strip tag but not the content as so
|
514 |
+
/// Array ("p","font");
|
515 |
+
$tags_to_strip = Array("thrive_headline","type","date","time","place","state","city" );
|
516 |
+
foreach ($tags_to_strip as $tag)
|
517 |
+
{
|
518 |
+
$content = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/",'',$content);
|
519 |
+
}
|
520 |
|
521 |
+
// $content = preg_replace('/<img*/', '<amp-img', $content); // Fallback for plugins
|
522 |
return $content;
|
523 |
}
|
524 |
|
648 |
*/
|
649 |
function ampforwp_title_callback( $post ) {
|
650 |
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
|
651 |
+
$ampforwp_stored_meta = get_post_meta( $post->ID );
|
652 |
+
|
653 |
+
// TODO: Move the data storage code, to Save meta Box area as it is not a good idea to update an option everytime, try adding this code inside ampforwp_title_meta_save()
|
654 |
+
// This code needs a rewrite.
|
655 |
+
if ( $ampforwp_stored_meta['ampforwp-amp-on-off'][0] == 'hide-amp') {
|
656 |
+
$exclude_post_value = get_option('ampforwp_exclude_post');
|
657 |
+
if ( $exclude_post_value == null ) {
|
658 |
+
$exclude_post_value[] = 0;
|
659 |
+
}
|
660 |
+
if ( $exclude_post_value ) {
|
661 |
+
if ( ! in_array( $post->ID, $exclude_post_value ) ) {
|
662 |
+
$exclude_post_value[] = $post->ID;
|
663 |
+
update_option('ampforwp_exclude_post', $exclude_post_value);
|
664 |
+
}
|
665 |
+
}
|
666 |
+
} else {
|
667 |
+
$exclude_post_value = get_option('ampforwp_exclude_post');
|
668 |
+
if ( $exclude_post_value == null ) {
|
669 |
+
$exclude_post_value[] = 0;
|
670 |
+
}
|
671 |
+
if ( $exclude_post_value ) {
|
672 |
+
if ( in_array( $post->ID, $exclude_post_value ) ) {
|
673 |
+
$exclude_ids = array_diff($exclude_post_value, array($post->ID) );
|
674 |
+
update_option('ampforwp_exclude_post', $exclude_ids);
|
675 |
+
}
|
676 |
+
}
|
677 |
+
|
678 |
+
}
|
679 |
+
?>
|
680 |
<p>
|
681 |
<div class="prfx-row-content">
|
682 |
<label for="meta-radio-one">
|
733 |
if ( ! function_exists( 'newrelic_disable_autorum' ) ) {
|
734 |
return $data;
|
735 |
}
|
736 |
+
if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) {
|
737 |
newrelic_disable_autorum();
|
738 |
}
|
739 |
return $data;
|
741 |
}
|
742 |
|
743 |
// 16. Remove Unwanted Scripts
|
744 |
+
if ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) {
|
745 |
add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 );
|
746 |
}
|
747 |
function ampforwp_remove_unwanted_scripts() {
|
749 |
}
|
750 |
// Remove Print Scripts and styles
|
751 |
function ampforwp_remove_print_scripts() {
|
752 |
+
if ( ampforwp_is_amp_endpoint() ) {
|
753 |
|
754 |
function ampforwp_remove_all_scripts() {
|
755 |
global $wp_scripts;
|
820 |
// 22. Removing author links from comments Issue #180
|
821 |
if( ! function_exists( "disable_comment_author_links" ) ) {
|
822 |
function ampforwp_disable_comment_author_links( $author_link ){
|
823 |
+
$ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
|
824 |
+
if ( $ampforwp_is_amp_endpoint ) {
|
825 |
return strip_tags( $author_link );
|
826 |
} else {
|
827 |
return $author_link;
|
911 |
|
912 |
|
913 |
//26. Extending Title Tagand De-Hooking the Standard one from AMP
|
914 |
+
add_action('amp_post_template_include_single','ampforwp_remove_title_tags');
|
915 |
+
function ampforwp_remove_title_tags(){
|
916 |
remove_action('amp_post_template_head','amp_post_template_add_title');
|
917 |
+
add_action('amp_post_template_head','ampforwp_add_custom_title_tag');
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
|
919 |
+
function ampforwp_add_custom_title_tag(){
|
920 |
+
global $redux_builder_amp; ?>
|
921 |
+
<title>
|
922 |
+
<?php
|
923 |
// title for a single post and single page
|
924 |
if( is_single() || is_page() ){
|
925 |
global $post;
|
926 |
$title = $post->post_title;
|
927 |
echo $title . ' | ' . get_option( 'blogname' ) ;
|
928 |
}
|
|
|
929 |
$site_title = get_bloginfo('name') . ' | ' . get_option( 'blogdescription' ) ;
|
930 |
if ( is_home() ) {
|
931 |
if ( $redux_builder_amp['amp-frontpage-select-option']== 1) {
|
934 |
}
|
935 |
echo $site_title ;
|
936 |
} ?>
|
937 |
+
</title>
|
938 |
<?php
|
939 |
}
|
940 |
}
|
|
|
941 |
|
942 |
+
// 27. Clean the Defer issue
|
943 |
+
// TODO : Get back to this issue. #407
|
944 |
+
function ampforwp_the_content_filter_full( $content_buffer ) {
|
945 |
+
$content_buffer = preg_replace("/' defer='defer/", "", $content_buffer);
|
946 |
+
$content_buffer = preg_replace("/onclick=[^>]*/", "", $content_buffer);
|
947 |
+
$content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer);
|
948 |
+
return $content_buffer;
|
949 |
+
}
|
950 |
+
ob_start('ampforwp_the_content_filter_full');
|
951 |
|
|
|
|
|
952 |
|
953 |
+
|
954 |
+
// 28. Properly removes AMP if turned off from Post panel
|
955 |
+
add_filter( 'amp_skip_post', 'ampforwp_skip_amp_post', 10, 3 );
|
956 |
function ampforwp_skip_amp_post( $skip, $post_id, $post ) {
|
957 |
+
$ampforwp_amp_post_on_off_meta = get_post_meta( $post->ID , 'ampforwp-amp-on-off' , true );
|
958 |
+
if( $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
|
959 |
$skip = true;
|
960 |
}
|
961 |
return $skip;
|
962 |
}
|
963 |
+
|
964 |
+
// 29. Remove analytics code if Already added by Glue or Yoast SEO (#370)
|
965 |
+
add_action('init','remove_analytics_code_if_available',20);
|
966 |
+
function remove_analytics_code_if_available(){
|
967 |
+
if ( class_exists('WPSEO_Options') && class_exists('YoastSEO_AMP') ) {
|
968 |
+
$yoast_glue_seo = get_option('wpseo_amp');
|
969 |
+
|
970 |
+
if ( $yoast_glue_seo['analytics-extra'] ) {
|
971 |
+
remove_action('amp_post_template_head','ampforwp_register_analytics_script', 20);
|
972 |
+
remove_action('amp_post_template_footer','ampforwp_analytics',11);
|
973 |
+
}
|
974 |
+
|
975 |
+
if ( class_exists('Yoast_GA_Options') ) {
|
976 |
+
$UA = Yoast_GA_Options::instance()->get_tracking_code();
|
977 |
+
if ( $UA ) {
|
978 |
+
remove_action('amp_post_template_head','ampforwp_register_analytics_script', 20);
|
979 |
+
remove_action('amp_post_template_footer','ampforwp_analytics',11);
|
980 |
+
}
|
981 |
+
}
|
982 |
+
}
|
983 |
+
}
|
984 |
+
|
985 |
+
//30. TagDiv menu issue removed
|
986 |
+
if( class_exists( 'td_mobile_theme' ) ) {
|
987 |
+
remove_action('option_stylesheet', array('td_mobile_theme', 'mobile'));
|
988 |
+
}
|