Skip to content

Instantly share code, notes, and snippets.

View mestrewp's full-sized avatar

Mestre WordPress mestrewp

View GitHub Profile
@mestrewp
mestrewp / gist:2820511
Created May 28, 2012 18:29
WordPress: Redirect User at Login
<?php
add_filter('login_redirect', 'change_login_redirect', 10, 3 );
function change_login_redirect( $redirect_to, $request, $user) {
/*
using $user, you can change this on a per-user basis if you want
*/
// options.php is just a sample, change as needed
@mestrewp
mestrewp / gist:2820506
Created May 28, 2012 18:29
WordPress: Redirect User at Login
<?php
add_filter('login_redirect', 'change_login_redirect', 10, 3 );
function change_login_redirect( $redirect_to, $request, $user) {
/*
using $user, you can change this on a per-user basis if you want
*/
// options.php is just a sample, change as needed
@mestrewp
mestrewp / gist:2820502
Created May 28, 2012 18:28
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@mestrewp
mestrewp / create-new-user.php
Created May 28, 2012 18:28
WordPress: Create New User
<?php
/*
save as 'create-new-user.php'
upload to /wp-content/mu-plugins/
(you may have to create the 'mu-plugins' folder)
*/
add_action('init', 'create_new_user' );
function create_new_user() {
$un = 'username';
@mestrewp
mestrewp / gist:2820494
Created May 28, 2012 18:28
WordPress: Get prev/next post link
<?php
/*
* @param $prev_or_next string. Either 'prev' or 'next'
*
* @return string empty or HTML link to prev/next post
*/
function get_star_post_link( $prev_or_next ) {
$pon = $prev_or_next;
@mestrewp
mestrewp / gist:2820489
Created May 28, 2012 18:28
#wordpress - Removindo special chars from uploaded files
<?
add_filter( 'sanitize_file_name_chars', 'add_chars_to_filter', 10, 2 );
function add_chars_to_filter ( $special_chars, $filename_raw ) {
$special_chars[] = 'e';
return $special_chars;
}
?>
@mestrewp
mestrewp / gist:2820487
Created May 28, 2012 18:28
Pegando a URL do tumbnail
<?php
/* coloque este código dentro de um loop */
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id);
$image_url = $image_url[0];
?>
@mestrewp
mestrewp / gist:2820485
Created May 28, 2012 18:28
Como mudar o texto "POST" para "ARTIGOS"
add_filter('gettext', 'change_post_to_article');
add_filter('ngettext', 'change_post_to_article');
function change_post_to_article($translated) {
$translated = str_ireplace('Post', 'Artigos', $translated);
return $translated;
}
@mestrewp
mestrewp / gist:2820483
Created May 28, 2012 18:28
Como mudar o texto "POST" para "ARTIGOS"
add_filter('gettext', 'change_post_to_article');
add_filter('ngettext', 'change_post_to_article');
function change_post_to_article($translated) {
$translated = str_ireplace('Post', 'Artigos', $translated);
return $translated;
}
@mestrewp
mestrewp / gist:2820480
Created May 28, 2012 18:28
Taxonomy Sync
<?php
/*
Plugin Name: Taxonomy Sync
Version: 0.1
*/
 
// Taxonomies
$taxonomies_to_sync = array( 'an', 'array', 'of', 'taxonomies', 'to', 'sync' ); // Change These!
 
function ms_taxonomy_sync_add_menu() {