PluginProbe
Menu Icons by Themeisle – Add Icons to Navigation Menus / 0.9.0
Menu Icons by Themeisle – Add Icons to Navigation Menus v0.9.0
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
161 lines 3.5 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.9.0
8 * @author Dzikri Aziz <kvcrvt@gmail.com>
9 *
10 *
11 * Plugin name: Menu Icons
12 * Plugin URI: http://kucrut.org/
13 * Description: Spice up your navigation menus with pretty icons, easily.
14 * Version: 0.9.0
15 * Author: Dzikri Aziz
16 * Author URI: http://kucrut.org/
17 * License: GPLv2
18 * Text Domain: menu-icons
19 * Domain Path: /languages
20 */
21
22
23 /**
24 * Main plugin class
25 */
26 final class Menu_Icons {
27
28 const VERSION = '0.9.0';
29
30 /**
31 * Holds plugin data
32 *
33 * @access protected
34 * @since 0.1.0
35 * @var array
36 */
37 protected static $data;
38
39
40 /**
41 * Get plugin data
42 *
43 * @since 0.1.0
44 * @since 0.9.0 Return NULL if $name is not set in $data.
45 * @param string $name
46 *
47 * @return mixed
48 */
49 public static function get( $name = null ) {
50 if ( is_null( $name ) ) {
51 return self::$data;
52 }
53
54 if ( isset( self::$data[ $name ] ) ) {
55 return self::$data[ $name ];
56 }
57
58 return null;
59 }
60
61
62 /**
63 * Load plugin
64 *
65 * 1. Load translation
66 * 2. Set plugin data (directory and URL paths)
67 * 3. Attach plugin initialization at icon_picker_init hook
68 *
69 * @since 0.1.0
70 * @wp_hook action plugins_loaded
71 * @link http://codex.wordpress.org/Plugin_API/Action_Reference/plugins_loaded
72 */
73 public static function _load() {
74 load_plugin_textdomain( 'menu-icons', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
75
76 self::$data = array(
77 'dir' => plugin_dir_path( __FILE__ ),
78 'url' => plugin_dir_url( __FILE__ ),
79 'types' => array(),
80 );
81
82 // Load Icon Picker.
83 if ( ! class_exists( 'Icon_Picker' ) ) {
84 require_once self::$data['dir'] . 'includes/library/icon-picker/icon-picker.php';
85 }
86 Icon_Picker::instance();
87
88 require_once self::$data['dir'] . 'includes/library/compat.php';
89 require_once self::$data['dir'] . 'includes/library/functions.php';
90 require_once self::$data['dir'] . 'includes/meta.php';
91
92 Menu_Icons_Meta::init();
93
94 add_action( 'icon_picker_init', array( __CLASS__, '_init' ), 9 );
95 }
96
97
98 /**
99 * Initialize
100 *
101 * 1. Get registered types from Icon Picker
102 * 2. Load settings
103 * 3. Load front-end functionalities
104 *
105 * @since 0.1.0
106 * @since 0.9.0 Hook into `icon_picker_init`.
107 * @wp_hook action icon_picker_init
108 * @link http://codex.wordpress.org/Plugin_API/Action_Reference
109 */
110 public static function _init() {
111 /**
112 * Allow themes/plugins to add/remove icon types
113 *
114 * @since 0.1.0
115 * @param array $types Icon types
116 */
117 self::$data['types'] = apply_filters(
118 'menu_icons_types',
119 Icon_Picker_Types_Registry::instance()->types
120 );
121
122 // Nothing to do if there are no icon types registered.
123 if ( empty( self::$data['types'] ) ) {
124 if ( WP_DEBUG ) {
125 trigger_error( esc_html__( 'Menu Icons: No registered icon types found.', 'menu-icons' ) );
126 }
127
128 return;
129 }
130
131 // Load settings.
132 require_once self::$data['dir'] . 'includes/settings.php';
133 Menu_Icons_Settings::init();
134
135 // Load front-end functionalities.
136 if ( ! is_admin() ) {
137 require_once self::$data['dir'] . '/includes/front.php';
138 Menu_Icons_Front_End::init();
139 }
140
141 do_action( 'menu_icons_loaded' );
142 }
143
144
145 /**
146 * Get script & style suffix
147 *
148 * When SCRIPT_DEBUG is defined true, this will return '.min'.
149 *
150 * @since 0.2.0
151 * @since 0.9.0 Deprecated.
152 * @return string
153 */
154 public static function get_script_suffix() {
155 _deprecated_function( __METHOD__, '0.9.0', 'kucrut_get_script_suffix' );
156
157 return kucrut_get_script_suffix();
158 }
159 }
160 add_action( 'plugins_loaded', array( 'Menu_Icons', '_load' ) );
161