Results 1 to 2 of 2

Thread: Please help me to create this function

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

    Default Please help me to create this function

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

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

    http://www.iamclarence.com/blog/2012...epost-editing/

    I'm changing this code to work with vine.co 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);

    if(
    $youTubeMatch[1]){
        
    // return youtube embed code
    }else{
        return 
    null;

    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);

    if(
    $vineMatch[1]){
        
    // return vine embed code
    <iframe class="vine-embed" src="https://vine.co/v/'.$vineMatch[1].'embed/simple" width="600" height="600" frameborder="0"></iframe>
    <
    script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
    }else{
        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("http://vine.co/v/{$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?

    https://halgatewood.com/php-get-vine...deo-thumbnail/

    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
    Posts
    172
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

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