This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @snippet JavaScript: Obtener la url de la página anterior | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.aprendeinformaticaconmigo.com/desarrollo/javascript/javascript-obtener-la-url-de-la-pagina-visitada-anteriormente | |
*/ | |
// Guardar la url de la página anteior en una variable. | |
// Usamos document.referrer | |
let urlAnteior = document.referrer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WordPress Snippet: Comprobar si el post (entrada) tiene asignada imagen destada. Si es así, motrarla (medium) | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.aprendeinformaticaconmigo.com | |
* @snippet_url https://www.aprendeinformaticaconmigo.com/wordpress-comprobar-la-entrada-post-tiene-asignada-una-imagen-destacada-y-si-es-asi-mostrarla-en-tamano-medium | |
*/ | |
function oaf_check_has_featured_image(){ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Nombre del plugin | |
* Plugin URI: https://oscarabadfolgueira.com/url-del-plugin | |
* Description: Texto descriptivo y corto de lo que hace el plugin. | |
* Author: Oscar Abad Folgueira | |
* Author URI: https://oscarabadfolgueira.com | |
* Text Domain: dominio-del-plugin (oaf-xxx-xxx) | |
* License: GPL-2.0+ | |
* Version: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example programmatic registration of Advanced Custom Fields fields | |
* | |
* @see http://www.advancedcustomfields.com/resources/register-fields-via-php/ | |
*/ | |
function register_custom_acf_fields() { | |
if ( function_exists( 'acf_add_local_field_group' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WordPress Snippet: Incluir ACF en un plugin | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WordPress Snippet: Cambiar traducción de textos | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
// Cambiar la traducción del texto "Nombre de usuario o correo electrónico" del formulario de acceso | |
add_filter( 'gettext', 'oaf_change_traduction_text', 10, 3 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WordPress Snippet: Desactivar login por email | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
// Desactivar login por email | |
remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WooCommerce Snippet: Comprobar si WooCommerce está activado. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/woocommerce-snippet-comprobar-si-woocommerce-esta-activado/ | |
*/ | |
// Comprobar si WooCommerce está en el array de plugins ativos | |
if ( in_array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WooCommerce Snippet: Comprobar si WooCommerce está instalado. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/woocommerce-snippet-comprobar-si-woocommerce-esta-instalado/ | |
*/ | |
if ( class_exists( 'WooCommerce' ) ) { | |
echo "WooCommerce está instalado. Podemos seguir"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet PHP Snippet: Obtener sólo las claves de un array asociativo en otro array. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com | |
*/ | |
$array = array("1" => "Uno", "2" => "Dos", "3" => "Tres", "4" => "Cuatro"); | |
print_r(array_keys($array)); |
NewerOlder