Version Description
Moved to WordPress.org. Woo! Added scope to methods and properties where missing.
=
Download this release
Release Info
Developer | mattyza |
Plugin | WooSidebars |
Version | 1.2.0 |
Comparing to | |
See all releases |
Version 1.2.0
- assets/css/admin-posts.css +3 -0
- assets/css/admin.css +26 -0
- assets/images/icon-settings.png +0 -0
- assets/images/success-off.png +0 -0
- assets/images/success.png +0 -0
- assets/js/admin.js +26 -0
- changelog.txt +20 -0
- classes/class-woo-conditions.php +721 -0
- classes/class-woo-sidebars.php +798 -0
- index.php +3 -0
- integrations/integration-woocommerce.php +141 -0
- lang/woosidebars-en_GB.po +495 -0
- lang/woosidebars-xx_XX.pot +1 -0
- readme.txt +89 -0
- woosidebars.php +27 -0
assets/css/admin-posts.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
/* Custom Column On Posts, etc */
|
2 |
+
|
3 |
+
.column-woosidebars_enable { width: 12%; }
|
assets/css/admin.css
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.conditions-tabs li { display: inline; margin: 5px 0; padding: 5px; }
|
2 |
+
.woo-conditions .ui-tabs-hide { display: none !important; }
|
3 |
+
.woo-conditions .conditions-tabs { background:#eaeaea;padding:3px 9px 0;margin:0;overflow:hidden;zoom:1;line-height:1em;-webkit-box-shadow:inset 0 -1px 0 0 #d5d5d5;-moz-box-shadow:inset 0 -1px 0 0 x #d5d5d5;box-shadow:inset 0 -1px 0 0 #d5d5d5; }
|
4 |
+
.woo-conditions .conditions-tabs li { float:left;padding:0;margin:0 5px 0 0; }
|
5 |
+
.woo-conditions .conditions-tabs li.alignright { float: right; }
|
6 |
+
.woo-conditions .conditions-tabs li.hide { display: none; }
|
7 |
+
.woo-conditions .conditions-tabs li.advanced-settings a { background-image: url(../images/icon-settings.png); background-repeat: no-repeat; background-position: 8px 50%; padding-left: 30px; }
|
8 |
+
.woo-conditions .conditions-tabs li a { padding:0;margin:0;border:0;border:1px solid #d5d5d5;border-bottom:0;float:left;padding:9px 9px;background:#ececec;text-decoration:none;color:#555;-moz-border-radius-topleft:3px;-moz-border-radius-topright:3px;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;-webkit-box-shadow:inset 0 1px 0 1px rgba(255, 255, 255, 0.5);-moz-box-shadow:inset 0 1px 0 1px rgba(255, 255, 255, 0.5);box-shadow:inset 0 1px 0 1px rgba(255, 255, 255, 0.5); }
|
9 |
+
.woo-conditions .conditions-tabs li.ui-state-active {}
|
10 |
+
.woo-conditions .conditions-tabs li.ui-state-active a { background:#f8f8f8;color:#555;background-image:linear-gradient(bottom, #ffffff 0%, #f8f8f8 100%);background-image:-o-linear-gradient(bottom, #ffffff 0%, #f8f8f8 100%);background-image:-moz-linear-gradient(bottom, #ffffff 0%, #f8f8f8 100%);background-image:-webkit-linear-gradient(bottom, #ffffff 0%, #f8f8f8 100%);background-image:-ms-linear-gradient(bottom, #ffffff 0%, #f8f8f8 100%);background-image:-webkit-gradient(linear, left bottom, left top, color-stop(0, #ffffff), color-stop(1, #f8f8f8)); }
|
11 |
+
#woo-conditions.postbox .inside { background: #FFFFFF; padding: 0; margin: 0; }
|
12 |
+
#woo-conditions.postbox .inside .condition-tab { background: #FFFFFF; padding: 2px 18px; }
|
13 |
+
#woo-conditions.postbox .inside .condition-tab h4 { margin-top: 10px; }
|
14 |
+
|
15 |
+
#woo-conditions.postbox .conditions-column { display: block; margin: 0 20px 20px 0; }
|
16 |
+
|
17 |
+
#woo-conditions.postbox .conditions-tabs-inner { display: block; padding: 10px 0; }
|
18 |
+
.conditions-tabs-inner li { display: inline; padding: .2em; line-height: 2; margin: 0; }
|
19 |
+
.conditions-tabs-inner li a { margin-right: 5px; text-decoration: none; }
|
20 |
+
.conditions-tabs-inner li.ui-state-active a { color: #000000; font-weight: bold; }
|
21 |
+
#woo-conditions.postbox .inside .condition-tab .condition-tab { padding: 2px 0px; }
|
22 |
+
|
23 |
+
.view-switch { display: none; }
|
24 |
+
|
25 |
+
#preview-action { display: none; }
|
26 |
+
#visibility.misc-pub-section { display: none; }
|
assets/images/icon-settings.png
ADDED
Binary file
|
assets/images/success-off.png
ADDED
Binary file
|
assets/images/success.png
ADDED
Binary file
|
assets/js/admin.js
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery( document ).ready( function () {
|
2 |
+
jQuery( '.woo-conditions.tabs' ).tabs();
|
3 |
+
jQuery( '.woo-conditions.tabs .inner-tabs' ).tabs();
|
4 |
+
|
5 |
+
jQuery( '#woo-conditions .advanced-settings a' ).click( function ( e ) {
|
6 |
+
jQuery( this ).parent( 'li' ).siblings( '.advanced' ).toggleClass( 'hide' );
|
7 |
+
|
8 |
+
var new_status = '1'; // Do display.
|
9 |
+
if ( jQuery( this ).parent( 'li' ).siblings( '.advanced' ).hasClass( 'hide' ) ) {
|
10 |
+
new_status = '0'; // Don't display.
|
11 |
+
}
|
12 |
+
|
13 |
+
// Perform the AJAX call.
|
14 |
+
jQuery.post(
|
15 |
+
ajaxurl,
|
16 |
+
{
|
17 |
+
action : 'woosidebars-toggle-advanced-items',
|
18 |
+
woosidebars_advanced_noonce : woosidebars_localized_data.woosidebars_advanced_noonce,
|
19 |
+
new_status: new_status
|
20 |
+
},
|
21 |
+
function( response ) {}
|
22 |
+
);
|
23 |
+
|
24 |
+
return false;
|
25 |
+
});
|
26 |
+
});
|
changelog.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*** WooSidebars Changelog ***
|
2 |
+
|
3 |
+
2012.08.14 - version 1.1.2
|
4 |
+
* /integrations/integration-woocommerce.php - Added logic to stop undefined index notices in foreach(). Prevent direct file access.
|
5 |
+
* /classes/class.wooconditions.php,
|
6 |
+
/classes/class.woosidebars.php - Prevent direct file access.
|
7 |
+
* /classes/class.updater.php - Prevent direct file access. Return $false instead of false when checking for updates, if not WooSidebars.
|
8 |
+
* /lang/woosidebars-en_GB.po - Rescanned language file.
|
9 |
+
* /lang/woosidebars-xx_XX.pot - Rescanned language template file.
|
10 |
+
* woosidebars.php - Prevent direct file access. Update stable tag.
|
11 |
+
* index.php - Added to prevent directory listing.
|
12 |
+
|
13 |
+
2012.05.23 - version 1.1.0
|
14 |
+
* /classes/class.woosidebars.php - Adjustments to accept integrations.
|
15 |
+
* /classes/class.wooconditions.php - Adjustments to accept integrations.
|
16 |
+
* /integrations/integration-woocommerce.php - Initial WooCommerce integration, if WooCommerce is active.
|
17 |
+
* woosidebars.php - Load WooCommerce integration, if WooCommerce is active.
|
18 |
+
|
19 |
+
2012.04.11 - version 1.0.0
|
20 |
+
* Initial release. Woo!
|
classes/class-woo-conditions.php
ADDED
@@ -0,0 +1,721 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Woo Conditions Class
|
6 |
+
*
|
7 |
+
* Determine the conditions that apply to each screen within WordPress.
|
8 |
+
*
|
9 |
+
* @package WordPress
|
10 |
+
* @subpackage WooSidebars
|
11 |
+
* @author WooThemes
|
12 |
+
* @since 1.0.0
|
13 |
+
*
|
14 |
+
* TABLE OF CONTENTS
|
15 |
+
*
|
16 |
+
* public $token
|
17 |
+
* public $conditions
|
18 |
+
* public $conditions_headings
|
19 |
+
* public $conditions_reference
|
20 |
+
* public $meta_box_settings
|
21 |
+
* private $assets_url
|
22 |
+
* private $plugin_url
|
23 |
+
*
|
24 |
+
* - __construct()
|
25 |
+
* - get_conditions()
|
26 |
+
* - determine_conditions()
|
27 |
+
* - setup_default_conditions_reference()
|
28 |
+
* - is_hierarchy()
|
29 |
+
* - is_taxonomy()
|
30 |
+
* - is_post_type_archive()
|
31 |
+
* - is_page_template()
|
32 |
+
* - meta_box_setup()
|
33 |
+
* - meta_box_content()
|
34 |
+
* - meta_box_save()
|
35 |
+
* - show_advanced_items()
|
36 |
+
* - ajax_toggle_advanced_items()
|
37 |
+
* - enqueue_scripts()
|
38 |
+
*/
|
39 |
+
class Woo_Conditions {
|
40 |
+
public $token = '';
|
41 |
+
public $conditions = array();
|
42 |
+
public $conditions_headings = array();
|
43 |
+
public $conditions_reference = array();
|
44 |
+
public $meta_box_settings = array();
|
45 |
+
private $assets_url;
|
46 |
+
private $plugin_url;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* __construct function.
|
50 |
+
*
|
51 |
+
* @access public
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
public function __construct () {
|
55 |
+
$this->meta_box_settings['title'] = __( 'Conditions', 'woosidebars' );
|
56 |
+
|
57 |
+
if ( is_admin() && get_post_type() == $this->token || ! get_post_type() ) {
|
58 |
+
add_action( 'admin_menu', array( &$this, 'meta_box_setup' ), 20 );
|
59 |
+
add_action( 'save_post', array( &$this, 'meta_box_save' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
/* Plugin URL/path settings. */
|
63 |
+
$this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
|
64 |
+
$this->assets_url = $this->plugin_url . '/assets';
|
65 |
+
|
66 |
+
if ( is_admin() ) {
|
67 |
+
add_action( 'admin_print_scripts', array( &$this, 'enqueue_scripts' ), 12 );
|
68 |
+
}
|
69 |
+
|
70 |
+
add_action( 'get_header', array( &$this, 'get_conditions' ) );
|
71 |
+
|
72 |
+
add_action( 'wp_ajax_woosidebars-toggle-advanced-items', array( &$this, 'ajax_toggle_advanced_items' ) );
|
73 |
+
} // End __construct()
|
74 |
+
|
75 |
+
/**
|
76 |
+
* get_conditions function.
|
77 |
+
*
|
78 |
+
* @access public
|
79 |
+
* @return void
|
80 |
+
*/
|
81 |
+
public function get_conditions () {
|
82 |
+
$this->determine_conditions();
|
83 |
+
|
84 |
+
$this->conditions = apply_filters( 'woo_conditions', $this->conditions );
|
85 |
+
|
86 |
+
$this->conditions = array_reverse( $this->conditions );
|
87 |
+
} // End get_conditions()
|
88 |
+
|
89 |
+
/**
|
90 |
+
* determine_conditions function.
|
91 |
+
*
|
92 |
+
* @access public
|
93 |
+
* @return void
|
94 |
+
*/
|
95 |
+
public function determine_conditions () {
|
96 |
+
$this->is_hierarchy();
|
97 |
+
$this->is_taxonomy();
|
98 |
+
$this->is_post_type_archive();
|
99 |
+
$this->is_page_template();
|
100 |
+
} // End determine_conditions()
|
101 |
+
|
102 |
+
/**
|
103 |
+
* setup_default_conditions_reference function.
|
104 |
+
*
|
105 |
+
* @description Setup the default conditions and their information, for display when selecting conditions.
|
106 |
+
* @access public
|
107 |
+
* @return void
|
108 |
+
*/
|
109 |
+
public function setup_default_conditions_reference () {
|
110 |
+
$conditions = array();
|
111 |
+
$conditions_headings = array();
|
112 |
+
|
113 |
+
// Pages
|
114 |
+
$conditions['pages'] = array();
|
115 |
+
|
116 |
+
$pages = get_pages();
|
117 |
+
|
118 |
+
if ( count( $pages ) > 0 ) {
|
119 |
+
|
120 |
+
$conditions_headings['pages'] = __( 'Pages', 'woosidebars' );
|
121 |
+
|
122 |
+
foreach ( $pages as $k => $v ) {
|
123 |
+
$token = 'post-' . $v->ID;
|
124 |
+
$conditions['pages'][$token] = array(
|
125 |
+
'label' => $v->post_title,
|
126 |
+
'description' => sprintf( __( 'The "%s" page', 'woosidebars' ), $v->post_title )
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
$args = array(
|
133 |
+
'show_ui' => true,
|
134 |
+
'public' => true,
|
135 |
+
'publicly_queryable' => true,
|
136 |
+
'_builtin' => false
|
137 |
+
);
|
138 |
+
|
139 |
+
$post_types = get_post_types( $args, 'object' );
|
140 |
+
|
141 |
+
// Set certain post types that aren't allowed to have custom sidebars.
|
142 |
+
$disallowed_types = array( 'slide' );
|
143 |
+
|
144 |
+
// Make the array filterable.
|
145 |
+
$disallowed_types = apply_filters( 'woosidebars_disallowed_post_types', $disallowed_types );
|
146 |
+
|
147 |
+
if ( count( $post_types ) ) {
|
148 |
+
foreach ( $post_types as $k => $v ) {
|
149 |
+
if ( in_array( $k, $disallowed_types ) ) {
|
150 |
+
unset( $post_types[$k] );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
// Add per-post support for any post type that supports it.
|
156 |
+
|
157 |
+
$args = array(
|
158 |
+
'show_ui' => true,
|
159 |
+
'public' => true,
|
160 |
+
'publicly_queryable' => true,
|
161 |
+
'_builtin' => true
|
162 |
+
);
|
163 |
+
|
164 |
+
$built_in_post_types = get_post_types( $args, 'object' );
|
165 |
+
|
166 |
+
foreach ( $built_in_post_types as $k => $v ) {
|
167 |
+
if ( $k == 'post' ) {
|
168 |
+
$post_types[$k] = $v;
|
169 |
+
break;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
foreach ( $post_types as $k => $v ) {
|
174 |
+
if ( ! post_type_supports( $k, 'woosidebars' ) ) { continue; }
|
175 |
+
|
176 |
+
$conditions_headings[$k] = $v->labels->name;
|
177 |
+
|
178 |
+
$query_args = array( 'numberposts' => -1, 'post_type' => $k, 'meta_key' => '_enable_sidebar', 'meta_value' => 'yes', 'meta_compare' => '=' );
|
179 |
+
|
180 |
+
$posts = get_posts( $query_args );
|
181 |
+
|
182 |
+
if ( count( $posts ) > 0 ) {
|
183 |
+
foreach ( $posts as $i => $j ) {
|
184 |
+
$conditions[$k]['post' . '-' . $j->ID] = array(
|
185 |
+
'label' => $j->post_title,
|
186 |
+
'description' => sprintf( __( 'A custom sidebar for "%s"', 'woosidebars' ), esc_attr( $j->post_title ) )
|
187 |
+
);
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
// Page Templates
|
193 |
+
$conditions['templates'] = array();
|
194 |
+
|
195 |
+
$page_templates = get_page_templates();
|
196 |
+
|
197 |
+
if ( count( $page_templates ) > 0 ) {
|
198 |
+
|
199 |
+
$conditions_headings['templates'] = __( 'Page Templates', 'woosidebars' );
|
200 |
+
|
201 |
+
foreach ( $page_templates as $k => $v ) {
|
202 |
+
$token = str_replace( '.php', '', 'page-template-' . $v );
|
203 |
+
$conditions['templates'][$token] = array(
|
204 |
+
'label' => $k,
|
205 |
+
'description' => sprintf( __( 'The "%s" page template', 'woosidebars' ), $k )
|
206 |
+
);
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
// Post Type Archives
|
211 |
+
$conditions['post_types'] = array();
|
212 |
+
|
213 |
+
if ( count( $post_types ) > 0 ) {
|
214 |
+
|
215 |
+
$conditions_headings['post_types'] = __( 'Post Types', 'woosidebars' );
|
216 |
+
|
217 |
+
foreach ( $post_types as $k => $v ) {
|
218 |
+
$token = 'post-type-archive-' . $k;
|
219 |
+
|
220 |
+
if ( $v->has_archive ) {
|
221 |
+
$conditions['post_types'][$token] = array(
|
222 |
+
'label' => sprintf( __( '"%s" Post Type Archive', 'woosidebars' ), $v->labels->name ),
|
223 |
+
'description' => sprintf( __( 'The "%s" post type archive', 'woosidebars' ), $v->labels->name )
|
224 |
+
);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
foreach ( $post_types as $k => $v ) {
|
229 |
+
$token = 'post-type-' . $k;
|
230 |
+
$conditions['post_types'][$token] = array(
|
231 |
+
'label' => sprintf( __( 'Individual %s', 'woosidebars' ), $v->labels->name ),
|
232 |
+
'description' => sprintf( __( 'Entries in the "%s" post type', 'woosidebars' ), $v->labels->name )
|
233 |
+
);
|
234 |
+
}
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
// Taxonomies and Taxonomy Terms
|
239 |
+
$conditions['taxonomies'] = array();
|
240 |
+
|
241 |
+
$args = array(
|
242 |
+
'public' => true,
|
243 |
+
'show_ui' => true
|
244 |
+
);
|
245 |
+
|
246 |
+
$taxonomies = get_taxonomies( $args, 'objects' );
|
247 |
+
|
248 |
+
if ( count( $taxonomies ) > 0 ) {
|
249 |
+
|
250 |
+
$conditions_headings['taxonomies'] = __( 'Taxonomy Archives', 'woosidebars' );
|
251 |
+
|
252 |
+
foreach ( $taxonomies as $k => $v ) {
|
253 |
+
$taxonomy = $v;
|
254 |
+
|
255 |
+
if ( $taxonomy->public == true ) {
|
256 |
+
$conditions['taxonomies']['archive-' . $k] = array(
|
257 |
+
'label' => $taxonomy->labels->name . ' (' . $k . ')',
|
258 |
+
'description' => sprintf( __( 'The default "%s" archives', 'woosidebars' ), strtolower( $taxonomy->labels->name ) )
|
259 |
+
);
|
260 |
+
|
261 |
+
// Setup each individual taxonomy's terms as well.
|
262 |
+
$conditions_headings['taxonomy-' . $k] = $taxonomy->labels->name;
|
263 |
+
$terms = get_terms( $k );
|
264 |
+
if ( count( $terms ) > 0 ) {
|
265 |
+
$conditions['taxonomy-' . $k] = array();
|
266 |
+
foreach ( $terms as $i => $j ) {
|
267 |
+
$conditions['taxonomy-' . $k]['term-' . $j->term_id] = array( 'label' => $j->name, 'description' => sprintf( __( 'The %s %s archive', 'woosidebars' ), $j->name, strtolower( $taxonomy->labels->name ) ) );
|
268 |
+
if ( $k == 'category' ) {
|
269 |
+
$conditions['taxonomy-' . $k]['in-term-' . $j->term_id] = array( 'label' => sprintf( __( 'All posts in "%s"', 'woosidebars' ), $j->name ), 'description' => sprintf( __( 'All posts in the %s %s archive', 'woosidebars' ), $j->name, strtolower( $taxonomy->labels->name ) ) );
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
$conditions_headings['hierarchy'] = __( 'Template Hierarchy', 'woosidebars' );
|
279 |
+
|
280 |
+
// Template Hierarchy
|
281 |
+
$conditions['hierarchy']['page'] = array(
|
282 |
+
'label' => __( 'Pages', 'woosidebars' ),
|
283 |
+
'description' => __( 'Displayed on all pages that don\'t have a more specific widget area.', 'woosidebars' )
|
284 |
+
);
|
285 |
+
|
286 |
+
$conditions['hierarchy']['search'] = array(
|
287 |
+
'label' => __( 'Search Results', 'woosidebars' ),
|
288 |
+
'description' => __( 'Displayed on search results screens.', 'woosidebars' )
|
289 |
+
);
|
290 |
+
|
291 |
+
$conditions['hierarchy']['home'] = array(
|
292 |
+
'label' => __( 'Default "Your Latest Posts" Screen', 'woosidebars' ),
|
293 |
+
'description' => __( 'Displayed on the default "Your Latest Posts" screen.', 'woosidebars' )
|
294 |
+
);
|
295 |
+
|
296 |
+
$conditions['hierarchy']['front_page'] = array(
|
297 |
+
'label' => __( 'Front Page', 'woosidebars' ),
|
298 |
+
'description' => __( 'Displayed on any front page, regardless of the settings under the "Settings -> Reading" admin screen.', 'woosidebars' )
|
299 |
+
);
|
300 |
+
|
301 |
+
$conditions['hierarchy']['single'] = array(
|
302 |
+
'label' => __( 'Single Entries', 'woosidebars' ),
|
303 |
+
'description' => __( 'Displayed on single entries of any public post type other than "Pages".', 'woosidebars' )
|
304 |
+
);
|
305 |
+
|
306 |
+
$conditions['hierarchy']['archive'] = array(
|
307 |
+
'label' => __( 'All Archives', 'woosidebars' ),
|
308 |
+
'description' => __( 'Displayed on all archives (category, tag, taxonomy, post type, dated, author and search).', 'woosidebars' )
|
309 |
+
);
|
310 |
+
|
311 |
+
$conditions['hierarchy']['author'] = array(
|
312 |
+
'label' => __( 'Author Archives', 'woosidebars' ),
|
313 |
+
'description' => __( 'Displayed on all author archive screens (that don\'t have a more specific sidebar).', 'woosidebars' )
|
314 |
+
);
|
315 |
+
|
316 |
+
$conditions['hierarchy']['date'] = array(
|
317 |
+
'label' => __( 'Date Archives', 'woosidebars' ),
|
318 |
+
'description' => __( 'Displayed on all date archives.', 'woosidebars' )
|
319 |
+
);
|
320 |
+
|
321 |
+
$conditions['hierarchy']['404'] = array(
|
322 |
+
'label' => __( '404 Error Screens', 'woosidebars' ),
|
323 |
+
'description' => __( 'Displayed on all 404 error screens.', 'woosidebars' )
|
324 |
+
);
|
325 |
+
|
326 |
+
$this->conditions_reference = (array)apply_filters( 'woo_conditions_reference', $conditions );
|
327 |
+
$this->conditions_headings = (array)apply_filters( 'woo_conditions_headings', $conditions_headings );
|
328 |
+
} // End setup_default_conditions_reference()
|
329 |
+
|
330 |
+
/**
|
331 |
+
* is_hierarchy function.
|
332 |
+
*
|
333 |
+
* @description Is the current view a part of the default template heirarchy?
|
334 |
+
* @access public
|
335 |
+
* @return void
|
336 |
+
*/
|
337 |
+
function is_hierarchy () {
|
338 |
+
if ( is_front_page() && ! is_home() ) {
|
339 |
+
$this->conditions[] = 'static_front_page';
|
340 |
+
}
|
341 |
+
|
342 |
+
if ( ! is_front_page() && is_home() ) {
|
343 |
+
$this->conditions[] = 'inner_posts_page';
|
344 |
+
}
|
345 |
+
|
346 |
+
if ( is_front_page() ) {
|
347 |
+
$this->conditions[] = 'front_page';
|
348 |
+
}
|
349 |
+
|
350 |
+
if ( is_home() ) {
|
351 |
+
$this->conditions[] = 'home';
|
352 |
+
}
|
353 |
+
|
354 |
+
if ( is_singular() ) {
|
355 |
+
$this->conditions[] = 'singular';
|
356 |
+
$this->conditions[] = 'post-type-' . get_post_type();
|
357 |
+
|
358 |
+
$categories = get_the_category( get_the_ID() );
|
359 |
+
|
360 |
+
if ( ! is_wp_error( $categories ) && ( count( $categories ) > 0 ) ) {
|
361 |
+
foreach ( $categories as $k => $v ) {
|
362 |
+
$this->conditions[] = 'in-term-' . $v->term_id;
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
$this->conditions[] = 'post' . '-' . get_the_ID();
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( is_search() ) {
|
370 |
+
$this->conditions[] = 'search';
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( is_home() ) {
|
374 |
+
$this->conditions[] = 'home';
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( is_front_page() ) {
|
378 |
+
$this->conditions[] = 'front_page';
|
379 |
+
}
|
380 |
+
|
381 |
+
if ( is_archive() ) {
|
382 |
+
$this->conditions[] = 'archive';
|
383 |
+
}
|
384 |
+
|
385 |
+
if ( is_author() ) {
|
386 |
+
$this->conditions[] = 'author';
|
387 |
+
}
|
388 |
+
|
389 |
+
if ( is_date() ) {
|
390 |
+
$this->conditions[] = 'date';
|
391 |
+
}
|
392 |
+
|
393 |
+
if ( is_404() ) {
|
394 |
+
$this->conditions[] = '404';
|
395 |
+
}
|
396 |
+
} // End is_hierarchy()
|
397 |
+
|
398 |
+
/**
|
399 |
+
* is_taxonomy function.
|
400 |
+
*
|
401 |
+
* @description Is the current view an archive within a specific taxonomy, that doesn't have a specific sidebar?
|
402 |
+
* @access public
|
403 |
+
* @return void
|
404 |
+
*/
|
405 |
+
public function is_taxonomy () {
|
406 |
+
if ( ( is_tax() || is_archive() ) && ! is_post_type_archive() ) {
|
407 |
+
$obj = get_queried_object();
|
408 |
+
|
409 |
+
if ( ! is_category() && ! is_tag() ) {
|
410 |
+
$this->conditions[] = 'taxonomies';
|
411 |
+
}
|
412 |
+
$this->conditions[] = 'archive-' . $obj->taxonomy;
|
413 |
+
$this->conditions[] = 'term-' . $obj->term_id;
|
414 |
+
}
|
415 |
+
} // End is_taxonomy()
|
416 |
+
|
417 |
+
/**
|
418 |
+
* is_post_type_archive function.
|
419 |
+
*
|
420 |
+
* @description Is the current view an archive of a post type?
|
421 |
+
* @access public
|
422 |
+
* @return void
|
423 |
+
*/
|
424 |
+
public function is_post_type_archive () {
|
425 |
+
if ( is_post_type_archive() ) {
|
426 |
+
$this->conditions[] = 'post-type-archive-' . get_post_type();
|
427 |
+
}
|
428 |
+
} // End is_post_type_archive()
|
429 |
+
|
430 |
+
/**
|
431 |
+
* is_page_template function.
|
432 |
+
*
|
433 |
+
* @description Does the current view have a specific page template attached (used on single views)?
|
434 |
+
* @access public
|
435 |
+
* @return void
|
436 |
+
*/
|
437 |
+
public function is_page_template () {
|
438 |
+
if ( is_singular() ) {
|
439 |
+
global $post;
|
440 |
+
$template = get_post_meta( $post->ID, '_wp_page_template', true );
|
441 |
+
|
442 |
+
if ( $template != '' && $template != 'default' ) {
|
443 |
+
$this->conditions[] = str_replace( '.php', '', 'page-template-' . $template );
|
444 |
+
}
|
445 |
+
}
|
446 |
+
} // End is_page_template()
|
447 |
+
|
448 |
+
/**
|
449 |
+
* meta_box_setup function.
|
450 |
+
*
|
451 |
+
* @access public
|
452 |
+
* @return void
|
453 |
+
*/
|
454 |
+
public function meta_box_setup () {
|
455 |
+
add_meta_box( 'woo-conditions', $this->meta_box_settings['title'], array( &$this, 'meta_box_content' ), $this->token, 'normal', 'low' );
|
456 |
+
} // End meta_box_setup()
|
457 |
+
|
458 |
+
/**
|
459 |
+
* meta_box_content function.
|
460 |
+
*
|
461 |
+
* @access public
|
462 |
+
* @return void
|
463 |
+
*/
|
464 |
+
public function meta_box_content () {
|
465 |
+
global $post_id;
|
466 |
+
|
467 |
+
if ( count( $this->conditions_reference ) <= 0 ) $this->setup_default_conditions_reference();
|
468 |
+
|
469 |
+
$selected_conditions = get_post_meta( $post_id, '_condition', false );
|
470 |
+
|
471 |
+
if ( $selected_conditions == '' ) {
|
472 |
+
$selected_conditions = array();
|
473 |
+
}
|
474 |
+
|
475 |
+
$html = '';
|
476 |
+
|
477 |
+
$html .= '<input type="hidden" name="woo_' . $this->token . '_conditions_noonce" id="woo_' . $this->token . '_noonce" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
|
478 |
+
|
479 |
+
if ( count( $this->conditions_reference ) > 0 ) {
|
480 |
+
|
481 |
+
// Separate out the taxonomy items for use as sub-tabs of "Taxonomy Terms".
|
482 |
+
$taxonomy_terms = array();
|
483 |
+
|
484 |
+
foreach ( $this->conditions_reference as $k => $v ) {
|
485 |
+
if ( substr( $k, 0, 9 ) == 'taxonomy-' ) {
|
486 |
+
$taxonomy_terms[$k] = $v;
|
487 |
+
unset( $this->conditions_reference[$k] );
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
$html .= '<div id="taxonomy-category" class="categorydiv tabs woo-conditions">' . "\n";
|
492 |
+
|
493 |
+
$html .= '<ul id="category-tabs" class="conditions-tabs">' . "\n";
|
494 |
+
|
495 |
+
$count = 0;
|
496 |
+
|
497 |
+
// Determine whether or not to show advanced items, based on user's preference (default: false).
|
498 |
+
$show_advanced = $this->show_advanced_items();
|
499 |
+
|
500 |
+
foreach ( $this->conditions_reference as $k => $v ) {
|
501 |
+
$count++;
|
502 |
+
$class = '';
|
503 |
+
if ( $count == 1 ) {
|
504 |
+
$class = 'tabs';
|
505 |
+
} else {
|
506 |
+
$class = 'hide-if-no-js';
|
507 |
+
}
|
508 |
+
if ( in_array( $k, array( 'pages' ) ) ) {
|
509 |
+
$class .= ' basic';
|
510 |
+
} else {
|
511 |
+
$class .= ' advanced';
|
512 |
+
if ( ! $show_advanced ) { $class .= ' hide'; }
|
513 |
+
}
|
514 |
+
|
515 |
+
if ( isset( $this->conditions_headings[$k] ) ) {
|
516 |
+
$html .= '<li class="' . esc_attr( $class ) . '"><a href="#tab-' . $k . '">' . $this->conditions_headings[$k] . '</a></li>' . "\n";
|
517 |
+
}
|
518 |
+
|
519 |
+
if ( $k == 'taxonomies' ) {
|
520 |
+
$html .= '<li class="' . $class . '"><a href="#tab-taxonomy-terms">' . __( 'Taxonomy Terms', 'woosidebars' ) . '</a></li>' . "\n";
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
$class = 'hide-if-no-js advanced';
|
525 |
+
if ( ! $show_advanced ) { $class .= ' hide'; }
|
526 |
+
|
527 |
+
$html .= '<li class="advanced-settings alignright hide-if-no-js"><a href="#">' . __( 'Advanced', 'woosidebars' ) . '</a></li>' . "\n";
|
528 |
+
|
529 |
+
$html .= '</ul>' . "\n";
|
530 |
+
|
531 |
+
foreach ( $this->conditions_reference as $k => $v ) {
|
532 |
+
$count = 0;
|
533 |
+
|
534 |
+
$tab = '';
|
535 |
+
|
536 |
+
$tab .= '<div id="tab-' . $k . '" class="condition-tab">' . "\n";
|
537 |
+
$tab .= '<h4>' . $this->conditions_headings[$k] . '</h4>' . "\n";
|
538 |
+
$tab .= '<ul class="alignleft conditions-column">' . "\n";
|
539 |
+
foreach ( $v as $i => $j ) {
|
540 |
+
$count++;
|
541 |
+
|
542 |
+
$checked = '';
|
543 |
+
if ( in_array( $i, $selected_conditions ) ) {
|
544 |
+
$checked = ' checked="checked"';
|
545 |
+
}
|
546 |
+
$tab .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '"><input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . $i . '"' . $checked . ' /> ' . $j['label'] . '</label></li>' . "\n";
|
547 |
+
|
548 |
+
if ( $count % 10 == 0 && $count < ( count( $v ) ) ) {
|
549 |
+
$tab .= '</ul><ul class="alignleft conditions-column">';
|
550 |
+
}
|
551 |
+
}
|
552 |
+
|
553 |
+
$tab .= '</ul>' . "\n";
|
554 |
+
// Filter the contents of the current tab.
|
555 |
+
$tab = apply_filters( 'woo_conditions_tab_' . esc_attr( $k ), $tab );
|
556 |
+
$html .= $tab;
|
557 |
+
$html .= '<div class="clear"></div>';
|
558 |
+
$html .= '</div>' . "\n";
|
559 |
+
}
|
560 |
+
|
561 |
+
// Taxonomy Terms Tab
|
562 |
+
$html .= '<div id="tab-taxonomy-terms" class="condition-tab inner-tabs">' . "\n";
|
563 |
+
$html .= '<ul class="conditions-tabs-inner hide-if-no-js">' . "\n";
|
564 |
+
|
565 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
566 |
+
if ( ! isset( $this->conditions_headings[$k] ) ) { unset( $taxonomy_terms[$k] ); }
|
567 |
+
}
|
568 |
+
|
569 |
+
$count = 0;
|
570 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
571 |
+
$count++;
|
572 |
+
$class = '';
|
573 |
+
if ( $count == 1 ) {
|
574 |
+
$class = 'tabs';
|
575 |
+
} else {
|
576 |
+
$class = 'hide-if-no-js';
|
577 |
+
}
|
578 |
+
|
579 |
+
$html .= '<li><a href="#tab-' . $k . '" title="' . __( 'Taxonomy Token', 'woosidebars' ) . ': ' . str_replace( 'taxonomy-', '', $k ) . '">' . $this->conditions_headings[$k] . '</a>';
|
580 |
+
if ( $count != count( $taxonomy_terms ) ) {
|
581 |
+
$html .= ' |';
|
582 |
+
}
|
583 |
+
$html .= '</li>' . "\n";
|
584 |
+
}
|
585 |
+
|
586 |
+
$html .= '</ul>' . "\n";
|
587 |
+
|
588 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
589 |
+
$count = 0;
|
590 |
+
|
591 |
+
$html .= '<div id="tab-' . $k . '" class="condition-tab">' . "\n";
|
592 |
+
$html .= '<h4>' . $this->conditions_headings[$k] . '</h4>' . "\n";
|
593 |
+
$html .= '<ul class="alignleft conditions-column">' . "\n";
|
594 |
+
foreach ( $v as $i => $j ) {
|
595 |
+
$count++;
|
596 |
+
|
597 |
+
$checked = '';
|
598 |
+
if ( in_array( $i, $selected_conditions ) ) {
|
599 |
+
$checked = ' checked="checked"';
|
600 |
+
}
|
601 |
+
$html .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '"><input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . $i . '"' . $checked . ' /> ' . $j['label'] . '</label></li>' . "\n";
|
602 |
+
|
603 |
+
if ( $count % 10 == 0 && $count < ( count( $v ) ) ) {
|
604 |
+
$html .= '</ul><ul class="alignleft conditions-column">';
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
$html .= '</ul>' . "\n";
|
609 |
+
$html .= '<div class="clear"></div>';
|
610 |
+
$html .= '</div>' . "\n";
|
611 |
+
}
|
612 |
+
$html .= '</div>' . "\n";
|
613 |
+
}
|
614 |
+
|
615 |
+
// Allow themes/plugins to act here (key, args).
|
616 |
+
do_action( 'woo_conditions_meta_box', $k, $v );
|
617 |
+
|
618 |
+
$html .= '<br class="clear" />' . "\n";
|
619 |
+
|
620 |
+
echo $html;
|
621 |
+
} // End meta_box_content()
|
622 |
+
|
623 |
+
/**
|
624 |
+
* meta_box_save function.
|
625 |
+
*
|
626 |
+
* @access public
|
627 |
+
* @param mixed $post_id
|
628 |
+
* @return void
|
629 |
+
*/
|
630 |
+
public function meta_box_save ( $post_id ) {
|
631 |
+
global $post, $messages;
|
632 |
+
|
633 |
+
// Verify
|
634 |
+
if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_conditions_noonce'], plugin_basename(__FILE__) ) ) {
|
635 |
+
return $post_id;
|
636 |
+
}
|
637 |
+
|
638 |
+
if ( 'page' == $_POST['post_type'] ) {
|
639 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
640 |
+
return $post_id;
|
641 |
+
}
|
642 |
+
} else {
|
643 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
644 |
+
return $post_id;
|
645 |
+
}
|
646 |
+
}
|
647 |
+
|
648 |
+
if ( isset( $_POST['conditions'] ) && ( count( $_POST['conditions'] ) > 0 ) ) {
|
649 |
+
|
650 |
+
delete_post_meta( $post_id, '_condition' );
|
651 |
+
|
652 |
+
foreach ( $_POST['conditions'] as $k => $v ) {
|
653 |
+
add_post_meta( $post_id, '_condition', $v, false );
|
654 |
+
}
|
655 |
+
}
|
656 |
+
} // End meta_box_save()
|
657 |
+
|
658 |
+
/**
|
659 |
+
* show_advanced_itesm function.
|
660 |
+
*
|
661 |
+
* @access private
|
662 |
+
* @return boolean
|
663 |
+
*/
|
664 |
+
private function show_advanced_items () {
|
665 |
+
$response = false;
|
666 |
+
|
667 |
+
$setting = get_user_setting( 'woosidebarsshowadvanced', '0' );
|
668 |
+
|
669 |
+
if ( $setting == '1' ) { $response = true; }
|
670 |
+
|
671 |
+
return $response;
|
672 |
+
} // End show_advanced_items()
|
673 |
+
|
674 |
+
/**
|
675 |
+
* ajax_toggle_advanced_items function.
|
676 |
+
*
|
677 |
+
* @access public
|
678 |
+
* @return void
|
679 |
+
*/
|
680 |
+
public function ajax_toggle_advanced_items () {
|
681 |
+
$nonce = $_POST['woosidebars_advanced_noonce'];
|
682 |
+
$status = $_POST['new_status'];
|
683 |
+
//Add nonce security to the request
|
684 |
+
if ( ! wp_verify_nonce( $nonce, 'woosidebars_advanced_noonce' ) ) {
|
685 |
+
die();
|
686 |
+
}
|
687 |
+
|
688 |
+
$response = set_user_setting( 'woosidebarsshowadvanced', $status );
|
689 |
+
|
690 |
+
echo $response;
|
691 |
+
die(); // WordPress may print out a spurious zero without this can be particularly bad if using JSON
|
692 |
+
} // End ajax_toggle_advanced_items()
|
693 |
+
|
694 |
+
/**
|
695 |
+
* enqueue_scripts function.
|
696 |
+
*
|
697 |
+
* @access public
|
698 |
+
* @return void
|
699 |
+
*/
|
700 |
+
public function enqueue_scripts () {
|
701 |
+
global $pagenow;
|
702 |
+
if ( get_post_type() != $this->token ) { return; }
|
703 |
+
|
704 |
+
if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
|
705 |
+
wp_register_script( $this->token . '-admin', $this->assets_url . '/js/admin.js', array( 'jquery', 'jquery-ui-tabs' ), '1.0.0', true );
|
706 |
+
|
707 |
+
wp_enqueue_script( $this->token . '-admin' );
|
708 |
+
|
709 |
+
wp_dequeue_script( 'jquery-ui-datepicker' );
|
710 |
+
|
711 |
+
$translation_strings = array();
|
712 |
+
|
713 |
+
$ajax_vars = array( 'woosidebars_advanced_noonce' => wp_create_nonce( 'woosidebars_advanced_noonce' ) );
|
714 |
+
|
715 |
+
$data = array_merge( $translation_strings, $ajax_vars );
|
716 |
+
|
717 |
+
wp_localize_script( $this->token . '-admin', 'woosidebars_localized_data', $data );
|
718 |
+
}
|
719 |
+
} // End enqueue_scripts()
|
720 |
+
} // End Class
|
721 |
+
?>
|
classes/class-woo-sidebars.php
ADDED
@@ -0,0 +1,798 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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**
|
5 |
+
* WooSidebars Base Class
|
6 |
+
*
|
7 |
+
* All functionality pertaining to core functionality of the WooSidebars plugin.
|
8 |
+
*
|
9 |
+
* @package WordPress
|
10 |
+
* @subpackage WooSidebars
|
11 |
+
* @author WooThemes
|
12 |
+
* @since 1.0.0
|
13 |
+
*
|
14 |
+
* TABLE OF CONTENTS
|
15 |
+
*
|
16 |
+
* public $version
|
17 |
+
* private $file
|
18 |
+
*
|
19 |
+
* private $token
|
20 |
+
* private $prefix
|
21 |
+
* public $conditions
|
22 |
+
*
|
23 |
+
* private $plugin_url
|
24 |
+
* private $assets_url
|
25 |
+
*
|
26 |
+
* - __construct()
|
27 |
+
* - init()
|
28 |
+
* - register_post_type_columns()
|
29 |
+
* - register_post_type()
|
30 |
+
* - register_custom_columns()
|
31 |
+
* - register_custom_column_headings()
|
32 |
+
* - meta_box_setup()
|
33 |
+
* - meta_box_content()
|
34 |
+
* - meta_box_save()
|
35 |
+
* - description_meta_box()
|
36 |
+
* - enter_title_here()
|
37 |
+
* - update_messages()
|
38 |
+
* - get_registered_sidebars()
|
39 |
+
* - register_custom_sidebars()
|
40 |
+
* - init_sidebar_replacement()
|
41 |
+
* - replace_sidebars()
|
42 |
+
* - find_best_sidebars()
|
43 |
+
* - enqueue_styles()
|
44 |
+
* - add_post_column_headings()
|
45 |
+
* - add_post_column_data()
|
46 |
+
* - enable_custom_post_sidebars()
|
47 |
+
* - multidimensional_search()
|
48 |
+
* - add_contextual_help()
|
49 |
+
*
|
50 |
+
* - load_localisation()
|
51 |
+
* - activation()
|
52 |
+
* - register_plugin_version()
|
53 |
+
*/
|
54 |
+
class Woo_Sidebars {
|
55 |
+
public $version;
|
56 |
+
private $file;
|
57 |
+
|
58 |
+
private $token;
|
59 |
+
private $prefix;
|
60 |
+
public $conditions;
|
61 |
+
|
62 |
+
private $plugin_url;
|
63 |
+
private $assets_url;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* __construct function.
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @return void
|
70 |
+
*/
|
71 |
+
public function __construct ( $file ) {
|
72 |
+
$this->version = '';
|
73 |
+
$this->file = $file;
|
74 |
+
|
75 |
+
$this->token = 'sidebar';
|
76 |
+
$this->prefix = 'woo_sidebar_';
|
77 |
+
|
78 |
+
/* Plugin URL/path settings. */
|
79 |
+
$this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
|
80 |
+
$this->assets_url = $this->plugin_url . '/assets';
|
81 |
+
|
82 |
+
$this->conditions = new Woo_Conditions();
|
83 |
+
$this->conditions->token = $this->token;
|
84 |
+
} // End __construct()
|
85 |
+
|
86 |
+
/**
|
87 |
+
* init function.
|
88 |
+
*
|
89 |
+
* @access public
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function init () {
|
93 |
+
add_action( 'init', array( &$this, 'load_localisation' ) );
|
94 |
+
|
95 |
+
add_action( 'init', array( &$this, 'register_post_type' ), 20 );
|
96 |
+
add_action( 'admin_menu', array( &$this, 'meta_box_setup' ), 20 );
|
97 |
+
add_action( 'save_post', array( &$this, 'meta_box_save' ) );
|
98 |
+
add_filter( 'enter_title_here', array( &$this, 'enter_title_here' ) );
|
99 |
+
add_filter( 'post_updated_messages', array( &$this, 'update_messages' ) );
|
100 |
+
add_action( 'widgets_init', array( &$this, 'register_custom_sidebars' ) );
|
101 |
+
add_action( 'get_header', array( &$this, 'init_sidebar_replacement' ) );
|
102 |
+
|
103 |
+
if ( is_admin() ) {
|
104 |
+
global $pagenow;
|
105 |
+
|
106 |
+
add_action( 'admin_print_styles', array( &$this, 'enqueue_styles' ), 12 );
|
107 |
+
add_action( 'admin_head', array( $this, 'add_contextual_help' ) );
|
108 |
+
if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && esc_attr( $_GET['post_type'] ) == $this->token ) {
|
109 |
+
add_filter( 'manage_edit-' . $this->token . '_columns', array( &$this, 'register_custom_column_headings' ), 10, 1 );
|
110 |
+
add_action( 'manage_posts_custom_column', array( &$this, 'register_custom_columns' ), 10, 2 );
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
// By default, add post type support for sidebars to the "post" post type.
|
115 |
+
add_post_type_support( 'post', 'woosidebars' );
|
116 |
+
|
117 |
+
add_action( 'admin_head', array( &$this, 'register_post_type_columns' ) );
|
118 |
+
|
119 |
+
add_action( 'wp_ajax_woosidebars-post-enable', array( &$this, 'enable_custom_post_sidebars' ) );
|
120 |
+
|
121 |
+
// Run this on activation.
|
122 |
+
register_activation_hook( $this->file, array( &$this, 'activation' ) );
|
123 |
+
} // End init()
|
124 |
+
|
125 |
+
/**
|
126 |
+
* register_post_type_columns function.
|
127 |
+
*
|
128 |
+
* @access public
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
public function register_post_type_columns () {
|
132 |
+
$post_type = get_post_type();
|
133 |
+
|
134 |
+
if ( $post_type != '' && post_type_supports( $post_type, 'woosidebars' ) ) {
|
135 |
+
add_filter( 'manage_edit-' . $post_type . '_columns', array( &$this, 'add_post_column_headings' ), 10, 1 );
|
136 |
+
add_action( 'manage_posts_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
|
137 |
+
add_action( 'manage_pages_custom_column', array( &$this, 'add_post_column_data' ), 10, 2 );
|
138 |
+
}
|
139 |
+
} // End register_post_type_columns()
|
140 |
+
|
141 |
+
/**
|
142 |
+
* register_post_type function.
|
143 |
+
*
|
144 |
+
* @access public
|
145 |
+
* @return void
|
146 |
+
*/
|
147 |
+
public function register_post_type () {
|
148 |
+
$page = 'themes.php';
|
149 |
+
|
150 |
+
$singular = __( 'Widget Area', 'woosidebars' );
|
151 |
+
$plural = __( 'Widget Areas', 'woosidebars' );
|
152 |
+
$rewrite = array( 'slug' => 'sidebars' );
|
153 |
+
$supports = array( 'title', 'excerpt' );
|
154 |
+
|
155 |
+
if ( $rewrite == '' ) { $rewrite = $this->token; }
|
156 |
+
|
157 |
+
$labels = array(
|
158 |
+
'name' => _x( 'Widget Areas', 'post type general name', 'woosidebars' ),
|
159 |
+
'singular_name' => _x( 'Widget Area', 'post type singular name', 'woosidebars' ),
|
160 |
+
'add_new' => _x( 'Add New', 'Widget Area' ),
|
161 |
+
'add_new_item' => sprintf( __( 'Add New %s', 'woosidebars' ), $singular ),
|
162 |
+
'edit_item' => sprintf( __( 'Edit %s', 'woosidebars' ), $singular ),
|
163 |
+
'new_item' => sprintf( __( 'New %s', 'woosidebars' ), $singular ),
|
164 |
+
'all_items' => sprintf( __( 'Widget Areas', 'woosidebars' ), $plural ),
|
165 |
+
'view_item' => sprintf( __( 'View %s', 'woosidebars' ), $singular ),
|
166 |
+
'search_items' => sprintf( __( 'Search %a', 'woosidebars' ), $plural ),
|
167 |
+
'not_found' => sprintf( __( 'No %s Found', 'woosidebars' ), $plural ),
|
168 |
+
'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'woosidebars' ), $plural ),
|
169 |
+
'parent_item_colon' => '',
|
170 |
+
'menu_name' => $plural
|
171 |
+
|
172 |
+
);
|
173 |
+
$args = array(
|
174 |
+
'labels' => $labels,
|
175 |
+
'public' => false,
|
176 |
+
'publicly_queryable' => true,
|
177 |
+
'show_ui' => true,
|
178 |
+
'show_in_nav_menus' => false,
|
179 |
+
'show_in_admin_bar' => false,
|
180 |
+
'show_in_menu' => $page,
|
181 |
+
'query_var' => true,
|
182 |
+
'rewrite' => $rewrite,
|
183 |
+
'capability_type' => 'post',
|
184 |
+
'has_archive' => $rewrite,
|
185 |
+
'hierarchical' => false,
|
186 |
+
'menu_position' => null,
|
187 |
+
'supports' => $supports
|
188 |
+
);
|
189 |
+
register_post_type( $this->token, $args );
|
190 |
+
} // End register_post_type()
|
191 |
+
|
192 |
+
/**
|
193 |
+
* register_custom_columns function.
|
194 |
+
*
|
195 |
+
* @access public
|
196 |
+
* @param string $column_name
|
197 |
+
* @param int $id
|
198 |
+
* @return void
|
199 |
+
*/
|
200 |
+
public function register_custom_columns ( $column_name, $id ) {
|
201 |
+
global $wpdb, $post;
|
202 |
+
|
203 |
+
$meta = get_post_custom( $id );
|
204 |
+
$sidebars = $this->get_registered_sidebars();
|
205 |
+
|
206 |
+
$this->conditions->setup_default_conditions_reference();
|
207 |
+
|
208 |
+
switch ( $column_name ) {
|
209 |
+
|
210 |
+
case 'sidebar_to_replace':
|
211 |
+
$value = '';
|
212 |
+
|
213 |
+
if ( isset( $meta['_sidebar_to_replace'] ) && ( $meta['_sidebar_to_replace'][0] != '' ) ) {
|
214 |
+
$value = $meta['_sidebar_to_replace'][0];
|
215 |
+
|
216 |
+
if ( isset( $sidebars[$value] ) ) {
|
217 |
+
$value = $sidebars[$value]['name'];
|
218 |
+
} else {
|
219 |
+
$value .= '<br /><strong>' . __( '(Not in use by current theme)', 'woosidebars' ) . '</strong>';
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
echo $value;
|
224 |
+
break;
|
225 |
+
|
226 |
+
case 'condition':
|
227 |
+
$value = '';
|
228 |
+
|
229 |
+
if ( isset( $meta['_condition'] ) && ( $meta['_condition'][0] != '' ) ) {
|
230 |
+
foreach ( $meta['_condition'] as $k => $v ) {
|
231 |
+
$value .= $this->multidimensional_search( $v, $this->conditions->conditions_reference ) . '<br />' . "\n";
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
echo $value;
|
236 |
+
break;
|
237 |
+
|
238 |
+
default:
|
239 |
+
break;
|
240 |
+
|
241 |
+
}
|
242 |
+
} // End register_custom_columns()
|
243 |
+
|
244 |
+
/**
|
245 |
+
* register_custom_column_headings function.
|
246 |
+
*
|
247 |
+
* @access public
|
248 |
+
* @param array $defaults
|
249 |
+
* @return void
|
250 |
+
*/
|
251 |
+
public function register_custom_column_headings ( $defaults ) {
|
252 |
+
$this->conditions->setup_default_conditions_reference();
|
253 |
+
|
254 |
+
$new_columns = array( 'sidebar_to_replace' => __( 'Sidebar To Replace', 'woosidebars' ), 'condition' => __( 'Condition(s)', 'woosidebars' ) );
|
255 |
+
|
256 |
+
$last_item = '';
|
257 |
+
|
258 |
+
if ( isset( $defaults['date'] ) ) { unset( $defaults['date'] ); }
|
259 |
+
|
260 |
+
if ( count( $defaults ) > 2 ) {
|
261 |
+
$last_item = array_slice( $defaults, -1 );
|
262 |
+
|
263 |
+
array_pop( $defaults );
|
264 |
+
}
|
265 |
+
$defaults = array_merge( $defaults, $new_columns );
|
266 |
+
|
267 |
+
if ( $last_item != '' ) {
|
268 |
+
foreach ( $last_item as $k => $v ) {
|
269 |
+
$defaults[$k] = $v;
|
270 |
+
break;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
return $defaults;
|
275 |
+
} // End register_custom_column_headings()
|
276 |
+
|
277 |
+
/**
|
278 |
+
* meta_box_setup function.
|
279 |
+
*
|
280 |
+
* @access public
|
281 |
+
* @return void
|
282 |
+
*/
|
283 |
+
public function meta_box_setup () {
|
284 |
+
add_meta_box( 'sidebar-to-replace', __( 'Sidebar To Replace', 'woosidebars' ), array( &$this, 'meta_box_content' ), $this->token, 'side', 'low' );
|
285 |
+
|
286 |
+
// Remove "Custom Settings" meta box.
|
287 |
+
remove_meta_box( 'woothemes-settings', 'sidebar', 'normal' );
|
288 |
+
|
289 |
+
// Customise the "Excerpt" meta box for the sidebars.
|
290 |
+
remove_meta_box( 'postexcerpt', $this->token, 'normal' );
|
291 |
+
add_meta_box( 'sidebar-description', __( 'Description', 'woosidebars' ), array( &$this, 'description_meta_box' ), $this->token, 'normal', 'core' );
|
292 |
+
} // End meta_box_setup()
|
293 |
+
|
294 |
+
/**
|
295 |
+
* meta_box_content function.
|
296 |
+
*
|
297 |
+
* @access public
|
298 |
+
* @return void
|
299 |
+
*/
|
300 |
+
public function meta_box_content () {
|
301 |
+
global $post_id;
|
302 |
+
|
303 |
+
$sidebars = $this->get_registered_sidebars();
|
304 |
+
|
305 |
+
$selected_sidebar = get_post_meta( $post_id, '_sidebar_to_replace', true );
|
306 |
+
|
307 |
+
$html = '';
|
308 |
+
|
309 |
+
$html .= '<input type="hidden" name="woo_' . $this->token . '_noonce" id="woo_' . $this->token . '_noonce" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
|
310 |
+
|
311 |
+
if ( count( $sidebars ) > 0 ) {
|
312 |
+
$html .= '<select name="sidebar_to_replace" class="widefat">' . "\n";
|
313 |
+
foreach ( $sidebars as $k => $v ) {
|
314 |
+
$html .= '<option value="' . $v['id'] . '"' . selected( $selected_sidebar, $v['id'], false ) . '>' . $v['name'] . '</option>' . "\n";
|
315 |
+
}
|
316 |
+
$html .= '</select>' . "\n";
|
317 |
+
} else {
|
318 |
+
$html .= '<p>' . __( 'No sidebars are available with this theme.', 'woosidebars' ) . '</p>';
|
319 |
+
}
|
320 |
+
|
321 |
+
echo $html;
|
322 |
+
|
323 |
+
} // End meta_box_content()
|
324 |
+
|
325 |
+
/**
|
326 |
+
* meta_box_save function.
|
327 |
+
*
|
328 |
+
* @access public
|
329 |
+
* @param int $post_id
|
330 |
+
* @return void
|
331 |
+
*/
|
332 |
+
public function meta_box_save ( $post_id ) {
|
333 |
+
global $post, $messages;
|
334 |
+
|
335 |
+
// Verify
|
336 |
+
if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) {
|
337 |
+
return $post_id;
|
338 |
+
}
|
339 |
+
|
340 |
+
if ( 'page' == $_POST['post_type'] ) {
|
341 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
342 |
+
return $post_id;
|
343 |
+
}
|
344 |
+
} else {
|
345 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
346 |
+
return $post_id;
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
$fields = array( 'sidebar_to_replace' );
|
351 |
+
|
352 |
+
foreach ( $fields as $f ) {
|
353 |
+
|
354 |
+
${$f} = strip_tags(trim($_POST[$f]));
|
355 |
+
|
356 |
+
if ( get_post_meta( $post_id, '_' . $f ) == '' ) {
|
357 |
+
add_post_meta( $post_id, '_' . $f, ${$f}, true );
|
358 |
+
} elseif( ${$f} != get_post_meta( $post_id, '_' . $f, true ) ) {
|
359 |
+
update_post_meta( $post_id, '_' . $f, ${$f} );
|
360 |
+
} elseif ( ${$f} == '' ) {
|
361 |
+
delete_post_meta( $post_id, '_' . $f, get_post_meta( $post_id, '_' . $f, true ) );
|
362 |
+
}
|
363 |
+
}
|
364 |
+
} // End meta_box_save()
|
365 |
+
|
366 |
+
/**
|
367 |
+
* description_meta_box function.
|
368 |
+
*
|
369 |
+
* @param object $post
|
370 |
+
*/
|
371 |
+
public function description_meta_box ( $post ) {
|
372 |
+
?>
|
373 |
+
<label class="screen-reader-text" for="excerpt"><?php _e( 'Description', 'woosidebars' ); ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
|
374 |
+
<p><?php printf( __( 'Add an optional description, to be displayed when adding widgets to this widget area on the %sWidgets%s screen.', 'woosidebars' ), '<a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">', '</a>' ); ?></p>
|
375 |
+
<?php
|
376 |
+
} // End description_meta_box()
|
377 |
+
|
378 |
+
/**
|
379 |
+
* enter_title_here function.
|
380 |
+
*
|
381 |
+
* @access public
|
382 |
+
* @param string $title
|
383 |
+
* @return void
|
384 |
+
*/
|
385 |
+
public function enter_title_here ( $title ) {
|
386 |
+
if ( get_post_type() == $this->token ) {
|
387 |
+
$title = __( 'Enter widget area name here', 'woosidebars' );
|
388 |
+
}
|
389 |
+
return $title;
|
390 |
+
} // End enter_title_here()
|
391 |
+
|
392 |
+
/**
|
393 |
+
* update_messages function.
|
394 |
+
*
|
395 |
+
* @access public
|
396 |
+
* @param array $messages
|
397 |
+
* @return void
|
398 |
+
*/
|
399 |
+
public function update_messages ( $messages ) {
|
400 |
+
if ( get_post_type() != $this->token ) {
|
401 |
+
return $messages;
|
402 |
+
}
|
403 |
+
|
404 |
+
$messages[$this->token][1] = __( 'Widget Area updated.', 'woosidebars' );
|
405 |
+
|
406 |
+
return $messages;
|
407 |
+
} // End update_messages()
|
408 |
+
|
409 |
+
/**
|
410 |
+
* get_registered_sidebars function.
|
411 |
+
*
|
412 |
+
* @access public
|
413 |
+
* @return void
|
414 |
+
*/
|
415 |
+
public function get_registered_sidebars () {
|
416 |
+
global $wp_registered_sidebars;
|
417 |
+
|
418 |
+
$sidebars = array();
|
419 |
+
$to_ignore = array();
|
420 |
+
|
421 |
+
$custom_sidebars = get_posts( 'post_type=sidebar&numberposts=-1' );
|
422 |
+
if ( ! is_wp_error( $custom_sidebars ) && count( $custom_sidebars ) > 0 ) {
|
423 |
+
foreach ( $custom_sidebars as $k => $v ) {
|
424 |
+
$to_ignore[] = $v->post_name;
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( is_array( $wp_registered_sidebars ) && ( count( $wp_registered_sidebars ) > 0 ) ) {
|
429 |
+
foreach ( $wp_registered_sidebars as $k => $v ) {
|
430 |
+
if ( ! stristr( $v['id'], $this->prefix ) && ! stristr( $v['id'], 'woo_sbm_' ) && ! in_array( $v['id'], $to_ignore ) ) {
|
431 |
+
$sidebars[$k] = $v;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
return $sidebars;
|
437 |
+
} // End get_registered_sidebars()
|
438 |
+
|
439 |
+
/**
|
440 |
+
* register_custom_sidebars function.
|
441 |
+
*
|
442 |
+
* @access public
|
443 |
+
* @return void
|
444 |
+
*/
|
445 |
+
public function register_custom_sidebars () {
|
446 |
+
$sidebars = get_posts( array( 'post_type' => 'sidebar', 'posts_per_page' => -1 ) );
|
447 |
+
|
448 |
+
if ( count( $sidebars ) > 0 ) {
|
449 |
+
foreach ( $sidebars as $k => $v ) {
|
450 |
+
$sidebar_id = $v->post_name;
|
451 |
+
// $sidebar_id = $this->prefix . $v->ID;
|
452 |
+
register_sidebar( array( 'name' => $v->post_title, 'id' => $sidebar_id, 'description' => $v->post_excerpt ) );
|
453 |
+
}
|
454 |
+
}
|
455 |
+
} // End register_custom_sidebars()
|
456 |
+
|
457 |
+
/**
|
458 |
+
* init_sidebar_replacement function.
|
459 |
+
*
|
460 |
+
* @access public
|
461 |
+
* @return void
|
462 |
+
*/
|
463 |
+
public function init_sidebar_replacement () {
|
464 |
+
add_filter( 'sidebars_widgets', array( &$this, 'replace_sidebars' ) );
|
465 |
+
} // End init_sidebar_replacement()
|
466 |
+
|
467 |
+
/**
|
468 |
+
* replace_sidebars function.
|
469 |
+
*
|
470 |
+
* @access public
|
471 |
+
* @param array $sidebars_widgets
|
472 |
+
* @return void
|
473 |
+
*/
|
474 |
+
public function replace_sidebars ( $sidebars_widgets ) {
|
475 |
+
if ( is_admin() ) {
|
476 |
+
return $sidebars_widgets;
|
477 |
+
}
|
478 |
+
|
479 |
+
// Determine the conditions to construct the query.
|
480 |
+
$conditions = $this->conditions->conditions;
|
481 |
+
|
482 |
+
if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
|
483 |
+
return $sidebars_widgets;
|
484 |
+
}
|
485 |
+
|
486 |
+
global $woo_custom_sidebar_data;
|
487 |
+
|
488 |
+
if ( ! isset( $woo_custom_sidebar_data ) ) {
|
489 |
+
|
490 |
+
$conditions_str = join( ', ', $conditions );
|
491 |
+
|
492 |
+
$args = array(
|
493 |
+
'post_type' => $this->token,
|
494 |
+
'posts_per_page' => -1
|
495 |
+
);
|
496 |
+
|
497 |
+
$meta_query = array(
|
498 |
+
'key' => '_sidebar_to_replace',
|
499 |
+
'compare' => '!=',
|
500 |
+
'value' => ''
|
501 |
+
);
|
502 |
+
|
503 |
+
$args['meta_query'][] = $meta_query;
|
504 |
+
|
505 |
+
$meta_query = array(
|
506 |
+
'key' => '_condition',
|
507 |
+
'compare' => 'IN',
|
508 |
+
'value' => $conditions
|
509 |
+
);
|
510 |
+
|
511 |
+
$args['meta_query'][] = $meta_query;
|
512 |
+
|
513 |
+
$sidebars = get_posts( $args );
|
514 |
+
|
515 |
+
if ( count( $sidebars ) > 0 ) {
|
516 |
+
foreach ( $sidebars as $k => $v ) {
|
517 |
+
$to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
|
518 |
+
$sidebars[$k]->to_replace = $to_replace;
|
519 |
+
|
520 |
+
$conditions = get_post_meta( $v->ID, '_condition', false );
|
521 |
+
|
522 |
+
$sidebars[$k]->conditions = array();
|
523 |
+
|
524 |
+
// Remove any irrelevant conditions from the array.
|
525 |
+
if ( is_array( $conditions ) ) {
|
526 |
+
foreach ( $conditions as $i => $j ) {
|
527 |
+
if ( in_array( $j, $this->conditions->conditions ) ) {
|
528 |
+
$sidebars[$k]->conditions[] = $j;
|
529 |
+
}
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
$woo_custom_sidebar_data = $sidebars;
|
537 |
+
}
|
538 |
+
|
539 |
+
// Make sure only the most appropriate sidebars are kept.
|
540 |
+
// $woo_custom_sidebar_data = $this->remove_unwanted_sidebars( $woo_custom_sidebar_data );
|
541 |
+
$woo_custom_sidebar_data = $this->find_best_sidebars( $woo_custom_sidebar_data );
|
542 |
+
|
543 |
+
if ( count( $woo_custom_sidebar_data ) > 0 ) {
|
544 |
+
foreach ( $woo_custom_sidebar_data as $k => $v ) {
|
545 |
+
$sidebar_id = $v->post_name;
|
546 |
+
// $sidebar_id = $this->prefix . $v->ID;
|
547 |
+
if ( isset( $sidebars_widgets[$sidebar_id] ) && isset( $v->to_replace ) && $v->to_replace != '' ) {
|
548 |
+
$widgets = $sidebars_widgets[$sidebar_id];
|
549 |
+
unset( $sidebars_widgets[$sidebar_id] );
|
550 |
+
$sidebars_widgets[$v->to_replace] = $widgets;
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
return $sidebars_widgets;
|
556 |
+
} // End replace_sidebars()
|
557 |
+
|
558 |
+
/**
|
559 |
+
* find_best_sidebars function.
|
560 |
+
*
|
561 |
+
* @access public
|
562 |
+
* @param array $sidebars
|
563 |
+
* @return array $sorted_sidebars
|
564 |
+
*/
|
565 |
+
public function find_best_sidebars ( $sidebars ) {
|
566 |
+
$sorted_sidebars = array();
|
567 |
+
|
568 |
+
if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
|
569 |
+
return $sidebars;
|
570 |
+
}
|
571 |
+
|
572 |
+
// Keep track of each sidebar we'd like to replace widgets for.
|
573 |
+
foreach ( $sidebars as $k => $v ) {
|
574 |
+
if ( isset( $v->to_replace ) && ( $v->to_replace != '' ) && ! isset( $sorted_sidebars[$v->to_replace] ) ) {
|
575 |
+
$sorted_sidebars[$v->to_replace] = '';
|
576 |
+
}
|
577 |
+
}
|
578 |
+
|
579 |
+
foreach ( $sidebars as $k => $v ) {
|
580 |
+
if ( isset( $sorted_sidebars[$v->to_replace] ) && ( $sorted_sidebars[$v->to_replace] == '' ) ) {
|
581 |
+
$sorted_sidebars[$v->to_replace] = $v;
|
582 |
+
} else {
|
583 |
+
continue;
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
return $sorted_sidebars;
|
588 |
+
} // End find_best_sidebars()
|
589 |
+
|
590 |
+
/**
|
591 |
+
* enqueue_styles function.
|
592 |
+
*
|
593 |
+
* @access public
|
594 |
+
* @return void
|
595 |
+
*/
|
596 |
+
public function enqueue_styles () {
|
597 |
+
global $pagenow;
|
598 |
+
|
599 |
+
if ( in_array( $pagenow, array( 'edit.php', 'post.php', 'post-new.php' ) ) ) {
|
600 |
+
if ( get_post_type() != $this->token ) { return; }
|
601 |
+
wp_enqueue_style( 'jquery-ui-tabs' );
|
602 |
+
|
603 |
+
wp_register_style( $this->token . '-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
|
604 |
+
|
605 |
+
wp_enqueue_style( $this->token . '-admin' );
|
606 |
+
|
607 |
+
wp_dequeue_style( 'jquery-ui-datepicker' );
|
608 |
+
}
|
609 |
+
|
610 |
+
if ( in_array( $pagenow, array( 'edit.php' ) ) ) {
|
611 |
+
wp_register_style( $this->token . '-admin-posts', $this->assets_url . '/css/admin-posts.css', array(), '1.0.0' );
|
612 |
+
|
613 |
+
wp_enqueue_style( $this->token . '-admin-posts' );
|
614 |
+
}
|
615 |
+
} // End enqueue_styles()
|
616 |
+
|
617 |
+
/**
|
618 |
+
* add_post_column_headings function.
|
619 |
+
*
|
620 |
+
* @access public
|
621 |
+
* @param array $defaults
|
622 |
+
* @return array $new_columns
|
623 |
+
*/
|
624 |
+
public function add_post_column_headings ( $defaults ) {
|
625 |
+
$defaults['woosidebars_enable'] = __( 'Custom Sidebars', 'woosidebars' );
|
626 |
+
return $defaults;
|
627 |
+
} // End add_post_column_headings()
|
628 |
+
|
629 |
+
/**
|
630 |
+
* add_post_column_data function.
|
631 |
+
*
|
632 |
+
* @access public
|
633 |
+
* @param string $column_name
|
634 |
+
* @param int $id
|
635 |
+
* @return void
|
636 |
+
*/
|
637 |
+
public function add_post_column_data ( $column_name, $id ) {
|
638 |
+
global $wpdb, $post;
|
639 |
+
|
640 |
+
$meta = get_post_custom( $id );
|
641 |
+
|
642 |
+
switch ( $column_name ) {
|
643 |
+
|
644 |
+
case 'woosidebars_enable':
|
645 |
+
$image = 'success-off';
|
646 |
+
$value = '';
|
647 |
+
$class = 'custom-sidebars-disabled';
|
648 |
+
|
649 |
+
if ( isset( $meta['_enable_sidebar'] ) && ( $meta['_enable_sidebar'][0] != '' ) && ( $meta['_enable_sidebar'][0] == 'yes' ) ) {
|
650 |
+
$image = 'success';
|
651 |
+
$class = 'custom-sidebars-enabled';
|
652 |
+
}
|
653 |
+
|
654 |
+
$url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woosidebars-post-enable&post_id=' . $post->ID ), 'woosidebars-post-enable' );
|
655 |
+
|
656 |
+
$value = '<span class="' . esc_attr( $class ) . '"><a href="' . esc_url( $url ) . '"><img src="' . $this->assets_url . '/images/' . $image . '.png" /></a></span>';
|
657 |
+
|
658 |
+
echo $value;
|
659 |
+
break;
|
660 |
+
|
661 |
+
default:
|
662 |
+
break;
|
663 |
+
|
664 |
+
}
|
665 |
+
} // End add_post_column_data()
|
666 |
+
|
667 |
+
/**
|
668 |
+
* enable_custom_post_sidebars function.
|
669 |
+
*
|
670 |
+
* @access public
|
671 |
+
* @return void
|
672 |
+
*/
|
673 |
+
public function enable_custom_post_sidebars () {
|
674 |
+
if( ! is_admin() ) die;
|
675 |
+
|
676 |
+
if( ! current_user_can( 'edit_posts' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'woosidebars' ) );
|
677 |
+
|
678 |
+
if( ! check_admin_referer( 'woosidebars-post-enable' ) ) wp_die( __( 'You have taken too long. Please go back and retry.', 'woosidebars' ) );
|
679 |
+
|
680 |
+
$post_id = isset( $_GET['post_id'] ) && (int)$_GET['post_id'] ? (int)$_GET['post_id'] : '';
|
681 |
+
|
682 |
+
if( ! $post_id ) die;
|
683 |
+
|
684 |
+
$post = get_post( $post_id );
|
685 |
+
if( ! $post ) die;
|
686 |
+
|
687 |
+
$meta = get_post_meta( $post->ID, '_enable_sidebar', true );
|
688 |
+
|
689 |
+
if ( $meta == 'yes' ) {
|
690 |
+
update_post_meta($post->ID, '_enable_sidebar', 'no' );
|
691 |
+
} else {
|
692 |
+
update_post_meta($post->ID, '_enable_sidebar', 'yes' );
|
693 |
+
}
|
694 |
+
|
695 |
+
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
|
696 |
+
wp_safe_redirect( $sendback );
|
697 |
+
} // End enable_custom_post_sidebars()
|
698 |
+
|
699 |
+
/**
|
700 |
+
* multidimensional_search function.
|
701 |
+
*
|
702 |
+
* @access public
|
703 |
+
* @param string $needle
|
704 |
+
* @param array $haystack
|
705 |
+
* @return string $m
|
706 |
+
*/
|
707 |
+
public function multidimensional_search ( $needle, $haystack ) {
|
708 |
+
if (empty($needle) || empty($haystack)) {
|
709 |
+
return false;
|
710 |
+
}
|
711 |
+
|
712 |
+
foreach ($haystack as $key => $value) {
|
713 |
+
$exists = 0;
|
714 |
+
foreach ( (array)$needle as $nkey => $nvalue) {
|
715 |
+
if ( ! empty( $value[$nvalue] ) && is_array( $value[$nvalue] ) ) {
|
716 |
+
return $value[$nvalue]['label'];
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
return false;
|
722 |
+
} // End multidimensional_search()
|
723 |
+
|
724 |
+
/**
|
725 |
+
* add_contextual_help function.
|
726 |
+
*
|
727 |
+
* @description Add contextual help to the current screen.
|
728 |
+
* @access public
|
729 |
+
* @since 1.0.0
|
730 |
+
* @return void
|
731 |
+
*/
|
732 |
+
public function add_contextual_help () {
|
733 |
+
if ( get_current_screen()->id != 'edit-sidebar' ) { return; }
|
734 |
+
|
735 |
+
get_current_screen()->add_help_tab( array(
|
736 |
+
'id' => 'overview',
|
737 |
+
'title' => __( 'Overview', 'woosidebars' ),
|
738 |
+
'content' =>
|
739 |
+
'<p>' . __( 'All custom widget areas are listed on this screen. To add a new customised widget area, click the "Add New" button.', 'woosidebars' ) . '</p>'
|
740 |
+
) );
|
741 |
+
get_current_screen()->add_help_tab( array(
|
742 |
+
'id' => 'wooframework-sbm',
|
743 |
+
'title' => __( 'Sidebar Manager', 'woosidebars' ),
|
744 |
+
'content' =>
|
745 |
+
'<p>' . __( 'WooSidebars is intended to replace the Sidebar Manager found in the WooFramework. Please ensure that all sidebars have been transferred over from the Sidebar Manager, if you choose to use WooSidebars instead.', 'woosidebars' ) . '</p>' .
|
746 |
+
'<p>' . __( 'To transfer a sidebar from the Sidebar Manager:', 'woosidebars' ) . '</p>' .
|
747 |
+
'<ul>' . "\n" .
|
748 |
+
'<li>' . __( 'Create a new custom widget area in WooSidebars.', 'woosidebars' ) . '</li>' . "\n" .
|
749 |
+
'<li>' . sprintf( __( 'Visit the %sAppearance → Widgets%s screen and drag the widgets from the old sidebar into the newly created sidebar.', 'woosidebars' ), '<a href="' . esc_url( admin_url( 'widgets.php' ) ) . '">', '</a>' ) . '</li>' . "\n" .
|
750 |
+
'<li>' . __( 'Repeat this process for each of your custom sidebars, including dependencies if necessary (the WooSidebars conditions system replaces the need for dependencies).', 'woosidebars' ) . '</li>' . "\n" .
|
751 |
+
'<li>' . __( 'Once you are certain that you widgets have been moved across for all widget areas, remove the sidebar from the Sidebar Manager (don\'t forget to transfer any dependencies over as well, if necessary).', 'woosidebars' ) . '</li>' . "\n" .
|
752 |
+
'</ul>' . "\n"
|
753 |
+
) );
|
754 |
+
|
755 |
+
get_current_screen()->set_help_sidebar(
|
756 |
+
'<p><strong>' . __( 'For more information:', 'woosidebars' ) . '</strong></p>' .
|
757 |
+
'<p><a href="http://support.woothemes.com/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'Support Forums', 'woosidebars' ) . '</a></p>' .
|
758 |
+
'<p><a href="http://woothemes.com/support/woosidebars/?ref=' . 'woosidebars' . '" target="_blank">' . __( 'WooSidebars Documentation', 'woosidebars' ) . '</a></p>'
|
759 |
+
);
|
760 |
+
} // End add_contextual_help()
|
761 |
+
|
762 |
+
/**
|
763 |
+
* load_localisation function.
|
764 |
+
*
|
765 |
+
* @access public
|
766 |
+
* @since 1.0.0
|
767 |
+
* @return void
|
768 |
+
*/
|
769 |
+
public function load_localisation () {
|
770 |
+
$lang_dir = trailingslashit( str_replace( 'classes', 'lang', basename( dirname(__FILE__) ) ) );
|
771 |
+
load_plugin_textdomain( 'woosidebars', false, $lang_dir );
|
772 |
+
} // End load_localisation()
|
773 |
+
|
774 |
+
/**
|
775 |
+
* activation function.
|
776 |
+
*
|
777 |
+
* @access public
|
778 |
+
* @since 1.0.0
|
779 |
+
* @return void
|
780 |
+
*/
|
781 |
+
public function activation () {
|
782 |
+
$this->register_plugin_version();
|
783 |
+
} // End activation()
|
784 |
+
|
785 |
+
/**
|
786 |
+
* register_plugin_version function.
|
787 |
+
*
|
788 |
+
* @access public
|
789 |
+
* @since 1.0.0
|
790 |
+
* @return void
|
791 |
+
*/
|
792 |
+
public function register_plugin_version () {
|
793 |
+
if ( $this->version != '' ) {
|
794 |
+
update_option( 'woosidebars' . '-version', $this->version );
|
795 |
+
}
|
796 |
+
} // End register_plugin_version()
|
797 |
+
} // End Class
|
798 |
+
?>
|
index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
?>
|
integrations/integration-woocommerce.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
3 |
+
|
4 |
+
class WooSidebars_Integration_WooCommerce {
|
5 |
+
private $taxonomies = array();
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Constructor.
|
9 |
+
* @since 1.1.0
|
10 |
+
*/
|
11 |
+
public function __construct () {
|
12 |
+
add_filter( 'woo_conditions', array( &$this, 'register_conditions' ) );
|
13 |
+
add_filter( 'woo_conditions_headings', array( &$this, 'register_conditions_headings' ) );
|
14 |
+
add_filter( 'woo_conditions_reference', array( &$this, 'register_conditions_reference' ) );
|
15 |
+
|
16 |
+
add_post_type_support( 'product', 'woosidebars' );
|
17 |
+
} // End __construct()
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Register the integration conditions with WooSidebars.
|
21 |
+
* @since 1.1.0
|
22 |
+
* @param array $conditions The existing array of conditions.
|
23 |
+
* @return array The modified array of conditions.
|
24 |
+
*/
|
25 |
+
public function register_conditions ( $conditions ) {
|
26 |
+
global $post;
|
27 |
+
|
28 |
+
if ( function_exists( 'is_woocommerce' ) && ! is_woocommerce() ) return $conditions;
|
29 |
+
|
30 |
+
$integration = array();
|
31 |
+
if ( function_exists( 'is_shop' ) && is_shop() ) $integration[] = 'wc-shop_page';
|
32 |
+
if ( function_exists( 'is_product_category' ) && is_product_category() ) $integration[] = 'wc-product_category';
|
33 |
+
if ( function_exists( 'is_product_tag' ) && is_product_tag() ) $integration[] = 'wc-product_tag';
|
34 |
+
if ( function_exists( 'is_cart' ) && is_cart() ) $integration[] = 'wc-cart';
|
35 |
+
if ( function_exists( 'is_checkout' ) && is_checkout() ) $integration[] = 'wc-checkout';
|
36 |
+
if ( function_exists( 'is_account_page' ) && is_account_page() ) $integration[] = 'wc-account';
|
37 |
+
|
38 |
+
if ( function_exists( 'is_product' ) && is_product() ) {
|
39 |
+
$integration[] = 'wc-product';
|
40 |
+
|
41 |
+
$categories = get_the_terms( $post->ID, 'product_cat' );
|
42 |
+
|
43 |
+
if ( ! is_wp_error( $categories ) && is_array( $categories ) && ( count( $categories ) > 0 ) ) {
|
44 |
+
foreach ( $categories as $k => $v ) {
|
45 |
+
$integration[] = 'in-term-' . esc_attr( $v->term_id );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
$tags = get_the_terms( $post->ID, 'product_tag' );
|
50 |
+
|
51 |
+
if ( ! is_wp_error( $tags ) && is_array( $tags ) && ( count( $tags ) > 0 ) ) {
|
52 |
+
foreach ( $tags as $k => $v ) {
|
53 |
+
$integration[] = 'in-term-' . esc_attr( $v->term_id );
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
$integration[] = $conditions[count($conditions)-1];
|
60 |
+
|
61 |
+
array_splice( $conditions, count( $conditions ), 0, $integration );
|
62 |
+
|
63 |
+
return $conditions;
|
64 |
+
} // End register_conditions()
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Register the integration's headings for the meta box.
|
68 |
+
* @since 1.1.0
|
69 |
+
* @param array $headings The existing array of headings.
|
70 |
+
* @return array The modified array of headings.
|
71 |
+
*/
|
72 |
+
public function register_conditions_headings ( $headings ) {
|
73 |
+
$headings['woocommerce'] = __( 'WooCommerce', 'woosidebars' );
|
74 |
+
|
75 |
+
return $headings;
|
76 |
+
} // End register_conditions_headings()
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Register the integration's conditions reference for the meta box.
|
80 |
+
* @since 1.1.0
|
81 |
+
* @param array $headings The existing array of conditions.
|
82 |
+
* @return array The modified array of conditions.
|
83 |
+
*/
|
84 |
+
public function register_conditions_reference ( $conditions ) {
|
85 |
+
$conditions['woocommerce'] = array();
|
86 |
+
|
87 |
+
$conditions['woocommerce']['wc-shop_page'] = array(
|
88 |
+
'label' => __( 'Shop Page', 'woosidebars' ),
|
89 |
+
'description' => __( 'The WooCommerce "Shop" landing page', 'woosidebars' )
|
90 |
+
);
|
91 |
+
|
92 |
+
$conditions['woocommerce']['wc-product_category'] = array(
|
93 |
+
'label' => __( 'Product Categories', 'woosidebars' ),
|
94 |
+
'description' => __( 'All product categories', 'woosidebars' )
|
95 |
+
);
|
96 |
+
|
97 |
+
$conditions['woocommerce']['wc-product_tag'] = array(
|
98 |
+
'label' => __( 'Product Tags', 'woosidebars' ),
|
99 |
+
'description' => __( 'All product tags', 'woosidebars' )
|
100 |
+
);
|
101 |
+
|
102 |
+
$conditions['woocommerce']['wc-product'] = array(
|
103 |
+
'label' => __( 'Products', 'woosidebars' ),
|
104 |
+
'description' => __( 'All products', 'woosidebars' )
|
105 |
+
);
|
106 |
+
|
107 |
+
$conditions['woocommerce']['wc-cart'] = array(
|
108 |
+
'label' => __( 'Cart Page', 'woosidebars' ),
|
109 |
+
'description' => __( 'The WooCommerce "Cart" page', 'woosidebars' )
|
110 |
+
);
|
111 |
+
|
112 |
+
$conditions['woocommerce']['wc-checkout'] = array(
|
113 |
+
'label' => __( 'Checkout Page', 'woosidebars' ),
|
114 |
+
'description' => __( 'The WooCommerce "Checkout" page', 'woosidebars' )
|
115 |
+
);
|
116 |
+
|
117 |
+
$conditions['woocommerce']['wc-account'] = array(
|
118 |
+
'label' => __( 'Account Pages', 'woosidebars' ),
|
119 |
+
'description' => __( 'The WooCommerce "Account" pages', 'woosidebars' )
|
120 |
+
);
|
121 |
+
|
122 |
+
// Setup terminologies for the "in category" and "tagged with" conditions.
|
123 |
+
$terminologies = array(
|
124 |
+
'taxonomy-product_cat' => __( 'Products in the "%s" category', 'woosidebars' ),
|
125 |
+
'taxonomy-product_tag' => __( 'Products tagged "%s"', 'woosidebars' )
|
126 |
+
);
|
127 |
+
|
128 |
+
foreach ( $terminologies as $k => $v ) {
|
129 |
+
if( ! isset( $conditions[$k] ) ) continue;
|
130 |
+
foreach ( $conditions[$k] as $i => $j ) {
|
131 |
+
$conditions[$k]['in-' . $i] = array( 'label' => sprintf( $terminologies[$k], $j['label'] ), 'description' => sprintf( $terminologies[$k], $j['label'] ) );
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
return $conditions;
|
136 |
+
} // End register_conditions_reference()
|
137 |
+
} // End Class
|
138 |
+
|
139 |
+
// Initialise the integration.
|
140 |
+
new WooSidebars_Integration_WooCommerce();
|
141 |
+
?>
|
lang/woosidebars-en_GB.po
ADDED
@@ -0,0 +1,495 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
+
"PO-Revision-Date: 2012-08-14 10:26:15+0000\n"
|
7 |
+
"Last-Translator: \n"
|
8 |
+
"Language-Team: \n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
13 |
+
"X-Poedit-Language: \n"
|
14 |
+
"X-Poedit-Country: \n"
|
15 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
16 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
17 |
+
"X-Poedit-Basepath: \n"
|
18 |
+
"X-Poedit-Bookmarks: \n"
|
19 |
+
"X-Poedit-SearchPath-0: .\n"
|
20 |
+
"X-Textdomain-Support: yes"
|
21 |
+
|
22 |
+
#: classes/class.wooconditions.php:55
|
23 |
+
#@ woosidebars
|
24 |
+
msgid "Conditions"
|
25 |
+
msgstr ""
|
26 |
+
|
27 |
+
#: classes/class.wooconditions.php:120
|
28 |
+
#: classes/class.wooconditions.php:282
|
29 |
+
#@ woosidebars
|
30 |
+
msgid "Pages"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: classes/class.wooconditions.php:126
|
34 |
+
#, php-format
|
35 |
+
#@ woosidebars
|
36 |
+
msgid "The \"%s\" page"
|
37 |
+
msgstr ""
|
38 |
+
|
39 |
+
#: classes/class.wooconditions.php:186
|
40 |
+
#, php-format
|
41 |
+
#@ woosidebars
|
42 |
+
msgid "A custom sidebar for \"%s\""
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: classes/class.wooconditions.php:199
|
46 |
+
#@ woosidebars
|
47 |
+
msgid "Page Templates"
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: classes/class.wooconditions.php:205
|
51 |
+
#, php-format
|
52 |
+
#@ woosidebars
|
53 |
+
msgid "The \"%s\" page template"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: classes/class.wooconditions.php:215
|
57 |
+
#@ woosidebars
|
58 |
+
msgid "Post Types"
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: classes/class.wooconditions.php:222
|
62 |
+
#, php-format
|
63 |
+
#@ woosidebars
|
64 |
+
msgid "\"%s\" Post Type Archive"
|
65 |
+
msgstr ""
|
66 |
+
|
67 |
+
#: classes/class.wooconditions.php:223
|
68 |
+
#, php-format
|
69 |
+
#@ woosidebars
|
70 |
+
msgid "The \"%s\" post type archive"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: classes/class.wooconditions.php:231
|
74 |
+
#, php-format
|
75 |
+
#@ woosidebars
|
76 |
+
msgid "Individual %s"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: classes/class.wooconditions.php:232
|
80 |
+
#, php-format
|
81 |
+
#@ woosidebars
|
82 |
+
msgid "Entries in the \"%s\" post type"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: classes/class.wooconditions.php:250
|
86 |
+
#@ woosidebars
|
87 |
+
msgid "Taxonomy Archives"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: classes/class.wooconditions.php:258
|
91 |
+
#, php-format
|
92 |
+
#@ woosidebars
|
93 |
+
msgid "The default \"%s\" archives"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: classes/class.wooconditions.php:267
|
97 |
+
#, php-format
|
98 |
+
#@ woosidebars
|
99 |
+
msgid "The %s %s archive"
|
100 |
+
msgstr ""
|
101 |
+
|
102 |
+
#: classes/class.wooconditions.php:283
|
103 |
+
#@ woosidebars
|
104 |
+
msgid "Displayed on all pages that don't have a more specific widget area."
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: classes/class.wooconditions.php:287
|
108 |
+
#@ woosidebars
|
109 |
+
msgid "Search Results"
|
110 |
+
msgstr ""
|
111 |
+
|
112 |
+
#: classes/class.wooconditions.php:288
|
113 |
+
#@ woosidebars
|
114 |
+
msgid "Displayed on search results screens."
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: classes/class.wooconditions.php:292
|
118 |
+
#@ woosidebars
|
119 |
+
msgid "Default \"Your Latest Posts\" Screen"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: classes/class.wooconditions.php:293
|
123 |
+
#@ woosidebars
|
124 |
+
msgid "Displayed on the default \"Your Latest Posts\" screen."
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: classes/class.wooconditions.php:297
|
128 |
+
#@ woosidebars
|
129 |
+
msgid "Front Page"
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: classes/class.wooconditions.php:298
|
133 |
+
#@ woosidebars
|
134 |
+
msgid "Displayed on any front page, regardless of the settings under the \"Settings -> Reading\" admin screen."
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: classes/class.wooconditions.php:302
|
138 |
+
#@ woosidebars
|
139 |
+
msgid "Single Entries"
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: classes/class.wooconditions.php:303
|
143 |
+
#@ woosidebars
|
144 |
+
msgid "Displayed on single entries of any public post type other than \"Pages\"."
|
145 |
+
msgstr ""
|
146 |
+
|
147 |
+
#: classes/class.wooconditions.php:307
|
148 |
+
#@ woosidebars
|
149 |
+
msgid "All Archives"
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: classes/class.wooconditions.php:308
|
153 |
+
#@ woosidebars
|
154 |
+
msgid "Displayed on all archives (category, tag, taxonomy, post type, dated, author and search)."
|
155 |
+
msgstr ""
|
156 |
+
|
157 |
+
#: classes/class.wooconditions.php:312
|
158 |
+
#@ woosidebars
|
159 |
+
msgid "Author Archives"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: classes/class.wooconditions.php:313
|
163 |
+
#@ woosidebars
|
164 |
+
msgid "Displayed on all author archive screens (that don't have a more specific sidebar)."
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: classes/class.wooconditions.php:317
|
168 |
+
#@ woosidebars
|
169 |
+
msgid "Date Archives"
|
170 |
+
msgstr ""
|
171 |
+
|
172 |
+
#: classes/class.wooconditions.php:318
|
173 |
+
#@ woosidebars
|
174 |
+
msgid "Displayed on all date archives."
|
175 |
+
msgstr ""
|
176 |
+
|
177 |
+
#: classes/class.wooconditions.php:322
|
178 |
+
#@ woosidebars
|
179 |
+
msgid "404 Error Screens"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: classes/class.wooconditions.php:323
|
183 |
+
#@ woosidebars
|
184 |
+
msgid "Displayed on all 404 error screens."
|
185 |
+
msgstr ""
|
186 |
+
|
187 |
+
#: classes/class.wooconditions.php:520
|
188 |
+
#@ woosidebars
|
189 |
+
msgid "Taxonomy Terms"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: classes/class.wooconditions.php:527
|
193 |
+
#@ woosidebars
|
194 |
+
msgid "Advanced"
|
195 |
+
msgstr ""
|
196 |
+
|
197 |
+
#: classes/class.wooconditions.php:579
|
198 |
+
#@ woosidebars
|
199 |
+
msgid "Taxonomy Token"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: classes/class.woosidebars.php:159
|
203 |
+
#@ woosidebars
|
204 |
+
msgid "Widget Area"
|
205 |
+
msgstr ""
|
206 |
+
|
207 |
+
#: classes/class.woosidebars.php:160
|
208 |
+
#: classes/class.woosidebars.php:173
|
209 |
+
#@ woosidebars
|
210 |
+
msgid "Widget Areas"
|
211 |
+
msgstr ""
|
212 |
+
|
213 |
+
#: classes/class.woosidebars.php:167
|
214 |
+
#@ woosidebars
|
215 |
+
msgctxt "post type general name"
|
216 |
+
msgid "Widget Areas"
|
217 |
+
msgstr ""
|
218 |
+
|
219 |
+
#: classes/class.woosidebars.php:168
|
220 |
+
#@ woosidebars
|
221 |
+
msgctxt "post type singular name"
|
222 |
+
msgid "Widget Area"
|
223 |
+
msgstr ""
|
224 |
+
|
225 |
+
#: classes/class.woosidebars.php:169
|
226 |
+
#@ default
|
227 |
+
msgctxt "Widget Area"
|
228 |
+
msgid "Add New"
|
229 |
+
msgstr ""
|
230 |
+
|
231 |
+
#: classes/class.woosidebars.php:170
|
232 |
+
#, php-format
|
233 |
+
#@ woosidebars
|
234 |
+
msgid "Add New %s"
|
235 |
+
msgstr ""
|
236 |
+
|
237 |
+
#: classes/class.woosidebars.php:171
|
238 |
+
#, php-format
|
239 |
+
#@ woosidebars
|
240 |
+
msgid "Edit %s"
|
241 |
+
msgstr ""
|
242 |
+
|
243 |
+
#: classes/class.woosidebars.php:172
|
244 |
+
#, php-format
|
245 |
+
#@ woosidebars
|
246 |
+
msgid "New %s"
|
247 |
+
msgstr ""
|
248 |
+
|
249 |
+
#: classes/class.woosidebars.php:174
|
250 |
+
#, php-format
|
251 |
+
#@ woosidebars
|
252 |
+
msgid "View %s"
|
253 |
+
msgstr ""
|
254 |
+
|
255 |
+
#: classes/class.woosidebars.php:175
|
256 |
+
#, php-format
|
257 |
+
#@ woosidebars
|
258 |
+
msgid "Search %a"
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: classes/class.woosidebars.php:176
|
262 |
+
#, php-format
|
263 |
+
#@ woosidebars
|
264 |
+
msgid "No %s Found"
|
265 |
+
msgstr ""
|
266 |
+
|
267 |
+
#: classes/class.woosidebars.php:177
|
268 |
+
#, php-format
|
269 |
+
#@ woosidebars
|
270 |
+
msgid "No %s Found In Trash"
|
271 |
+
msgstr ""
|
272 |
+
|
273 |
+
#: classes/class.woosidebars.php:228
|
274 |
+
#@ woosidebars
|
275 |
+
msgid "(Not in use by current theme)"
|
276 |
+
msgstr ""
|
277 |
+
|
278 |
+
#: classes/class.woosidebars.php:263
|
279 |
+
#: classes/class.woosidebars.php:293
|
280 |
+
#@ woosidebars
|
281 |
+
msgid "Sidebar To Replace"
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: classes/class.woosidebars.php:263
|
285 |
+
#@ woosidebars
|
286 |
+
msgid "Condition(s)"
|
287 |
+
msgstr ""
|
288 |
+
|
289 |
+
#: classes/class.woosidebars.php:300
|
290 |
+
#: classes/class.woosidebars.php:382
|
291 |
+
#@ woosidebars
|
292 |
+
msgid "Description"
|
293 |
+
msgstr ""
|
294 |
+
|
295 |
+
#: classes/class.woosidebars.php:327
|
296 |
+
#@ woosidebars
|
297 |
+
msgid "No sidebars are available with this theme."
|
298 |
+
msgstr ""
|
299 |
+
|
300 |
+
#: classes/class.woosidebars.php:383
|
301 |
+
#, php-format
|
302 |
+
#@ woosidebars
|
303 |
+
msgid "Add an optional description, to be displayed when adding widgets to this widget area on the %sWidgets%s screen."
|
304 |
+
msgstr ""
|
305 |
+
|
306 |
+
#: classes/class.woosidebars.php:396
|
307 |
+
#@ woosidebars
|
308 |
+
msgid "Enter widget area name here"
|
309 |
+
msgstr ""
|
310 |
+
|
311 |
+
#: classes/class.woosidebars.php:413
|
312 |
+
#@ woosidebars
|
313 |
+
msgid "Widget Area updated."
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: classes/class.woosidebars.php:634
|
317 |
+
#@ woosidebars
|
318 |
+
msgid "Custom Sidebars"
|
319 |
+
msgstr ""
|
320 |
+
|
321 |
+
#: classes/class.woosidebars.php:685
|
322 |
+
#@ woosidebars
|
323 |
+
msgid "You do not have sufficient permissions to access this page."
|
324 |
+
msgstr ""
|
325 |
+
|
326 |
+
#: classes/class.woosidebars.php:687
|
327 |
+
#@ woosidebars
|
328 |
+
msgid "You have taken too long. Please go back and retry."
|
329 |
+
msgstr ""
|
330 |
+
|
331 |
+
#: classes/class.woosidebars.php:746
|
332 |
+
#@ woosidebars
|
333 |
+
msgid "Overview"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: classes/class.woosidebars.php:748
|
337 |
+
#@ woosidebars
|
338 |
+
msgid "All custom widget areas are listed on this screen. To add a new customised widget area, click the \"Add New\" button."
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: classes/class.woosidebars.php:752
|
342 |
+
#@ woosidebars
|
343 |
+
msgid "Sidebar Manager"
|
344 |
+
msgstr ""
|
345 |
+
|
346 |
+
#: classes/class.woosidebars.php:754
|
347 |
+
#@ woosidebars
|
348 |
+
msgid "WooSidebars is intended to replace the Sidebar Manager found in the WooFramework. Please ensure that all sidebars have been transferred over from the Sidebar Manager, if you choose to use WooSidebars instead."
|
349 |
+
msgstr ""
|
350 |
+
|
351 |
+
#: classes/class.woosidebars.php:755
|
352 |
+
#@ woosidebars
|
353 |
+
msgid "To transfer a sidebar from the Sidebar Manager:"
|
354 |
+
msgstr ""
|
355 |
+
|
356 |
+
#: classes/class.woosidebars.php:757
|
357 |
+
#@ woosidebars
|
358 |
+
msgid "Create a new custom widget area in WooSidebars."
|
359 |
+
msgstr ""
|
360 |
+
|
361 |
+
#: classes/class.woosidebars.php:758
|
362 |
+
#, php-format
|
363 |
+
#@ woosidebars
|
364 |
+
msgid "Visit the %sAppearance → Widgets%s screen and drag the widgets from the old sidebar into the newly created sidebar."
|
365 |
+
msgstr ""
|
366 |
+
|
367 |
+
#: classes/class.woosidebars.php:759
|
368 |
+
#@ woosidebars
|
369 |
+
msgid "Repeat this process for each of your custom sidebars, including dependencies if necessary (the WooSidebars conditions system replaces the need for dependencies)."
|
370 |
+
msgstr ""
|
371 |
+
|
372 |
+
#: classes/class.woosidebars.php:760
|
373 |
+
#@ woosidebars
|
374 |
+
msgid "Once you are certain that you widgets have been moved across for all widget areas, remove the sidebar from the Sidebar Manager (don't forget to transfer any dependencies over as well, if necessary)."
|
375 |
+
msgstr ""
|
376 |
+
|
377 |
+
#: classes/class.woosidebars.php:765
|
378 |
+
#@ woosidebars
|
379 |
+
msgid "For more information:"
|
380 |
+
msgstr ""
|
381 |
+
|
382 |
+
#: classes/class.woosidebars.php:766
|
383 |
+
#@ woosidebars
|
384 |
+
msgid "Support Forums"
|
385 |
+
msgstr ""
|
386 |
+
|
387 |
+
#: classes/class.woosidebars.php:767
|
388 |
+
#@ woosidebars
|
389 |
+
msgid "WooSidebars Documentation"
|
390 |
+
msgstr ""
|
391 |
+
|
392 |
+
#: classes/class.wooconditions.php:269
|
393 |
+
#, php-format
|
394 |
+
#@ woosidebars
|
395 |
+
msgid "All posts in \"%s\""
|
396 |
+
msgstr ""
|
397 |
+
|
398 |
+
#: classes/class.wooconditions.php:269
|
399 |
+
#, php-format
|
400 |
+
#@ woosidebars
|
401 |
+
msgid "All posts in the %s %s archive"
|
402 |
+
msgstr ""
|
403 |
+
|
404 |
+
#: classes/class.wooconditions.php:278
|
405 |
+
#@ woosidebars
|
406 |
+
msgid "Template Hierarchy"
|
407 |
+
msgstr ""
|
408 |
+
|
409 |
+
#: integrations/integration-woocommerce.php:73
|
410 |
+
#@ woosidebars
|
411 |
+
msgid "WooCommerce"
|
412 |
+
msgstr ""
|
413 |
+
|
414 |
+
#: integrations/integration-woocommerce.php:88
|
415 |
+
#@ woosidebars
|
416 |
+
msgid "Shop Page"
|
417 |
+
msgstr ""
|
418 |
+
|
419 |
+
#: integrations/integration-woocommerce.php:89
|
420 |
+
#@ woosidebars
|
421 |
+
msgid "The WooCommerce \"Shop\" landing page"
|
422 |
+
msgstr ""
|
423 |
+
|
424 |
+
#: integrations/integration-woocommerce.php:93
|
425 |
+
#@ woosidebars
|
426 |
+
msgid "Product Categories"
|
427 |
+
msgstr ""
|
428 |
+
|
429 |
+
#: integrations/integration-woocommerce.php:94
|
430 |
+
#@ woosidebars
|
431 |
+
msgid "All product categories"
|
432 |
+
msgstr ""
|
433 |
+
|
434 |
+
#: integrations/integration-woocommerce.php:98
|
435 |
+
#@ woosidebars
|
436 |
+
msgid "Product Tags"
|
437 |
+
msgstr ""
|
438 |
+
|
439 |
+
#: integrations/integration-woocommerce.php:99
|
440 |
+
#@ woosidebars
|
441 |
+
msgid "All product tags"
|
442 |
+
msgstr ""
|
443 |
+
|
444 |
+
#: integrations/integration-woocommerce.php:103
|
445 |
+
#@ woosidebars
|
446 |
+
msgid "Products"
|
447 |
+
msgstr ""
|
448 |
+
|
449 |
+
#: integrations/integration-woocommerce.php:104
|
450 |
+
#@ woosidebars
|
451 |
+
msgid "All products"
|
452 |
+
msgstr ""
|
453 |
+
|
454 |
+
#: integrations/integration-woocommerce.php:108
|
455 |
+
#@ woosidebars
|
456 |
+
msgid "Cart Page"
|
457 |
+
msgstr ""
|
458 |
+
|
459 |
+
#: integrations/integration-woocommerce.php:109
|
460 |
+
#@ woosidebars
|
461 |
+
msgid "The WooCommerce \"Cart\" page"
|
462 |
+
msgstr ""
|
463 |
+
|
464 |
+
#: integrations/integration-woocommerce.php:113
|
465 |
+
#@ woosidebars
|
466 |
+
msgid "Checkout Page"
|
467 |
+
msgstr ""
|
468 |
+
|
469 |
+
#: integrations/integration-woocommerce.php:114
|
470 |
+
#@ woosidebars
|
471 |
+
msgid "The WooCommerce \"Checkout\" page"
|
472 |
+
msgstr ""
|
473 |
+
|
474 |
+
#: integrations/integration-woocommerce.php:118
|
475 |
+
#@ woosidebars
|
476 |
+
msgid "Account Pages"
|
477 |
+
msgstr ""
|
478 |
+
|
479 |
+
#: integrations/integration-woocommerce.php:119
|
480 |
+
#@ woosidebars
|
481 |
+
msgid "The WooCommerce \"Account\" pages"
|
482 |
+
msgstr ""
|
483 |
+
|
484 |
+
#: integrations/integration-woocommerce.php:124
|
485 |
+
#, php-format
|
486 |
+
#@ woosidebars
|
487 |
+
msgid "Products in the \"%s\" category"
|
488 |
+
msgstr ""
|
489 |
+
|
490 |
+
#: integrations/integration-woocommerce.php:125
|
491 |
+
#, php-format
|
492 |
+
#@ woosidebars
|
493 |
+
msgid "Products tagged \"%s\""
|
494 |
+
msgstr ""
|
495 |
+
|
lang/woosidebars-xx_XX.pot
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit
|
readme.txt
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WooSidebars ===
|
2 |
+
Contributors: woothemes, mattyza
|
3 |
+
Tags: widgets, sidebars, widget-areas
|
4 |
+
Requires at least: 3.3
|
5 |
+
Tested up to: 3.5-beta3
|
6 |
+
Stable tag: 1.2.0
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
+
WooSidebars adds functionality to display different widgets in a sidebar, according to a context (for example, a specific page or a category).
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
With WooSidebars, it's possible to change the widgets that display in a sidebar (widgetized area) according to a context (for example, a specific page, a specific blog post, certain categories or the search results screen). Setting up a custom widget area to display across multiple conditions is as easy as a few clicks.
|
15 |
+
|
16 |
+
[vimeo http://vimeo.com/42980663]
|
17 |
+
|
18 |
+
Looking for a helping hand? [View plugin documentation](http://dojodocs.woothemes.com/woosidebars/).
|
19 |
+
|
20 |
+
Looking to contribute code to this plugin? [Fork the repository over at GitHub](http://github.com/woothemes/woosidebars/).
|
21 |
+
(submit pull requests to the "develop" branch)
|
22 |
+
|
23 |
+
== Installation ==
|
24 |
+
|
25 |
+
= Minimum Requirements =
|
26 |
+
|
27 |
+
* WordPress 3.3 or greater
|
28 |
+
* PHP version 5.2.4 or greater
|
29 |
+
* MySQL version 5.0 or greater
|
30 |
+
|
31 |
+
= Automatic installation =
|
32 |
+
|
33 |
+
Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t even need to leave your web browser. To do an automatic install of WooSidebars, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
|
34 |
+
|
35 |
+
In the search field type "WooSidebars" and click Search Plugins. Once you’ve found our widget areas plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking Install Now. After clicking that link you will be asked if you’re sure you want to install the plugin. Click yes and WordPress will automatically complete the installation.
|
36 |
+
|
37 |
+
= Manual installation =
|
38 |
+
|
39 |
+
The manual installation method involves downloading WooSidebars and uploading it to your webserver via your favourite FTP application.
|
40 |
+
|
41 |
+
1. Download the plugin file to your computer and unzip it
|
42 |
+
2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installation’s wp-content/plugins/ directory.
|
43 |
+
3. Activate the plugin from the Plugins menu within the WordPress admin.
|
44 |
+
|
45 |
+
= Where to go after installation =
|
46 |
+
|
47 |
+
Once WooSidebars has been installed and activated, please visit the "Appearance -> Widget Areas" screen to begin adding custom widget areas.
|
48 |
+
|
49 |
+
= Upgrading =
|
50 |
+
|
51 |
+
Automatic updates should work a charm; as always though, ensure you backup your site just in case.
|
52 |
+
|
53 |
+
== Frequently Asked Questions ==
|
54 |
+
|
55 |
+
= Where can I find WooSidebars documentation and user guides? =
|
56 |
+
|
57 |
+
For further documentation on using WooSidebars, please view the [WooSidebars Documentation](http://dojodocs.woothemes.com/woosidebars/).
|
58 |
+
|
59 |
+
= Will WooSidebars work with my theme? =
|
60 |
+
|
61 |
+
Yes; WooSidebars will work with any theme that supports dynamic widget areas.
|
62 |
+
|
63 |
+
== Screenshots ==
|
64 |
+
|
65 |
+
1. The list of custom widget areas.
|
66 |
+
2. Adding a custom widget area.
|
67 |
+
|
68 |
+
== Upgrade Notice ==
|
69 |
+
|
70 |
+
= 1.2.0 =
|
71 |
+
Moved to WordPress.org. Woo! Added scope to methods and properties where missing.
|
72 |
+
|
73 |
+
== Changelog ==
|
74 |
+
|
75 |
+
= 1.2.0 =
|
76 |
+
* Renamed files according to standards naming convention.
|
77 |
+
* Added scope to methods and properties where missing.
|
78 |
+
|
79 |
+
= 1.1.2 =
|
80 |
+
* Routine hardening and maintenance update. Fixed notice message in WooCommerce integration.
|
81 |
+
|
82 |
+
= 1.1.1 =
|
83 |
+
* Fix notice displayed on WooCommerce product pages from the WooSidebars integration.
|
84 |
+
|
85 |
+
= 1.1.0 =
|
86 |
+
* Initial WooCommerce integration.
|
87 |
+
|
88 |
+
= 1.0.0 =
|
89 |
+
* First release. Woo!
|
woosidebars.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WooSidebars
|
4 |
+
* Plugin URI: http://woothemes.com/woosidebars/
|
5 |
+
* Description: Replace widget areas in your theme for specific pages, archives and other sections of WordPress.
|
6 |
+
* Author: WooThemes
|
7 |
+
* Author URI: http://woothemes.com/
|
8 |
+
* Version: 1.2.0
|
9 |
+
* Stable tag: 1.2.0
|
10 |
+
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
14 |
+
|
15 |
+
if ( ! class_exists( 'Woo_Conditions' ) ) {
|
16 |
+
require_once( 'classes/class-woo-conditions.php' );
|
17 |
+
}
|
18 |
+
require_once( 'classes/class-woo-sidebars.php' );
|
19 |
+
|
20 |
+
// Third-party integrations.
|
21 |
+
if ( class_exists( 'Woocommerce' ) ) require_once( 'integrations/integration-woocommerce.php' );
|
22 |
+
|
23 |
+
global $woosidebars;
|
24 |
+
$woosidebars = new Woo_Sidebars( __FILE__ );
|
25 |
+
$woosidebars->version = '1.2.0';
|
26 |
+
$woosidebars->init();
|
27 |
+
?>
|