w3guy / persist-admin-notices-dismissal

Simple plugin that persists dismissal of admin notices across pages in WordPress dashboard.
http://w3guy.com/wordpress-admin-notices-dismissible/
87 stars 22 forks source link

add js url filter hook #27

Closed afragen closed 5 years ago

afragen commented 5 years ago

We hard-coded the plugin URL. If this framework is used in a theme the JS won't be loaded. This hook allows for a simple method of returning a correct URL for enqueuing the JS file.

Hopefully, this fixes https://github.com/afragen/wp-dependency-installer/issues/29

afragen commented 5 years ago

Adding the filter as follows to a theme's functions.php file should properly load the JS file.

add_filter(
    'pand_dismiss_notice_js_url',
    function( $js_url, $composer_path ) {
        return get_stylesheet_directory_uri() . $composer_path;
    },
    10,
    2
);

Unfortunately I see no way to do this automatically, though I could include this filter inside the code and create another filter to return a boolean if running from a theme.

@collizo4sky let me know your thoughts.

w3guy commented 5 years ago

LGTM