Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
@zeshanshani
zeshanshani / fullScreenBannerWithOffset.js
Last active July 4, 2016 08:35
Full Screen Banner with Offset. Default offset is header only.
/**
* Full Screen Banner with Offset Value
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*/
jQuery(document).ready(function($) {
// To run on homepage only. Remove/update if required on other pages.
if ($('body').hasClass('home')) {
@zeshanshani
zeshanshani / fullHeightSection.js
Last active April 17, 2019 23:17
This JavaScript function will expand the sections to the 100% of browser window height.
/**
* Full Height Sections
* This function will expand the sections to the 100% of browser window height.
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*
* Replace '#banner' with your targeted element's selector.
*/
if (window.devicePixelRatio > 1) {
/* highDPI display */
}
if (window.devicePixelRatio >= 2) {
/* retina display */
}
@zeshanshani
zeshanshani / gist:05dc77bf977a74dec9104fc72501b03d
Created May 17, 2016 07:29 — forked from betweenbrain/gist:5405671
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@zeshanshani
zeshanshani / extendedAnimations.css
Last active June 10, 2016 13:39
Extended Animations - Utilizes animate.css. Provides data attributes to add animations in any element on the page. Triggers animations on scroll. Updated: trigger all animations in one section at once.
/**
* Extended Sections Animations
* By: Zeshan Ahmed
* URI: http://www.zeshanahmed.com/
*
* Extended animations trigger on scroll. Uses animate.css.
*/
.not-animated {
opacity: 0;
@zeshanshani
zeshanshani / customizer-controls-40.php
Last active March 5, 2016 08:00 — forked from devinsays/customizer-controls-40
WordPress 4.0 Customizer Controls
<?php
function prefix_customizer_register( $wp_customize ) {
$wp_customize->add_panel( 'panel_id', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Example Panel', 'textdomain' ),
'description' => __( 'Description of what this panel does.', 'textdomain' ),
@zeshanshani
zeshanshani / WC-Exclude-Products-From-Shop.php
Created February 9, 2016 12:34
WooCommerce - Exclude Products from Shop Page using IDs.
<?php
// WooCommerce - Exclude Products from Shop Page using IDs.
// =============================================================================
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
@zeshanshani
zeshanshani / ExcerptLengthByCharacter.php
Created December 30, 2015 05:46
Limit WordPress excerpt length by character and keep last word complete, i.e., instead of 'compat...' show full last word, i.e. 'compatibility...'.
// Excerpt - Limit Length by Characters and Keep Last Word Complete.
// Solution from:
// https://wordpress.org/support/topic/limit-excerpt-length-by-characters#post-2248039
// ================================================================================
function excerpt_character_length( $excerpt ){
$permalink = get_permalink($post->ID);
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
@zeshanshani
zeshanshani / wp-snippets.php
Last active November 27, 2015 19:13
Helpful WordPress snippets for daily use.
<?php
/**
* Get the author profile URL
**/
$author_id = get_the_author_meta( 'ID' );
$author_url = get_author_posts_url( $author_id );