Skip to content

Instantly share code, notes, and snippets.

@dededey
dededey / popup
Created March 22, 2018 13:14
popup usato per avviso importante
<!-- OVERLAY POPUP BIANCO -->
<div class="popup-overlay-white">
<div class="content1">
<h5>Recuperi insoluti in bolletta, tutto quello che c'è da sapere.</h5>
</div>
<div class="content2">
<p>
Su social e articoli continua a diffondersi la falsa notizia di rincari di 35€ /40€ in bolletta.
Facciamo chiarezza sulla questione approfondendo la delibera dell'ARERA n. 50/2018.
<br>
@dededey
dededey / roleToBody.php
Created February 7, 2017 08:59
// Add role class to body
// Add role class to body
function add_role_to_body($classes) {
global $current_user;
$user_role = array_shift($current_user->roles);
$classes[] .= 'role-'. $user_role;
return $classes;
}
add_filter('body_class','add_role_to_body');
@dededey
dededey / acfGmapsFix.php
Last active November 9, 2016 15:59
acf fix google maps
/**
* enqueue scripts and styles
*
*/
function nr_load_scripts() {
wp_register_script('googlemaps', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCxucarwzsej2hTS4d89VnYICal7OB6-cw',null,null,true);
wp_enqueue_script('googlemaps');
@dededey
dededey / flexslider.css
Created August 17, 2016 14:20
flexslider arrows change
.flex-direction-nav a:before {
content: " ";
display: block;
background: url('img/prev.png') no-repeat center center;
background-size: contain;
width: 40px;
height: 40px;
}
.flex-direction-nav a.flex-next:before {
content: " ";
@dededey
dededey / province.php
Created July 12, 2016 10:57
province italiane select
<?php
$province = array(
'AG' => 'Agrigento',
'AL' => 'Alessandria',
'AN' => 'Ancona',
'AO' => 'Aosta',
'AR' => 'Arezzo',
'AP' => 'Ascoli Piceno',
'AT' => 'Asti',
'AV' => 'Avellino',
@dededey
dededey / breadcrumbs.php
Created June 28, 2016 13:52
breadcrumbs for custom taxonomy of custom post
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php
$parent = null;
$child = null;
$terms = get_the_terms( $post->ID , 'line' );
// var_dump($terms);exit();
foreach ($terms as $t) {
if($t->parent == 0){
$parent = $t->name;
}else{
@dededey
dededey / category_links.php
Created June 1, 2016 09:25
get category links array hierarcal
@dededey
dededey / ajax.php
Created May 23, 2016 09:37
wordpress ajax call, load more posts
// chiamata ajax per la pagina category load more posts
function load_old_post()
{
$offset = $_GET['offset'];
$category = $_GET['category'];
$args = array( 'posts_per_page' => 2 , 'cat' => $category, 'offset' => $offset );
$theme_post_query = new WP_Query( $args );
while( $theme_post_query->have_posts() ) : $theme_post_query->the_post();?>
<?php $category = get_the_category(); $category = $category[0]; ?>
<?php $parent_cat = get_cat_name( $category->parent ); ?>
@dededey
dededey / password.php
Created March 31, 2016 15:22
password salt generator and has
$salt = uniqid(mt_rand(), true);
function getSaltedHash($password, $salt) {
$hash = $password . $salt;
for ($i = 0; $i < 50; $i++) {
$hash = hash('sha512', $password . $hash . $salt);
}
return $hash;
}
@dededey
dededey / attachment_url.php
Created February 23, 2016 11:45
save attachment url in wp media
function _save_attachment_url($post, $attachment) {
if ( isset($attachment['url']) )
update_post_meta( $post['ID'], '_wp_attachment_url', esc_url_raw($attachment['url']) );
return $post;
}
add_filter('attachment_fields_to_save', '_save_attachment_url', 10, 2);
function _replace_attachment_url($form_fields, $post) {
if ( isset($form_fields['url']['html']) ) {
$url = get_post_meta( $post->ID, '_wp_attachment_url', true );
if ( ! empty($url) )