PluginProbe ʕ •ᴥ•ʔ
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.11.2
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.11.2
trunk 0.1.0 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.11.2 0.11.3 0.11.4 0.11.5 0.12.0 0.12.1 0.12.10 0.12.11 0.12.12 0.12.2 0.12.3 0.12.4 0.12.5 0.12.6 0.12.7 0.12.8 0.12.9 0.13.0 0.13.1 0.13.10 0.13.11 0.13.12 0.13.13 0.13.14 0.13.15 0.13.16 0.13.17 0.13.18 0.13.19 0.13.2 0.13.20 0.13.21 0.13.22 0.13.23 0.13.3 0.13.4 0.13.5 0.13.6 0.13.7 0.13.8 0.13.9 0.2.0 0.2.1 0.2.2 0.2.3 0.3.0 0.3.1 0.3.2 0.4.0 0.5.0 0.5.1 0.6.0 0.7.0 0.8.0 0.8.1 0.9.0 0.9.2
menu-icons / menu-icons.php
menu-icons Last commit date
assets 8 years ago css 8 years ago includes 8 years ago js 8 years ago languages 8 years ago vendor 8 years ago CHANGELOG.md 8 years ago LICENSE 8 years ago mailin.php 8 years ago menu-icons.php 8 years ago readme.md 8 years ago readme.txt 8 years ago
menu-icons.php
179 lines
1 <?php
2
3 /**
4 * Menu Icons
5 *
6 * @package Menu_Icons
7 * @version 0.10.2
8 * @author Dzikri Aziz <kvcrvt@gmail.com>
9 *
10 *
11 * Plugin name: Menu Icons
12 * Plugin URI: https://github.com/Codeinwp/wp-menu-icons
13 * Description: Spice up your navigation menus with pretty icons, easily.
14 * Version: 0.11.2
15 * Author: ThemeIsle
16 * Author URI: https://themeisle.com
17 * License: GPLv2
18 * Text Domain: menu-icons
19 * Domain Path: /languages
20 * WordPress Available: yes
21 * Requires License: no
22 */
23
24
25 /**
26 * Main plugin class
27 */
28 final class Menu_Icons {
29
30 const VERSION = '0.11.2';
31
32 /**
33 * Holds plugin data
34 *
35 * @access protected
36 * @since 0.1.0
37 * @var array
38 */
39 protected static $data;
40
41
42 /**
43 * Get plugin data
44 *
45 * @since 0.1.0
46 * @since 0.9.0 Return NULL if $name is not set in $data.
47 * @param string $name
48 *
49 * @return mixed
50 */
51 public static function get( $name = null ) {
52 if ( is_null( $name ) ) {
53 return self::$data;
54 }
55
56 if ( isset( self::$data[ $name ] ) ) {
57 return self::$data[ $name ];
58 }
59
60 return null;
61 }
62
63
64 /**
65 * Load plugin
66 *
67 * 1. Load translation
68 * 2. Set plugin data (directory and URL paths)
69 * 3. Attach plugin initialization at icon_picker_init hook
70 *
71 * @since 0.1.0
72 * @wp_hook action plugins_loaded
73 * @link http://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
74 */
75 public static function _load() {
76 load_plugin_textdomain( 'menu-icons', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
77
78 self::$data = array(
79 'dir' => plugin_dir_path( __FILE__ ),
80 'url' => plugin_dir_url( __FILE__ ),
81 'types' => array(),
82 );
83 $vendor_file = dirname(__FILE__) . '/vendor/autoload.php';
84
85 if ( is_readable( $vendor_file ) ) {
86 require_once $vendor_file;
87 }
88 // Load Icon Picker.
89 if ( ! class_exists( 'Icon_Picker' ) ) {
90 $ip_file = self::$data['dir'] . 'includes/library/icon-picker/icon-picker.php';
91
92 if ( file_exists( $ip_file ) ) {
93 require_once $ip_file;
94 } else {
95 add_action( 'admin_notices', array( __CLASS__, '_notice_missing_icon_picker' ) );
96 return;
97 }
98 }
99 Icon_Picker::instance();
100
101 require_once self::$data['dir'] . 'includes/library/compat.php';
102 require_once self::$data['dir'] . 'includes/library/functions.php';
103 require_once self::$data['dir'] . 'includes/meta.php';
104
105 Menu_Icons_Meta::init();
106
107 add_action( 'icon_picker_init', array( __CLASS__, '_init' ), 9 );
108 }
109
110
111 /**
112 * Initialize
113 *
114 * 1. Get registered types from Icon Picker
115 * 2. Load settings
116 * 3. Load front-end functionalities
117 *
118 * @since 0.1.0
119 * @since 0.9.0 Hook into `icon_picker_init`.
120 * @wp_hook action icon_picker_init
121 * @link http://codex.wordpress.org/Plugin_API/Action_Reference
122 */
123 public static function _init() {
124 /**
125 * Allow themes/plugins to add/remove icon types
126 *
127 * @since 0.1.0
128 * @param array $types Icon types
129 */
130 self::$data['types'] = apply_filters(
131 'menu_icons_types',
132 Icon_Picker_Types_Registry::instance()->types
133 );
134
135 // Nothing to do if there are no icon types registered.
136 if ( empty( self::$data['types'] ) ) {
137 if ( WP_DEBUG ) {
138 trigger_error( esc_html__( 'Menu Icons: No registered icon types found.', 'menu-icons' ) );
139 }
140
141 return;
142 }
143
144 // Load settings.
145 require_once self::$data['dir'] . 'includes/settings.php';
146 Menu_Icons_Settings::init();
147
148 // Load front-end functionalities.
149 if ( ! is_admin() ) {
150 require_once self::$data['dir'] . '/includes/front.php';
151 Menu_Icons_Front_End::init();
152 }
153
154 do_action( 'menu_icons_loaded' );
155 }
156
157
158 /**
159 * Display notice about missing Icon Picker
160 *
161 * @since 0.9.1
162 * @wp_hook action admin_notice
163 */
164 public static function _notice_missing_icon_picker() {
165 ?>
166 <div class="error">
167 <p><?php esc_html_e( 'Looks like Menu Icons was installed via Composer. Please activate Icon Picker first.', 'menu-icons' ); ?></p>
168 </div>
169 <?php
170 }
171 }
172 add_action( 'plugins_loaded', array( 'Menu_Icons', '_load' ) );
173
174 add_filter( 'themeisle_sdk_products', 'kucrut_register_sdk', 10, 1 );
175 function kucrut_register_sdk( $products ) {
176
177 $products[] = __FILE__;
178 return $products;
179 }