-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #841: Native AMP audio and video playlists. #954
Changes from 1 commit
00a3f08
8140a40
cddce46
f19c281
ca78258
78f7368
ccc066d
aba8cf1
f13d2ad
d3cc386
1b07e90
168b9ba
7cae35c
d01e9ea
e08bc8b
b093c85
b9d9f09
365af92
d94888d
13370ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* For the custom AMP implementation of audio 'playlist' shortcode. | ||
*/ | ||
.wp-playlist .wp-playlist-current-item img { | ||
margin-right: 0; | ||
} | ||
|
||
.wp-playlist .wp-playlist-current-item amp-img { | ||
float: left; | ||
margin-right: 10px; | ||
} | ||
|
||
.wp-playlist audio { | ||
display: block; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,13 @@ | |
*/ | ||
class AMP_Playlist_Embed_Handler extends AMP_Base_Embed_Handler { | ||
|
||
/** | ||
* The tag of the shortcode. | ||
* | ||
* @var string. | ||
*/ | ||
const SHORTCODE = 'playlist'; | ||
|
||
/** | ||
* The max width of the audio thumbnail image. | ||
* | ||
|
@@ -57,7 +64,8 @@ class AMP_Playlist_Embed_Handler extends AMP_Base_Embed_Handler { | |
* Registers the playlist shortcode. | ||
*/ | ||
public function register_embed() { | ||
add_shortcode( 'playlist', array( $this, 'shortcode' ) ); | ||
add_shortcode( self::SHORTCODE, array( $this, 'shortcode' ) ); | ||
add_action( 'wp_enqueue_scripts', array( $this, 'styling' ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be removed in favor of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @westonruter, |
||
} | ||
|
||
/** | ||
|
@@ -66,7 +74,27 @@ public function register_embed() { | |
* @return void. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The period shouldn't be used here. A period should only appear after a description when it is provided, for example:
See examples https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this commit removes that extra period. |
||
*/ | ||
public function unregister_embed() { | ||
remove_shortcode( 'playlist' ); | ||
remove_shortcode( self::SHORTCODE ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the other examples of embeds in the plugin aren't quite right in how they call add_shortcode( self::SHORTCODE, array( $this, 'shortcode' ) ); It should do: global $shortcode_tags;
if ( shortcode_exists( self::SHORTCODE ) ) {
$this->removed_shortcode = $shortcode_tags[ self::SHORTCODE ];
}
add_shortcode( self::SHORTCODE, array( $this, 'shortcode' ) ); And then in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this commit applies your suggestion of restoring the shortcode before |
||
} | ||
|
||
/** | ||
* Enqueues the playlist styling. | ||
* | ||
* @return void. | ||
*/ | ||
public function styling() { | ||
global $post; | ||
if ( ! isset( $post->post_content ) || ! has_shortcode( $post->post_content, self::SHORTCODE ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conditional can be removed if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @westonruter, |
||
return; | ||
} | ||
|
||
wp_enqueue_style( 'wp-mediaelement' ); | ||
wp_enqueue_style( | ||
'amp-playlist-shortcode', | ||
amp_get_asset_url( 'css/amp-playlist-shortcode.css' ), | ||
array(), | ||
AMP__VERSION | ||
); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses
wp_enqueue_scripts
, instead ofwp_playlist_script
. That enqueues too late.