Checking for ‘gallery’ shortcode using strpos always returns false

You will need global $post to get the $post variable into the scope of that function. function doraemon_scripts() { if( is_single() ) { global $post; if (strpos($post->post_content,'[gallery’) === false){ } else { // wp_enqueue_style( … ); // wp_enqueue_script( … ); } } } add_action( ‘wp_enqueue_scripts’, ‘doraemon_scripts’ ); Using the $post global outside of the Loop … Read more

How to include php-generated javascript?

You can either not use wp_enqueue_script (which loads a JS file, where you won’t be able to use PHP) and instead simply print the script out on the wp_head or wp_footer hooks…. or you can use wp_localize_script() wp_enqueue_script( ‘some_handle’ ); $instance = // not sure how you are fetching this value $array = array( ‘thumbs’ … Read more

Plugin Scripts no loading on options page

Hey use admin_enqueue_scripts. if you want to load a set of CSS and/or Javascript documents to all admin pages. You can do this from within your plugin or from your themes function file using admin_enqueue_scripts: function class_table_scripts() { wp_register_script( ‘JavaScript1’, plugins_url(‘js/wcs.css’), array() ); wp_enqueue_script(‘JavaScript1’); wp_register_script( ‘JavaScript1’, plugins_url(‘js/jquery.qtip-1.0.0-rc3.min.js’), array(‘jquery’) ); wp_enqueue_script(‘JavaScript1’); } add_action( ‘admin_enqueue_scripts’, ‘class_table_scripts’ );