Skip to content

Instantly share code, notes, and snippets.

(function ($) {
'use strict';
function change_avatar_div( e ){
var field = $(e.currentTarget);
var acw_avatar_div = field.closest('.acw-thumb-size-wrap').find('.acw-avatar');
if( acw_avatar_div.length ) {
var icon = $( '.acw-icon', acw_avatar_div);
@dboutote
dboutote / bootstrap-link-pages.php
Created March 24, 2016 03:18
Bootstrap replacement for WordPress wp_link_pages() function.
@dboutote
dboutote / random-post-tags.php
Created April 15, 2016 02:52
[WordPress] Display random post tags.
<?php
$args = array(
'taxonomy' => 'post_tag',
'hide_empty' => 0
);
$tags = get_terms( $args );
$class_name = 'my-custom-class-name';
if ( ! empty( $tags ) && ! is_wp_error( $tags ) ) {
shuffle( $tags );
@dboutote
dboutote / hide-wp-status-links.php
Created April 19, 2016 17:54
[WordPress] Hide status link in the Posts table
@dboutote
dboutote / filter_acatw_allowed_taxonomies.php
Created August 27, 2016 15:35
Filtering Allowed Taxonomies in the Advanced Categories Widget
<?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 / shortcode.js
Created October 20, 2016 04:37
TinyMCE Shortcode Button for WordPress
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 / instagram-scraper.php
Created February 15, 2017 18:46
Quick and dirty Instagram scraper
<?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
<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 / rest-endpoints-filter.php
Last active June 14, 2022 16:47
Filtering the WP REST API endpoints.
<?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'
@dboutote
dboutote / list-height-toggle.js
Created January 13, 2018 23:12
Toggle the height of Unordered or Ordered Lists
(function($) {
$( document ).ready(function() {
var $sideNavs = $();
$.fn.toggleHeight = function( options ){
if( 'ontouchstart' in document ) return this;