Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Soucie AdamSoucie

View GitHub Profile
View class-wyvern-plugin.php
<?php
/**
* Define the core plugin class.
*
* A class definition that includes attributes and functions used across both the
* public-facing side of the site and the admin area.
*
* @since 1.0.0
*
@AdamSoucie
AdamSoucie / multi-level-flyout-a11y.js
Created Dec 14, 2019
Script that helps support multi-level flyout menus
View multi-level-flyout-a11y.js
// Global Variables
const subMenus = document.querySelectorAll( 'li.menu-item-has-children' );
let focasable;
let delayTimer;
let focusTimer;
let currentSubMenu;
// Deal with the sub-menus
if ( subMenus ) {
Array.prototype.forEach.call( subMenus, function( element, iterator ){
@AdamSoucie
AdamSoucie / load-assets.php
Created Aug 31, 2018
Loads assets for the child theme
View load-assets.php
<?php
/**
* Load files in the /assets/ directory
*
* @since 1.0.0
*/
function seven_pines_load_assets()
{
// Load the main Genesis stylesheet first
@AdamSoucie
AdamSoucie / gist-block.js
Created Aug 17, 2018
Block.js file for Gist Gutenberg Block
View gist-block.js
/**
* BLOCK: wds-gist
*/
// Import CSS.
import './style.scss';
import './editor.scss';
const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks
@AdamSoucie
AdamSoucie / bb-frontend.php
Created Aug 17, 2018
Beaver Builder Gist Module - Front End
View bb-frontend.php
<?php
/**
* The frontend of the Gist Module.
*
* @package wds-gist
*/
// Get our fields.
$user_name = $settings->github_username;
$url = $settings->gist_url;
@AdamSoucie
AdamSoucie / with-toggle.php
Last active Aug 2, 2018
Select Field with Toggle
View with-toggle.php
'fields' => array(
'module_layout' => array(
'type' => 'select',
'label' => __( 'Module Layout', 'wds-beaver-builder' ),
'default' => 'fifty-image-text',
'options' => array(
'fifty-image-text' => __( 'Image/Text', 'wds-beaver-builder' ),
'fifty-text-image' => __( 'Text/Image', 'wds-beaver-builder' ),
'fifty-text-text' => __( 'Text/Text', 'wds-beaver-builder' ),
),
@AdamSoucie
AdamSoucie / no-toggle.php
Created Aug 2, 2018
Beaver Builder Select Field (no toggle)
View no-toggle.php
'module_layout' => array(
'type' => 'select',
'label' => __( 'Module Layout', 'wds-beaver-builder' ),
'default' => 'fifty-image-text',
'options' => array(
'fifty-image-text' => __( 'Image/Text', 'wds-beaver-builder' ),
'fifty-text-image' => __( 'Text/Image', 'wds-beaver-builder' ),
'fifty-text-text' => __( 'Text/Text', 'wds-beaver-builder' ),
),
View ARIA Overkill
<button id="main-menu-trigger" class="main-menu-trigger" role="button">Menu</button>
<nav id="main-menu-container" class="main-menu-container" role="navigation">
<ul id="main-menu" aria-expanded="false" role="menu">
<li id="menu-item-1" class="menu-item" role="menuitem">
<a href="#" role="link">Home</a>
</li>
<li id="menu-item-2" class="menu-item" role="menuitem">
<a href="#" role="link">About</a>
</li>
<li id="menu-item-3" class="menu-item" role="menuitem">
View toggleARIAExpanded.js
function toggleARIAExpanded(menu)
{
var isExpanded = menu.attr('aria-expanded');
if( isExpanded === 'true' )
{
menu.attr('aria-expanded', 'false');
menu.toggleClass('active');
}
else
View ARIA Menu - Not Expanded
<button id="main-menu-trigger" class="main-menu-trigger">Menu</button>
<nav id="main-menu-container" class="main-menu-container">
<ul id="main-menu" aria-expanded="false">
<li id="menu-item-1" class="menu-item">
<a href="#">Home</a>
</li>
<li id="menu-item-2" class="menu-item">
<a href="#">About</a>
</li>
<li id="menu-item-3" class="menu-item">