Skip to content

Instantly share code, notes, and snippets.

View DavidWells's full-sized avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@DavidWells
DavidWells / Wordpress :: Add jQuery Script with enqueue
Created December 4, 2012 01:34
Wordpress :: Add jQuery Script with enqueue
/** Add jquery script for responsive slider
This is for use with a child theme!
If not use: get_template_directory_uri() instead
*/
function fws_add_the_scripts() {
wp_enqueue_script(
'custom_script',
get_stylesheet_directory_uri() . '/js/responsiveslides.min.js',
array('jquery')
);
@DavidWells
DavidWells / get_all_post_meta.php
Created December 4, 2012 01:41
WordPress :: Get All Post Meta
<h3>Get All WordPress Post Meta</h3>
<?php $getPostCustom=get_post_custom(); // Get all the data ?>
<?php
foreach($getPostCustom as $name=>$value) {
echo "<strong>".$name."</strong>"." => ";
foreach($value as $nameAr=>$valueAr) {
@DavidWells
DavidWells / HTML-5-Page_defaults.html
Created December 9, 2012 05:16
HTML5 :: Page Defaults
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@DavidWells
DavidWells / WordPress-Queued-Styles.php
Created December 10, 2012 03:03
WordPress :: View Queued Styles
<?php
add_action('wp_head', 'debug_styles_queued');
function debug_styles_queued() {
global $wp_styles;
echo '<!--- Styles QUEUED'."\r\n";
foreach ( $wp_styles->queue as $styles ) {
echo "\r\nStyle: ".$styles."\r\n";
}
echo "\r\n--->";
@DavidWells
DavidWells / jQuery :: Add Visual Element Selector for Frontend
Created December 12, 2012 03:15
jquery to add hover elements to every item on the page
$(document).ready(function() {
$('head').append('<style type="text/css">.outline-element {outline: 1px solid #c00;}.outline-element-clicked {outline: 1px solid #0c0;}</style>');
$('body').bind('mouseover mouseout click', function(event) {
var $tgt = $(event.target);
if (!$tgt.closest('.syntax_hilite').length) {
$tgt.toggleClass(event.type == 'click' ? 'outline-element-clicked' : 'outline-element');
$('body').removeClass('outline-element-clicked')
}
});
});
javascript: var t = document.getElementsByTagName('div');
for (i = 0; i < t.length; i++) {
void(t[i].style.padding = '5px;');
b = t[i].id;
h = t[i].innerHTML;
void(t[i].innerHTML = '<p style=\'color:red;font-weight:bold;\'>' + b + '</p>' + h);
void(t[i].style.border = '2px solid red');
}
@DavidWells
DavidWells / jquery.responsive-media-query-helper.js
Created December 13, 2012 08:25
jQuery :: Responsive Design Media Query Helper Function
<script>
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$(function() {
@DavidWells
DavidWells / Dynamic-Clear-PNG.php
Created December 15, 2012 02:07
PHP :: Create a Dynamic Colored Transparent .png file
<?php
// file: image.php
// Dynamically Create a clear png for css background opacities
header("Content-type: image/png");
$hex_value = $_GET['hex'];
// Convert Hex to RGB Value
function HexToRGB($hex) {
$hex = ereg_replace("#", "", $hex);
$color = array();
@DavidWells
DavidWells / wp-add-visual-editor-meta-box.php
Created December 20, 2012 18:27
WordPress :: Custom Additional Custom WYSIWYG Metabox
<?php // Add additonal edit box:
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('Top Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
add_meta_box(WYSIWYG_META_BOX_ID, __('Top Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'page', 'normal');
add_meta_box(WYSIWYG_META_BOX_ID, __('Top Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'services-page', 'normal'); // add to custom post type
@DavidWells
DavidWells / get_admin_screen_data.php
Created December 24, 2012 01:29
WordPress :: GET Current Screen Data for conditional admin
$screen = get_current_screen();
echo "<pre>";
print_r($screen);
echo "</pre>";