I have a shortcode ( outputURL ) that is used to output a value into a URL. The value is retrieved from a shortcode ( valueURL ). The valueURL output is text wrapped in a div:
<div class="">textForURL</div>
I need only the textForURL value, excluding the div tags. Thus far, I have only been able to output the div tags and text but not the clean version of just text.
Here is my shortcode function:
function ouputURL(){
$content = '[valueURL id="5"]';
$clean = preg_replace("#<div.*?>.*?</div>#", "", $content);
echo do_shortcode( $clean );
}
add_shortcode('output', 'ouputURL');
I researched and was able to put this together but I am unsure as to whether I am heading in the right direction of executing it correctly. Any help to achieve my goal will be appreciated.
EDIT:
This is to further clarify my problem.
I am using a WordPress plugin which manages all embedded video URLs within a post;
As a feature, the plugin allows for a single video id ( i.e. vid=X23dw34 ) to be added through it's admin page which is viewed in a playlist prior to viewing the primary video;
I want to use an ad rotator plugin to manage multiple video id's and serve a single video id based upon the ad serving parameters and called by a shortcode ( i.e. [valueURL id="5"] );
The ad rotator plugin wraps a DIV around the video id:
<div class="">X23dw34</div>
- Using my function, I have been able to modify the plugin which manages the embedded video URLs to populate the video id including the div wrapper retrieved by the ad rotator shortcode. Unfortunately, the output result is:
"...video.com/embed/<div class="">X23dw34</div>..."
- My trouble has been to parse out the DIVs and only populate the video id to produce this:
"...video.com/embed/X23dw34..."
I am not sure if my limited understanding of shortcode and parsing is the issue or if my ultimate objective can not be handled by a simple function.
Please let me know if you require further information.
EDIT 2:
Here is the entire iframe, I removed extra tabs that to format it correctly:
<iframe width="100%" height="459" src="http://www.youtube.com/embed/oiE5qs8opqo?rel=0&autoplay=0&showinfo=0&controls=0&cc_load_policy=0&modestbranding=1&iv_load_policy=3&wmode=transparent&version=3&autohide=1" frameborder="0" allowfullscreen="true" allownetworking="internal"></iframe>