giovedì 24 marzo 2016

wp_nav_menu

1) cambiare link al menu

function change_menu($items){
if(!is_home()){
foreach($items as $item) {
if($item->title=="Progetti" || $item->title=="Projects") {
} else {
$item->url = get_bloginfo("url") . "/" . $item->url;
}
}
}
return $items;
}

add_filter('wp_nav_menu_objects', 'change_menu');

domenica 20 marzo 2016

Views bulk operation in Drupal

1) Cambiare la data di creazione su un node usando il modulo VIEWS BULK OPERATION e l'opzione Execute Arbitray Script PHP

$timestamp = strtotime('22-09-2008');
$new_node = node_load($entity->nid);
$new_node->created= $timestamp;
node_save($new_node);


venerdì 18 marzo 2016

Metabox in base al template

su functions.php


if (is_admin()) {

$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
 
// controlla se è un template specifico

  if ($template_file == 'page-template.php') {


// codice che genera i meta box (in questo caso ho usato le classi wpalchemy)
  $custom_select_mb = new WPAlchemy_MetaBox(array
(
'id' => '_pagina_cat',
'title' => 'Select Inputs',
'template' => get_stylesheet_directory() . '/metaboxes/select-meta.php',
));  
  }
 
  }