Skip to content

Instantly share code, notes, and snippets.

View benklocek's full-sized avatar

Ben Klocek benklocek

View GitHub Profile
@benklocek
benklocek / cpt-custom-messages.php
Last active September 16, 2022 13:02 — forked from thenbrent/gist:1625033
WordPress Custom Post Type Message
/**
* Replaces "Post" in the update messages for custom post types on the "Edit" post screen.
*
* For example, for a "Product" custom post type, "Post updated. View Post." becomes "Product updated. View Product".
*
* @param array $messages The default WordPress messages.
*/
function pico_custom_update_messages( $messages ) {
global $post, $post_ID;
<?php
add_filter('site_option_active_sitewide_plugins', 'modify_sitewide_plugins');
function modify_sitewide_plugins($value) {
global $current_blog;
if( $current_blog->blog_id == 83 ) {
unset($value['sendgrid-email-delivery-simplified/wpsendgrid.php']);
}
@benklocek
benklocek / gist:7206060
Last active November 14, 2018 15:35
Wordpress Functions: Bust cache, register and enqueue stylesheet
<?php
// cache bust, register, and enqueue main stylesheet
$cache_bust = '?'.filemtime( get_stylesheet_directory() . '/css/style.css');
wp_register_style( 'main-stylesheet', get_stylesheet_directory_uri() . '/css/style.css'.$cache_bust, array(), '', 'all' );
wp_enqueue_style( 'main-stylesheet' );
@benklocek
benklocek / unhook_recurring_events_community.php
Created May 30, 2017 23:47 — forked from GeoffEW/unhook_recurring_events_community.php
Removes the recurring events option from Community Events
<?php
/* Apply the following snippet in the functions.php file of your theme (without the PHP tag at the top) */
add_action( 'tribe_events_community_form', function() {
$event_form = Tribe__Events__Community__Main::instance()->form;
remove_action( 'tribe_events_date_display', array( $event_form, 'loadRecurrenceData' ) );
}, 5 );
<?php
/**
* Plugin Name: Author Meta Box only with authors
* Plugin URI: http://wordpress.stackexchange.com/questions/60429/stop-loading-collaborators-users-on-add-new-post-or-page
* Description:
* Author: Frank Bueltge
* Author URI: http://bueltge.de
* License: GPLv3
*/
add_action( 'admin_menu', 'fb_remove_author_meta_boxes' );
#Get the size of each table, ordered by largest to smallest
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOU+TABLE+NAME+HERE"
ORDER BY (data_length + index_length) DESC;
#Get the size of the entire DB
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
@benklocek
benklocek / functions.php
Last active March 22, 2016 15:37 — forked from zaerl/functions.php
Custom bbPress role names
function my_custom_roles( $role, $user_id ) {
if( $role == 'Keymaster' )
return 'Site Owner';
return $role;
}
add_filter( 'bbp_get_user_display_role', 'my_custom_roles', 10, 2 );
@benklocek
benklocek / beaver-builder-friendly.php
Created March 9, 2016 23:59 — forked from brentjett/beaver-builder-friendly.php
Making a Theme Beaver Builder Friendly
<?php
// I add a simple function to my functions.php that lets me do clean page-builder checks inside my template files.
// This is safe to include regardless of if bb-plugin is active or not. Won't trigger error.
function is_builder_layout() {
if (class_exists( 'FLBuilderModel' ) && FLBuilderModel::is_builder_enabled()) return true;
return false;
}
// Inside page.php I use is_builder_layout() to determine layout
if (is_builder_layout()) {
@benklocek
benklocek / plugin-class-demo.php
Created January 20, 2016 23:11 — forked from thefuxia/plugin-class-demo.php
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: GPL
* Text Domain: plugin_unique_name
@benklocek
benklocek / WordPress Config: Local to remote Constant Definition
Last active January 12, 2016 20:06
Wordpress Config: Local to remote Constant definition
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );