Skip to content

Instantly share code, notes, and snippets.

View banderon's full-sized avatar

Gary Smirny banderon

  • TechCrunch
  • United States
View GitHub Profile
<?php
$build_time = filemtime( get_stylesheet_directory() . '/style.css' );
function set_enqueue_ver( $data ) use ( $build_time ) {
$data->default_version = $build_time;
}
add_action( 'wp_default_scripts', 'set_enqueue_ver' );
add_action( 'wp_default_styles', 'set_enqueue_ver' );
http://codepen.io/rglazebrook/pen/87e0eef911eef54857fdd559f4f6c738
@banderon
banderon / wp - user has role
Last active December 27, 2017 15:21
wordpress user has role check
<?php
/**
* Check if a role is assigned to a particular user
*
* @param string $role
* @param int $user_id
* @return bool
*/
function user_has_role( $role, $user_id = null ) {
if ( is_numeric( $user_id ) ) {
color = {
black: '\x1b[30m'
red: '\x1b[31m'
green: '\x1b[32m'
yellow: '\x1b[33m'
blue: '\x1b[34m'
magenta: '\x1b[35m'
cyan: '\x1b[36m'
white: '\x1b[37m'
}
functions.php
===============
function get_the_permalink(){
global $post;
return get_permalink( $post->ID );
}
add_filter( 'pre_get_posts', function($query){
if ( !is_search() ){
return $query;
}
if ( ($post_type = $query->get('post_type')) ) {
$query->set('post_types', $post_type);
}