Skip to content

Instantly share code, notes, and snippets.

View jimboobrien's full-sized avatar

Jimobrien jimboobrien

View GitHub Profile
@jimboobrien
jimboobrien / format-address.php
Created September 20, 2017 23:30 — forked from wpscholar/format-address.php
Format an address
<?php
/**
* Takes an array containing address elements and outputs a formatted address.
*/
function get_formatted_address( $address, $args = array() ) {
$before = isset( $args['before'] ) ? $args['before']: '';
$after = isset( $args['after'] ) ? $args['after']: '';
$format = ( isset( $args['format'] ) && 'block' == $args['format'] ) ? 'block': 'inline';
$formatted_address = '';
@jimboobrien
jimboobrien / downloadable-csv.php
Created September 20, 2017 23:29 — forked from wpscholar/downloadable-csv.php
Takes an array of data and create a csv file that will automatically download
<?php
/**
* Takes an array of data and creates a csv file that will automatically download
*/
function downloadable_csv( $data, $filename = 'data_csv' ){
/*
Sample Data Format:
array(
'headings' => array(),
@jimboobrien
jimboobrien / show-custom-post-types.php
Created September 20, 2017 23:29 — forked from wpscholar/show-custom-post-types.php
Show WordPress custom post types on the main blog and archive pages
<?php
/**
* Show WordPress custom post types on the main blog and archive pages
*
* @param WP_Query $query
**/
function show_custom_post_types( $query ) {
// Show all custom post types on main blog and archive pages
@jimboobrien
jimboobrien / is_plugin_active.php
Created September 20, 2017 23:29 — forked from wpscholar/is_plugin_active.php
Test if a WordPress plugin is active
<?php
/**
* Test if a WordPress plugin is active
*/
if ( is_plugin_active('plugin-directory/plugin-file.php') ) {
// the plugin is active
}
@jimboobrien
jimboobrien / customize-wp-login.php
Created September 20, 2017 23:29 — forked from wpscholar/customize-wp-login.php
Customize the login form in WordPress
<?php
/**
* Customize the login form in WordPress
* @author Micah Wood <[email protected]>
*/
/**
* Change the href for the logo link on login page to point to the main site
*/
add_filter( 'login_headerurl', 'change_login_headerurl' );
@jimboobrien
jimboobrien / jquery.keboardblock.js
Created September 20, 2017 23:29 — forked from wpscholar/jquery.keboardblock.js
Prevent the display of the pop-up keyboard on mobile devices
/**
* Using this snippet of code, just add the 'mobile-no-keyboard' class to your input or textarea
* to prevent the keyboard display on most mobile devices. You can just add the 'readonly' attribute,
* but there may be reasons you don't want to on a desktop/laptop machine.
*/
jQuery(document).ready(function($) {
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
$('input.mobile-no-keyboard, textarea.mobile-no-keyboard').attr( 'readonly', 'readonly' );
}
});
@jimboobrien
jimboobrien / singleton.class.php
Created September 20, 2017 23:29 — forked from wpscholar/singleton.class.php
An example of a singleton class
<?php
class singleton() {
private static $instance;
public static get_instance() {
return isset( self::$instance ) ? self::$instance : new self();
}
@jimboobrien
jimboobrien / jquery.external-links-new-window.js
Created September 20, 2017 23:28 — forked from wpscholar/jquery.external-links-new-window.js
Open all external links in a new window
@jimboobrien
jimboobrien / replace-wp-dashboard.php
Created September 20, 2017 23:28 — forked from wpscholar/replace-wp-dashboard.php
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/
@jimboobrien
jimboobrien / functions.php
Created September 20, 2017 23:28 — forked from wpscholar/functions.php
Enqueueing IE conditional stylesheets in WordPress the right way
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/