PluginProbe
ANAC XML Bandi di Gara / 2.0
ANAC XML Bandi di Gara v2.0
7.8 trunk 0.1 1.0.0.1 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.1.1 1.1.2 2.0 2.0.1 2.0.2 2.0.3 2.1 2.2 2.3 2.3.1 3 3.0.1 3.1 3.1.1 3.1.2 3.1.3 All 57 releases
avcp / avcp.php

avcp.php in ANAC XML Bandi di Gara 2.0, at avcp.php

271 lines 10.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: AVCP XML
4 Plugin URI: http://www.marcomilesi.ml
5 Description: Generatore XML per l’AVCP (Autorità per la Vigilanza sui Contratti Pubblici di Lavori, Servizi e Forniture) // Art. 1 comma 32 Legge 190/2012.
6 Author: Marco Milesi
7 Version: 2.0
8 Author URI: http://www.marcomilesi.ml
9 */
10
11 add_action( 'init', 'register_cpt_avcp' );
12
13 function register_cpt_avcp() {
14
15 $labels = array(
16 'name' => _x( 'Gare', 'avcp' ),
17 'singular_name' => _x( 'Gara', 'avcp' ),
18 'add_new' => _x( 'Nuova Gara', 'avcp' ),
19 'add_new_item' => _x( 'Nuova Gara', 'avcp' ),
20 'edit_item' => _x( 'Modifica Gara', 'avcp' ),
21 'new_item' => _x( 'Nuova Gara', 'avcp' ),
22 'view_item' => _x( 'Vedi Gara', 'avcp' ),
23 'search_items' => _x( 'Cerca Gara', 'avcp' ),
24 'not_found' => _x( 'Nessuna voce trovata', 'avcp' ),
25 'not_found_in_trash' => _x( 'Nessuna voce trovata', 'avcp' ),
26 'parent_item_colon' => _x( 'Parent Gara:', 'avcp' ),
27 'menu_name' => _x( 'AVCP', 'avcp' ),
28 );
29
30 $args = array(
31 'labels' => $labels,
32 'hierarchical' => false,
33 'description' => 'Gare AVCP',
34 'supports' => array( 'title', 'custom-fields', 'revisions' ),
35 'taxonomies' => array( 'ditte' ),
36 'public' => true,
37 'show_ui' => true,
38 'show_in_menu' => true,
39 'menu_position' => 20,
40 'menu_icon' => 'http://www.comunepantelleria.it/files/ext/ico_zip.gif',
41 'show_in_nav_menus' => false,
42 'publicly_queryable' => true,
43 'exclude_from_search' => false,
44 'has_archive' => true,
45 'query_var' => true,
46 'can_export' => true,
47 'rewrite' => true,
48 'capability_type' => 'post'
49 );
50
51 register_post_type( 'avcp', $args );
52 }
53
54 add_action( 'init', 'register_taxonomy_ditte' );
55
56 function register_taxonomy_ditte() {
57
58 $labels = array(
59 'name' => _x( 'Ditta', 'ditte' ),
60 'singular_name' => _x( 'Ditte', 'ditte' ),
61 'search_items' => _x( 'Cerca Ditta', 'ditte' ),
62 'popular_items' => _x( 'Ditte più usate', 'ditte' ),
63 'all_items' => _x( 'Tutte le ditte', 'ditte' ),
64 'parent_item' => _x( 'Parent Ditte', 'ditte' ),
65 'parent_item_colon' => _x( 'Parent Ditte:', 'ditte' ),
66 'edit_item' => _x( 'Edit Ditte', 'ditte' ),
67 'update_item' => _x( 'Update Ditte', 'ditte' ),
68 'add_new_item' => _x( 'Nuova Ditta', 'ditte' ),
69 'new_item_name' => _x( 'Nuova Ditte', 'ditte' ),
70 'separate_items_with_commas' => _x( 'Separate ditta with commas', 'ditte' ),
71 'add_or_remove_items' => _x( 'Add or remove ditta', 'ditte' ),
72 'choose_from_most_used' => _x( 'Choose from the most used ditta', 'ditte' ),
73 'menu_name' => _x( 'Ditte', 'ditte' ),
74 );
75
76 $args = array(
77 'labels' => $labels,
78 'public' => true,
79 'show_in_nav_menus' => false,
80 'show_ui' => true,
81 'show_tagcloud' => false,
82 'show_admin_column' => true,
83 'hierarchical' => true,
84 'rewrite' => true,
85 'query_var' => true
86 );
87
88 register_taxonomy( 'ditte', array('avcp'), $args );
89 }
90
91 add_action( 'init', 'register_taxonomy_annirif' );
92
93 function register_taxonomy_annirif() {
94
95 $labels2 = array(
96 'name' => _x( 'Anno Riferimento', 'annirif' ),
97 'singular_name' => _x( 'Anno Riferimento', 'annirif' ),
98 'search_items' => _x( 'Cerca Anno', 'annirif' ),
99 'popular_items' => _x( 'Anni più Usati', 'annirif' ),
100 'all_items' => _x( 'Tutti gli anni', 'annirif' ),
101 'parent_item' => _x( 'Parent Anni', 'annirif' ),
102 'parent_item_colon' => _x( 'Parent Anno:', 'annirif' ),
103 'edit_item' => _x( 'Modifica Anno', 'annirif' ),
104 'update_item' => _x( 'Aggiorna Anno', 'annirif' ),
105 'add_new_item' => _x( 'Nuovo Anno', 'annirif' ),
106 'new_item_name' => _x( 'Nuovo Anno', 'annirif' ),
107 'separate_items_with_commas' => _x( 'Separate anno with commas', 'annirif' ),
108 'add_or_remove_items' => _x( 'Add or remove anno', 'annirif' ),
109 'choose_from_most_used' => _x( 'Choose from the most used years', 'annirif' ),
110 'menu_name' => _x( 'Anni', 'annirif' ),
111 );
112
113 $args = array(
114 'labels' => $labels2,
115 'public' => true,
116 'show_in_nav_menus' => true,
117 'show_ui' => true,
118 'show_tagcloud' => false,
119 'show_admin_column' => true,
120 'hierarchical' => true,
121 'rewrite' => true,
122 'capabilities' => array('manage_terms' => 'utentealieno','edit_terms' => 'utentealieno','delete_terms' => 'utentealieno'),
123 'query_var' => true
124 );
125
126 register_taxonomy( 'annirif', array('avcp'), $args );
127 wp_insert_term('2013', 'annirif');
128 wp_insert_term('2014', 'annirif');
129 }
130
131 add_action('save_post', 'save_at_gara_posts',10,2);
132 function save_at_gara_posts($post_id) {
133
134 // If this isn't a 'book' post, don't update it.
135 $slug = 'avcp'; if ( $slug != $_POST['post_type'] ) { return; }
136
137 $get_avcp_autopublish = get_option('avcp_autopublish');
138 if ($get_avcp_autopublish == '1') {
139 $terms = wp_get_post_terms($post_id, 'annirif');
140 $count = count($terms);
141 if (!($count > 0 )){
142 echo '<div class="error"><p>';
143 printf(__('AVCP | Errore: impossibile ricreare il file .xml: nessuna ditta impostata' . $verificafilecreati));
144 echo "</p></div>";
145 }
146 require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
147 foreach ( $terms as $term ) {
148 creafilexml ($term->name);
149 $verificafilecreati = $term->name . ' - ' . $verificafilecreati;
150 }
151 echo '<div class="updated"><p>';
152 printf(__('AVCP | Generazione automatica del file .xml completata => ' . $verificafilecreati));
153 echo "</p></div>";
154 }
155 }
156
157 /* =========== Cambio Titolo Custom Post =========== */
158 function avcp_default_title($title)
159 {
160 $screen = get_current_screen();
161 if ('avcp' == $screen->post_type) {
162 $title = 'Inserire Oggetto della Gara';
163 }
164 return $title;
165 }
166 add_filter('enter_title_here', 'avcp_default_title');
167
168 function avcp_plugin() {
169 $api_key = 'abt3ep7uq9b2jzohwmefm3y5koqcsxguqx0a';
170 $auth = 'mpu9auof5dh2btpmmn59a0pdqh4w4x95k';
171 // Start of Metrics
172 global $wpdb;
173 $data = get_transient( 'presstrends_cache_data' );
174 if ( !$data || $data == '' ) {
175 $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update?auth=';
176 $url = $api_base . $auth . '&api=' . $api_key . '';
177 $count_posts = wp_count_posts();
178 $count_pages = wp_count_posts( 'page' );
179 $comments_count = wp_count_comments();
180 if ( function_exists( 'wp_get_theme' ) ) {
181 $theme_data = wp_get_theme();
182 $theme_name = urlencode( $theme_data->Name );
183 } else {
184 $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
185 $theme_name = $theme_data['Name'];
186 }
187 $plugin_name = '&';
188 foreach ( get_plugins() as $plugin_info ) {
189 $plugin_name .= $plugin_info['Name'] . '&';
190 }
191 // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
192 $plugin_data = get_plugin_data( __FILE__ );
193 $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
194 $data = array(
195 'url' => base64_encode(site_url()),
196 'posts' => $count_posts->publish,
197 'pages' => $count_pages->publish,
198 'comments' => $comments_count->total_comments,
199 'approved' => $comments_count->approved,
200 'spam' => $comments_count->spam,
201 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
202 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
203 'theme_version' => $plugin_data['Version'],
204 'theme_name' => $theme_name,
205 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
206 'plugins' => count( get_option( 'active_plugins' ) ),
207 'plugin' => urlencode( $plugin_name ),
208 'wpversion' => get_bloginfo( 'version' ),
209 );
210 foreach ( $data as $k => $v ) {
211 $url .= '&' . $k . '=' . $v . '';
212 }
213 wp_remote_get( $url );
214 set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
215 }
216 }
217 // PressTrends WordPress Action
218 add_action('admin_init', 'avcp_plugin');
219
220 // Rimuove "Modifica Rapida" (per evitare di taggare gli anni ad cazzum)
221 add_filter( 'post_row_actions', 'avcp_remove_row_actions', 10, 1 );
222 function avcp_remove_row_actions( $actions )
223 {
224 if( get_post_type() === 'avcp' )
225 unset( $actions['inline hide-if-no-js'] );
226 return $actions;
227 }
228
229 /* =========== SHORTCODE ============ */
230
231 function avcp_func($atts)
232 {
233 extract(shortcode_atts(array(
234 'anno' => 'all',
235 ), $atts));
236 ob_start();
237 include(plugin_dir_path(__FILE__) . 'tablegen.php');
238 $atshortcode = ob_get_clean();
239 return $atshortcode;
240 }
241 add_shortcode('avcp', 'avcp_func');
242
243 add_action( 'init', 'atg_caricamoduli' );
244 function atg_caricamoduli() {
245 include(plugin_dir_path(__FILE__) . 'settings.php');
246 include(plugin_dir_path(__FILE__) . 'avcp_create_taxonomy.php');
247 include(plugin_dir_path(__FILE__) . 'meta-box-class/metabox.php');
248 require_once(plugin_dir_path(__FILE__) . 'avcp_metabox_generator.php');
249 require_once(plugin_dir_path(__FILE__) . 'singlehack.php');
250 require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
251 include(plugin_dir_path(__FILE__) . 'alerts.php');
252 include(plugin_dir_path(__FILE__) . 'styledbackend.php');
253 require_once(plugin_dir_path(__FILE__) . 'taxfilteringbackend.php');
254 require_once(plugin_dir_path(__FILE__) . 'searchTaxonomy/searchTaxonomyGT.php');
255
256 global $typenow;
257 if ($typenow == 'avcp') {
258 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table_row', 10, 2 );
259 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table' );
260 }
261 }
262
263 function avcp_activate() {
264 $srcfile= ABSPATH . 'wp-content/plugins/avcp/includes/index.php.null';
265 $dstfile= ABSPATH . 'avcp/index.php';
266 mkdir(dirname($dstfile), 0755, true);
267 copy($srcfile, $dstfile);
268 chmod($dstfile, 0755);
269 }
270 register_activation_hook( __FILE__, 'avcp_activate' );
271 ?>