Skip to content

Instantly share code, notes, and snippets.

View iamjoshellis's full-sized avatar
🏝️

Josh Ellis iamjoshellis

🏝️
View GitHub Profile
@iamjoshellis
iamjoshellis / bootstrap-js-loader-prepros.js
Last active August 29, 2015 14:25 — forked from planetoftheweb/bootstrap_prepros.js
Bootstrap js loader for Prepros
//@prepros-prepend "jquery.js"
//@prepros-prepend "affix.js"
//@prepros-prepend "transition.js"
//@prepros-prepend "tooltip.js"
//@prepros-prepend "alert.js"
//@prepros-prepend "button.js"
//@prepros-prepend "carousel.js"
//@prepros-prepend "collapse.js"
//@prepros-prepend "dropdown.js"
//@prepros-prepend "modal.js"
<?php
// Place this script in a page template and navigate to it. Script will correct counts for comments and categories.
include("wp-config.php");
if (!mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)) { die('Could not connect: ' . mysql_error()); }
if (!mysql_select_db(DB_NAME)) { die('Could not connect: ' . mysql_error()); }
$result = mysql_query("SELECT term_taxonomy_id FROM ".$table_prefix."term_taxonomy");
while ($row = mysql_fetch_array($result)) {
$term_taxonomy_id = $row['term_taxonomy_id'];
@iamjoshellis
iamjoshellis / tidy-strings.php
Last active March 23, 2016 14:46
Alphanumeric Hyphenated Strings (Not min)
/**
* Alphanumeric Hyphenated Strings
*/
function tidyString($string) {
//Lower case everything
$string = strtolower($string);
//Make alphanumeric (removes all other characters)
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean up multiple dashes or whitespaces
$string = preg_replace("/[\s-]+/", " ", $string);
@iamjoshellis
iamjoshellis / wordpress-list-enqueued-scripts.php
Created February 16, 2016 09:22
Wordpress - List all enqueued scripts
function list_enqueued_scripts() {
global $wp_scripts;
foreach( $wp_scripts->queue as $handle ) :
echo $handle . ', ';
endforeach;
}
add_action( 'wp_print_scripts', __NAMESPACE__ . '\\list_enqueued_scripts()' );
@iamjoshellis
iamjoshellis / overide-wp-page-numbers-capabilties.php
Last active February 25, 2016 10:08
Fixes WP Page Number capabilities roles.
// Remove the default plugin settings
remove_action('admin_menu', 'wp_page_numbers_add_to_menu');
// Overide the the settings with the correct capability 'administrator' instead of numerical value
function overide_wp_page_numbers_add_to_menu() {
add_submenu_page('options-general.php', 'WP Page Numbers Options', 'Page Numbers', 'administrator', __FILE__, 'wp_page_numbers_settings');
}
// Apply the settings
add_action('admin_menu', 'overide_wp_page_numbers_add_to_menu');
@iamjoshellis
iamjoshellis / wordpress-include-template-part.php
Created February 26, 2016 15:13
Pass variables to template parts in wordpress
include(locate_template('your-template-name.php'));
@iamjoshellis
iamjoshellis / jquery-scroll-to-href.js
Created March 23, 2016 15:14
Scroll to a thing based on the href attribute of another thing
$("a").click(function(e){
e.preventDefault();
var target = $(this).attr('href');
$('html, body').animate({
scrollTop: $(target).offset().top
}, 1000);
});
@iamjoshellis
iamjoshellis / formatted-phone-link.php
Last active April 14, 2016 11:04
Tidy a phone number and make it into a formatted 'tel' link
@iamjoshellis
iamjoshellis / index.html
Created October 24, 2016 17:42
SVG Animated Drum Kit (Play Me!)
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="300 300 1400 1400">
<g id="Drums">
<g>
<path id="Drum-Shadow" opacity="0.1" fill="#333333" d="M1626.6,1282.8c0,45.4-280.5,82.1-626.6,82.1
c-346,0-626.6-36.8-626.6-82.1c0-45.4,280.5-82.1,626.6-82.1C1346,1200.6,1626.6,1237.4,1626.6,1282.8z"/>
<g id="Snare">
<g id="Snare-Drum">
<rect x="1219" y="885" fill="#0BC1F8" stroke="#333333" stroke-width="8" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" width="223" height="110"/>
<line fill="none" stroke="#0891BA" stroke-width="8" stroke-miterlimit="10" x1="1438" y1="914" x2="1223" y2="914"/>