Skip to content

Instantly share code, notes, and snippets.

<?php wp_register_style( 'font_awesome_css', BOILERPLATE_URL . 'lib/fontawesome/css/all.css', FALSE, BOILERPLATE_VERSION, FALSE );
<?php // A slug for our plugin.
define( 'BOILERPLATE', 'Boilerplate' );
// Establish a value for plugin version to bust file caches.
define( 'BOILERPLATE_VERSION', '0.1' );
// A constant to define the paths to our plugin folders.
define( 'BOILERPLATE_FILE', __FILE__ );
define( 'BOILERPLATE_PATH', trailingslashit( plugin_dir_path( BOILERPLATE_FILE ) ) );
@scofennell
scofennell / script.js
Created January 10, 2018 14:28
LXB MCT JS
/**
* A global object with members that any of our jQuery plugins can use.
*
* @type {Object}
*/
var lxbMailChimpTools = {
/**
* Grab the value of a url var.
* @param {string} url Any url.
@scofennell
scofennell / jquery-plugins.js
Created January 10, 2018 14:27
LXB MCT jQuery
/**
* Our jQuery plugin for doing tablesorters.
*/
jQuery( document ).ready( function() {
var options = {};
jQuery( '.lxb_mailchimp_tools-tablesorter' ).lxbMctTableSorter( options );
});
<?php
function boolify( $var ) {
if( $var == 'true' ) {
$out = TRUE;
} elseif( $var == 'false' ) {
$out = FALSE;
} elseif( is_scalar( $var ) ) {
$out = $var;
} elseif( is_array( $var ) ) {
$out = array();
<?php
function my_array_booler( $var ) {
$out = array();
foreach( $var as $v ) {
if( $v === 'true' ) { $out[] = true; continue; }
if( $v === 'false' ) { $out[] = false; continue; }
$out[]= $v;
}
return $out;
}
<?php
function my_booler( $var ) {
if( $var === 'true' ) { $var = true; }
if( $var === 'false' ) { $var = false; }
return $var;
}
@scofennell
scofennell / version_compare.php
Created January 10, 2017 06:00
Compare two version numbers in php.
/**
* Determine if this asset needs to be updated.
*
* @return boolean Returns TRUE of the local version number
* is lower than the remote version number, else FALSE.
*/
function needs_update() {
$old_version = $this -> old_version;
@scofennell
scofennell / auth.php
Created December 23, 2016 05:34
Basic auth creds for Bitbucket
<?php
/**
* Authenticate all of our calls to Bitbucket, so that we can access private repos.
*
* @param array $args The current args for http requests.
* @param string $url The url to which the current http request is going.
* @return array $args, filtered to include BB basic auth.
*/
public function authenticate_http( $args, $url ) {
@scofennell
scofennell / pre_set_site_transient_update_plugins.php
Created December 22, 2016 23:42
Inject a Bitbucket repo into the WordPress updates UI.
<?php
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'set_plugin_transient' ) );
/**
* Inject our updates into core's list of updates.
*
* @param array $transient The existing list of assets that need an update.
* @return The list of assets that need an update, filtered.
*/