forked from stackgrinder/shoestrap-extras-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shoestrap-extras-pack.php
171 lines (133 loc) · 4.41 KB
/
shoestrap-extras-pack.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/*
Plugin Name: Shoestrap Extras Pack
Plugin URI: http://wpmu.io
Description: Shoestrap Customizations and additions
Version: 0.7
Author: Aristeides Stathopoulos
Author URI: http://aristeides.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define the main file path
define ( 'SSEP_FILE_FATH', __FILE__ );
// Define the plugin version
define ( 'SSEP_PLUGIN_VER', '0.6' );
// Include the updater
require_once( plugin_dir_path(__FILE__) . 'includes/updater/updater.php' );
/**
*
*/
class Shoestrap_Extras_Pack {
function __construct() {
add_filter( 'redux/options/shoestrap/sections', array( $this, 'options' ) );
add_action( 'init', array( $this, 'init_meta_boxes' ), 9999 );
add_action( 'shoestrap_include_files', array( $this, 'include_files' ) );
add_filter( 'cmb_meta_boxes', array( $this, 'metabox' ) );
}
/*
* The admin options
*/
function options( $sections ) {
global $redux;
// Blog Options
$section = array(
'title' => __( 'Extras Pack', 'shoestrap' ),
'icon' => 'el-icon-plus',
);
$fields[] = array(
'id' => 'ssep_active_modules',
'type' => 'checkbox',
'title' => __( 'Activate extra modules', 'shoestrap' ),
'subtitle' => '',
'desc' => '',
'options' => array(
'hidemeta' => __( 'Hide meta per post', 'shoestrap' ),
'hidetitle' => __( 'Hide titles per post', 'shoestrap' ),
'jumbotrons' => __( 'Jombotron post type + per post assignments', 'shoestrap' ),
'layouts' => __( 'Per-Post Layouts', 'shoestrap' ),
'featured' => __( 'Featured Content Section', 'shoestrap' )
),
'default' => array(
'hidemeta' => '0',
'hidetitle' => '0',
'jumbotrons' => '0',
'layouts' => '0',
'featured' => '0'
)
);
$fields[] = array(
'id' => 'ssep_help',
'type' => 'info',
'title' => '',
'subtitle' => '',
'desc' => __( 'The featured content section displays your "sticky" posts in the jumbotron.
On first activation you will have to manually trigger the compiler (by changing for example the Jumbotron Background Color setting).', 'shoestrap' )
);
$section['fields'] = $fields;
$sections[] = $section;
return $sections;
}
/**
* Include files
*/
function include_files() {
global $ss_settings;
$ssep_active_modules = $ss_settings['ssep_active_modules'];
if ( isset( $ssep_active_modules['hidemeta'] ) && '1' == $ssep_active_modules['hidemeta'] ) {
// Hide meta info per-post
require_once( plugin_dir_path(__FILE__) . 'includes/hide-meta.php' );
}
if ( isset( $ssep_active_modules['hidetitle'] ) && '1' == $ssep_active_modules['hidetitle'] ) {
// Hide the title.
require_once( plugin_dir_path(__FILE__) . 'includes/hide-title.php' );
}
if ( isset( $ssep_active_modules['jumbotrons'] ) && '1' == $ssep_active_modules['jumbotrons'] ) {
// Add the Jumbotron Custom post type + fields
require_once( plugin_dir_path(__FILE__) . 'includes/jumbotron.php' );
}
if ( isset( $ssep_active_modules['layouts'] ) && '1' == $ssep_active_modules['layouts'] ) {
// Add Custom layouts per post
require_once( plugin_dir_path(__FILE__) . 'includes/layouts.php' );
}
if ( isset( $ssep_active_modules['featured'] ) && '1' == $ssep_active_modules['featured'] ) {
// Add Featured Content files
if ( ! class_exists( 'Featured_Content' ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
require_once( plugin_dir_path(__FILE__) . 'includes/class-Featured_Content.php' );
}
require_once( plugin_dir_path(__FILE__) . 'includes/featured.php' );
}
}
/**
* Initialize the metabox class.
*/
function init_meta_boxes() {
if ( ! class_exists( 'cmb_Meta_Box' ) )
require_once( plugin_dir_path(__FILE__) . 'includes/cmf/init.php' );
}
/**
* Define the metabox
*/
function metabox( array $meta_boxes ) {
// Get an array of the available post types
$post_types = get_post_types( array( 'public' => true ), 'objects' );
$pt_array = array();
foreach ( $post_types as $post_type ) {
if ( 'ss_jumbotron' != $post_type->name ) {
$pt_array[] = $post_type->name;
}
}
$meta_boxes[] = array(
'id' => 'ssep_metabox',
'title' => 'Shoestrap Extras',
'pages' => $pt_array,
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => apply_filters( 'ssep_metabox_fields', array() ),
);
return $meta_boxes;
}
}
$ssep = new Shoestrap_Extras_Pack();