Skip to content

Instantly share code, notes, and snippets.

@yankiara
yankiara / jquery-replace-characters.js
Created January 8, 2020 15:11
Replace characters in jQuery
jQuery("h1, h2, h3, h4, h5, h6").each(function() {
jQuery(this).html(function(index, text) {
return text.replace( /([',.;:?!])/g, '<span class="special">$1</span>' );
});
});
@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 / 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;
}
@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 / 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 / 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 / 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 / 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 / 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 / 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' ) {