Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Pradeep Sonawane pradeep910

🏠
Working from home
View GitHub Profile
@pradeep910
pradeep910 / amp-error-handling-example.php
Created Sep 23, 2020
AMP error handling example for WordPress
View amp-error-handling-example.php
<?php
function amp_wp_org_is_amp() {
return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint();
}
if ( amp_wp_org_is_amp() ) {
// Remove script from AMP pages.
wp_dequeue_script( 'script-handle' );
}
@pradeep910
pradeep910 / Sample responsive amp-video-iframe
Last active Aug 8, 2019
Responsive amp-video-iframe based on sizes with media query.
View Sample responsive amp-video-iframe
<!-- Page 6 (Rabbit): 3 layers (fill (video) + vertical + vertical) -->
<amp-story-page id="page6">
<amp-story-grid-layer template="fill">
<!-- DESKTOP -->
<amp-video-iframe media="(min-width: 900px)"
id="myVideo"
src="https://sudhir.dev/videojs-example/amp-videojs-embed1.html"
@pradeep910
pradeep910 / rt-amp-enabler-for-non-amp.php
Last active Apr 2, 2019
Include amp-runtime script for Non-AMP pages.
View rt-amp-enabler-for-non-amp.php
<?php
/**
* Plugin Name: AMP Framework enabler for Non AMP.
* Description: Enables AMP as Framework enabler for Non AMP.
* Plugin URI: https://rtcamp.com
* Version: 0.2
* Author: rtCamp, pradeep910
* Author URI: https://rtcamp.com
*
* @package rtCamp
@pradeep910
pradeep910 / rt-amp-mailchimp-for-wordpress-fix.php
Created Feb 3, 2019
AMP support for MailChimp for WordPress plugin
View rt-amp-mailchimp-for-wordpress-fix.php
<?php
/**
* Plugin Name: MailChimp for WordPress - AMP Support
* Description: Fix for MailChimp form submission with page update in AMP.
* Plugin URI: https://pradeepsonawane.com
* Version: 0.1
* Author: Pradeep Sonawane
* Author URI: https://pradeepsonawane.com
*
* @package rtCamp
@pradeep910
pradeep910 / rt-gutenberg-block-grid-support.scss
Last active Sep 12, 2018
Gutenberg Columns Block and Gallery Block CSS Fix (.scss version)
View rt-gutenberg-block-grid-support.scss
/* Gutenberg Columns Block (Beta) Responsive CSS Fix */
.wp-block-columns {
display: grid;
grid-gap: 1rem;
grid-auto-flow: dense;
.layout-column-1 {
grid-column: 1;
}
.layout-column-2 {
@pradeep910
pradeep910 / rt-amp-gravity-form-fix.php
Last active Jul 8, 2020
Fix for gravity form submission with page update in AMP native mode (amp-wp plugin)
View rt-amp-gravity-form-fix.php
<?php
/**
* Plugin Name: Gravity form fix for AMP-WP plugin
* Description: Fix for gravity form submission with page update in AMP native mode (amp-wp plugin). Gravity forms submission with page update fix for AMP Native mode of amp-wp plugin. https://ampbyexample.com/components/amp-form/#form-submission-with-page-update
* Plugin URI: https://gist.github.com/pradeep910/b25525034289ab0bc2b7fa0896f4ac90/
* Version: 0.1
* Author: Pradeep Sonawane
* Author URI: https://pradeepsonawane.com
*
* @package rtCamp
View force-download.php
<?php
$file = "filename.ext";
// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename="" . basename($file) . """);
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream;");
readfile($file);
?>