Help to execute short code outside sender content area

To start, I use this plugin

http://wordpress.org/extend/plugins/my-youtube-playlist/ & amp; this topic, www.press75.com/themes/on-demand/this-is-a-sample-video-post-4/

My intention is for the youtube playlist to appear in the gray area of ​​the theme where only 1 video is currently displayed. my intention was to use the field to insert the Youtube code as a place where I could post a short plugin code and therefore have a plugin to create the playlist needed for the message. However, I was not able to get the plugin to execute short code if it is NOT placed in the message content area.

A theme creates a Div video container (gray area for video) when either a video link is placed or the embed video code is entered in the corresponding field of the theme.

I tried the following

  • Hard coding [myyoutubeplaylist LO3n67BQvh0, WGOohBytKTU, iwY5o2fsG7Y, PyKNxUThW4E, 1cX4t5-YpHQ, SJ183htYl-8, eWwoHPrrJYY, bja2ttzGOFM]php file into one post to find out if this plug will pick up. Bad luck. It just displays a short code on the screen.

  • Hardcoding <?php echo do_shortcode('[myyoutubeplaylist LO3n67BQvh0, WGOohBytKTU, iwY5o2fsG7Y, PyKNxUThW4E, 1cX4t5-YpHQ, SJ183htYl-8, eWwoHPrrJYY, bja2ttzGOFM]'); ?>to see if he picks it up. Bad luck. It simply displays a short code on the screen.

  • Give the dump pattern short code parameters as follows:
    <?php echo do_shortcode( get_video($post->ID); ?>. Bad luck. It just displays a short code on the screen.

  • Repeating all of the above outside the div container of the video created by the theme

I'm fresh from the idea, so any help would be SO appreciated

+3
5

functions.php:

add_filter('widget_text', 'do_shortcode');

, .

+1

TubePress

, CSS...

edit: shortcut codepress post/page ( , pro version tho)

0
<?php echo myYoutubePlaylist('[myyoutubeplaylist WnY59mDJ1gg, bKwQ_zeRwEs]'); ?>
0

, , , , , .

, , , . , , , , , .

YouTube, https://www.youtube.com/watch?v=eh7lp9umG2I, " ( ).

. , , "the_content".

, , , - DRY.

, .

function your_shortcode_handler($atts)
{
    $url = $atts['video'];

    if (isset($url))
    {
        $type = 'application/x-shockwave-flash';
        $url  = str_replace("watch?v=", 'v/', $url);

        $obj  = "<object data='$url' type='$type'><param name='src' value='$url' /></object>"

        return $obj;
    }
}

add_shortcode('your_shortcode_name', 'your_shortcode_handler');

function your_shortcode_filter($content)
{
    $pattern = "/\[your_shortcode_name(.*?)\]/";

    $content = preg_replace($pattern, '', $content);

    return $content;
}

add_filter('the_content', 'your_shortcode_filter');

function stealFromContent($content)
{
    $pattern = "/\[your_shortcode_name(.*?)\]/";
    $match = null;

    preg_match($pattern, $content, $match);

    if (is_array($match) and $match[0] != '')
    {
        return $match[0];
    }

    return '';
}

//somewhere in the template you're wanting to add the video to
//BEFORE the_content is called.
$youtube_video = stealFromContent();

//then

echo $youtube_video; //wherever you want it.

. , , . regexing the_content, , , javascript.

do_shortcode , . , , , - .

source file for reference.

0
source
-1
source

Source: https://habr.com/ru/post/1780541/


All Articles