Skip to content

Instantly share code, notes, and snippets.

@jbd91
jbd91 / snippet.html
Created April 27, 2022 01:21
Accordion HTML
<div class="accordion__section col-span-12 lg:col-span-6">
<button tabindex="0" id="accordion__toggle4" class="accordion__toggle">
<span class="accordion__icon">
<span class="accordion__open">+</span>
<span class="accordion__close">-</span>
</span>
<span class="accordion__title">Test Title 4</span>
</button>
<div class="accordion__panel" aria-expanded="false"
aria-labelledby="accordion__toggle4">
@jbd91
jbd91 / snippet.js
Created April 27, 2022 01:21
Accordion Toggle
var acc = document.getElementsByClassName("accordion__toggle");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function () {
var panel = this.nextElementSibling;
if (this.classList.contains('active')) {
this.classList.remove("active");
@jbd91
jbd91 / snippet.js
Created March 17, 2022 21:13
Sticky
// Sticky Navigation
var header = document.getElementById('header');
var sticky = header.offsetTop;
window.onscroll = function () {
stickyNav()
};
function stickyNav() {
if (window.pageYOffset > sticky) {
@jbd91
jbd91 / snippet.php
Created May 7, 2021 17:37
functions.php
function theme_enqueue_styles() {
wp_enqueue_style( 'slick', get_template_directory_uri() . '/assets/vendor/slick/slick.css' );
wp_enqueue_style( 'slick-theme', get_template_directory_uri() . '/assets/vendor/slick/slick-theme.css');
//wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css?family=Rajdhani:500,700|Roboto:700&display=swap');
wp_enqueue_script( 'font-awesome', 'https://kit.fontawesome.com/1a3f79275c.js' );
wp_enqueue_script( 'mixitup', get_template_directory_uri() . '/assets/vendor/mixitup/mixitup.min.js', array( 'jquery' ), '3', true );
wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/vendor/slick/slick.min.js', array( 'jquery' ), '1.8', true );
//wp_enqueue_script( 'match-height', get_template_directory_uri() . '/assets/vendor/jquery.matchHeight-min.js', array( 'jquery' ), '1.6.0', true );
}
@jbd91
jbd91 / snippet.php
Created May 7, 2021 17:19
modal video conditional
<?php if ($landing_block_video_vimeo || $landing_block_video_youtube) : ?>
<div class="reveal small" id="videoModal<?php echo $i; ?>" data-reveal>
<?php if ($landing_block_video_vimeo) : ?>
<div class="responsive-embed">
<iframe src="https://player.vimeo.com/video/<?php echo $landing_block_video_vimeo ?>"
width="640" height="360"
frameborder="0" allow="autoplay; fullscreen"
@jbd91
jbd91 / snippet.php
Created January 18, 2021 23:25
Pantheon Avada broken CSS file issues
// This error occurred when transferring the Avada theme from an external host to pantheon. There was a MIME type error followed by a 404 on the homepage. I believe the random string pantheon uses for file struture differed from the other pages of the site.
Make sure WP_cache is off and added the addition if statement below to fix.
//define('WP_CACHE', true);
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
define('FS_METHOD', 'direct');
}
@jbd91
jbd91 / snippet.php
Created January 15, 2021 20:39
Hierarchial Mixitup Select Filter
<div class="filter-controls">
<div class="filter-controls__drop-down">
<select id="filterSelect">
<?php $hiterms = get_terms("dealer_locations", array("orderby" => "slug", "parent" => 0)); ?>
<?php foreach ($hiterms as $key => $hiterm) : ?>
<optgroup label="<?php echo $hiterm->name; ?>">
<?php $loterms = get_terms("dealer_locations", array("orderby" => "slug", "parent" => $hiterm->term_id)); ?>
<?php if ($loterms) : ?>
<?php foreach ($loterms as $key => $loterm) : ?>
<option data-filter=".<?php echo $loterm->slug; ?>"><?php echo $loterm->name; ?></option>
@jbd91
jbd91 / snippet.php
Created October 22, 2020 17:49
Security Headers
// Headers
if (!empty($_SERVER['HTTPS'])) {
function add_hsts_header($headers) {
$headers['strict-transport-security'] = 'max-age=31536000; includeSubDomains';
$headers['x-xss-protection'] = '1; mode=block';
$headers['x-content-type-options'] = 'nosniff';
$headers['x-frame-options'] = 'SAMEORIGIN';
$headers['referrer-policy'] = 'no-referrer-when-downgrade';
$headers['permissions-policy'] = 'geolocation=(); midi=(); notifications=(); push=(); sync-xhr=(); microphone=(); camera=(); magnetometer=(); gyroscope=(); vibrate=(); fullscreen=(); payment=()';
$headers['content-security-policy'] = 'default-src \'self\' \'unsafe-inline\' \'unsafe-eval\' https: data:';
@jbd91
jbd91 / snippet.txt
Created October 8, 2020 20:24
When Updraft Shits the Bed
Post in PHPmyadmin SQL tab when updraft does not correctly replace URLs
UPDATE wp_options SET option_value = replace(option_value, 'Old URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Old URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Old URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Old URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Old URL','New URL');
UPDATE wp_comments SET comment_content = replace(comment_content , 'Old URL','New URL');
UPDATE wp_posts SET post_content = replace(post_content, 'Old URL', 'New URL');
UPDATE wp_links SET link_image = replace(link_image, 'Old URL','New URL');
@jbd91
jbd91 / snippet.php
Created July 15, 2020 03:10
Set pagination posts per page
// functions.php
function custom_posts_per_page($query) {
if (is_home()) {
$query->set('posts_per_page', 8);
}
if (is_search()) {
$query->set('posts_per_page', -1);
}
if (is_archive()) {
$query->set('posts_per_page', 3);