PluginProbe
Leaflet Map / 2.11.5
Leaflet Map v2.11.5
3.4.7 3.4.6 trunk 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.11.5 2.12.0 2.13.0 2.14.0 2.15.0 2.16.0 2.16.1 2.16.2 2.17.0 2.17.1 2.17.2 2.17.3 2.18.0 2.19.0 2.19.1 All 49 releases
leaflet-map / class.admin.php

class.admin.php in Leaflet Map 2.11.5, at class.admin.php

114 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Used to generate an admin for Leaflet Map
4 *
5 * PHP Version 5.5
6 *
7 * @category Admin
8 * @author Benjamin J DeLong <ben@bozdoz.com>
9 */
10
11 // Exit if accessed directly
12 if (!defined('ABSPATH')) {
13 exit;
14 }
15
16 /**
17 * Leaflet_Map_Admin class
18 */
19 class Leaflet_Map_Admin
20 {
21 /**
22 * Singleton Instance
23 *
24 * @var Leaflet_Map_Admin $_instance
25 */
26 private static $_instance = null;
27
28 /**
29 * Singleton
30 *
31 * @static
32 *
33 * @return Leaflet_Map_Admin
34 */
35 public static function init()
36 {
37 if (!self::$_instance) {
38 self::$_instance = new self;
39 }
40
41 return self::$_instance;
42 }
43
44 /**
45 * Instantiate the class
46 */
47 private function __construct()
48 {
49 add_action('admin_init', array($this, 'admin_init'));
50 add_action('admin_menu', array($this, 'admin_menu'));
51 add_action('admin_enqueue_scripts', array('Leaflet_Map', 'enqueue_and_register'));
52
53 /* add settings to plugin page */
54 add_filter('plugin_action_links_' . plugin_basename(LEAFLET_MAP__PLUGIN_FILE), array($this, 'plugin_action_links'));
55 }
56
57 /**
58 * Admin init registers styles
59 */
60 public function admin_init()
61 {
62 wp_register_style('leaflet_admin_stylesheet', plugins_url('style.css', LEAFLET_MAP__PLUGIN_FILE));
63 }
64
65 /**
66 * Add admin menu page when user in admin area
67 */
68 public function admin_menu()
69 {
70 if (current_user_can('manage_options')) {
71 $main_link = 'leaflet-map';
72 } else {
73 $main_link = 'leaflet-shortcode-helper';
74 }
75
76 add_menu_page("Leaflet Map", "Leaflet Map", 'manage_options', $main_link, array($this, "settings_page"), plugins_url('images/leaf.png', LEAFLET_MAP__PLUGIN_FILE));
77 add_submenu_page("leaflet-map", "Default Values", "Default Values", 'manage_options', "leaflet-map", array($this, "settings_page"));
78 add_submenu_page("leaflet-map", "Shortcode Helper", "Shortcode Helper", 'edit_posts', "leaflet-shortcode-helper", array($this, "shortcode_page"));
79 }
80
81 /**
82 * Main settings page includes form inputs
83 */
84 public function settings_page()
85 {
86 wp_enqueue_style('leaflet_admin_stylesheet');
87
88 $settings = Leaflet_Map_Plugin_Settings::init();
89 $plugin_data = get_plugin_data(LEAFLET_MAP__PLUGIN_FILE);
90 include 'templates/settings.php';
91 }
92
93 /**
94 * Shortcode page shows example shortcodes and an interactive generator
95 */
96 public function shortcode_page()
97 {
98 wp_enqueue_style('leaflet_admin_stylesheet');
99 wp_enqueue_script('custom_plugin_js', plugins_url('scripts/shortcode-helper.min.js', LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false);
100
101 include 'templates/shortcode-helper.php';
102 }
103
104 /**
105 * Add settings link to the plugin on Installed Plugins page
106 *
107 * @return array
108 */
109 public function plugin_action_links($links)
110 {
111 $links[] = '<a href="'. esc_url( get_admin_url(null, 'admin.php?page=leaflet-map') ) .'">Settings</a>';
112 return $links;
113 }
114 }