Results 1 to 2 of 2

Thread: Please help me to create this function

  1. #1
    Join Date
    Sep 2007
    Thanked 0 Times in 0 Posts

    Default Please help me to create this function

    I'm Adding a ( Meta Box to WordPress Page/Post.

    I found the guide which demonstrate how to add a custom meta box for (YouTube Videos) only.

    I'm changing this code to work with videos.

    I just replace the YouTube output with Vine output and change the variable names to improve readability.

    PHP Code:
    // original
    preg_match('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i'$featuredVideoURL$youTubeMatch);

    // return youtube embed code

    PHP Code:
        // new
        //   (for readability, replace all instances of "youTubeMatch"
        //      with "vineMatch"; leave everything else the same
    preg_match('/property="twitterlayer:stream" content="(.*?)"/'$featuredVideoURL$vineMatch);

    // return vine embed code
    <iframe class="vine-embed" src="'.$vineMatch[1].'embed/simple" width="600" height="600" frameborder="0"></iframe>
    script async src="//" charset="utf-8"></script>
        return null;

    This is the output code which I'm using in my theme

    PHP Code:
     <?php $the_video_output getFeaturedVideo($post->ID708366); echo $the_video_output?>
    I believe I am unable to implement the function correctly maybe there is something wrong in returning vine embed code.

    This is the Vine function which I want to replace with YouTube function

    PHP Code:
    function vine($id) { // gets the raw .mp4 url from the vine id
    $vine file_get_contents("{$id}");
    preg_match('/property="twitterlayer:stream" content="(.*?)"/'$vine$matches);
    return (
    $matches[1]) ? $matches[1] : false;

    Another function I want to merge is to get the vine featured image and set it automatically in WordPress using the guide below?

    If anyone can help it will be greatly appreciated. Thanks in advance.
    Last edited by bbilal; 03-04-2014 at 12:06 AM. Reason: Changed few things in the function

  2. #2
    Join Date
    Sep 2007
    Thanked 0 Times in 0 Posts


    Help Please

Similar Threads

  1. create a drop down menu with custom option?
    By slymongoose in forum HTML
    Replies: 10
    Last Post: 03-11-2010, 02:26 AM
  2. Create a custom CSS image Gallery
    By kandace in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 04-13-2008, 06:41 PM
  3. Trying to create a custom pop up
    By Castle_Rock in forum JavaScript
    Replies: 3
    Last Post: 03-09-2008, 12:48 PM
  4. Can anyone tell me how to create custom events??
    By shachi in forum JavaScript
    Replies: 34
    Last Post: 09-28-2006, 05:34 PM
  5. How can i create a custom visit counter?
    By artificialraven in forum HTML
    Replies: 0
    Last Post: 09-07-2005, 05:14 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts