Skip to content

Instantly share code, notes, and snippets.

View zeshanshani's full-sized avatar
🎯
Focusing

Zeshan Ahmed zeshanshani

🎯
Focusing
View GitHub Profile
if (window.devicePixelRatio > 1) {
/* highDPI display */
}
if (window.devicePixelRatio >= 2) {
/* retina display */
}
@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.
*/
@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 / scrollToNextSection.css
Last active July 4, 2016 08:36
Click on the arrow to scroll to the next section to the banner.
/* Additional Styling */
#bottom-arrow {
position: absolute;
width: 52px; /* Width of arrow image */
height: 32px; /* Height of arrow image */
left: 50%;
margin-left: -26px; /* Horizontally centered, should be half of the 'width' */
background: url(path/to/arrow/file.png) no-repeat center center;
z-index: 10;
text-indent: -9999px; /* To visually hide the text inside the button */
@zeshanshani
zeshanshani / fetchGoogleNewsItems.js
Created August 18, 2016 05:54
Fetch Google News items of the specified term and display them in an element.
/**
* Converts XML to JSON
* Source: https://davidwalsh.name/convert-xml-json
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
@zeshanshani
zeshanshani / runFunctionMultipleTimes.js
Created August 24, 2016 04:54
Run a function multiple times until the element is found on the page
function runUACLCLoop() {
setTimeout(function() {
// Check if something is found on the page.
if ( jQuery('.class_name').is(':visible') ) { // change it to another condition
// Run the same function again to create the loop.
runUACLCLoop();
// If nothing is found, then run the else statement.
@zeshanshani
zeshanshani / nav-menu-exporter-importer.php
Created September 1, 2016 09:04 — forked from hissy/nav-menu-exporter-importer.php
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@zeshanshani
zeshanshani / convertURLToLinks.js
Created October 7, 2016 04:54
Check if a string contains any URLs and wrap them all into HTML <a> tags.
@zeshanshani
zeshanshani / acf_options_multilingual.php
Last active December 10, 2025 12:51
Creates separate Advanced Custom Fields options pages for the specified languages.
<?php // Don't copy this line if you are inserting in a file that has it already.
/**
* ACF Options Page
*
* Instructions:
* Add more languages to the array below: $languages
*
* @author: Zeshan Ahmed <https://zeshanahmed.com/>
*/
@zeshanshani
zeshanshani / polylang_custom_language_switcher.css
Last active February 19, 2023 06:12
Custom Language Switcher for Polylang. Contains both the PHP function and SCSS styling. HTML markup is using BEM methodology. SCSS file is using my variables and mixins from here: https://gist.github.com/zeshanshani/c4d5ae43e6a9f661d012
/* Component: Languages */
.languages__item {
text-transform: uppercase;
color: #899099;
font-size: 13px;
font-size: 1.3rem;
line-height: 1.15;
}
.languages__item--current {
color: #212121;