Skip to content
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

Automagically load popups when needed #926

Merged
merged 11 commits into from
Dec 30, 2020
Merged

Automagically load popups when needed #926

merged 11 commits into from
Dec 30, 2020

Conversation

fpcorso
Copy link
Contributor

@fpcorso fpcorso commented Dec 22, 2020

Description

Automatically load when we detect that a popup is needed.

Enqueue popups when found in the_content

Used the following content to test regex:

<button class="popmake-1244">Test</button><a href="#" class='popmake-1222'>TEst</a>
<input type="reset" class="button-primary popmake-1234 butoon-lg">
<p>Example text within elements that shouldn't match: Use popmake-1224</p>
<div class="wp-block-buttons">
<div class="wp-block-button popmake-2230"><a class="wp-block-button__link">Example button added in block editor with popup controls set to open popup</a></div>
</div>

Enqueue popups when found in the menu

Automatically loads a popup when we detect the menu item has a popup ID in the menu setting.

Enqueue popups when popup_trigger is used

If popup_trigger shortcode is used, go ahead and ensure the popup gets loaded.

Related Issue

Issue: #543

Types of changes

Filters the_content and search for popmake-### class. If found, load the popup. When processing menu items, if a popup ID is set, go ahead and load the popup.

This has been tested in the following browsers

  • Chrome
  • Firefox
  • Edge
  • Safari

Checklist:

  • This PR passes all automated checks (will appear once pull request is submitted)
  • My code has been tested in the latest version of WordPress.
  • My code does not have any warnings from ESLint.
  • My code does not have any warnings from StyleLint.
  • My code does not have any warnings from PHPCS.
  • My code follows the WordPress coding standards.
  • My code follows the accessibility standards.
  • All new functions and classes have code documentation.

@fpcorso fpcorso requested a review from danieliser December 22, 2020 15:05
@fpcorso fpcorso changed the title [WIP] Automagically load popups when found in content [WIP] Automagically load popups when needed Dec 22, 2020
Since we are using this code in several places, and may add more,
lets create its own method for this.
The preload_popup method will add multiple instances of the popup code
which results in flashes and multiple open/closes which prevents the popup from opening.
Add conditional to make sure the popup isn't already loaded.
The original solution only caught when they used our popup setting for
triggering popups. But, they can also add the popmake- class instead. So,
we now check the classes after we set ours.
@fpcorso fpcorso changed the title [WIP] Automagically load popups when needed Automagically load popups when needed Dec 22, 2020
@fpcorso fpcorso requested a review from danieliser December 28, 2020 17:01
@fpcorso fpcorso merged commit 484834e into develop Dec 30, 2020
@fpcorso fpcorso deleted the feature/543 branch December 30, 2020 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants