Skip to content

Instantly share code, notes, and snippets.

View gugaalves's full-sized avatar

Guga Alves gugaalves

View GitHub Profile
<?php
/*
Enviar e-mail para o administrador se houver posts para revisão
Dica do @GugaAlves: incluir link para a edição do post no admin, facilitando a vida do admin que receber este email.
Dica do Gustavo Bordoni (@webord): incluir na função o $post (objeto para WP_Query) para não ficar passando o $post_id a cada save.
Dica do Manoel Netto: Incluir a verificação "! wp_is_post_revision( $post )" para não enviar e-mail a cada auto save.
*/
@gugaalves
gugaalves / form-example.php
Last active August 29, 2015 14:04
Mailpoet Form - Chamada dos Js no Header de um tema WP e Form no Bootstrap + FontAwesome
<div class="row">
<div class="col-md-12 text-default">
<div class="newsletter widget_wysija_cont html_wysija">
<!-- Conferir o ID do form nas configurações do formulário, versão HTML -->
<div id="msg-form-wysija-html53c535dfee43f-1" class="wysija-msg ajax"></div>
<form id="form-wysija-html53c535dfee43f-1" method="post" action="#wysija" class="form-inline widget_wysija html_wysija">
<div class="col-md-3 col-sm-12 col-xs-12 form-group texto">
<i class="fa fa-envelope-o"></i> Assine nossa Newsletter
</div>
<div class="col-md-3 col-sm-6 col-xs-12 form-group wysija-paragraph">
@gugaalves
gugaalves / functions.php
Created July 17, 2014 23:30
Vendo qual arquivo do tema está rodando!
add_action('admin_bar_menu', 'show_template');
function show_template() {
global $template;
print_r($template);
}
@gugaalves
gugaalves / gist:5aceef8f08705aa0b073
Last active August 29, 2015 14:06
Remover ajuda do admin do WP
<?php
// Adicione esta função no functions.php
add_filter( 'contextual_help', 'mytheme_remove_help_tabs', 999, 3 );
function mytheme_remove_help_tabs($old_help, $screen_id, $screen){
$screen->remove_help_tabs();
return $old_help;
}
?>
@gugaalves
gugaalves / gist:3d4b72dc2f4d63d6ab42
Last active August 29, 2015 14:10
Redirecionar usuários
//Redirecionar o usuário após o login
function redirect_user_login() {
if (!current_user_can('manage_woocommerce')) {
$url = home_url(); //redirecionar pra home
return $url
}
}
add_filter( 'login_redirect', 'redirect_user_login', 10, 3 );
@gugaalves
gugaalves / gist:7c2ec2305a5e20eef00f
Last active January 18, 2016 20:20
Mostrar posts privados apenas pro autor deste post
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// the loop
$checkpost = get_post_status ( post->ID );
$author_id = the_author_meta('ID', post->ID);
$user_id = get_current_user_id();
$private = get_post_custom_values('private'); // read custom field
if ( $checkpost == 'private' && $user_id == $author_id ) {
// display private post, only logged user who had posted this post
} else {
@gugaalves
gugaalves / custom-login-styles.css
Last active November 14, 2022 12:16
WordPress - Customizing Login, Register and Lost Password pages
/*
*
* This CSS template will customize WordPress.org login pages:
*
* Login page: /wp-login.php
* Register page: /wp-login.php?action=register
* Lost Password page: /wp-login.php?action=lostpassword
*
* @site https://tudoparawp.com.br
* @author Guga Alves
// Add Shortcode
function button_category($post_id) {
$category = get_the_category( $post_id );
$return = '<a href="'. esc_url( get_category_link( $category[0]->term_id ) ) .'">Ver ' . $category[0]->cat_name . '</a>';
return $return;
}
add_shortcode( 'button-category', 'button_category' );
@gugaalves
gugaalves / tooltip.php
Last active February 11, 2020 20:23
[Plugin] TheEvents Calendar - Show default feature inside the tooltip if the event doesn't have a featured image (for monthly view only)
<?php
/**
* Please see single-event.php in this directory for detailed instructions on how to use and modify these templates.
*
* Override this template in your own theme by creating a file at:
*
* [your-theme]/tribe-events/month/tooltip.php
* @version 4.6.21
*/
?>
@gugaalves
gugaalves / functions.php
Last active February 11, 2020 19:49
[Plugin] The Events Calendar - Programatically set events as "Featured" when meeting some custom criteria
<?php
/**
*
* Custom function setting events as Featured Event when meeting your custom criteria
*
* @link https://theeventscalendar.com/knowledgebase/k/using-tribe_get_events/
*
* Note that you can use all arguments available on WP_Query class => http://codex.wordpress.org/Class_Reference/WP_Query
* The Events Calendar exposes some additional arguments that are not normally available but which make life easier when working with events:
* start_date is used to indicate the start of the date range you are interested in