Skip to content

Instantly share code, notes, and snippets.

View crstauf's full-sized avatar
🤔
const THINKING = true;

Caleb Stauffer crstauf

🤔
const THINKING = true;
View GitHub Profile
@crstauf
crstauf / gist:5750836
Last active December 18, 2015 08:00 — forked from anonymous/gist:5750810
<?php
/**
* I want to get this query to also desplay events that are on the current day.
* Any Ideas on how I can do that?
* I added '>=' instead of '>' but it did not do anything.
* I assume time() does not work when comparing to date becuase the date starts at 0:00, so anytime on the current day will be past 0:00
*/
$args = array(
'post_type' => 'event',
function trash_past_events() {
$args = array(
'post_type' => 'event',
'posts_per_page' => -1,
'meta_key' => '_date',
'meta_value' => time(),
'meta_compare' => '<'
);
$events = new WP_Query($args);
if ($events->have_posts()) {
@crstauf
crstauf / test-QM-deprecated-notices.php
Last active July 30, 2016 07:26
mu-plugin used to confirm number of notices Query Monitor receives regarding deprecated function
add_action('init','stop_heartbeat',0);
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}
foreach (array(
'muplugins_loaded',
'registered_taxonomy',
'registered_post_type',
'plugins_loaded',
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
<?php
new enhance_wp_enqueues;
class enhance_wp_enqueues {
const VERSION = '0.0.2.3';
function __construct() {
add_filter( 'style_loader_tag', array( __CLASS__, 'filter_style_loader_tag' ), 9999999, 4 );
<?php
if (is_admin())
new more_post_thumbnails;
class more_post_thumbnails {
CONST version = '0.0.1';
CONST github = '';
new gravityforms_api_integration;
add_filter( 'gform_entry_meta', array( 'gravityforms_api_integration', 'filter_gform_entry_meta' ), 1, 2 );
class gravityforms_api_integration {
const gravityforms_api_integration_version = '0.0.1'; // https://gist.github.com/crstauf/9d63194eb6fd169b110b6301e8519ff3
const gforms_version = '1.9.18'; // Gravity Forms Version
const service_name = '';
@crstauf
crstauf / wordpress-postmeta-count-by-posttypes.sql
Last active January 10, 2017 22:44
SQL query to count total number of post meta rows per post type
SELECT
p.`post_type`,
COUNT( pm.`post_id` ) as postmeta_count
FROM `wp_posts` as p
JOIN `wp_postmeta` as pm
ON (p.`ID` = pm.`post_id`)
GROUP BY p.`post_type`
ORDER BY
postmeta_count DESC,
p.`post_type` ASC
.screen-reader-text {
clip: rect(1px, 1px, 1px, 1px);
clip-path: polygon(0px 0px, 0px 0px,0px 0px, 0px 0px);
position: absolute !important;
white-space: nowrap;
height: 1px;
width: 1px;
overflow: hidden;
}
@crstauf
crstauf / search-postmeta-fields.php
Created January 28, 2017 02:39
filter function to add postmeta field '_sections' to search
function posts_clauses( $clauses, $wp_query ) {
/* reference: https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/ */
if ( !$wp_query->is_search() )
return $clauses;
global $wpdb;
$clauses['join'] .=
' LEFT JOIN ' . $wpdb->postmeta .