Skip to content

Instantly share code, notes, and snippets.

View scrubmx's full-sized avatar
🏴‍☠️

Jorge González scrubmx

🏴‍☠️
View GitHub Profile
@scrubmx
scrubmx / image_size_by_post_type.php
Created April 12, 2013 16:09
Filter through wordpress and custom image sizes and remove unwanted fields from the array
add_filter( 'intermediate_image_sizes', function($sizes){
$type = get_post_type($_REQUEST['post_id']);
foreach($sizes as $key => $value){
if($type=='post_type' && $value != 'img_size_name'){
unset($sizes[$key]);
}
}
return $sizes;
});
@scrubmx
scrubmx / parseTwitterContent.php
Last active December 25, 2015 12:39
WordPress Helper Function:Convert url's @mentions and hashtags to links
function parseTwitterContent($string) {
$links = make_clickable($string);
$patterns = array("/@([a-zA-Z0-9_]+)/", "/#([a-zA-Z0-9_]+)/");
$replace = array(
"<a href='http://twitter.com/$1' target='_blank'>@$1</a>",
"<a href='http://twitter.com/#$1' target='_blank'>#$1</a>"
);
return preg_replace($patterns, $replace, $links);
}
@scrubmx
scrubmx / mkwp.sh
Created November 28, 2013 19:56
Install WordPress from the command line
#! /bin/bash
# Author: Jorge González (@scrubmx)
# https://github.com/scrubmx/Shell-Scripts/edit/master/mkwp.sh
#
function _remove_wp_folders(){
mv wordpress/* ./
rmdir wordpress
rm *.tar.gz
}
@scrubmx
scrubmx / qtranslate_terms.php
Created December 10, 2013 17:14
Translate WordPress custom taxonomy terms
add_action('admin_init', function(){
$args = array( 'public' => true, '_builtin' => false );
$taxonomies = get_taxonomies( $args,'object','and' );
foreach ( $taxonomies as $taxonomy ) {
add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');
add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');
}
@scrubmx
scrubmx / mkwp
Last active August 29, 2015 13:56
#! /bin/bash
# Author: @scrubmx
# https://github.com/scrubmx/
#
# WordPress installation name
if [[ $# -eq 0 ]] ; then
printf '\n\033[0;33m%s\033[0m' 'usage: '
printf '\033[0;32m%s\033[0m\n' 'mkwp name'
exit 0
if ( ! Modernizr.inputtypes.date ) {
$('input[type="date"]').datepicker({
dateFormat: 'yy-mm-dd'
});
}
/**
* Muestra el link a la ultima pagina del archive o page (con paginación)
* @return string HTML link with the proper link.
*/
function last_page_link()
{
global $wp_query;
$pagename = ($wp_query->query['pagename']) ? $wp_query->query['pagename'] : '';
window.Lightbox = {};
/**
* Contenedor donde se pone la imagen
* @type jQuery Wrapped DOM Element
*/
Lightbox.$container =$('#evento-uploads-lightbox');
/**
* Contador que indica el indice de la imagen que estamos viendo
body {
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
-webkit-transform: rotate(-180deg);
transform: rotate(-180deg);
}
@scrubmx
scrubmx / remove.js
Created April 9, 2014 20:01
Remove an element from an array
Array.prototype.remove = function (itemToRemove)
{
return this.filter(function (element) {
return element !== itemToRemove;
});
}