Created
August 21, 2019 11:20
-
-
Save wpmudev-sls/c45ae504b03d1e3ddaf04a38f3268b0b to your computer and use it in GitHub Desktop.
[SmartCrawl] - Autolinks for AMP. Since the AMP plugin isn't using the_content filter we're overriding the `AMPforWP\\AMPVendor\\amp_render` method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [SmartCrawl] - Autolinks for AMP | |
* Plugin URI: https://premium.wpmudev.org/ | |
* Description: Since the AMP plugin isn't using the_content filter we're overriding the `AMPforWP\\AMPVendor\\amp_render` method | |
* Author: Panos Lyrakis @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/ | |
* License: GPLv2 or later | |
*/ | |
namespace AMPforWP\AMPVendor; | |
if ( ! function_exists('AMPforWP\\AMPVendor\\amp_render') ) { | |
function amp_render() { | |
global $ampforwpTemplate; | |
$sc_autolinks = \Smartcrawl_Autolinks::get(); | |
amp_load_classes(); | |
$post_id = get_queried_object_id(); | |
do_action( 'pre_amp_render_post', $post_id ); | |
amp_add_post_template_actions(); | |
$template = $ampforwpTemplate = new AMP_Post_Template( $post_id ); | |
ob_start(); | |
$template->load(); | |
$content = $sc_autolinks->the_content_filter( ob_get_clean() ); | |
echo $content; | |
// Set Header: last modified information | |
if( is_singular() && $post_id ) { | |
header("Last-Modified: " . get_the_modified_time("D, d M Y H:i:s", $post_id) ); | |
} | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment