Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
developing ...

Antonio Blanco eggemplo

👨‍💻
developing ...
View GitHub Profile
View custom-wp-login.php
<?php
/**
* Personalizamos la página de wp-login de WordPress.
* Cambiamos url, title y logo de la cabecera.
* Y favicon, tanto de wp-login como del admin en general.
**/
// Login WordPress
add_filter( 'login_headerurl', 'my_login_headerurl' );
function my_login_headerurl( $url ) {
View new-woocommerce-order-status.php
// Register new 'shipped' (enviado) status
function register_shipped_order_status() {
register_post_status( 'wc-shipped', array(
'label' => 'Enviado',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Enviado (%s)', 'Enviado (%s)' )
) );
@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
// ....
}