-
Notifications
You must be signed in to change notification settings - Fork 0
/
sip-sidebars.php
executable file
·76 lines (61 loc) · 1.9 KB
/
sip-sidebars.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
<?php
/*
Plugin Name: Sip Sidebars Demo
Plugin URI: http://shopitpress.com
Author: atinder
Version: 1.0
*/
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if(!class_exists('SipSidebars')){
require_once dirname(__FILE__) . '/class.sip.sidebars.php';
}
if(!class_exists('SipMetabox')){
require_once dirname(__FILE__) . '/sip-metabox/class.sip.metabox.php';
}
class SipSidebarsDemo{
public function __construct(){
add_action( 'widgets_init', array($this,'config' ));
if ( is_admin() )
add_action( 'load-post.php', array('SipSidebarsDemo','call_metabox_class' ));
add_action( 'load-post-new.php', array('SipSidebarsDemo','call_metabox_class' ));
}
public function config(){
$sidebars[] = array(
'name' => __( 'Yea Right Sidebar' ),
'id' => 'right-sidebar'
);
$sidebars[] = array(
'name' => __( 'Test Left Hand Sidebar' ),
'id' => 'left-sidebar',
'description' => __( 'Widgets in this area will be shown on the right-hand side.' )
);
$sidebars_more = array('check','check2','check3');
$sidebars = array_merge_recursive($sidebars,$sidebars_more);
$wrapper = new SipSidebars($sidebars);
}
public function call_metabox_class(){
foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) {
$metaboxSidebars[] = $sidebar['name'];
}
array_unshift($metaboxSidebars, 'None');
$meta_boxes[] = array(
'id' => 'sip_sidebar_meta',
'title' => 'Sidebar',
'page' => 'post',
'context' => 'side',
'priority' => 'low',
'fields' => array(
array(
'name' => 'Sidebar',
'id' => 'sidebar',
'type' => 'select',
'std' => 'Sidebar',
'options' => $metaboxSidebars
)
)
);
$sipMetabox = new SipMetaBox($meta_boxes,plugins_url('',__FILE__));
}
}
new SipSidebarsDemo();