Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Conversation

@jonathanbardo
Copy link
Contributor

@fjarrett Please review.

screen shot 2017-02-24 at 10 11 47 am

@jonathanbardo
Copy link
Contributor Author

Changing the array syntax over to 5.2 compatible right now

@frankiejarrett
Copy link
Contributor

@jonathanbardo I started a review but stopped to discuss a broader point first.

I assume the idea was that we might add more widgets later. But I'm wondering if there's a case to be made that we might be over-engineering it. TBH this feels like a shitload of code to maintain for just a simple widget with 4 fields. Could it be simpler to just cross that road when we come to it?

@jonathanbardo
Copy link
Contributor Author

@fjarrett I could get rid of the base class if you feel more comfortable. It's basically the same pattern as contact widget so I don't know if it adds that much more burden on our shoulder since we maintain the other one anyway. In any case I can bring it down to 1 php class and 1 js file.

@frankiejarrett
Copy link
Contributor

@jonathanbardo I've been thinking a little about CW too, in light of godaddy-wordpress/contact-widgets#22, which required significant changes to the base class to the point where we had to table it until the next major release. Rather than the base class being an aid to speed things up, instead, we had to manhandle the HOO widget to be compatible with the pattern.

@jonathanbardo
Copy link
Contributor Author

@fjarrett I've consolidated the necessary logic in class-hero.php and got rid of the base class. I think you can give this another look.

@frankiejarrett frankiejarrett added this to the 1.6.0 milestone Feb 27, 2017
@frankiejarrett
Copy link
Contributor

@EvanHerman and @jonathanbardo please have a look at this and test. My goal was to reduce the widget code to its simplest and purest form.


parent::__construct( 'primer-hero-text', esc_html__( 'Hero Text', 'primer' ), $widget_options );

add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett Will this only enqueue the script if we are on the widget page or in the customizer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett I see that you are checking for specific hook in the method itself. That was the reason I only added the action when the form was printed and in the footer only. That way we know the widget is being printed on the page.

Copy link
Contributor

@frankiejarrett frankiejarrett Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanbardo But doesn't that require a page reload? What happens if you drag the widget into a sidebar for the first time on widgets.php?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett It should work as expected even if the widget is not in any sidebars because the form is printed anyways.

( function ( $ ) {

// This let us know that we appended a new widget to reset sortables.
// Let our script know a widget has been added to make its URL search input work.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanbardo I updated the comment here to better clarify why the inline script exists.

@frankiejarrett
Copy link
Contributor

@EvanHerman please test this and merge if you approve

Copy link
Contributor

@EvanHerman EvanHerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett Works well for me. Merging in.

@EvanHerman EvanHerman merged commit 058c75e into develop Feb 28, 2017
@EvanHerman EvanHerman deleted the hero-widget branch February 28, 2017 20:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants