Version Description
Bug fix and maintenance release. Enables "pages and their children" as a widget area condition.
Download this release
Release Info
| Developer | mattyza |
| Plugin | |
| Version | 1.4.4 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.3 to 1.4.4
- CONTRIBUTING.md +4 -4
- changelog.txt +4 -0
- classes/class-woo-conditions.php +184 -115
- classes/class-woo-sidebars.php +23 -10
- readme.txt +11 -4
- woosidebars.php +21 -18
CONTRIBUTING.md
CHANGED
|
@@ -6,11 +6,11 @@ When contributing please ensure you follow the guidelines below so that we can k
|
|
| 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 [
|
| 10 |
|
| 11 |
- Codeable: http://codeable.io/
|
| 12 |
- Tweaky: https://www.tweaky.com/
|
| 13 |
-
-
|
| 14 |
|
| 15 |
## Getting Started
|
| 16 |
|
|
@@ -35,5 +35,5 @@ At this point you're waiting on us to merge your pull request. We'll review all
|
|
| 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.
|
| 39 |
-
* [
|
| 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 |
|
| 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/)
|
changelog.txt
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
*** WooSidebars Changelog ***
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
2015.09.22 - version 1.4.3
|
| 4 |
* Fix - Ensures condition headings are present before attempting to output in the conditions meta box.
|
| 5 |
/classes/class-woo-conditions.php
|
| 1 |
*** WooSidebars Changelog ***
|
| 2 |
|
| 3 |
+
2018.06.08 - version 1.4.4
|
| 4 |
+
* New - Enable a widget area for "a page and it's children".
|
| 5 |
+
* Fix - Error notice when on a page without a defined screen_id.
|
| 6 |
+
|
| 7 |
2015.09.22 - version 1.4.3
|
| 8 |
* Fix - Ensures condition headings are present before attempting to output in the conditions meta box.
|
| 9 |
/classes/class-woo-conditions.php
|
classes/class-woo-conditions.php
CHANGED
|
@@ -116,8 +116,9 @@ class Woo_Conditions {
|
|
| 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
|
| 120 |
$conditions['pages'] = array();
|
|
|
|
| 121 |
|
| 122 |
$statuses_string = join( ',', array_keys( $post_statuses ) );
|
| 123 |
$pages = get_pages( array( 'post_status' => $statuses_string ) );
|
|
@@ -125,20 +126,31 @@ class Woo_Conditions {
|
|
| 125 |
if ( count( $pages ) > 0 ) {
|
| 126 |
|
| 127 |
$conditions_headings['pages'] = __( 'Pages', 'woosidebars' );
|
|
|
|
| 128 |
|
| 129 |
foreach ( $pages as $k => $v ) {
|
| 130 |
$token = 'post-' . $v->ID;
|
|
|
|
|
|
|
| 131 |
$label = esc_html( $v->post_title );
|
| 132 |
if ( 'publish' != $v->post_status ) {
|
| 133 |
$label .= ' (' . $post_statuses[$v->post_status] . ')';
|
| 134 |
}
|
| 135 |
|
| 136 |
$conditions['pages'][$token] = array(
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
}
|
| 141 |
|
|
|
|
| 142 |
}
|
| 143 |
|
| 144 |
$args = array(
|
|
@@ -274,7 +286,7 @@ class Woo_Conditions {
|
|
| 274 |
|
| 275 |
// Setup each individual taxonomy's terms as well.
|
| 276 |
$conditions_headings['taxonomy-' . $k] = $taxonomy->labels->name;
|
| 277 |
-
$terms = get_terms( $k );
|
| 278 |
if ( count( $terms ) > 0 ) {
|
| 279 |
$conditions['taxonomy-' . $k] = array();
|
| 280 |
foreach ( $terms as $i => $j ) {
|
|
@@ -340,14 +352,39 @@ class Woo_Conditions {
|
|
| 340 |
'description' => __( 'Displayed on all 404 error screens.', 'woosidebars' )
|
| 341 |
);
|
| 342 |
|
|
|
|
| 343 |
$this->conditions_reference = (array)apply_filters( 'woo_conditions_reference', $conditions );
|
| 344 |
$this->conditions_headings = (array)apply_filters( 'woo_conditions_headings', $conditions_headings );
|
| 345 |
} // End setup_default_conditions_reference()
|
| 346 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
/**
|
| 348 |
* is_hierarchy function.
|
| 349 |
*
|
| 350 |
-
* @description Is the current view a part of the default template
|
| 351 |
* @access public
|
| 352 |
* @return void
|
| 353 |
*/
|
|
@@ -400,18 +437,17 @@ class Woo_Conditions {
|
|
| 400 |
|
| 401 |
// Post-specific condition.
|
| 402 |
$this->conditions[] = 'post' . '-' . get_the_ID();
|
|
|
|
| 403 |
}
|
| 404 |
|
| 405 |
-
|
| 406 |
-
$this->conditions[] = 'search';
|
| 407 |
-
}
|
| 408 |
|
| 409 |
-
|
| 410 |
-
$this->conditions[] = '
|
| 411 |
}
|
| 412 |
|
| 413 |
-
if (
|
| 414 |
-
$this->conditions[] = '
|
| 415 |
}
|
| 416 |
|
| 417 |
if ( is_archive() ) {
|
|
@@ -523,149 +559,182 @@ class Woo_Conditions {
|
|
| 523 |
|
| 524 |
if ( count( $this->conditions_reference ) > 0 ) {
|
| 525 |
|
| 526 |
-
// Separate out the taxonomy items for use as sub-tabs of "Taxonomy Terms"
|
| 527 |
$taxonomy_terms = array();
|
|
|
|
|
|
|
| 528 |
|
| 529 |
foreach ( $this->conditions_reference as $k => $v ) {
|
| 530 |
if ( substr( $k, 0, 9 ) == 'taxonomy-' ) {
|
| 531 |
$taxonomy_terms[$k] = $v;
|
| 532 |
unset( $this->conditions_reference[$k] );
|
| 533 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
}
|
| 535 |
|
| 536 |
$html .= '<div id="taxonomy-category" class="categorydiv tabs woo-conditions">' . "\n";
|
| 537 |
|
| 538 |
-
|
| 539 |
|
| 540 |
-
|
| 541 |
|
| 542 |
-
|
| 543 |
-
$show_advanced = $this->show_advanced_items();
|
| 544 |
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
$class = '';
|
| 548 |
-
if ( $count == 1 ) {
|
| 549 |
-
$class = 'tabs';
|
| 550 |
-
} else {
|
| 551 |
-
$class = 'hide-if-no-js';
|
| 552 |
-
}
|
| 553 |
-
if ( in_array( $k, array( 'pages' ) ) ) {
|
| 554 |
-
$class .= ' basic';
|
| 555 |
-
} else {
|
| 556 |
-
$class .= ' advanced';
|
| 557 |
-
if ( ! $show_advanced ) { $class .= ' hide'; }
|
| 558 |
-
}
|
| 559 |
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
}
|
| 563 |
|
| 564 |
-
|
| 565 |
-
$html .= '<li class="' . esc_attr( $class ) . '"><a href="#tab-taxonomy-terms">' . __( 'Taxonomy Terms', 'woosidebars' ) . '</a></li>' . "\n";
|
| 566 |
-
}
|
| 567 |
-
}
|
| 568 |
|
| 569 |
-
|
| 570 |
-
|
| 571 |
|
| 572 |
-
|
|
|
|
| 573 |
|
| 574 |
-
|
| 575 |
|
| 576 |
-
|
| 577 |
-
|
| 578 |
|
| 579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
}
|
| 585 |
-
$tab .= '<ul class="alignleft conditions-column">' . "\n";
|
| 586 |
-
foreach ( $v as $i => $j ) {
|
| 587 |
-
$count++;
|
| 588 |
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
$tab .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '"><input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . $i . '"' . $checked . ' /> ' . esc_html( $j['label'] ) . '</label></li>' . "\n";
|
| 594 |
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
}
|
| 598 |
-
}
|
| 599 |
|
| 600 |
-
|
| 601 |
-
// Filter the contents of the current tab.
|
| 602 |
-
$tab = apply_filters( 'woo_conditions_tab_' . esc_attr( $k ), $tab );
|
| 603 |
-
$html .= $tab;
|
| 604 |
-
$html .= '<div class="clear"></div>';
|
| 605 |
-
$html .= '</div>' . "\n";
|
| 606 |
-
}
|
| 607 |
|
| 608 |
-
|
| 609 |
-
$html .= '<div id="tab-taxonomy-terms" class="condition-tab inner-tabs">' . "\n";
|
| 610 |
-
$html .= '<ul class="conditions-tabs-inner hide-if-no-js">' . "\n";
|
| 611 |
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
}
|
| 615 |
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
$count++;
|
| 619 |
-
$class = '';
|
| 620 |
-
if ( $count == 1 ) {
|
| 621 |
-
$class = 'tabs';
|
| 622 |
-
} else {
|
| 623 |
-
$class = 'hide-if-no-js';
|
| 624 |
-
}
|
| 625 |
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
}
|
|
|
|
| 632 |
|
| 633 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 634 |
|
| 635 |
-
|
| 636 |
-
|
|
|
|
|
|
|
| 637 |
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
|
|
|
|
|
|
| 643 |
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
$checked = ' checked="checked"';
|
| 647 |
-
}
|
| 648 |
-
$html .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '"><input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . esc_attr( $i ) . '"' . $checked . ' /> ' . esc_html( $j['label'] ) . '</label></li>' . "\n";
|
| 649 |
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 658 |
}
|
| 659 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 660 |
}
|
| 661 |
|
| 662 |
-
|
| 663 |
-
do_action( 'woo_conditions_meta_box', $k, $v );
|
| 664 |
|
| 665 |
-
$
|
|
|
|
| 666 |
|
| 667 |
-
|
| 668 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
|
| 670 |
/**
|
| 671 |
* meta_box_save function.
|
| 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 ) );
|
| 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(
|
| 286 |
|
| 287 |
// Setup each individual taxonomy's terms as well.
|
| 288 |
$conditions_headings['taxonomy-' . $k] = $taxonomy->labels->name;
|
| 289 |
+
$terms = get_terms( array( 'taxonomy' => $k, 'hide_empty' => false ) );
|
| 290 |
if ( count( $terms ) > 0 ) {
|
| 291 |
$conditions['taxonomy-' . $k] = array();
|
| 292 |
foreach ( $terms as $i => $j ) {
|
| 352 |
'description' => __( 'Displayed on all 404 error screens.', 'woosidebars' )
|
| 353 |
);
|
| 354 |
|
| 355 |
+
|
| 356 |
$this->conditions_reference = (array)apply_filters( 'woo_conditions_reference', $conditions );
|
| 357 |
$this->conditions_headings = (array)apply_filters( 'woo_conditions_headings', $conditions_headings );
|
| 358 |
} // End setup_default_conditions_reference()
|
| 359 |
|
| 360 |
+
|
| 361 |
+
private function add_depth( $conditions ) {
|
| 362 |
+
$map = array();
|
| 363 |
+
$depth = array();
|
| 364 |
+
foreach ( $conditions as $condition ) {
|
| 365 |
+
$map[ $condition['ID'] ] = $condition['parent'];
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
foreach ( $map as $id => $parent ) {
|
| 369 |
+
$d = 0;
|
| 370 |
+
while ( 0 != $parent ) {
|
| 371 |
+
$d++;
|
| 372 |
+
$parent = $map[$parent];
|
| 373 |
+
}
|
| 374 |
+
$depth[$id] = $d;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
foreach ( $conditions as $key => $condition ) {
|
| 378 |
+
$conditions[ $key ]['depth'] = $depth[ $condition['ID'] ];
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
return $conditions;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
/**
|
| 385 |
* is_hierarchy function.
|
| 386 |
*
|
| 387 |
+
* @description Is the current view a part of the default template hierarchy?
|
| 388 |
* @access public
|
| 389 |
* @return void
|
| 390 |
*/
|
| 437 |
|
| 438 |
// Post-specific condition.
|
| 439 |
$this->conditions[] = 'post' . '-' . get_the_ID();
|
| 440 |
+
$this->conditions[] = 'postwc' . '-' . get_the_ID();
|
| 441 |
}
|
| 442 |
|
| 443 |
+
$ancestors = get_post_ancestors( get_the_ID() );
|
|
|
|
|
|
|
| 444 |
|
| 445 |
+
foreach ( $ancestors as $ancestor ) {
|
| 446 |
+
$this->conditions[] = 'postwc-' . $ancestor;
|
| 447 |
}
|
| 448 |
|
| 449 |
+
if ( is_search() ) {
|
| 450 |
+
$this->conditions[] = 'search';
|
| 451 |
}
|
| 452 |
|
| 453 |
if ( is_archive() ) {
|
| 559 |
|
| 560 |
if ( count( $this->conditions_reference ) > 0 ) {
|
| 561 |
|
| 562 |
+
// Separate out the taxonomy items and pages with children for use as sub-tabs of "Taxonomy Terms" and hierarchical presentation of pages
|
| 563 |
$taxonomy_terms = array();
|
| 564 |
+
$pwc = array();
|
| 565 |
+
|
| 566 |
|
| 567 |
foreach ( $this->conditions_reference as $k => $v ) {
|
| 568 |
if ( substr( $k, 0, 9 ) == 'taxonomy-' ) {
|
| 569 |
$taxonomy_terms[$k] = $v;
|
| 570 |
unset( $this->conditions_reference[$k] );
|
| 571 |
}
|
| 572 |
+
|
| 573 |
+
if ( 'pages_with_children' === $k ) {
|
| 574 |
+
$pwc[$k] = $v;
|
| 575 |
+
// unset( $this->conditions_reference[$k] );
|
| 576 |
+
}
|
| 577 |
}
|
| 578 |
|
| 579 |
$html .= '<div id="taxonomy-category" class="categorydiv tabs woo-conditions">' . "\n";
|
| 580 |
|
| 581 |
+
$html .= $this->render_tabs( $selected_conditions );
|
| 582 |
|
| 583 |
+
$html .= $this->render_standard_pages( $selected_conditions );
|
| 584 |
|
| 585 |
+
$html .= $this->render_taxonomy_terms_tabs( $taxonomy_terms, $selected_conditions );
|
|
|
|
| 586 |
|
| 587 |
+
$html .= '</div>' . "\n";
|
| 588 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 589 |
|
| 590 |
+
// Allow themes/plugins to act here (key, args).
|
| 591 |
+
do_action( 'woo_conditions_meta_box', $k, $v );
|
|
|
|
| 592 |
|
| 593 |
+
$html .= '<br class="clear" />' . "\n";
|
|
|
|
|
|
|
|
|
|
| 594 |
|
| 595 |
+
echo $html;
|
| 596 |
+
} // End meta_box_content()
|
| 597 |
|
| 598 |
+
private function render_tabs( $selected_conditions ) {
|
| 599 |
+
$html = '<ul id="category-tabs" class="conditions-tabs alignleft">' . "\n";
|
| 600 |
|
| 601 |
+
$count = 0;
|
| 602 |
|
| 603 |
+
// Determine whether or not to show advanced items, based on user's preference (default: false).
|
| 604 |
+
$show_advanced = $this->show_advanced_items();
|
| 605 |
|
| 606 |
+
foreach ( $this->conditions_reference as $k => $v ) {
|
| 607 |
+
$count++;
|
| 608 |
+
$class = '';
|
| 609 |
+
if ( $count == 1 ) {
|
| 610 |
+
$class = 'tabs';
|
| 611 |
+
} else {
|
| 612 |
+
$class = 'hide-if-no-js';
|
| 613 |
+
}
|
| 614 |
+
if ( in_array( $k, array( 'pages' ) ) ) {
|
| 615 |
+
$class .= ' basic';
|
| 616 |
+
} else {
|
| 617 |
+
$class .= ' advanced';
|
| 618 |
+
if ( ! $show_advanced ) { $class .= ' hide'; }
|
| 619 |
+
}
|
| 620 |
|
| 621 |
+
if ( isset( $this->conditions_headings[$k] ) ) {
|
| 622 |
+
$html .= '<li class="' . esc_attr( $class ) . '"><a href="#tab-' . esc_attr( $k ) . '">' . esc_html( $this->conditions_headings[$k] ) . '</a></li>' . "\n";
|
| 623 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
|
| 625 |
+
if ( $k == 'taxonomies' ) {
|
| 626 |
+
$html .= '<li class="' . esc_attr( $class ) . '"><a href="#tab-taxonomy-terms">' . __( 'Taxonomy Terms', 'woosidebars' ) . '</a></li>' . "\n";
|
| 627 |
+
}
|
| 628 |
+
}
|
|
|
|
| 629 |
|
| 630 |
+
$class = 'hide-if-no-js advanced';
|
| 631 |
+
if ( ! $show_advanced ) { $class .= ' hide'; }
|
|
|
|
|
|
|
| 632 |
|
| 633 |
+
$html .= '</ul>' . "\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 634 |
|
| 635 |
+
$html .= '<ul class="conditions-tabs"><li class="advanced-settings alignright hide-if-no-js"><a href="#">' . __( 'Advanced', 'woosidebars' ) . '</a></li></ul>' . "\n";
|
|
|
|
|
|
|
| 636 |
|
| 637 |
+
return $html;
|
| 638 |
+
}
|
|
|
|
| 639 |
|
| 640 |
+
private function render_standard_pages( $selected_conditions ) {
|
| 641 |
+
$html = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
|
| 643 |
+
foreach ( $this->conditions_reference as $k => $v ) {
|
| 644 |
+
$count = 0;
|
| 645 |
+
|
| 646 |
+
$tab = '';
|
| 647 |
+
|
| 648 |
+
$tab .= '<div id="tab-' . esc_attr( $k ) . '" class="condition-tab">' . "\n";
|
| 649 |
+
if ( isset( $this->conditions_headings[$k] ) ) {
|
| 650 |
+
$tab .= '<h4>' . esc_html( $this->conditions_headings[$k] ) . '</h4>' . "\n";
|
| 651 |
+
}
|
| 652 |
+
$tab .= '<ul class="alignleft conditions-column">' . "\n";
|
| 653 |
+
foreach ( $v as $i => $j ) {
|
| 654 |
+
$depth = '';
|
| 655 |
+
if ( isset( $j['depth'] ) ) {
|
| 656 |
+
$depth = str_repeat( ' ', $j['depth'] * 3 );
|
| 657 |
}
|
| 658 |
+
$count++;
|
| 659 |
|
| 660 |
+
$checked = '';
|
| 661 |
+
if ( in_array( $i, $selected_conditions ) ) {
|
| 662 |
+
$checked = ' checked="checked"';
|
| 663 |
+
}
|
| 664 |
+
$tab .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '">' . $depth . '<input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . $i . '"' . $checked . ' /> ' . esc_html( $j['label'] ) . '</label></li>' . "\n";
|
| 665 |
|
| 666 |
+
if ( $count % 10 == 0 && $count < ( count( $v ) ) ) {
|
| 667 |
+
$tab .= '</ul><ul class="alignleft conditions-column">';
|
| 668 |
+
}
|
| 669 |
+
}
|
| 670 |
|
| 671 |
+
$tab .= '</ul>' . "\n";
|
| 672 |
+
// Filter the contents of the current tab.
|
| 673 |
+
$tab = apply_filters( 'woo_conditions_tab_' . esc_attr( $k ), $tab );
|
| 674 |
+
$html .= $tab;
|
| 675 |
+
$html .= '<div class="clear"></div>';
|
| 676 |
+
$html .= '</div>' . "\n";
|
| 677 |
+
}
|
| 678 |
|
| 679 |
+
return $html;
|
| 680 |
+
}
|
|
|
|
|
|
|
|
|
|
| 681 |
|
| 682 |
+
private function render_taxonomy_terms_tabs( $taxonomy_terms, $selected_conditions ) {
|
| 683 |
+
// Taxonomy Terms Tab
|
| 684 |
+
$html = '<div id="tab-taxonomy-terms" class="condition-tab inner-tabs">' . "\n";
|
| 685 |
+
$html .= '<ul class="conditions-tabs-inner hide-if-no-js">' . "\n";
|
| 686 |
+
|
| 687 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
| 688 |
+
if ( ! isset( $this->conditions_headings[$k] ) ) { unset( $taxonomy_terms[$k] ); }
|
| 689 |
+
}
|
| 690 |
|
| 691 |
+
$count = 0;
|
| 692 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
| 693 |
+
$count++;
|
| 694 |
+
$class = '';
|
| 695 |
+
if ( $count == 1 ) {
|
| 696 |
+
$class = 'tabs';
|
| 697 |
+
} else {
|
| 698 |
+
$class = 'hide-if-no-js';
|
| 699 |
}
|
| 700 |
+
|
| 701 |
+
$html .= '<li><a href="#tab-' . $k . '" title="' . __( 'Taxonomy Token', 'woosidebars' ) . ': ' . str_replace( 'taxonomy-', '', $k ) . '">' . esc_html( $this->conditions_headings[$k] ) . '</a>';
|
| 702 |
+
if ( $count != count( $taxonomy_terms ) ) {
|
| 703 |
+
$html .= ' |';
|
| 704 |
+
}
|
| 705 |
+
$html .= '</li>' . "\n";
|
| 706 |
}
|
| 707 |
|
| 708 |
+
$html .= '</ul>' . "\n";
|
|
|
|
| 709 |
|
| 710 |
+
foreach ( $taxonomy_terms as $k => $v ) {
|
| 711 |
+
$count = 0;
|
| 712 |
|
| 713 |
+
$html .= '<div id="tab-' . $k . '" class="condition-tab">' . "\n";
|
| 714 |
+
$html .= '<h4>' . esc_html( $this->conditions_headings[$k] ) . '</h4>' . "\n";
|
| 715 |
+
$html .= '<ul class="alignleft conditions-column">' . "\n";
|
| 716 |
+
|
| 717 |
+
foreach ( $v as $i => $j ) {
|
| 718 |
+
$count++;
|
| 719 |
+
|
| 720 |
+
$checked = '';
|
| 721 |
+
if ( in_array( $i, $selected_conditions ) ) {
|
| 722 |
+
$checked = ' checked="checked"';
|
| 723 |
+
}
|
| 724 |
+
$html .= '<li><label class="selectit" title="' . esc_attr( $j['description'] ) . '"><input type="checkbox" name="conditions[]" value="' . $i . '" id="checkbox-' . esc_attr( $i ) . '"' . $checked . ' /> ' . esc_html( $j['label'] ) . '</label></li>' . "\n";
|
| 725 |
+
|
| 726 |
+
if ( $count % 10 == 0 && $count < ( count( $v ) ) ) {
|
| 727 |
+
$html .= '</ul><ul class="alignleft conditions-column">';
|
| 728 |
+
}
|
| 729 |
+
}
|
| 730 |
+
|
| 731 |
+
$html .= '</ul>' . "\n";
|
| 732 |
+
$html .= '<div class="clear"></div>';
|
| 733 |
+
$html .= '</div>' . "\n";
|
| 734 |
+
|
| 735 |
+
}
|
| 736 |
+
return $html;
|
| 737 |
+
}
|
| 738 |
|
| 739 |
/**
|
| 740 |
* meta_box_save function.
|
classes/class-woo-sidebars.php
CHANGED
|
@@ -375,10 +375,10 @@ class Woo_Sidebars {
|
|
| 375 |
* @param object $post
|
| 376 |
*/
|
| 377 |
public function description_meta_box ( $post ) {
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
} // End description_meta_box()
|
| 383 |
|
| 384 |
/**
|
|
@@ -453,9 +453,12 @@ class Woo_Sidebars {
|
|
| 453 |
|
| 454 |
if ( count( $sidebars ) > 0 ) {
|
| 455 |
foreach ( $sidebars as $k => $v ) {
|
| 456 |
-
$
|
| 457 |
-
|
| 458 |
-
|
|
|
|
|
|
|
|
|
|
| 459 |
}
|
| 460 |
}
|
| 461 |
} // End register_custom_sidebars()
|
|
@@ -498,7 +501,7 @@ class Woo_Sidebars {
|
|
| 498 |
$args = array(
|
| 499 |
'post_type' => $this->token,
|
| 500 |
'posts_per_page' => intval( $this->upper_limit ),
|
| 501 |
-
'suppress_filters' =>
|
| 502 |
);
|
| 503 |
|
| 504 |
$meta_query = array(
|
|
@@ -521,6 +524,16 @@ class Woo_Sidebars {
|
|
| 521 |
|
| 522 |
if ( count( $sidebars ) > 0 ) {
|
| 523 |
foreach ( $sidebars as $k => $v ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 524 |
$to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
|
| 525 |
$sidebars[$k]->to_replace = $to_replace;
|
| 526 |
|
|
@@ -740,7 +753,7 @@ class Woo_Sidebars {
|
|
| 740 |
* @return void
|
| 741 |
*/
|
| 742 |
public function add_contextual_help () {
|
| 743 |
-
if ( get_current_screen()->id != 'edit-sidebar' ) { return; }
|
| 744 |
|
| 745 |
get_current_screen()->add_help_tab( array(
|
| 746 |
'id' => 'overview',
|
|
@@ -805,4 +818,4 @@ class Woo_Sidebars {
|
|
| 805 |
}
|
| 806 |
} // End register_plugin_version()
|
| 807 |
} // End Class
|
| 808 |
-
?>
|
| 375 |
* @param object $post
|
| 376 |
*/
|
| 377 |
public function description_meta_box ( $post ) {
|
| 378 |
+
?>
|
| 379 |
+
<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>
|
| 380 |
+
<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>
|
| 381 |
+
<?php
|
| 382 |
} // End description_meta_box()
|
| 383 |
|
| 384 |
/**
|
| 453 |
|
| 454 |
if ( count( $sidebars ) > 0 ) {
|
| 455 |
foreach ( $sidebars as $k => $v ) {
|
| 456 |
+
$args = apply_filters( 'woosidebars_sidebar_args', array(
|
| 457 |
+
'name' => $v->post_title,
|
| 458 |
+
'id' => $v->post_name,
|
| 459 |
+
'description' => $v->post_excerpt,
|
| 460 |
+
), $v, $this );
|
| 461 |
+
register_sidebar( $args );
|
| 462 |
}
|
| 463 |
}
|
| 464 |
} // End register_custom_sidebars()
|
| 501 |
$args = array(
|
| 502 |
'post_type' => $this->token,
|
| 503 |
'posts_per_page' => intval( $this->upper_limit ),
|
| 504 |
+
'suppress_filters' => true
|
| 505 |
);
|
| 506 |
|
| 507 |
$meta_query = array(
|
| 524 |
|
| 525 |
if ( count( $sidebars ) > 0 ) {
|
| 526 |
foreach ( $sidebars as $k => $v ) {
|
| 527 |
+
|
| 528 |
+
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
|
| 529 |
+
// get the post language
|
| 530 |
+
$wpml_element = apply_filters( 'wpml_element_language_code', ICL_LANGUAGE_CODE, array( 'element_id' => intval( $v->ID ), 'element_type' => 'post_sidebar' ) );
|
| 531 |
+
// check if the current language matches the language of the sidebar
|
| 532 |
+
if ( $wpml_element != ICL_LANGUAGE_CODE ) {
|
| 533 |
+
continue;
|
| 534 |
+
}
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
$to_replace = get_post_meta( $v->ID, '_sidebar_to_replace', true );
|
| 538 |
$sidebars[$k]->to_replace = $to_replace;
|
| 539 |
|
| 753 |
* @return void
|
| 754 |
*/
|
| 755 |
public function add_contextual_help () {
|
| 756 |
+
if ( empty( get_current_screen() ) || get_current_screen()->id != 'edit-sidebar' ) { return; }
|
| 757 |
|
| 758 |
get_current_screen()->add_help_tab( array(
|
| 759 |
'id' => 'overview',
|
| 818 |
}
|
| 819 |
} // End register_plugin_version()
|
| 820 |
} // End Class
|
| 821 |
+
?>
|
readme.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
=== WooSidebars ===
|
| 2 |
-
Contributors: woothemes, mattyza
|
| 3 |
Tags: widgets, sidebars, widget-areas
|
| 4 |
Requires at least: 4.1
|
| 5 |
-
Tested up to: 4.6.
|
| 6 |
-
Stable tag: 1.4.
|
| 7 |
License: GPLv3 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 9 |
|
|
@@ -69,6 +69,9 @@ Looking to contribute code to this plugin? [Fork the repository over at GitHub](
|
|
| 69 |
|
| 70 |
== Upgrade Notice ==
|
| 71 |
|
|
|
|
|
|
|
|
|
|
| 72 |
= 1.4.3 =
|
| 73 |
Bug fix and maintenance release.
|
| 74 |
|
|
@@ -99,6 +102,10 @@ Moved to WordPress.org. Woo! Added scope to methods and properties where missing
|
|
| 99 |
|
| 100 |
== Changelog ==
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
= 1.4.3 =
|
| 103 |
* 2015-09-22
|
| 104 |
* Ensures condition headings are present before attempting to output in the conditions meta box.
|
|
@@ -152,4 +159,4 @@ Moved to WordPress.org. Woo! Added scope to methods and properties where missing
|
|
| 152 |
* Initial WooCommerce integration.
|
| 153 |
|
| 154 |
= 1.0.0 =
|
| 155 |
-
* First release. Woo!
|
| 1 |
=== WooSidebars ===
|
| 2 |
+
Contributors: woothemes, Automattic, mattyza
|
| 3 |
Tags: widgets, sidebars, widget-areas
|
| 4 |
Requires at least: 4.1
|
| 5 |
+
Tested up to: 4.6.5
|
| 6 |
+
Stable tag: 1.4.4
|
| 7 |
License: GPLv3 or later
|
| 8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
| 9 |
|
| 69 |
|
| 70 |
== Upgrade Notice ==
|
| 71 |
|
| 72 |
+
= 1.4.4 =
|
| 73 |
+
Bug fix and maintenance release. Enables "pages and their children" as a widget area condition.
|
| 74 |
+
|
| 75 |
= 1.4.3 =
|
| 76 |
Bug fix and maintenance release.
|
| 77 |
|
| 102 |
|
| 103 |
== Changelog ==
|
| 104 |
|
| 105 |
+
= 1.4.4 =
|
| 106 |
+
* 2018-06-08
|
| 107 |
+
* Bug fix and maintenance release. Enables "pages and their children" as a widget area condition.
|
| 108 |
+
|
| 109 |
= 1.4.3 =
|
| 110 |
* 2015-09-22
|
| 111 |
* Ensures condition headings are present before attempting to output in the conditions meta box.
|
| 159 |
* Initial WooCommerce integration.
|
| 160 |
|
| 161 |
= 1.0.0 =
|
| 162 |
+
* First release. Woo!
|
woosidebars.php
CHANGED
|
@@ -1,31 +1,34 @@
|
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooSidebars
|
| 4 |
-
* Plugin URI: http://
|
| 5 |
* Description: Replace widget areas in your theme for specific pages, archives and other sections of WordPress.
|
| 6 |
-
* Author:
|
| 7 |
-
* Author URI: http://
|
| 8 |
-
* Version: 1.4.
|
| 9 |
-
* Stable tag: 1.4.
|
| 10 |
* Requires at least: 4.1
|
| 11 |
-
* Tested up to: 4.6.
|
| 12 |
* License: GPL v3 or later - http://www.gnu.org/licenses/gpl-3.0.html
|
| 13 |
* Text Domain: woosidebars
|
| 14 |
* Domain Path: /lang
|
| 15 |
*/
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
?>
|
| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Plugin Name: WooSidebars
|
| 4 |
+
* Plugin URI: http://woocommerce.com/woosidebars/
|
| 5 |
* Description: Replace widget areas in your theme for specific pages, archives and other sections of WordPress.
|
| 6 |
+
* Author: WooCommerce
|
| 7 |
+
* Author URI: http://woocommerce.com/
|
| 8 |
+
* Version: 1.4.4
|
| 9 |
+
* Stable tag: 1.4.4
|
| 10 |
* Requires at least: 4.1
|
| 11 |
+
* Tested up to: 4.6.5
|
| 12 |
* License: GPL v3 or later - http://www.gnu.org/licenses/gpl-3.0.html
|
| 13 |
* Text Domain: woosidebars
|
| 14 |
* Domain Path: /lang
|
| 15 |
*/
|
| 16 |
|
| 17 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 18 |
+
exit; // Exit if accessed directly
|
| 19 |
+
}
|
| 20 |
|
| 21 |
+
if ( ! class_exists( 'Woo_Conditions' ) ) {
|
| 22 |
+
require_once( 'classes/class-woo-conditions.php' );
|
| 23 |
+
}
|
| 24 |
+
require_once( 'classes/class-woo-sidebars.php' );
|
| 25 |
|
| 26 |
+
// Third-party integrations.
|
| 27 |
+
if ( class_exists( 'Woocommerce' ) ) {
|
| 28 |
+
require_once( 'integrations/integration-woocommerce.php' );
|
| 29 |
+
}
|
| 30 |
|
| 31 |
+
global $woosidebars;
|
| 32 |
+
$woosidebars = new Woo_Sidebars( __FILE__ );
|
| 33 |
+
$woosidebars->version = '1.4.4';
|
| 34 |
+
$woosidebars->init();
|
|
|
