-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanac-xml-viewer.php
88 lines (79 loc) · 2.8 KB
/
anac-xml-viewer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
Plugin Name: ANAC XML Viewer
Plugin URI: https://wordpress.org/plugins/anac-xml-viewer/
Description: Visualizzatore XML per file generati da applicativi esterni
Author: Marco Milesi
Version: 1.7.1
Author URI: https://marcomilesi.com
*/
add_action( 'init', 'register_cpt_anacimporter' );
function register_cpt_anacimporter() {
$labels = array(
'name' => 'Visualizzatore dataset XML Anac',
'singular_name' => 'Dataset XML',
'add_new' => 'Nuovo Dataset',
'add_new_item' => 'Importa Nuovo Dataset',
'edit_item' => 'Modifica Dataset',
'new_item' => 'Nuovo Dataset',
'view_item' => 'Vedi Dataset',
'search_items' => 'Cerca Dataset',
'not_found' => 'Nessuna voce trovata',
'not_found_in_trash' => 'Nessuna voce trovata',
'parent_item_colon' => 'Parent:',
'menu_name' => 'Anac XML',
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Gare AVCP',
'supports' => array( 'title', 'editor'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 37,
'menu_icon' => 'dashicons-list-view',
'show_in_nav_menus' => false,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
'can_export' => false,
'rewrite' => false
);
register_post_type( 'anac-xml-view', $args );
}
require_once(plugin_dir_path(__FILE__) . 'core.php');
add_action( 'admin_notices', function() {
global $current_screen;
if ( 'anac-xml-view' == $current_screen->post_type ) {
echo '
<div class="notice">
<p>Puoi importare un file XML copiando e incollando il contenuto o inserendo un indirizzo URL completo. Tutorial: <a href="https://youtu.be/cdn082kZogk" target="_blank">youtu.be/cdn082kZogk</a></p>
</div>';
}
} );
function axv_columns($columns) {
$columns['atype'] = 'Dettagli';
unset($columns['date']);
$columns['date'] = 'Data';
return $columns;
}
add_filter('manage_edit-anac-xml-view_columns', 'axv_columns');
add_filter('bulk_actions-edit-anac-xml-view', '__return_empty_array');
add_action('manage_anac-xml-view_posts_custom_column', 'axv_manage_columns', 10, 2);
function axv_manage_columns($column, $post_id)
{
global $post;
switch ($column) {
case 'atype':
if ( substr( get_post_field('post_content', $post_id), 0, 4 ) === "http" ) {
printf( '<a target="_blank" href="'.get_post_field('post_content', $post_id ).'">'.get_post_field('post_content', $post_id ).'</a><br>' );
}
printf( 'Shortcode: [anac-xml id="' . $post_id . '"]');
break;
default:
break;
}
}
?>