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 los valores 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_values($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 ACF Snippet: Obtener los ajustes de un campo de ACF. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com | |
*/ | |
$campo = get_field_object( 'field_6124b36041b98' ); |
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: Establecer tiempo de expiracion del token de "JWT Authentication for WP REST API". | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/establecer-el-tiempo-de-expiracion-del-token-de-la-rest-api-de-wordpress/ | |
*/ | |
// Establecer el tiempo a una hora (3600 segundos). |
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: Deshabilitar todos los endpoints de la rest api. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
add_filter( 'rest_endpoints', 'oaf_remove_default_endpoints' ); | |
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: Establecer un single de un CPT como página de inicio. | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/establecer-un-single-de-un-cpt-como-pagina-de-inicio/ | |
*/ | |
function add_pages_to_dropdown( $pages, $r ){ | |
if ( ! isset( $r[ 'name' ] ) ) |
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: Redireccionar después de salir sin confirmación | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
add_action('check_admin_referer', 'logout_without_confirm', 10, 2); | |
function logout_without_confirm($action, $result) |
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: Redireccionar tras salir | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/ | |
*/ | |
add_action('wp_logout','oaf_redirect_after_logout'); | |
function oaf_redirect_after_logout(){ |
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 (WPML): Crear posts y traducciones en WordPress para WPML con código | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://oscarabadfolgueira.com/crear-posts-y-traducciones-en-wordpress-para-wpml-con-codigo | |
*/ | |
function nuevos_posts_para_publicar() { | |
$output = array(); // array que contendrá los posts para publicar |
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: Como crear tareas programadas en WordPress | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/como-crear-tareas-programadas-en-wordpress--cron-jobs/ | |
*/ | |
add_action('cron_borrar_todos_posts', 'oaf_borrar_todos_posts'); |
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: Borrar todos los posts con código | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/como-crear-tareas-programadas-en-wordpress--cron-jobs/ | |
*/ | |
function oaf_borrar_todos_posts(){ | |
$todos_posts = get_posts( array('post_type'=>'post','numberposts'=>-1) ); |