Skip to content

Instantly share code, notes, and snippets.

View MARQAS's full-sized avatar
💭
Code is Poetry

Mohammed Razzaq MARQAS

💭
Code is Poetry
View GitHub Profile
@MARQAS
MARQAS / hidebulkpost
Created May 16, 2017 11:49
Filter to Hide bulk posts in AMP
add_filter( 'amp_skip_post', 'ampforwp_skip_amp_post', 10, 3 );
function ampforwp_skip_amp_post( $skip, $post_id, $post ) {
$ampforwp_skip_posts_in = array(postid1, postid2, postid3, ....,postidn);
if( in_array( $post_id, $ampforwp_skip_posts_in ) ) {
$skip = true;
}
return $skip;
}
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>Example Gist to show in AMP</p>
</body>
</html>
<?php
/*
Plugin Name: Custom Plugin for AMP
Description: Extension to add more functionality in AMPforWP
Version: 1.0
Author: Marqas
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
@MARQAS
MARQAS / Override Blacklist sanitizer
Last active April 24, 2019 07:01
A new class file which will override Blacklist Sanitizer
<?php
$amp_blacklist_sanitizer = realpath( AMP__VENDOR__DIR__ . '/includes/sanitizers/class-amp-blacklist-sanitizer.php' );
if ( $amp_blacklist_sanitizer ) {
include_once $amp_blacklist_sanitizer;
}
if ( class_exists( 'AMPforWP\\AMPVendor\\AMP_Blacklist_Sanitizer' ) ) {
class AMP_New_Blacklist extends AMPforWP\AMPVendor\AMP_Blacklist_Sanitizer {
const PATTERN_REL_WP_ATTACHMENT = '#wp-att-([\d]+)#';
protected $DEFAULT_ARGS = array(