Skip to content

Instantly share code, notes, and snippets.

View kjbenk's full-sized avatar

Kyle Benk kjbenk

  • PMC
  • Vermont
View GitHub Profile
@kjbenk
kjbenk / uninstall.php
Created April 27, 2014 16:42
WordPress plugin general uninstall.php
<?php
/* if uninstall not called from WordPress exit */
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit ();
/* Delete all existence of this plugin */
global $wpdb;
@kjbenk
kjbenk / custom_field_dropdown.php
Created August 4, 2014 19:25
Custom Field Dropdown
<?php
global $wpdb;
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
WHERE meta_key NOT LIKE '\_%'
GROUP BY meta_key
ORDER BY meta_id DESC"
);
@kjbenk
kjbenk / functions.php
Created January 24, 2015 23:28
bbPress: Display topics to topic author or admin
<?php
add_action('pre_get_posts', 'wps_private_topics');
/**
* Only display topics to admins and the author of that topic
*
* @access public
* @param mixed $query
* @return void
*/
@kjbenk
kjbenk / widget-events.js
Created April 13, 2015 00:12
WordPress Widget Events
// Credit to https://core.trac.wordpress.org/ticket/19587
jQuery(document).ready(function($){
// 1. when dropped in
$('div.widgets-sortables').bind('sortstop',function(event,ui){
console.log('just dropped in');
});
// 2. do some stuff on load
console.log('onLoad');
// 3. on action
@kjbenk
kjbenk / selectize-dropdown-colors.js
Last active November 27, 2017 14:50
Selectize Dropdown Background Colors
jQuery(document).ready(function($) {
$('.selectize').selectize({
plugins: ['drag_drop', 'remove_button'],
valueField: 'hex',
labelField: 'name',
searchField: 'name',
options: [
{hex: '#61BD6D', name: 'Fern'},
{hex: '#1ABC9C', name: 'Mountain Meadow'},
{hex: '#54ACD2', name: 'Picton Blue'},
@kjbenk
kjbenk / post-serach-filter.php
Last active August 29, 2015 14:20
WordPress post_search filter
<?php
// Add our custom filter
add_filter( 'posts_search', 'filter_search', 1, 2);
$posts_query = new WP_Query;
$posts = $posts_query->query($post_args);
// Remove our custom filter
@kjbenk
kjbenk / purge_transients.php
Last active November 20, 2021 15:28
WordPress - Purge All Expired Transients
<?php
// Schedule the CRON Job to purge all expired transients
if (!wp_next_scheduled('purge_popup_transients_cron')) {
/**
* wp_schedule_event
*
* @param - When to start the CRON job
@kjbenk
kjbenk / bbp-noreply.php
Created May 18, 2015 12:20
bbPress no-reply email change
<?php
add_filter('bbp_get_do_not_reply_address','my_bbp_no_reply_email');
function my_bbp_no_reply_email(){
return 'yournewemail@example.com';
}
@kjbenk
kjbenk / readable-number.php
Created June 16, 2015 16:11
Readable Number
<?php
/**
* Outputs a readable number
*
* @access public
* @static
* @param mixed $n
* @return void
*/
function readable_number($n) {
@kjbenk
kjbenk / code-canyon-verify-purchase.php
Created June 17, 2015 21:38
Code Canyon Verify Purchase
<?php
/**
* Creates a license code from verifing that the user purchased through Code Canyon
*
* @access public
* @static
* @return void
*/
static function create_license() {