Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View joelworsham's full-sized avatar

Joel Worsham joelworsham

View GitHub Profile
<?php
/*
Plugin Name: test
*/
function test_filter( $test ) {
$current_day = intval( date( 'j' ) );
$change = false;
$new_array = array();
@joelworsham
joelworsham / how-to-dynamically-hide-a-widget.php
Last active August 29, 2015 14:07
How to dynamically hide a widget.Jaxon WP Meetup rules
<?php
// Don't change anything on this line EXCEPT for "hide_widget_pages". You can change that if you want, but you don't
// have to. But if you do, be sure to change it...
add_filter( 'widget_display_callback', 'hide_widget_pages', 10, 3 );
// ... here as well! And don't worry about changing anything else in this line.
function hide_widget_pages( $instance, $widget, $args ) {
// This is where you would enter the widget ID that you want to hide. Get this by using the Chrome inspector
@joelworsham
joelworsham / dynamic-scripts.php
Last active August 29, 2015 14:07
Used to easily and dynamically add scripts and styles into a WordPress application.
<?php
/**
* These are all of the files (both javascript and css) that needed to be registered and enqueued.
*
* In order to use this system, create an array similar to this example and create a new "DynamicScripts" class, passing
* that array into it (like done below). Your files should use the naming convention of "{filename}.css|js" for development
* files and "{filename}.min.css|js" for the minified production files (though feel free to modify the class below
* to suit your file naming convention needs).
*
@joelworsham
joelworsham / SassMeister-input.scss
Created October 21, 2014 12:43
Generated by SassMeister.com.
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// ----
@mixin icon($icon, $top, $left, $color, $atts: null) {
.icon-#{$icon} {
top: $top;
left: $left;
@joelworsham
joelworsham / Gruntfile.js
Last active August 29, 2015 14:09
A basic Gruntfile for a WordPress plugin
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
// Define the package
pkg: grunt.file.readJSON('package.json'),
@joelworsham
joelworsham / package.json
Created November 19, 2014 15:34
A basic package.json file for a WordPress plugin.
{
"name": "ProjectName",
"version": "1.0.0",
"description": "This plugin is incredible.",
"repository": {
"type": "git",
"url": "https://github.com/username/repository"
},
"author": "Thats you!",
"license": "GPLv2 or later",
@joelworsham
joelworsham / easy-register-post-type.php
Created January 2, 2015 16:57
Easy Register Post Type
<?php
/**
* Easy way to register a new post type!
*
* Example: easy_register_post_type( 'book', 'Book', 'Books', array( 'menu_icon' => 'dashicons-book' ) );
*
* @param string $name The name of the post type (not the label, must be lowercase and no spaces or dashes).
* @param string $label The label of the post type. This is public facing.
* @param string $label_plural The plural version of the label.
* @param array $_args An array of args to overwrite or add to the register_post_type() args.
@joelworsham
joelworsham / add_to_logic.php
Last active August 29, 2015 14:13
Render: Add options to the Logic shortcode.
<?php
/**
* First, we need to actually add our new options to each selectbox.
*/
add_filter( 'render_att_pre_loop', function( $atts, $code ) {
// Make sure we only do this for the Logic shortcode
if ( $code == 'render_logic' ) {
// Here's an option for the first argument
@joelworsham
joelworsham / extension-ideas.txt
Last active August 29, 2015 14:14
Render Extension Ideas
Extension:
Paypal
Shortcode Templates
Stylebox for TinyMCE
Custom shortcode creater (integrates directly into the modal, maybe)
Integration:
WooCommerce
Gravity Forms
Mini Loops
@joelworsham
joelworsham / dynamic-shortcode-scripts-pt1.php
Created January 30, 2015 16:43
Dynamic Shortcode Scripts
<?php
// Add our action
add_action( 'wp_enqueue_scripts', 'joelworsham_add_shortcode_styles' );
/**
* Dynamically calls scripts and styles based on the presence
* of shortcodes in the post content.
*/
function joelworsham_add_shortcode_styles() {