Skip to content

Instantly share code, notes, and snippets.

View DavidWells's full-sized avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@DavidWells
DavidWells / match-password-fields.js
Created December 29, 2012 02:15
jQuery :: Match Form Passwords and Alert User
function checkPasswordMatch() {
var password = $("#txtNewPassword").val();
var confirmPassword = $("#txtConfirmPassword").val();
if (password != confirmPassword)
$("#divCheckPasswordMatch").html("Passwords do not match!");
else
$("#divCheckPasswordMatch").html("Passwords match.");
}
@DavidWells
DavidWells / lp-background-settings.php
Created January 1, 2013 00:26
Landing Pages :: Config.php Background Settings
<?php
/* Template Background Settings
*
* Add this to your landing page template config.php file
* to have standard background options for your template.
*
*/
// Select Background Type Setting
$options = array('fullscreen'=>'Fullscreen Image', 'tile'=>'Tile Background Image', 'color' => 'Solid Color', 'repeat-x' => 'Repeat Image Horizontally', 'repeat-y' => 'Repeat Image Vertically', 'custom' => 'Custom CSS');
@DavidWells
DavidWells / javascript-query-string.js
Created January 16, 2013 00:55
JavaScript :: Regex trick: Parse a query string into an object
// http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
// JavaScript regex trick: Parse a query string into an object
var queryString = {};
anchor.href.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
// Usage
@DavidWells
DavidWells / add-default-meta-options.php
Created January 16, 2013 01:58
Landing Pages :: Add More Metabox Options to Default Template in functions.php
<?php
/* Add Options to Your Default Landing Page Template */
$plugins = get_option('active_plugins');
$required_plugin = 'landing-pages/landing-pages.php';
// Check if landing page plugin is active
if ( in_array( $required_plugin , $plugins ) ) {
// Check if in the admin section
if ( is_admin() ) {
// Add options to default lander
$options = array('widget'=>'Use Sidebar Widget','right'=>'Float Right', 'left'=>'Float Left','bottom'=>'Below Content','top'=>'Above Content');
@DavidWells
DavidWells / add-wordpress-settings-page.php
Created January 28, 2013 05:59
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@DavidWells
DavidWells / list-all-pages.php
Created February 12, 2013 08:27
WordPress:: Get All Pages and list in ul
<?php
// Get All Pages and List
$pages = get_pages();
foreach ( $pages as $page ): ?>
<li>
<a href="<?php echo get_page_link( $page->ID ) ?>" title=""><?php echo $page->post_title ?></a>
</li>
<?php endforeach; ?>
@DavidWells
DavidWells / random.rbg.js
Created February 15, 2013 00:30
jQuery:: Random RBG color generator
var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';
$('body').css("background",hue);
@DavidWells
DavidWells / dynamic-element-jquery.js
Created February 26, 2013 03:03
jQuery:: Dynamic Element Function
$(document).on("click", ".awesome-button", function(event) {
// do awesome and blow your mind
});
@DavidWells
DavidWells / conditional-admin.php
Created March 27, 2013 01:02
Conditional WordPress admin scripts
add_action('admin_enqueue_scripts','wpleads_admin_enqueue');
function wpleads_admin_enqueue($hook)
{
global $post;
//Admin enqueue - Landing Page CPT only
if ( isset($post) && 'wp-lead' == $post->post_type )
{
wp_enqueue_script('wp-lead-js', WPL_URL . 'js/admin.post-edit.js');
@DavidWells
DavidWells / print-wordpress-meta.php
Created May 11, 2013 20:19
Print all wordpress post meta on backend for debugging
//print all global fields for post
global $wpdb;
$data = array();
$wpdb->query("
SELECT `meta_key`, `meta_value`
FROM $wpdb->postmeta
WHERE `post_id` = ".$_GET['post']."
");
foreach($wpdb->last_result as $k => $v){