Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Saborio csaborio001

View GitHub Profile
View countries-array.php
$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',
View puzzle.js
'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');
View output.php
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
View wordpress-notices-with-nonce.php
<?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
Using Meow Gallery to Display ACF Galleries
View meow-acf.php
// 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!
View oxygen-search-condition.php
<?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 Mar 9, 2021
Modifying Repeater Query from Oxygen for a Particular Custom Post Type
View EventQueryMod.php
<?php
/**
* Modifies event listing.
*
* @package scorpiotek-wordpress-utilities
*
*/
namespace ScorpioTek\WPUtil\Events;
View pre_query.php
<?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. */
View wppb_toolbox_count_user_logins.php
<?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' ) );
}
View only-admins.php
$current_user = wp_get_current_user();
$current_user_roles = $current_user->roles;
if ( in_array( 'administrator', $current_user_roles, true ) ) {
// Show the Review.
}