Hire freelancer to do a small php job

Status
Not open for further replies.

jason212

Power Member
Joined
Feb 21, 2015
Messages
645
Reaction score
99
Hey,


I have a tube site and I want to change my code. If I click on one video it should be open and another tab (with the link which I addded) too. The link can stay in the code. This code is from loop-content.php. I hope its right.

<?php global $loop_view;
$ajaxload = get_option('dp_archive_ajaxload');
?>

<div class="loop-content switchable-view <?php echo $loop_view; ?>" data-view="<?php echo $loop_view; ?>" data-ajaxload=<?php echo $ajaxload; ?>>
<div class="nag cf">
<?php while (have_posts()) : the_post();
get_template_part('item-video');
endwhile; ?>
</div>
</div><!-- end .loop-content -->


You can write me a PM as well
 
Can't find you on skype
 
Added you. You have to response. I'm still waiting.
 
<div class="data">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permalink to %s', 'dp'), get_the_title()); ?>"><?php the_title(); ?></a></h2>


here is the right code, it should open the permalink + google.com in a new tab additionally.
 
Code:
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permalink to %s', 'dp'), get_the_title()); ?>"><?php the_title(); ?></a></h2>
change to
Code:
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permalink to %s', 'dp'), get_the_title()); ?>" onclick="window.open('http://google.com');
return true;"><?php the_title(); ?></a></h2>
 
Hello mate, thank you your code works. If I go click on the Link it works but when I click on the Thumbnail it doenst work. I think we have to edit this code too.

<div id="post-<?php the_ID(); ?>" <?php $item_format = is_video() ? 'video' : 'post'; post_class('item cf item-'.$item_format); ?>>
<?php
// Set image size based on section view, only for section box
global $section_view;
$thumb_size = 'custom-medium';
if(!empty($section_view)) {
if($section_view == 'list-large')
$thumb_size = 'custom-large';
elseif($section_view == 'grid-mini')
$thumb_size = 'custom-small';
}
dp_thumb_html($thumb_size);
?>


regards
 
there no thumb link on the current code, i think it will be on dp_thumb_html function, find the link tag (<a href) on that function, then add
Code:
onclick="window.open('http://google.com');
return true;"
inside the tag , like
Code:
<a onclick="window.open('http://google.com');
return true;"  href
 
I found this codes on looking for dp_thumb_html

under: cat-featured.php

Code:
       // Get items
       $items = '';
       $i = 0;
       while ($query->have_posts()) : $query->the_post();           
           $thumb_html = dp_thumb_html('custom-small', '', '', false);

functions.php

Code:
/**
 * Get Video Thumbnail URL
 *
 * @param string $size Optional. Image size. Defaults to 'custom-medium';.
 */
function dp_thumb_url($size = 'custom-medium', $default = '', $post_id = null, $echo = false){
   global $post;
  
   if(!$post_id)
       $post_id = $post->ID;
   if(!$size)
       $size == 'custom-medium';
  
   /* Check if this video has a feature image */
   if(has_post_thumbnail() && $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size))
       $thumb_url = $thumb[0];

   /* If no feature image, try to get thumbnail by "Video Thumbnails" plugin */
   if(empty($thumb_url) && function_exists('get_video_thumbnail')) {
       $video_thumbnail = get_video_thumbnail($post_id);
       if(!is_wp_error($video_thumbnail))
           $thumb_url = $video_thumbnail;
   }

   /* If this is a video by jplayer, try to get thumbnail from video_posts */
   if(empty($thumb_url) && $poster = get_post_meta($post_id, 'dp_video_poster', true))
       $thumb_url = $poster;
  
   /* If still no image or is wp error, define default image */
   if(empty($thumb_url) || is_wp_error($thumb_url)) {
       if($default === false || $default === 0)
           return false;
      
       $thumb_url = !empty($default) ? $default : get_template_directory_uri().'/images/nothumb.png';
   }
      
   if($echo)
       echo $thumb_url;
   else
       return $thumb_url;
}
/**
 * Display Video Thumbnail HTML
 *
 * @param int $size Optional. Image size. Defaults to 'custom-medium';.
 */
function dp_thumb_html($size = 'custom-medium', $default = '', $post_id = null, $echo = true) {
   global $post;
  
   if(!$post_id)
       $post_id = $post->ID;
   if(!$size)
       $size == 'custom-medium';
  
   // Get thumb url
   $thumb_url = dp_thumb_url($size, $default, $post_id, false);

   $html = '
   <div class="thumb">
       <a class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
           <span class="clip">
               <img src="'.$thumb_url.'" alt="'.esc_attr(get_the_title($post_id)).'" /><span class="vertical-align"></span>
           </span>
                          
           <span class="overlay"></span>
       </a>
   </div>';
  
   if($echo)
       echo $html;
   else
       return $html;
}

functions.php

Code:
    // Get image
        if (is_singular()) {
           global $post;
          
           // Get image by feature image
           $image = dp_thumb_url('large', false, $post->ID);

home-featured-full-width.php
Code:
           <div class="screen">
               <?php
                   if($i == 1 && !$autoscroll && is_video($post->ID) && $first_post_media == 'video') {
                       echo '<div class="video fluid-width-video-wrapper" data-ratio="16:9">';
                           dp_video($post->ID, $autoplay);
                       echo '</div>';
                   }
               ?>
              
               <?php dp_thumb_html('custom-full'); ?>
           </div>

home-featured.php

Code:
               <?php  
                   dp_thumb_html('custom-large');
               ?>

home-featured.php

Code:
    <div class="carousel">
       <div class="carousel-clip">
           <ul class="carousel-list">
               <?php $items = ''; $i = 0; while ($query->have_posts()) : $query->the_post(); global $post; ?>
               <li data-id="<?php the_ID(); ?>" class="<?php echo is_video() ? 'item-video' : 'item-post'; ?>">
               <div class="inner">
                   <?php
                   $thumb_size = 'custom-small';
                   dp_thumb_html($thumb_size);
                   ?>
          
                   <div class="data">
                       <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permalink to %s', 'dp'), get_the_title()); ?>"><?php the_title(); ?></a></h2>
          
                       <p class="meta">
                           <span class="time"><?php printf(__('%s ago', 'dp'), relative_time(get_post_time('U', true))); ?></span>
                       </p>
                   </div>
               </div>
               </li>
               <?php $i++; endwhile; ?>

item-video.php

Code:
    <div id="post-<?php the_ID(); ?>" <?php $item_format = is_video() ? 'video' : 'post'; post_class('item cf item-'.$item_format); ?>>
       <?php
           // Set image size based on section view, only for section box
           global $section_view;
           $thumb_size = 'custom-medium';
           if(!empty($section_view)) {
               if($section_view == 'list-large')
                   $thumb_size = 'custom-large';
               elseif($section_view == 'grid-mini')
                   $thumb_size = 'custom-small';
           }
           dp_thumb_html($thumb_size);
       ?>

single.php

Code:
               <?php
               // Thumbnail
               global $post;
               $post_type = get_post_type($post_type);
               $post_format = get_post_format($post->ID);
               if(!$post_format && $post_type == 'post' && get_option('dp_single_thumb')) {
                   $thumb_url = dp_thumb_url('custom-large', '', $post->ID, false);
                   if(!empty($thumb_url)) {
                       echo '<div id="thumb" class="rich-content"><img src="'.$thumb_url.'" alt="'.esc_attr(get_the_title($post->ID)).'" /><span class="vertical-align"></div>';
                   }
               }
               ?>

widget-posts.php

Code:
       <?php if ( $title ) echo $before_title . $title . $after_title; ?>
      
       <ul class="<?php echo 'post-'.$style; ?>">
           <?php while ($r->have_posts()) : $r->the_post(); $item_format = is_video() ? 'video' : 'post'; ?>
           <li class="item cf <?php echo 'item-'.$item_format; ?>">
               <?php
                   $image_size = ($style == 'list-full') ? 'custom-medium' : 'custom-small';
                   dp_thumb_html($image_size);
               ?>

widget-related-posts.php

Code:
       <ul class="<?php echo 'post-'.$style; ?>">
           <?php while ($r->have_posts()) : $r->the_post(); $item_format = is_video() ? 'video' : 'post'; ?>
           <li class="item cf <?php echo 'item-'.$item_format; ?>">
               <?php
                   $image_size = ($style == 'list-full') ? 'custom-medium' : 'custom-small';
                   dp_thumb_html($image_size);
               ?>

Thank you
 
find this code, inside function dp_thumb_html in file functions.php
Code:
      <a class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
change to

Code:
      <a onclick="window.open('http://google.com'); return true;" class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
because widely use of dp_thumb_html function in various files, every thumb link that use that function will have same effect, open google on another tab.
 
Last edited:
The site doenst work when I change the code:

Code:
<div class="thumb">
       <a class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
           <span class="clip">
               <img src="'.$thumb_url.'" alt="'.esc_attr(get_the_title($post_id)).'" /><span class="vertical-align"></span>
           </span>
                           
           <span class="overlay"></span>
       </a>
   </div>';

to

Code:
<div class="thumb">
             <a onclick="window.open('http://google.com'); return true;" class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
           <span class="clip">
               <img src="'.$thumb_url.'" alt="'.esc_attr(get_the_title($post_id)).'" /><span class="vertical-align"></span>
           </span>
                           
           <span class="overlay"></span>
       </a>
   </div>';
 
fixed

Code:
     <a onclick="window.open(\'http://google.com\'); return true;" class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
 
Still doenst work with this code:

Code:
function dp_thumb_html($size = 'custom-medium', $default = '', $post_id = null, $echo = true) {
   global $post;
   
   if(!$post_id)
       $post_id = $post->ID;
   if(!$size)
       $size == 'custom-medium';
   
   // Get thumb url
   $thumb_url = dp_thumb_url($size, $default, $post_id, false);

   $html = '
   <div class="thumb">
       <a onclick="window.open(\'http://google.com\'); return true;" class="clip-link" data-id="'.$post->ID.'" title="'.esc_attr(get_the_title($post_id)).'" href="'.get_permalink($post_id).'">
           <span class="clip">
               <img src="'.$thumb_url.'" alt="'.esc_attr(get_the_title($post_id)).'" /><span class="vertical-align"></span>
           </span>
                           
           <span class="overlay"></span>
       </a>
   </div>';
   
   if($echo)
       echo $html;
   else
       return $html;
}

The site is blank.
 
tested the partial code on my localhost, it worked, if you have teamviewer, send the id and pass via PM.
 
Status
Not open for further replies.
This thread has been auto closed due to the forum's thread age policy. Read more.
Back
Top