Skip to content

Instantly share code, notes, and snippets.

Avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@DavidWells
DavidWells / Wordpress :: Add jQuery Script with enqueue
Created Dec 4, 2012
Wordpress :: Add jQuery Script with enqueue
View 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 Dec 4, 2012
WordPress :: Get All Post Meta
View get_all_post_meta.php
<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) {
View HTML-5-Page_defaults.html
<!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 Dec 10, 2012
WordPress :: View Queued Styles
View WordPress-Queued-Styles.php
<?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 Dec 12, 2012
jquery to add hover elements to every item on the page
View jQuery :: Add Visual Element Selector for Frontend
$(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')
}
});
});
View Javascript :: Get, Overline and Display Div Names on Page
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 Dec 13, 2012
jQuery :: Responsive Design Media Query Helper Function
View jquery.responsive-media-query-helper.js
<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 Dec 15, 2012
PHP :: Create a Dynamic Colored Transparent .png file
View Dynamic-Clear-PNG.php
<?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 Dec 20, 2012
WordPress :: Custom Additional Custom WYSIWYG Metabox
View wp-add-visual-editor-meta-box.php
<?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 Dec 24, 2012
WordPress :: GET Current Screen Data for conditional admin
View get_admin_screen_data.php
$screen = get_current_screen();
echo "<pre>";
print_r($screen);
echo "</pre>";