Skip to content

Instantly share code, notes, and snippets.

View MZAWeb's full-sized avatar

Daniel Dvorkin MZAWeb

View GitHub Profile
@MZAWeb
MZAWeb / functions.php
Created August 14, 2013 20:32
Cambiar theme según sección
<?php
add_action( 'wp', 'elegir_theme' );
function elegir_theme() {
// Aca pones la condición que quieras verificar para decidir si cambiar el theme...
// Puede ser cualquier cosa, obviamente... is_page, is_tax, or cualquier cosa que necesites.
if ( is_page( 2 ) ) {
add_filter( 'stylesheet', 'cambiar_theme', 10, 1 );
add_filter( 'template', 'cambiar_theme', 10, 1 );
<?php
function custom_excerpt_length( $length ) {
$la_cantidad_de_caracteres_que_quieras = 20;
return $la_cantidad_de_caracteres_que_quieras;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
@MZAWeb
MZAWeb / composer.json
Created June 7, 2013 04:36
composer.json file to install WP_Mock and it's dependencies
{
"repositories": [
{
"type" : "package",
"package": {
"name" : "hamcrest/hamcrest",
"version" : "1.1.0",
"dist" : {
"type": "zip",
"url" : "https://hamcrest.googlecode.com/files/hamcrest-php-1.1.0.zip"
@MZAWeb
MZAWeb / gist:5685950
Created May 31, 2013 15:52
Fork bomb
:(){ :|:& };:
@MZAWeb
MZAWeb / gist:5467372
Last active December 16, 2015 16:59
Index: templates/default/bbpress-functions.php
===================================================================
--- templates/default/bbpress-functions.php (revision 4870)
+++ templates/default/bbpress-functions.php (working copy)
@@ -216,6 +216,10 @@
<?php if ( bbp_use_wp_editor() ) : ?>
jQuery(document).ready( function() {
+ /* Use backticks instead of <code> for the Code button in the editor */
+ edButtons[110] = new QTags.TagButton('code','code','`','`','c');
<?php
add_filter( 'pre_get_posts', 'cambia_queries', 10, 1 );
function cambia_queries( $query ) {
if ( $query->is_category( 31 ) && $query->is_main_query() ) {
$query->set( 'cat', array( 18, 31 ) );
$query->set( 'posts_per_page', - 1 );
}
return $query;
<?php
/* Plugin Name: Damn Vulnerable WordPress Plugin
* Description: Intentionally vulnerable plugin for plugin author education
* Version: 0.1
* Plugin URI: http://make.wordpress.org/plugins/2013/04/09/intentionally-vulnerable-plugin/
* Author: Jon Cave
* Author URI: http://joncave.co.uk
* License: GPLv2+
*
* DO NOT RUN THIS PLUGIN ON AN INTERNET ACCESSIBLE SITE
@MZAWeb
MZAWeb / gist:5122874
Last active December 14, 2015 17:29
Remove breadcrums for bbPress shortcodes
<?php
add_filter( 'the_content', 'remove_breadcrum', 0 );
add_filter( 'the_content', 'add_breadcrum', 1000 );
function remove_breadcrum( $content ) {
add_filter( 'bbp_no_breadcrumb', '__return_true' );
return $content;
}
function add_breadcrum( $content ) {
@MZAWeb
MZAWeb / gist:4590550
Created January 21, 2013 23:30
Maybe use current directory as a taskwarrior project filter
function t() {
project=$(basename `pwd`);
tp=( $(task _projects | grep $project) );
if [[ -n $tp ]]; then
task "$@" project:$project;
else
task "$@"
fi
}