Skip to content

Instantly share code, notes, and snippets.

View wpbullet's full-sized avatar
💭
Find me https://guides.wp-bullet.com/codeable-hire

WP Bullet wpbullet

💭
Find me https://guides.wp-bullet.com/codeable-hire
View GitHub Profile
cd wp-content/plugins
git clone https://github.com/Mindsize/mindsize-newrelic
cd mindsize-newrelic
composer install
wp plugin activate mindsize-newrelic --skip-plugins --skip-themes --allow-root
@wpbullet
wpbullet / clean-wpengine.sh
Created April 23, 2018 02:30
Clean WPEngine config and mu-plugins
# Clean WPEngine variables for use with local clone setups
# Author: Mike from https.//wp-bullet.com
# run this in the root folder where wp-config.php lives
# define wp-config.php path
WPCONFIGPATH="wp-config.php"
# clean up WPE variables from wp-config.php
sed -i '/wpe/d' ${WPCONFIGPATH}
sed -i '/WPE/d' ${WPCONFIGPATH}
@wpbullet
wpbullet / wp-profile-doctor.sh
Last active May 5, 2021 13:24
Autoinstall wp profile and doctor
#!/bin/bash
php -d memory_limit=-1 $(which wp) package install wp-cli/profile-command:@stable --allow-root
php -d memory_limit=-1 $(which wp) package install wp-cli/doctor-command:@stable --allow-root
function SetSearchArgs( $formattedArgs, $args = [] ) {
if( isset( $args[ 'post_type' ] ) && ( count( $args[ 'post_type' ] ) > 1 || gettype( $args[ 'post_type' ] ) === 'string' ) ) {
if( gettype( $args[ 'post_type' ] ) === 'array' ) {
$existing_query = $formattedArgs[ 'query' ];
unset( $formattedArgs[ 'query' ] );
$formattedArgs[ 'query' ][ 'function_score' ][ 'query' ] = $existing_query;
/**
* Exclude certain post types from nginx cache cleanup by Till Kruss
*
*/
function nginx_cache_excluded_custom_post_types( $post_types ) {
$post_types[] = 'shop_order';
$post_types[] = 'shop_order_refund';
$post_types[] = 'shop_subscription';
$post_types[] = 'ticket';
$post_types[] = 'ticket_reply';
@wpbullet
wpbullet / functions.php
Created September 9, 2017 03:24 — forked from schilke/functions.php
How to load CSS files asynchronously in WordPress (using Scott Jehl's "loadCSS")
<?php
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress"
// ...
// register and enqueue loadCSS
function load_scripts_and_styles() {
// register loadCSS
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false );
<?php
define('INBOUND_FAST_AJAX' , true );
/**
* Enable Fast Ajax
*/
add_filter( 'option_active_plugins', 'ajax_disable_plugins' );
function ajax_disable_plugins($plugins){
@wpbullet
wpbullet / get-user-role.php
Last active July 27, 2017 03:09 — forked from kellenmace/get-user-role.php
Get user role in WordPress
<?php
/*
* Get user's role
*
* If $user parameter is not provided, returns the current user's role.
* Only returns the user's first role, even if they have more than one.
* Returns false on failure.
*
* @param mixed $user User ID or object.
* @return string|bool The User's role, or false on failure.
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
@wpbullet
wpbullet / gist:83a573b6617c09a673116572061d8f46
Created July 9, 2017 21:54
disable-ajax-threshold-woocommerce.php
/ Begin Show 180 variations when loading page.
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 400;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
// END Show 180 variations when loading page.