Skip to content

Instantly share code, notes, and snippets.

View jdelia's full-sized avatar

Jackie D'Elia jdelia

View GitHub Profile
@myogeshchavan97
myogeshchavan97 / trap_focus.js
Last active November 26, 2022 08:46
Code for trapping focus inside modal
// add all the elements inside modal which you want to make focusable
const focusableElements =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
const modal = document.querySelector('#exampleModal'); // select the modal by it's id
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
const focusableContent = modal.querySelectorAll(focusableElements);
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
@westonruter
westonruter / amp-story-supports-landscape.php
Last active August 6, 2019 17:39
Enable landscape (desktop) support for stories that have the 'landscape' tag. Requires AMP plugin 1.2+.
<?php
/**
* Plugin Name: AMP Story Supports Landscape
*
* @package AMP_Story_Supports_Landscape
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@thierrypigot
thierrypigot / script.js
Created October 20, 2017 06:01
Smooth scroll Javascript
jQuery(document).ready(function ($) {
'use strict';
// Smooth scroll
// https://css-tricks.com/snippets/jquery/smooth-scrolling/
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
@Auke1810
Auke1810 / wpa-clean-header.php
Last active May 9, 2024 14:14
create a clean wordpress header and remove unnecessary clutter.
<?php
/*
Plugin Name: wordpress assist clean header
Plugin URI: http://www.wordpressassist.nl/
Description: Remove shortlink hook
Version: 1.0
Author: AukeJomm
Author URI: http://www.aukejongbloed.nl
*/
@neilgee
neilgee / archive-title-removal.php
Created March 2, 2016 02:39
Remove Archive Title & Description from all the Genesis Archive Pages
<?php //<~ Remove me
//Removes Title and Description on CPT Archive
remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
//Removes Title and Description on Blog Archive
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
//Removes Title and Description on Date Archive
remove_action( 'genesis_before_loop', 'genesis_do_date_archive_title' );
//Removes Title and Description on Archive, Taxonomy, Category, Tag
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
@nciske
nciske / custom-simple-sidebar.php
Last active November 29, 2016 22:29
Add a custom simple sidebar to a page, CPT archive, singular post, etc.
<?php
// Hooks to remove default sidebar and add our custom one
// Place me in functions.php or above genesis(); on a page template (in which case, no conditional is needed)
add_action('get_header','example_change_genesis_sidebar');
function example_change_genesis_sidebar() {
// change the conditional to determine where the swap occurs
// https://codex.wordpress.org/Conditional_Tags
@neilgee
neilgee / slick-init-multiple-page-genesis.php
Last active April 25, 2019 23:50
Slick Carousel Enqueued and USed with ACF
<?php // <~ keep me in
add_action('genesis_entry_content','themeprefix_team_slider' );
//Fields
//team_portfolio = Gallery Field
function themeprefix_team_slider() {
$images = get_field('team_portfolio');//add your correct filed name
if( $images ): ?>
<div class="team-items">
@alexkalh
alexkalh / php-convert-color-code-from-hex-to-rgba
Created January 7, 2015 03:23
php-convert-color-code-from-hex-to-rgba
<?php
function ak_convert_hex2rgba($color, $opacity = false) {
$default = 'rgb(0,0,0)';
if (empty($color))
return $default;
if ($color[0] == '#')
$color = substr($color, 1);
@studiopress
studiopress / functions.php
Last active March 22, 2017 05:41
Sticky menu.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Enqueue sticky menu script
add_action( 'wp_enqueue_scripts', 'sp_enqueue_script' );
function sp_enqueue_script() {
wp_enqueue_script( 'sample-sticky-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-menu.js', array( 'jquery' ), '1.0.0' );
}
//* Reposition the secondary navigation menu
@glueckpress
glueckpress / paginate-parent-children.php
Last active September 3, 2021 19:42
[WordPress] Pagination for a parent page and their child pages.
<?php
/**
* Pagination for a parent page and their child pages.
* Use as gp130428_link_pages() in your template file.
* Optionally limit to a particular parent page by passing its ID (i.e. 123) to the function: gp130428_link_pages( 123 )
*
*/
function gp130428_paginate_parent_children( $parent = null ) {
global $post;