Skip to content

Instantly share code, notes, and snippets.

View csaborio001's full-sized avatar

Christian Saborio csaborio001

View GitHub Profile
wp.domReady( function() {
//wp.blocks.getBlockTypes().forEach( function( blockType ){ console.log( blockType.name ); });
var core_variations = [
'core/archives',
'core/audio',
'core/avatar',
'core/block',
'core/block',
$countries = array(
'Afghanistan' => 'Afghanistan',
'Albania' => 'Albania',
'Algeria' => 'Algeria',
'American Samoa' => 'American Samoa',
'Andorra' => 'Andorra',
'Angola' => 'Angola',
'Anguilla' => 'Anguilla',
'Antarctica' => 'Antarctica',
'Antigua and Barbuda' => 'Antigua and Barbuda',
'use strict'
const puzzle = {
init: function (start) {
const nextBtn = document.getElementById('next');
nextBtn.dataset.current = start;
},
shuffle: function () {
const puzzContainer = document.getElementById('puzzle-container');
const nextBtn = document.getElementById('next');
WP_Rewrite Object
(
[permalink_structure] => /%postname%/
[use_trailing_slashes] => 1
[author_base] => author
[page_structure] => %pagename%
[search_base] => search
[comments_base] => comments
[pagination_base] => page
[comments_pagination_base] => comment-page
<?php
/**
* Proptotype
*/
namespace DoggieRescue\Notices;
class AdminNotice {
public static function process_messages() {
$notice = self::get_admin_message();
if ( ! empty( $notice ) && is_array( $notice ) ) {
@csaborio001
csaborio001 / meow-acf.php
Last active May 11, 2021 12:09
Using Meow Gallery to Display ACF Galleries
// Need to set the shortcut parameter in the post template where the gallery will be displayed.
[meow-gallery acf=1]
// Hook up to intercept the gallery shortcode and check for attribute.
add_filter(
'shortcode_atts_gallery',
function( $result, $defaults, $atts ) {
if ( 1== $atts['acf']) { // The ACF gallery MUST be set to return IDs for this to work!
<?php
/**
* Oxygen helper class to define when to display search results.
*
* @package scorpiotek-wordpress-utilities
*/
namespace ScorpioTek\WPUtil\Oxygen;
class SearchAssist {
@csaborio001
csaborio001 / EventQueryMod.php
Created March 9, 2021 02:11
Modifying Repeater Query from Oxygen for a Particular Custom Post Type
<?php
/**
* Modifies event listing.
*
* @package scorpiotek-wordpress-utilities
*
*/
namespace ScorpioTek\WPUtil\Events;
<?php
function( $query ) use ( $custom_post_type_name ) {
if ( ! is_admin() && $query->is_main_query() ) {
if ( ! empty( $custom_post_type_name) && $query->is_post_type_archive( $custom_post_type_name ) ) {
$date_sydney_now = ( new \DateTime( 'now', new \DateTimeZone( 'Australia/Sydney' ) ) )->format('Ymd');
/** Default to upcoming events. */
$compare = '>=';
if ( 'true' === $_GET['archive'] ) {
/** We need to get everything older than today. */
<?php
add_action( 'wp_login', 'wppb_toolbox_count_user_logins', 20, 2 );
function wppb_toolbox_count_user_logins( $user_login, $user ) {
if ( empty($user->ID) ) return;
$now = new DateTime( 'now', wp_timezone() );
update_user_meta( $user->ID, 'last_login_date', $now->format( 'Y-m-d H:i:s' ) );
}