Skip to content

Instantly share code, notes, and snippets.

View hellerbenjamin's full-sized avatar

Benjamin Heller hellerbenjamin

View GitHub Profile
@chrisberkhout
chrisberkhout / .bash_profile
Created January 25, 2017 14:33
Git aliases taken from oh-my-zsh's git plugin and translated to bash
# git aliases - taken from oh-my-zsh's git plugin and translated to bash
# https://github.com/robbyrussell/oh-my-zsh/wiki/Cheatsheet#helpful-aliases-for-common-git-tasks
# https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/git/git.plugin.zsh
function git_current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
function git_current_repository() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
@EvanHerman
EvanHerman / wp-admin-table-markup.html
Last active August 8, 2020 07:32
WordPress Dashboard Admin Table Markup
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<th id="cb" class="manage-column column-cb check-column" scope="col"></th> <!-- this column contains checkboxes -->
<th id="columnname" class="manage-column column-columnname" scope="col"></th>
<th id="columnname" class="manage-column column-columnname num" scope="col"></th> <!-- "num" added because the column contains numbers -->
</tr>
</thead>
@mikaelz
mikaelz / remove-all-product-categories-tags.php
Created January 27, 2016 11:37
Remove all WooCommerce product categories and tags
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id
WHERE c.taxonomy = 'product_tag'");
$wpdb->query("DELETE a,c FROM wp_terms AS a
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id
@jchristopher
jchristopher / functions.php
Created December 18, 2015 13:22
SearchWP Regex Whitelist modification to allow strings with letters, numbers, hyphens, underscores, and periods
<?php
function my_searchwp_term_pattern_whitelist( $whitelist ) {
$my_whitelist = array(
"/(\\b[-_.]?[0-9a-zA-Z]+(?:[-_.]+[0-9a-zA-Z]+)+[-_.]?)/iu", // strings with letters, numbers, hyphens, underscores, and periods (no spaces)
);
// we want our pattern to be considered the most specific
// so that false positive matches do not interfere
$whitelist = array_merge( $my_whitelist, $whitelist );
@mattclements
mattclements / function.php
Last active April 16, 2024 17:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@einkoro
einkoro / acf_object_cache_fix.php
Last active July 23, 2018 13:08
Must-use plugin for WordPress to flush fields and post meta when using Advanced Custom Fields
<?php
/**
* Plugin Name: WP ACF Obj Cache Fix
* Plugin URI: http://bitpiston.com/
* Description: Fix for Advanced Custom Fields expiry with 3rd party Object Caches.
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.1.1
* Licence: BSD
*/
@macbleser
macbleser / wp-permissions-script
Created February 21, 2014 15:37
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # &lt;-- wordpress owner
WP_GROUP=changeme # &lt;-- wordpress group
WP_ROOT=/home/changeme # &lt;-- wordpress root directory
@eusonlito
eusonlito / foldersize.php
Last active July 25, 2023 12:50
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}