forked from ionic-team/ionicons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathionicons.php
100 lines (79 loc) · 2.48 KB
/
ionicons.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
<?php
/**
* Plugin Name: ionicons
* Plugin URI: https://github.com/ConnectThink/ionicons
* Description: Adds support for ionicons http://http://ionicons.com/
* Version: 1.0.0
* Author: Connect Think
* Author URI: http://connectthink.com
* License: MIT
*/
/*
* PLUGIN GLOBAL VARIABLES
*/
// Plugin Paths
if (!defined('IONICONS_PLUGIN_NAME'))
define('IONICONS_PLUGIN_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
if (!defined('IONICONS_PLUGIN_URL'))
define('IONICONS_PLUGIN_URL', WP_PLUGIN_URL . '/' . IONICONS_PLUGIN_NAME);
// Plugin Version
if (!defined('IONICONS_VERSION_KEY'))
define('IONICONS_VERSION_KEY', 'ionicons_version');
if (!defined('IONICONS_VERSION_NUM'))
define('IONICONS_VERSION_NUM', '1.0.0');
// Add version to options table
add_option(IONICONS_VERSION_KEY, IONICONS_VERSION_NUM);
/*
* ADD CHEAT SHEET LINK
*/
add_filter('plugin_action_links', 'ionicons_plugin_action_links', 10, 2);
function ionicons_plugin_action_links($links, $file) {
static $this_plugin;
if( !$this_plugin ) {
$this_plugin = plugin_basename(__FILE__);
}
if ($file == $this_plugin) {
$settings_link = '<a href="' . IONICONS_PLUGIN_URL .'/cheatsheet.html" target="_blank">Cheat Sheet</a>';
array_unshift($links, $settings_link);
}
return $links;
}
/*
* CLASS DEFINITION
*/
class IonIcons {
/**
* Define stylesheet properties for enqueuing
* Add hooks to enqueue stylesheets and register shortcode
*/
public function __construct() {
$this->name = IONICONS_PLUGIN_NAME;
$this->uri = IONICONS_PLUGIN_URL . '/css/ionicons.min.css';
$this->ver = '1.0';
add_action('wp_enqueue_scripts', array($this, 'register_ionicons'));
add_action('admin_enqueue_scripts', array($this, 'register_ionicons'));
add_shortcode('icon', array($this, 'ionicons_shortcode'));
}
/**
* Enqueues stylesheet using instance properties
* @return nothing
*/
public function register_ionicons() {
wp_enqueue_style( $this->name, $this->uri, array(), $this->ver, 'all');
}
/**
* Define Shortcode [icon name=ion-icon-name]
* @param string $atts = name of icon to be passed in shortcode
* @return html for icon display using passed $atts
*/
public function ionicons_shortcode($atts) {
extract(shortcode_atts(array(
'name' => '',
), $atts));
return '<i class="icon ' . $atts['name'] . '"> </i>';
}
} // End Class Definition
/*
* OBJECT INSTANTIATION
*/
$ionicons = new IonIcons;