Skip to content

Instantly share code, notes, and snippets.

@yankiara
yankiara / defer-youtube-load-with-thumbnail.php
Created June 1, 2022 18:13
Defer loading of YouTube player
<?php
add_shortcode( 'pavenum_video', function( $atts ) {
$a = shortcode_atts( array(
'id' => '',
'ratio' => '',
/*'legend' => '',*/
'alt' => ''
), $atts );
@yankiara
yankiara / scroll-direction.js
Last active May 27, 2022 09:32
Scroll direction for sticky header/footer, etc.
window.addEventListener( 'DOMContentLoaded', ()=> {
const body = document.body,
scrollUp = "scroll-up",
scrollDown = "scroll-down",
offset = 0;
let lastScroll = window.pageYOffset;
if ( lastScroll > offset ) {
body.classList.add(scrollUp);
@yankiara
yankiara / oxygen-pro-menu-mobile-accessibility.js
Last active February 16, 2022 01:54
Oxygen ProMenu mobile accessibility
jQuery(document).ready(function($) {
// Initialize roles and aria attributes
$('.oxy-pro-menu-list .menu-item-has-children > a').attr('aria-haspopup','true').attr('aria-expanded','false');
$('.oxy-pro-menu-list .sub-menu').each(function(){
$(this).attr('aria-label', $(this).prev('a').text());
});
if ( $('.oxy-pro-menu-mobile-open-icon').css('display') == 'none' ) {
@yankiara
yankiara / oxygen-accordion-in-repeater.js
Created May 18, 2021 08:49
Use Oxygen Composite Accordion inside a repeater
//** Oxygen Composite Elements Settings Section **//
//** Edit the variables below to change the behavior of the element. **//
var closeOtherToggles = true; // Set this to true to close all other accordions when an accordion is expanded.
//** That's it, stop editing! **/
jQuery(document).ready(function(){
// Expand the content when row is clicked.
jQuery('body').on('click', '.oxel_accordion__row', function() {
@yankiara
yankiara / polylang-init.php
Created April 7, 2021 10:30
Polylang helpers and translatable strings
<?php
function plang() {
if ( function_exists('pll_current_language') )
return pll_current_language('slug');
else
return 'fr';
}
function phome() {
@yankiara
yankiara / fluentform-dynamic-dropdown.php
Last active November 10, 2022 03:51
Dynamically populate Fluentform dropdown select menu
<?php
add_filter('fluentform_rendering_field_data_select', function ($data, $form) {
if ($form->id != 10)
return $data;
if (\FluentForm\Framework\Helpers\ArrayHelper::get($data, 'attributes.name') != 'poste')
return $data;
$jobs = get_posts( [ 'post_type' => 'job' ] );
@yankiara
yankiara / oxygen-media-breakpoints-buttons.css
Last active January 28, 2021 20:53
Direct access to Oxygen's media breakpoints
.oxygen-media-query-box-wrapper {
position: static;
}
.oxygen-sidebar-currently-editing {
position: relative;
padding-bottom: 48px;
}
.oxygen-media-query-box {
display: none;
}
@yankiara
yankiara / remove-oxygen-imported-alt-text.php
Last active May 17, 2020 11:18
Remove imported alt text from Oxygen builder images in all posts/templates
<?php
/* WARNING: Advanced SQL table modifications, USE AT YOUR OWN RISKS */
/* IMPORTANT: You need to RESIGN SHORTCODES after executing this script */
global $wpdb;
$sql = 'SELECT meta_id, meta_value
FROM ' . $wpdb->postmeta . '
WHERE meta_key = "ct_builder_shortcodes"';
@yankiara
yankiara / gutenberg-columns-gap.css
Created April 13, 2020 10:55
Custom Gutenberg columns gap
:root {
--columns-gap: 1rem;
}
@media (min-width:782px) {
.wp-block-column:not(:first-child) {
margin-left: var(--columns-gap);
}
}
@media (min-width:600px) and (max-width:781px) {
@yankiara
yankiara / wp-defer-scripts.js
Created January 17, 2020 11:01
Defer enqueued JS scripts in Wordpress
add_filter( 'script_loader_tag', 'yankiara_defer_scripts', 10, 3 );
function yankiara_defer_scripts( $tag, $handle, $src ) {
$defer = array( 'script-handle-1', 'script-handle-2', 'script-handle-3' );
if ( in_array( $handle, $defer ) )
return '<script src="' . $src . '" defer="defer" type="text/javascript"></script>' . "\n";
return $tag;
}