forked from bearded-avenger/nb-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnb-plugin.php
108 lines (82 loc) · 2.64 KB
/
nb-plugin.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
101
102
103
104
105
106
<?php
/*
Author: Nick Haskins
Author URI: http://nickhaskins.com
Plugin Name: Nicks Base Plugin
Plugin URI: http://nickhaskins.com
Version: 1.2
Description: A base plugin for PageLines DMS.
Demo:
Pagelines:true
*/
// Check to make sure we're in DMS
add_action('pagelines_setup', 'nbplugin_init' );
function nbplugin_init() {
if( !function_exists('pl_has_editor') )
return;
$landing = new nbBasePlugin;
}
class nbBasePlugin {
const version = '1.2';
function __construct() {
$this->id = 'nb_plugin';
$this->name = 'Nicks Base Plugin';
$this->dir = plugin_dir_path( __FILE__ );
$this->url = plugins_url( '', __FILE__ );
$this->icon = plugins_url( '/icon.png', __FILE__ );
add_action( 'template_redirect', array(&$this,'insert_less' ));
add_action( 'init', array( &$this, 'init' ) );
}
// Add a less file
function insert_less() {
$file = sprintf( '%sstyle.less', plugin_dir_path( __FILE__ ) );
if(function_exists('pagelines_insert_core_less')) {
pagelines_insert_core_less( $file );
}
}
function init(){
add_action( 'wp_enqueue_scripts', array(&$this,'scripts' ));
add_filter('pl_settings_array', array(&$this, 'options'));
}
// Enqueue stuffs
function scripts(){
wp_register_script('nbplugin-script',$this->url.'/script.js', array('jquery'), self::version, true );
//wp_enqueue_script('nbplugin-script');
}
// Init options
// Choose from Font Awesome icons for Icon
// Position denotes how far from top in Global Options Tab
function options( $settings ){
$settings[ $this->id ] = array(
'name' => $this->name,
'icon' => 'icon-thumbs-up',
'pos' => 5,
'opts' => $this->global_opts()
);
return $settings;
}
// Draw Options Panel
// Call settings as $var = pl_setting($this->id.'_optionB');
function global_opts(){
$global_opts = array(
array(
'key' => $this->id.'_optionA',
'type' => 'multi',
'title' => __('Sample Option', 'nb-plugin'),
'opts' => array(
array(
'key' => $this->id.'_optionB',
'type' => 'text',
'label' => __('Some Option', 'nb-plugin'),
),
array(
'key' => $this->id.'_optionC',
'type' => 'text',
'label' => __('Some Option', 'nb-plugin'),
),
),
),
);
return $global_opts;
}
}