mercredi 8 juin 2016

wp_register_ not working with infinite scroll

I'm having some issues with plugins / shortcodes and an infinite scroll and, while I try to solve this thing, I found something that maybe the problem.

I'm using two plugins that need shortcodes to work (Shortcodes Ultimate and Ditty News Ticker) and Ajax Load More to create the scroll.

Shortcodes Ultimate -- when the content is injected via ajax when scrolling -- just cannot access it's own CSS files. It runs, it adds the HTMLs that are needed, but no styling.

IF I put the CSSs inside my style.php, it works.

This is the code Shortcodes Ultimate uses to load / register the CSS and seems to not work when the Ajax Load More injects the code in the page.

wp_register_style( 'su-box-shortcodes', self::skin_url( 'box-shortcodes.css' ), false, SU_PLUGIN_VERSION, 'all' );

With Ditty News Ticker, the code that loads the function is this:

// Load the news ticker scripts
wp_register_script( 'ditty-news-ticker', MTPHR_DNT_URL.'assets/js/script-admin.js', array( 'jquery','jquery-ui-core','jquery-ui-sortable', 'jquery-easing', 'qtip', 'mtphr-dnt-affix' ), MTPHR_DNT_VERSION, true );
 wp_enqueue_script( 'ditty-news-ticker' );
 wp_localize_script( 'ditty-news-ticker', 'ditty_news_ticker_vars', array(
 'security' => wp_create_nonce( 'ditty-news-ticker' ),
 'img_title' => __( 'Upload or select an image', 'ditty-news-ticker' ),
 'img_button' => __( 'Use Image', 'ditty-news-ticker' )
 )
 );
 }

Does this tells wordpress that the plugin / style is loaded and that's it? It should be loaded everytime, with the content that ajax inject to create the scroll, but it's not.

Actually, if I use this to load Ditty News Ticker, after the first post I get a "does not exist".

<?php 
if (function_exists('ditty_news_ticker')) {
    echo 'ditty_news_ticker() exists! Yay!';
    ditty_news_ticker( 1487 );
} else {
    echo 'ditty_news_ticker() does not exist';
}
?>

How could I make the plugin to register the CSS / functions everytime?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire