_x('Spese', 'spesa'), 'singular_name' => _x('Spesa', 'spesa'), 'add_new' => _x('Nuova Spesa', 'spesa'), 'add_new_item' => _x('Nuova Spesa', 'spesa'), 'edit_item' => _x('Modifica Spesa', 'spesa'), 'new_item' => _x('Nuova Spesa', 'spesa'), 'view_item' => _x('Visualizza Spesa', 'spesa'), 'search_items' => _x('Cerca Spesa', 'spesa'), 'not_found' => _x('Nessun elemento trovato', 'spesa'), 'not_found_in_trash' => _x('Nessun elemento trovato', 'spesa'), 'parent_item_colon' => _x('Parent Spesa:', 'spesa'), 'menu_name' => _x('Amm. Aperta', 'spesa') ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'In particolare, al fine di ottemperare all’obbligo normativo, per ogni spesa documentata è richiesta la pubblicazione di informazioni relative a: ragione sociale e dati fiscali dell’impresa beneficiaria; importo di spesa; la norma o il titolo a base dell’attribuzione; l’ufficio e il funzionario o responsabile del procedimento amministrativo; metodo e modalità per la scelta del beneficiario; link utili a: progetto selezionato, curriculum del soggetto incaricato, contratto e capitolato della prestazione, fornitura o servizio', 'supports' => array( 'title', 'custom-fields' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => plugin_dir_url(__FILE__) . 'openshareicon-16x16.png', 'show_in_nav_menus' => false, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => false, 'query_var' => false, 'can_export' => true, 'rewrite' => false, 'capability_type' => 'post' ); register_post_type('spesa', $args); } /* =========== TITOLO HCK =========== */ function change_default_title($title) { $screen = get_current_screen(); if ('spesa' == $screen->post_type) { $title = 'Inserire Titolo Spesa/Progetto'; } return $title; } add_filter('enter_title_here', 'change_default_title'); /* =========== SHORTCODE ============ */ function ammap_func($atts) { ob_start(); include(plugin_dir_path(__FILE__) . 'tablegen.php'); $atshortcode = ob_get_clean(); return $atshortcode; } add_shortcode('ammap', 'ammap_func'); /* =========== META BOX ============ */ include(plugin_dir_path(__FILE__) . 'meta-box-class/my-meta-box-class.php'); /* * configure your meta box */ $config = array( 'id' => 'ammap_meta_box', // meta box id, unique per meta box 'title' => 'Dettagli Spesa', // meta box title 'pages' => array( 'spesa' ), // post types, accept custom post types as well, default is array('post'); optional 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional 'priority' => 'high', // order of meta box: high (default), low; optional 'fields' => array(), // list of meta fields (can be added by field arrays) or using the class's functions 'local_images' => false, // Use local or hosted images (meta box images for add/remove) 'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). ); /* * Initiate your meta box */ $my_meta = new AT_Meta_Box($config); /* * Campi personalizzati del Plugin - Usa API terze parti */ $prefix = "ammap_"; //text field $my_meta->addText($prefix . 'beneficiario', array( 'name' => 'Beneficiario' )); $my_meta->addText($prefix . 'importo', array( 'name' => 'Importo. Es. 2.000' )); $my_meta->addText($prefix . 'fiscale', array( 'name' => 'Dati Fiscali' )); $my_meta->addText($prefix . 'norma', array( 'name' => 'Norma' )); $my_meta->addText($prefix . 'responsabile', array( 'name' => 'Responsabile' )); $my_meta->addText($prefix . 'determina', array( 'name' => 'Determina' )); $my_meta->addSelect($prefix . 'assegnazione', array( 'Chiamata Diretta' => 'Chiamata Diretta', 'Bando Pubblico' => 'Bando Pubblico' ), array( 'name' => 'Modalità Assegnazione', 'std' => array( 'Selezionare...' ) )); $my_meta->addDate($prefix . 'data', array( 'name' => 'Data' )); $my_meta->addWysiwyg($prefix . 'wysiwyg', array( 'name' => ' Caricamento Allegati' )); /* * Don't Forget to Close up the meta box deceleration */ //Finish Meta Box Deceleration $my_meta->Finish(); /* =========== Visualizzazione Singola */ add_action('template_redirect', 'ft_job_cpt_template'); function ft_job_cpt_template() { global $wp, $wp_query; if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] == 'spesa') { if (have_posts()) { add_filter('the_content', 'ft_job_cpt_template_filter'); } else { $wp_query->is_404 = true; } } } function ft_job_cpt_template_filter($content) { global $wp_query; $jobID = $wp_query->post->ID; echo 'Importo: € ' . get_post_meta(get_the_ID(), 'ammap_importo', true) . '
'; echo 'Beneficiario: ' . get_post_meta(get_the_ID(), 'ammap_beneficiario', true) . '
'; echo 'Dati Fiscali: ' . get_post_meta(get_the_ID(), 'ammap_fiscale', true) . '
'; echo 'Norma: ' . get_post_meta(get_the_ID(), 'ammap_norma', true) . '
'; echo 'Modalità: ' . get_post_meta(get_the_ID(), 'ammap_assegnazione', true) . '
'; echo 'Responsabile: ' . get_post_meta(get_the_ID(), 'ammap_responsabile', true) . '
'; echo 'Determina: ' . get_post_meta(get_the_ID(), 'ammap_determina', true) . '
'; echo 'Data: ' . get_post_meta(get_the_ID(), 'ammap_data', true) . '
'; echo 'Documenti Allegati:
'; $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'application/pdf,application/msword,application/zip,application/vnd.ms-excel', 'numberposts' => -1, 'post_status' => null, 'post_parent' => get_the_ID(), 'orderby' => 'menu_order', 'order' => 'desc' ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { $class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type); echo '
  • '; echo $attachment->post_title; echo ' ('; echo _format_bytes(filesize(get_attached_file($attachment->ID))); echo ')
  • '; } } } function nascondi_areatesto() { global $current_screen; if ($current_screen->post_type == 'spesa') { $css = ''; echo $css; } } add_action('admin_footer', 'nascondi_areatesto'); function _format_bytes($a_bytes) { if ($a_bytes < 1024) { return $a_bytes . ' B'; } elseif ($a_bytes < 1048576) { return round($a_bytes / 1024, 2) . ' KB'; } elseif ($a_bytes < 1073741824) { return round($a_bytes / 1048576, 2) . ' MB'; } elseif ($a_bytes < 1099511627776) { return round($a_bytes / 1073741824, 2) . ' GB'; } else { return round($a_bytes / 1208925819614629174706176, 2) . ' ERROR'; } } /* =========== Credits Menu ============ */ function ammap_menu() { add_submenu_page('edit.php?post_type=spesa', 'Informazioni', 'Informazioni', 'manage_options', 'ammap_credits', 'ammap_settings_menu'); } add_action('admin_menu', 'ammap_menu'); function ammap_settings_menu() { echo '

    Amministrazione Aperta per Wordpress

    Soluzione completa per la pubblicazione online ai sensi del D.L. n.22 giugno 2012 n. 83 di spese e sovvenzioni concessi alle imprese da enti pubblici.

    Versione 2.1.3
    Autore: Marco Milesi
    Blog: www.amministrazioneaperta.wordpress.com
    Supporto & Feedback: www.wordpress.org/extend/plugins/amministrazione-aperta

    Installazione

    Dopo avere attivato il plugin, per visualizzare le spese pubblicate è sufficiente creare una nuova pagina (es. "Amministrazione Aperta"), inserendo al suo interno il tag "[ammap]". Per informazioni e supporto, consultare il blog ufficiale oppure la pagina dedicata su Wordpress.org.
    Grazie per utilizzare Amministrazione Aperta per Wordpress!
    Marco'; } ?> Name); } else { $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css'); $theme_name = $theme_data['Name']; } $plugin_name = '&'; foreach (get_plugins() as $plugin_info) { $plugin_name .= $plugin_info['Name'] . '&'; } // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE $plugin_data = get_plugin_data(__FILE__); $posts_with_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0"); $data = array( 'url' => stripslashes(str_replace(array( 'http://', '/', ':' ), '', site_url())), 'posts' => $count_posts->publish, 'pages' => $count_pages->publish, 'comments' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pingbacks' => $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'"), 'post_conversion' => ($count_posts->publish > 0 && $posts_with_comments > 0) ? number_format(($posts_with_comments / $count_posts->publish) * 100, 0, '.', '') : 0, 'theme_version' => $plugin_data['Version'], 'theme_name' => $theme_name, 'site_name' => str_replace(' ', '', get_bloginfo('name')), 'plugins' => count(get_option('active_plugins')), 'plugin' => urlencode($plugin_name), 'wpversion' => get_bloginfo('version') ); foreach ($data as $k => $v) { $url .= $k . '/' . $v . '/'; } wp_remote_get($url); set_transient('presstrends_cache_data', $data, 60 * 60 * 24); } } // PressTrends WordPress Action register_activation_hook(__FILE__, 'presstrends_AmministrazioneAperta_plugin'); add_action('admin_init', 'presstrends_AmministrazioneAperta_plugin'); include(plugin_dir_path(__FILE__) . 'admin-messages.php'); ?>