Skip to content

Instantly share code, notes, and snippets.

@axxe16
axxe16 / cloneRole.php
Last active January 8, 2017 08:36
Clona le capabilities del ruolo amministratore e le attribuisce ad un ruolo custom che creo From http://wordpress.stackexchange.com/questions/31471/how-to-create-a-clone-role-in-wordpress
<?php
add_action('init', 'cloneRole');
function cloneRole()
{
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$adm = $wp_roles->get_role('administrator');
@axxe16
axxe16 / .htaccess
Last active September 6, 2017 07:47
redirect 301 di un sito ad un'altro eccetto per alcuni indirizzi specifici che saranno redirezionati dove dico io
RewriteEngine on
#eccezioni pagine specifiche
RewriteCond %{REQUEST_URI} !/catalogues
RewriteCond %{REQUEST_URI} !/gallery-parquet-pavimenti-legno
RewriteCond %{REQUEST_URI} !/parquet/natural-wood-floor/types-of-wood
RewriteCond %{REQUEST_URI} !/parquet/natural-wood-floor/antico-asolo-3-ply
RewriteCond %{REQUEST_URI} !/parquet/natural-wood-floor/antico-asolo-2-ply
RewriteCond %{REQUEST_URI} !/parquet/natural-wood-floor/parquet-mosaici-dasolo
RewriteCond %{REQUEST_URI} !/contacts
@axxe16
axxe16 / conversione_data.php
Created October 10, 2017 12:39
[conversione data] da usare se si parte da una data con questo format g/m/a e si vole ottenere il formato mysql #date #php #convert #toSQLformat
<?php
//perchè funzioni strtotime è necessario sostituire / con -
$data = strtotime(str_replace('/', '-' ,$_POST['data_nascita_cliente']);
//ottengo il formato richiesto
$data_nascita_cliente = date('Y-m-d', $data));
@axxe16
axxe16 / apik_acf.php
Created July 19, 2017 12:13
API KEY Google per ACF cosa mettere in function.php
<?php
function fix_gmaps_api_key() {
if(mb_strlen(acf_get_setting("google_api_key")) <= 0){
acf_update_setting("google_api_key", "AIzaSyDXiH2aFtmW-8TYE2Tyll702wwlwyOsEZQ");
}
}
add_action( 'admin_enqueue_scripts', 'fix_gmaps_api_key' );
@axxe16
axxe16 / redirectWP.php
Created October 30, 2017 08:25
Permette il redirect in qualunque punto #redirect #wp #wordpress
<?php
// *F001* filtro per permettere il redirect
//allow redirection, even if your theme starts to send output to the browser
add_action('init', 'clean_output_buffer');
function clean_output_buffer() {
ob_start();
}
@axxe16
axxe16 / ajax.js
Last active November 9, 2017 12:38
procedura per l'utlizzo di uno script ajax in frontend su Wordpress #ajax #wp #js
(function($) {
$('#form_tesseramento #ek_province').on('change', function(){
var provincia_id = $(this).val();
console.log(provincia_id);
jQuery.ajax({
url : postdata.ajax_url, //definito riga 8 precedente script
type : 'post',
data : {
action : 'ek_skipay_getComuneByProvincia', //function ajax da richiamare
provincia_id : provincia_id //dato da passare, in questo caso id estratto da option selezionata
@axxe16
axxe16 / media-lib-resolution-column.php
Last active November 9, 2017 13:32
Nella media library nella vista lista aggiunge la colonna con le risoluzioni delle immagini #colonne #customize #media #library *WPM*
add_filter('manage_upload_columns', 'size_column_register');
function size_column_register($columns) {
$columns['dimensions'] = 'Dimensions';
return $columns;
}
add_action('manage_media_custom_column', 'size_column_display', 10, 2);
@axxe16
axxe16 / custom_tax.php
Last active November 9, 2017 13:40
stampa i valori per la tassonomia custom indicata per il post corrente #custom #tax #post *WPM*
<?php
$id = get_the_ID();
$taxonomy = 'your-taxonomy';
$terms = get_the_terms( $id, $taxonomy );
foreach ($terms as $term) {
// Here you can display the terms how you want
echo 'TERM: '.$term->name;
@axxe16
axxe16 / WP_Query.php
Last active November 9, 2017 13:42
reference completo per WP_Query #WP_Query #query #loop *WPM*
<?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(
@axxe16
axxe16 / wp_query_all.php
Last active November 9, 2017 15:48
wp_query per più custom type e ricevere solo gli id *WPM* #WP_query #custom_type
$query = new WP_Query( array(
'post_type' => array('salplesk_profili','salplesk_aziende','salplesk_offerte'),
'posts_per_page' => -1,
'fields' => 'ids'
) );