Skip to content

Instantly share code, notes, and snippets.

View michael-cannon's full-sized avatar

Michael Cannon michael-cannon

View GitHub Profile
@michael-cannon
michael-cannon / tw_remove_menu_pages.php
Created September 25, 2013 16:00
Remove custom post type submenu pages.
<?php
function tw_remove_menu_pages() {
// remove testimonials menu section
// remove_menu_page( 'edit.php?post_type=testimonials-widget' );
// remove categories
remove_submenu_page( 'edit.php?post_type=testimonials-widget', 'edit-tags.php?taxonomy=category&amp;post_type=testimonials-widget' );
// remove tags
@michael-cannon
michael-cannon / cbqe-learndash-lms.php
Last active February 3, 2021 12:02
LearnDash LMS for Custom Bulk/Quick Edit plugin
<?php
/**
* LearnDash LMS for Custom Bulk/Quick Edit plugin
*
* Download and unpack this Gist into your theme folder. Then include this script itself in your theme's `functions.php` file via…
*
* require_once get_stylesheet_directory() . '/35b676bb68eee50737f3/cbqe-learndash-lms.php';
*
* In WordPress Admin > Settings > Custom Bulk/Quick, configure your fields as needed, per below. If configuration updates are needed, either manually edit them or remove the current field configuration and click Save Changes for automatic updates.
*
@michael-cannon
michael-cannon / quick_edit.js
Last active April 15, 2020 01:25
Working WordPress bulk and quick edit example for a video custom post type. http://aihr.us/wordpress/working-examples-for-wordpress-bulk-and-quick-edit/
// @ref http://rachelcarden.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/
(function($) {
// we create a copy of the WP inline edit post function
var $wp_inline_edit = inlineEditPost.edit;
// and then we overwrite the function with our own code
inlineEditPost.edit = function( id ) {
// "call" the original WP edit function
// we don't want to leave WordPress hanging
$wp_inline_edit.apply( this, arguments );
<?php
/*
Plugin Name: Purge Transients
Description: Purge old transients
Version: 0.1
Author: Seebz
*/
@michael-cannon
michael-cannon / gist:4025132
Created November 6, 2012 14:48
Import image keywords as alternate text and tags in WordPress - makes tags available in attachments
function register_attachment_taxonomy() {
add_post_type_support('attachment', 'post_tag');
register_taxonomy_for_object_type('post_tag', 'attachment');
}
add_action('admin_init', 'register_attachment_taxonomy');
// add_filter('wp_read_image_metadata', 'read_all_image_metadata', '', 3);
function add_attachment_post_tags( $meta, $attachment_id ) {
@michael-cannon
michael-cannon / cbqe_menu_swapper.php
Last active December 25, 2015 13:59
Menu Swapper adaption for Custom Bulk/Quick Edit
<?php
/**
* Menu Swapper adaption for Custom Bulk/Quick Edit Premium
*
* @author Michael Cannon <mc@aihr.us>
* @ref http://wordpress.org/plugins/menu-swapper/
* @ref http://wordpress.org/plugins/custom-bulkquick-edit/
* @ref http://aihr.us/products/custom-bulkquick-edit-premium-wordpress-plugin/
*/
@michael-cannon
michael-cannon / cbqe_post_types_ignore.php
Created October 15, 2013 05:42
Filter `cbqe_post_types_ignore` Customize the ignored post_types array.
<?php
add_filter( 'cbqe_post_types_ignore', 'bhc_cbqe_post_types_ignore' );
function bhc_cbqe_post_types_ignore( $post_types ) {
foreach ( $post_types as $key => $value ) {
if ( 'page' == $value )
unset( $post_types[ $key ] );
}
return $post_types;
}
@michael-cannon
michael-cannon / twp_remove_donate.php
Created September 10, 2013 02:07
How do you remove the donate button from Testimonials Widget Premium?
<?php
add_action( 'plugins_loaded', 'twp_remove_donate', 25 );
function twp_remove_donate() {
global $TW_Premium;
remove_filter( 'plugin_row_meta', array( $TW_Premium, 'plugin_row_meta' ), 10, 2 );
}
?>
<?php
add_filter( 'cbqe_get_post_types_args', array( $this, 'get_post_types_args' ) );
public function get_post_types_args( $args ) {
$args[ 'exclude_from_search' ] = true;
return $args;
}
?>
<?php
add_filter( 'cbqe_quick_edit_custom_box_field', array( $this, 'quick_edit_custom_box_field' ), 10, 5 );
public function quick_edit_custom_box_field( $input, $field_type, $field_name, $options, $bulk_mode ) {
$result = '';
switch ( $field_type ) {
case 'date':
$result = '<input type="text" class="datepicker" name="' . $field_name . '" autocomplete="off" />';
break;