Code Monkey home page Code Monkey logo

be-subpages-widget's Introduction

=== BE Subpages Widget ===
Contributors: billerickson
Tags: widget, subpages, menu
Requires at least: 3.0
Tested up to: 5.5
Stable tag: 1.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Lists subpages of the current section

== Description ==

This widget will dynamically list a section's subpages. When on a page, it will find the section's top level page and list its children.

It can also include the current page's subpages in listing.

You can customize the listing with the following filters:
be_subpages_widget_args - modifies the arguments passed to wp_list_pages
be_subpages_widget_display_override - determine when the widget is displayed
be_subpages_widget_override_post - change the current post
be_subpages_widget_parents - customize the hierarchy used in querying subpages
be_subpages_widget_title - customize the widget title
be_subpages_page_title - customize the page title
be_subpages_widget_class - customize the classes applied to pages

Contributors:
- [billerickson](http://profiles.wordpress.org/billerickson)
- [scil](http://profiles.wordpress.org/scil/)
- [jb510](https://github.com/jb510)
- [fabiancz](https://github.com/fabiancz)

[View all plugins by Bill Erickson](http://www.billerickson.net/contributions/plugins/)

== Changelog ==

= 1.7 =
* Allow $post to be filtered

= 1.6 =
* Update widget to use PHP5 constructor

= 1.5 =
* Add filter for changing section parents
* Add unique class to menu items, menu-item-{id}
* Add hook for adding links to end of subpages listing

= 1.4 =
* Update widget formatting in backend
* Subpage titles are filterable

= 1.3 =
* Support for all hierarchical post types
* Only output HTML for classes if there are classes
* Only output subpages ul if there are subpages
* Allow second level subpages to be nested in li
* Czech translation

= 1.2 =
* Add class for first menu item
* Add filter for widget classes
* Add filter for widget title
* Sort by menu order
* Add a depth parameter to the args filter

= 1.1 =
* Allow deeper menu (current page's subpages)
* French Translation
* Add 'widget_subpages_current_page' class to current menu item
* Add be_subpages_page_title filter
* Thanks to Cedric Houbart of SCIL for this set of changes

= 1.0 =
* Release of plugin

be-subpages-widget's People

Contributors

billerickson avatar fabiancz avatar jb510 avatar mustardbees avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

be-subpages-widget's Issues

Child pages not showing

When checking the "Include the current page's subpages" box. Child lists do not output. Example...

$instance['deep_subpages'] is showing as '1'. But won't display children. Hardcoding "$deep_subpages = 1" works though.

Tested on WP 3.4.1 with both PHP 5.2 and 5.3. Windows 2008/IIS 7.

Error with Gutenberg block

I was checking out your Gutenberg block, and it worked fine at first. But after a while I get the same error as described here: WordPress/gutenberg#4043

TypeError
columnNumber: 24486
fileName: "http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2"
lineNumber: 1
message: "this.activateMode is not a function"
stack: "
_createModes/<@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:24486
arrayEach@webpack-internal:///41:537:11
forEach@webpack-internal:///41:9359:14
_createModes@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:24449
initialize@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:23855
initialize@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:25475
initialize@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:28347
e.View@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:17:14728
constructor@http://test.dev/wp-includes/js/wp-backbone.min.js?ver=4.9.2:1:2602
constructor@http://test.dev/wp-includes/js/media-views.min.js?ver=4.9.2:1:23290
n@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:17:22929
n@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:17:22929
n@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:17:22929
[20]/wp.media@http://test.dev/wp-includes/js/media-models.min.js?ver=4.9.2:1:666
t@http://test.dev/wp-content/plugins/gutenberg/blocks/build/index.js?ver=1516268334:6:71380
constructClassInstance@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:125:436
beginWork@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:134:25
d@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:158:393
f@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:159:214
g@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:159:462
t@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:167:3
x@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:166:247
r@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:164:368
v@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:163:278
updateContainer@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:172:31
Hb/<@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:83:450
unbatchedUpdates@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:169:269
Hb@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:83:420
render@http://test.dev/wp-content/plugins/gutenberg/vendor/react-dom.min.3583f8be.js:191:247
c@http://test.dev/wp-content/plugins/gutenberg/editor/build/index.js?ver=1516268334:11:54108
window._wpLoadGutenbergEditor<@http://test.dev/wp-admin/post-new.php:1653:11
then/</</<@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:28766
i@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:27444
add@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:27748
then/</<@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:28738
each@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:2879
then/<@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:28684
a.Deferred@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:9:9928
then@http://test.dev/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,underscore,backbone,wp-api-request&ver=4.9.2:2:28661
@http://test.dev/wp-admin/post-new.php:1652:257
@http://test.dev/wp-admin/post-new.php:1652:3"
  • Browser: Firefox
  • Wordpress: 4.9.2
  • PHP: 7.0.3
  • Active Plugins: Gutenberg (2.0.0) and BE Subpages Widget (branch gutenberg)

As I'm new to Gutenberg I have no clue what the error means or if my setup is causing this error. If I de-activate your block the error goes away.

Running on posts via filter

I need to display child pages of a particular page on posts (an event CPT) however the plugin bails if not on a hierarchical post type (line 53) which normally makes sense...

I tried a couple things and arrived at this (starting at be-subpages-widget.php:51):

// Only run on hierarchical post types unless passed a 'post_type'
$page_filter_check = apply_filters( 'be_subpages_widget_args', $args );
$post_types = get_post_types( array( 'hierarchical' => true ) );
if ( !is_singular( $post_types ) && !isset($page_filter_check['post_type'] ) )
    return;

Seems to be working, but feel like I might be missing something. What are your thoughts on that?

for reference I'm passing into the filter this:

add_filter( 'be_subpages_widget_args', 'touro_subpages_widget_args' );
/**
 * Add Parent to the Subpages Widget.
 *
 * @param array $args Array of arguments.
 * @param array Modified array of arguments for get_pages().
 */
function touro_subpages_widget_args( $args ) {

    $post_type = get_post_type( get_the_ID() );
    if ( is_page('calendar') || 'ai1ec_event' == $post_type ) { //TODO Not working for single CPT due to be-subpages-widget.php:53 limit to hierarchical post types.
        // Build a menu listing top level parent's children
        $args['child_of'] = 2;
        $args['parent'] = 2;
        $args['sort_column'] = 'menu_order';
        $args['post_type'] = 'page';
    }

    return $args;
}

Classes not only for the first menu item

Hi! Thanks for the great plugin.
I see, that the first menu item has it's own class "first-menu-item"
I would also like to adress with my css the items below the first item, like:

  • ".first-menu-item"
    • subpage
    • subpage
  • ".menu-item-2" or ".menu-item-to-page-id-yxz"
    • subpage
    • subpage
  • ".menu-item-3" or ".menu-item-to-page-id-yxz"

Could you give me a hint? How could i add this piece of code into the plugins php-code?

I thank you very much for your attention in advance.

Cheers
Michael from Germany ([email protected])

Widget showing links at parent/uncle level.

When you use this widget in templates that are 2 or more levels down in a hierarchy, it does not treat its page as the top level. It treats its parent as the top level, and therefore displays uncle links in addition to subpages. This happens even when it is a dedicated widget (i.e., it is not sharing a template with its parent page). Argh.

Ability to directly inject extra list items...

It's been handy to have an action to inject links to the bottom of auto-generated lists.

In this particular case, it's a BP login/logout link we only show when they're in the BP section of the site. (PR coming)

be_subpages_widget_args filter

The be_subpages_widget_args filter appears twice, once for the original fetch of get_pages() and another for the deeper pages. So if this is filtered (since $post->ID or $subpage->ID), then it ruins the entire widget. I recommend that the second filter name be changed to something like be_subpages_widget_deeper_args.

Nested ul is wrong

Hi Bill Ericson,

I noticed one flaw with your Subpages Widget - and I hop you have the time to make this update soon.

Check this screenshot:
http://cl.ly/image/1q2P3T3p1y2H

The first one is a modification I just did to show how it should be, the other clipping is how it looks from the way the plugin adds in nested lists.

According to specs, w3, stackoverflow and all - the nested ul validates and acts better when within li.

http://www.w3.org/wiki/HTML_lists

skarmavbild 2013-06-12 kl 08 31 07

Deep tree

On the site I'm working on I need to sub-menus to display deep. So not only show children of current page, but children of children etc.

What I did was change

// Check if the subpage is in parent tree to go deeper if ( $deep_subpages && in_array( $subpage->ID, $parents ) ) {

to

// Check if the subpage is in parent tree to go deeper if ( $deep_subpages && apply_filters( 'be_subpages_widget_deep_tree', in_array( $subpage->ID, $parents ), $subpage ) ) {

Thoughts on that? Other than not being that very performant?

I think it would be a fun idea in the future if we rewrote this to be similar to how the Yoast Breadcrumbs work. Meaning you are building a multi-dimensional array that gets output at the very end. The benefits being much easier to filter modify, and in addition to this, on output since everything is built you can them add all the helpful classes like 'has-children' etc instead if figuring it all out with jQuery (or at least that is what I'm using now). Maybe 2.0... you know, in all our spare time! ๐Ÿ˜†

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.