Skip to content

Instantly share code, notes, and snippets.

View kadai's full-sized avatar

Kadai Crosshansen kadai

View GitHub Profile
@kadai
kadai / ImageCreateFromBMP.php
Created June 26, 2017 06:35
ImageCreateFromBMP implementation (author unknown)
<?php
function ImageCreateFromBMP($filename) {
if (! $f1 = fopen($filename,"rb")) return FALSE;
$FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14));
if ($FILE['file_type'] != 19778) return FALSE;
$BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'.
'/Vcompression/Vsize_bitmap/Vhoriz_resolution'.
'/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40));
@kadai
kadai / modify-topposts01.php
Last active June 26, 2017 06:43
Functions to add to the functions.php to change "Top Posts" widget from Jetpack
<?php
/* MODIFICAMOS EL TIEMPO A CONSIDERAR PARA EL "TOP POSTS" */
function jetpackcustom_new_timeframe() {
/* CONSIDERAREMOS 30 DÍAS */
return '30';
}
add_filter( 'jetpack_top_posts_days', 'jetpackcustom_new_timeframe' );
/**
* WIDGET TOP POSTS: AGREGAMOS LA FECHA AL FINAL
@kadai
kadai / topppost-change01.css
Created June 26, 2017 06:49
CSS to change the appearance of the Top Posts widget
.widgets-list-layout-blavatar {
display: block;
border-radius: 99px;
max-width: 55px !important;
min-height: 55px;
padding: 2px;
background: #fff;
border: 1px solid #eee;
}
@kadai
kadai / topppost-change02.css
Created June 26, 2017 06:50
CSS to change the appearance of the Top Posts widget (part 2)
.widgets-list-layout-links a {
font-family: 'Playfair Display',Georgia,serif;
line-height: 140%;
font-weight: 700;
color: #111;
}
.widgets-list-layout-links a:hover {
color: #111;
text-decoration: underline;
@kadai
kadai / topppost-change03.css
Created June 26, 2017 06:51
CSS to change the appearance of the Top Posts widget (Part 3)
.top_posts_date {
margin-top: 3px;
font-size: 0.75em;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1px;
color: #888;
}
@kadai
kadai / modify-topposts02.php
Last active June 26, 2017 07:23
Functions to add to the functions.php to change "Top Posts" widget from Jetpack (part 2)
<?php
function jetpackcustom_changeimage($get_image_options){
$default = 150;
$get_image_options['avatar_size'] = $default;
$get_image_options['width'] = $default;
$get_image_options['height'] = $default;
return $get_image_options;
}
add_action( 'jetpack_top_posts_widget_image_options', 'jetpackcustom_changeimage' );
@kadai
kadai / dummy_funct.php
Last active July 1, 2017 09:08
Conjunto de código de ejemplo
<?php
add_filter( 'wp_title', 'myfunction_cambiandoimagen' );
?>
<?php if (current_user_can('update_core')) { ?>
<p><?php echo get_num_queries() ?> queries. <?php if (function_exists('memory_get_usage')) { $unit=array('b','kb','mb','gb','tb','pb'); echo @round(memory_get_usage(true)/pow(1024,($i=floor(log(memory_get_usage(true),1024)))),2).' '.$unit[$i]; ?> Memory usage. <?php } timer_stop(1) ?> seconds.</p>
<?php } ?>
#CAMBIA "xxx.xxx" CON TU DIRECCIÓN IP
SetEnvIF X-Forwarded-For xxx.xxx Allowed
order deny,allow
allow from env=Allowed
deny from all
#LE PERMITIMOS A TODOS ACCEDER AL AJAX
<Files "admin-ajax.php">
Order allow,deny
<?php
add_action( 'wp_footer', 'funcion_codigo_especial' );
function funcion_codigo_especial(){
/* AQUÍ IMPRIMIMOS EL CÓDIGO JAVASCRIPT A USAR */
/* O LO PODEMOS DELIMITAR ENTRE "?>" Y <?php" */
}
?>