Skip to content

Instantly share code, notes, and snippets.

View gugaalves's full-sized avatar

Guga Alves gugaalves

View GitHub Profile
@gugaalves
gugaalves / gist:3cee2f7acf67ec3e0229cbcb1417fbec
Created January 12, 2024 19:39
Events Calendar + Rank Math SEO: Noindex past events automatically
// That snippet was tested using the following plugin versions:
// The Events Calendar v6.2.9
// Rank Math SEO v1.0.210
// Check if Events Calendar and Rank Math plugins are enabled
if (class_exists('Tribe__Events__Main') && class_exists('RankMath')) {
add_filter( 'rank_math/frontend/robots', function( $robots ) {
global $post;
if (!is_admin() && is_singular() && @$post->post_type == 'tribe_events') {
if (strtotime(tribe_get_end_date($post->ID, true, 'r')) < time()) {
@gugaalves
gugaalves / gist:5be5a7bfba15c16ca5fe371aadae6fe5
Created September 17, 2021 19:39
Events Calendar [Free] [PRO] - Add Category Tags to List, Month and Map Views
// Source: https://theeventscalendar.com/knowledgebase/k/add-category-tags-to-list-view/
// Remove "Event Categories" label from tribe_get_event_categories function
function tec_remove_category_label( $html, $post_id, $args, $categories ) {
$html = ! empty( $categories ) ? sprintf(
'%s%s%s',
$args['wrap_before'],
$categories,
$args['wrap_after']
) : '';
@gugaalves
gugaalves / single-event.php
Last active February 11, 2020 21:44
[Plugin] The Events Calendar- Show event category in Monthly view
<?php
/**
* Month Single Event
* This file contains one event in the month view
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/month/single-event.php
*
* @package TribeEventsCalendar
* @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
@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
*/
?>
// 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 / 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
@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 / 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: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;
}
?>