Skip to content

Instantly share code, notes, and snippets.

View wpmark's full-sized avatar

Mark Wilkinson wpmark

View GitHub Profile
@wpmark
wpmark / before-after-shortcode-jquery
Created May 6, 2015 17:59
Before and After Shortcode jQuery
/**
* trigger the before and after images
*/
var beforeafter = function() {
/* get the preceeding element before the toggle button - hides all the after images */
$( '.before-after-toggle' ).prev().hide();
/* when the element with 'before-after-toggle' class is clicked */
$( '.before-after-toggle' ).click(function() {
@wpmark
wpmark / before-after-shortcode.php
Created May 6, 2015 17:53
Before and After Image Shortcode
<?php
/**
* function wpmark_add_before_after_shortcode()
* adds the shortcode to output the before and after image
*/
function wpmark_add_before_after_shortcode( $attr ) {
$attr = wp_parse_args(
$attr,
array(
@wpmark
wpmark / wp-dashboard-tabs.php
Created March 18, 2015 19:22
WordPress Dashboard Tabs
<?php
/***************************************************************
* Function wpbasis_dashboard_content()
* Pulls in the new dashboard page content from plugin file
***************************************************************/
function wpbasis_dashboard() {
/* check for a dashboard content file in the theme folder */
if( file_exists( STYLESHEETPATH . '/wpbasis/dashboard.php' ) ) {
/* load the dashboard content file from the theme folder */
get_template_part( 'wpbasis/dashboard', 'content' );
@wpmark
wpmark / wp_terms_query.php
Created January 21, 2015 17:03
Query Posts from Different Terms
<?php
/* get the terms for the taxonomy */
$terms = get_terms(
'taxonomy_name_here',
array(
'hide_empty' => false
)
);
@wpmark
wpmark / add-options-with-of-options.php
Created January 6, 2015 20:44
Add options with the of_options Options Framework Filter
/**
* function spts_site_options()
* sets the options which appear on the theme options page under
* appearance in the dashboard.
* for a detailed list of all the example options that can be used here see
* https://github.com/devinsays/options-framework-plugin/blob/master/options-check/options.php
* @param (array) $options an array of options to filter
* @filtered $of_options
* @return (array) $options to new array of options to use
*/
@wpmark
wpmark / options-framework-get-option.php
Created January 6, 2015 20:41
Options Framework Get Option
<?php
/**
* function wpmark_get_option()
* gets a theme options specificed from the options table
* @param (string) $name is the name of the options to get
* @param (string) $default is the default value to return if no value is present
*/
function wpmark_get_option( $name, $default = false ) {
/* get the options framework setting option */
@wpmark
wpmark / optionsframework_option_name.php
Created January 6, 2015 20:38
Overwrite the optionsframework_option_name function
<?php
/**
* function optionsframework_option_name()
*
* overwrites the function in the options framework which
* names the options value that stores all the options
*/
function optionsframework_option_name() {
/* get the options framework setting from options */
@wpmark
wpmark / wpbb-new-tax.php
Created December 23, 2014 15:50
Add new Taxonomies in WP Broadbean
<?php
/**
* function wpmark_add_wpbb_taxonmies()
* adds new taxonomies for jobs
* @param (array) $tax is the current array of taxonomies to add
* @return (array) $tax is the new array of modified taxonomies to add
*/
function wpmark_add_wpbb_taxonmies( $tax ) {
$tax[ 'country' ] = array(
@wpmark
wpmark / wpbb-new-fields.php
Created December 23, 2014 15:42
Add new Fields to WP Broadbean
<?php
/**
* function wpmark_add_wpbb_fields()
* @param (array) $fields is an array of current fields in the filter
* @return (array) $fields is the newly modified array of fields
*
* each array passed here should contain the following:
* array(
* 'name' => 'the label given to the field used in the admin',
* 'id' => 'meta key used when saving the data as post meta - should be prefixed with _wpbb_job_',
@wpmark
wpmark / nthpostclass.php
Created December 20, 2014 14:55
Add a Class to Every nth Post
<?php
/* setup a counter for the sections to use as class */
$counter = 0;
/* loop through each section */
foreach( $sections as $section ) {
/* increment the counter */
$counter++;