PluginProbe
ANAC XML Bandi di Gara / 2.2
ANAC XML Bandi di Gara v2.2
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.2, at avcp.php

277 lines 10.5 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.2
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('2012', 'annirif');
128 wp_insert_term('2013', 'annirif');
129 wp_insert_term('2014', 'annirif');
130 }
131
132 add_action('save_post', 'save_at_gara_posts',10,2);
133 function save_at_gara_posts($post_id) {
134
135 $post = get_post($post_id);
136 // If this isn't a 'book' post, don't update it.
137 $slug = 'avcp'; if ( $slug != $post->post_type ) { return; }
138
139 $get_avcp_autopublish = get_option('avcp_autopublish');
140 if ($get_avcp_autopublish == '1') {
141 $terms = wp_get_post_terms($post_id, 'annirif');
142 $count = count($terms);
143 if (!($count > 0 )){
144 echo '<div class="error"><p>';
145 printf(__('AVCP | Errore: impossibile ricreare il file .xml: la gara inserita non ha ditte collegate' . $verificafilecreati));
146 echo "</p></div>";
147 }
148 require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
149 foreach ( $terms as $term ) {
150 creafilexml ($term->name);
151 $verificafilecreati = $term->name . ' - ' . $verificafilecreati;
152 }
153 echo '<div class="updated"><p>';
154 printf(__('AVCP | Generazione automatica del file .xml completata => ' . $verificafilecreati));
155 echo "</p></div>";
156 }
157 }
158
159 /* =========== Cambio Titolo Custom Post =========== */
160 function avcp_default_title($title)
161 {
162 $screen = get_current_screen();
163 if ('avcp' == $screen->post_type) {
164 $title = 'Inserire Oggetto della Gara';
165 }
166 return $title;
167 }
168 add_filter('enter_title_here', 'avcp_default_title');
169
170 function avcp_plugin() {
171 $api_key = 'abt3ep7uq9b2jzohwmefm3y5koqcsxguqx0a';
172 $auth = 'mpu9auof5dh2btpmmn59a0pdqh4w4x95k';
173 // Start of Metrics
174 global $wpdb;
175 $data = get_transient( 'presstrends_cache_data' );
176 if ( !$data || $data == '' ) {
177 $api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update?auth=';
178 $url = $api_base . $auth . '&api=' . $api_key . '';
179 $count_posts = wp_count_posts();
180 $count_pages = wp_count_posts( 'page' );
181 $comments_count = wp_count_comments();
182 if ( function_exists( 'wp_get_theme' ) ) {
183 $theme_data = wp_get_theme();
184 $theme_name = urlencode( $theme_data->Name );
185 } else {
186 $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
187 $theme_name = $theme_data['Name'];
188 }
189 $plugin_name = '&';
190 foreach ( get_plugins() as $plugin_info ) {
191 $plugin_name .= $plugin_info['Name'] . '&';
192 }
193 // CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
194 $plugin_data = get_plugin_data( __FILE__ );
195 $posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
196 $data = array(
197 'url' => base64_encode(site_url()),
198 'posts' => $count_posts->publish,
199 'pages' => $count_pages->publish,
200 'comments' => $comments_count->total_comments,
201 'approved' => $comments_count->approved,
202 'spam' => $comments_count->spam,
203 'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
204 'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
205 'theme_version' => $plugin_data['Version'],
206 'theme_name' => $theme_name,
207 'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
208 'plugins' => count( get_option( 'active_plugins' ) ),
209 'plugin' => urlencode( $plugin_name ),
210 'wpversion' => get_bloginfo( 'version' ),
211 );
212 foreach ( $data as $k => $v ) {
213 $url .= '&' . $k . '=' . $v . '';
214 }
215 wp_remote_get( $url );
216 set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
217 }
218 }
219 // PressTrends WordPress Action
220 add_action('admin_init', 'avcp_plugin');
221
222 // Rimuove "Modifica Rapida" (per evitare di taggare gli anni ad cazzum)
223 add_filter( 'post_row_actions', 'avcp_remove_row_actions', 10, 1 );
224 function avcp_remove_row_actions( $actions )
225 {
226 if( get_post_type() === 'avcp' )
227 unset( $actions['inline hide-if-no-js'] );
228 return $actions;
229 }
230
231 /* =========== SHORTCODE ============ */
232
233 function avcp_func($atts)
234 {
235 extract(shortcode_atts(array(
236 'anno' => 'all',
237 ), $atts));
238 ob_start();
239 include(plugin_dir_path(__FILE__) . 'tablegen.php');
240 $atshortcode = ob_get_clean();
241 return $atshortcode;
242 }
243 add_shortcode('avcp', 'avcp_func');
244
245 add_action( 'init', 'atg_caricamoduli' );
246 function atg_caricamoduli() {
247 include(plugin_dir_path(__FILE__) . 'settings.php');
248 include(plugin_dir_path(__FILE__) . 'avcp_create_taxonomy.php');
249 include(plugin_dir_path(__FILE__) . 'meta-box-class/metabox.php');
250 require_once(plugin_dir_path(__FILE__) . 'avcp_metabox_generator.php');
251 require_once(plugin_dir_path(__FILE__) . 'singlehack.php');
252 require_once(plugin_dir_path(__FILE__) . 'avcp_xml_generator.php');
253 include(plugin_dir_path(__FILE__) . 'alerts.php');
254 include(plugin_dir_path(__FILE__) . 'styledbackend.php');
255 require_once(plugin_dir_path(__FILE__) . 'taxfilteringbackend.php');
256 require_once(plugin_dir_path(__FILE__) . 'searchTaxonomy/searchTaxonomyGT.php');
257
258 //Include sistemi di validazione
259 include(plugin_dir_path(__FILE__) . 'valid_check.php');
260 include(plugin_dir_path(__FILE__) . 'valid_page.php');
261
262 global $typenow;
263 if ($typenow == 'avcp') {
264 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table_row', 10, 2 );
265 add_filter( 'manage_posts_custom_column', 'avcp_modify_post_table' );
266 }
267 }
268
269 function avcp_activate() {
270 $srcfile= ABSPATH . 'wp-content/plugins/avcp/includes/index.php.null';
271 $dstfile= ABSPATH . 'avcp/index.php';
272 mkdir(dirname($dstfile), 0755, true);
273 copy($srcfile, $dstfile);
274 chmod($dstfile, 0755);
275 }
276 register_activation_hook( __FILE__, 'avcp_activate' );
277 ?>