Skip to content

Instantly share code, notes, and snippets.

View csaborio001's full-sized avatar

Christian Saborio csaborio001

View GitHub Profile
$args = array(
'post_type' => 'volunteer',
'posts_per_page' => '10',
'button_label' => 'Load More',
'button_loading_label' => 'Loading...',
'scroll' => 'false',
'post__in' => implode( ',', $unmatched_volunteers->posts ),
'repeater' => 'template_1',
'id' => 'participant_listing',
);
<?php
function compeer_content_types_init() {
/** Other functions hidden for brevity */
register_post_type( 'announcement', generate_compeer_cpt_options( 'announcement', 'announcements', 'announcements', 'dashicons-rss', true, true ) );
}
add_action( 'init', 'compeer_content_types_init' );
/**
<?php
/**
* Encapsulates the field creation of the announcement custom post type.
*
* @package compeer
* @since 0.0.6.3.3
*/
namespace Compeer;
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');
<?php
/**
* Logic activates / deactivates the plugin.
*
* @package compeer-matching-plugin
*/
namespace ScorpioTek;
class PluginActivation {
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
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;
$current_user = wp_get_current_user();
$current_user_roles = $current_user->roles;
if ( in_array( 'administrator', $current_user_roles, true ) ) {
// Show the Review.
}
<?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' ) );
}
<?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. */