Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
developing ...

Antonio Blanco eggemplo

👨‍💻
developing ...
View GitHub Profile
@eggemplo
eggemplo / functions.php
Created Apr 15, 2020
Remove hreflang if there isn't translation of a post/page.
View functions.php
function otgs_custom_hreflang( $hreflang_items ){
if( is_array($hreflang_items) && !empty( $hreflang_items ) ){
// Check if there are no translations available.
if( 1 == count( $hreflang_items ) ){
return null;
}
}
return $hreflang_items;
@eggemplo
eggemplo / functions.php
Created Apr 13, 2020
Añade la clase 'active' a un item de menú cuando estamos viendo un custom post type en concreto.
View functions.php
function my_custom_nav_menu_css_class( $classes, $item, $args ) {
if ( is_singular( 'curso' ) && 'Nuestros cursos' == $item->title ) {
$classes[] = 'active';
}
return array_unique( $classes );
}
add_filter( 'nav_menu_css_class', 'my_custom_nav_menu_css_class', 10, 3 );
@eggemplo
eggemplo / functions.php
Created Apr 9, 2020
Include theme parent and theme child styles
View functions.php
function parent_and_child_scripts() {
// Parent
wp_enqueue_style( 'mytheme-parent-style', get_template_directory_uri(). '/style.css', array(), '0.0.1' );
// Child
wp_enqueue_style( 'mytheme-child-style', get_stylesheet_directory_uri(). '/style.css', array(), '0.0.1' );
}
add_action( 'wp_enqueue_scripts', 'parent_and_child_scripts' );
@eggemplo
eggemplo / my-options.php
Last active Oct 27, 2019
Simple WordPress plugin with ACF options page
View my-options.php
<?php
/*
Plugin Name: My options
Plugin URI: https://www.ablancodev.com
Description: Simple plugin with an ACF options page
Tags: plugin
Version: 0.1
Author: Antonio Blanco
Author URI: https://www.ablancodev.com
@eggemplo
eggemplo / change-slugs-cpt.php
Last active Aug 31, 2019
Change the custom posts type and custom taxonomies slugs.
View change-slugs-cpt.php
/**
* Author: Antonio Blanco Oliva
* Website: www.ablancodev.com
* Company: www.blancoleon.com
**/
function change_post_types_slug( $args, $post_type ) {
/*item post type slug*/
if ( 'portfolio' === $post_type ) {
if ( !is_array( $args['rewrite'] ) ) {
$args['rewrite'] = array( 'slug' => '' );
@eggemplo
eggemplo / mail.php
Created Apr 22, 2019
Envío de email usando la función mail() de php
View mail.php
<?php
// El mensaje
$mensaje = "Línea 1\r\nLínea 2\r\nLínea 3";
// Si cualquier línea es más larga de 70 caracteres, se debería usar wordwrap()
$mensaje = wordwrap($mensaje, 70, "\r\n");
// Enviarlo
mail('hello@example.com', 'Mi título', $mensaje);
?>
@eggemplo
eggemplo / functions.php
Created Mar 14, 2018
Extends the [groups_user_groups] shortcode to display the ids. This new shortcode is [groups_user_groups_id]
View functions.php
add_shortcode( 'groups_user_groups_id', 'itx_groups_user_groups_id' );
/**
* Renders the current or a specific user's groups id.
* Attributes:
* - "user_id" OR "user_login" OR "user_email" to identify the user, if none given assumes the current user
* - "format" : one of "list" "div" "ul" or "ol" - "list" and "ul" are equivalent
* - "list_class" : defaults to "groups"
* - "item_class" : defaults to "name"
* - "order_by" : defaults to "name", also accepts "group_id"
* - "order" : default to "ASC", also accepts "asc", "desc" and "DESC"
@eggemplo
eggemplo / affiliates_stored_affiliate.php
Created Jan 30, 2018
example of affiliates_stored_affiliate action
View affiliates_stored_affiliate.php
add_action( 'affiliates_stored_affiliate', 'connecting_crm_api_affiliates_stored_affiliate', 10, 2 );
function connecting_crm_api_affiliates_stored_affiliate ( $affiliate_id, $affiliate_user_id ) {
// This function is launched when a new affiliate is created
// Here you can add your crm api code
// ....
}
@eggemplo
eggemplo / function.php
Last active Jan 3, 2018
affiliates_check_confirmation_text
View function.php
add_filter( 'affiliates_check_confirmation_text', 'my_custom_affiliates_check_confirmation_text', 10, 1 );
function my_custom_affiliates_check_confirmation_text( $txt ) {
return '<p>' . 'Your custom text here'. '</p>';
}
@eggemplo
eggemplo / decent-comments-post-avatar.php
Created Nov 27, 2017
Display the post avatar on the decent-comments widgets.
View decent-comments-post-avatar.php
add_filter( 'decent_comments_comments_output', 'random_decent_comments_comments_output', 10, 3 );
function random_decent_comments_comments_output ( $output, $comments, $options ) {
extract( Decent_Comments_Renderer::$defaults );
// display options
if ( isset( $options['avatar_size'] ) ) {
$avatar_size = intval( $options['avatar_size'] );
} else {
$avatar_size = 32;
You can’t perform that action at this time.