示例#1
0
function wppa_get_the_widget_thumb($type, $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents)
{
    // Init
    $result = '';
    // Get the id
    $id = $image ? $image['id'] : '0';
    // Fix url if audio
    if (wppa_has_audio($id)) {
        $imgurl = wppa_fix_poster_ext($imgurl, $id);
    }
    // Is it a video?
    $is_video = $id ? wppa_is_video($id) : false;
    // Get the video and audio bodies
    $videobody = $id ? wppa_get_video_body($id) : '';
    $audiobody = $id ? wppa_get_audio_body($id) : '';
    // Open container if an image must be displayed
    if ($display == 'thumbs') {
        $size = max($imgstyle_a['width'], $imgstyle_a['height']);
        $result .= '<div style="width:' . $size . 'px; height:' . $size . 'px; overflow:hidden;" >';
    }
    // The medals if on top
    if ($display == 'thumbs') {
        $result .= $id ? wppa_get_medal_html_a(array('id' => $id, 'size' => 'S', 'where' => 'top')) : '';
    }
    // Get the name
    $name = $id ? wppa_get_photo_name($id) : '';
    if ($link) {
        if ($link['is_url']) {
            // Is a href
            $result .= "\n\t" . '<a href="' . $link['url'] . '" title="' . $title . '" target="' . $link['target'] . '" >';
            $result .= "\n\t\t";
            if ($display == 'thumbs') {
                if ($is_video) {
                    $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgstyle_a['width'], 'height' => $imgstyle_a['height'], 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $imgevents, 'title' => $title));
                } else {
                    $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ($title ? ' title="' . $title . '"' : '') . ' src="' . $imgurl . '"' . ' width="' . $imgstyle_a['width'] . '"' . ' height="' . $imgstyle_a['height'] . '"' . ' style="' . $imgstyle_a['style'] . ' cursor:pointer;"' . ' ' . $imgevents . ' ' . wppa_get_imgalt($id) . ' />';
                }
            } else {
                $result .= $name;
            }
            $result .= "\n\t" . '</a>';
        } elseif ($link['is_lightbox']) {
            $title = wppa_get_lbtitle('thumb', $id);
            $videohtml = esc_attr($videobody);
            $audiohtml = esc_attr($audiobody);
            $result .= '<a href="' . $link['url'] . '"' . ($videohtml ? ' data-videohtml="' . $videohtml . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[' . $type . '-' . $album . '-' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' target="' . $link['target'] . '" >';
            $result .= "\n\t\t";
            if ($display == 'thumbs') {
                $title = wppa_zoom_in($id);
                if ($is_video) {
                    $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgstyle_a['width'], 'height' => $imgstyle_a['height'], 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $imgstyle_a['cursor'], 'events' => $imgevents, 'title' => $title));
                } else {
                    $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ($title ? ' title="' . $title . '"' : '') . ' src="' . $imgurl . '"' . ' width="' . $imgstyle_a['width'] . '"' . ' height="' . $imgstyle_a['height'] . '"' . ' style="' . $imgstyle_a['style'] . $imgstyle_a['cursor'] . '"' . ' ' . $imgevents . ' ' . wppa_get_imgalt($id) . ' />';
                }
            } else {
                $result .= $name;
            }
            $result .= "\n\t" . '</a>';
        } else {
            // Is an onclick unit
            $result .= "\n\t";
            if ($display == 'thumbs') {
                if ($is_video) {
                    $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgstyle_a['width'], 'height' => $imgstyle_a['height'], 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $imgevents, 'title' => $title, 'onclick' => $link['url']));
                } else {
                    $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ($title ? ' title="' . $title . '"' : '') . ' src="' . $imgurl . '"' . ' width="' . $imgstyle_a['width'] . '"' . ' height="' . $imgstyle_a['height'] . '"' . ' style="' . $imgstyle_a['style'] . ' cursor:pointer;"' . ' ' . $imgevents . ' onclick="' . $link['url'] . '"' . ' ' . wppa_get_imgalt($id) . ' />';
                }
            } else {
                $result .= '<a' . ' style="cursor:pointer;"' . ' onclick="' . $link['url'] . '"' . ' >' . $name . '</a>';
            }
        }
    } else {
        // No link
        $result .= "\n\t";
        if ($display == 'thumbs') {
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgstyle_a['width'], 'height' => $imgstyle_a['height'], 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $imgevents, 'title' => $title));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ($title ? ' title="' . $title . '"' : '') . ' src="' . $imgurl . '"' . ' width="' . $imgstyle_a['width'] . '"' . ' height="' . $imgstyle_a['height'] . '"' . ' style="' . $imgstyle_a['style'] . '"' . ' ' . $imgevents . ' ' . wppa_get_imgalt($id) . ' />';
            }
        } else {
            $result .= $name;
        }
    }
    // The medals if at the bottom
    if ($display == 'thumbs') {
        $result .= $id ? wppa_get_medal_html_a(array('id' => $id, 'size' => 'S', 'where' => 'bot')) : '';
    }
    // Close container
    if ($display == 'thumbs') {
        $result .= '</div>';
    }
    return $result;
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     wppa('in_widget', 'potd');
     wppa_bump_mocc();
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     extract($args);
     $widget_title = apply_filters('widget_title', $instance['title']);
     // get the photo  ($image)
     $image = wppa_get_potd();
     // Make the HTML for current picture
     $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->';
     $ali = wppa_opt('potd_align');
     if ($ali != 'none') {
         $align = 'text-align:' . $ali . ';';
     } else {
         $align = '';
     }
     $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px;position:relative;" >';
     if ($image) {
         $id = $image['id'];
         $w = wppa_opt('potd_widget_width');
         $ratio = wppa_get_photoy($id) / wppa_get_photox($id);
         $h = round($w * $ratio);
         $usethumb = wppa_use_thumb_file($id, wppa_opt('potd_widget_width'), '0');
         $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id);
         $name = wppa_get_photo_name($id);
         $page = in_array(wppa_opt('potd_linktype'), wppa('links_no_page')) && !wppa_switch('potd_counter') ? '' : wppa_get_the_landing_page('potd_linkpage', __('Photo of the day', 'wp-photo-album-plus'));
         $link = wppa_get_imglnk_a('potdwidget', $id);
         $is_video = wppa_is_video($id);
         $has_audio = wppa_has_audio($id);
         if ($link['is_lightbox']) {
             $lightbox = ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"';
         } else {
             $lightbox = '';
         }
         if ($link) {
             if ($link['is_lightbox']) {
                 $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('magnifier') . '),pointer;';
                 $title = wppa_zoom_in($id);
                 $ltitle = wppa_get_lbtitle('potd', $id);
             } else {
                 $cursor = ' cursor:pointer;';
                 $title = $link['title'];
                 $ltitle = $title;
             }
         } else {
             $cursor = ' cursor:default;';
             $title = esc_attr(stripslashes(__($image['name'], 'wp-photo-album-plus')));
         }
         // The medal if on top
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
         // The link, if any
         if ($link) {
             $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">';
         }
         // The image
         if (wppa_is_video($id)) {
             $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('potd_linktype') == 'none', 'cursor' => $cursor));
         } else {
             $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . ' />';
         }
         // Close the link
         if ($link) {
             $widget_content .= '</a>';
         }
         // The medal if at the bottom
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
         // The counter
         if (wppa_switch('potd_counter')) {
             // If we want this
             $alb = wppa_get_photo_item($id, 'album');
             $c = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = " . $alb) - 1;
             if ($c > 0) {
                 if (wppa_opt('potd_counter_link') == 'thumbs') {
                     $lnk = wppa_get_album_url($alb, $page, 'thumbs', '1');
                 } elseif (wppa_opt('potd_counter_link') == 'slide') {
                     $lnk = wppa_get_slideshow_url($alb, $page, $id, '1');
                 } elseif (wppa_opt('potd_counter_link') == 'single') {
                     $lnk = wppa_encrypt_url(get_permalink($page) . '?occur=1&photo=' . $id);
                     //	wppa_get_image_page_url_by_id( $id, true, false, $page );
                 } else {
                     wppa_log('Err', 'Unimplemented counter link type in wppa-potd-widget: ' . wppa_opt('potd_counter_link'));
                 }
                 $widget_content .= '<a href="' . $lnk . '" >' . '<div style="font-size:12px;position:absolute;right:4px;bottom:4px;" >+' . $c . '</div>' . '</a>';
             }
         }
         // Audio
         if (wppa_has_audio($id)) {
             $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'controls' => true));
         }
     } else {
         // No image
         $widget_content .= __('Photo not found', 'wp-photo-album-plus');
     }
     $widget_content .= "\n" . '</div>';
     // Add subtitle, if any
     if ($image) {
         switch (wppa_opt('potd_subtitle')) {
             case 'none':
                 break;
             case 'name':
                 $widget_content .= '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>';
                 break;
             case 'desc':
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>';
                 break;
             case 'owner':
                 $owner = $image['owner'];
                 $user = get_user_by('login', $owner);
                 $owner = $user->display_name;
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __('By:', 'wp-photo-album-plus') . ' ' . $owner . '</div>';
                 break;
             default:
                 wppa_log('Err', 'Unimplemented potd_subtitle found in wppa-potd-widget: ' . wppa_opt('potd_subtitle'));
         }
     }
     $widget_content .= '<div style="clear:both;" ></div>';
     $widget_content .= "\n" . '<!-- WPPA+ Photo of the day Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
示例#3
0
function wppa_bestof_html($args, $widget = true)
{
    // Copletify args
    $args = wp_parse_args((array) $args, array('page' => '0', 'count' => '1', 'sortby' => 'maxratingcount', 'display' => 'photo', 'period' => 'thisweek', 'maxratings' => 'yes', 'meanrat' => 'yes', 'ratcount' => 'yes', 'linktype' => 'none', 'size' => wppa_opt('widget_width'), 'fontsize' => wppa_opt('fontsize_widget_thumb'), 'lineheight' => wppa_opt('fontsize_widget_thumb') * 1.5, 'height' => '200'));
    // Make args into seperate vars
    extract($args);
    // Validate args
    if (!in_array($sortby, array('maxratingcount', 'meanrating', 'ratingcount'))) {
        wppa_dbg_msg('Invalid arg sortby "' . $sortby . '" must be "maxratingcount", "meanrating" or "ratingcount"', 'red', 'force');
    }
    if (!in_array($display, array('photo', 'owner'))) {
        wppa_dbg_msg('Invalid arg display "' . $display . '" must be "photo" or "owner"', 'red', 'force');
    }
    if (!in_array($period, array('lastweek', 'thisweek', 'lastmonth', 'thismonth', 'lastyear', 'thisyear'))) {
        wppa_dbg_msg('Invalid arg period "' . $period . '" must be "lastweek", "thisweek", "lastmonth", "thismonth", "lastyear" or "thisyear"', 'red', 'force');
    }
    if (!$widget) {
        $size = $height;
    }
    $result = '';
    $data = wppa_get_the_bestof($count, $period, $sortby, $display);
    if ($display == 'photo') {
        if (is_array($data)) {
            foreach (array_keys($data) as $id) {
                $thumb = wppa_cache_thumb($id);
                if ($thumb) {
                    $imgsize = array(wppa_get_photox($id), wppa_get_photoy($id));
                    if ($widget) {
                        $maxw = $size;
                        $maxh = round($maxw * $imgsize['1'] / $imgsize['0']);
                    } else {
                        $maxh = $size;
                        $maxw = round($maxh * $imgsize['0'] / $imgsize['1']);
                    }
                    $totalh = $maxh + $lineheight;
                    if ($maxratings == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($meanrat == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($ratcount == 'yes') {
                        $totalh += $lineheight;
                    }
                    if ($widget) {
                        $clear = 'clear:both; ';
                    } else {
                        $clear = '';
                    }
                    $result .= "\n" . '<div' . ' class="wppa-widget"' . ' style="' . $clear . 'width:' . $maxw . 'px; height:' . $totalh . 'px; margin:4px; display:inline; text-align:center; float:left;"' . ' >';
                    // The medal if at the top
                    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
                    // The link if any
                    if ($linktype != 'none') {
                        switch ($linktype) {
                            case 'owneralbums':
                                $href = wppa_get_permalink($page) . 'wppa-cover=1&amp;wppa-owner=' . $thumb['owner'] . '&amp;wppa-occur=1';
                                $title = __('See the authors albums', 'wp-photo-album-plus');
                                break;
                            case 'ownerphotos':
                                $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-owner=' . $thumb['owner'] . '&photos-only&amp;wppa-occur=1';
                                $title = __('See the authors photos', 'wp-photo-album-plus');
                                break;
                            case 'upldrphotos':
                                $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-upldr=' . $thumb['owner'] . '&amp;wppa-occur=1';
                                $title = __('See all the authors photos', 'wp-photo-album-plus');
                                break;
                        }
                        $result .= '<a href="' . wppa_convert_to_pretty($href) . '" title="' . $title . '" >';
                    }
                    // The image
                    $result .= '<img' . ' style="height:' . $maxh . 'px; width:' . $maxw . 'px;"' . ' src="' . wppa_fix_poster_ext(wppa_get_photo_url($id, '', $maxw, $maxh), $id) . '"' . ' ' . wppa_get_imgalt($id) . ' />';
                    // The /link
                    if ($linktype != 'none') {
                        $result .= '</a>';
                    }
                    // The medal if near the bottom
                    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
                    // The subtitles
                    $result .= "\n\t" . '<div style="font-size:' . $fontsize . 'px; line-height:' . $lineheight . 'px; position:absolute; width:' . $maxw . 'px; ">';
                    $result .= sprintf(__('Photo by: %s', 'wp-photo-album-plus'), $data[$id]['user']) . '<br />';
                    if ($maxratings == 'yes') {
                        $n = $data[$id]['maxratingcount'];
                        $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />';
                    }
                    if ($ratcount == 'yes') {
                        $n = $data[$id]['ratingcount'];
                        $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />';
                    }
                    if ($meanrat == 'yes') {
                        $m = $data[$id]['meanrating'];
                        $result .= sprintf(__('Rating: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />';
                    }
                    $result .= '</div>';
                    $result .= '<div style="clear:both" ></div>';
                    $result .= "\n" . '</div>';
                } else {
                    // No image
                    $result .= '<div>' . sprintf(__('Photo %s not found.', 'wp-photo-album-plus'), $id) . '</div>';
                }
            }
        } else {
            $result .= $data;
            // No array, print message
        }
    } else {
        // Display = owner
        if (is_array($data)) {
            $result .= '<ul>';
            foreach (array_keys($data) as $author) {
                $result .= '<li>';
                // The link if any
                if ($linktype != 'none') {
                    switch ($linktype) {
                        case 'owneralbums':
                            $href = wppa_get_permalink($page) . 'wppa-cover=1&amp;wppa-owner=' . $data[$author]['owner'] . '&amp;wppa-occur=1';
                            $title = __('See the authors albums', 'wp-photo-album-plus');
                            break;
                        case 'ownerphotos':
                            $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-owner=' . $data[$author]['owner'] . '&amp;photos-only&amp;wppa-occur=1';
                            $title = __('See the authors photos', 'wp-photo-album-plus');
                            break;
                        case 'upldrphotos':
                            $href = wppa_get_permalink($page) . 'wppa-cover=0&amp;wppa-upldr=' . $data[$author]['owner'] . '&amp;wppa-occur=1';
                            $title = __('See all the authors photos', 'wp-photo-album-plus');
                            break;
                    }
                    $result .= '<a href="' . $href . '" title="' . $title . '" >';
                }
                // The name
                $result .= $author;
                // The /link
                if ($linktype != 'none') {
                    $result .= '</a>';
                }
                $result .= '<br/>';
                // The subtitles
                $result .= "\n" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px; ">';
                if ($maxratings == 'yes') {
                    $n = $data[$author]['maxratingcount'];
                    $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />';
                }
                if ($ratcount == 'yes') {
                    $n = $data[$author]['ratingcount'];
                    $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />';
                }
                if ($meanrat == 'yes') {
                    $m = $data[$author]['meanrating'];
                    $result .= sprintf(__('Mean value: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />';
                }
                $result .= '</div>';
                $result .= '</li>';
            }
            $result .= '</ul>';
        } else {
            $result .= $data;
            // No array, print message
        }
    }
    return $result;
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa;
     $wppa['in_widget'] = 'potd';
     $wppa['mocc']++;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     extract($args);
     $widget_title = apply_filters('widget_title', $instance['title']);
     // get the photo  ($image)
     $image = wppa_get_potd();
     // Make the HTML for current picture
     $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->';
     $ali = wppa_opt('wppa_potd_align');
     if ($ali != 'none') {
         $align = 'text-align:' . $ali . ';';
     } else {
         $align = '';
     }
     $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px; ">';
     if ($image) {
         $id = $image['id'];
         $w = wppa_opt('wppa_potd_widget_width');
         $ratio = wppa_get_photoy($id) / wppa_get_photox($id);
         $h = round($w * $ratio);
         $usethumb = wppa_use_thumb_file($id, wppa_opt('wppa_widget_width'), '0');
         $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id);
         $name = wppa_get_photo_name($id);
         $page = in_array(wppa_opt('wppa_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_widget_linkpage', __a('Photo of the day'));
         $link = wppa_get_imglnk_a('potdwidget', $id);
         $is_video = wppa_is_video($id);
         $has_audio = wppa_has_audio($id);
         if ($link['is_lightbox']) {
             $lightbox = ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"';
         } else {
             $lightbox = '';
         }
         if ($link) {
             if ($link['is_lightbox']) {
                 $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('wppa_magnifier') . '),pointer;';
                 $title = wppa_zoom_in($id);
                 $ltitle = wppa_get_lbtitle('potd', $id);
             } else {
                 $cursor = ' cursor:pointer;';
                 $title = $link['title'];
                 $ltitle = $title;
             }
         } else {
             $cursor = ' cursor:default;';
             $title = esc_attr(stripslashes(__($image['name'])));
         }
         // The medal if on top
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
         // The link, if any
         if ($link) {
             $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">';
         }
         // The image
         if (wppa_is_video($id)) {
             $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('widget_linktype') == 'none', 'cursor' => $cursor));
         } else {
             $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('wppa_potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . '/ >';
         }
         // Close the link
         if ($link) {
             $widget_content .= "\n\t" . '</a>';
         }
         // The medal if at the bottom
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
         // Audio
         if (wppa_has_audio($id)) {
             $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('wppa_potd_widget_width'), 'controls' => true));
         }
     } else {
         // No image
         $widget_content .= __a('Photo not found.', 'wppa_theme');
     }
     $widget_content .= "\n" . '</div>';
     // Add subtitle, if any
     switch (wppa_opt('wppa_widget_subtitle')) {
         case 'none':
             break;
         case 'name':
             if ($image && $image['name'] != '') {
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>';
             }
             break;
         case 'desc':
             if ($image && $image['description'] != '') {
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>';
             }
             break;
         case 'owner':
             if ($image) {
                 $owner = $image['owner'];
                 $user = get_user_by('login', $owner);
                 $owner = $user->display_name;
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __a('By:') . ' ' . $owner . '</div>';
             }
     }
     $widget_content .= "\n" . '<!-- WPPA+ Photo of the day Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     $wppa['in_widget'] = false;
 }