Skip to content

Instantly share code, notes, and snippets.

View bassscape's full-sized avatar

Peter Lugg bassscape

  • Adelaide, Australia
View GitHub Profile
@mattradford
mattradford / licence activation.php
Last active October 28, 2023 19:25
ACF5 Pro licence activation. Could be adapted for any other plugin that requires a licence key, but doesn't yet support defining it in wp-config. Fires on theme activation.
// Place this in wp-config
define( 'ACF_5_KEY', 'yourkeyhere' );
// Set ACF 5 license key on theme activation. Stick in your functions.php or equivalent.
function auto_set_license_keys() {
if ( ! get_option( 'acf_pro_license' ) && defined( 'ACF_5_KEY' ) ) {
$save = array(
'key' => ACF_5_KEY,
@salcode
salcode / .gitignore
Last active April 3, 2024 18:38
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@stevenslack
stevenslack / class-drop-walker-nav.php
Last active November 24, 2020 07:53
WordPress Walker Nav extended to add data attributes for Drop support
<?php
/**
* Extends WordPress nav menu by adding data attributes and
* markup for Drop by Chris Ferdinandi
*
* Version 6.1.1
*
* drop source: https://github.com/cferdinandi/drop
*/
@woogist
woogist / woocommerce-customer-order-xml-export-suite-custom-plugin.php
Last active November 8, 2019 13:50
WooCommerce Customer/Order XML Export Suite: Custom Plugin for changing the XML output
<?php
/**
* Plugin Name: WooCommerce Sample XML
* Plugin URI: http://www.skyverge.com/contact/
* Description: Customizes the WooCommerce Customer/Order XML Export Suite specifically for Sample
* Author: SkyVerge
* Author URI: http://www.skyverge.com
* Version: 1.0
*
* Copyright: (c) 2013 SkyVerge, Inc. (info@skyverge.com)
@jasongaylord
jasongaylord / IEUserAgentTest.html
Last active October 10, 2023 08:04
A sample JavaScript file to detect IE compatibility mode and version. This is not recommended unless absolutely needed as features should be detected instead.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing IE Compatibility Mode</title>
<script src="ieUserAgent.js" type="text/javascript"></script>
</head>
<body>
<div id="results">Results:</div>
<script type="text/javascript">
var val = "IE" + ieUserAgent.version;
@Cais
Cais / wpfa-login-form.php
Last active May 29, 2019 14:38
WPFA Login Form
<?php
/**
* WPFA Login Form
* Borrowed from the core login form and used with the shortcode 'bns_login'
* This allows for the 'bns_login' shortcode to accept all of the parameters
* of the `wp_login_form` function as the shortcode attributes.
*
* @package WPFA_Login_Form
* @since 1.0
*
@nerrad
nerrad / categorycptrewrite.php
Created October 28, 2012 17:52
Have category archive pages display only posts in a certain custom post type
/**
* This could be extrapolated and used for tags or any other taxonomy really.
*/
add_action('init', 'category_cpt_rewrites');
function category_cpt_rewrites() {
$custom_post_types = array('video', 'audio', 'photo', 'file'); //some example post types
foreach ( $custom_post_types as $post_type ) {
$rule = '^' . $post_type . '/category/(.+?)/?$';
@awshout
awshout / foundation4-topbar-menu.php
Last active August 19, 2023 02:44
WordPress Menu & Walker for ZURB's Foundation 4 Top Bar
<?php
add_theme_support('menus');
/**
* Register Menus
* http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
'top-bar-r' => 'Right Top Bar'
@ChromeOrange
ChromeOrange / functions.php
Created September 2, 2012 10:20
Add login / logout links to any menu and position it
<?php
/**
* Add login / logout links to any menu and position it
* Based On : http://www.viper007bond.com/2011/09/20/code-snippet-add-a-link-to-latest-post-to-wordpress-nav-menu/
*
* Instructions :
* 1 - Add this code to your theme functions file
* 2 - create a new custom menu item : http://cl.ly/image/092k303O3C2z DO NOT change this #loginlogout
* 3 - Position the menu item where ever you would like it to appear : http://cl.ly/image/0p00131v1L09
**/
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/