Skip to content

Instantly share code, notes, and snippets.

View MikeiLL's full-sized avatar

Mike iLL Kilmer MikeiLL

View GitHub Profile
/**
* Add & remove image sizes from the "Image Sizes" panel
*
* @since 1.0.0
* source: https://wpexplorer-themes.com/total/snippets/addremove-image-sizes/
*/
public static function cpt_image_sizes( $sizes ) {
// Remove "blog_post_full" image size
unset( $sizes['blog_post_full'] );
/**
* Generate single crumb html
*
* @since 3.6.0
*/
public static function get_crumb_html( $label, $link, $class = '', $rel = '' ) {
$scope = self::get_scope();
$class = $class ? ' class="'. esc_attr( $class ) .'"': '';
$rel = $rel ? ' rel="'. esc_attr( $rel ) .'"': '';
return '<span '. $scope . $class . $rel .'><a href="'. esc_url( $link ) .'" title="'. esc_attr( $label ) .'" itemprop="url" content="'. esc_url( $link ) .'"><span itemprop="title">'. esc_html( $label ) .'</span></a></span>';
#/usr/bin/bash
# Loop through jpg images and apply sips, mkbitmap and potrace
# http://potrace.sourceforge.net/
if [ $1 == '--help' ]; then
echo "Two optional parameters: filename and threshold. Otherwise vectorizes as .jpg in current dir.";
exit 1;
fi
function dumpdb()
{
# source https://stackoverflow.com/a/46042938/2223106
# source https://gist.github.com/spalladino/6d981f7b33f6e0afe6bb
local wkdir=`basename $PWD`
local container='echo ${wkdir}_my-wpdb_1'
docker exec ${container} mysqldump -uroot --password=password wordpress > backup.sql
}
function restoredb()
@MikeiLL
MikeiLL / taxonomy-breadcrumbs.php
Last active September 11, 2017 15:07
WordPress custom taxonomy breadcrumbs based on deepest term.
<?php
if( !function_exists( 'inspiry_get_breadcrumbs_items' ) ) :
/**
* Returns a array of breadcrumbs items
*
* @param $post_id int Post id
* @param $breadcrumbs_taxonomy string Taxonomy name
* @return mixed|void
*/
function inspiry_get_breadcrumbs_items( $post_id, $breadcrumbs_taxonomy ) {
@MikeiLL
MikeiLL / .htaccess
Created September 7, 2017 20:52 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
#!/usr/bin/python
"""
Compare two small csv files and create two new files, one with matches, the other which don't match.
I use it here to to get the names and email addresses from "personal" FB friends which are in a specific group.
It loops the group and pulls matches from the friends list, so that only group members whom are also found in the
friends list will be included in the GroupFriends list.
A hipper, more efficient approach is found here: https://stackoverflow.com/a/23090697/2223106
"""
@MikeiLL
MikeiLL / Useful WP Plugins
Last active April 26, 2018 16:21
Some go-to wordpress plugins
simply-show-hooks
contact-form-7
contact-form-7-honeypot
custom-post-type-ui
debug-bar
duplicate-post
get-tweets-in-php
tinymce-advanced
tailor
really-simple-csv-importer
<script>
// Get the parameter from the Query String
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
@MikeiLL
MikeiLL / composer-private-package-github-token.md
Created April 10, 2018 14:54 — forked from jeffersonmartin/composer-private-package-github-token.md
Generate a GitHub Personal Access Token for Private Composer Packages

Generate a GitHub Personal Access Token for Private Composer Packages

If you're trying to load a private repository with Composer/Laravel, we'll need to generate a GitHub Personal Access Token (similar to OAuth token) to access the repository during a composer install without entering credentials.

If you have used other Github packages from {my-org} before, you may be able to skip this step.

  1. Visit https://github.com/settings/tokens.

  2. Click Generate new token.