Skip to content

Instantly share code, notes, and snippets.

View AndreaBarghigiani's full-sized avatar

Andrea Barghigiani AndreaBarghigiani

View GitHub Profile
@AndreaBarghigiani
AndreaBarghigiani / m_carrelli.php
Created May 30, 2014 14:55
Con questo codice creo un CPT e ci collego una tassionomia. La pagina archivio per quest'ultima prende il nome di taxonomy-cat_saliscale.php ma non viene letta correttamente...
<?php
/*
Plugin Name: Carrelli CPT
Plugin URI: http://mariocarrelli.com
Description: Il CPT per contenere i carrelli e struttura categorie personalizzata
Version: 1.0
Author: Andrea Barghigiani
Author URI: http://andreabarghigiani.info
License: GPL2 (o anche 3 va bene)
<?php
/* In qst file aggiungo tutte le modifiche che devono essere applicate grazie a ACF PRO */
/* Rimuovo il titolo dai post */
function remove_title(){
remove_post_type_support('post', 'title');
}
add_action( "admin_init", "remove_title" );
@AndreaBarghigiani
AndreaBarghigiani / test.php
Created January 20, 2015 11:56
Esercizio funzione riduci_stringa()
<?php
//Manca l'inserimento di un parametro da passare alla funzione
function riduci_stringa($stringa){
//Il secondo parametro di substr() era sbagliato
//perchè nn serve un negativo.
//puoi approfondire su: http://php.net/manual/en/function.substr.php
echo substr( $stringa, 2);
@AndreaBarghigiani
AndreaBarghigiani / test.php
Created January 20, 2015 12:02
Esercizio funzione solo_pari()
<?php
//OK per la dichiarazione di un Array
//Ricorda che gli indici partono da 0
$piovono_polpette = array(
"Pollaccione", //indice 0
" Bred", //indice 1
"Diventa", //indice 2
" Gattaccio", //indice 3
" Breddaccio", //indice 4
@AndreaBarghigiani
AndreaBarghigiani / test.php
Created January 20, 2015 12:09
Esercizio funzione conto_alla_rovescia()
<?php
//Manca proprio tutta la definizione della funzione
function conto_alla_rovescia( $int ){
$int = intval($int); //Mi assicuro che sia un intero
$m = $int; //Mi creo una variabile per contare i passi
for( $i = 0; $i < $m; $i++ ){
echo $int-- . "<br />";
}
}
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created June 21, 2015 18:44
Includere codice jQuery in WordPress
/****************************************
Da inserire all'interno del file functions.php
*****************************************/
if ( is_single( $id ) ){ //Sostituisci $id con l'ID della pagina specifica
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'mio-codice', get_template_directory_uri() . '/percorso/file.js', array( 'jquery' ) );
}
@AndreaBarghigiani
AndreaBarghigiani / file.js
Created June 21, 2015 18:45
Scrivere codice jQuery in WordPress
/****************************************
Da inserire all'interno del file /percorso/file.js
*****************************************/
jQuery(document).ready(function($) {
$("#toggle_it").click(function () { $(".to_toggle").toggle(1000); });
$(".to_toggle").show();
$("#toggle_it1").click(function () { $(".to_toggle1").toggle(1000); });
<?php echo "Ciao Mondo"; ?>
@AndreaBarghigiani
AndreaBarghigiani / functions.php
Created February 17, 2013 19:59
Crea un nuovo Custom Post Type
<?php
// Creazione Custom Post Type Portfolio
add_action( 'admin_init', 'wpam_portfolio' );
function wpam_portfolio(){
$labels = array(
'name' => _x('Portfolio', 'la sezione per i nostri lavori', 'tuo-tema'),
'singular_name' => _x('Lavoro', 'un elemento del nostro portfolio', 'tuo-tema'),
'add_new' => _x('Aggiungi Nuovo', 'elemento', 'tuo-tema'),
'add_new_item' => __('Aggiungi un Nuovo Lavoro', 'tuo-tema'),
@AndreaBarghigiani
AndreaBarghigiani / gist:7651231
Created November 26, 2013 00:12
Errore con Wordmove in cerca di soluzione
iMac-di-Andrea:vdAM andreabarghigiani$ wordmove push -s --all
▬▬ ✓ Using Movefile: ./Movefile ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
/Library/Ruby/Gems/2.0.0/gems/wordmove-1.1.0/lib/wordmove/deployer/base.rb:23:in `deployer_for': You need to specify an environment with --environment parameter (RuntimeError)
from /Library/Ruby/Gems/2.0.0/gems/wordmove-1.1.0/lib/wordmove/cli.rb:56:in `push'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
from /Library/Ruby/Gems/2.0.0/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from /Library/Ruby/Gems/2.0.0/gems/wordmove-1.1.0/bin/wordmove:6:in `<top (required)>'