css
2 years ago
images
2 years ago
img
2 years ago
js
1 year ago
archiveorg-book.php
5 years ago
archiveorg.php
5 years ago
archives.php
5 years ago
bandcamp.php
3 years ago
brightcove.php
5 years ago
cartodb.php
5 years ago
class.filter-embedded-html-objects.php
2 years ago
codepen.php
5 years ago
crowdsignal.php
2 years ago
dailymotion.php
3 years ago
descript.php
4 years ago
facebook.php
1 year ago
flatio.php
5 years ago
flickr.php
2 years ago
getty.php
2 years ago
gist.php
3 years ago
googleapps.php
2 years ago
googlemaps.php
2 years ago
googleplus.php
5 years ago
gravatar.php
2 years ago
houzz.php
5 years ago
inline-pdfs.php
4 years ago
instagram.php
1 year ago
kickstarter.php
3 years ago
mailchimp.php
3 years ago
medium.php
3 years ago
mixcloud.php
2 years ago
others.php
1 year ago
pinterest.php
2 years ago
presentations.php
2 years ago
quiz.php
4 years ago
recipe.php
2 years ago
scribd.php
5 years ago
sitemap.php
5 years ago
slideshare.php
5 years ago
slideshow.php
1 year ago
smartframe.php
3 years ago
soundcloud.php
3 years ago
spotify.php
2 years ago
ted.php
5 years ago
tweet.php
2 years ago
twitchtv.php
5 years ago
twitter-timeline.php
5 years ago
twitter.php
1 year ago
unavailable.php
3 years ago
untappd-menu.php
3 years ago
upcoming-events.php
1 year ago
ustream.php
5 years ago
videopress.php
4 years ago
vimeo.php
2 years ago
vine.php
5 years ago
vr.php
2 years ago
wufoo.php
3 years ago
youtube.php
1 year ago
unavailable.php
94 lines
| 1 | <?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Display a message on the frontend when we retire a shortcode, |
| 4 | * explaining why the shortcode is not available anymore. |
| 5 | * |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 10 | |
| 11 | /** |
| 12 | * Class Jetpack_Shortcode_Unavailable |
| 13 | */ |
| 14 | class Jetpack_Shortcode_Unavailable { |
| 15 | /** |
| 16 | * Shortcodes that are unavailable. |
| 17 | * |
| 18 | * Key is the shortcode, value is string explaining why. |
| 19 | * |
| 20 | * @var array |
| 21 | */ |
| 22 | public $shortcodes; |
| 23 | |
| 24 | /** |
| 25 | * Set up the actions and filters for the class to listen to. |
| 26 | * |
| 27 | * @param array $shortcodes An associative array of keys being the shortcodes that are unavailable, and a string explaining why. |
| 28 | */ |
| 29 | public function __construct( $shortcodes ) { |
| 30 | $this->shortcodes = $shortcodes; |
| 31 | |
| 32 | add_action( 'template_redirect', array( $this, 'add_shortcodes' ) ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * For all of our defined unavailable shortcodes, if something else hasn't |
| 37 | * already claimed them, add a handler to nullify their output. |
| 38 | */ |
| 39 | public function add_shortcodes() { |
| 40 | foreach ( array_keys( $this->shortcodes ) as $shortcode ) { |
| 41 | if ( ! shortcode_exists( $shortcode ) ) { |
| 42 | add_shortcode( $shortcode, array( $this, 'stub_shortcode' ) ); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Nullify the output of unavailable shortcodes. Includes a filter to make |
| 49 | * it easier to notify admins that a shortcode that they used is unavailable. |
| 50 | * |
| 51 | * @param array $atts Shortcode attributes. |
| 52 | * @param string $content Post content. |
| 53 | * @param string $shortcode Shortcode name. |
| 54 | * |
| 55 | * @return mixed|void |
| 56 | */ |
| 57 | public function stub_shortcode( $atts, $content = '', $shortcode = '' ) { |
| 58 | $str = ''; |
| 59 | if ( current_user_can( 'edit_posts' ) && ! empty( $this->shortcodes[ $shortcode ] ) ) { |
| 60 | $str = sprintf( '<div><strong>%s</strong></div>', $this->shortcodes[ $shortcode ] ); |
| 61 | } |
| 62 | /** |
| 63 | * Filter the front-end output of unavailable shortcodes. |
| 64 | * |
| 65 | * @module shortcodes |
| 66 | * |
| 67 | * @since 4.5.0 |
| 68 | * |
| 69 | * @param string $str The html displayed in lieu of the shortcode. |
| 70 | * @param array $atts The attributes (numeric or named) passed to the shortcode. |
| 71 | * @param string $content The content (if any) between the opening and closing tags. |
| 72 | * @param string $shortcode The shortcode tag used to invoke this. |
| 73 | */ |
| 74 | return apply_filters( 'jetpack_stub_shortcode', $str, $atts, $content, $shortcode ); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Init class. |
| 80 | */ |
| 81 | function jetpack_init_shortcode_unavailable() { |
| 82 | new Jetpack_Shortcode_Unavailable( |
| 83 | array( |
| 84 | 'digg' => __( 'The Digg API was shut down in 2014.', 'jetpack' ), |
| 85 | 'hulu' => __( 'Hulu no longer allows embedding content.', 'jetpack' ), |
| 86 | 'blip.tv' => __( 'The Blip.tv service has been shut down since August 20th, 2015.', 'jetpack' ), |
| 87 | 'googlevideo' => __( 'The Google Video embed service is not available anymore, it has been replaced by YouTube.', 'jetpack' ), |
| 88 | 'jetpack-email-subscribe' => __( 'The Email Subscribe shortcode is now available as a block in the Block editor.', 'jetpack' ), |
| 89 | 'lytro' => __( 'Lytro has been shut down since March 2019.', 'jetpack' ), |
| 90 | ) |
| 91 | ); |
| 92 | } |
| 93 | add_action( 'init', 'jetpack_init_shortcode_unavailable' ); |
| 94 |