This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function create_faq_schema($content) { | |
// get the bloocks | |
global $post; | |
$blocks = parse_blocks( $post->post_content ); | |
// create arrays to store our questions | |
$faq = array(); | |
$questions = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elements = document.querySelectorAll('.className'); | |
elements.forEach(element => { | |
element.addEventListener('click', () => { | |
elements.forEach(sibling => sibling.classList.remove('active')); | |
element.classList.toggle('active'); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// terms that match the tax archives heierarchy | |
// show only parent terms in parent archives | |
// show only child terms in child archives | |
function custom_get_terms() { | |
// set the taxonomy | |
$tax_name = 'category'; | |
// is archive parent or child logic | |
$current_term = get_queried_object(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'body_class', function( $classes ) { | |
global $generate_elements; | |
foreach ( $generate_elements as $element => $data ) { | |
$element_title = 'gp-elem-' . strtolower(str_replace(' ', '-', get_the_title( $data['id'] ) )); | |
$classes[] = $element_title; | |
} | |
return $classes; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function db_add_widget_title_attr($params) { | |
// get the widget ID | |
$id = $params[0]['id']; | |
// get the widget name | |
$name = isset($params[0]['widget_name']) ? $params[0]['widget_name'] : ""; | |
// create a new aside html string with concatenated name + id title attribute | |
$title = '<aside title="' . $name . ' ' . $id . '"'; | |
// string replace the before widget opening tag | |
$params[0]['before_widget'] = str_replace( '<aside' , $title , $params[0]['before_widget'] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple mutation observer | |
// listen to group of elements with target-class | |
// for style change and toggle class on root HTML | |
var modals = document.querySelectorAll('.target-class'); | |
var rootHTML = document.getElementsByTagName( 'html' )[0]; | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutationRecord) { | |
// do something on observed style change |