Skip to content

Commit

Permalink
Merge pull request #7 from ahmedkaludi/master
Browse files Browse the repository at this point in the history
Update from main repo
  • Loading branch information
Nicholas Griffin authored Aug 5, 2017
2 parents 9f07d70 + 37b7724 commit 7c15965
Show file tree
Hide file tree
Showing 36 changed files with 1,168 additions and 342 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== AMP for WP - Accelerated Mobile Pages ===
Contributors: mohammed_kaludi, ahmedkaludi, ampforwp
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO, Instant Articles
Tags: AMP, accelerated mobile pages, mobile, amp project, google amp, amp wp, google, plugin, SEO
Donate link: https://www.paypal.me/Kaludi/5
Requires at least: 3.0
Tested up to: 4.8
Stable tag: 0.9.54
Stable tag: 0.9.56
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -29,11 +29,12 @@ Bug reports for AMP for WP are [welcomed on GitHub](https://github.com/ahmedkalu

= Features: =

* NEW - Page Break / NextPage (Pagination) Support
* NEW - Contact Form 7 Support [More Info](https://ampforwp.com/contact-form-7/)
* NEW - Page Builder for AMP! [Watch the Demo](http://ampforwp.com/demo/#pagebuilder) | [How to](https://ampforwp.com/tutorials/page-builder/)
* NEW - Github Gist Support
* NEW - Facebook Comments Support
* NEW - Email Opt-in Subscription form support in AMP added
* Github Gist Support
* Email Opt-in Subscription form support in AMP added
* Call to Action boxes and notification bars
* 9 Advertisement sizes - 2 More AD slots added recently
* Comments Forms in AMP.
Expand Down Expand Up @@ -136,6 +137,40 @@ You can contact me using this url: http://ampforwp.com/contact/

== Changelog ==

= 0.9.56 (31st July 2017) =
* View more details on https://ampforwp.com/page-break-in-amp/
* Page Break / NextPage (Pagination) Support Added #834 #857 (Improvement)
* Show/Hide AMP for Categories of Posts or All posts #872 (Improvement)
* JetPack Plugin Conflict Solved #971
* Social sharing code improved. amp-social-share js is getting added for line and WhatsApp social share #981
* Code improvement for rel canonicals(home and archive)
* Perfect SEO URL + Yoast SEO Compatibility #982
* Some styling for tags to show up properly
* Undefined index notices #960
* Non-amp category pages should redirect to non-amp pages if turned off from Hiding AMP #999
* Page builder text and button module issues #972
* Documentation links updated in the Options panel

= 0.9.55 (13th July 2017) =
* View more details on https://ampforwp.com/0-9-55-released-improvement-update-61st-update/
* Disqus Comments show up even when disabled per post #931
* Unnecessary: Adding the Markup for AMP Woocommerce latest Products #929
* H3 inside OL in Related-Posts.php #930
* Advertisement Options in Instant Articles #943
* Incompatible with bootstrap plugin #525
* Error in tag and category links #934
* Pagebuilder Button module link had issues #951
* Unnecessary: Adding the Markup for AMP Woocommerce latest Products #929
* WPtouch Pro Compatibility Issues #927
* Better scripts compatibility in Single of post types #757
* Instant Articles Error: "The HTML element does not contain any text" #949
* added a filter in all the dates so a user can change the date format and modify #962
* Design3 Menu Arrows are clickable along with the links #952


= 0.9.54.2 (4th July 2017) =
* Minor bug post 0.9.54 bug fixed

= 0.9.54 (4th July 2017) =
* View more details on https://ampforwp.com/new/
* Facebook Instant Articles Support #862
Expand Down
5 changes: 3 additions & 2 deletions 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 for WP - Accelerated Mobile Pages for WordPress
Version: 0.9.55
Version: 0.9.57
Author: Ahmed Kaludi, Mohammed Kaludi
Author URI: https://ampforwp.com/
Donate link: https://www.paypal.me/Kaludi/25
Expand All @@ -17,7 +17,8 @@
define('AMPFORWP_PLUGIN_DIR_URI', plugin_dir_url(__FILE__));
define('AMPFORWP_DISQUS_URL',plugin_dir_url(__FILE__).'includes/disqus.php');
define('AMPFORWP_IMAGE_DIR',plugin_dir_url(__FILE__).'images');
define('AMPFORWP_VERSION','0.9.55');
define('AMPFORWP_MAIN_PLUGIN_DIR', plugin_dir_path( __DIR__ ) );
define('AMPFORWP_VERSION','0.9.57');
// any changes to AMP_QUERY_VAR should be refelected here
define('AMPFORWP_AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );

Expand Down
132 changes: 132 additions & 0 deletions classes/class-ampforwp-youtube-embed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php #971
require_once AMP__DIR__ . '/includes/embeds/class-amp-base-embed-handler.php' ;

// Much of this class is borrowed from Jetpack embeds
class AMPforWP_YouTube_Embed_Handler extends AMP_Base_Embed_Handler {
const SHORT_URL_HOST = 'youtu.be';
// Only handling single videos. Playlists are handled elsewhere.
const URL_PATTERN = '#https?://(?:www\.)?(?:youtube.com/(?:v/|e/|embed/|watch[/\#?])|youtu\.be/).*#i';
const RATIO = 0.5625;

protected $DEFAULT_WIDTH = 600;
protected $DEFAULT_HEIGHT = 338;

private static $script_slug = 'amp-youtube';
private static $script_src = 'https://cdn.ampproject.org/v0/amp-youtube-0.1.js';

function __construct( $args = array() ) {
parent::__construct( $args );

if ( isset( $this->args['content_max_width'] ) ) {
$max_width = $this->args['content_max_width'];
$this->args['width'] = $max_width;
$this->args['height'] = round( $max_width * self::RATIO );
}
}

function register_embed() {
wp_embed_register_handler( 'amp-youtube', self::URL_PATTERN, array( $this, 'oembed' ), -1 );
add_shortcode( 'youtube', array( $this, 'shortcode' ) );
}

public function unregister_embed() {
wp_embed_unregister_handler( 'amp-youtube', -1 );
remove_shortcode( 'youtube' );
}

public function get_scripts() {
if ( ! $this->did_convert_elements ) {
return array();
}

return array( self::$script_slug => self::$script_src );
}

public function shortcode( $attr ) {
$url = false;
$video_id = false;
if ( isset( $attr[0] ) ) {
$url = ltrim( $attr[0] , '=' );
} elseif ( function_exists ( 'ampforwp_youtube_shortcode' ) ) {
$url = ampforwp_youtube_shortcode( $attr );
}

if ( empty( $url ) ) {
return '';
}

$video_id = $this->get_video_id_from_url( $url );

return $this->render( array(
'url' => $url,
'video_id' => $video_id,
) );
}


public function oembed( $matches, $attr, $url, $rawattr ) {
return $this->shortcode( array( $url ) );
}

public function render( $args ) {
$args = wp_parse_args( $args, array(
'video_id' => false,
) );

if ( empty( $args['video_id'] ) ) {
return AMP_HTML_Utils::build_tag( 'a', array( 'href' => esc_url( $args['url'] ), 'class' => 'amp-wp-embed-fallback' ), esc_html( $args['url'] ) );
}

$this->did_convert_elements = true;

return AMP_HTML_Utils::build_tag(
'amp-youtube',
array(
'data-videoid' => $args['video_id'],
'layout' => 'responsive',
'width' => $this->args['width'],
'height' => $this->args['height'],
)
);
}

private function get_video_id_from_url( $url ) {
$video_id = false;
$parsed_url = parse_url( $url );

if ( self::SHORT_URL_HOST === substr( $parsed_url['host'], -strlen( self::SHORT_URL_HOST ) ) ) {
// youtu.be/{id}
$parts = explode( '/', $parsed_url['path'] );
if ( ! empty( $parts ) ) {
$video_id = $parts[1];
}
} else {
// ?v={id} or ?list={id}
parse_str( $parsed_url['query'], $query_args );

if ( isset( $query_args['v'] ) ) {
$video_id = $this->sanitize_v_arg( $query_args['v'] );
}
}

if ( empty( $video_id ) ) {
// /(v|e|embed)/{id}
$parts = explode( '/', $parsed_url['path'] );

if ( in_array( $parts[1], array( 'v', 'e', 'embed' ) ) ) {
$video_id = $parts[2];
}
}

return $video_id;
}

private function sanitize_v_arg( $value ) {
// Deal with broken params like `?v=123?rel=0`
if ( false !== strpos( $value, '?' ) ) {
$value = strtok( $value, '?' );
}

return $value;
}
}
2 changes: 1 addition & 1 deletion includes/admin-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body #toplevel_page_amp_options .wp-menu-image{
background-size: 20px auto;
}
.amp_content_builder .redux-group-tab-link-a span:after {
content: "NEW";
/* content: "NEW";*/
color: #fff;
font-size: 10px;
background: #4452a7;
Expand Down
24 changes: 12 additions & 12 deletions includes/includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ function ampforwp_menu() {
add_action( 'init', 'ampforwp_menu' );
}

// 1.2 Footer Menu
global $redux_builder_amp;
if ( $redux_builder_amp['amp-design-selector'] == 1 ||
$redux_builder_amp['amp-design-selector'] == 2 ||
$redux_builder_amp['amp-design-selector'] == 3) {
add_action( 'init', 'ampforwp_footermenu' );
}
// 1.2 Footer Menu
add_action( 'init', 'ampforwp_footermenu' );
if (! function_exists( 'ampforwp_footermenu') ) {
function ampforwp_footermenu() {
register_nav_menus(
array(
'amp-footer-menu' => __( 'AMP Footer Menu','accelerated-mobile-pages' ),
)
);
global $redux_builder_amp;
if ( $redux_builder_amp['amp-design-selector'] == 1 ||
$redux_builder_amp['amp-design-selector'] == 2 ||
$redux_builder_amp['amp-design-selector'] == 3 ) {
register_nav_menus(
array(
'amp-footer-menu' => __( 'AMP Footer Menu','accelerated-mobile-pages' ),
)
);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions includes/modules/ampforwp-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function widget( $args, $instance ) {
} elseif( $feature['size'] == '3' ){
$size = "l_btn";
}
//Corrected the URL in button module #951
$output .= '<a href=" '. $feature['url'] .'" class="' . $size . '" target="' . $target . '" >'. $feature['title'] .'</a>';
//Corrected the URL in button module and breaking of desing and link issue #951 & #972
$output .= '<a href="'.esc_url($feature['url']).'" class="' . $size . '" target="' . $target . '" >'. $feature['title'] .'</a>';
}
$output .= '</div>';

Expand Down
Loading

0 comments on commit 7c15965

Please sign in to comment.