PluginProbe
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.12.10
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.12.10
0.13.24 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 All 70 releases
menu-icons / menu-icons.php
menu-icons.php
171 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.12.10
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.12.10';
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
84 Icon_Picker::instance();
85
86 require_once self::$data['dir'] . 'includes/library/compat.php';
87 require_once self::$data['dir'] . 'includes/library/functions.php';
88 require_once self::$data['dir'] . 'includes/meta.php';
89
90 Menu_Icons_Meta::init();
91
92 add_action( 'icon_picker_init', array( __CLASS__, '_init' ), 9 );
93 }
94
95
96 /**
97 * Initialize
98 *
99 * 1. Get registered types from Icon Picker
100 * 2. Load settings
101 * 3. Load front-end functionalities
102 *
103 * @since 0.1.0
104 * @since 0.9.0 Hook into `icon_picker_init`.
105 * @wp_hook action icon_picker_init
106 * @link http://codex.wordpress.org/Plugin_API/Action_Reference
107 */
108 public static function _init() {
109 /**
110 * Allow themes/plugins to add/remove icon types
111 *
112 * @since 0.1.0
113 * @param array $types Icon types
114 */
115 self::$data['types'] = apply_filters(
116 'menu_icons_types',
117 Icon_Picker_Types_Registry::instance()->types
118 );
119
120 // Nothing to do if there are no icon types registered.
121 if ( empty( self::$data['types'] ) ) {
122 if ( WP_DEBUG ) {
123 trigger_error( esc_html__( 'Menu Icons: No registered icon types found.', 'menu-icons' ) );
124 }
125
126 return;
127 }
128
129 // Load settings.
130 require_once self::$data['dir'] . 'includes/settings.php';
131 Menu_Icons_Settings::init();
132
133 // Load front-end functionalities.
134 if ( ! is_admin() ) {
135 require_once self::$data['dir'] . '/includes/front.php';
136 Menu_Icons_Front_End::init();
137 }
138
139 do_action( 'menu_icons_loaded' );
140 }
141
142
143 /**
144 * Display notice about missing Icon Picker
145 *
146 * @since 0.9.1
147 * @wp_hook action admin_notice
148 */
149 public static function _notice_missing_icon_picker() {
150 ?>
151 <div class="error">
152 <p><?php esc_html_e( 'Looks like Menu Icons was installed via Composer. Please activate Icon Picker first.', 'menu-icons' ); ?></p>
153 </div>
154 <?php
155 }
156 }
157 add_action( 'plugins_loaded', array( 'Menu_Icons', '_load' ) );
158
159 $vendor_file = dirname(__FILE__) . '/vendor/autoload.php';
160
161 if ( is_readable( $vendor_file ) ) {
162 require_once $vendor_file;
163 }
164
165 add_filter( 'themeisle_sdk_products', 'kucrut_register_sdk', 10, 1 );
166 function kucrut_register_sdk( $products ) {
167
168 $products[] = __FILE__;
169 return $products;
170 }
171