Skip to content

Commit

Permalink
Merge pull request #158 from ahmedkaludi/0.8.6-Beta
Browse files Browse the repository at this point in the history
0.8.5.1 Release
  • Loading branch information
ahmedkaludi committed Oct 13, 2016
2 parents 3cc9082 + d27955d commit 31da4a3
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 9 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
Requires at least: 3.0
Tested up to: 4.6.1
Stable tag: 0.8.5
Stable tag: 0.8.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -112,6 +112,17 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F


== Changelog ==
= 0.8.5.1 =
* Proper Details at http://ampforwp.com/new/
* Validation issue fixed: 'Value' tag
* Validation issue fixed: The attribute 'contenteditable' may not appear in tag 'a'.
* Validation issue fixed: Table markup
* Validation issue fixed: nowrap and misc tags
* New Relic Support
* Tags on off option
* Canonical and correct AMP html Redirect issues Solved
* NextGEN Gallery Validation Support Added

= 0.8.5 =
* Proper Details at http://ampforwp.com/the-0-4-compatibility/
* AMP 0.4 Compatibility Check
Expand Down
2 changes: 1 addition & 1 deletion accelerated-moblie-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Accelerated Mobile Pages
Plugin URI: https://wordpress.org/plugins/accelerated-mobile-pages/
Description: AMP Toolbox - Accelerated Mobile Pages for WordPress
Version: 0.8.5
Version: 0.8.5.1
Author: Ahmed Kaludi, Mohammed Kaludi
Author URI: http://ampforwp.com/
License: GPL2
Expand Down
10 changes: 10 additions & 0 deletions includes/options/options-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,16 @@
'subtitle' => __('Enable Next / Previous in the single post', 'redux-framework-demo'),
'true' => 'Enabled',
'false' => 'Disabled',
),
// Tags ON/OFF
array(
'id' => 'ampforwp-single-tags-on-off',
'type' => 'switch',
'title' => __('Tags', 'redux-framework-demo'),
'default' => 1,
'subtitle' => __('Enable / Disable Tags in the single post', 'redux-framework-demo'),
'true' => 'Enabled',
'false' => 'Disabled',
),
// Social Icons ON/OFF
array(
Expand Down
13 changes: 12 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: mohammed_kaludi, ahmedkaludi
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google
Requires at least: 3.0
Tested up to: 4.6.1
Stable tag: 0.8.5
Stable tag: 0.8.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -109,6 +109,17 @@ Please check if you have "Pretty Permalinks" enabled. If not then activate it. F


== Changelog ==
= 0.8.5.1 =
* Proper Details at http://ampforwp.com/new/
* Validation issue fixed: 'Value' tag
* Validation issue fixed: The attribute 'contenteditable' may not appear in tag 'a'.
* Validation issue fixed: Table markup
* Validation issue fixed: nowrap and misc tags
* New Relic Support
* Tags on off option
* Canonical and correct AMP html Redirect issues Solved
* NextGEN Gallery Validation Support Added

= 0.8.5 =
* Proper Details at http://ampforwp.com/the-0-4-compatibility/
* AMP 0.4 Compatibility Check
Expand Down
104 changes: 100 additions & 4 deletions templates/features.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
12. Add Logo URL in the structured metadata
13. Add Custom Placeholder Image for Structured Data.
14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
15. Disable New Relic's extra script that its adds in AMP pages.
16. Remove Unwanted Scripts
17. Archives Canonical in AMP version
18. Custom Canonical for Homepage
19. Remove Canonical tags
*/

// Adding AMP-related things to the main theme
global $redux_builder_amp;

Expand All @@ -29,7 +33,7 @@ function ampforwp_allow_homepage(){
}

function ampforwp_add_endpoint_actions() {
if ( is_home() || is_archive() ) {
if ( is_home() || is_archive() ) {

$is_amp_endpoint = is_amp_endpoint();

Expand All @@ -48,7 +52,13 @@ function ampforwp_home_archive_rel_canonical() {

if ( is_home() || is_front_page() ){
$amp_url = home_url('/?amp');
} else {
}
elseif( is_archive()){
global $wp;
$archive_current_url = add_query_arg( '', '', home_url( $wp->request ) );
$amp_url = $archive_current_url . '/?amp';
}
else {
$amp_url = trailingslashit( get_permalink().'amp' );
}

Expand Down Expand Up @@ -368,12 +378,24 @@ function ampforwp_strip_invalid_content(){
function ampforwp_the_content_filter( $content ) {
$content = preg_replace('/property=[^>]*/', '', $content);
$content = preg_replace('/vocab=[^>]*/', '', $content);
$content = preg_replace('/value=[^>]*/', '', $content);
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
$content = preg_replace('/time=[^>]*/', '', $content);
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
$content = preg_replace('/security=[^>]*/', '', $content);
$content = preg_replace('/deposit=[^>]*/', '', $content);
$content = preg_replace('/for=[^>]*/', '', $content);
$content = preg_replace('/style=[^>]*/', '', $content);
$content = preg_replace('/nowrap="nowrap"/', '', $content);
$content = preg_replace('#<comments-count.*?>(.*?)</comments-count>#i', '', $content);
$content = preg_replace('#<col.*?>#i', '', $content);
$content = preg_replace('#<table.*?>#i', '<table width="100%">', $content);
$content = preg_replace('#<style scoped.*?>(.*?)</style>#i', '', $content);
$content = preg_replace('/href="javascript:void*/', ' ', $content);
return $content;
}



// 12. Add Logo URL in the structured metadata
add_filter( 'amp_post_template_metadata', 'ampforwp_update_metadata', 10, 2 );
function ampforwp_update_metadata( $metadata, $post ) {
Expand Down Expand Up @@ -487,3 +509,77 @@ function ampforwp_hide_amp_for_specific_pages($input){
}
return $input;
}

// 15. Disable New Relic's extra script that its adds in AMP pages.
add_action( 'amp_post_template_data', 'ampforwp_disable_new_relic_scripts' );
if ( ! function_exists('ampforwp_disable_new_relic_scripts') ) {
function ampforwp_disable_new_relic_scripts( $data ) {
if ( ! function_exists( 'newrelic_disable_autorum' ) ) {
return $data;
}
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
newrelic_disable_autorum();
}
return $data;
}
}

// 16. Remove Unwanted Scripts
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
add_action( 'wp_enqueue_scripts', 'ampforwp_remove_unwanted_scripts',20 );
}
function ampforwp_remove_unwanted_scripts() {
wp_dequeue_script('jquery');
}
// Remove Print Scripts and styles
function ampforwp_remove_print_scripts() {
if ( is_amp_endpoint() ) {

function ampforwp_remove_all_scripts() {
global $wp_scripts;
$wp_scripts->queue = array();
}
add_action('wp_print_scripts', 'ampforwp_remove_all_scripts', 100);
function ampforwp_remove_all_styles() {
global $wp_styles;
$wp_styles->queue = array();
}
add_action('wp_print_styles', 'ampforwp_remove_all_styles', 100);

// Remove Print Emoji for Nextgen Gallery support
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

}
}
add_action( 'template_redirect', 'ampforwp_remove_print_scripts' );


// 17. Archives Canonical in AMP version
function ampforwp_rel_canonical_archive() {
if ( !is_archive() )
return;
global $wp;
$current_archive_url = home_url( $wp->request );
// $archivelink = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
echo "<link rel='canonical' href='$current_archive_url' />\n";
}
add_action( 'amp_post_template_head', 'ampforwp_rel_canonical_archive' );

// 18. Custom Canonical for Homepage
function ampforwp_rel_canonical() {
if ( !is_home() || !is_front_page() )
return;
// $link = esc_url( get_permalink( $id ) . AMP_QUERY_VAR . '/' );
$homelink = get_home_url();
echo "<link rel='canonical' href='$homelink' />\n";
}
add_action( 'amp_post_template_head', 'ampforwp_rel_canonical' );

// 19. Remove Canonical tags
function ampforwp_amp_remove_actions() {
if ( is_home() || is_front_page() || is_archive() ) {
remove_action( 'amp_post_template_head', 'amp_post_template_add_canonical' );
}
}
add_action( 'amp_post_template_head', 'ampforwp_amp_remove_actions', 9 );
7 changes: 5 additions & 2 deletions templates/single.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
</div>

<div class="amp-wp-content post-pagination-meta">
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) ); ?>
<?php if($redux_builder_amp['ampforwp-single-tags-on-off'] == true) {
$this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-taxonomy' ) ) );

} ?>


<?php if($redux_builder_amp['enable-next-previous-pagination'] == true) { ?>
Expand Down Expand Up @@ -89,4 +92,4 @@

<?php do_action( 'amp_post_template_footer', $this ); ?>
</body>
</html>
</html>

0 comments on commit 31da4a3

Please sign in to comment.