Ejemplos de Hacks sencillos para WordPress.
Ejemplos de hacks sencillos que puedes realizar en tu instalación WordPress para personalizarla
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: Mis Funciones Personales | |
* Plugin URI: http://tupaginaweb.com | |
* Description: Pequeño plugin en el que meto todas las funcionalidades que me interesan. | |
* Author: Tu Nombre Aquí | |
* Author URI: http://tupaginaweb.com | |
* Version: 0.1.0 | |
*/ | |
// Tu código a continuación... |
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 | |
/** | |
* Añade mi logo en la página de login. | |
* | |
* @sine 0.1.0 | |
*/ | |
function wprin_my_logo_on_login() { | |
// Pon el path a tu imagen. | |
$image = get_bloginfo( 'template_directory' ) . '/images/custom-login-logo.gif'; | |
echo '<style type="text/css">h1 a { background-image:url(' . $image . ') !important; }</style>'; | |
}//end wprin_my_logo_on_login() | |
add_action( 'login_head', 'wprin_my_logo_on_login' ); |
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 | |
/** | |
* Mantén la sesión por un año. | |
* | |
* @param int $expire duración por defecto. | |
* @return int devuelve la nueva duración (en segundos). | |
* | |
* @sine 0.1.0 | |
*/ | |
function wprin_stay_logged_in_for_one_year( $expire ) { | |
// Un año en segundos: 365 d/a * 24h/d * 60m/d * 60s/m | |
return 31536000; | |
}//end wprin_stay_logged_in_for_one_year() | |
add_action( 'auth_cookie_expiration', 'wprin_stay_logged_in_for_one_year' ); |
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 | |
/** | |
* Modifica el footer del escritorio de WordPress. | |
* | |
* @sine 0.1.0 | |
*/ | |
function wprin_custom_text_in_footer_admin() { | |
return 'Tu texto aquí'; | |
}//end wprin_custom_text_in_footer_admin() | |
add_action( 'admin_footer_text', 'wprin_custom_text_in_footer_admin' ); |
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 | |
// Reduce el número de revisiones por entrada a 3: | |
define( 'WP_POST_REVISIONS', 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 | |
// Aumenta el intervalo de auto-guardados a 5 minutos (300 segundos). | |
define( 'AUTOSAVE_INTERVAL', 300 ); |
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 | |
/** | |
* Modifica la condición de selección de entradas para excluir aquellas que lleven | |
* menos de 60 minutos publicadas, pero únicamente cuando la selección se realice | |
* para generar el canal RSS. | |
* | |
* @param string $where condición de selección de las entradas que aparecen en mi canal. | |
* @return nueva condición de selección de las entradas que aparecen en mi canal. | |
* | |
* @sine 0.1.0 | |
*/ | |
function wprin_delay_rss_after_publish( $where ) { | |
global $wpdb; | |
if ( is_feed() ) { | |
$now = gmdate( 'Y-m-d H:i:s' ); | |
$wait = '60'; | |
$device = 'MINUTE'; | |
$where .= " AND TIMESTAMPDIFF( $device, $wpdb->posts.post_date_gmt, '$now' ) > $wait "; | |
} | |
return $where; | |
}//end wprin_delay_rss_after_publish() | |
add_action( 'posts_where', 'wprin_delay_rss_after_publish' ); |
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 | |
/** | |
* Cuando la query es una búsqueda, sólo devuelve las entradas del blog, | |
* excluyendo cualquier página o entrada personalizada de la lista de | |
* resultados. | |
* | |
* @param object $query condición de selección de las entradas a devolver en la búsqueda. | |
* @return nueva condición de selección donde se especifica que sólo se deben devolver entradas ("post"). | |
* | |
* @sine 0.1.0 | |
*/ | |
function wprin_exclude_pages_from_search( $query ) { | |
if ( $query->is_search && ! is_admin() ) { | |
$query->set( 'post_type', 'post' ); | |
} | |
return $query; | |
}//end wprin_exclude_pages_from_search() | |
add_action( 'pre_get_posts', 'wprin_exclude_pages_from_search' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment