Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Saborio csaborio001

View GitHub Profile
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.
}
View redirection.php
public static function external_user_redirect( $redirect_to, $requested_redirect_to, $user ) {
// Is there a user registered to check? Otherwise simply redirect.
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
// Does this user belong to the internal group?
if ( UserManagement::is_user_internal( $user ) ) {
// This will redirect them to WP-Admin.
return $redirect_to;
} elseif ( ! empty( $requested_redirect_to ) ) {
// External User with redirect.
return $requested_redirect_to;
View two_pros.sql
SELECT
*
FROM
wp_posts
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
LEFT JOIN (
SELECT
wp_posts.ID
FROM
wp_posts
View class-pluginactivation.php
<?php
/**
* Logic activates / deactivates the plugin.
*
* @package compeer-matching-plugin
*/
namespace ScorpioTek;
class PluginActivation {
View maps-an.js
var placeSearch, autocomplete;
var componentForm = {
postal_code: 'short_name'
};
jQuery(document).ready(function($){
$(document).on('can_embed_loaded', function() {
$('#postcode').prop('id', 'postal_code');
$('#form-street').prop('id', 'autocomplete');
$('#postal_code').prop('disabled', 'true');
View announcement-fields
<?php
/**
* Encapsulates the field creation of the announcement custom post type.
*
* @package compeer
* @since 0.0.6.3.3
*/
namespace Compeer;