Skip to content

Instantly share code, notes, and snippets.

View KittenCodes's full-sized avatar

Phe Simmonds KittenCodes

View GitHub Profile
<?php
// Get the terms for the current post, using the Director taxonomy
$post_terms = get_the_terms( get_the_ID(), 'director' );
// If there are terms
if ($post_terms) {
// Create an empty array to add links to
$terms_list = array();
@KittenCodes
KittenCodes / polylang_condition.php
Last active October 4, 2023 00:02
Language Conditions for Oxygen
<?php
if( function_exists('oxygen_vsb_register_condition') && function_exists('pll_languages_list') ) {
$lang_list = pll_languages_list();
oxygen_vsb_register_condition(
//Condition Name
'Locale',
@KittenCodes
KittenCodes / wooco_parent_cats.php
Created February 4, 2022 19:12
PHP to show WooCo Parent Categories only
<?php
$terms = get_terms(['taxonomy' => 'product_cat', 'hide_empty' => false, 'parent' => 0]);
if ($terms)
{ ?>
<div id="-woo-product-categories-3-137" class="oxy-woo-product-categories oxy-woo-element">
<div class="woocommerce columns-4">
<ul class="products columns-4">
@KittenCodes
KittenCodes / event_condition.php
Last active January 22, 2022 20:18
Formation PRH Event Condition
<?php
function my_check_published_posts($type) {
$post_id = get_the_ID();
$acf_relationship_field = get_field('associations_formations_enseignants_et_evenements', $post_id);
if (empty($acf_relationship_field)) {
return "false";
@KittenCodes
KittenCodes / shapeDividerHeight.js
Created September 5, 2021 06:58
Change the height of Oxygen's Shape Dividers on scroll
var ready = (callback) => {
if (document.readyState != 'loading') callback();
else document.addEventListener('DOMContentLoaded', callback);
}
ready ( () => {
if (window.angular) { return; }
calcHeight();
})
@KittenCodes
KittenCodes / skip-spans.js
Last active June 29, 2021 19:13
Table of Contents - Skip Spans
jQuery(document).ready( function() {
// If we're in the builder, return and don't execute.
if( window.angular ) { return; }
// Skip spans
$("span").parent().attr("toc-skip", "1");
@KittenCodes
KittenCodes / close-modal-on-scroll.js
Created June 13, 2021 19:59
Close Modal when page scrolls
jQuery(document).ready(function() {
jQuery('a[href^="#"]').click(function() {
// smooth scroll
jQuery('html, body').animate({
scrollTop: $($.attr(this, 'href')).offset().top
}, 500);
// close modal
@KittenCodes
KittenCodes / code_Block_Above_Repeater_CSS.css
Last active March 22, 2023 19:00
Get images from ACF gallery in a Oxygen Repeater when the datasource is an ACF Repeater and add a lightbox to the Gallery
/*
* Add this to the CSS tab of the Code Block ABOVE the Repeater:
*/
.thumbnail img {
box-sizing: border-box;
border: 1px solid #ddd;
padding: 2px;
margin: 0 1% 15px 0;
width: 32.6667%;
@KittenCodes
KittenCodes / containsposts.php
Created May 5, 2021 10:34
Post Type Doesn't Contain Posts Condition
<?php
// Set your post type
$my_post_type = 'post';
if( function_exists('oxygen_vsb_register_condition') ) {
global $oxy_condition_operators;
oxygen_vsb_register_condition('Contains Posts', array('options'=>array('true', 'false'), 'custom'=>false), array('=='), 'search_has_results_callback', 'Query Has Posts');
@KittenCodes
KittenCodes / categories.css
Created March 27, 2021 10:43
Show a list of taxonomies using a Code Block
.category-post-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.category-post {
width: 33.33%;
}