-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapy-cz.php
102 lines (89 loc) · 3.11 KB
/
mapy-cz.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
* Plugin Name: Mapy.cz
* Plugin URI: https://github.com/matyasbach/Mapy.cz-Wordpress-Plugin
* Version: 0.1
* Author: Matyáš Bach
* Author URI: mailto://[email protected]
* Description: A plugin to display mapy.cz map
* License: Unlicense + mapy.cz API license
* License URI: https://api.mapy.cz/
* Text Domain: mapy-cz
*/
namespace MapyCZ;
defined ( 'ABSPATH' ) or die ( 'No script kiddies please!' );
class MapyCZ {
function __construct() {
$inc_path = plugin_dir_path ( __FILE__ ) . '/inc/';
$admin_path = plugin_dir_path ( __FILE__ ) . '/admin/';
$this->languages_path = basename ( dirname( __FILE__ ) ) . '/languages/';
$this->inc_list = array(
'admin' => $admin_path . 'admin.php',
'front' => $inc_path . 'front.php',
'map_ajax' => $inc_path . 'map-ajax.php',
);
}
public function init() {
add_action ( 'init', array ( $this, 'register_map_post_type' ) );
add_action ( 'admin_init', function() {
include_once $this->inc_list['admin'];
new Admin;
});
add_action ( 'plugins_loaded', function() {
load_plugin_textdomain( 'mapy-cz', false, $this->languages_path );
});
add_shortcode ( 'mcz_map', function( $atts ) {
include_once $this->inc_list['front'];
if( ! isset( $this->front ) ) {
$this->front = new Front;
}
return $this->front->mcz_map_shortcode( $atts );
});
add_action ( 'wp_ajax_mapy-cz-get-map', array ( $this, 'get_maps' ) );
add_action ( 'wp_ajax_nopriv_mapy-cz-get-map', array ( $this, 'get_maps' ) );
}
function get_maps() {
include_once $this->inc_list['map_ajax'];
get_maps_ajax();
}
/**
* Registers a Custom Post Type: map
*/
function register_map_post_type() {
register_post_type ( 'mapy-cz-map', array(
'labels' => array(
'name' => _x( 'Mapy.cz Maps', 'post type general name', 'mapy-cz' ),
'singular_name' => _x( 'Mapy.cz Map', 'post type singular name', 'mapy-cz' ),
'menu_name' => _x( 'Mapy.cz', 'admin menu', 'mapy-cz' ),
'name_admin_bar' => _x( 'Mapy.cz Map', 'add new on admin bar', 'mapy-cz' ),
'add_new' => _x( 'Add new', 'sub menu', 'mapy-cz' ),
'add_new_item' => __( 'Add new map', 'mapy-cz' ),
'new_item' => __( 'New Map', 'mapy-cz' ),
'edit_item' => __( 'Edit Map', 'mapy-cz' ),
'view_item' => __( 'View Map', 'mapy-cz' ),
'all_items' => __( 'All Maps', 'mapy-cz' ),
'search_items' => __( 'Search Maps', 'mapy-cz' ),
'parent_item_colon' => __( 'Parent Maps:', 'mapy-cz' ),
'not_found' => __( 'No maps found.', 'mapy-cz' ),
'not_found_in_trash' => __( 'No maps found in Trash.', 'mapy-cz' ),
),
// Frontend
'has_archive' => false,
'public' => false,
'publicly_queryable' => false,
// Admin
'capability_type' => 'post',
'show_ui' => true,
'menu_position' => 100,
'menu_icon' => plugins_url ( 'admin/img/mapy-cz.png', __FILE__ ),
'supports' => array(
'title',
'author',
'custom_fields',
'revisions'
),
));
}
}
$mapyCZ = new MapyCZ();
$mapyCZ->init();