Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / dynnamic-style.php
Created January 30, 2015 08:57
Enqueue a dynamic style
<?php
add_action( 'wp_enqueue_scripts', 'dolly_load_styles' );
function dolly_load_styles() {
$css_url = add_query_arg( 'dolly-styles', 'true', home_url() );
wp_enqueue_style( 'dolly-styles', $css_url );
}
@igmoweb
igmoweb / dolly-dynamic.php
Last active August 29, 2015 14:14
Generate dynamic CSS stylesheet
<?php
add_action( 'plugins_loaded', 'dolly_generate_css_file' );
function dolly_generate_css_file() {
if ( isset( $_GET['dolly-styles'] ) && $_GET['dolly-styles'] === 'true' ) {
// "Engañar la cabecera"
// Generar aquí el CSS
exit;
}
}
@igmoweb
igmoweb / dolly-dynamic.php
Created January 30, 2015 09:17
Generate dynamic CSS
<?php
add_action( 'plugins_loaded', 'dolly_generate_css_file' );
function dolly_generate_css_file() {
if ( isset( $_GET['dolly-styles'] ) && $_GET['dolly-styles'] === 'true' ) {
header( 'Content-type: text/css' );
$options = get_option( 'dolly-options' );
?>
.mi-clase {
background:<?php echo $options['background-color']; ?>;
@igmoweb
igmoweb / locations.js
Created February 26, 2015 13:32
locations.js
jQuery(document).ready(function($) {
window.CalendarPlusAdmin = {
models: {},
views: {},
collections: {},
/*****************************************************************/
/** HELPERS **/
@igmoweb
igmoweb / arguments.js
Created March 16, 2015 20:28
Arguments
// extend the Function object to include a wrap instance method
Function.prototype.wrap = function( callback ) {
var original = this;
// Aquí arguments tiene un sólo elemento (la función anónima que se pasa a speak)
console.log(arguments);
return function() {
// Aquí arguments tiene 23 elementos (¿Por qué?). Son 'Mary' y 'Kate'
// Si estamos en una función anónima sin parámetros,¿No debería estar vacío?
console.log(arguments);
@igmoweb
igmoweb / conti.php
Created March 17, 2015 13:43
conti
<?php
function media_files_tools_load_js(){
wp_enqueue_media();
wp_enqueue_script('media_files_tools_load_js' , "/" . PLUGINDIR . '/media-files-tools/js/uploader.js' , array('jquery'),'2.0');
$object = array(
'conti' => __( 'John Conti', 'conti' ),
'my_string' => __( 'My String', 'conti' )
);
@igmoweb
igmoweb / uploader.js
Created March 17, 2015 13:49
uploader.js
// Esto es lo que crea wp_localize_script ( no lo tienes que poner en tu fichero):
media_files_i18n = {
conti: 'John Conti', // O su versión traducida, si la hay
my_string: 'My String' // O su versión traducida, si la hay
};
// Y ahora, dentrode uploader.js, simplemente puedes usar:
var my_name = media_files_i18n.conti
@igmoweb
igmoweb / the-category.php
Created June 21, 2015 19:06
alex the category
<?php
/**
* En lugar de usaar the_category( ' | ' ), usa alex_the_category( ' | ' )
* Añadee una clase CSS a cada link en la lista. Si tu categoría se llama "Mi Categoría",
* la clase será "cat-mi-categoria"
*
* Si no le metes el parámetro separator, va a salir feo.
*/
function alex_the_category( $separator = '' ) {
global $wp_rewrite;
@igmoweb
igmoweb / posts-list.php
Created June 23, 2015 17:30
posts-list-shortcode
<?php
add_shortcode( 'posts-list', 'ignacio_posts_list_shortcode' );
function ignacio_posts_list_shortcode( $atts ) {
$defaults = array(
'items' => 3
);
$atts = wp_parse_args( $atts, $defaults );
#!/bin/bash
BROWSER_PATH='open /Applications/Google\ Chrome.app'
if [[ $# -eq 0 ]] ; then
echo "Please enter a version number:"
read VERSION
else
VERSION=$1
fi