Skip to content

Instantly share code, notes, and snippets.

@isotrope
isotrope / Get_Words.php
Last active March 5, 2020 19:11
A toe-dip into transients for Thierry
<?php
class Get_Words {
public static $transient_name = 'awesome_words_compiled';
public static $option_name = 'awesome_words_compiled';
public static $repeater_name_left = 'awesome_words_repeater_left';
public static $repeater_name_right = 'awesome_words_repeater_right';
<?php
$post_id = get_the_ID(); // ou whatever fonction pour avoir ton post ID
/*
* Les arrays sont très pratiques pour traverser des clés aussi
*
* Trouve les termes qui sont pareils dans les deux cas,
* on va concatener post_ ou live_ plus tard
<?php
$query_args = array(
'meta_query' => array(
// relation between time query and online query
'relation' => 'OR',
// time query
array(
// no conflict-safe mode (passing $ as an alias into our inner closure)
( function ( $ ) {
function acfFieldToGroupBg() {
// cache all our instances of the grab-this element which will be what we work with
var $jsGrabThis = $( '.js-grab-this' );
// none of them? why keep going. ABORT!
<?php
$query_object = new Wp_Query( array(
'showposts' => 5,
'post_type' => array( 'post' ),
'category_name' => 'videos',
'orderby' => 1,
) );
// The Loop
if ( $query_object->have_posts() ) {
<?php
global $wpdb;
$postmeta_to_compile = 'some_field';
$unique_values = $wpdb->get_col(
$wpdb->prepare(
"SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key=%s",
$postmeta_to_compile
)
);
@isotrope
isotrope / start-em-up.js
Last active May 16, 2019 12:07
Instantiating ACF Gutenberg block script instances.
$( function () {
// back-end instantiating
if ( window.acf ) {
// https://www.advancedcustomfields.com/resources/javascript-api/#functions-addaction
window.acf.addAction( 'render_block_preview/type=full-width-slider', function ( field ) {
const $sliderContainers = $( field ).find( '.block.full-width-slider' );
@isotrope
isotrope / quick-acf-fieldnames.js
Last active March 18, 2020 19:03
Smalll script to quickly gather ACF field names
/*
* Stick me in your console and run
*/
(function ( $ ) {
var fields = '',
php = '',
letAcfFormatTheValues = true,