Skip to content

Instantly share code, notes, and snippets.

Darrin dboutote

Block or report user

Report or block dboutote

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dboutote
dboutote / query-by-meta.php
Created Jun 11, 2018
Querying content by a meta key
View query-by-meta.php
<?php
$args = array(
'meta_key' => '_affiliatedCompany',
'meta_value' => $companyID,
'post_type' => 'article',
'posts_per_page' => 20,
);
$r = new WP_Query( $args );
@dboutote
dboutote / disable-custom-rest-routes.php
Created Apr 6, 2018
Filter the generated REST routes by filtering the show_in_rest arg in register_post_type function
View disable-custom-rest-routes.php
<?php
function dbdb_unset_rest_routes( $args, $post_type ) {
$allowed_post_types = array( 'page', 'post', 'company', 'job' );
$allowed_post_types = apply_filters( 'dbdb_unset_rest_routes_types', $allowed_post_types );
if( in_array( $post_type, $allowed_post_types ) ){
return $args;
} else {
$args['show_in_rest'] = 0;
@dboutote
dboutote / tect-bases-rewrite.php
Created Jan 25, 2018
Fix The Events Calendar 4.6 update for custom url slug
View tect-bases-rewrite.php
<?php
function filter_tribe_bases( $bases = array() ){
$rewriteSlug = sanitize_title( Tribe__Settings_Manager::get_option( ‘eventsSlug’, ‘events’ ) );
$bases[‘archive’] = array( $rewriteSlug );
return $bases;
}
add_filter( ‘tribe_events_rewrite_base_slugs’, ‘filter_tribe_bases’ );
@dboutote
dboutote / list-height-toggle.js
Created Jan 13, 2018
Toggle the height of Unordered or Ordered Lists
View list-height-toggle.js
(function($) {
$( document ).ready(function() {
var $sideNavs = $();
$.fn.toggleHeight = function( options ){
if( 'ontouchstart' in document ) return this;
@dboutote
dboutote / rest-endpoints-filter.php
Last active Apr 13, 2018
Filtering the WP REST API endpoints.
View rest-endpoints-filter.php
<?php
add_action( 'rest_endpoints', function( $endpoints ){
if( isset( $endpoints[ '/wp/v2/posts' ] ) ){
foreach( $endpoints[ '/wp/v2/posts' ] as &$post_endpoint ){
if( ! empty( $post_endpoint[ 'methods' ] ) && 'GET' == $post_endpoint[ 'methods' ] ){
$post_endpoint[ 'args' ][ 'type' ] = array(
'description' => 'Post types',
'type' => 'array',
'required' => false,
'default' => 'post'
View get-posts.php
<ul>
<?php
global $post;
$args = array( 'numberposts' => 5, 'post_type' => 'article' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
<?php the_excerpt();?>
@dboutote
dboutote / instagram-scraper.php
Created Feb 15, 2017
Quick and dirty Instagram scraper
View instagram-scraper.php
<?php
/**
* Instagram scraper
*
* Quick and dirty Instragram scraper for displaying a Instagram feed.
*
* Based on : https://gist.github.com/cosmocatalano/4544576
*
* @param string $username Instagram user account
@dboutote
dboutote / shortcode.js
Created Oct 20, 2016
TinyMCE Shortcode Button for WordPress
View shortcode.js
jQuery(document).ready(function($) {
tinymce.create( 'tinymce.plugins.dbdb_social_button', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished its initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
@dboutote
dboutote / filter_acatw_allowed_taxonomies.php
Created Aug 27, 2016
Filtering Allowed Taxonomies in the Advanced Categories Widget
View filter_acatw_allowed_taxonomies.php
<?php
/**
* This will ADD a custom taxonomy to the allowed taxonomies used by the widget
* */
function filter_acatw_allowed_taxonomies( $taxonomies ){
$taxonomies['project_category']= 'Project Categories';
return $taxonomies;
}
@dboutote
dboutote / hide-wp-status-links.php
Created Apr 19, 2016
[WordPress] Hide status link in the Posts table
View hide-wp-status-links.php
You can’t perform that action at this time.