Skip to content

Instantly share code, notes, and snippets.

View mathetos's full-sized avatar
💭
Working on @impress-org Stuff

Matt Cromwell mathetos

💭
Working on @impress-org Stuff
View GitHub Profile
@mathetos
mathetos / Deregister This
Created July 9, 2013 22:03
How do I deregister the RevSlider?
<?php
$slider = new RevSlider();
$arrSliders = $slider->getArrSliders();
$addNewLink = self::getViewUrl(RevSliderAdmin::VIEW_SLIDER);
require self::getPathTemplate("sliders");
?>
@mathetos
mathetos / gist:8078647
Last active January 1, 2016 02:19
List WP Categories by First Letter
<?php
$args = array(
'orderby' => 'name',
'parent' => 0,
'order' => DESC
);
$categories = get_categories( $args );
$curr_letter = '';
foreach ( $categories as $category ) {
$this_letter = strtoupper(substr($category->name,0,1));
@mathetos
mathetos / gist:8078693
Created December 22, 2013 05:08
3 factor Featured Image Fallback in WordPress
/*
* This code allows your posts to have a fallback featured image based on your category.
* It requires manual upload of the featured images. In this case it assumed /category-images to have
* been created in the root WP install directory.
* It is based on this tutorial at WPBeginner:
* http://www.wpbeginner.com/wp-themes/set-fallback-featured-image-based-post-category-wordpress/
* The original tutorial assumed all categories have a featured image.
* This codes inserts a div (to be styled) when there is also no featured image for the category.
* Nathan Briggs was instrumental in implementation of the file_exists method.
*/
<?php
/**
* Optimize WooCommerce Scripts
* Updated for WooCommerce 2.0+
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
@mathetos
mathetos / plugin.php
Created May 20, 2014 03:12
FooBox V2 or Free check and notice
<?php
/*
* This checks whether either version of FooBox --
* Free or Premium -- is activated. If not, it throws
* An admin notification, only for users who can
* activate plugins.
*/
function fooboxnotpresent_admin_notice() {
if ( class_exists('Foobox_Free') || class_exists('fooboxV2')) {
@mathetos
mathetos / gist:4d80d5c7bf2d23fd2a7e
Created June 19, 2014 21:35
Targeting Mobile Devices
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
// Small script to detect mobile browsers and toggle the visibility of specified elements.
(function($){
var isMobile = function(_, ua){
_.Android = ua.match(/Android/i);
@mathetos
mathetos / gist:6c4d3dc77ee3591e0a74
Created July 22, 2014 04:45
Admin Enqueue Iris.js
<?php
function load_mc_iris() {
if (wp_script_is( 'iris', 'enqueued' )) {
return; // if it's already enqueued, don't enqueue it again.
} else { // since it's NOT enqueued, let's enqueue it
wp_enqueue_script(
'iris', //iris.js handle
admin_url( 'js/iris.min.js' ), //path to wordpress iris file
@mathetos
mathetos / custom_the_content.php
Last active July 17, 2017 09:53
Adding Custom Class to the_content
<?php
//Adding custom class to posts is easy with the post_class filter
add_filter('post_class', 'custom_content_class');
function custom_content_class($classes) {
$classes[] = 'custom_class';
return $classes;
}
@mathetos
mathetos / imagelens-image-class.php
Last active August 29, 2015 14:05
Change image class if meta field available
<?php
add_filter('get_image_tag_class', 'add_imagelens_frames', 0, 4);
function add_imagelens_frames($classes, $id) {
$singlelens = get_post_meta( $id, '_enable_lens', true );
if ($singlelens === 'imagelens-single') {
return $classes . ' ' . $singlelens;
} else {
@mathetos
mathetos / image-upload-field-custom-taxonomy
Created September 20, 2014 21:37
Add Image Upload Field to Custom Taxonomy
<?php
/* Add Image Upload to Series Taxonomy */
// Add Upload fields to "Add New Taxonomy" form
function add_series_image_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="series_image"><?php _e( 'Series Image:', 'journey' ); ?></label>