Skip to content

Instantly share code, notes, and snippets.

@andrescifuentesr
andrescifuentesr / Resume xmots
Created April 18, 2014 14:12
A php function to cut a character chaine
//----------------------------------------------------------------------------------------------------
// Fonction pour limiter le nombre de caractere
//----------------------------------------------------------------------------------------------------
function resume_xmots($MaChaine,$xmots)
{
$ChaineTab=explode(" ",$MaChaine);
for($i=0;$i<$xmots;$i++)
{
$NouvelleChaine.=" "."$ChaineTab[$i]";
}
@andrescifuentesr
andrescifuentesr / .htaccess wp-config.php
Created April 20, 2014 21:27
.htaccess to protect wp-config.php file
<files wp-config.php>
order allow,deny
deny from all
</files>
@andrescifuentesr
andrescifuentesr / gist:11326078
Last active August 29, 2015 14:00
Remove/Format [...] Excerpt in WP
//Remove [...] string using Filters
<?php
function new_excerpt_more( $more ) {
return '<div class="read-more"><a href="'. get_permalink( get_the_ID() ) . '">Read More</a></div>';
}
add_filter('excerpt_more', 'new_excerpt_more');
//Control Excerpt Length using Filters
function custom_excerpt_length( $length ) {
return 30;
@andrescifuentesr
andrescifuentesr / Insert PHP
Last active August 29, 2015 14:01
Insert Basic PHP
<?php
// Connexion BDD
mysql_connect('localhost', 'hostname', 'password'); //
mysql_select_db('mybdd');
mysql_query("SET NAMES 'utf8'");
// on start la session
session_start();
ini_set('session.gc_maxlifetime', 2592000); // durée de la session => 30 jours (2592000 secondes)
@andrescifuentesr
andrescifuentesr / ImageLightbox.js
Created July 23, 2014 23:08
ImageLightbox.js use code
jQuery( function( $ )
{
// ACTIVITY INDICATOR
var activityIndicatorOn = function()
{
$( '<div id="imagelightbox-loading"><div></div></div>' ).appendTo( 'body' );
},
activityIndicatorOff = function()
{
@andrescifuentesr
andrescifuentesr / Simple grid
Last active August 29, 2015 14:05
A simple grid mixin
//=================================
/* Simple grid */
@mixin simple-grid($nombre-items , $margin-right ){
width: ( (100% - ( ($nombre-items - 1) * $margin-right) ) / $nombre-items);
margin-right: $margin-right;
float:left;
&:nth-child(n) {
margin-right: $margin-right;
<?php //different sizes ?>
<?php $large_image_urlLarge = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogLarge' ); ?>
<?php $large_image_urlMedium = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogMedium' ); ?>
<?php $large_image_urlSmall = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogSmall' ); ?>
<?php //title == alt ?>
<?php $title = get_post(get_post_thumbnail_id())->post_title; //The Title ?>
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
@andrescifuentesr
andrescifuentesr / gzipping .htacces
Created February 20, 2015 10:57
Web perfomance gzipping from HTML5 boilerplate
# ######################################################################
# # WEB PERFORMANCE #
# ######################################################################
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
@andrescifuentesr
andrescifuentesr / Performance .htacces
Created February 23, 2015 16:33
Web perfomance gzipping and caching header from HTML5 Boilerplate
# ######################################################################
# # WEB PERFORMANCE #
# ######################################################################
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
@andrescifuentesr
andrescifuentesr / WPSlider
Last active December 28, 2015 12:28
WordPress: slider with responsive-slides.viljamis.com
<?php
$args = array(
'post_parent' => $post->ID, // For the current post
'post_type' => 'attachment', // Get all post attachments
'post_mime_type' => 'image', // Only grab images
'order' => 'ASC', // List in ascending order
'orderby' => 'rand', // List them in their menu order
'numberposts' => -1, // Show all attachments
'post_status' => null, // For any post status
);