Skip to content

Instantly share code, notes, and snippets.

View Irfan-Ansari's full-sized avatar

Irfan Ansari Irfan-Ansari

View GitHub Profile
@Irfan-Ansari
Irfan-Ansari / bootsrap_responsive.css
Created October 16, 2015 14:03
Bootstrap Responsive Media Queries
/* Media Quries for Responsivness*/
/* Landscape tablets and medium desktops */
@media (min-width: 992px) and (max-width: 1199px) {
}
/* Portrait tablets and small desktops */
@media (min-width: 768px) and (max-width: 991px) {
@Irfan-Ansari
Irfan-Ansari / gist:5bf91886cdbc4709c153
Last active September 11, 2015 16:31 — forked from davidmh/gist:5689418
Fast Next/Prev Post Links for large databases. http://wordpress.stackexchange.com/q/101435/
<?php # -*- coding: utf-8 -*-
namespace WPSE;
/* Plugin Name: Fast Next/Prev Post Links
* Plugin URI: http://wordpress.stackexchange.com/q/101435/
*/
add_action(
'fast_prev_post_link',
__NAMESPACE__ . '\fast_prev_post_link',
10,
@Irfan-Ansari
Irfan-Ansari / delte_post_in_selected_category
Created July 15, 2015 13:45
Delete posts from selected category within the date range.
delete a, b, c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id IN (10)
AND a.post_type = 'post'
AND a.post_date BETWEEN '2008-01-01' AND '2013-01-15';
<?
function mandatory_excerpt($data) {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_post_location', 'excerpt_error_message_redirect', '99');
}
@Irfan-Ansari
Irfan-Ansari / force page to load on top - cause of refresh
Created June 2, 2015 09:56
force page to load on top - cause of refresh
/* force page to load on top - cause of refresh */
$(window).on('beforeunload', function(){
$(window).scrollTop(0);
});
function THEMENAME_wrap_gumby_intrinsic($html, $url, $args){
$provider = '';
if (preg_match("#https?://youtu\.be/.*#i", $url) || preg_match("#https?://(www\.)?youtube\.com/watch.*#i", $url)) {
$provider = 'youtube';
}elseif (preg_match("/vimeo.com\/([^&]+)/i", $url)) {
$provider = 'vimeo';
}
//no oEmbed for Twich :<
//elseif (preg_match("/https?:\/\/(.*twitch\.tv\/.*|.*twitch\.tv\/.*\/b\/.*)/i", $url)){
//$provider = 'twitch';
<?php
/*
Plugin Name: Remove All Feeds [for WPSE33072]
Description: Remove all feeds from WordPress
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
@Irfan-Ansari
Irfan-Ansari / custom post type bas slug
Last active August 29, 2015 14:18
custom post type bas slug
function nsppt_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'portfolio' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'nsppt_remove_cpt_slug', 10, 3 );
/**
* Some hackery to have WordPress match postname to any of our public post types
* All of our public post types can have /post-name/ as the slug, so they better be unique across all posts
// Use the new media manager to handle uploads to Soliloquy.
$('#soliloquy-area').on('click.soliloquyUpload', '#soliloquy-upload', function(e){
// Prevent the default action from occuring.
e.preventDefault();
// Variable to hold our media applicaton.
var soliloquy_frame;
// If the media frame already exists, reopen it and return.
if ( soliloquy_frame ) {
@Irfan-Ansari
Irfan-Ansari / Widget.php
Created February 26, 2015 11:45
Register and call wdiget area in wordpress
<?php
/**
* Register Widget Area.
*
*/
function wpgyan_widgets_init() {
register_sidebar( array(
'name' => 'Header Sidebar',