WordPress.org

Ready to get started?Download WordPress

Forums

Smart WYSIWYG Blocks Of Content
Problem with wp_enqueue_script in shortcode (1 post)

  1. valx76
    Member
    Posted 2 years ago #

    Hi,

    I need your help for a problem with this plugin..
    I'm developping plugins and I have problems to include styles/scripts with Smart Blocks..
    In the Smartblock content, I include a shortcode ([carrousel] for example), that called external JS / CSS files. They work in a simple page but not inside a Smart Block..

    To includes styles, I'm using that way :

    add_action( 'wp_print_styles', 'vp_annuaire_css' );
    
    function vp_annuaire_css() {
    	if ( !is_admin() ) {
    		global $posts;
    
    		if ( $posts != NULL ) {
    			foreach( $posts as $post ) {
    
    				if ( strstr( $post->post_content, '[carrousel' ) ) {
    					wp_enqueue_style( 'annuaire_css', plugins_url( 'css/annuaire.css', __FILE__ ) );
    
    					break;
    				}
    			}
    		}
    	}
    }

    The problem is that the global variable $posts doesn't contain Smart Blocks posts..

    EDIT: I'm using the 0.6 version.

    Best regards,
    Valentin

    http://wordpress.org/extend/plugins/smart-wysiwyg-blocks-of-content/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic