New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #839: Add wp-cli script to create test widgets #859

Merged
merged 7 commits into from Jan 15, 2018

Conversation

Projects
None yet
4 participants
@kienstra
Collaborator

kienstra commented Jan 13, 2018

Request For Code Review

Hi @westonruter or @ThierryA,
Could you please review this pull request for #839? This builds on @kopepasah's work to create a widget test script.

Using Koop's function, it finds the first registered sidebar. Then, it adds an instance of every WordPress widget that's registered in a "vanilla" instance, per Joshua's screenshot.

But only if an instance with the same settings doesn't already exist in that sidebar, As @westonruter requested in #839.

Some widgets have multiple instances, with different settings. Like 'Audio,' 'Archives,'Categories,' 'Tag Cloud,' and 'Video.'

kopepasah and others added some commits Jan 10, 2018

Issue #839: wp-cli script to add test widgets to sidebar.
Adds an instance of every default WordPress widget
to the first registered sidebar.
First, it checks if a widget with the same settings exists in the sidebar.
Then, it conditionally creates the widget.
And adds all of them to the sidebar.
Mainly copies amp_get_widget_id() from import_theme_starter_content().
Props @westonruter.
Issue #839: Fix issue in image URL, height, and width.
Use get_attachment_url() to get the image's URL.
Also, access the height and width with array index notation,
Not with object operators.
Also, pass array() as a second argument to get_option().
This will ensure that the default return is array().

@kienstra kienstra requested a review from westonruter Jan 13, 2018

@kienstra kienstra requested a review from ThierryA Jan 13, 2018

ThierryA added some commits Jan 15, 2018

@ThierryA

Great work @kienstra 👍 I pushed a quick fix and added documentation for the script, could you kindly review my changes.

$menus = wp_get_nav_menus();
$minimum_count = 4;
foreach ( $menus as $menu ) {
if ( $menu->count > $minimum_count ) {

This comment has been minimized.

@ThierryA

ThierryA Jan 15, 2018

Collaborator

This actually requires 5 menu items.

This comment has been minimized.

@ThierryA

ThierryA Jan 15, 2018

Collaborator

Fixed here.

*/
function amp_widget_already_in_sidebar( $widget, $sidebar ) {
$sidebars = wp_get_sidebars_widgets();
$widgets_in_sidebar = $sidebars[ $sidebar ];

This comment has been minimized.

@ThierryA

ThierryA Jan 15, 2018

Collaborator

Make sure this isset.

This comment has been minimized.

@ThierryA

ThierryA Jan 15, 2018

Collaborator

Fixed here.

1. `ssh` into an environment like [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV)
2. `cd` to the root of this plugin
3. run `wp eval-file bin/add-test-widgets-to-sidebar.php`
4. visit a page with the sidebar: Blog Sidebar.

This comment has been minimized.

@kienstra

kienstra Jan 15, 2018

Collaborator

Hi @ThierryA,
Thanks for adding this documentation. This step 4. will often be accurate. But the step below would apply no matter what theme is active:

4. There will be a message indicating which sidebar has the widgets. Please visit a page with that sidebar.
@kienstra

This comment has been minimized.

Collaborator

kienstra commented Jan 15, 2018

Thanks For Reviewing And Improving
Made Minor Point

Hi @ThierryA,
Thanks a lot for reviewing this and adding documentation. I only added a minor point above about the documentation, but it's not a blocker to merging. If you'd like, I'd be happy to apply the suggestion to this branch.

@ThierryA

This comment has been minimized.

Collaborator

ThierryA commented Jan 15, 2018

Thanks @kienstra, I pushed a commit with your suggestion 👍

@ThierryA ThierryA merged commit 75ed4a9 into develop Jan 15, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@ThierryA ThierryA deleted the add/839-wpcli-script-for-widgets branch Jan 15, 2018

@westonruter westonruter added this to the v0.7 milestone Jan 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment