WordPress.org

Ready to get started?Download WordPress

Forums

Youtube shortcode
shortcode in ajax (3 posts)

  1. salexch
    Member
    Posted 1 year ago #

    Hi! I think you have a bug..
    trying to add content of the post with ajax, the shortcode of the plugin is not parsed..

    after I change line #35 in youtube-shortcode.php to
    if ( !is_admin() || FALSE !== strpos($_SERVER['SCRIPT_NAME'], 'wp-admin'))

    it started to work as expected

    http://wordpress.org/extend/plugins/youtube-shortcode/

  2. salexch
    Member
    Posted 1 year ago #

    // Constructor / initialize plugin
        function Youtube_shortcode()
        {
            // Load our shortcode only on the frontend
            if ( !is_admin() || FALSE !== strpos($_SERVER['SCRIPT_NAME'], 'wp-admin'))
            {
                // Is it a mobile phone?
                $this->detect_mobile();
                // Guess once host language (used for Youtube's old embed code = Flash only)
                $this->get_hl();
                // do_shortcode() is registered as a default filter on 'the_content' with a priority of 11.
                // To make videos appear on post excerpts follow this guide: http://bloggingsquared.com/blogging-tips/make-shortcodes-work-in-all-wordpress-post-excerpts/
                add_shortcode('youtube_sc', array($this, 'output_html'));
                add_action('wp_enqueue_scripts', array($this, 'output_css'));
            }
            // Allow the button to appear on any rich text editor (i.e. text editor in a widget)
    
    		add_action('admin_init', array($this, 'setup_tinymce_button'));
        }
  3. kabushi
    Member
    Posted 1 year ago #

    I also corrected this feature by
    /**
    * Check if WordPress is doing ajax or not. Helpful when testing for admin
    * templates because is_admin() will be true even though the user might not be
    * on admin, or even logged in.
    */
    function is_ajax()
    {
    return defined( 'DOING_AJAX' ) && DOING_AJAX;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic