├── CONTRIBUTING.md
├── assets
├── css
│ ├── admin-posts.css
│ └── admin.css
├── images
│ ├── icon-settings.png
│ ├── success-off.png
│ └── success.png
└── js
│ └── admin.js
├── changelog.txt
├── classes
├── class-woo-conditions.php
└── class-woo-sidebars.php
├── index.php
├── integrations
└── integration-woocommerce.php
├── lang
└── woosidebars.pot
├── readme.txt
└── woosidebars.php
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | Community made patches, localisations, bug reports and contributions are always welcome and are crucial to ensure WooSidebars remains the #1 widget area management plugin for WordPress. ;)
4 |
5 | When contributing please ensure you follow the guidelines below so that we can keep on top of things.
6 |
7 | __Note:__
8 |
9 | GitHub is for *bug reports and contributions only* - if you have a support question or a request for a customization, don't post here. Use [WordPress.org](http://wordpress.org/support/plugin/woosidebars) for community support, and for customisations we recommend one of the following services:
10 |
11 | - Codeable: http://codeable.io/
12 | - Tweaky: https://www.tweaky.com/
13 | - WooExperts: http://www.woocommerce.com/experts/
14 |
15 | ## Getting Started
16 |
17 | * Make sure you have a [GitHub account](https://github.com/signup/free)
18 | * Submit a ticket for your issue, assuming one does not already exist.
19 | * Clearly describe the issue including steps to reproduce when it is a bug.
20 | * Make sure you fill in the earliest version that you know has the issue.
21 |
22 | ## Making Changes
23 |
24 | * Fork the repository on GitHub.
25 | * Make the changes to your forked repository.
26 | * **Ensure you stick to the [WordPress Coding Standards](http://codex.wordpress.org/WordPress_Coding_Standards).**
27 | * Ensure you use LF line endings - no crazy windows line endings. :)
28 | * When committing, reference your issue (#1234) and include a note about the fix.
29 | * Push the changes to your fork and submit a pull request on the latest release branch of the WooSidebars repository.
30 | * Release branches start their branch name with `release-`.
31 |
32 | At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
33 |
34 | # Additional Resources
35 |
36 | * [General GitHub documentation](http://help.github.com/)
37 | * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
38 | * [WooSidebars Docs](http://docs.woocommerce.com/documentation/plugins/woosidebars/)
39 | * [WooCommerce Support](http://woocommerce.com/my-account/tickets/)
--------------------------------------------------------------------------------
/assets/css/admin-posts.css:
--------------------------------------------------------------------------------
1 | /* Custom Column On Posts, etc */
2 |
3 | .column-woosidebars_enable { width: 12%; }
--------------------------------------------------------------------------------
/assets/css/admin.css:
--------------------------------------------------------------------------------
1 | .conditions-tabs li { display: inline; margin: 5px 0; padding: 5px; }
2 | .woo-conditions.ui-tabs { padding: 0; }
3 | .woo-conditions .ui-tabs-hide { display: none; }
4 | .woo-conditions .ui-widget-header { border: none; }
5 | .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; }
6 | .woo-conditions .conditions-tabs li { float:left;padding:0;margin:0 5px 0 0; }
7 | .woo-conditions .conditions-tabs li.alignright { float: right; }
8 | .woo-conditions .conditions-tabs li.hide { display: none; }
9 | .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; }
10 | .woo-conditions .conditions-tabs li a { padding:0;margin:0;border:0;border:1px solid #d5d5d5;border-bottom:0;float:left; outline: none; 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); }
11 | .woo-conditions .conditions-tabs li.ui-state-active {}
12 | .woo-conditions .conditions-tabs li.ui-state-active a { background:#FFFFFF; color:#555; }
13 | #woosidebars-conditions.postbox .inside { background: #FFFFFF; padding: 0; margin: 0; }
14 | #woosidebars-conditions.postbox .inside .condition-tab { background: #FFFFFF; padding: 2px 18px; }
15 | #woosidebars-conditions.postbox .inside .condition-tab h4 { margin-top: 10px; }
16 |
17 | #woosidebars-conditions.postbox .conditions-column { display: block; margin: 0 20px 20px 0; }
18 |
19 | #woosidebars-conditions.postbox .conditions-tabs-inner { border-bottom: 1px solid #EBEBEB !important; display: block; margin-top: 0.4rem; padding: 0; padding-bottom: 0.4rem; }
20 | .conditions-tabs-inner li { display: inline; padding: 0; line-height: 2; margin: 0; }
21 | .conditions-tabs-inner li a { margin-right: 5px; text-decoration: none; }
22 | .conditions-tabs-inner li.ui-state-active a { color: #000000; font-weight: bold; }
23 | #woosidebars-conditions.postbox .inside .condition-tab .condition-tab { padding: 2px 0px; }
24 |
25 | .view-switch { display: none; }
26 |
27 | #preview-action { display: none; }
28 | #visibility.misc-pub-section { display: none; }
29 |
30 | /* Reset and override jQueryUI styling, used by several plugins. */
31 | #woosidebars-conditions.postbox .woo-conditions { background: none; border: 0; -webkit-border-radius: 0; -moz-border-radius: 0; -o-border-radius: 0; border-radius: 0; font-size: 12px; font-weight: normal; font-family: sans-serif; }
32 | #woosidebars-conditions.postbox .conditions-tabs, #woosidebars-conditions.postbox .conditions-tabs-inner { border: 0; -webkit-border-radius: 0; -moz-border-radius: 0; -o-border-radius: 0; border-radius: 0; }
33 | #woosidebars-conditions.postbox .conditions-tabs-inner { background: none; }
34 | #woosidebars-conditions.postbox .conditions-tabs li, #woosidebars-conditions.postbox .conditions-tabs-inner li { background: none; border: 0; -webkit-border-radius: 0; -moz-border-radius: 0; -o-border-radius: 0; border-radius: 0; }
35 | #woosidebars-conditions.postbox .conditions-tabs li a, #woosidebars-conditions.postbox .conditions-tabs-inner li a { outline: none; }
36 | #woosidebars-conditions.postbox .conditions-tabs-inner li a { padding: 0 0.1em; }
--------------------------------------------------------------------------------
/assets/images/icon-settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/woocommerce/woosidebars/2498a4054522ff0343a26f21654ca8ca7f720218/assets/images/icon-settings.png
--------------------------------------------------------------------------------
/assets/images/success-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/woocommerce/woosidebars/2498a4054522ff0343a26f21654ca8ca7f720218/assets/images/success-off.png
--------------------------------------------------------------------------------
/assets/images/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/woocommerce/woosidebars/2498a4054522ff0343a26f21654ca8ca7f720218/assets/images/success.png
--------------------------------------------------------------------------------
/assets/js/admin.js:
--------------------------------------------------------------------------------
1 | jQuery( document ).ready( function () {
2 | jQuery( '.woo-conditions.tabs' ).tabs();
3 | jQuery( '.woo-conditions.tabs .inner-tabs' ).tabs();
4 |
5 | jQuery( '#woosidebars-conditions .advanced-settings a' ).click( function ( e ) {
6 | jQuery( '#woosidebars-conditions .tabs li.advanced' ).toggleClass( 'hide' );
7 |
8 | var new_status = '1'; // Do display.
9 | if ( jQuery( '#woosidebars-conditions .tabs li.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:
--------------------------------------------------------------------------------
1 | *** WooSidebars Changelog ***
2 |
3 | 2018.06.18 - version 1.4.5
4 | * Fix - Fixes a fatal error, by removing the no longer relevant contextual help.
5 |
6 | 2018.06.08 - version 1.4.4
7 | * New - Enable a widget area for "a page and it's children".
8 | * Fix - Error notice when on a page without a defined screen_id.
9 |
10 | 2015.09.22 - version 1.4.3
11 | * Fix - Ensures condition headings are present before attempting to output in the conditions meta box.
12 | /classes/class-woo-conditions.php
13 |
14 | 2015.04.22 - version 1.4.2
15 | * Security Fix - remove_query_arg vulnerability
16 | /classes/class-woo-sidebars.php
17 |
18 | 2015.02.17 - version 1.4.1
19 | * Fix - Fixes an error notice on the homepage, caused by the tag check logic.
20 | /classes/class-woo-conditions.php
21 |
22 | 2015.02.17 - version 1.4.0
23 | * New - Adds a condition to change the widget area for all posts tagged with a selected tag.
24 | /classes/class-woo-conditions.php
25 |
26 | 2013.08.13 - version 1.3.1
27 | * /classes/class-woo-conditions.php - Re-introduce add_post_meta() instead of update_post_meta() when saving conditions. Using update_post_meta() prevents multiple conditions from being saved.
28 |
29 | 2013.08.12 - version 1.3.0
30 | * /assets/css/admin.css - Replace all instances of #woo-conditions with #woosidebars-conditions to match the renamed meta box. Add basic jQueryUI styling reset to prevent visual inconsistency when jQueryUI is loaded via a third-party plugin.
31 | * /assets/js/admin.js - Adjust the JavaScript logic to use the new "woosidebars-conditions" selector instead of "woo-conditions" for toggling advanced options on and off.
32 | * /classes/class-woo-conditions.php - Rename "woo-conditions" meta box to "woosidebars-conditions". Fixes display bug with the WPML "Multilingual Content Setup" meta box. Replaces all instances of &$this with $this. Introduces upper_limit property and woosidebars_upper_limit filter. Addresses logic for the "single" condition type.
33 | * /classes/class-woo-sidebars.php - Replaces all instances of &$this with $this. Introduces upper_limit property and woosidebars_upper_limit filter.
34 |
35 | 2013.03.08 - version 1.2.2
36 | * /classes/class-woo-sidebars.php - Changed capability for displaying the "Widget Areas" menu to use "edit_theme_options" instead of "switch_themes".
37 | * /assets/css/admin.css - Minor styling adjustments. Fixes admin styling when jquery-ui-fresh CSS is loaded by other plugins.
38 |
39 | 2013.01.09 - version 1.2.1
40 | * /classes/class-woo-conditions.php - Update script version. Update conditions meta box HTML to move the "advanced" button to it's own list instead of being a part of the tabs. Add "post_type" condition without the "post-type-" prefix. Fixes the "Template Hierarchy -> Pages" bug.
41 | * /classes/class-woo-sidebars.php - If WordPress SEO is active, remove the unused meta box styling, as it conflicts with the custom WooSidebars meta box styling. Set "has_archive" to "sidebars". Make sure only users with the "switch_themes" capability can see the "Widget Areas" admin menu.
42 | * /assets/js/admin.js - Adjust admin JavaScript to work with updated conditions meta box HTML.
43 |
44 | 2012.08.14 - version 1.1.2
45 | * /integrations/integration-woocommerce.php - Added logic to stop undefined index notices in foreach(). Prevent direct file access.
46 | * /classes/class.wooconditions.php,
47 | /classes/class.woosidebars.php - Prevent direct file access.
48 | * /classes/class.updater.php - Prevent direct file access. Return $false instead of false when checking for updates, if not WooSidebars.
49 | * /lang/woosidebars-en_GB.po - Rescanned language file.
50 | * /lang/woosidebars-xx_XX.pot - Rescanned language template file.
51 | * woosidebars.php - Prevent direct file access. Update stable tag.
52 | * index.php - Added to prevent directory listing.
53 |
54 | 2012.05.23 - version 1.1.0
55 | * /classes/class.woosidebars.php - Adjustments to accept integrations.
56 | * /classes/class.wooconditions.php - Adjustments to accept integrations.
57 | * /integrations/integration-woocommerce.php - Initial WooCommerce integration, if WooCommerce is active.
58 | * woosidebars.php - Load WooCommerce integration, if WooCommerce is active.
59 |
60 | 2012.04.11 - version 1.0.0
61 | * Initial release. Woo!
62 |
--------------------------------------------------------------------------------
/classes/class-woo-conditions.php:
--------------------------------------------------------------------------------
1 | meta_box_settings['title'] = __( 'Conditions', 'woosidebars' );
58 | $this->upper_limit = intval( apply_filters( 'woosidebars_upper_limit', 200 ) );
59 |
60 | if ( is_admin() && get_post_type() == $this->token || ! get_post_type() ) {
61 | add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
62 | add_action( 'save_post', array( $this, 'meta_box_save' ) );
63 | }
64 |
65 | /* Plugin URL/path settings. */
66 | $this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
67 | $this->assets_url = $this->plugin_url . '/assets';
68 |
69 | if ( is_admin() ) {
70 | add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ), 12 );
71 | }
72 |
73 | add_action( 'get_header', array( $this, 'get_conditions' ) );
74 |
75 | add_action( 'wp_ajax_woosidebars-toggle-advanced-items', array( $this, 'ajax_toggle_advanced_items' ) );
76 | } // End __construct()
77 |
78 | /**
79 | * get_conditions function.
80 | *
81 | * @access public
82 | * @return void
83 | */
84 | public function get_conditions () {
85 | $this->determine_conditions();
86 |
87 | $this->conditions = apply_filters( 'woo_conditions', $this->conditions );
88 |
89 | $this->conditions = array_reverse( $this->conditions );
90 | } // End get_conditions()
91 |
92 | /**
93 | * determine_conditions function.
94 | *
95 | * @access public
96 | * @return void
97 | */
98 | public function determine_conditions () {
99 | $this->is_hierarchy();
100 | $this->is_taxonomy();
101 | $this->is_post_type_archive();
102 | $this->is_page_template();
103 | } // End determine_conditions()
104 |
105 | /**
106 | * setup_default_conditions_reference function.
107 | *
108 | * @description Setup the default conditions and their information, for display when selecting conditions.
109 | * @access public
110 | * @return void
111 | */
112 | public function setup_default_conditions_reference () {
113 | $conditions = array();
114 | $conditions_headings = array();
115 |
116 | // Get an array of the different post status labels, in case we need it later.
117 | $post_statuses = get_post_statuses();
118 |
119 | // Pages and Pages with children
120 | $conditions['pages'] = array();
121 | $conditions['pages_with_children'] = array();
122 |
123 | $statuses_string = join( ',', array_keys( $post_statuses ) );
124 | $pages = get_pages( array( 'post_status' => $statuses_string ) );
125 |
126 | if ( count( $pages ) > 0 ) {
127 |
128 | $conditions_headings['pages'] = __( 'Pages', 'woosidebars' );
129 | $conditions_headings['pages_with_children'] = __( 'Pages and their children', 'woosidebars' );
130 |
131 | foreach ( $pages as $k => $v ) {
132 | $token = 'post-' . $v->ID;
133 | $pwctoken = 'postwc-' . $v->ID;
134 |
135 | $label = esc_html( $v->post_title );
136 | if ( 'publish' != $v->post_status ) {
137 | $label .= ' (' . $post_statuses[$v->post_status] . ')';
138 | }
139 |
140 | $conditions['pages'][$token] = array(
141 | 'label' => $label,
142 | 'description' => sprintf( __( 'The "%s" page', 'woosidebars' ), $v->post_title )
143 | );
144 |
145 | $conditions['pages_with_children'][$pwctoken] = array(
146 | 'label' => $label,
147 | 'description' => sprintf( __( 'The "%s" page and its children', 'woosidebars' ), $v->post_title ),
148 | 'parent' => $v->post_parent,
149 | 'ID' => $v->ID,
150 | );
151 | }
152 |
153 | $conditions['pages_with_children'] = $this->add_depth( $conditions['pages_with_children'] );
154 | }
155 |
156 | $args = array(
157 | 'show_ui' => true,
158 | 'public' => true,
159 | 'publicly_queryable' => true,
160 | '_builtin' => false
161 | );
162 |
163 | $post_types = get_post_types( $args, 'object' );
164 |
165 | // Set certain post types that aren't allowed to have custom sidebars.
166 | $disallowed_types = array( 'slide' );
167 |
168 | // Make the array filterable.
169 | $disallowed_types = apply_filters( 'woosidebars_disallowed_post_types', $disallowed_types );
170 |
171 | if ( count( $post_types ) ) {
172 | foreach ( $post_types as $k => $v ) {
173 | if ( in_array( $k, $disallowed_types ) ) {
174 | unset( $post_types[$k] );
175 | }
176 | }
177 | }
178 |
179 | // Add per-post support for any post type that supports it.
180 | $args = array(
181 | 'show_ui' => true,
182 | 'public' => true,
183 | 'publicly_queryable' => true,
184 | '_builtin' => true
185 | );
186 |
187 | $built_in_post_types = get_post_types( $args, 'object' );
188 |
189 | foreach ( $built_in_post_types as $k => $v ) {
190 | if ( $k == 'post' ) {
191 | $post_types[$k] = $v;
192 | break;
193 | }
194 | }
195 |
196 | foreach ( $post_types as $k => $v ) {
197 | if ( ! post_type_supports( $k, 'woosidebars' ) ) { continue; }
198 |
199 | $conditions_headings[$k] = $v->labels->name;
200 |
201 | $query_args = array( 'numberposts' => intval( $this->upper_limit ), 'post_type' => $k, 'meta_key' => '_enable_sidebar', 'meta_value' => 'yes', 'meta_compare' => '=', 'post_status' => 'any', 'suppress_filters' => 'false' );
202 |
203 | $posts = get_posts( $query_args );
204 |
205 | if ( count( $posts ) > 0 ) {
206 | foreach ( $posts as $i => $j ) {
207 | $label = $j->post_title;
208 | if ( 'publish' != $j->post_status ) {
209 | $label .= ' (' . $post_statuses[$j->post_status] . ')';
210 | }
211 | $conditions[$k]['post' . '-' . $j->ID] = array(
212 | 'label' => $label,
213 | 'description' => sprintf( __( 'A custom sidebar for "%s"', 'woosidebars' ), esc_attr( $j->post_title ) )
214 | );
215 | }
216 | }
217 | }
218 |
219 | // Page Templates
220 | $page_templates = get_page_templates();
221 |
222 | if ( 0 < count( $page_templates ) ) {
223 | $conditions['templates'] = array();
224 |
225 | $conditions_headings['templates'] = __( 'Page Templates', 'woosidebars' );
226 |
227 | foreach ( $page_templates as $k => $v ) {
228 | $token = str_replace( '.php', '', 'page-template-' . $v );
229 | $conditions['templates'][$token] = array(
230 | 'label' => $k,
231 | 'description' => sprintf( __( 'The "%s" page template', 'woosidebars' ), $k )
232 | );
233 | }
234 | }
235 |
236 | // Post Type Archives
237 | $conditions['post_types'] = array();
238 |
239 | if ( count( $post_types ) > 0 ) {
240 |
241 | $conditions_headings['post_types'] = __( 'Post Types', 'woosidebars' );
242 |
243 | foreach ( $post_types as $k => $v ) {
244 | $token = 'post-type-archive-' . $k;
245 |
246 | if ( $v->has_archive ) {
247 | $conditions['post_types'][$token] = array(
248 | 'label' => sprintf( __( '"%s" Post Type Archive', 'woosidebars' ), $v->labels->name ),
249 | 'description' => sprintf( __( 'The "%s" post type archive', 'woosidebars' ), $v->labels->name )
250 | );
251 | }
252 | }
253 |
254 | foreach ( $post_types as $k => $v ) {
255 | $token = 'post-type-' . $k;
256 | $conditions['post_types'][$token] = array(
257 | 'label' => sprintf( __( 'Each Individual %s', 'woosidebars' ), $v->labels->singular_name ),
258 | 'description' => sprintf( __( 'Entries in the "%s" post type', 'woosidebars' ), $v->labels->name )
259 | );
260 | }
261 |
262 | }
263 |
264 | // Taxonomies and Taxonomy Terms
265 | $conditions['taxonomies'] = array();
266 |
267 | $args = array(
268 | 'public' => true
269 | );
270 |
271 | $taxonomies = get_taxonomies( $args, 'objects' );
272 |
273 | if ( count( $taxonomies ) > 0 ) {
274 |
275 | $conditions_headings['taxonomies'] = __( 'Taxonomy Archives', 'woosidebars' );
276 |
277 | foreach ( $taxonomies as $k => $v ) {
278 | $taxonomy = $v;
279 |
280 | if ( $taxonomy->public == true ) {
281 | $conditions['taxonomies']['archive-' . $k] = array(
282 | 'label' => esc_html( $taxonomy->labels->name ) . ' (' . esc_html( $k ) . ')',
283 | 'description' => sprintf( __( 'The default "%s" archives', 'woosidebars' ), strtolower( $taxonomy->labels->name ) )
284 | );
285 |
286 | // Setup each individual taxonomy's terms as well.
287 | $conditions_headings['taxonomy-' . $k] = $taxonomy->labels->name;
288 | $terms = get_terms( array( 'taxonomy' => $k, 'hide_empty' => false ) );
289 | if ( count( $terms ) > 0 ) {
290 | $conditions['taxonomy-' . $k] = array();
291 | foreach ( $terms as $i => $j ) {
292 | $conditions['taxonomy-' . $k]['term-' . $j->term_id] = array( 'label' => esc_html( $j->name ), 'description' => sprintf( __( 'The %s %s archive', 'woosidebars' ), esc_html( $j->name ), strtolower( $taxonomy->labels->name ) ) );
293 | if ( $k == 'category' ) {
294 | $conditions['taxonomy-' . $k]['in-term-' . $j->term_id] = array( 'label' => sprintf( __( 'All posts in "%s"', 'woosidebars' ), esc_html( $j->name ) ), 'description' => sprintf( __( 'All posts in the %s %s archive', 'woosidebars' ), esc_html( $j->name ), strtolower( $taxonomy->labels->name ) ) );
295 | }
296 | if ( $k == 'post_tag' ) {
297 | $conditions['taxonomy-' . $k]['has-term-' . $j->term_id] = array( 'label' => sprintf( __( 'All posts tagged "%s"', 'woosidebars' ), esc_html( $j->name ) ), 'description' => sprintf( __( 'All posts tagged %s', 'woosidebars' ), esc_html( $j->name ) ) );
298 | }
299 | }
300 | }
301 |
302 | }
303 | }
304 | }
305 |
306 | $conditions_headings['hierarchy'] = __( 'Template Hierarchy', 'woosidebars' );
307 |
308 | // Template Hierarchy
309 | $conditions['hierarchy']['page'] = array(
310 | 'label' => __( 'Pages', 'woosidebars' ),
311 | 'description' => __( 'Displayed on all pages that don\'t have a more specific widget area.', 'woosidebars' )
312 | );
313 |
314 | $conditions['hierarchy']['search'] = array(
315 | 'label' => __( 'Search Results', 'woosidebars' ),
316 | 'description' => __( 'Displayed on search results screens.', 'woosidebars' )
317 | );
318 |
319 | $conditions['hierarchy']['home'] = array(
320 | 'label' => __( 'Default "Your Latest Posts" Screen', 'woosidebars' ),
321 | 'description' => __( 'Displayed on the default "Your Latest Posts" screen.', 'woosidebars' )
322 | );
323 |
324 | $conditions['hierarchy']['front_page'] = array(
325 | 'label' => __( 'Front Page', 'woosidebars' ),
326 | 'description' => __( 'Displayed on any front page, regardless of the settings under the "Settings -> Reading" admin screen.', 'woosidebars' )
327 | );
328 |
329 | $conditions['hierarchy']['single'] = array(
330 | 'label' => __( 'Single Entries', 'woosidebars' ),
331 | 'description' => __( 'Displayed on single entries of any public post type other than "Pages".', 'woosidebars' )
332 | );
333 |
334 | $conditions['hierarchy']['archive'] = array(
335 | 'label' => __( 'All Archives', 'woosidebars' ),
336 | 'description' => __( 'Displayed on all archives (category, tag, taxonomy, post type, dated, author and search).', 'woosidebars' )
337 | );
338 |
339 | $conditions['hierarchy']['author'] = array(
340 | 'label' => __( 'Author Archives', 'woosidebars' ),
341 | 'description' => __( 'Displayed on all author archive screens (that don\'t have a more specific sidebar).', 'woosidebars' )
342 | );
343 |
344 | $conditions['hierarchy']['date'] = array(
345 | 'label' => __( 'Date Archives', 'woosidebars' ),
346 | 'description' => __( 'Displayed on all date archives.', 'woosidebars' )
347 | );
348 |
349 | $conditions['hierarchy']['404'] = array(
350 | 'label' => __( '404 Error Screens', 'woosidebars' ),
351 | 'description' => __( 'Displayed on all 404 error screens.', 'woosidebars' )
352 | );
353 |
354 |
355 | $this->conditions_reference = (array)apply_filters( 'woo_conditions_reference', $conditions );
356 | $this->conditions_headings = (array)apply_filters( 'woo_conditions_headings', $conditions_headings );
357 | } // End setup_default_conditions_reference()
358 |
359 |
360 | private function add_depth( $conditions ) {
361 | $map = array();
362 | $depth = array();
363 | foreach ( $conditions as $condition ) {
364 | $map[ $condition['ID'] ] = $condition['parent'];
365 | }
366 |
367 | foreach ( $map as $id => $parent ) {
368 | $d = 0;
369 | while ( 0 != $parent ) {
370 | $d++;
371 | $parent = $map[$parent];
372 | }
373 | $depth[$id] = $d;
374 | }
375 |
376 | foreach ( $conditions as $key => $condition ) {
377 | $conditions[ $key ]['depth'] = $depth[ $condition['ID'] ];
378 | }
379 |
380 | return $conditions;
381 | }
382 |
383 | /**
384 | * is_hierarchy function.
385 | *
386 | * @description Is the current view a part of the default template hierarchy?
387 | * @access public
388 | * @return void
389 | */
390 | function is_hierarchy () {
391 | if ( is_front_page() && ! is_home() ) {
392 | $this->conditions[] = 'static_front_page';
393 | }
394 |
395 | if ( ! is_front_page() && is_home() ) {
396 | $this->conditions[] = 'inner_posts_page';
397 | }
398 |
399 | if ( is_front_page() ) {
400 | $this->conditions[] = 'front_page';
401 | }
402 |
403 | if ( is_home() ) {
404 | $this->conditions[] = 'home';
405 | }
406 |
407 | if ( is_singular() ) {
408 | $this->conditions[] = 'singular';
409 | }
410 |
411 | if ( is_single() ) {
412 | $this->conditions[] = 'single';
413 | }
414 |
415 | if ( is_single() || is_singular() ) {
416 | $this->conditions[] = 'post-type-' . get_post_type();
417 | $this->conditions[] = get_post_type();
418 |
419 | // In Category conditions.
420 | $categories = get_the_category( get_the_ID() );
421 |
422 | if ( is_array( $categories ) && ! is_wp_error( $categories ) && ( 0 < count( $categories ) ) ) {
423 | foreach ( $categories as $k => $v ) {
424 | $this->conditions[] = 'in-term-' . $v->term_id;
425 | }
426 | }
427 |
428 | // Has Tag conditions.
429 | $tags = get_the_tags( get_the_ID() );
430 |
431 | if ( is_array( $tags ) && ! is_wp_error( $tags ) && ( 0 < count( $tags ) ) ) {
432 | foreach ( $tags as $k => $v ) {
433 | $this->conditions[] = 'has-term-' . $v->term_id;
434 | }
435 | }
436 |
437 | // Post-specific condition.
438 | $this->conditions[] = 'post' . '-' . get_the_ID();
439 | $this->conditions[] = 'postwc' . '-' . get_the_ID();
440 | }
441 |
442 | $ancestors = get_post_ancestors( get_the_ID() );
443 |
444 | foreach ( $ancestors as $ancestor ) {
445 | $this->conditions[] = 'postwc-' . $ancestor;
446 | }
447 |
448 | if ( is_search() ) {
449 | $this->conditions[] = 'search';
450 | }
451 |
452 | if ( is_archive() ) {
453 | $this->conditions[] = 'archive';
454 | }
455 |
456 | if ( is_author() ) {
457 | $this->conditions[] = 'author';
458 | }
459 |
460 | if ( is_date() ) {
461 | $this->conditions[] = 'date';
462 | }
463 |
464 | if ( is_404() ) {
465 | $this->conditions[] = '404';
466 | }
467 | } // End is_hierarchy()
468 |
469 | /**
470 | * is_taxonomy function.
471 | *
472 | * @description Is the current view an archive within a specific taxonomy, that doesn't have a specific sidebar?
473 | * @access public
474 | * @return void
475 | */
476 | public function is_taxonomy () {
477 | if ( ( is_tax() || is_archive() ) && ! is_post_type_archive() ) {
478 | $obj = get_queried_object();
479 |
480 | if ( ! is_category() && ! is_tag() ) {
481 | $this->conditions[] = 'taxonomies';
482 | }
483 |
484 | if ( is_object( $obj ) ) {
485 | $this->conditions[] = 'archive-' . $obj->taxonomy;
486 | $this->conditions[] = 'term-' . $obj->term_id;
487 | }
488 | }
489 | } // End is_taxonomy()
490 |
491 | /**
492 | * is_post_type_archive function.
493 | *
494 | * @description Is the current view an archive of a post type?
495 | * @access public
496 | * @return void
497 | */
498 | public function is_post_type_archive () {
499 | if ( is_post_type_archive() ) {
500 |
501 | $post_type = get_query_var( 'post_type' );
502 | if ( is_array( $post_type ) ){
503 | $post_type = reset( $post_type );
504 | }
505 |
506 | $this->conditions[] = 'post-type-archive-' . $post_type;
507 | }
508 | } // End is_post_type_archive()
509 |
510 | /**
511 | * is_page_template function.
512 | *
513 | * @description Does the current view have a specific page template attached (used on single views)?
514 | * @access public
515 | * @return void
516 | */
517 | public function is_page_template () {
518 | if ( is_singular() ) {
519 | global $post;
520 | $template = get_post_meta( $post->ID, '_wp_page_template', true );
521 |
522 | if ( $template != '' && $template != 'default' ) {
523 | $this->conditions[] = str_replace( '.php', '', 'page-template-' . $template );
524 | }
525 | }
526 | } // End is_page_template()
527 |
528 | /**
529 | * meta_box_setup function.
530 | *
531 | * @access public
532 | * @return void
533 | */
534 | public function meta_box_setup () {
535 | add_meta_box( 'woosidebars-conditions', esc_html( $this->meta_box_settings['title'] ), array( $this, 'meta_box_content' ), $this->token, 'normal', 'low' );
536 | } // End meta_box_setup()
537 |
538 | /**
539 | * meta_box_content function.
540 | *
541 | * @access public
542 | * @return void
543 | */
544 | public function meta_box_content () {
545 | global $post_id;
546 |
547 | if ( count( $this->conditions_reference ) <= 0 ) $this->setup_default_conditions_reference();
548 |
549 | $selected_conditions = get_post_meta( $post_id, '_condition', false );
550 |
551 | if ( $selected_conditions == '' ) {
552 | $selected_conditions = array();
553 | }
554 |
555 | $html = '';
556 |
557 | $html .= '';
558 |
559 | if ( count( $this->conditions_reference ) > 0 ) {
560 |
561 | // Separate out the taxonomy items and pages with children for use as sub-tabs of "Taxonomy Terms" and hierarchical presentation of pages
562 | $taxonomy_terms = array();
563 | $pwc = array();
564 |
565 |
566 | foreach ( $this->conditions_reference as $k => $v ) {
567 | if ( substr( $k, 0, 9 ) == 'taxonomy-' ) {
568 | $taxonomy_terms[$k] = $v;
569 | unset( $this->conditions_reference[$k] );
570 | }
571 |
572 | if ( 'pages_with_children' === $k ) {
573 | $pwc[$k] = $v;
574 | // unset( $this->conditions_reference[$k] );
575 | }
576 | }
577 |
578 | $html .= '
' . "\n";
579 |
580 | $html .= $this->render_tabs( $selected_conditions );
581 |
582 | $html .= $this->render_standard_pages( $selected_conditions );
583 |
584 | $html .= $this->render_taxonomy_terms_tabs( $taxonomy_terms, $selected_conditions );
585 |
586 | $html .= '
' . "\n";
587 | }
588 |
589 | // Allow themes/plugins to act here (key, args).
590 | do_action( 'woo_conditions_meta_box', $k, $v );
591 |
592 | $html .= '
' . "\n";
593 |
594 | echo $html;
595 | } // End meta_box_content()
596 |
597 | private function render_tabs( $selected_conditions ) {
598 | $html = '' . "\n";
599 |
600 | $count = 0;
601 |
602 | // Determine whether or not to show advanced items, based on user's preference (default: false).
603 | $show_advanced = $this->show_advanced_items();
604 |
605 | foreach ( $this->conditions_reference as $k => $v ) {
606 | $count++;
607 | $class = '';
608 | if ( $count == 1 ) {
609 | $class = 'tabs';
610 | } else {
611 | $class = 'hide-if-no-js';
612 | }
613 | if ( in_array( $k, array( 'pages' ) ) ) {
614 | $class .= ' basic';
615 | } else {
616 | $class .= ' advanced';
617 | if ( ! $show_advanced ) { $class .= ' hide'; }
618 | }
619 |
620 | if ( isset( $this->conditions_headings[$k] ) ) {
621 | $html .= '- ' . esc_html( $this->conditions_headings[$k] ) . '
' . "\n";
622 | }
623 |
624 | if ( $k == 'taxonomies' ) {
625 | $html .= '- ' . __( 'Taxonomy Terms', 'woosidebars' ) . '
' . "\n";
626 | }
627 | }
628 |
629 | $class = 'hide-if-no-js advanced';
630 | if ( ! $show_advanced ) { $class .= ' hide'; }
631 |
632 | $html .= '
' . "\n";
633 |
634 | $html .= '' . "\n";
635 |
636 | return $html;
637 | }
638 |
639 | private function render_standard_pages( $selected_conditions ) {
640 | $html = '';
641 |
642 | foreach ( $this->conditions_reference as $k => $v ) {
643 | $count = 0;
644 |
645 | $tab = '';
646 |
647 | $tab .= '' . "\n";
648 | if ( isset( $this->conditions_headings[$k] ) ) {
649 | $tab .= '
' . esc_html( $this->conditions_headings[$k] ) . '
' . "\n";
650 | }
651 | $tab .= '
';
667 | }
668 | }
669 |
670 | $tab .= '
' . "\n";
671 | // Filter the contents of the current tab.
672 | $tab = apply_filters( 'woo_conditions_tab_' . esc_attr( $k ), $tab );
673 | $html .= $tab;
674 | $html .= '
';
675 | $html .= '
' . "\n";
676 | }
677 |
678 | return $html;
679 | }
680 |
681 | private function render_taxonomy_terms_tabs( $taxonomy_terms, $selected_conditions ) {
682 | // Taxonomy Terms Tab
683 | $html = '' . "\n";
684 | $html .= '
' . "\n";
685 |
686 | foreach ( $taxonomy_terms as $k => $v ) {
687 | if ( ! isset( $this->conditions_headings[$k] ) ) { unset( $taxonomy_terms[$k] ); }
688 | }
689 |
690 | $count = 0;
691 | foreach ( $taxonomy_terms as $k => $v ) {
692 | $count++;
693 | $class = '';
694 | if ( $count == 1 ) {
695 | $class = 'tabs';
696 | } else {
697 | $class = 'hide-if-no-js';
698 | }
699 |
700 | $html .= '- ' . esc_html( $this->conditions_headings[$k] ) . '';
701 | if ( $count != count( $taxonomy_terms ) ) {
702 | $html .= ' |';
703 | }
704 | $html .= '
' . "\n";
705 | }
706 |
707 | $html .= '
' . "\n";
708 |
709 | foreach ( $taxonomy_terms as $k => $v ) {
710 | $count = 0;
711 |
712 | $html .= '
' . "\n";
713 | $html .= '
' . esc_html( $this->conditions_headings[$k] ) . '
' . "\n";
714 | $html .= '
';
727 | }
728 | }
729 |
730 | $html .= '
' . "\n";
731 | $html .= '
';
732 | $html .= '
' . "\n";
733 |
734 | }
735 | return $html;
736 | }
737 |
738 | /**
739 | * meta_box_save function.
740 | *
741 | * @access public
742 | * @param mixed $post_id
743 | * @return void
744 | */
745 | public function meta_box_save ( $post_id ) {
746 | global $post, $messages;
747 |
748 | // Verify
749 | if ( ! isset( $_POST['woo_' . $this->token . '_conditions_noonce'] ) || ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_conditions_noonce'], plugin_basename(__FILE__) ) ) {
750 | return $post_id;
751 | }
752 |
753 | if ( 'page' == $_POST['post_type'] ) {
754 | if ( ! current_user_can( 'edit_page', $post_id ) ) {
755 | return $post_id;
756 | }
757 | } else {
758 | if ( ! current_user_can( 'edit_post', $post_id ) ) {
759 | return $post_id;
760 | }
761 | }
762 |
763 | if ( isset( $_POST['conditions'] ) && ( 0 < count( $_POST['conditions'] ) ) ) {
764 | delete_post_meta( $post_id, '_condition' );
765 |
766 | foreach ( $_POST['conditions'] as $k => $v ) {
767 | add_post_meta( $post_id, '_condition', $v, false );
768 | }
769 | }
770 | } // End meta_box_save()
771 |
772 | /**
773 | * show_advanced_itesm function.
774 | *
775 | * @access private
776 | * @return boolean
777 | */
778 | private function show_advanced_items () {
779 | $response = false;
780 |
781 | $setting = get_user_setting( 'woosidebarsshowadvanced', '0' );
782 |
783 | if ( $setting == '1' ) { $response = true; }
784 |
785 | return $response;
786 | } // End show_advanced_items()
787 |
788 | /**
789 | * ajax_toggle_advanced_items function.
790 | *
791 | * @access public
792 | * @return void
793 | */
794 | public function ajax_toggle_advanced_items () {
795 | //Add nonce security to the request
796 | if ( ( ! isset( $_POST['woosidebars_advanced_noonce'] ) || ! isset( $_POST['new_status'] ) ) || ! wp_verify_nonce( $_POST['woosidebars_advanced_noonce'], 'woosidebars_advanced_noonce' ) ) {
797 | die();
798 | }
799 |
800 | $response = set_user_setting( 'woosidebarsshowadvanced', $_POST['new_status'] );
801 |
802 | echo $response;
803 | die(); // WordPress may print out a spurious zero without this can be particularly bad if using JSON
804 | } // End ajax_toggle_advanced_items()
805 |
806 | /**
807 | * enqueue_scripts function.
808 | *
809 | * @access public
810 | * @return void
811 | */
812 | public function enqueue_scripts () {
813 | global $pagenow;
814 | if ( get_post_type() != $this->token ) { return; }
815 |
816 | if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
817 | wp_register_script( $this->token . '-admin', $this->assets_url . '/js/admin.js', array( 'jquery', 'jquery-ui-tabs' ), '1.2.1', true );
818 |
819 | wp_enqueue_script( $this->token . '-admin' );
820 |
821 | wp_dequeue_script( 'jquery-ui-datepicker' );
822 |
823 | $translation_strings = array();
824 |
825 | $ajax_vars = array( 'woosidebars_advanced_noonce' => wp_create_nonce( 'woosidebars_advanced_noonce' ) );
826 |
827 | $data = array_merge( $translation_strings, $ajax_vars );
828 |
829 | wp_localize_script( $this->token . '-admin', 'woosidebars_localized_data', $data );
830 | }
831 | } // End enqueue_scripts()
832 | } // End Class
833 | ?>
--------------------------------------------------------------------------------
/classes/class-woo-sidebars.php:
--------------------------------------------------------------------------------
1 | version = '';
74 | $this->file = $file;
75 | $this->upper_limit = intval( apply_filters( 'woosidebars_upper_limit', 200 ) );
76 |
77 | $this->token = 'sidebar';
78 | $this->prefix = 'woo_sidebar_';
79 |
80 | /* Plugin URL/path settings. */
81 | $this->plugin_url = str_replace( '/classes', '', plugins_url( plugin_basename( dirname( __FILE__ ) ) ) );
82 | $this->assets_url = $this->plugin_url . '/assets';
83 |
84 | $this->conditions = new Woo_Conditions();
85 | $this->conditions->token = $this->token;
86 | } // End __construct()
87 |
88 | /**
89 | * init function.
90 | *
91 | * @access public
92 | * @return void
93 | */
94 | public function init () {
95 | add_action( 'init', array( $this, 'load_localisation' ) );
96 |
97 | add_action( 'init', array( $this, 'register_post_type' ), 20 );
98 | add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
99 | add_action( 'save_post', array( $this, 'meta_box_save' ) );
100 | add_filter( 'enter_title_here', array( $this, 'enter_title_here' ) );
101 | add_filter( 'post_updated_messages', array( $this, 'update_messages' ) );
102 | add_action( 'widgets_init', array( $this, 'register_custom_sidebars' ) );
103 | add_action( 'get_header', array( $this, 'init_sidebar_replacement' ) );
104 |
105 | if ( is_admin() ) {
106 | global $pagenow;
107 |
108 | add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ), 12 );
109 | if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && esc_attr( $_GET['post_type'] ) == $this->token ) {
110 | add_filter( 'manage_edit-' . $this->token . '_columns', array( $this, 'register_custom_column_headings' ), 10, 1 );
111 | add_action( 'manage_posts_custom_column', array( $this, 'register_custom_columns' ), 10, 2 );
112 | }
113 | }
114 |
115 | // By default, add post type support for sidebars to the "post" post type.
116 | add_post_type_support( 'post', 'woosidebars' );
117 |
118 | add_action( 'admin_head', array( $this, 'register_post_type_columns' ) );
119 |
120 | add_action( 'wp_ajax_woosidebars-post-enable', array( $this, 'enable_custom_post_sidebars' ) );
121 |
122 | // Run this on activation.
123 | register_activation_hook( $this->file, array( $this, 'activation' ) );
124 | } // End init()
125 |
126 | /**
127 | * register_post_type_columns function.
128 | *
129 | * @access public
130 | * @return void
131 | */
132 | public function register_post_type_columns () {
133 | $post_type = get_post_type();
134 |
135 | if ( $post_type != '' && post_type_supports( $post_type, 'woosidebars' ) ) {
136 | add_filter( 'manage_edit-' . $post_type . '_columns', array( $this, 'add_post_column_headings' ), 10, 1 );
137 | add_action( 'manage_posts_custom_column', array( $this, 'add_post_column_data' ), 10, 2 );
138 | add_action( 'manage_pages_custom_column', array( $this, 'add_post_column_data' ), 10, 2 );
139 | }
140 | } // End register_post_type_columns()
141 |
142 | /**
143 | * register_post_type function.
144 | *
145 | * @access public
146 | * @return void
147 | */
148 | public function register_post_type () {
149 | // Allow only users who can adjust the theme to view the WooSidebars admin.
150 | if ( ! current_user_can( 'edit_theme_options' ) ) return;
151 |
152 | $page = 'themes.php';
153 |
154 | $singular = __( 'Widget Area', 'woosidebars' );
155 | $plural = __( 'Widget Areas', 'woosidebars' );
156 | $rewrite = array( 'slug' => 'sidebars' );
157 | $supports = array( 'title', 'excerpt' );
158 |
159 | if ( $rewrite == '' ) { $rewrite = $this->token; }
160 |
161 | $labels = array(
162 | 'name' => _x( 'Widget Areas', 'post type general name', 'woosidebars' ),
163 | 'singular_name' => _x( 'Widget Area', 'post type singular name', 'woosidebars' ),
164 | 'add_new' => _x( 'Add New', 'Widget Area' ),
165 | 'add_new_item' => sprintf( __( 'Add New %s', 'woosidebars' ), $singular ),
166 | 'edit_item' => sprintf( __( 'Edit %s', 'woosidebars' ), $singular ),
167 | 'new_item' => sprintf( __( 'New %s', 'woosidebars' ), $singular ),
168 | 'all_items' => sprintf( __( 'Widget Areas', 'woosidebars' ), $plural ),
169 | 'view_item' => sprintf( __( 'View %s', 'woosidebars' ), $singular ),
170 | 'search_items' => sprintf( __( 'Search %s', 'woosidebars' ), $plural ),
171 | 'not_found' => sprintf( __( 'No %s Found', 'woosidebars' ), $plural ),
172 | 'not_found_in_trash' => sprintf( __( 'No %s Found In Trash', 'woosidebars' ), $plural ),
173 | 'parent_item_colon' => '',
174 | 'menu_name' => $plural
175 |
176 | );
177 | $args = array(
178 | 'labels' => $labels,
179 | 'public' => false,
180 | 'publicly_queryable' => true,
181 | 'show_ui' => true,
182 | 'show_in_nav_menus' => false,
183 | 'show_in_admin_bar' => false,
184 | 'show_in_menu' => $page,
185 | 'query_var' => true,
186 | 'rewrite' => $rewrite,
187 | 'capability_type' => 'post',
188 | 'has_archive' => 'sidebars',
189 | 'hierarchical' => false,
190 | 'menu_position' => null,
191 | 'supports' => $supports
192 | );
193 | register_post_type( $this->token, $args );
194 | } // End register_post_type()
195 |
196 | /**
197 | * register_custom_columns function.
198 | *
199 | * @access public
200 | * @param string $column_name
201 | * @param int $id
202 | * @return void
203 | */
204 | public function register_custom_columns ( $column_name, $id ) {
205 | global $wpdb, $post;
206 |
207 | $meta = get_post_custom( $id );
208 | $sidebars = $this->get_registered_sidebars();
209 |
210 | $this->conditions->setup_default_conditions_reference();
211 |
212 | switch ( $column_name ) {
213 |
214 | case 'sidebar_to_replace':
215 | $value = '';
216 |
217 | if ( isset( $meta['_sidebar_to_replace'] ) && ( $meta['_sidebar_to_replace'][0] != '' ) ) {
218 | $value = $meta['_sidebar_to_replace'][0];
219 |
220 | if ( isset( $sidebars[$value] ) ) {
221 | $value = $sidebars[$value]['name'];
222 | } else {
223 | $value .= '
' . __( '(Not in use by current theme)', 'woosidebars' ) . '';
224 | }
225 | }
226 |
227 | echo $value;
228 | break;
229 |
230 | case 'condition':
231 | $value = '';
232 |
233 | if ( isset( $meta['_condition'] ) && ( $meta['_condition'][0] != '' ) ) {
234 | foreach ( $meta['_condition'] as $k => $v ) {
235 | $value .= $this->multidimensional_search( $v, $this->conditions->conditions_reference ) . '
' . "\n";
236 | }
237 | }
238 |
239 | echo $value;
240 | break;
241 |
242 | default:
243 | break;
244 |
245 | }
246 | } // End register_custom_columns()
247 |
248 | /**
249 | * register_custom_column_headings function.
250 | *
251 | * @access public
252 | * @param array $defaults
253 | * @return void
254 | */
255 | public function register_custom_column_headings ( $defaults ) {
256 | $this->conditions->setup_default_conditions_reference();
257 |
258 | $new_columns = array( 'sidebar_to_replace' => __( 'Sidebar To Replace', 'woosidebars' ), 'condition' => __( 'Condition(s)', 'woosidebars' ) );
259 |
260 | $last_item = '';
261 |
262 | if ( isset( $defaults['date'] ) ) { unset( $defaults['date'] ); }
263 |
264 | if ( count( $defaults ) > 2 ) {
265 | $last_item = array_slice( $defaults, -1 );
266 |
267 | array_pop( $defaults );
268 | }
269 | $defaults = array_merge( $defaults, $new_columns );
270 |
271 | if ( $last_item != '' ) {
272 | foreach ( $last_item as $k => $v ) {
273 | $defaults[$k] = $v;
274 | break;
275 | }
276 | }
277 |
278 | return $defaults;
279 | } // End register_custom_column_headings()
280 |
281 | /**
282 | * meta_box_setup function.
283 | *
284 | * @access public
285 | * @return void
286 | */
287 | public function meta_box_setup () {
288 | add_meta_box( 'sidebar-to-replace', __( 'Sidebar To Replace', 'woosidebars' ), array( $this, 'meta_box_content' ), $this->token, 'side', 'low' );
289 |
290 | // Remove "Custom Settings" meta box.
291 | remove_meta_box( 'woothemes-settings', 'sidebar', 'normal' );
292 |
293 | // Customise the "Excerpt" meta box for the sidebars.
294 | remove_meta_box( 'postexcerpt', $this->token, 'normal' );
295 | add_meta_box( 'sidebar-description', __( 'Description', 'woosidebars' ), array( $this, 'description_meta_box' ), $this->token, 'normal', 'core' );
296 | } // End meta_box_setup()
297 |
298 | /**
299 | * meta_box_content function.
300 | *
301 | * @access public
302 | * @return void
303 | */
304 | public function meta_box_content () {
305 | global $post_id;
306 |
307 | $sidebars = $this->get_registered_sidebars();
308 |
309 | $selected_sidebar = get_post_meta( $post_id, '_sidebar_to_replace', true );
310 |
311 | $html = '';
312 |
313 | $html .= '
';
314 |
315 | if ( count( $sidebars ) > 0 ) {
316 | $html .= '
' . "\n";
321 | } else {
322 | $html .= '
' . __( 'No sidebars are available with this theme.', 'woosidebars' ) . '
';
323 | }
324 |
325 | echo $html;
326 |
327 | } // End meta_box_content()
328 |
329 | /**
330 | * meta_box_save function.
331 | *
332 | * @access public
333 | * @param int $post_id
334 | * @return void
335 | */
336 | public function meta_box_save ( $post_id ) {
337 | global $post, $messages;
338 |
339 | // Verify
340 | if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename( __FILE__ ) ) ) {
341 | return $post_id;
342 | }
343 |
344 | if ( 'page' == $_POST['post_type'] ) {
345 | if ( ! current_user_can( 'edit_page', $post_id ) ) {
346 | return $post_id;
347 | }
348 | } else {
349 | if ( ! current_user_can( 'edit_post', $post_id ) ) {
350 | return $post_id;
351 | }
352 | }
353 |
354 | $fields = array( 'sidebar_to_replace' );
355 |
356 | foreach ( $fields as $f ) {
357 |
358 | ${$f} = strip_tags(trim($_POST[$f]));
359 |
360 | if ( get_post_meta( $post_id, '_' . $f ) == '' ) {
361 | add_post_meta( $post_id, '_' . $f, ${$f}, true );
362 | } elseif( ${$f} != get_post_meta( $post_id, '_' . $f, true ) ) {
363 | update_post_meta( $post_id, '_' . $f, ${$f} );
364 | } elseif ( ${$f} == '' ) {
365 | delete_post_meta( $post_id, '_' . $f, get_post_meta( $post_id, '_' . $f, true ) );
366 | }
367 | }
368 | } // End meta_box_save()
369 |
370 | /**
371 | * description_meta_box function.
372 | *
373 | * @param object $post
374 | */
375 | public function description_meta_box ( $post ) {
376 | ?>
377 |
378 |
', '' ); ?>
379 | token ) {
391 | $title = __( 'Enter widget area name here', 'woosidebars' );
392 | }
393 | return $title;
394 | } // End enter_title_here()
395 |
396 | /**
397 | * update_messages function.
398 | *
399 | * @access public
400 | * @param array $messages
401 | * @return void
402 | */
403 | public function update_messages ( $messages ) {
404 | if ( get_post_type() != $this->token ) {
405 | return $messages;
406 | }
407 |
408 | $messages[$this->token][1] = __( 'Widget Area updated.', 'woosidebars' );
409 |
410 | return $messages;
411 | } // End update_messages()
412 |
413 | /**
414 | * get_registered_sidebars function.
415 | *
416 | * @access public
417 | * @return void
418 | */
419 | public function get_registered_sidebars () {
420 | global $wp_registered_sidebars;
421 |
422 | $sidebars = array();
423 | $to_ignore = array();
424 |
425 | $custom_sidebars = get_posts( array( 'post_type' => 'sidebar', 'numberposts' => intval( $this->upper_limit ), 'suppress_filters' => 'false' ) );
426 | if ( ! is_wp_error( $custom_sidebars ) && count( $custom_sidebars ) > 0 ) {
427 | foreach ( $custom_sidebars as $k => $v ) {
428 | $to_ignore[] = $v->post_name;
429 | }
430 | }
431 |
432 | if ( is_array( $wp_registered_sidebars ) && ( count( $wp_registered_sidebars ) > 0 ) ) {
433 | foreach ( $wp_registered_sidebars as $k => $v ) {
434 | if ( ! stristr( $v['id'], $this->prefix ) && ! stristr( $v['id'], 'woo_sbm_' ) && ! in_array( $v['id'], $to_ignore ) ) {
435 | $sidebars[$k] = $v;
436 | }
437 | }
438 | }
439 |
440 | return $sidebars;
441 | } // End get_registered_sidebars()
442 |
443 | /**
444 | * register_custom_sidebars function.
445 | *
446 | * @access public
447 | * @return void
448 | */
449 | public function register_custom_sidebars () {
450 | $sidebars = get_posts( array( 'post_type' => 'sidebar', 'posts_per_page' => intval( $this->upper_limit ), 'suppress_filters' => 'false' ) );
451 |
452 | if ( count( $sidebars ) > 0 ) {
453 | foreach ( $sidebars as $k => $v ) {
454 | $args = apply_filters( 'woosidebars_sidebar_args', array(
455 | 'name' => $v->post_title,
456 | 'id' => $v->post_name,
457 | 'description' => $v->post_excerpt,
458 | ), $v, $this );
459 | register_sidebar( $args );
460 | }
461 | }
462 | } // End register_custom_sidebars()
463 |
464 | /**
465 | * init_sidebar_replacement function.
466 | *
467 | * @access public
468 | * @return void
469 | */
470 | public function init_sidebar_replacement () {
471 | add_filter( 'sidebars_widgets', array( $this, 'replace_sidebars' ) );
472 | } // End init_sidebar_replacement()
473 |
474 | /**
475 | * replace_sidebars function.
476 | *
477 | * @access public
478 | * @param array $sidebars_widgets
479 | * @return void
480 | */
481 | public function replace_sidebars ( $sidebars_widgets ) {
482 | if ( is_admin() ) {
483 | return $sidebars_widgets;
484 | }
485 |
486 | // Determine the conditions to construct the query.
487 | $conditions = $this->conditions->conditions;
488 |
489 | if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
490 | return $sidebars_widgets;
491 | }
492 |
493 | global $woo_custom_sidebar_data;
494 |
495 | if ( ! isset( $woo_custom_sidebar_data ) ) {
496 |
497 | $conditions_str = join( ', ', $conditions );
498 |
499 | $args = array(
500 | 'post_type' => $this->token,
501 | 'posts_per_page' => intval( $this->upper_limit ),
502 | 'suppress_filters' => true
503 | );
504 |
505 | $meta_query = array(
506 | 'key' => '_sidebar_to_replace',
507 | 'compare' => '!=',
508 | 'value' => ''
509 | );
510 |
511 | $args['meta_query'][] = $meta_query;
512 |
513 | $meta_query = array(
514 | 'key' => '_condition',
515 | 'compare' => 'IN',
516 | 'value' => $conditions
517 | );
518 |
519 | $args['meta_query'][] = $meta_query;
520 |
521 | $sidebars = get_posts( $args );
522 |
523 | if ( count( $sidebars ) > 0 ) {
524 | foreach ( $sidebars as $k => $v ) {
525 |
526 | if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
527 | // get the post language
528 | $wpml_element = apply_filters( 'wpml_element_language_code', ICL_LANGUAGE_CODE, array( 'element_id' => intval( $v->ID ), 'element_type' => 'post_sidebar' ) );
529 | // check if the current language matches the language of the sidebar
530 | if ( $wpml_element != ICL_LANGUAGE_CODE ) {
531 | continue;
532 | }
533 | }
534 |
535 | $to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
536 | $sidebars[$k]->to_replace = $to_replace;
537 |
538 | $conditions = get_post_meta( $v->ID, '_condition', false );
539 |
540 | $sidebars[$k]->conditions = array();
541 |
542 | // Remove any irrelevant conditions from the array.
543 | if ( is_array( $conditions ) ) {
544 | foreach ( $conditions as $i => $j ) {
545 | if ( in_array( $j, $this->conditions->conditions ) ) {
546 | $sidebars[$k]->conditions[] = $j;
547 | }
548 | }
549 | }
550 |
551 | }
552 | }
553 |
554 | $woo_custom_sidebar_data = $sidebars;
555 | }
556 |
557 | // Make sure only the most appropriate sidebars are kept.
558 | // $woo_custom_sidebar_data = $this->remove_unwanted_sidebars( $woo_custom_sidebar_data );
559 | $woo_custom_sidebar_data = $this->find_best_sidebars( $woo_custom_sidebar_data );
560 |
561 | if ( count( $woo_custom_sidebar_data ) > 0 ) {
562 | foreach ( $woo_custom_sidebar_data as $k => $v ) {
563 | $sidebar_id = $v->post_name;
564 | // $sidebar_id = $this->prefix . $v->ID;
565 | if ( isset( $sidebars_widgets[$sidebar_id] ) && isset( $v->to_replace ) && $v->to_replace != '' ) {
566 | $widgets = $sidebars_widgets[$sidebar_id];
567 | unset( $sidebars_widgets[$sidebar_id] );
568 | $sidebars_widgets[$v->to_replace] = $widgets;
569 | }
570 | }
571 | }
572 |
573 | return $sidebars_widgets;
574 | } // End replace_sidebars()
575 |
576 | /**
577 | * find_best_sidebars function.
578 | *
579 | * @access public
580 | * @param array $sidebars
581 | * @return array $sorted_sidebars
582 | */
583 | public function find_best_sidebars ( $sidebars ) {
584 | $sorted_sidebars = array();
585 |
586 | if ( ! isset( $this->conditions->conditions ) || count( $this->conditions->conditions ) <= 0 ) {
587 | return $sidebars;
588 | }
589 |
590 | // Keep track of each sidebar we'd like to replace widgets for.
591 | foreach ( $sidebars as $k => $v ) {
592 | if ( isset( $v->to_replace ) && ( $v->to_replace != '' ) && ! isset( $sorted_sidebars[$v->to_replace] ) ) {
593 | $sorted_sidebars[$v->to_replace] = '';
594 | }
595 | }
596 |
597 | foreach ( $sidebars as $k => $v ) {
598 | if ( isset( $sorted_sidebars[$v->to_replace] ) && ( $sorted_sidebars[$v->to_replace] == '' ) ) {
599 | $sorted_sidebars[$v->to_replace] = $v;
600 | } else {
601 | continue;
602 | }
603 | }
604 |
605 | return $sorted_sidebars;
606 | } // End find_best_sidebars()
607 |
608 | /**
609 | * enqueue_styles function.
610 | *
611 | * @access public
612 | * @return void
613 | */
614 | public function enqueue_styles () {
615 | global $pagenow;
616 |
617 | if ( in_array( $pagenow, array( 'edit.php', 'post.php', 'post-new.php' ) ) ) {
618 | if ( get_post_type() != $this->token ) { return; }
619 | wp_enqueue_style( 'jquery-ui-tabs' );
620 |
621 | wp_register_style( $this->token . '-admin', $this->assets_url . '/css/admin.css', array(), '1.0.0' );
622 | wp_enqueue_style( $this->token . '-admin' );
623 |
624 | wp_dequeue_style( 'jquery-ui-datepicker' );
625 |
626 | if ( class_exists( 'WPSEO_Metabox' ) ) {
627 | // Dequeue unused WordPress SEO CSS files.
628 | wp_dequeue_style( 'edit-page' );
629 | wp_dequeue_style( 'metabox-tabs' );
630 |
631 | $color = get_user_meta( get_current_user_id(), 'admin_color', true );
632 | if ( '' == $color ) $color = 'fresh';
633 |
634 | wp_dequeue_style( 'metabox-' . $color );
635 | }
636 | }
637 |
638 | if ( in_array( $pagenow, array( 'edit.php' ) ) ) {
639 | wp_register_style( $this->token . '-admin-posts', $this->assets_url . '/css/admin-posts.css', array(), '1.0.0' );
640 | wp_enqueue_style( $this->token . '-admin-posts' );
641 | }
642 | } // End enqueue_styles()
643 |
644 | /**
645 | * add_post_column_headings function.
646 | *
647 | * @access public
648 | * @param array $defaults
649 | * @return array $new_columns
650 | */
651 | public function add_post_column_headings ( $defaults ) {
652 | $defaults['woosidebars_enable'] = __( 'Custom Sidebars', 'woosidebars' );
653 | return $defaults;
654 | } // End add_post_column_headings()
655 |
656 | /**
657 | * add_post_column_data function.
658 | *
659 | * @access public
660 | * @param string $column_name
661 | * @param int $id
662 | * @return void
663 | */
664 | public function add_post_column_data ( $column_name, $id ) {
665 | global $wpdb, $post;
666 | $meta = get_post_custom( $id );
667 |
668 | switch ( $column_name ) {
669 | case 'woosidebars_enable':
670 | $image = 'success-off';
671 | $value = '';
672 | $class = 'custom-sidebars-disabled';
673 |
674 | if ( isset( $meta['_enable_sidebar'] ) && ( $meta['_enable_sidebar'][0] != '' ) && ( $meta['_enable_sidebar'][0] == 'yes' ) ) {
675 | $image = 'success';
676 | $class = 'custom-sidebars-enabled';
677 | }
678 |
679 | $url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woosidebars-post-enable&post_id=' . $post->ID ), 'woosidebars-post-enable' );
680 | $value = '
 . ')
';
681 |
682 | echo $value;
683 | break;
684 |
685 | default:
686 | break;
687 | }
688 | } // End add_post_column_data()
689 |
690 | /**
691 | * enable_custom_post_sidebars function.
692 | *
693 | * @access public
694 | * @return void
695 | */
696 | public function enable_custom_post_sidebars () {
697 | if( ! is_admin() ) die;
698 | if( ! current_user_can( 'edit_posts' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.', 'woosidebars' ) );
699 | if( ! check_admin_referer( 'woosidebars-post-enable' ) ) wp_die( __( 'You have taken too long. Please go back and retry.', 'woosidebars' ) );
700 |
701 | $post_id = isset( $_GET['post_id'] ) && (int)$_GET['post_id'] ? (int)$_GET['post_id'] : '';
702 |
703 | if( ! $post_id ) die;
704 |
705 | $post = get_post( $post_id );
706 | if( ! $post ) die;
707 |
708 | $meta = get_post_meta( $post->ID, '_enable_sidebar', true );
709 |
710 | if ( $meta == 'yes' ) {
711 | update_post_meta($post->ID, '_enable_sidebar', 'no' );
712 | } else {
713 | update_post_meta($post->ID, '_enable_sidebar', 'yes' );
714 | }
715 |
716 | $sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
717 | wp_safe_redirect( esc_url( $sendback ) );
718 | } // End enable_custom_post_sidebars()
719 |
720 | /**
721 | * multidimensional_search function.
722 | *
723 | * @access public
724 | * @param string $needle
725 | * @param array $haystack
726 | * @return string $m
727 | */
728 | public function multidimensional_search ( $needle, $haystack ) {
729 | if (empty( $needle ) || empty( $haystack ) ) {
730 | return false;
731 | }
732 |
733 | foreach ( $haystack as $key => $value ) {
734 | $exists = 0;
735 | foreach ( (array)$needle as $nkey => $nvalue) {
736 | if ( ! empty( $value[$nvalue] ) && is_array( $value[$nvalue] ) ) {
737 | return $value[$nvalue]['label'];
738 | }
739 | }
740 | }
741 |
742 | return false;
743 | } // End multidimensional_search()
744 |
745 | /**
746 | * load_localisation function.
747 | *
748 | * @access public
749 | * @since 1.0.0
750 | * @return void
751 | */
752 | public function load_localisation () {
753 | $lang_dir = trailingslashit( str_replace( 'classes', 'lang', plugin_basename( dirname(__FILE__) ) ) );
754 | load_plugin_textdomain( 'woosidebars', false, $lang_dir );
755 | } // End load_localisation()
756 |
757 | /**
758 | * activation function.
759 | *
760 | * @access public
761 | * @since 1.0.0
762 | * @return void
763 | */
764 | public function activation () {
765 | $this->register_plugin_version();
766 | } // End activation()
767 |
768 | /**
769 | * register_plugin_version function.
770 | *
771 | * @access public
772 | * @since 1.0.0
773 | * @return void
774 | */
775 | public function register_plugin_version () {
776 | if ( $this->version != '' ) {
777 | update_option( 'woosidebars' . '-version', $this->version );
778 | }
779 | } // End register_plugin_version()
780 | } // End Class
781 | ?>
782 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/integrations/integration-woocommerce.php:
--------------------------------------------------------------------------------
1 | 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.pot:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2015 WooSidebars
2 | # This file is distributed under the same license as the WooSidebars package.
3 | msgid ""
4 | msgstr ""
5 | "Project-Id-Version: WooSidebars 1.4.2\n"
6 | "Report-Msgid-Bugs-To: http://wordpress.org/tag/woosidebars\n"
7 | "POT-Creation-Date: 2015-09-22 07:53:22+00:00\n"
8 | "MIME-Version: 1.0\n"
9 | "Content-Type: text/plain; charset=UTF-8\n"
10 | "Content-Transfer-Encoding: 8bit\n"
11 | "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
12 | "Last-Translator: FULL NAME
\n"
13 | "Language-Team: LANGUAGE \n"
14 |
15 | #: classes/class-woo-conditions.php:57
16 | msgid "Conditions"
17 | msgstr ""
18 |
19 | #: classes/class-woo-conditions.php:127 classes/class-woo-conditions.php:299
20 | msgid "Pages"
21 | msgstr ""
22 |
23 | #: classes/class-woo-conditions.php:138
24 | msgid "The \"%s\" page"
25 | msgstr ""
26 |
27 | #: classes/class-woo-conditions.php:201
28 | msgid "A custom sidebar for \"%s\""
29 | msgstr ""
30 |
31 | #: classes/class-woo-conditions.php:214
32 | msgid "Page Templates"
33 | msgstr ""
34 |
35 | #: classes/class-woo-conditions.php:220
36 | msgid "The \"%s\" page template"
37 | msgstr ""
38 |
39 | #: classes/class-woo-conditions.php:230
40 | msgid "Post Types"
41 | msgstr ""
42 |
43 | #: classes/class-woo-conditions.php:237
44 | msgid "\"%s\" Post Type Archive"
45 | msgstr ""
46 |
47 | #: classes/class-woo-conditions.php:238
48 | msgid "The \"%s\" post type archive"
49 | msgstr ""
50 |
51 | #: classes/class-woo-conditions.php:246
52 | msgid "Each Individual %s"
53 | msgstr ""
54 |
55 | #: classes/class-woo-conditions.php:247
56 | msgid "Entries in the \"%s\" post type"
57 | msgstr ""
58 |
59 | #: classes/class-woo-conditions.php:264
60 | msgid "Taxonomy Archives"
61 | msgstr ""
62 |
63 | #: classes/class-woo-conditions.php:272
64 | msgid "The default \"%s\" archives"
65 | msgstr ""
66 |
67 | #: classes/class-woo-conditions.php:281
68 | msgid "The %s %s archive"
69 | msgstr ""
70 |
71 | #: classes/class-woo-conditions.php:283
72 | msgid "All posts in \"%s\""
73 | msgstr ""
74 |
75 | #: classes/class-woo-conditions.php:283
76 | msgid "All posts in the %s %s archive"
77 | msgstr ""
78 |
79 | #: classes/class-woo-conditions.php:286
80 | msgid "All posts tagged \"%s\""
81 | msgstr ""
82 |
83 | #: classes/class-woo-conditions.php:286
84 | msgid "All posts tagged %s"
85 | msgstr ""
86 |
87 | #: classes/class-woo-conditions.php:295
88 | msgid "Template Hierarchy"
89 | msgstr ""
90 |
91 | #: classes/class-woo-conditions.php:300
92 | msgid "Displayed on all pages that don't have a more specific widget area."
93 | msgstr ""
94 |
95 | #: classes/class-woo-conditions.php:304
96 | msgid "Search Results"
97 | msgstr ""
98 |
99 | #: classes/class-woo-conditions.php:305
100 | msgid "Displayed on search results screens."
101 | msgstr ""
102 |
103 | #: classes/class-woo-conditions.php:309
104 | msgid "Default \"Your Latest Posts\" Screen"
105 | msgstr ""
106 |
107 | #: classes/class-woo-conditions.php:310
108 | msgid "Displayed on the default \"Your Latest Posts\" screen."
109 | msgstr ""
110 |
111 | #: classes/class-woo-conditions.php:314
112 | msgid "Front Page"
113 | msgstr ""
114 |
115 | #: classes/class-woo-conditions.php:315
116 | msgid "Displayed on any front page, regardless of the settings under the \"Settings -> Reading\" admin screen."
117 | msgstr ""
118 |
119 | #: classes/class-woo-conditions.php:319
120 | msgid "Single Entries"
121 | msgstr ""
122 |
123 | #: classes/class-woo-conditions.php:320
124 | msgid "Displayed on single entries of any public post type other than \"Pages\"."
125 | msgstr ""
126 |
127 | #: classes/class-woo-conditions.php:324
128 | msgid "All Archives"
129 | msgstr ""
130 |
131 | #: classes/class-woo-conditions.php:325
132 | msgid "Displayed on all archives (category, tag, taxonomy, post type, dated, author and search)."
133 | msgstr ""
134 |
135 | #: classes/class-woo-conditions.php:329
136 | msgid "Author Archives"
137 | msgstr ""
138 |
139 | #: classes/class-woo-conditions.php:330
140 | msgid "Displayed on all author archive screens (that don't have a more specific sidebar)."
141 | msgstr ""
142 |
143 | #: classes/class-woo-conditions.php:334
144 | msgid "Date Archives"
145 | msgstr ""
146 |
147 | #: classes/class-woo-conditions.php:335
148 | msgid "Displayed on all date archives."
149 | msgstr ""
150 |
151 | #: classes/class-woo-conditions.php:339
152 | msgid "404 Error Screens"
153 | msgstr ""
154 |
155 | #: classes/class-woo-conditions.php:340
156 | msgid "Displayed on all 404 error screens."
157 | msgstr ""
158 |
159 | #: classes/class-woo-conditions.php:565
160 | msgid "Taxonomy Terms"
161 | msgstr ""
162 |
163 | #: classes/class-woo-conditions.php:574
164 | msgid "Advanced"
165 | msgstr ""
166 |
167 | #: classes/class-woo-conditions.php:624
168 | msgid "Taxonomy Token"
169 | msgstr ""
170 |
171 | #: classes/class-woo-sidebars.php:156
172 | msgid "Widget Area"
173 | msgstr ""
174 |
175 | #: classes/class-woo-sidebars.php:157 classes/class-woo-sidebars.php:170
176 | msgid "Widget Areas"
177 | msgstr ""
178 |
179 | #: classes/class-woo-sidebars.php:164
180 | msgctxt "post type general name"
181 | msgid "Widget Areas"
182 | msgstr ""
183 |
184 | #: classes/class-woo-sidebars.php:165
185 | msgctxt "post type singular name"
186 | msgid "Widget Area"
187 | msgstr ""
188 |
189 | #: classes/class-woo-sidebars.php:166
190 | msgctxt "Widget Area"
191 | msgid "Add New"
192 | msgstr ""
193 |
194 | #: classes/class-woo-sidebars.php:167
195 | msgid "Add New %s"
196 | msgstr ""
197 |
198 | #: classes/class-woo-sidebars.php:168
199 | msgid "Edit %s"
200 | msgstr ""
201 |
202 | #: classes/class-woo-sidebars.php:169
203 | msgid "New %s"
204 | msgstr ""
205 |
206 | #: classes/class-woo-sidebars.php:171
207 | msgid "View %s"
208 | msgstr ""
209 |
210 | #: classes/class-woo-sidebars.php:172
211 | msgid "Search %a"
212 | msgstr ""
213 |
214 | #: classes/class-woo-sidebars.php:173
215 | msgid "No %s Found"
216 | msgstr ""
217 |
218 | #: classes/class-woo-sidebars.php:174
219 | msgid "No %s Found In Trash"
220 | msgstr ""
221 |
222 | #: classes/class-woo-sidebars.php:225
223 | msgid "(Not in use by current theme)"
224 | msgstr ""
225 |
226 | #: classes/class-woo-sidebars.php:260 classes/class-woo-sidebars.php:290
227 | msgid "Sidebar To Replace"
228 | msgstr ""
229 |
230 | #: classes/class-woo-sidebars.php:260
231 | msgid "Condition(s)"
232 | msgstr ""
233 |
234 | #: classes/class-woo-sidebars.php:297 classes/class-woo-sidebars.php:379
235 | msgid "Description"
236 | msgstr ""
237 |
238 | #: classes/class-woo-sidebars.php:324
239 | msgid "No sidebars are available with this theme."
240 | msgstr ""
241 |
242 | #: classes/class-woo-sidebars.php:380
243 | msgid "Add an optional description, to be displayed when adding widgets to this widget area on the %sWidgets%s screen."
244 | msgstr ""
245 |
246 | #: classes/class-woo-sidebars.php:393
247 | msgid "Enter widget area name here"
248 | msgstr ""
249 |
250 | #: classes/class-woo-sidebars.php:410
251 | msgid "Widget Area updated."
252 | msgstr ""
253 |
254 | #: classes/class-woo-sidebars.php:641
255 | msgid "Custom Sidebars"
256 | msgstr ""
257 |
258 | #: classes/class-woo-sidebars.php:687
259 | msgid "You do not have sufficient permissions to access this page."
260 | msgstr ""
261 |
262 | #: classes/class-woo-sidebars.php:688
263 | msgid "You have taken too long. Please go back and retry."
264 | msgstr ""
265 |
266 | #: classes/class-woo-sidebars.php:747
267 | msgid "Overview"
268 | msgstr ""
269 |
270 | #: classes/class-woo-sidebars.php:749
271 | msgid "All custom widget areas are listed on this screen. To add a new customised widget area, click the \"Add New\" button."
272 | msgstr ""
273 |
274 | #: classes/class-woo-sidebars.php:753
275 | msgid "Sidebar Manager"
276 | msgstr ""
277 |
278 | #: classes/class-woo-sidebars.php:755
279 | 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."
280 | msgstr ""
281 |
282 | #: classes/class-woo-sidebars.php:756
283 | msgid "To transfer a sidebar from the Sidebar Manager:"
284 | msgstr ""
285 |
286 | #: classes/class-woo-sidebars.php:758
287 | msgid "Create a new custom widget area in WooSidebars."
288 | msgstr ""
289 |
290 | #: classes/class-woo-sidebars.php:759
291 | msgid "Visit the %sAppearance → Widgets%s screen and drag the widgets from the old sidebar into the newly created sidebar."
292 | msgstr ""
293 |
294 | #: classes/class-woo-sidebars.php:760
295 | msgid "Repeat this process for each of your custom sidebars, including dependencies if necessary (the WooSidebars conditions system replaces the need for dependencies)."
296 | msgstr ""
297 |
298 | #: classes/class-woo-sidebars.php:761
299 | 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)."
300 | msgstr ""
301 |
302 | #: classes/class-woo-sidebars.php:766
303 | msgid "For more information:"
304 | msgstr ""
305 |
306 | #: classes/class-woo-sidebars.php:767
307 | msgid "Support HelpDesk"
308 | msgstr ""
309 |
310 | #: classes/class-woo-sidebars.php:768
311 | msgid "WooSidebars Documentation"
312 | msgstr ""
313 |
314 | #: integrations/integration-woocommerce.php:73
315 | msgid "WooCommerce"
316 | msgstr ""
317 |
318 | #: integrations/integration-woocommerce.php:88
319 | msgid "Shop Page"
320 | msgstr ""
321 |
322 | #: integrations/integration-woocommerce.php:89
323 | msgid "The WooCommerce \"Shop\" landing page"
324 | msgstr ""
325 |
326 | #: integrations/integration-woocommerce.php:93
327 | msgid "Product Categories"
328 | msgstr ""
329 |
330 | #: integrations/integration-woocommerce.php:94
331 | msgid "All product categories"
332 | msgstr ""
333 |
334 | #: integrations/integration-woocommerce.php:98
335 | msgid "Product Tags"
336 | msgstr ""
337 |
338 | #: integrations/integration-woocommerce.php:99
339 | msgid "All product tags"
340 | msgstr ""
341 |
342 | #: integrations/integration-woocommerce.php:103
343 | msgid "Products"
344 | msgstr ""
345 |
346 | #: integrations/integration-woocommerce.php:104
347 | msgid "All products"
348 | msgstr ""
349 |
350 | #: integrations/integration-woocommerce.php:108
351 | msgid "Cart Page"
352 | msgstr ""
353 |
354 | #: integrations/integration-woocommerce.php:109
355 | msgid "The WooCommerce \"Cart\" page"
356 | msgstr ""
357 |
358 | #: integrations/integration-woocommerce.php:113
359 | msgid "Checkout Page"
360 | msgstr ""
361 |
362 | #: integrations/integration-woocommerce.php:114
363 | msgid "The WooCommerce \"Checkout\" page"
364 | msgstr ""
365 |
366 | #: integrations/integration-woocommerce.php:118
367 | msgid "Account Pages"
368 | msgstr ""
369 |
370 | #: integrations/integration-woocommerce.php:119
371 | msgid "The WooCommerce \"Account\" pages"
372 | msgstr ""
373 |
374 | #: integrations/integration-woocommerce.php:124
375 | msgid "Products in the \"%s\" category"
376 | msgstr ""
377 |
378 | #: integrations/integration-woocommerce.php:125
379 | msgid "Products tagged \"%s\""
380 | msgstr ""
381 | #. Plugin Name of the plugin/theme
382 | msgid "WooSidebars"
383 | msgstr ""
384 |
385 | #. Plugin URI of the plugin/theme
386 | msgid "http://woothemes.com/woosidebars/"
387 | msgstr ""
388 |
389 | #. Description of the plugin/theme
390 | msgid "Replace widget areas in your theme for specific pages, archives and other sections of WordPress."
391 | msgstr ""
392 |
393 | #. Author of the plugin/theme
394 | msgid "WooThemes"
395 | msgstr ""
396 |
397 | #. Author URI of the plugin/theme
398 | msgid "http://woothemes.com/"
399 | msgstr ""
400 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === WooSidebars ===
2 | Contributors: woothemes, Automattic, mattyza
3 | Tags: widgets, sidebars, widget-areas
4 | Requires at least: 4.1
5 | Tested up to: 5.8.3
6 | Stable tag: 1.4.6
7 | License: GPLv3 or later
8 | License URI: http://www.gnu.org/licenses/gpl-3.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 | Looking for a helping hand? [View plugin documentation](https://woocommerce.com/documentation/plugins/woosidebars/).
17 |
18 | Looking to contribute code to this plugin? [Fork the repository over at GitHub](https://github.com/woocommerce/woosidebars/). Please also read the CONTRIBUTING.md file, bundled within this plugin.
19 |
20 | == Installation ==
21 |
22 | = Minimum Requirements =
23 |
24 | * WordPress 3.3 or greater
25 | * PHP version 5.2.4 or greater
26 | * MySQL version 5.0 or greater
27 |
28 | = Automatic installation =
29 |
30 | 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.
31 |
32 | 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 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.
33 |
34 | = Manual installation =
35 |
36 | The manual installation method involves downloading WooSidebars and uploading it to your webserver via your favourite FTP application.
37 |
38 | 1. Download the plugin file to your computer and unzip it
39 | 2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installation’s wp-content/plugins/ directory.
40 | 3. Activate the plugin from the Plugins menu within the WordPress admin.
41 |
42 | = Where to go after installation =
43 |
44 | Once WooSidebars has been installed and activated, please visit the "Appearance -> Widget Areas" screen to begin adding custom widget areas.
45 |
46 | = Upgrading =
47 |
48 | Automatic updates should work a charm; as always though, ensure you backup your site just in case.
49 |
50 | == Frequently Asked Questions ==
51 |
52 | = Where can I find WooSidebars documentation and user guides? =
53 |
54 | For further documentation on using WooSidebars, please view the [WooSidebars Documentation](https://woocommerce.com/documentation/plugins/woosidebars/).
55 |
56 | = Will WooSidebars work with my theme? =
57 |
58 | Yes; WooSidebars will work with any theme that supports dynamic widget areas.
59 |
60 | = How can I contribute to WooSidebars development? =
61 |
62 | Looking to contribute code to this plugin? [Fork the repository over at GitHub](https://github.com/woocommerce/woosidebars/).
63 | (submit pull requests to the "develop" branch)
64 |
65 | == Screenshots ==
66 |
67 | 1. The list of custom widget areas.
68 | 2. Adding a custom widget area.
69 |
70 | == Upgrade Notice ==
71 |
72 | = 1.4.6 =
73 | Fixes a sprintf modifier which was breaking WP Admin on sites running PHP8.
74 | Fixes alignment of the content of the "Taxanomy Terms" conditions tab in WP Admin.
75 |
76 | = 1.4.5 =
77 | Fixes a fatal error, by removing the no longer relevant contextual help.
78 |
79 | = 1.4.4 =
80 | Bug fix and maintenance release. Enables "pages and their children" as a widget area condition.
81 |
82 | = 1.4.3 =
83 | Bug fix and maintenance release.
84 |
85 | = 1.4.2 =
86 | Security Fix for XSS vulnerability
87 |
88 | = 1.4.1 =
89 | Fixes an error notice on the homepage, caused by the tag check logic.
90 |
91 | = 1.4.0 =
92 | WordPress 3.8 compatibility.
93 | Adds "posts tagged with" condition.
94 |
95 | = 1.3.1 =
96 | Bug fix to ensure multiple conditions save correctly.
97 |
98 | = 1.3.0 =
99 | Optimisation update.
100 |
101 | = 1.2.2 =
102 | "Widget Areas" menu is now only visible to users who can add/modify widgets.
103 |
104 | = 1.2.1 =
105 | Updated for WordPress 3.5+ compatibility. Adjusted "Advanced" tab logic. Fixed bug where "Template Hierarchy -> Pages" condition wasn't being applied correctly. Dequeue WordPress SEO admin stylesheets from the "Widget Areas" "Add" and "Edit" screens.
106 |
107 | = 1.2.0 =
108 | Moved to WordPress.org. Woo! Added scope to methods and properties where missing.
109 |
110 | == Changelog ==
111 |
112 | = 1.4.5 =
113 | * 2018-06-18
114 | * Fixes a fatal error, by removing the no longer relevant contextual help.
115 |
116 | = 1.4.4 =
117 | * 2018-06-08
118 | * Bug fix and maintenance release. Enables "pages and their children" as a widget area condition.
119 |
120 | = 1.4.3 =
121 | * 2015-09-22
122 | * Ensures condition headings are present before attempting to output in the conditions meta box.
123 |
124 | = 1.4.2 =
125 | * 2015-04-22
126 | * Security Fix for remove_query_arg vulnerability
127 |
128 | = 1.4.1 =
129 | * 2015-02-17
130 | * Fixes an error notice on the homepage, caused by the tag check logic.
131 |
132 | = 1.4.0 =
133 | * 2015-02-17
134 | * WordPress 3.8 compatibility.
135 | * Adds "posts tagged with" condition.
136 |
137 |
138 | = 1.3.1 =
139 | * 2013-08-13
140 | * Bug fix to ensure multiple conditions save correctly.
141 |
142 | = 1.3.0 =
143 | * 2013-08-12
144 | * Introduces woosidebars_upper_limit filter, used on all database queries, to control scaling.
145 | * Fixes several PHP notices for "undefined index".
146 | * Fixes "single" condition, where a small section of logic was missing for determining if the condition applied to the current screen being loaded.
147 | * Optimises admin-side JavaScript and CSS.
148 |
149 | = 1.2.2 =
150 | * 2013-03-08
151 | * Changes capability for displaying the menu to "edit_theme_options" in line with the "Widgets" menu capability.
152 |
153 | = 1.2.1 =
154 | * 2013-01-09
155 | * Updated admin JavaScript for WordPress 3.5+ compatibility. Moved "Advanced" tab outside of the tabs list.
156 | * Fixed bug with the "Template Hierarchy -> Pages" condition that wasn't applying.
157 | * When WordPress SEO is active, dequeue unused stylesheets on the "Widget Areas" "add" and "edit" screens.
158 |
159 | = 1.2.0 =
160 | * Renamed files according to standards naming convention.
161 | * Added scope to methods and properties where missing.
162 |
163 | = 1.1.2 =
164 | * Routine hardening and maintenance update. Fixed notice message in WooCommerce integration.
165 |
166 | = 1.1.1 =
167 | * Fix notice displayed on WooCommerce product pages from the WooSidebars integration.
168 |
169 | = 1.1.0 =
170 | * Initial WooCommerce integration.
171 |
172 | = 1.0.0 =
173 | * First release. Woo!
174 |
--------------------------------------------------------------------------------
/woosidebars.php:
--------------------------------------------------------------------------------
1 | version = '1.4.6';
34 | $woosidebars->init();
35 |
--------------------------------------------------------------------------------