Skip to content

Instantly share code, notes, and snippets.

View azanebrain's full-sized avatar
🤖
Jamming with the console cowboys in cyberspace

AJ Zane azanebrain

🤖
Jamming with the console cowboys in cyberspace
View GitHub Profile
@azanebrain
azanebrain / get-contents-of-dir
Created January 19, 2014 20:19
A PHP Function to get an array of files within a directory
/* getContentsofDir v0.1
* This function gets the contents of a directory.
* It returns an array ($contentsArr) of strings for each item in the target directory
* $dir : The path of the directory to search in
* Attributes:
ignoreSystemFiles: Do not include system files in the array
Such as: ., .., DS_Store
num: How many entries to return. 0 will return all
ignore: Ignore this file(s)
ignoreType: Ignore this file type(s)
@azanebrain
azanebrain / php-read-dir
Created January 19, 2014 20:18
A PHP snippet that reads the files of a folder and returns the filename as an array
<?php
//vvvvvvvvvv *INCLUDE_FUNCTIONS vvvvvvvvvv
/* phpReadDir v0.1
* This function gets the contents of a directory.
* It returns an array ($contentsArr) of strings for each item in the target directory
* $dir : The path of the directory to search in
* Attributes:
ignoreSystemFiles: Do not include system files in the array
Such as: ., .., DS_Store
num: How many entries to return. 0 will return all
@azanebrain
azanebrain / hover-sprite
Last active January 3, 2016 19:48
Hover sprite icon with css
.hoverSpriteVert,
.hoverSpriteHoriz
background-position: 0 0
.hoverSpriteHoriz:hover
background-position: 100% 0
.hoverSpriteVert:hover
background-position: 0 100%
@azanebrain
azanebrain / wp-plugin-add-template
Created January 8, 2014 03:23
Add template files to wordpress plugin
//Template fallback
add_action("template_redirect", 'my_theme_redirect');
function my_theme_redirect() {
global $wp;
$plugindir = dirname( __FILE__ );
//A Specific Custom Post Type
if ($wp->query_vars["post_type"] == 'product') {
$templatefilename = 'single-product.php';
@azanebrain
azanebrain / disable-admin-bar
Created December 11, 2013 05:43
Don't allow subscribers to view the admin panels or the admin bar
/**
* Disable admin bar on the frontend of your website
* for subscribers.
*/
function themeblvd_disable_admin_bar() {
if( ! current_user_can('edit_posts') )
add_filter('show_admin_bar', '__return_false');
}
add_action( 'after_setup_theme', 'themeblvd_disable_admin_bar' );
@azanebrain
azanebrain / Create WordPress Users
Created June 29, 2013 23:16
Create WordPress Users with a function
//This would be good for setting up a stock dev environment. So instead of dumping in a DB, you would run an initializer with options
$users[0] = array(
'first_name' => 'Daniel',
'last_name' => 'Pataki',
'user_login' => 'danielpataki',
'user_pass' => 'mysupersecretpass',
'user_email' => '[email protected]',
'display_name' => 'Daniel',
'description' => 'Guitar-wielding Web developer',