Skip to content

Instantly share code, notes, and snippets.

@dededey
dededey / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_body_class' );
@dededey
dededey / wp_query_args.php
Created March 25, 2015 14:43
wp_query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@dededey
dededey / filter_active_menu.php
Created March 31, 2015 09:17
add active in menu
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
if( in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@dededey
dededey / segment.php
Created April 1, 2015 08:11
get wp segment uri
$segments = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'));
$numSegments = count($segments);
$currentSegment = $segments[$numSegments - 1];
echo 'Current Segment: ' , $currentSegment;
@dededey
dededey / socials_share.php
Last active August 29, 2015 14:20
socials share in functions
// facebook share
function fbShare($url,$picture = 'http://www.sito.com/wp-content/uploads/foto-default.jpg' , $title = 'sito.com', $desc = 'descritpion'){
// return "https://www.facebook.com/dialog/share?app_id=422399111266789&display=popup&href=".$url."&redirect_uri=".$url;
return "https://www.facebook.com/dialog/feed?app_id=422399111266789&link=".$url."&picture=".$picture."&name=".$title."&description=".$desc."&redirect_uri=http://www.thewinterview.com";
}
// twitter share
function twitterShare($url,$frase = NULL){
@dededey
dededey / update_plugins.php
Created June 8, 2015 08:36
// to update plugins in localhost
// to update plugins in localhost
define('FS_METHOD', 'direct');
@dededey
dededey / custom_field_woocommerce_product_category.php
Created August 5, 2015 10:21
add custom field to woocommerce product category
// Add term page
function custom_url_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Custom url category', 'custom_url_category' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Inserisci un custom url prodotto per la categoria','custom_url_category' ); ?></p>
</div>
<?php
@dededey
dededey / thumbnail_url.php
Created August 28, 2015 10:59
thumbnail url
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
CSS
.box{
position: relative;
width: 50%; /* desired width */
}
.box:before{
content: "";
display: block;
padding-top: 100%; /* initial ratio of 1:1*/
}