Skip to content

Instantly share code, notes, and snippets.

/**
* Add Oxygen's global colors to Gutenberg's backend editor palette
*/
function pavenum_gutenberg_oxygen_palette() {
$gutenberg_colors = [];
$oxy_colors = oxy_get_global_colors();
foreach( $oxy_colors['colors'] as $oxy_color) {
$gutenberg_colors[] = [ 'name' => $oxy_color['name'], 'slug' => 'color-' . $oxy_color['id'], 'color' => $oxy_color['value'] ];
@yankiara
yankiara / oxygen-repeater-dynamic-query.php
Last active September 6, 2023 19:25
Use dynamic queries with Oxygen's repeater
/* I'll put here different examples of dynamic query for Oxygen repeater :
* - Use one of the following repeater_dynamic_query definitions
* in code block just BEFORE the repeater
* - Set the repeater custom query settings : post type, number of posts, order...
* - Add the remove_action in a code block AFTER the repeater
*/
/****************************************************************************************************
* Display related posts for any CPT with taxonomy:
@yankiara
yankiara / wordpress-pagination-frontpage.php
Last active January 19, 2023 01:15
Allow Wordpress posts pagination on frontpage
<?php
/*
* Put following code BEFORE running the query (WP loop, Oxygen's repeater, etc.)
* What it does:
* - updates query with right page number variable to display the correct page
* - assigns the query to wp_query so that pagination links work
*/
function handle_pagination_on_frontpage( $query ) {
@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 / customization-plugin.php
Last active July 12, 2022 06:26
Oxygen Builder dummy theme used to increase plugins compatibility
/**
* Oxy-Dummy activation (thank you Sridhar Katakam)
* Paste this code snippet in your Oxygen's customization plugin
* or copy the file to /wp-content/plugins/customization-plugin/
*/
remove_filter( 'template', 'ct_oxygen_template_name' );
remove_filter( 'template_directory', 'ct_disable_theme_load', 1, 1 );
remove_filter( 'stylesheet_directory', 'ct_disable_theme_load', 1, 1 );
@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 / fluid-fonts-and-icons.css
Last active July 10, 2021 04:31
Fluid fonts and icons in CSS
body {
--base: 20;
--scale-headings: 1.44;
--scale-mobile: 0.7;
--scale-mobile-headings: 0.4;
--scale-icons: 1.4;
--min-viewport: 480;
--max-viewport: 1600;
--max-size: var(--base);
}