Skip to content

Instantly share code, notes, and snippets.

View cabans's full-sized avatar
:octocat:

Abel Cabans cabans

:octocat:
View GitHub Profile
@cabans
cabans / fix_paged_homepage.php
Created September 27, 2012 09:34
Wordpress: Fix for loop pagination with Custom Post Type in homepage
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
@cabans
cabans / gist:7679199
Last active December 29, 2015 13:39
Disable Wordpress top bar for all users, use in add_action('after_setup_theme')
// Disable Wordpress top bar for all users
if ( !is_admin() ) {
show_admin_bar(false);
}
@cabans
cabans / send_smtp_with_wpmail.php
Created December 17, 2013 14:30
Wordpress: Add SMTP settings to wp_mail()
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer )
{
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server
$phpmailer->Host = "your server smtp address";
// Use SMTP authentication (true|false)
@cabans
cabans / CSScomb.sublime-settings
Created December 23, 2013 19:08
CSSComb Alphabetical Order
{
"custom_sort_order": true,
"sort_order": [
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-delay",
"-moz-animation-delay",
@cabans
cabans / Add Pinterest Button to all Images in the_content()
Last active March 15, 2022 00:12
Wordpress - Function to wrap all images and adds Pinterest button
// Wraps image with container and add link to share src from all <img> in the content
function gear_pinterest_in_content_images($content) {
$dom = new DOMDocument('UTF-8');
@$dom->loadHTML( utf8_decode($content) ); // Decode to simple ISO to avoid accent errors
$dom->preserveWhiteSpace = false;
$images = $dom->getElementsByTagName('img');
if( count($images) > 0 ) {
foreach ($images as $image) {
@cabans
cabans / hidden-text.css
Created February 13, 2014 15:54
Hide text from human eyes
.hidden-text {
/* Kellum Replacement Method: http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/ */
position: absolute;
text-indent: 100%;
height: 0;
white-space: nowrap;
overflow: hidden;
}
@cabans
cabans / last_and_first_month_day.php
Last active August 29, 2015 13:56
PHP: Last and First day of actual month
/** Actual month last day **/
function _data_last_month_day() {
$month = date('m');
$year = date('Y');
$day = date("d", mktime(0,0,0, $month+1, 0, $year));
return date('Y-m-d', mktime(0,0,0, $month, $day, $year));
};
/** Actual month first day **/
@cabans
cabans / change-url-in-wordpress-site.sql
Created March 4, 2014 19:12
Wordpress : Change URL in all site (Options, GUID, Post content and meta values)
UPDATE wp_options SET option_value = replace(option_value, 'http://site-to-change.com', 'http://127.0.0.1/site-changed') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://site-to-change.com', 'http://127.0.0.1/site-changed');
@cabans
cabans / css-media-queries-base.css
Created May 9, 2014 08:23
CSS Media queries Base
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@cabans
cabans / media-queries-base.css
Created May 9, 2014 08:28
CSS Media Queries Base
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }