Version Description
Download this release
Release Info
Developer | Nikschavan |
Plugin | Lightweight Sidebar Manager |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- classes/class-bsf-sb-loader.php +3 -18
- classes/class-bsf-sb-metabox.php +42 -70
- classes/class-bsf-sb-post-type.php +42 -33
- classes/class-bsf-sb-sidebar.php +42 -39
- classes/class-bsf-sb-white-label.php +174 -0
- classes/modules/target-rule/{class-bsf-sb-rules-fields.php → class-bsf-sb-target-rules-fields.php} +608 -124
- includes/white-label.php +36 -0
- languages/custom-sidebars.pot +282 -0
- readme.txt +13 -3
- sidebar-manager.php +24 -6
classes/class-bsf-sb-loader.php
CHANGED
@@ -35,25 +35,9 @@ if ( ! class_exists( 'BSF_SB_Loader' ) ) {
|
|
35 |
* Constructor
|
36 |
*/
|
37 |
public function __construct() {
|
38 |
-
$this->define_constants();
|
39 |
$this->load_files();
|
40 |
}
|
41 |
|
42 |
-
/**
|
43 |
-
* Define builder constants.
|
44 |
-
*
|
45 |
-
* @since 1.0.0
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
private function define_constants() {
|
49 |
-
define('BSF_SB_VER', '1.0.0');
|
50 |
-
define('BSF_SB_FILE', trailingslashit(dirname(dirname(__FILE__))) . 'sidebar-manager.php');
|
51 |
-
define('BSF_SB_DIR', plugin_dir_path(BSF_SB_FILE));
|
52 |
-
define('BSF_SB_URL', plugins_url('/', BSF_SB_FILE));
|
53 |
-
define('BSF_SB_PREFIX', 'bsf-sb');
|
54 |
-
define('BSF_SB_POST_TYPE', 'bsf-sidebar');
|
55 |
-
}
|
56 |
-
|
57 |
/**
|
58 |
* Loads classes and includes.
|
59 |
*
|
@@ -62,12 +46,13 @@ if ( ! class_exists( 'BSF_SB_Loader' ) ) {
|
|
62 |
*/
|
63 |
private function load_files() {
|
64 |
|
65 |
-
|
66 |
/* Classes */
|
67 |
-
require_once BSF_SB_DIR . 'classes/modules/target-rule/class-bsf-sb-rules-fields.php';
|
68 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-post-type.php';
|
69 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-sidebar.php';
|
70 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-metabox.php';
|
|
|
|
|
71 |
}
|
72 |
}
|
73 |
}
|
35 |
* Constructor
|
36 |
*/
|
37 |
public function __construct() {
|
|
|
38 |
$this->load_files();
|
39 |
}
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
/**
|
42 |
* Loads classes and includes.
|
43 |
*
|
46 |
*/
|
47 |
private function load_files() {
|
48 |
|
|
|
49 |
/* Classes */
|
50 |
+
require_once BSF_SB_DIR . 'classes/modules/target-rule/class-bsf-sb-target-rules-fields.php';
|
51 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-post-type.php';
|
52 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-sidebar.php';
|
53 |
require_once BSF_SB_DIR . 'classes/class-bsf-sb-metabox.php';
|
54 |
+
|
55 |
+
require_once BSF_SB_DIR . 'classes/class-bsf-sb-white-label.php';
|
56 |
}
|
57 |
}
|
58 |
}
|
classes/class-bsf-sb-metabox.php
CHANGED
@@ -49,7 +49,8 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
49 |
* Replace sidebar metabox.
|
50 |
*
|
51 |
* @since 1.0.0
|
52 |
-
* @
|
|
|
53 |
*/
|
54 |
public function change_post_name_palceholder( $title ) {
|
55 |
if ( get_post_type() == BSF_SB_POST_TYPE ) {
|
@@ -67,7 +68,7 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
67 |
public function metabox_actions() {
|
68 |
/* Remove the "Excerpt" meta box for the sidebars. */
|
69 |
remove_meta_box( 'postexcerpt', BSF_SB_POST_TYPE, 'normal' );
|
70 |
-
|
71 |
/* Target Rule */
|
72 |
add_meta_box( 'sidebar-settings', __( 'Sidebar Settings', 'bsfsidebars' ), array( $this, 'sidebar_settings' ), BSF_SB_POST_TYPE, 'normal', 'core' );
|
73 |
}
|
@@ -76,19 +77,20 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
76 |
* Replace sidebar metabox.
|
77 |
*
|
78 |
* @since 1.0.0
|
79 |
-
* @
|
80 |
*/
|
81 |
public function metabox_save( $post_id ) {
|
82 |
|
83 |
if ( get_post_type() != BSF_SB_POST_TYPE
|
84 |
-
|| ( isset( $_POST[ BSF_SB_POST_TYPE . '-nonce'] ) && ! wp_verify_nonce( $_POST[ BSF_SB_POST_TYPE . '-nonce'], BSF_SB_POST_TYPE ) )
|
85 |
) {
|
86 |
return $post_id;
|
87 |
}
|
88 |
|
89 |
// Verify if this is an auto save routine.
|
90 |
-
|
91 |
-
|
|
|
92 |
|
93 |
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
94 |
return $post_id;
|
@@ -96,42 +98,11 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
96 |
|
97 |
$store_keys = array( 'bsf-sb-location', 'bsf-sb-exclusion' );
|
98 |
|
99 |
-
foreach ($store_keys as $key ) {
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
if ( isset( $_POST[ $key ]['specific'] ) ) {
|
105 |
-
$_POST[ $key ]['specific'] = array_unique( $_POST[ $key ]['specific'] );
|
106 |
-
}
|
107 |
-
|
108 |
-
// Unset the specifics from rule. This will be readded conditionally in next condition.
|
109 |
-
$index = array_search( '', $_POST[ $key ]['rule'] );
|
110 |
-
if ( false !== $index ) {
|
111 |
-
unset( $_POST[ $key ]['rule'][ $index ] );
|
112 |
-
}
|
113 |
-
$index = array_search( 'specifics', $_POST[ $key ]['rule'] );
|
114 |
-
if ( false !== $index ) {
|
115 |
-
unset( $_POST[ $key ]['rule'][ $index ] );
|
116 |
-
|
117 |
-
// Only re-add the specifics key if there are specific rules added.
|
118 |
-
if ( isset( $_POST[ $key ]['specific'] ) && is_array( $_POST[ $key ]['specific'] ) ) {
|
119 |
-
array_push( $_POST[ $key ]['rule'], 'specifics' );
|
120 |
-
}
|
121 |
-
}
|
122 |
-
|
123 |
-
foreach ( $_POST[ $key ] as $meta_key => $value ) {
|
124 |
-
$meta_value[ $meta_key ] = array_map( 'esc_attr', $value );
|
125 |
-
}
|
126 |
-
if ( ! in_array( 'specifics', $meta_value['rule'] ) ) {
|
127 |
-
$meta_value['specific'] = array();
|
128 |
-
}
|
129 |
-
if ( empty( $meta_value['rule'] ) ) {
|
130 |
-
$meta_value = array();
|
131 |
-
}
|
132 |
-
}
|
133 |
-
|
134 |
-
update_post_meta( $post_id, '_'.$key, $meta_value );
|
135 |
}
|
136 |
|
137 |
if ( isset( $_POST['bsf-sb-users'] ) ) {
|
@@ -139,30 +110,31 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
139 |
}
|
140 |
|
141 |
if ( isset( $_POST['replace_this_sidebar'] ) ) {
|
142 |
-
|
143 |
$replace_sidebar = esc_attr( $_POST['replace_this_sidebar'] );
|
144 |
-
|
145 |
update_post_meta( $post_id, '_replace_this_sidebar', $replace_sidebar );
|
146 |
}
|
147 |
}
|
148 |
-
|
149 |
/**
|
150 |
* Target Rule.
|
151 |
*
|
152 |
* @since 1.0.0
|
|
|
153 |
* @return void
|
154 |
*/
|
155 |
public function sidebar_settings( $post ) {
|
156 |
-
|
157 |
$post_id = $post->ID;
|
158 |
|
159 |
$include_locations = get_post_meta( $post_id, '_bsf-sb-location', true );
|
160 |
$exclude_locations = get_post_meta( $post_id, '_bsf-sb-exclusion', true );
|
161 |
-
$users
|
162 |
$replace_sidebar = get_post_meta( $post_id, '_replace_this_sidebar', true );
|
163 |
-
|
164 |
/* Get Sidebars to show in replace list */
|
165 |
-
$sidebars
|
166 |
|
167 |
$out = wp_nonce_field( BSF_SB_POST_TYPE, BSF_SB_POST_TYPE . '-nonce', true, false );
|
168 |
$out .= '<table class="bsf-sb-table widefat">';
|
@@ -174,20 +146,20 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
174 |
$out .= '</td>';
|
175 |
$out .= '<td class="bsf-sb-row-content">';
|
176 |
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
$out .= '</td>';
|
193 |
$out .= '</tr>';
|
@@ -199,7 +171,7 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
199 |
$out .= '</td>';
|
200 |
$out .= '<td class="bsf-sb-row-content">';
|
201 |
$out .= '<input type="text" rows="1" name="excerpt" value="' . $post->post_excerpt . '">';
|
202 |
-
|
203 |
$out .= '</td>';
|
204 |
$out .= '</tr>';
|
205 |
|
@@ -258,10 +230,10 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
258 |
BSF_SB_Target_Rules_Fields::target_user_role_settings_field(
|
259 |
'bsf-sb-users',
|
260 |
array(
|
261 |
-
'title' => __( 'Users', '
|
262 |
'value' => '[]',
|
263 |
'tags' => 'site,enable,target,pages',
|
264 |
-
'add_rule_label' => __( 'Add User Rule', '
|
265 |
),
|
266 |
$users
|
267 |
);
|
@@ -278,7 +250,7 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
278 |
* Replace sidebar metabox.
|
279 |
*
|
280 |
* @since 1.0.0
|
281 |
-
* @return
|
282 |
*/
|
283 |
public function show_sidebars_to_replace() {
|
284 |
global $wp_registered_sidebars;
|
@@ -286,9 +258,9 @@ if ( ! class_exists( 'BSF_SB_Metabox' ) ) {
|
|
286 |
$sidebars_show = array();
|
287 |
|
288 |
if ( is_array( $wp_registered_sidebars ) ) {
|
289 |
-
|
290 |
-
foreach( $wp_registered_sidebars as $slug => $data ) {
|
291 |
-
$sidebars_show[$slug] = $data['name'];
|
292 |
}
|
293 |
}
|
294 |
|
49 |
* Replace sidebar metabox.
|
50 |
*
|
51 |
* @since 1.0.0
|
52 |
+
* @param string $title post title.
|
53 |
+
* @return string title
|
54 |
*/
|
55 |
public function change_post_name_palceholder( $title ) {
|
56 |
if ( get_post_type() == BSF_SB_POST_TYPE ) {
|
68 |
public function metabox_actions() {
|
69 |
/* Remove the "Excerpt" meta box for the sidebars. */
|
70 |
remove_meta_box( 'postexcerpt', BSF_SB_POST_TYPE, 'normal' );
|
71 |
+
|
72 |
/* Target Rule */
|
73 |
add_meta_box( 'sidebar-settings', __( 'Sidebar Settings', 'bsfsidebars' ), array( $this, 'sidebar_settings' ), BSF_SB_POST_TYPE, 'normal', 'core' );
|
74 |
}
|
77 |
* Replace sidebar metabox.
|
78 |
*
|
79 |
* @since 1.0.0
|
80 |
+
* @param int $post_id current id.
|
81 |
*/
|
82 |
public function metabox_save( $post_id ) {
|
83 |
|
84 |
if ( get_post_type() != BSF_SB_POST_TYPE
|
85 |
+
|| ( isset( $_POST[ BSF_SB_POST_TYPE . '-nonce' ] ) && ! wp_verify_nonce( $_POST[ BSF_SB_POST_TYPE . '-nonce' ], BSF_SB_POST_TYPE ) )
|
86 |
) {
|
87 |
return $post_id;
|
88 |
}
|
89 |
|
90 |
// Verify if this is an auto save routine.
|
91 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
92 |
+
return $post_id;
|
93 |
+
}
|
94 |
|
95 |
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
96 |
return $post_id;
|
98 |
|
99 |
$store_keys = array( 'bsf-sb-location', 'bsf-sb-exclusion' );
|
100 |
|
101 |
+
foreach ( $store_keys as $key ) {
|
102 |
+
|
103 |
+
$meta_value = BSF_SB_Target_Rules_Fields::get_format_rule_value( $_POST, $key );
|
104 |
+
|
105 |
+
update_post_meta( $post_id, '_' . $key, $meta_value );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
|
108 |
if ( isset( $_POST['bsf-sb-users'] ) ) {
|
110 |
}
|
111 |
|
112 |
if ( isset( $_POST['replace_this_sidebar'] ) ) {
|
113 |
+
|
114 |
$replace_sidebar = esc_attr( $_POST['replace_this_sidebar'] );
|
115 |
+
|
116 |
update_post_meta( $post_id, '_replace_this_sidebar', $replace_sidebar );
|
117 |
}
|
118 |
}
|
119 |
+
|
120 |
/**
|
121 |
* Target Rule.
|
122 |
*
|
123 |
* @since 1.0.0
|
124 |
+
* @param object $post post_object.
|
125 |
* @return void
|
126 |
*/
|
127 |
public function sidebar_settings( $post ) {
|
128 |
+
|
129 |
$post_id = $post->ID;
|
130 |
|
131 |
$include_locations = get_post_meta( $post_id, '_bsf-sb-location', true );
|
132 |
$exclude_locations = get_post_meta( $post_id, '_bsf-sb-exclusion', true );
|
133 |
+
$users = get_post_meta( $post_id, '_bsf-sb-users', true );
|
134 |
$replace_sidebar = get_post_meta( $post_id, '_replace_this_sidebar', true );
|
135 |
+
|
136 |
/* Get Sidebars to show in replace list */
|
137 |
+
$sidebars = $this->show_sidebars_to_replace();
|
138 |
|
139 |
$out = wp_nonce_field( BSF_SB_POST_TYPE, BSF_SB_POST_TYPE . '-nonce', true, false );
|
140 |
$out .= '<table class="bsf-sb-table widefat">';
|
146 |
$out .= '</td>';
|
147 |
$out .= '<td class="bsf-sb-row-content">';
|
148 |
|
149 |
+
if ( ! empty( $sidebars ) ) {
|
150 |
+
$out .= '<select name="replace_this_sidebar" class="widefat">';
|
151 |
+
$out .= '<option value=""' . selected( $replace_sidebar, '', false ) . '>' . __( 'None', 'bsfsidebars' ) . '</option>';
|
152 |
+
|
153 |
+
foreach ( $sidebars as $slug => $name ) {
|
154 |
+
if ( strrpos( $slug, BSF_SB_PREFIX ) !== false ) {
|
155 |
+
continue;
|
156 |
+
}
|
157 |
+
$out .= '<option value="' . $slug . '"' . selected( $replace_sidebar, $slug, false ) . '>' . $name . '</option>';
|
158 |
+
}
|
159 |
+
$out .= '</select>';
|
160 |
+
} else {
|
161 |
+
$out .= '<p>' . __( 'Sidebars are not available.', 'bsfsidebars' ) . '</p>';
|
162 |
+
}
|
163 |
|
164 |
$out .= '</td>';
|
165 |
$out .= '</tr>';
|
171 |
$out .= '</td>';
|
172 |
$out .= '<td class="bsf-sb-row-content">';
|
173 |
$out .= '<input type="text" rows="1" name="excerpt" value="' . $post->post_excerpt . '">';
|
174 |
+
// $out .= '<textarea rows="1" name="excerpt">' . $post->post_excerpt . '</textarea>';
|
175 |
$out .= '</td>';
|
176 |
$out .= '</tr>';
|
177 |
|
230 |
BSF_SB_Target_Rules_Fields::target_user_role_settings_field(
|
231 |
'bsf-sb-users',
|
232 |
array(
|
233 |
+
'title' => __( 'Users', 'bsfsidebars' ),
|
234 |
'value' => '[]',
|
235 |
'tags' => 'site,enable,target,pages',
|
236 |
+
'add_rule_label' => __( 'Add User Rule', 'bsfsidebars' ),
|
237 |
),
|
238 |
$users
|
239 |
);
|
250 |
* Replace sidebar metabox.
|
251 |
*
|
252 |
* @since 1.0.0
|
253 |
+
* @return array of sidebars
|
254 |
*/
|
255 |
public function show_sidebars_to_replace() {
|
256 |
global $wp_registered_sidebars;
|
258 |
$sidebars_show = array();
|
259 |
|
260 |
if ( is_array( $wp_registered_sidebars ) ) {
|
261 |
+
|
262 |
+
foreach ( $wp_registered_sidebars as $slug => $data ) {
|
263 |
+
$sidebars_show[ $slug ] = $data['name'];
|
264 |
}
|
265 |
}
|
266 |
|
classes/class-bsf-sb-post-type.php
CHANGED
@@ -54,48 +54,57 @@ if ( ! class_exists( 'BSF_SB_Post_Type' ) ) {
|
|
54 |
* @access public
|
55 |
* @return void
|
56 |
*/
|
57 |
-
public function register_post_type
|
58 |
/* Allow users who can edit theme. */
|
59 |
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
-
$singular
|
64 |
-
$plural
|
65 |
-
$rewrite
|
66 |
-
|
67 |
-
|
|
|
|
|
68 |
$labels = array(
|
69 |
-
'name'
|
70 |
-
'singular_name'
|
71 |
-
'menu_name'
|
72 |
-
'add_new'
|
73 |
-
|
74 |
-
'
|
75 |
-
|
76 |
-
'
|
77 |
-
|
78 |
-
'
|
79 |
-
'
|
80 |
-
|
81 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
);
|
84 |
$args = array(
|
85 |
-
'labels'
|
86 |
-
'public'
|
87 |
-
'publicly_queryable'
|
88 |
-
'show_ui'
|
89 |
-
'show_in_nav_menus'
|
90 |
-
'show_in_admin_bar'
|
91 |
-
'show_in_menu'
|
92 |
-
'query_var'
|
93 |
-
'rewrite'
|
94 |
-
'capability_type'
|
95 |
-
'has_archive'
|
96 |
-
'hierarchical'
|
97 |
-
'menu_position'
|
98 |
-
'supports'
|
99 |
);
|
100 |
register_post_type( BSF_SB_POST_TYPE, $args );
|
101 |
}
|
54 |
* @access public
|
55 |
* @return void
|
56 |
*/
|
57 |
+
public function register_post_type() {
|
58 |
/* Allow users who can edit theme. */
|
59 |
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
60 |
return;
|
61 |
}
|
62 |
|
63 |
+
$singular = __( 'Sidebar', 'bsfsidebars' );
|
64 |
+
$plural = __( 'Sidebars', 'bsfsidebars' );
|
65 |
+
$rewrite = array(
|
66 |
+
'slug' => BSF_SB_POST_TYPE,
|
67 |
+
);
|
68 |
+
$supports = array( 'title', 'excerpt' );
|
69 |
+
|
70 |
$labels = array(
|
71 |
+
'name' => _x( 'Sidebars', 'post type general name', 'bsfsidebars' ),
|
72 |
+
'singular_name' => _x( 'Sidebar', 'post type singular name', 'bsfsidebars' ),
|
73 |
+
'menu_name' => _x( 'Sidebars', 'admin menu', 'bsfsidebars' ),
|
74 |
+
'add_new' => __( 'Add New', 'bsfsidebars' ),
|
75 |
+
/* translators: %s singular */
|
76 |
+
'add_new_item' => sprintf( __( 'Add New %s', 'bsfsidebars' ), $singular ),
|
77 |
+
/* translators: %s singular */
|
78 |
+
'edit_item' => sprintf( __( 'Edit %s', 'bsfsidebars' ), $singular ),
|
79 |
+
/* translators: %s singular */
|
80 |
+
'new_item' => sprintf( __( 'New %s', 'bsfsidebars' ), $singular ),
|
81 |
+
'all_items' => $plural,
|
82 |
+
/* translators: %s singular */
|
83 |
+
'view_item' => sprintf( __( 'View %s', 'bsfsidebars' ), $singular ),
|
84 |
+
/* translators: %s plural */
|
85 |
+
'search_items' => sprintf( __( 'Search %s', 'bsfsidebars' ), $plural ),
|
86 |
+
/* translators: %s plural */
|
87 |
+
'not_found' => sprintf( __( 'No %s Found', 'bsfsidebars' ), $plural ),
|
88 |
+
/* translators: %s plural */
|
89 |
+
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'bsfsidebars' ), $plural ),
|
90 |
+
'parent_item_colon' => '',
|
91 |
|
92 |
);
|
93 |
$args = array(
|
94 |
+
'labels' => $labels,
|
95 |
+
'public' => false,
|
96 |
+
'publicly_queryable' => true,
|
97 |
+
'show_ui' => true,
|
98 |
+
'show_in_nav_menus' => false,
|
99 |
+
'show_in_admin_bar' => false,
|
100 |
+
'show_in_menu' => 'themes.php',
|
101 |
+
'query_var' => true,
|
102 |
+
'rewrite' => $rewrite,
|
103 |
+
'capability_type' => 'post',
|
104 |
+
'has_archive' => BSF_SB_POST_TYPE,
|
105 |
+
'hierarchical' => false,
|
106 |
+
'menu_position' => null,
|
107 |
+
'supports' => $supports,
|
108 |
);
|
109 |
register_post_type( BSF_SB_POST_TYPE, $args );
|
110 |
}
|
classes/class-bsf-sb-sidebar.php
CHANGED
@@ -66,17 +66,25 @@ if ( ! class_exists( 'BSF_SB_Sidebar' ) ) {
|
|
66 |
* @return void
|
67 |
*/
|
68 |
public function register_sidebars() {
|
69 |
-
|
70 |
-
$to_register = get_posts( array( 'post_type' => BSF_SB_POST_TYPE, 'posts_per_page' => -1, 'suppress_filters' => 'false' ) );
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
foreach ( $to_register as $index => $data ) {
|
74 |
-
|
75 |
-
register_sidebar(
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
}
|
81 |
}
|
82 |
}
|
@@ -96,55 +104,50 @@ if ( ! class_exists( 'BSF_SB_Sidebar' ) ) {
|
|
96 |
* Replace Sidebars.
|
97 |
*
|
98 |
* @access public
|
99 |
-
* @
|
|
|
100 |
*/
|
101 |
public function replace_sidebars( $sidebars ) {
|
102 |
-
if ( !is_admin() ) {
|
103 |
-
|
104 |
-
if (
|
105 |
global $post;
|
106 |
|
107 |
-
$
|
108 |
-
'
|
109 |
-
'
|
110 |
-
'
|
111 |
-
'meta_query' => array(
|
112 |
-
array(
|
113 |
-
'key' => '_replace_this_sidebar',
|
114 |
-
'compare' => '!=',
|
115 |
-
'value' => ''
|
116 |
-
)
|
117 |
-
)
|
118 |
);
|
119 |
|
120 |
-
$replace_sidebars =
|
|
|
|
|
121 |
|
122 |
-
if ( !empty( $replace_sidebars ) ) {
|
123 |
-
|
124 |
foreach ( $replace_sidebars as $i => $data ) {
|
125 |
|
126 |
-
$post_replace_sidebar = get_post_meta( $data
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
129 |
if ( isset( $sidebars[ $post_replace_sidebar ] ) && isset( $sidebars[ $sidebar_id ] ) ) {
|
130 |
-
|
131 |
-
$is_show = BSF_SB_Target_Rules_Fields::get_instance()->get_current_layout( $data->ID );
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
unset( $sidebars[ $sidebar_id ] );
|
136 |
-
}
|
137 |
}
|
138 |
}
|
139 |
|
140 |
self::$global_sidebar = $sidebars;
|
141 |
}
|
142 |
-
}else{
|
143 |
-
|
144 |
$sidebars = self::$global_sidebar;
|
145 |
}
|
146 |
}
|
147 |
-
|
148 |
return $sidebars;
|
149 |
}
|
150 |
}
|
66 |
* @return void
|
67 |
*/
|
68 |
public function register_sidebars() {
|
|
|
|
|
69 |
|
70 |
+
$to_register = get_posts(
|
71 |
+
array(
|
72 |
+
'post_type' => BSF_SB_POST_TYPE,
|
73 |
+
'posts_per_page' => -1,
|
74 |
+
'suppress_filters' => 'false',
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
if ( ! empty( $to_register ) ) {
|
79 |
foreach ( $to_register as $index => $data ) {
|
80 |
+
|
81 |
+
register_sidebar(
|
82 |
+
array(
|
83 |
+
'name' => $data->post_title,
|
84 |
+
'id' => BSF_SB_PREFIX . '-' . $data->post_name,
|
85 |
+
'description' => $data->post_excerpt,
|
86 |
+
)
|
87 |
+
);
|
88 |
}
|
89 |
}
|
90 |
}
|
104 |
* Replace Sidebars.
|
105 |
*
|
106 |
* @access public
|
107 |
+
* @param array $sidebars array of current sidebars.
|
108 |
+
* @return array
|
109 |
*/
|
110 |
public function replace_sidebars( $sidebars ) {
|
111 |
+
if ( ! is_admin() ) {
|
112 |
+
|
113 |
+
if ( null === self::$global_sidebar ) {
|
114 |
global $post;
|
115 |
|
116 |
+
$option = array(
|
117 |
+
'location' => '_bsf-sb-location',
|
118 |
+
'exclusion' => '_bsf-sb-exclusion',
|
119 |
+
'users' => '_bsf-sb-users',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
);
|
121 |
|
122 |
+
$replace_sidebars = BSF_SB_Target_Rules_Fields::get_instance()->get_posts_by_conditions( BSF_SB_POST_TYPE, $option );
|
123 |
+
|
124 |
+
if ( ! empty( $replace_sidebars ) ) {
|
125 |
|
|
|
|
|
126 |
foreach ( $replace_sidebars as $i => $data ) {
|
127 |
|
128 |
+
$post_replace_sidebar = get_post_meta( $data['id'], '_replace_this_sidebar', true );
|
129 |
+
|
130 |
+
if ( false === $post_replace_sidebar || '' == $post_replace_sidebar ) {
|
131 |
+
continue;
|
132 |
+
}
|
133 |
+
|
134 |
+
$sidebar_id = BSF_SB_PREFIX . '-' . $data['post_name'];
|
135 |
+
|
136 |
if ( isset( $sidebars[ $post_replace_sidebar ] ) && isset( $sidebars[ $sidebar_id ] ) ) {
|
|
|
|
|
137 |
|
138 |
+
$sidebars[ $post_replace_sidebar ] = $sidebars[ $sidebar_id ];
|
139 |
+
unset( $sidebars[ $sidebar_id ] );
|
|
|
|
|
140 |
}
|
141 |
}
|
142 |
|
143 |
self::$global_sidebar = $sidebars;
|
144 |
}
|
145 |
+
} else {
|
146 |
+
|
147 |
$sidebars = self::$global_sidebar;
|
148 |
}
|
149 |
}
|
150 |
+
|
151 |
return $sidebars;
|
152 |
}
|
153 |
}
|
classes/class-bsf-sb-white-label.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Astra Hooks White Label
|
4 |
+
*
|
5 |
+
* @package Astra Hooks
|
6 |
+
* @since 1.0.1
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! class_exists( 'Bsf_Sb_White_Label' ) ) :
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Bsf_Sb_White_Label
|
13 |
+
*
|
14 |
+
* @since 1.0.1
|
15 |
+
*/
|
16 |
+
class Bsf_Sb_White_Label {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Instance
|
20 |
+
*
|
21 |
+
* @since 1.0.1
|
22 |
+
* @var object Class Object.
|
23 |
+
* @access private
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Member Variable
|
29 |
+
*
|
30 |
+
* @since 1.0.1
|
31 |
+
* @var array branding
|
32 |
+
* @access private
|
33 |
+
*/
|
34 |
+
private static $branding;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Initiator
|
38 |
+
*
|
39 |
+
* @since 1.0.1
|
40 |
+
* @return object initialized object of class.
|
41 |
+
*/
|
42 |
+
public static function set_instance() {
|
43 |
+
if ( ! isset( self::$instance ) ) {
|
44 |
+
self::$instance = new self;
|
45 |
+
}
|
46 |
+
return self::$instance;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Constructor
|
51 |
+
*
|
52 |
+
* @since 1.0.1
|
53 |
+
*/
|
54 |
+
public function __construct() {
|
55 |
+
|
56 |
+
add_filter( 'all_plugins' , array( $this, 'plugins_page' ) );
|
57 |
+
add_filter( 'astra_addon_branding_options' , __CLASS__ . '::settings' );
|
58 |
+
add_action( 'astra_pro_white_label_add_form' , __CLASS__ . '::add_white_lavel_form' );
|
59 |
+
|
60 |
+
if ( is_admin() ) {
|
61 |
+
// Display the link with the plugin meta.
|
62 |
+
add_filter( 'plugin_row_meta', array( $this, 'plugin_links' ), 10, 4 );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* White labels the plugins page.
|
68 |
+
*
|
69 |
+
* @param array $plugins Plugins Array.
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
function plugins_page( $plugins ) {
|
73 |
+
|
74 |
+
if ( ! is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
|
75 |
+
return $plugins;
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( ! isset( $plugins[ BSF_SB_BASE ] ) ) {
|
79 |
+
return $plugins;
|
80 |
+
}
|
81 |
+
|
82 |
+
// Set White Labels.
|
83 |
+
$name = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-lw-sb', 'name' );
|
84 |
+
$description = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-lw-sb', 'description' );
|
85 |
+
$author = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author' );
|
86 |
+
$author_uri = Astra_Ext_White_Label_Markup::get_white_label( 'astra-agency', 'author_url' );
|
87 |
+
|
88 |
+
if ( ! empty( $name ) ) {
|
89 |
+
$plugins[ BSF_SB_BASE ]['Name'] = $name;
|
90 |
+
|
91 |
+
// Remove Plugin URI if Agency White Label name is set.
|
92 |
+
$plugins[ BSF_SB_BASE ]['PluginURI'] = '';
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( ! empty( $description ) ) {
|
96 |
+
$plugins[ BSF_SB_BASE ]['Description'] = $description;
|
97 |
+
}
|
98 |
+
|
99 |
+
if ( ! empty( $author ) ) {
|
100 |
+
$plugins[ BSF_SB_BASE ]['Author'] = $author;
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( ! empty( $author_uri ) ) {
|
104 |
+
$plugins[ BSF_SB_BASE ]['AuthorURI'] = $author_uri;
|
105 |
+
}
|
106 |
+
|
107 |
+
return $plugins;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Remove a "view details" link from the plugin list table
|
112 |
+
*
|
113 |
+
* @since 1.0.1
|
114 |
+
*
|
115 |
+
* @param array $plugin_meta List of links.
|
116 |
+
* @param string $plugin_file Relative path to the main plugin file from the plugins directory.
|
117 |
+
* @param array $plugin_data Data from the plugin headers.
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
+
public function plugin_links( $plugin_meta, $plugin_file, $plugin_data ) {
|
121 |
+
|
122 |
+
if ( is_callable( 'Astra_Ext_White_Label_Markup::get_white_label' ) ) {
|
123 |
+
if ( BSF_SB_BASE == $plugin_file ) {
|
124 |
+
// Set White Labels.
|
125 |
+
$name = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-lw-sb', 'name' );
|
126 |
+
$description = Astra_Ext_White_Label_Markup::get_white_label( 'bsf-lw-sb', 'description' );
|
127 |
+
|
128 |
+
if ( ! empty( $name ) ) {
|
129 |
+
// Remove Plugin URI if Agency White Label name is set.
|
130 |
+
unset( $plugin_meta[2] );
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
return $plugin_meta;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Add White Label setting's
|
139 |
+
*
|
140 |
+
* @since 1.0.1
|
141 |
+
*
|
142 |
+
* @param array $settings White label setting.
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public static function settings( $settings = array() ) {
|
146 |
+
|
147 |
+
$settings['bsf-lw-sb'] = array(
|
148 |
+
'name' => '',
|
149 |
+
'description' => '',
|
150 |
+
);
|
151 |
+
|
152 |
+
return $settings;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Add White Label form
|
157 |
+
*
|
158 |
+
* @since 1.0.1
|
159 |
+
*
|
160 |
+
* @param array $settings White label setting.
|
161 |
+
* @return void
|
162 |
+
*/
|
163 |
+
public static function add_white_lavel_form( $settings = array() ) {
|
164 |
+
require_once BSF_SB_DIR . 'includes/white-label.php';
|
165 |
+
}
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Kicking this off by calling 'set_instance()' method
|
171 |
+
*/
|
172 |
+
Bsf_Sb_White_Label::set_instance();
|
173 |
+
|
174 |
+
endif;
|
classes/modules/target-rule/{class-bsf-sb-rules-fields.php → class-bsf-sb-target-rules-fields.php}
RENAMED
@@ -34,6 +34,42 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
34 |
*/
|
35 |
private static $meta_option;
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
* Initiator
|
39 |
*
|
@@ -53,10 +89,178 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
53 |
* @since 1.0.0
|
54 |
*/
|
55 |
public function __construct() {
|
|
|
56 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
57 |
add_action( 'wp_ajax_bsf_sb_get_posts_by_query', array( $this, 'get_posts_by_query' ) );
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
/**
|
61 |
* Ajax handeler to return the posts based on the search query.
|
62 |
* When searching for the post/pages only titles are searched for.
|
@@ -204,9 +408,9 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
204 |
* @param string $hook string parameter.
|
205 |
*/
|
206 |
public function admin_styles( $hook ) {
|
207 |
-
|
208 |
if ( false !== strrpos( $hook, 'post' ) && 'bsf-sidebar' == get_post_type() ) {
|
209 |
-
|
210 |
wp_enqueue_script( 'bsf-sb-select2', BSF_SB_URL . 'classes/modules/target-rule/select2.js', array( 'jquery' ), BSF_SB_VER, true );
|
211 |
wp_enqueue_script(
|
212 |
'bsf-sb-target-rule', BSF_SB_URL . 'classes/modules/target-rule/target-rule.js', array(
|
@@ -223,7 +427,7 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
223 |
wp_enqueue_style( 'bsf-sb-select2', BSF_SB_URL . 'classes/modules/target-rule/select2.css', '', BSF_SB_VER );
|
224 |
wp_enqueue_style( 'bsf-sb-target-rule', BSF_SB_URL . 'classes/modules/target-rule/target-rule.css', '', BSF_SB_VER );
|
225 |
}
|
226 |
-
|
227 |
}
|
228 |
|
229 |
/**
|
@@ -243,74 +447,11 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
243 |
$saved_values = $value;
|
244 |
$output = '';
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
'_builtin' => true,
|
249 |
-
);
|
250 |
-
|
251 |
-
$builtin_post_types = get_post_types( $args, 'objects' );
|
252 |
-
unset( $builtin_post_types['attachment'] );
|
253 |
-
$builtin_taxonomies = get_taxonomies( $args, 'objects' );
|
254 |
-
unset( $builtin_taxonomies['post_format'] );
|
255 |
-
|
256 |
-
$args = array(
|
257 |
-
'public' => true,
|
258 |
-
'_builtin' => false,
|
259 |
-
);
|
260 |
-
|
261 |
-
$custom_post_type = get_post_types( $args, 'objects' );
|
262 |
-
$custom_taxonomies = get_taxonomies( $args, 'objects' );
|
263 |
-
|
264 |
-
$selection_options = array(
|
265 |
-
'basic' => array(
|
266 |
-
'label' => __( 'Basic', 'bsfsidebars' ),
|
267 |
-
'value' => array(
|
268 |
-
'basic-global' => __( 'Entire Website', 'bsfsidebars' ),
|
269 |
-
'basic-singulars' => __( 'All Singulars', 'bsfsidebars' ),
|
270 |
-
'basic-archives' => __( 'All Archives', 'bsfsidebars' ),
|
271 |
-
),
|
272 |
-
),
|
273 |
-
|
274 |
-
'special-pages' => array(
|
275 |
-
'label' => __( 'Special Pages', 'bsfsidebars' ),
|
276 |
-
'value' => array(
|
277 |
-
'special-404' => __( '404 Page', 'bsfsidebars' ),
|
278 |
-
'special-search' => __( 'Search Page', 'bsfsidebars' ),
|
279 |
-
'special-blog' => __( 'Blog / Posts Page', 'bsfsidebars' ),
|
280 |
-
'special-front' => __( 'Front Page', 'bsfsidebars' ),
|
281 |
-
'special-date' => __( 'Date Archive', 'bsfsidebars' ),
|
282 |
-
'special-author' => __( 'Author Archive', 'bsfsidebars' ),
|
283 |
-
),
|
284 |
-
),
|
285 |
-
);
|
286 |
-
|
287 |
-
/* Builtin post types */
|
288 |
-
foreach ( $builtin_post_types as $post_type ) {
|
289 |
-
|
290 |
-
$post_opt = self::get_post_target_rule_options( $post_type, $builtin_taxonomies );
|
291 |
-
|
292 |
-
$selection_options[ $post_opt['post_key'] ] = array(
|
293 |
-
'label' => $post_opt['label'],
|
294 |
-
'value' => $post_opt['value'],
|
295 |
-
);
|
296 |
-
}
|
297 |
-
|
298 |
-
/* Custom post types */
|
299 |
-
foreach ( $custom_post_type as $c_post_type ) {
|
300 |
-
$post_opt = self::get_post_target_rule_options( $c_post_type, $custom_taxonomies );
|
301 |
-
|
302 |
-
$selection_options[ $post_opt['post_key'] ] = array(
|
303 |
-
'label' => $post_opt['label'],
|
304 |
-
'value' => $post_opt['value'],
|
305 |
-
);
|
306 |
}
|
307 |
|
308 |
-
$selection_options
|
309 |
-
'label' => __( 'Specific Target', 'bsfsidebars' ),
|
310 |
-
'value' => array(
|
311 |
-
'specifics' => __( 'Specific Pages / Posts / Taxanomies, etc.', 'bsfsidebars' ),
|
312 |
-
),
|
313 |
-
);
|
314 |
|
315 |
/* WP Template Format */
|
316 |
$output .= '<script type="text/html" id="tmpl-bsf-sb-target-rule-' . $rule_type . '-condition">';
|
@@ -372,11 +513,15 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
372 |
|
373 |
/* translators: %s percentage */
|
374 |
$all_posts = sprintf( __( 'All %s', 'bsfsidebars' ), $post_label );
|
375 |
-
/* translators: %s percentage */
|
376 |
-
$all_archive = sprintf( __( 'All %s Archive', 'bsfsidebars' ), $post_label );
|
377 |
-
|
378 |
$post_option[ $post_name . '|all' ] = $all_posts;
|
379 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
|
381 |
foreach ( $taxonomies as $taxonomy ) {
|
382 |
$tax_label = ucwords( $taxonomy->label );
|
@@ -449,41 +594,32 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
449 |
|
450 |
$output .= '</div>';
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
if ( isset( $saved_values['specific'] ) && null != $saved_values['specific'] && is_array( $saved_values['specific'] ) ) {
|
466 |
-
|
467 |
-
foreach ( $saved_values['specific'] as $data_key => $sel_value ) {
|
468 |
-
// posts.
|
469 |
-
if ( strpos( $sel_value, 'post-' ) !== false ) {
|
470 |
-
$post_id = (int) str_replace( 'post-', '', $sel_value );
|
471 |
-
$post_title = get_the_title( $post_id );
|
472 |
-
$output .= '<option value="post-' . $post_id . '" selected="selected" >' . $post_title . '</option>';
|
473 |
-
}
|
474 |
|
475 |
// taxonomy options.
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
|
|
|
482 |
}
|
483 |
}
|
|
|
|
|
484 |
}
|
485 |
-
$output .= '</select>';
|
486 |
-
$output .= '</div>';
|
487 |
|
488 |
$output .= '</div>';
|
489 |
|
@@ -704,29 +840,12 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
704 |
$saved_values = $value;
|
705 |
$output = '';
|
706 |
|
707 |
-
|
708 |
-
|
709 |
-
'label' => __( 'Basic', 'bsfsidebars' ),
|
710 |
-
'value' => array(
|
711 |
-
'all' => __( 'All', 'bsfsidebars' ),
|
712 |
-
'logged-in' => __( 'Logged In', 'bsfsidebars' ),
|
713 |
-
'logged-out' => __( 'Logged Out', 'bsfsidebars' ),
|
714 |
-
),
|
715 |
-
),
|
716 |
-
|
717 |
-
'advanced' => array(
|
718 |
-
'label' => __( 'Advanced', 'bsfsidebars' ),
|
719 |
-
'value' => array(),
|
720 |
-
),
|
721 |
-
);
|
722 |
-
|
723 |
-
/* User roles */
|
724 |
-
$roles = get_editable_roles();
|
725 |
-
|
726 |
-
foreach ( $roles as $slug => $data ) {
|
727 |
-
$selection_options['advanced']['value'][ $slug ] = $data['name'];
|
728 |
}
|
729 |
|
|
|
|
|
730 |
/* WP Template Format */
|
731 |
$output .= '<script type="text/html" id="tmpl-bsf-sb-user-role-condition">';
|
732 |
$output .= '<div class="bsf-sb-user-role-condition bsf-sb-user-role-{{data.id}}" data-rule="{{data.id}}" >';
|
@@ -803,9 +922,10 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
803 |
*/
|
804 |
public function parse_user_role_condition( $post_id, $rules ) {
|
805 |
|
806 |
-
$show_popup =
|
807 |
|
808 |
if ( is_array( $rules ) && ! empty( $rules ) ) {
|
|
|
809 |
|
810 |
foreach ( $rules as $i => $rule ) {
|
811 |
|
@@ -851,6 +971,370 @@ if ( ! class_exists( 'BSF_SB_Target_Rules_Fields' ) ) {
|
|
851 |
|
852 |
return $show_popup;
|
853 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
}
|
855 |
}// End if().
|
856 |
|
34 |
*/
|
35 |
private static $meta_option;
|
36 |
|
37 |
+
/**
|
38 |
+
* Current page type
|
39 |
+
*
|
40 |
+
* @since 1.0.0
|
41 |
+
*
|
42 |
+
* @var $current_page_type
|
43 |
+
*/
|
44 |
+
private static $current_page_type = null;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* CUrrent page data
|
48 |
+
*
|
49 |
+
* @since 1.0.0
|
50 |
+
*
|
51 |
+
* @var $current_page_data
|
52 |
+
*/
|
53 |
+
private static $current_page_data = array();
|
54 |
+
|
55 |
+
/**
|
56 |
+
* User Selection Option
|
57 |
+
*
|
58 |
+
* @since 1.0.0
|
59 |
+
*
|
60 |
+
* @var $user_selection
|
61 |
+
*/
|
62 |
+
private static $user_selection;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Location Selection Option
|
66 |
+
*
|
67 |
+
* @since 1.0.0
|
68 |
+
*
|
69 |
+
* @var $location_selection
|
70 |
+
*/
|
71 |
+
private static $location_selection;
|
72 |
+
|
73 |
/**
|
74 |
* Initiator
|
75 |
*
|
89 |
* @since 1.0.0
|
90 |
*/
|
91 |
public function __construct() {
|
92 |
+
add_action( 'admin_action_edit', array( $this, 'initialize_options' ) );
|
93 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
94 |
add_action( 'wp_ajax_bsf_sb_get_posts_by_query', array( $this, 'get_posts_by_query' ) );
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
+
* Initialize member variables.
|
99 |
+
*
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
public function initialize_options() {
|
103 |
+
self::$user_selection = self::get_user_selections();
|
104 |
+
self::$location_selection = self::get_location_selections();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get location selection options.
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public static function get_location_selections() {
|
113 |
+
|
114 |
+
$args = array(
|
115 |
+
'public' => true,
|
116 |
+
'_builtin' => true,
|
117 |
+
);
|
118 |
+
|
119 |
+
$post_types = get_post_types( $args, 'objects' );
|
120 |
+
unset( $post_types['attachment'] );
|
121 |
+
|
122 |
+
$args['_builtin'] = false;
|
123 |
+
$custom_post_type = get_post_types( $args, 'objects' );
|
124 |
+
|
125 |
+
$post_types = apply_filters( 'astra_location_rule_post_types', array_merge( $post_types, $custom_post_type ) );
|
126 |
+
|
127 |
+
$selection_options = array(
|
128 |
+
'basic' => array(
|
129 |
+
'label' => __( 'Basic', 'bsfsidebars' ),
|
130 |
+
'value' => array(
|
131 |
+
'basic-global' => __( 'Entire Website', 'bsfsidebars' ),
|
132 |
+
'basic-singulars' => __( 'All Singulars', 'bsfsidebars' ),
|
133 |
+
'basic-archives' => __( 'All Archives', 'bsfsidebars' ),
|
134 |
+
),
|
135 |
+
),
|
136 |
+
|
137 |
+
'special-pages' => array(
|
138 |
+
'label' => __( 'Special Pages', 'bsfsidebars' ),
|
139 |
+
'value' => array(
|
140 |
+
'special-404' => __( '404 Page', 'bsfsidebars' ),
|
141 |
+
'special-search' => __( 'Search Page', 'bsfsidebars' ),
|
142 |
+
'special-blog' => __( 'Blog / Posts Page', 'bsfsidebars' ),
|
143 |
+
'special-front' => __( 'Front Page', 'bsfsidebars' ),
|
144 |
+
'special-date' => __( 'Date Archive', 'bsfsidebars' ),
|
145 |
+
'special-author' => __( 'Author Archive', 'bsfsidebars' ),
|
146 |
+
),
|
147 |
+
),
|
148 |
+
);
|
149 |
+
|
150 |
+
/* post types */
|
151 |
+
foreach ( $post_types as $post_type ) {
|
152 |
+
|
153 |
+
$args = array(
|
154 |
+
'public' => true,
|
155 |
+
'object_type' => array( $post_type->name ),
|
156 |
+
);
|
157 |
+
$taxonomies = get_taxonomies( $args, 'objects' );
|
158 |
+
unset( $taxonomies['post_format'] );
|
159 |
+
|
160 |
+
$post_opt = self::get_post_target_rule_options( $post_type, $taxonomies );
|
161 |
+
|
162 |
+
$selection_options[ $post_opt['post_key'] ] = array(
|
163 |
+
'label' => $post_opt['label'],
|
164 |
+
'value' => $post_opt['value'],
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
$selection_options['specific-target'] = array(
|
169 |
+
'label' => __( 'Specific Target', 'bsfsidebars' ),
|
170 |
+
'value' => array(
|
171 |
+
'specifics' => __( 'Specific Pages / Posts / Taxanomies, etc.', 'bsfsidebars' ),
|
172 |
+
),
|
173 |
+
);
|
174 |
+
|
175 |
+
return $selection_options;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Get user selection options.
|
180 |
+
*
|
181 |
+
* @return array
|
182 |
+
*/
|
183 |
+
public static function get_user_selections() {
|
184 |
+
$selection_options = array(
|
185 |
+
'basic' => array(
|
186 |
+
'label' => __( 'Basic', 'bsfsidebars' ),
|
187 |
+
'value' => array(
|
188 |
+
'all' => __( 'All', 'bsfsidebars' ),
|
189 |
+
'logged-in' => __( 'Logged In', 'bsfsidebars' ),
|
190 |
+
'logged-out' => __( 'Logged Out', 'bsfsidebars' ),
|
191 |
+
),
|
192 |
+
),
|
193 |
+
|
194 |
+
'advanced' => array(
|
195 |
+
'label' => __( 'Advanced', 'bsfsidebars' ),
|
196 |
+
'value' => array(),
|
197 |
+
),
|
198 |
+
);
|
199 |
+
|
200 |
+
/* User roles */
|
201 |
+
$roles = get_editable_roles();
|
202 |
+
|
203 |
+
foreach ( $roles as $slug => $data ) {
|
204 |
+
$selection_options['advanced']['value'][ $slug ] = $data['name'];
|
205 |
+
}
|
206 |
+
|
207 |
+
return $selection_options;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Get location label by key.
|
212 |
+
*
|
213 |
+
* @param string $key Location option key.
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
public static function get_location_by_key( $key ) {
|
217 |
+
if ( ! isset( self::$location_selection ) || empty( self::$location_selection ) ) {
|
218 |
+
self::$location_selection = self::get_location_selections();
|
219 |
+
}
|
220 |
+
$location_selection = self::$location_selection;
|
221 |
+
|
222 |
+
foreach ( $location_selection as $location_grp ) {
|
223 |
+
if ( isset( $location_grp['value'][ $key ] ) ) {
|
224 |
+
return $location_grp['value'][ $key ];
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
if ( strpos( $key, 'post-' ) !== false ) {
|
229 |
+
$post_id = (int) str_replace( 'post-', '', $key );
|
230 |
+
return get_the_title( $post_id );
|
231 |
+
}
|
232 |
+
|
233 |
+
// taxonomy options.
|
234 |
+
if ( strpos( $key, 'tax-' ) !== false ) {
|
235 |
+
$tax_id = (int) str_replace( 'tax-', '', $key );
|
236 |
+
$term = get_term( $tax_id );
|
237 |
+
$term_taxonomy = ucfirst( str_replace( '_', ' ', $term->taxonomy ) );
|
238 |
+
return $term->name . ' - ' . $term_taxonomy;
|
239 |
+
}
|
240 |
+
|
241 |
+
return $key;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Get user label by key.
|
246 |
+
*
|
247 |
+
* @param string $key User option key.
|
248 |
+
* @return string
|
249 |
+
*/
|
250 |
+
public static function get_user_by_key( $key ) {
|
251 |
+
if ( ! isset( self::$user_selection ) || empty( self::$user_selection ) ) {
|
252 |
+
self::$user_selection = self::get_user_selections();
|
253 |
+
}
|
254 |
+
$user_selection = self::$user_selection;
|
255 |
+
|
256 |
+
if ( isset( $user_selection['basic']['value'][ $key ] ) ) {
|
257 |
+
return $user_selection['basic']['value'][ $key ];
|
258 |
+
} elseif ( $user_selection['advanced']['value'][ $key ] ) {
|
259 |
+
return $user_selection['advanced']['value'][ $key ];
|
260 |
+
}
|
261 |
+
return $key;
|
262 |
+
}
|
263 |
+
|
264 |
/**
|
265 |
* Ajax handeler to return the posts based on the search query.
|
266 |
* When searching for the post/pages only titles are searched for.
|
408 |
* @param string $hook string parameter.
|
409 |
*/
|
410 |
public function admin_styles( $hook ) {
|
411 |
+
|
412 |
if ( false !== strrpos( $hook, 'post' ) && 'bsf-sidebar' == get_post_type() ) {
|
413 |
+
|
414 |
wp_enqueue_script( 'bsf-sb-select2', BSF_SB_URL . 'classes/modules/target-rule/select2.js', array( 'jquery' ), BSF_SB_VER, true );
|
415 |
wp_enqueue_script(
|
416 |
'bsf-sb-target-rule', BSF_SB_URL . 'classes/modules/target-rule/target-rule.js', array(
|
427 |
wp_enqueue_style( 'bsf-sb-select2', BSF_SB_URL . 'classes/modules/target-rule/select2.css', '', BSF_SB_VER );
|
428 |
wp_enqueue_style( 'bsf-sb-target-rule', BSF_SB_URL . 'classes/modules/target-rule/target-rule.css', '', BSF_SB_VER );
|
429 |
}
|
430 |
+
|
431 |
}
|
432 |
|
433 |
/**
|
447 |
$saved_values = $value;
|
448 |
$output = '';
|
449 |
|
450 |
+
if ( isset( self::$location_selection ) || empty( self::$location_selection ) ) {
|
451 |
+
self::$location_selection = self::get_location_selections();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
}
|
453 |
|
454 |
+
$selection_options = self::$location_selection;
|
|
|
|
|
|
|
|
|
|
|
455 |
|
456 |
/* WP Template Format */
|
457 |
$output .= '<script type="text/html" id="tmpl-bsf-sb-target-rule-' . $rule_type . '-condition">';
|
513 |
|
514 |
/* translators: %s percentage */
|
515 |
$all_posts = sprintf( __( 'All %s', 'bsfsidebars' ), $post_label );
|
|
|
|
|
|
|
516 |
$post_option[ $post_name . '|all' ] = $all_posts;
|
517 |
+
|
518 |
+
if ( 'pages' != $post_key ) {
|
519 |
+
/* translators: %s percentage */
|
520 |
+
$all_archive = sprintf( __( 'All %s Archive', 'bsfsidebars' ), $post_label );
|
521 |
+
/* translators: %s post label */
|
522 |
+
$post_option[ $post_name . '|all|archive' ] = $all_archive;
|
523 |
+
|
524 |
+
}
|
525 |
|
526 |
foreach ( $taxonomies as $taxonomy ) {
|
527 |
$tax_label = ucwords( $taxonomy->label );
|
594 |
|
595 |
$output .= '</div>';
|
596 |
|
597 |
+
/* Specific page selection */
|
598 |
+
$output .= '<div class="target_rule-specific-page-wrap" style="display:none">';
|
599 |
+
$output .= '<select name="' . esc_attr( $input_name ) . '[specific][]" class="target-rule-select2 target_rule-specific-page form-control ast-input " multiple="multiple">';
|
600 |
+
if ( 'specifics' == $data && isset( $saved_values['specific'] ) && null != $saved_values['specific'] && is_array( $saved_values['specific'] ) ) {
|
601 |
+
|
602 |
+
foreach ( $saved_values['specific'] as $data_key => $sel_value ) {
|
603 |
+
// posts.
|
604 |
+
if ( strpos( $sel_value, 'post-' ) !== false ) {
|
605 |
+
$post_id = (int) str_replace( 'post-', '', $sel_value );
|
606 |
+
$post_title = get_the_title( $post_id );
|
607 |
+
$output .= '<option value="post-' . $post_id . '" selected="selected" >' . $post_title . '</option>';
|
608 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
609 |
|
610 |
// taxonomy options.
|
611 |
+
if ( strpos( $sel_value, 'tax-' ) !== false ) {
|
612 |
+
$tax_id = (int) str_replace( 'tax-', '', $sel_value );
|
613 |
+
$term = get_term( $tax_id );
|
614 |
+
$term_taxonomy = ucfirst( str_replace( '_', ' ', $term->taxonomy ) );
|
615 |
+
$output .= '<option value="tax-' . $tax_id . '" selected="selected" >' . $term->name . ' - ' . $term_taxonomy . '</option>';
|
616 |
|
617 |
+
}
|
618 |
}
|
619 |
}
|
620 |
+
$output .= '</select>';
|
621 |
+
$output .= '</div>';
|
622 |
}
|
|
|
|
|
623 |
|
624 |
$output .= '</div>';
|
625 |
|
840 |
$saved_values = $value;
|
841 |
$output = '';
|
842 |
|
843 |
+
if ( ! isset( self::$user_selection ) || empty( self::$user_selection ) ) {
|
844 |
+
self::$user_selection = self::get_user_selections();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
845 |
}
|
846 |
|
847 |
+
$selection_options = self::$user_selection;
|
848 |
+
|
849 |
/* WP Template Format */
|
850 |
$output .= '<script type="text/html" id="tmpl-bsf-sb-user-role-condition">';
|
851 |
$output .= '<div class="bsf-sb-user-role-condition bsf-sb-user-role-{{data.id}}" data-rule="{{data.id}}" >';
|
922 |
*/
|
923 |
public function parse_user_role_condition( $post_id, $rules ) {
|
924 |
|
925 |
+
$show_popup = true;
|
926 |
|
927 |
if ( is_array( $rules ) && ! empty( $rules ) ) {
|
928 |
+
$show_popup = false;
|
929 |
|
930 |
foreach ( $rules as $i => $rule ) {
|
931 |
|
971 |
|
972 |
return $show_popup;
|
973 |
}
|
974 |
+
|
975 |
+
/**
|
976 |
+
* Get current page type
|
977 |
+
*
|
978 |
+
* @since 1.0.0
|
979 |
+
*
|
980 |
+
* @return string Page Type.
|
981 |
+
*/
|
982 |
+
public function get_current_page_type() {
|
983 |
+
|
984 |
+
if ( null === self::$current_page_type ) {
|
985 |
+
|
986 |
+
$page_type = '';
|
987 |
+
|
988 |
+
if ( is_404() ) {
|
989 |
+
$page_type = 'is_404';
|
990 |
+
} elseif ( is_search() ) {
|
991 |
+
$page_type = 'is_search';
|
992 |
+
} elseif ( is_archive() ) {
|
993 |
+
$page_type = 'is_archive';
|
994 |
+
|
995 |
+
if ( is_category() || is_tag() || is_tax() ) {
|
996 |
+
$page_type = 'is_tax';
|
997 |
+
} elseif ( is_date() ) {
|
998 |
+
$page_type = 'is_date';
|
999 |
+
} elseif ( is_author() ) {
|
1000 |
+
$page_type = 'is_author';
|
1001 |
+
}
|
1002 |
+
} elseif ( is_home() ) {
|
1003 |
+
$page_type = 'is_home';
|
1004 |
+
} elseif ( is_front_page() ) {
|
1005 |
+
$page_type = 'is_front_page';
|
1006 |
+
} elseif ( is_singular() ) {
|
1007 |
+
$page_type = 'is_singular';
|
1008 |
+
$current_id = get_the_id();
|
1009 |
+
} else {
|
1010 |
+
$current_id = get_the_id();
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
self::$current_page_type = $page_type;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
return self::$current_page_type;
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
/**
|
1020 |
+
* Get posts by conditions
|
1021 |
+
*
|
1022 |
+
* @since 1.0.0
|
1023 |
+
* @param string $post_type Post Type.
|
1024 |
+
* @param array $option meta option name.
|
1025 |
+
*
|
1026 |
+
* @return object Posts.
|
1027 |
+
*/
|
1028 |
+
public function get_posts_by_conditions( $post_type, $option ) {
|
1029 |
+
|
1030 |
+
if ( is_array( self::$current_page_data ) && isset( self::$current_page_data[ $post_type ] ) ) {
|
1031 |
+
return self::$current_page_data[ $post_type ];
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
global $wpdb;
|
1035 |
+
global $post;
|
1036 |
+
|
1037 |
+
$current_page_type = $this->get_current_page_type();
|
1038 |
+
$post_type = $post_type ? esc_sql( $post_type ) : esc_sql( $post->post_type );
|
1039 |
+
$current_post_type = esc_sql( get_post_type() );
|
1040 |
+
$current_post_id = false;
|
1041 |
+
$q_obj = get_queried_object();
|
1042 |
+
|
1043 |
+
$location = isset( $option['location'] ) ? $option['location'] : '';
|
1044 |
+
|
1045 |
+
self::$current_page_data[ $post_type ] = array();
|
1046 |
+
|
1047 |
+
$query = "SELECT p.ID, p.post_name, pm.meta_value FROM {$wpdb->postmeta} as pm
|
1048 |
+
INNER JOIN {$wpdb->posts} as p ON pm.post_id = p.ID
|
1049 |
+
WHERE pm.meta_key = '{$location}'
|
1050 |
+
AND p.post_type = '{$post_type}'
|
1051 |
+
AND p.post_status = 'publish'";
|
1052 |
+
|
1053 |
+
$orderby = ' ORDER BY p.post_date DESC';
|
1054 |
+
|
1055 |
+
/* Entire Website */
|
1056 |
+
$meta_args = "pm.meta_value LIKE '%\"basic-global\"%'";
|
1057 |
+
|
1058 |
+
switch ( $current_page_type ) {
|
1059 |
+
case 'is_404':
|
1060 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-404\"%'";
|
1061 |
+
break;
|
1062 |
+
case 'is_search':
|
1063 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-search\"%'";
|
1064 |
+
break;
|
1065 |
+
case 'is_archive':
|
1066 |
+
case 'is_tax':
|
1067 |
+
case 'is_date':
|
1068 |
+
case 'is_author':
|
1069 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"basic-archives\"%'";
|
1070 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"{$current_post_type}|all|archive\"%'";
|
1071 |
+
|
1072 |
+
if ( 'is_tax' == $current_page_type && ( is_category() || is_tag() || is_tax() ) ) {
|
1073 |
+
|
1074 |
+
if ( is_object( $q_obj ) ) {
|
1075 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"{$current_post_type}|all|taxarchive|{$q_obj->taxonomy}\"%'";
|
1076 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"tax-{$q_obj->term_id}\"%'";
|
1077 |
+
}
|
1078 |
+
} elseif ( 'is_date' == $current_page_type ) {
|
1079 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-date\"%'";
|
1080 |
+
} elseif ( 'is_author' == $current_page_type ) {
|
1081 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-author\"%'";
|
1082 |
+
}
|
1083 |
+
break;
|
1084 |
+
case 'is_home':
|
1085 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-blog\"%'";
|
1086 |
+
break;
|
1087 |
+
case 'is_front_page':
|
1088 |
+
$current_id = esc_sql( get_the_id() );
|
1089 |
+
$current_post_id = $current_id;
|
1090 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"special-front\"%'";
|
1091 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"{$current_post_type}|all\"%'";
|
1092 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"post-{$current_id}\"%'";
|
1093 |
+
break;
|
1094 |
+
case 'is_singular':
|
1095 |
+
$current_id = esc_sql( get_the_id() );
|
1096 |
+
$current_post_id = $current_id;
|
1097 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"basic-singulars\"%'";
|
1098 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"{$current_post_type}|all\"%'";
|
1099 |
+
$meta_args .= " OR pm.meta_value LIKE '%\"post-{$current_id}\"%'";
|
1100 |
+
break;
|
1101 |
+
case '':
|
1102 |
+
$current_post_id = get_the_id();
|
1103 |
+
break;
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
// Ignore the PHPCS warning about constant declaration.
|
1107 |
+
// @codingStandardsIgnoreStart
|
1108 |
+
$posts = $wpdb->get_results( $query . ' AND (' . $meta_args . ')' . $orderby );
|
1109 |
+
// @codingStandardsIgnoreEnd
|
1110 |
+
|
1111 |
+
foreach ( $posts as $local_post ) {
|
1112 |
+
self::$current_page_data[ $post_type ][ $local_post->ID ] = array(
|
1113 |
+
'id' => $local_post->ID,
|
1114 |
+
'post_name' => $local_post->post_name,
|
1115 |
+
'location' => unserialize( $local_post->meta_value ),
|
1116 |
+
);
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
$option['current_post_id'] = $current_post_id;
|
1120 |
+
|
1121 |
+
$this->remove_exclusion_rule_posts( $post_type, $option );
|
1122 |
+
$this->remove_user_rule_posts( $post_type, $option );
|
1123 |
+
|
1124 |
+
return self::$current_page_data[ $post_type ];
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
/**
|
1128 |
+
* Remove exclusion rule posts.
|
1129 |
+
*
|
1130 |
+
* @since 1.0.0
|
1131 |
+
* @param string $post_type Post Type.
|
1132 |
+
* @param array $option meta option name.
|
1133 |
+
*/
|
1134 |
+
public function remove_exclusion_rule_posts( $post_type, $option ) {
|
1135 |
+
|
1136 |
+
$exclusion = isset( $option['exclusion'] ) ? $option['exclusion'] : '';
|
1137 |
+
$current_post_id = isset( $option['current_post_id'] ) ? $option['current_post_id'] : false;
|
1138 |
+
|
1139 |
+
foreach ( self::$current_page_data[ $post_type ] as $c_post_id => $c_data ) {
|
1140 |
+
|
1141 |
+
$exclusion_rules = get_post_meta( $c_post_id, $exclusion, true );
|
1142 |
+
$is_exclude = $this->parse_layout_display_condition( $current_post_id, $exclusion_rules );
|
1143 |
+
|
1144 |
+
if ( $is_exclude ) {
|
1145 |
+
unset( self::$current_page_data[ $post_type ][ $c_post_id ] );
|
1146 |
+
}
|
1147 |
+
}
|
1148 |
+
}
|
1149 |
+
|
1150 |
+
/**
|
1151 |
+
* Remove user rule posts.
|
1152 |
+
*
|
1153 |
+
* @since 1.0.0
|
1154 |
+
* @param int $post_type Post Type.
|
1155 |
+
* @param array $option meta option name.
|
1156 |
+
*/
|
1157 |
+
public function remove_user_rule_posts( $post_type, $option ) {
|
1158 |
+
|
1159 |
+
$users = isset( $option['users'] ) ? $option['users'] : '';
|
1160 |
+
$current_post_id = isset( $option['current_post_id'] ) ? $option['current_post_id'] : false;
|
1161 |
+
|
1162 |
+
foreach ( self::$current_page_data[ $post_type ] as $c_post_id => $c_data ) {
|
1163 |
+
|
1164 |
+
$user_rules = get_post_meta( $c_post_id, $users, true );
|
1165 |
+
$is_user = $this->parse_user_role_condition( $current_post_id, $user_rules );
|
1166 |
+
|
1167 |
+
if ( ! $is_user ) {
|
1168 |
+
unset( self::$current_page_data[ $post_type ][ $c_post_id ] );
|
1169 |
+
}
|
1170 |
+
}
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
/**
|
1174 |
+
* Same display_on notice.
|
1175 |
+
*
|
1176 |
+
* @since 1.0.0
|
1177 |
+
* @param int $post_type Post Type.
|
1178 |
+
* @param array $option meta option name.
|
1179 |
+
*/
|
1180 |
+
static public function same_display_on_notice( $post_type, $option ) {
|
1181 |
+
global $wpdb;
|
1182 |
+
global $post;
|
1183 |
+
|
1184 |
+
$all_rules = array();
|
1185 |
+
$already_set_rule = array();
|
1186 |
+
|
1187 |
+
$location = isset( $option['location'] ) ? $option['location'] : '';
|
1188 |
+
|
1189 |
+
$all_headers = $wpdb->get_results(
|
1190 |
+
$wpdb->prepare(
|
1191 |
+
"SELECT p.ID, p.post_title, pm.meta_value FROM {$wpdb->postmeta} as pm
|
1192 |
+
INNER JOIN {$wpdb->posts} as p ON pm.post_id = p.ID
|
1193 |
+
WHERE pm.meta_key = '%s'
|
1194 |
+
AND p.post_type = '%s'
|
1195 |
+
AND p.post_status = 'publish'", $location,
|
1196 |
+
$post_type
|
1197 |
+
)
|
1198 |
+
);
|
1199 |
+
|
1200 |
+
foreach ( $all_headers as $header ) {
|
1201 |
+
|
1202 |
+
$location_rules = unserialize( $header->meta_value );
|
1203 |
+
|
1204 |
+
if ( is_array( $location_rules ) && isset( $location_rules['rule'] ) ) {
|
1205 |
+
|
1206 |
+
foreach ( $location_rules['rule'] as $key => $rule ) {
|
1207 |
+
|
1208 |
+
if ( ! isset( $all_rules[ $rule ] ) ) {
|
1209 |
+
$all_rules[ $rule ] = array();
|
1210 |
+
}
|
1211 |
+
|
1212 |
+
if ( 'specifics' == $rule && isset( $location_rules['specific'] ) && is_array( $location_rules['specific'] ) ) {
|
1213 |
+
|
1214 |
+
foreach ( $location_rules['specific'] as $s_index => $s_value ) {
|
1215 |
+
|
1216 |
+
$all_rules[ $rule ][ $s_value ][ $header->ID ] = array(
|
1217 |
+
'ID' => $header->ID,
|
1218 |
+
'name' => $header->post_title,
|
1219 |
+
);
|
1220 |
+
}
|
1221 |
+
} else {
|
1222 |
+
$all_rules[ $rule ][ $header->ID ] = array(
|
1223 |
+
'ID' => $header->ID,
|
1224 |
+
'name' => $header->post_title,
|
1225 |
+
);
|
1226 |
+
}
|
1227 |
+
}
|
1228 |
+
}
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
$current_post_data = get_post_meta( $post->ID, $location, true );
|
1232 |
+
|
1233 |
+
if ( is_array( $current_post_data ) && isset( $current_post_data['rule'] ) ) {
|
1234 |
+
|
1235 |
+
foreach ( $current_post_data['rule'] as $c_key => $c_rule ) {
|
1236 |
+
|
1237 |
+
if ( ! isset( $all_rules[ $c_rule ] ) ) {
|
1238 |
+
continue;
|
1239 |
+
}
|
1240 |
+
|
1241 |
+
if ( 'specifics' === $c_rule ) {
|
1242 |
+
|
1243 |
+
foreach ( $current_post_data['specific'] as $s_index => $s_id ) {
|
1244 |
+
if ( ! isset( $all_rules[ $c_rule ][ $s_id ] ) ) {
|
1245 |
+
continue;
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
foreach ( $all_rules[ $c_rule ][ $s_id ] as $p_id => $data ) {
|
1249 |
+
|
1250 |
+
if ( $p_id == $post->ID ) {
|
1251 |
+
continue;
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
$already_set_rule[] = $data['name'];
|
1255 |
+
}
|
1256 |
+
}
|
1257 |
+
} else {
|
1258 |
+
|
1259 |
+
foreach ( $all_rules[ $c_rule ] as $p_id => $data ) {
|
1260 |
+
|
1261 |
+
if ( $p_id == $post->ID ) {
|
1262 |
+
continue;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
$already_set_rule[] = $data['name'];
|
1266 |
+
}
|
1267 |
+
}
|
1268 |
+
}
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
if ( ! empty( $already_set_rule ) ) {
|
1272 |
+
add_action(
|
1273 |
+
'admin_notices', function() use ( $already_set_rule ) {
|
1274 |
+
|
1275 |
+
$rule_set_titles = '<strong>' . implode( ',', $already_set_rule ) . '</strong>';
|
1276 |
+
|
1277 |
+
/* translators: %s post title. */
|
1278 |
+
$notice = sprintf( __( 'The same display setting is already exist in %s post/s.', 'bsfsidebars' ), $rule_set_titles );
|
1279 |
+
|
1280 |
+
echo '<div class="error">';
|
1281 |
+
echo '<p>' . $notice . '</p>';
|
1282 |
+
echo '</div>';
|
1283 |
+
|
1284 |
+
}
|
1285 |
+
);
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
/**
|
1290 |
+
* Formated rule meta value to save.
|
1291 |
+
*
|
1292 |
+
* @since 1.0.0
|
1293 |
+
* @param array $save_data PostData.
|
1294 |
+
* @param string $key varaible key.
|
1295 |
+
*
|
1296 |
+
* @return array Rule data.
|
1297 |
+
*/
|
1298 |
+
static public function get_format_rule_value( $save_data, $key ) {
|
1299 |
+
$meta_value = array();
|
1300 |
+
|
1301 |
+
if ( isset( $save_data[ $key ]['rule'] ) ) {
|
1302 |
+
$save_data[ $key ]['rule'] = array_unique( $save_data[ $key ]['rule'] );
|
1303 |
+
if ( isset( $save_data[ $key ]['specific'] ) ) {
|
1304 |
+
$save_data[ $key ]['specific'] = array_unique( $save_data[ $key ]['specific'] );
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
// Unset the specifics from rule. This will be readded conditionally in next condition.
|
1308 |
+
$index = array_search( '', $save_data[ $key ]['rule'] );
|
1309 |
+
if ( false !== $index ) {
|
1310 |
+
unset( $save_data[ $key ]['rule'][ $index ] );
|
1311 |
+
}
|
1312 |
+
$index = array_search( 'specifics', $save_data[ $key ]['rule'] );
|
1313 |
+
if ( false !== $index ) {
|
1314 |
+
unset( $save_data[ $key ]['rule'][ $index ] );
|
1315 |
+
|
1316 |
+
// Only re-add the specifics key if there are specific rules added.
|
1317 |
+
if ( isset( $save_data[ $key ]['specific'] ) && is_array( $save_data[ $key ]['specific'] ) ) {
|
1318 |
+
array_push( $save_data[ $key ]['rule'], 'specifics' );
|
1319 |
+
}
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
foreach ( $save_data[ $key ] as $meta_key => $value ) {
|
1323 |
+
if ( ! empty( $value ) ) {
|
1324 |
+
$meta_value[ $meta_key ] = array_map( 'esc_attr', $value );
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
if ( ! isset( $meta_value['rule'] ) || ! in_array( 'specifics', $meta_value['rule'] ) ) {
|
1328 |
+
$meta_value['specific'] = array();
|
1329 |
+
}
|
1330 |
+
|
1331 |
+
if ( empty( $meta_value['rule'] ) ) {
|
1332 |
+
$meta_value = array();
|
1333 |
+
}
|
1334 |
+
}
|
1335 |
+
|
1336 |
+
return $meta_value;
|
1337 |
+
}
|
1338 |
}
|
1339 |
}// End if().
|
1340 |
|
includes/white-label.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* White Label Form
|
4 |
+
*
|
5 |
+
* @package Astra SideBar
|
6 |
+
*/
|
7 |
+
|
8 |
+
?>
|
9 |
+
<li>
|
10 |
+
<div class="branding-form postbox">
|
11 |
+
<button type="button" class="handlediv button-link" aria-expanded="true">
|
12 |
+
<span class="screen-reader-text"><?php _e( 'Astra SideBar Branding', 'bsfsidebars' ); ?></span>
|
13 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
14 |
+
</button>
|
15 |
+
|
16 |
+
<h2 class="hndle ui-sortable-handle">
|
17 |
+
<span><?php _e( 'Astra SideBar Branding', 'bsfsidebars' ); ?></span>
|
18 |
+
</h2>
|
19 |
+
|
20 |
+
<div class="inside">
|
21 |
+
<div class="form-wrap">
|
22 |
+
<div class="form-field">
|
23 |
+
<label><?php _e( 'Plugin Name:', 'bsfsidebars' ); ?>
|
24 |
+
<input type="text" name="ast_white_label[bsf-lw-sb][name]" class="placeholder placeholder-active" value="<?php echo esc_attr( $settings['bsf-lw-sb']['name'] ); ?>">
|
25 |
+
</label>
|
26 |
+
</div>
|
27 |
+
<div class="form-field">
|
28 |
+
<label><?php _e( 'Plugin Description:', 'bsfsidebars' ); ?>
|
29 |
+
<textarea name="ast_white_label[bsf-lw-sb][description]" class="placeholder placeholder-active" rows="2"><?php echo esc_attr( $settings['bsf-lw-sb']['description'] ); ?></textarea>
|
30 |
+
</label>
|
31 |
+
</div>
|
32 |
+
<div class="clear"></div>
|
33 |
+
</div>
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
</li>
|
languages/custom-sidebars.pot
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2017
|
2 |
+
# This file is distributed under the same license as the package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: \n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/custom-sidebars\n"
|
7 |
+
"POT-Creation-Date: 2017-10-03 10:41:53+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
|
12 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
13 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14 |
+
"X-Generator: grunt-wp-i18n 0.5.4\n"
|
15 |
+
"X-Poedit-KeywordsList: "
|
16 |
+
"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
|
17 |
+
"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
|
18 |
+
"Language: en\n"
|
19 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
20 |
+
"X-Poedit-Country: United States\n"
|
21 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
22 |
+
"X-Poedit-Basepath: ../\n"
|
23 |
+
"X-Poedit-SearchPath-0: .\n"
|
24 |
+
"X-Poedit-Bookmarks: \n"
|
25 |
+
"X-Textdomain-Support: yes\n"
|
26 |
+
|
27 |
+
#: classes/class-bsf-sb-metabox.php:57
|
28 |
+
msgid "Enter sidebar title here"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: classes/class-bsf-sb-metabox.php:73
|
32 |
+
msgid "Sidebar Settings"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#: classes/class-bsf-sb-metabox.php:144
|
36 |
+
msgid "Sidebar To Replace"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: classes/class-bsf-sb-metabox.php:145
|
40 |
+
msgid ""
|
41 |
+
"Choose which sidebar you want to replace. Select None to disable this "
|
42 |
+
"sidebar."
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: classes/class-bsf-sb-metabox.php:151
|
46 |
+
msgid "None"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: classes/class-bsf-sb-metabox.php:161
|
50 |
+
msgid "Sidebars are not available."
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: classes/class-bsf-sb-metabox.php:169
|
54 |
+
msgid "Description"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: classes/class-bsf-sb-metabox.php:170
|
58 |
+
msgid "Add an optional description fot the Widgets screen."
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: classes/class-bsf-sb-metabox.php:180
|
62 |
+
msgid "Display On"
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: classes/class-bsf-sb-metabox.php:181
|
66 |
+
msgid "Add locations for where this sidebar should appear."
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: classes/class-bsf-sb-metabox.php:189
|
70 |
+
msgid "Display Rules"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: classes/class-bsf-sb-metabox.php:193
|
74 |
+
msgid "Add Display Rule"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: classes/class-bsf-sb-metabox.php:203
|
78 |
+
msgid "Do Not Display On"
|
79 |
+
msgstr ""
|
80 |
+
|
81 |
+
#: classes/class-bsf-sb-metabox.php:204
|
82 |
+
msgid "This Sidebar will not appear at these locations."
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: classes/class-bsf-sb-metabox.php:211
|
86 |
+
msgid "Exclude On"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: classes/class-bsf-sb-metabox.php:214
|
90 |
+
msgid "Add Excludion Rule"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: classes/class-bsf-sb-metabox.php:225
|
94 |
+
msgid "User Roles"
|
95 |
+
msgstr ""
|
96 |
+
|
97 |
+
#: classes/class-bsf-sb-metabox.php:226
|
98 |
+
msgid "Target header based on user role."
|
99 |
+
msgstr ""
|
100 |
+
|
101 |
+
#: classes/class-bsf-sb-metabox.php:233
|
102 |
+
msgid "Users"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: classes/class-bsf-sb-metabox.php:236
|
106 |
+
msgid "Add User Rule"
|
107 |
+
msgstr ""
|
108 |
+
|
109 |
+
#: classes/class-bsf-sb-post-type.php:63
|
110 |
+
msgid "Sidebar"
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: classes/class-bsf-sb-post-type.php:64
|
114 |
+
msgid "Sidebars"
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: classes/class-bsf-sb-post-type.php:74
|
118 |
+
msgid "Add New"
|
119 |
+
msgstr ""
|
120 |
+
|
121 |
+
#: classes/class-bsf-sb-post-type.php:76
|
122 |
+
#. translators: %s singular
|
123 |
+
msgid "Add New %s"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: classes/class-bsf-sb-post-type.php:78
|
127 |
+
#. translators: %s singular
|
128 |
+
msgid "Edit %s"
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: classes/class-bsf-sb-post-type.php:80
|
132 |
+
#. translators: %s singular
|
133 |
+
msgid "New %s"
|
134 |
+
msgstr ""
|
135 |
+
|
136 |
+
#: classes/class-bsf-sb-post-type.php:83
|
137 |
+
#. translators: %s singular
|
138 |
+
msgid "View %s"
|
139 |
+
msgstr ""
|
140 |
+
|
141 |
+
#: classes/class-bsf-sb-post-type.php:85
|
142 |
+
#. translators: %s plural
|
143 |
+
msgid "Search %s"
|
144 |
+
msgstr ""
|
145 |
+
|
146 |
+
#: classes/class-bsf-sb-post-type.php:87
|
147 |
+
#. translators: %s plural
|
148 |
+
msgid "No %s Found"
|
149 |
+
msgstr ""
|
150 |
+
|
151 |
+
#: classes/class-bsf-sb-post-type.php:89
|
152 |
+
#. translators: %s plural
|
153 |
+
msgid "No %s Found In Trash"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:129
|
157 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:186
|
158 |
+
msgid "Basic"
|
159 |
+
msgstr ""
|
160 |
+
|
161 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:131
|
162 |
+
msgid "Entire Website"
|
163 |
+
msgstr ""
|
164 |
+
|
165 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:132
|
166 |
+
msgid "All Singulars"
|
167 |
+
msgstr ""
|
168 |
+
|
169 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:133
|
170 |
+
msgid "All Archives"
|
171 |
+
msgstr ""
|
172 |
+
|
173 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:138
|
174 |
+
msgid "Special Pages"
|
175 |
+
msgstr ""
|
176 |
+
|
177 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:140
|
178 |
+
msgid "404 Page"
|
179 |
+
msgstr ""
|
180 |
+
|
181 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:141
|
182 |
+
msgid "Search Page"
|
183 |
+
msgstr ""
|
184 |
+
|
185 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:142
|
186 |
+
msgid "Blog / Posts Page"
|
187 |
+
msgstr ""
|
188 |
+
|
189 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:143
|
190 |
+
msgid "Front Page"
|
191 |
+
msgstr ""
|
192 |
+
|
193 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:144
|
194 |
+
msgid "Date Archive"
|
195 |
+
msgstr ""
|
196 |
+
|
197 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:145
|
198 |
+
msgid "Author Archive"
|
199 |
+
msgstr ""
|
200 |
+
|
201 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:169
|
202 |
+
msgid "Specific Target"
|
203 |
+
msgstr ""
|
204 |
+
|
205 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:171
|
206 |
+
msgid "Specific Pages / Posts / Taxanomies, etc."
|
207 |
+
msgstr ""
|
208 |
+
|
209 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:188
|
210 |
+
msgid "All"
|
211 |
+
msgstr ""
|
212 |
+
|
213 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:189
|
214 |
+
msgid "Logged In"
|
215 |
+
msgstr ""
|
216 |
+
|
217 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:190
|
218 |
+
msgid "Logged Out"
|
219 |
+
msgstr ""
|
220 |
+
|
221 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:195
|
222 |
+
msgid "Advanced"
|
223 |
+
msgstr ""
|
224 |
+
|
225 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:446
|
226 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:839
|
227 |
+
msgid "Add Rule"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:463
|
231 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:574
|
232 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:856
|
233 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:888
|
234 |
+
msgid "Select"
|
235 |
+
msgstr ""
|
236 |
+
|
237 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:515
|
238 |
+
#. translators: %s percentage
|
239 |
+
msgid "All %s"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:520
|
243 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:531
|
244 |
+
#. translators: %s percentage
|
245 |
+
msgid "All %s Archive"
|
246 |
+
msgstr ""
|
247 |
+
|
248 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:634
|
249 |
+
msgid "Add Exclusion Rule"
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#: classes/modules/target-rule/class-bsf-sb-target-rules-fields.php:1278
|
253 |
+
#. translators: %s post title.
|
254 |
+
msgid "The same display setting is already exist in %s post/s."
|
255 |
+
msgstr ""
|
256 |
+
|
257 |
+
#: includes/white-label.php:12 includes/white-label.php:17
|
258 |
+
msgid "Astra SideBar Branding"
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: includes/white-label.php:23
|
262 |
+
msgid "Plugin Name:"
|
263 |
+
msgstr ""
|
264 |
+
|
265 |
+
#: includes/white-label.php:28
|
266 |
+
msgid "Plugin Description:"
|
267 |
+
msgstr ""
|
268 |
+
|
269 |
+
#: classes/class-bsf-sb-post-type.php:71
|
270 |
+
msgctxt "post type general name"
|
271 |
+
msgid "Sidebars"
|
272 |
+
msgstr ""
|
273 |
+
|
274 |
+
#: classes/class-bsf-sb-post-type.php:72
|
275 |
+
msgctxt "post type singular name"
|
276 |
+
msgid "Sidebar"
|
277 |
+
msgstr ""
|
278 |
+
|
279 |
+
#: classes/class-bsf-sb-post-type.php:73
|
280 |
+
msgctxt "admin menu"
|
281 |
+
msgid "Sidebars"
|
282 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: BrainstormForce
|
|
3 |
Donate link: https://www.brainstormforce.com/payment/
|
4 |
Tags: custom sidebar, sidebar manager, custom widget areas, widgets, conditional sidebar
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.8
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -46,4 +46,14 @@ Other plugins we found are heavy with ugly interface, non supported, developed o
|
|
46 |
|
47 |
1. Add a New Sidebar from Appearance -> Sidebars -> Add New.
|
48 |
1. Give sidebar a name, Select a sidebar that is to be replaced and locations where the sidebar should appear.
|
49 |
-
1. Add Content to the newly created sidebar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Donate link: https://www.brainstormforce.com/payment/
|
4 |
Tags: custom sidebar, sidebar manager, custom widget areas, widgets, conditional sidebar
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.8.2
|
7 |
+
Stable tag: 1.0.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
46 |
|
47 |
1. Add a New Sidebar from Appearance -> Sidebars -> Add New.
|
48 |
1. Give sidebar a name, Select a sidebar that is to be replaced and locations where the sidebar should appear.
|
49 |
+
1. Add Content to the newly created sidebar.
|
50 |
+
|
51 |
+
|
52 |
+
== Changelog ==
|
53 |
+
|
54 |
+
v1.0.1
|
55 |
+
* White Label support added from the [Astra Pro](https://wpastra.com/pro/) plugin.
|
56 |
+
* Optimized target rules query to be even more lightweight.
|
57 |
+
|
58 |
+
v1.0.0
|
59 |
+
* Initial release
|
sidebar-manager.php
CHANGED
@@ -1,14 +1,32 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Sidebar Manager
|
4 |
-
* Plugin URI:
|
5 |
-
* Description:
|
6 |
-
* Version: 1.0.
|
7 |
-
* Author:
|
8 |
-
* Author URI:
|
9 |
* Text Domain: bsfsidebars
|
10 |
*
|
11 |
* @package Custom_Sidebars
|
12 |
*/
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Sidebar Manager
|
4 |
+
* Plugin URI: http://www.brainstormforce.com
|
5 |
+
* Description: This is the plugin to create custom siderbars to your site.
|
6 |
+
* Version: 1.0.1
|
7 |
+
* Author: Brainstorm Force
|
8 |
+
* Author URI: https://www.brainstormforce.com/
|
9 |
* Text Domain: bsfsidebars
|
10 |
*
|
11 |
* @package Custom_Sidebars
|
12 |
*/
|
13 |
|
14 |
+
/**
|
15 |
+
* Exit if accessed directly.
|
16 |
+
*/
|
17 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
18 |
+
exit();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Set constants.
|
23 |
+
*/
|
24 |
+
define( 'BSF_SB_FILE', __FILE__ );
|
25 |
+
define( 'BSF_SB_BASE', plugin_basename( BSF_SB_FILE ) );
|
26 |
+
define( 'BSF_SB_DIR', plugin_dir_path( BSF_SB_FILE ) );
|
27 |
+
define( 'BSF_SB_URL', plugins_url( '/', BSF_SB_FILE ) );
|
28 |
+
define( 'BSF_SB_VER', '1.0.1' );
|
29 |
+
define( 'BSF_SB_PREFIX', 'bsf-sb' );
|
30 |
+
define( 'BSF_SB_POST_TYPE', 'bsf-sidebar' );
|
31 |
+
|
32 |
+
require_once 'classes/class-bsf-sb-loader.php';
|