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

Remove legacy asset enqueueing compatibility code #1358

Closed
jom opened this issue Feb 23, 2018 · 2 comments
Closed

Remove legacy asset enqueueing compatibility code #1358

jom opened this issue Feb 23, 2018 · 2 comments

Comments

@jom
Copy link
Member

jom commented Feb 23, 2018

See: #1354

Remove constant check and compatibility filters that maintain the old enqueueing strategy:

/**
* Starting in WP Job Manager 1.32.0, the chosen JS library and core frontend WPJM CSS will only be enqueued
* when used on a particular page. Theme and plugin authors as well as people who have overloaded WPJM's default
* template files should test this upcoming behavior.
*
* To test this behavior before 1.32.0, add this to your `wp-config.php`:
* define( 'JOB_MANAGER_TEST_NEW_ASSET_BEHAVIOR', true );
*
* Unless this constant is defined, WP Job Manager will default to its old behavior: chosen JS library and
* frontend styles are always enqueued.
*
* If your theme or plugin depend on the `frontend.css` or chosen JS library from WPJM core, you can use the
* `job_manager_chosen_enabled` and `job_manager_enqueue_frontend_style` filters.
*
* Example code for a custom shortcode that depends on the chosen library:
*
* add_filter( 'job_manager_chosen_enabled', function( $chosen_used_on_page ) {
* global $post;
* if ( is_singular()
* && is_a( $post, 'WP_Post' )
* && has_shortcode( $post->post_content, 'resumes' )
* ) {
* $chosen_used_on_page = true;
* }
* return $chosen_used_on_page;
* } );
*
*/
if ( ! defined( 'JOB_MANAGER_TEST_NEW_ASSET_BEHAVIOR' ) || true !== JOB_MANAGER_TEST_NEW_ASSET_BEHAVIOR ) {
add_filter( 'job_manager_chosen_enabled', '__return_true' );
add_filter( 'job_manager_enqueue_frontend_style', '__return_true' );
}

@jom jom added this to the 1.32.0 milestone Feb 23, 2018
@tripflex
Copy link
Collaborator

tripflex commented Mar 2, 2018

Any specific reason for not keeping the asset registered and just dealing with the enqueueing of the asset?

@jom
Copy link
Member Author

jom commented Mar 2, 2018

@tripflex Are you referring to chosen and the original PR that this references?

We could, but it has a bit of a cascading effect unless we update templates/form-fields/term-multiselect-field.php and templates/form-fields/multiselect-field.php. Those blindly enqueue wp-job-manager-multiselect which has no effect if that is never registered (which is good if we have disabled the library). We could, technically, register chosen JS and CSS and leave them out there, but if we are replacing that library soon I'd rather not make it easier for people to add dependencies other than wp-job-manager-multiselect.

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

No branches or pull requests

2 participants