cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
280 stars 82 forks source link

Minify, clean up, and identify WPP's loading animation inline style tag #318

Closed cabrerahector closed 2 years ago

cabrerahector commented 2 years ago

At the moment the plugin injects this inline style tag to the <head> section of the page so ajaxified widgets can display their loading animation bar.

<style>
    @-webkit-keyframes bgslide {
        from {
            background-position-x: 0;
        }
        to {
            background-position-x: -200%;
        }
    }

    @keyframes bgslide {
            from {
                background-position-x: 0;
            }
            to {
                background-position-x: -200%;
            }
    }

    .wpp-widget-placeholder {
        margin: 0 auto;
        width: 60px;
        height: 3px;
        background: #dd3737;
        background: -webkit-gradient(linear, left top, right top, from(#dd3737), color-stop(10%, #571313), to(#dd3737));
        background: linear-gradient(90deg, #dd3737 0%, #571313 10%, #dd3737 100%);
        background-size: 200% auto;
        border-radius: 3px;
        -webkit-animation: bgslide 1s infinite linear;
        animation: bgslide 1s infinite linear;
    }
</style>

We could improve things a bit:

lflorent commented 2 years ago

Hi @cabrerahector,

Could you also provide a way to use remove_action() with your inline_loading_css action in WordPressPopularPosts\Front\Front class ?

I want to remove this inline css code and use my own css from theme.

Currently we have no possibility to achieve this :

Thanks :)

cabrerahector commented 2 years ago

Yup, I can look into that as well. I'll leave a comment here when/if a find a simple way to do that @lflorent :)

lflorent commented 2 years ago

Hi @cabrerahector,

The simplest way I think is to change :

I tested and it works when I use remove_action('wp_head', array('WordPressPopularPosts\Front\Front', 'inline_loading_css'), 10); on my function.php ;)

cabrerahector commented 2 years ago

@lflorent FYI thanks for the suggestion, however I decided to go for a different solution instead:

add_filter('wpp_insert_loading_animation_styles', '__return_false');

The end result will still be the same :)

lflorent commented 2 years ago

@cabrerahector thanks for the new filter ;)