Skip to content

Instantly share code, notes, and snippets.

View kopepasah's full-sized avatar
🤖
Solving problems with bots.

Justin Kopepasah kopepasah

🤖
Solving problems with bots.
View GitHub Profile
@kopepasah
kopepasah / custom-extension-directory.php
Created February 13, 2013 00:21
A simple filter that allows us to change the extension directory within Builder.
<?php
function custom_extension_directory() {
$directories = array(
get_stylesheet_directory() . '/extensions',
);
return $directories;
}
add_filter( 'builder_get_extension_directories', 'custom_extension_directory' );
@kopepasah
kopepasah / posts-to-articles.php
Created March 26, 2013 15:22
This gist was "forked" from Eric Mann (https://gist.github.com/ericmann/5245768).
<?php
/**
* Rename 'posts' to 'articles'
*/
function posts_to_articles( $translated ) {
$words = array(
// 'word to translate' = > 'translation'
'Posts' => 'Articles',
'Post' => 'Article',
@kopepasah
kopepasah / list-directory-files.php
Last active December 19, 2015 22:09
This is will list the files with in a directory, including files within subdirectories. The output is a MediaWiki format list of the files grouped together by similar parts.
<?php
function list_directory_files( $directory ) {
$files = array_diff( scandir( $directory ), array( '.', '..', 'list-files.php', '.DS_Store' ) );
foreach ( $files as $file ) {
if ( dirname( __FILE__ ) == $directory ) {
if ( is_dir( $directory . '/' . $file ) ) {
$folder = $file . '.php';
}
if ( $folder != $file ) {
<?php
header('Content-Type: text/plain');
// $file = $argv[1];
$file = '';
$hook_pattern = "|" . preg_quote( '<?php do_action(', '/') . "(.*?);|";
$api_pattern = "|" . preg_quote( '<?php it_exchange(' ) . "(.*?);|";
$contents = file_get_contents( dirname( __FILE__ ) . '/' . $file );
@kopepasah
kopepasah / remove-yahoo-bar.css
Created August 23, 2013 05:41
Adding this code to your custom styles for browser will remove the new annoying Yahoo bar on Flickr. You hate it, I hate it, let's remove it.
body.with-eyebrow > #global-nav {
top: 0 !important;
}
body.with-eyebrow > #main > .subnav-refresh {
margin-top: 0 !important;
}
body.with-eyebrow > #eyebrow {
display: none !important;
}
@kopepasah
kopepasah / find-duplicate-hooks.php
Last active December 23, 2015 22:19
Needed a way to list all the theme hooks in iThemes Exchange templates. Output is structured for Mediawiki, but can be modified to suit your needs.
<?php
$GLOBALS['hooks'] = array();
$GLOBALS['duplicates'] = array();
function list_theme_hooks( $directory ) {
global $hooks, $duplicates;
$files = array_diff( scandir( $directory ), array( '.', '..', '_list-files.php', '_list-hooks.php', '_get-contents.php', '.DS_Store', 'nonce.php', '_list-hooks-duplicates.php' ) );
@kopepasah
kopepasah / list-functions.php
Created September 27, 2013 14:52
Much like the other lists I created here, this will list Exchange functions.
<?php
$GLOBALS['functions'] = array();
function list_theme_functions( $directory ) {
global $functions;
$files = array_diff( scandir( $directory ), array( '.', '..', '_list-files.php', '_list-hooks.php', '_get-contents.php', '.DS_Store', 'nonce.php', '_list-hooks-duplicates.php', '_list-functions.php' ) );
foreach ( $files as $file ) {
@kopepasah
kopepasah / compile-less.bash
Last active December 25, 2015 07:39
This function will compile style.less into style.css while converting the two spaces before the property into a tab. In addition, any comments that start with /** - will get a line inserted before that comment.
function compile-less() {
lessc style.less | sed -E 's/\ (.*): (.*);/ \1: \2;/;s/(\/\*\* -)/\
\1/' > style.css
}
@kopepasah
kopepasah / draw-names.php
Created December 1, 2013 19:04
A simple function for mimicking drawing names from a hat.
<?php
function draw_names_from_hat( $names = array(), $couples = false ) {
$hat = $names;
foreach ( $names as $key => $name ) {
$pick = array_rand( $hat );
if ( $name == $hat[$pick] ) {
unset( $hat[$pick] );
@kopepasah
kopepasah / menu-output.css
Last active January 1, 2016 13:49
This it the last unordered list menu CSS you will ever have to write.
.menu {
padding-left: 0;
padding-right: 0;
margin-left: 0;
margin-right: 0;
list-style: none;
z-index: 999;
}
.menu li {
display: inline-block;