function wppa_add_metatags() { global $wpdb; // Share info for sm that uses og $id = wppa_get_get('photo'); if (!wppa_photo_exists($id)) { $id = false; } if ($id) { // SM may not accept images from the cloud. wppa('for_sm', true); $imgurl = wppa_get_photo_url($id); wppa('for_sm', false); if (wppa_is_video($id)) { $imgurl = wppa_fix_poster_ext($imgurl, $id); } } else { $imgurl = ''; } if ($id) { if (wppa_switch('og_tags_on')) { $thumb = wppa_cache_thumb($id); if ($thumb) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); $mime = wppa_get_mime_type($id); echo ' <!-- WPPA+ Og Share data --> <meta property="og:site_name" content="' . esc_attr(sanitize_text_field($site)) . '" /> <meta property="og:type" content="article" /> <meta property="og:url" content="' . $url . '" /> <meta property="og:title" content="' . esc_attr(sanitize_text_field($title)) . '" />'; if ($mime) { echo ' <meta property="og:image" content="' . esc_url(sanitize_text_field($imgurl)) . '" /> <meta property="og:image:type" content="' . $mime . '" /> <meta property="og:image:width" content="' . wppa_get_photox($id) . '" /> <meta property="og:image:height" content="' . wppa_get_photoy($id) . '" />'; } if ($desc) { echo ' <meta property="og:description" content="' . esc_attr(sanitize_text_field($desc)) . '" />'; } echo ' <!-- WPPA+ End Og Share data --> '; } } if (wppa_switch('share_twitter') && wppa_opt('twitter_account')) { $thumb = wppa_cache_thumb($id); // Twitter wants at least 280px in width, and at least 150px in height if ($thumb) { $x = wppa_get_photo_item($id, 'photox'); $y = wppa_get_photo_item($id, 'photoy'); } if ($thumb && $x >= 280 && $y >= 150) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); echo ' <!-- WPPA+ Twitter Share data --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:creator" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:title" content="' . esc_attr(sanitize_text_field($title)) . '"> <meta name="twitter:description" content="' . esc_attr(sanitize_text_field($desc)) . '"> <meta name="twitter:image" content="' . esc_url(sanitize_text_field($imgurl)) . '"> <!-- WPPA+ End Twitter Share data --> '; } elseif ($thumb && $x >= 120 && $y >= 120) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); echo ' <!-- WPPA+ Twitter Share data --> <meta name="twitter:card" content="summary"> <meta name="twitter:site" content="' . wppa_opt('twitter_account') . '"> <meta name="twitter:title" content="' . esc_attr(sanitize_text_field($title)) . '"> <meta name="twitter:description" content="' . esc_attr(sanitize_text_field($desc)) . '"> <meta name="twitter:image" content="' . esc_url(sanitize_text_field($imgurl)) . '"> <!-- WPPA+ End Twitter Share data --> '; } } } // To make sure we are on a page that contains at least [wppa] we check for Get var 'wppa-album'. // This also narrows the selection of featured photos to those that exist in the current album. $done = array(); $album = ''; if (isset($_REQUEST['album'])) { $album = $_REQUEST['album']; } elseif (isset($_REQUEST['wppa-album'])) { $album = $_REQUEST['wppa-album']; } $album = strip_tags($album); if (strlen($album == 12)) { $album = wppa_get_get('album'); } if ($album) { if (wppa_switch('meta_page')) { $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'featured'", $album), ARRAY_A); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this page -->"; foreach ($photos as $photo) { $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this page -->\n"; } } } elseif (wppa_switch('meta_all')) { $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured'", ARRAY_A); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this site -->"; foreach ($photos as $photo) { $thumb = $photo; // Set to global to reduce queries when getting the name $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this site -->\n"; } } // Facebook Admin and App if ((wppa_switch('share_on') || wppa_switch('share_on_widget')) && (wppa_switch('facebook_comments') || wppa_switch('facebook_like') || wppa_switch('share_facebook'))) { echo "\n<!-- WPPA+ BEGIN Facebook meta tags -->"; if (wppa_opt('facebook_admin_id')) { echo "\n\t<meta property=\"fb:admins\" content=\"" . wppa_opt('facebook_admin_id') . "\" />"; } if (wppa_opt('facebook_app_id')) { echo "\n\t<meta property=\"fb:app_id\" content=\"" . wppa_opt('facebook_app_id') . "\" />"; } if ($imgurl) { echo ' <link rel="image_src" href="' . esc_url($imgurl) . '" />'; } echo ' <!-- WPPA+ END Facebook meta tags --> '; } }
function wppa_add_metatags() { global $wpdb; global $thumb; // Share info for sm that uses og $id = wppa_get_get('photo'); if ($id) { $imgurl = wppa_get_photo_url($id); if (wppa_is_video($id)) { $imgurl = wppa_fix_poster_ext($imgurl, $id); } } else { $imgurl = ''; } if ($id) { if (wppa_switch('wppa_og_tags_on')) { wppa_cache_thumb($id); if ($thumb) { $title = wppa_get_photo_name($id); $desc = wppa_get_og_desc($id); $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $site = get_bloginfo('name'); echo ' <!-- WPPA+ Share data --> <meta property="og:site_name" content="' . esc_attr(sanitize_text_field($site)) . '" /> <meta property="og:type" content="article" /> <meta property="og:url" content="' . esc_url(sanitize_text_field($url)) . '" /> <meta property="og:title" content="' . esc_attr(sanitize_text_field($title)) . '" /> <meta property="og:image" content="' . esc_url(sanitize_text_field($imgurl)) . '" /> <meta property="og:description" content="' . esc_attr(sanitize_text_field($desc)) . '" /> <!-- WPPA+ End Share data --> '; } } } // To make sure we are on a page that contains at least %%wppa%% we check for Get var 'wppa-album'. // This also narrows the selection of featured photos to those that exist in the current album. $done = array(); if (wppa_get_get('album')) { if (wppa_switch('wppa_meta_page')) { $album = wppa_get_get('album'); $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'featured'", $album), ARRAY_A); wppa_dbg_q('Q-meta1'); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this page -->"; foreach ($photos as $photo) { $thumb = $photo; // Set to global to reduce queries when getting the name $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this page -->\n"; } } } elseif (wppa_switch('wppa_meta_all')) { $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured'", ARRAY_A); wppa_dbg_q('Q-meta2'); wppa_cache_photo('add', $photos); if ($photos) { echo "\n<!-- WPPA+ BEGIN Featured photos on this site -->"; foreach ($photos as $photo) { $thumb = $photo; // Set to global to reduce queries when getting the name $id = $photo['id']; $content = esc_attr(sanitize_text_field(wppa_get_keywords($id))); if ($content && !in_array($content, $done)) { echo ' <meta name="keywords" content="' . $content . '" >'; $done[] = $content; } } echo "\n<!-- WPPA+ END Featured photos on this site -->\n"; } } // Facebook Admin and App if ((wppa_switch('wppa_share_on') || wppa_switch('wppa_share_on_widget')) && (wppa_switch('wppa_facebook_comments') || wppa_switch('wppa_facebook_like') || wppa_switch('wppa_share_facebook'))) { echo "\n<!-- WPPA+ BEGIN Facebook meta tags -->"; if (wppa_opt('wppa_facebook_admin_id')) { echo "\n\t<meta property=\"fb:admins\" content=\"" . wppa_opt('wppa_facebook_admin_id') . "\" />"; } if (wppa_opt('wppa_facebook_app_id')) { echo "\n\t<meta property=\"fb:app_id\" content=\"" . wppa_opt('wppa_facebook_app_id') . "\" />"; } if ($imgurl) { echo ' <link rel="image_src" href="' . esc_url($imgurl) . '" />'; } echo ' <!-- WPPA+ END Facebook meta tags --> '; } }
function wppa_get_lores_url($id) { $lores_url = wppa_fix_poster_ext(wppa_get_photo_url($id), $id); $temp = explode('?', $lores_url); $lores_url = $temp['0']; return $lores_url; }
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
function wppa_get_audio_body($id, $for_lb = false, $w = '0', $h = '0') { // Audio enabled? if (!wppa_switch('enable_audio')) { return ''; } $is_audio = wppa_has_audio($id, true); // Not a audio? no go if (!$is_audio) { return ''; } // See what file types are present extract(wp_parse_args($is_audio, array('mp3' => false, 'wav' => false, 'ogg' => false))); // Collect other data $width = $w ? $w : wppa_get_photox($id); $height = $h ? $h : wppa_get_photoy($id); $source = wppa_get_photo_url($id); $source = substr($source, 0, strrpos($source, '.')); $class = $for_lb ? ' class="wppa-overlay-img"' : ''; $is_opera = strpos($_SERVER["HTTP_USER_AGENT"], 'OPR'); $is_ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident'); $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari'); wppa_dbg_msg('Mp3:' . $mp3 . ', Opera:' . $is_opera . ', Ie:' . $is_ie . ', Saf:' . $is_safari); // Assume the browser supports html5 $ext = ''; if ($is_ie) { if ($mp3) { $ext = 'mp3'; } } elseif ($is_safari) { if ($mp3) { $ext = 'mp3'; } elseif ($wav) { $ext = 'wav'; } } else { if ($mp3) { $ext = 'mp3'; } elseif ($wav) { $ext = 'wav'; } elseif ($ogg) { $ext = 'ogg'; } } if ($ext) { $mime = str_replace('mp3', 'mpeg', 'audio/' . $ext); $result = '<source src="' . $source . '.' . $ext . '" type="' . $mime . '">'; } $result .= esc_js(__('There is no filetype available for your browser, or your browser does not support html5 audio', 'wp-photo-album-plus')); return $result; }
function wppa_sphoto() { $id = wppa('single_photo'); $width = wppa_get_container_width(); $height = floor($width / wppa_get_ratio($id)); $usethumb = wppa_use_thumb_file($id, $width, $height); $src = $usethumb ? wppa_get_thumb_url($id, '', $width, $height) : wppa_get_photo_url($id, '', $width, $height); if (wppa_has_audio($id)) { $src = wppa_fix_poster_ext($src, $id); } if (!wppa_in_widget()) { wppa_bump_viewcount('photo', $id); } $autocol = wppa('auto_colwidth') || $width > 0 && $width <= 1.0; // The initial width is $width if not autocol, else it should default to initial column width when auto // or initial column width * fraction if ($autocol) { if ($width == 'auto') { $contwidth = wppa_opt('initial_colwidth'); } else { $contwidth = wppa_opt('initial_colwidth') * $width; } } else { $contwidth = $width; } // Open the pseudo container wppa_out('<div' . ' id="wppa-container-' . wppa('mocc') . '"' . ' class="' . (wppa('align') ? 'align' . wppa('align') : '') . ' wppa-sphoto-' . wppa('mocc') . '"' . ' style="width:' . $contwidth . 'px;position:relative;"' . ' >'); // The script for responsive wppa_add_js_page_data("\n" . '<script type="text/javascript">'); if ($autocol) { wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = true;'); if ($width > 0 && $width <= 1.0) { wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = ' . $width . ';'); } else { wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = 1.0;'); } wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = 0;'); } wppa_add_js_page_data("\n" . 'wppaTopMoc = ' . wppa('mocc') . ';'); wppa_add_js_page_data("\n" . '</script>'); wppa('portrait_only', true); $fis = wppa_get_fullimgstyle_a($id); $width = $fis['width']; $height = $fis['height']; $style = $fis['style']; $style .= 'box-sizing:content-box;vertical-align:middle;'; // The link $link = wppa_get_imglnk_a('sphoto', $id); if ($link) { if ($link['is_lightbox']) { $lbtitle = wppa_get_lbtitle('sphoto', $id); $videobody = esc_attr(wppa_get_video_body($id)); $audiobody = esc_attr(wppa_get_audio_body($id)); $videox = wppa_get_videox($id); $videoy = wppa_get_videoy($id); wppa_out('<a' . ' href="' . $link['url'] . '"' . ($lbtitle ? ' ' . wppa('lbtitle') . '="' . $lbtitle . '"' : '') . ($videobody ? ' data-videohtml="' . $videobody . '"' : '') . ($audiobody ? ' data-audiohtml="' . $audiobody . '"' : '') . ($videox ? ' data-videonatwidth="' . $videox . '"' : '') . ($videoy ? ' data-videonatheight="' . $videoy . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ($link['target'] ? ' target="' . $link['target'] . '"' : '') . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >'); } else { wppa_out('<a' . ' href="' . $link['url'] . '"' . ' title="' . $link['title'] . '"' . ' target="' . $link['target'] . '"' . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >'); } } // The image $title = $link ? esc_attr($link['title']) : esc_attr(stripslashes(wppa_get_photo_name($id))); if ($link['is_lightbox']) { $style .= ' cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;'; $title = wppa_zoom_in($id); } if (wppa_is_video($id)) { if ($autocol) { wppa_out(wppa_get_video_html(array('id' => $id, 'controls' => !$link['is_lightbox'], 'style' => $style, 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc')))); } else { wppa_out(wppa_get_video_html(array('id' => $id, 'width' => $width, 'height' => $height, 'controls' => !$link['is_lightbox'], 'style' => $style, 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc')))); } } else { wppa_out('<img' . ' src="' . $src . '"' . ' ' . wppa_get_imgalt($id) . ' class="size-medium wppa-sphoto wppa-simg-' . wppa('mocc') . '"' . ' ' . wppa_get_imgalt($id) . ($title ? ' title="' . $title . '" ' : '') . ' style="' . $style . '"' . ($autocol ? '' : ' width="' . $width . '" height="' . $height . '" ') . '/ >'); } // Close the link if ($link) { wppa_out('</a>'); } // Add audio? sphoto if (wppa_has_audio($id)) { wppa_out('<div style="position:relative;z-index:11;" >'); $margl = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') + 1; $margb = $margl; wppa_out(wppa_get_audio_html(array('id' => $id, 'cursor' => 'cursor:pointer;', 'style' => $style . 'position:absolute;' . 'left:' . $margl . 'px;' . 'bottom:' . $margb . 'px;' . 'padding:0;' . 'margin:0;' . 'border:none;' . 'height:' . wppa_get_audio_control_height() . 'px;' . 'border-radius:0;', 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc')))); wppa_out('</div>'); } // The pseudo container wppa_out('</div>'); }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; global $wppa; global $thumb; 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(); $wppa['in_widget'] = 'alb'; $wppa['mocc']++; extract($args); $instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => 'none', 'name' => 'no', 'skip' => 'yes')); $widget_title = apply_filters('widget_title', $instance['title']); $page = in_array(wppa_opt('wppa_album_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_album_widget_linkpage', __a('Photo Albums')); $max = wppa_opt('wppa_album_widget_count'); if (!$max) { $max = '10'; } $parent = $instance['parent']; $name = $instance['name']; $skip = $instance['skip']; if (is_numeric($parent)) { $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . wppa_get_album_order($parent), $parent), ARRAY_A); } else { switch ($parent) { case 'all': $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ' . wppa_get_album_order(), ARRAY_A); break; case 'last': $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ORDER BY `timestamp` DESC', ARRAY_A); break; default: wppa_dbg_msg('Error, unimplemented album selection: ' . $parent . ' in Album widget.', 'red', true); } } $widget_content = "\n" . '<!-- WPPA+ album Widget start -->'; $maxw = wppa_opt('wppa_album_widget_size'); $maxh = $maxw; if ($name == 'yes') { $maxh += 18; } $count = 0; if ($albums) { foreach ($albums as $album) { if ($count < $max) { global $thumb; $imageid = wppa_get_coverphoto_id($album['id']); $image = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $imageid), ARRAY_A); $imgcount = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . WPPA_PHOTOS . ' WHERE `album` = %s', $album['id'])); $subalbumcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $album['id'])); $thumb = $image; // Make the HTML for current picture if ($image && ($imgcount > wppa_opt('wppa_min_thumbs') || $subalbumcount)) { $link = wppa_get_imglnk_a('albwidget', $image['id']); $file = wppa_get_thumb_path($image['id']); $imgevents = wppa_get_imgevents('thumb', $image['id'], true); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $cursor = $imgstyle_a['cursor']; if (wppa_switch('wppa_show_albwidget_tooltip')) { $title = esc_attr(strip_tags(wppa_get_album_desc($album['id']))); } else { $title = ''; } $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height); } else { $link = ''; $file = ''; $imgevents = ''; $imgstyle = 'width:' . $maxw . ';height:' . $maxh . ';'; $width = $maxw; $height = $maxw; // !! $cursor = 'default'; $title = sprintf(__a('Upload at least %d photos to this album!', 'wppa_theme'), wppa_opt('wppa_min_thumbs') - $imgcount + 1); if ($imageid) { // The 'empty album has a cover image $file = wppa_get_thumb_path($image['id']); $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb'); $imgstyle = $imgstyle_a['style']; $width = $imgstyle_a['width']; $height = $imgstyle_a['height']; $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height); } else { $imgurl = wppa_get_imgdir() . 'album32.png'; } } $imgurl = wppa_fix_poster_ext($imgurl, $image['id']); if ($imgcount > wppa_opt('wppa_min_thumbs') || $skip == 'no') { $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">'; if ($link) { if ($link['is_url']) { // Is a href $widget_content .= "\n\t" . '<a href="' . $link['url'] . '" title="' . $title . '" target="' . $link['target'] . '" >'; if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } $widget_content .= "\n\t" . '</a>'; } elseif ($link['is_lightbox']) { $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A'); if ($thumbs) { foreach ($thumbs as $thumb) { $title = wppa_get_lbtitle('alw', $thumb['id']); if (wppa_is_video($thumb['id'])) { $siz['0'] = wppa_get_videox($thumb['id']); $siz['1'] = wppa_get_videoy($thumb['id']); } else { // $siz = getimagesize( wppa_get_photo_path( $thumb['id'] ) ); $siz['0'] = wppa_get_photox($thumb['id']); $siz['1'] = wppa_get_photoy($thumb['id']); } $link = wppa_fix_poster_ext(wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']), $thumb['id']); $is_video = wppa_is_video($thumb['id']); $has_audio = wppa_has_audio($thumb['id']); $widget_content .= "\n\t" . '<a href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('wppa_lightbox_name') . '[alw-' . $wppa['mocc'] . '-' . $album['id'] . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" >'; if ($thumb['id'] == $image['id']) { // the cover image if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => $cursor, 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => wppa_zoom_in($image['id']))); } else { $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . $cursor . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } } $widget_content .= "\n\t" . '</a>'; } } } else { // Is an onclick unit if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents . ' onclick="' . $link['url'] . '"', 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' onclick="' . $link['url'] . '" ' . wppa_get_imgalt($image['id']) . ' >'; } } } else { if (wppa_is_video($image['id'])) { $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title)); } else { $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >'; } } if ($name == 'yes') { $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('wppa_fontsize_widget_thumb') . 'px; min-height:100%;">' . __(stripslashes($album['name'])) . '</span>'; } $widget_content .= "\n" . '</div>'; $count++; } } } } else { $widget_content .= 'There are no albums (yet).'; } $widget_content .= '<div style="clear:both"></div>'; $widget_content .= "\n" . '<!-- WPPA+ thumbnail 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; }
function wppa_run_slidecontainer($type = '') { global $thumbs; // if ( wppa( 'is_filmonly' ) ) return; $c = is_array($thumbs) ? count($thumbs) : '0'; wppa_dbg_msg('Running slidecontainer type ' . $type . ' with ' . $c . ' elements in thumbs, is_single=' . wppa('is_single')); if (wppa('is_single') && is_feed()) { // process feed for single image slideshow here, normal slideshow uses filmthumbs $style_a = wppa_get_fullimgstyle_a(wppa('start_photo')); $style = $style_a['style']; $width = $style_a['width']; $height = $style_a['height']; $imgalt = wppa_get_imgalt(wppa('start_photo')); wppa_out('<a href="' . get_permalink() . '">' . '<img' . ' src="' . wppa_get_photo_url(wppa('start_photo'), '', $width, $height) . '"' . ' style="' . $style . '"' . ' width="' . $width . '"' . ' height="' . $height . '" ' . $imgalt . ' />' . '</a>'); return; } elseif ($type == 'slideshow') { // Find slideshow start method switch (wppa_opt('start_slide')) { case 'run': $startindex = -1; break; case 'still': $startindex = 0; break; case 'norate': $startindex = -2; break; default: echo 'Unexpected error unknown wppa_start_slide in wppa_run_slidecontainer'; } // A requested photo id overrules the method. $startid >0 is requested photo id, -1 means: no id requested if (wppa('start_photo')) { $startid = wppa('start_photo'); } else { $startid = -1; } // Create next ids $ix = 0; if ($thumbs) { while ($ix < count($thumbs)) { if ($ix == count($thumbs) - 1) { $thumbs[$ix]['next_id'] = $thumbs[0]['id']; } else { $thumbs[$ix]['next_id'] = $thumbs[$ix + 1]['id']; } $ix++; } } // Produce scripts for slides $index = 0; if ($thumbs) { $t = -microtime(true); wppa_add_js_page_data("\n" . '<script type="text/javascript">'); foreach ($thumbs as $thumb) { if (wppa_switch('next_on_callback')) { wppa_add_js_page_data("\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info($index, $thumb['id'], $thumb['next_id']) . ' );'); } else { wppa_add_js_page_data("\n" . 'wppaStoreSlideInfo( ' . wppa_get_slide_info($index, $thumb['id']) . ' );'); } if ($startid == $thumb['id']) { $startindex = $index; } // Found the requested id, put the corresponding index in $startindex $index++; } wppa_add_js_page_data("\n" . '</script>'); $t += microtime(true); wppa_dbg_msg('SlideInfo took ' . $t . ' seconds.'); } wppa_add_js_page_data("\n" . '<script type="text/javascript">'); // How to start if slideonly if (wppa('is_slideonly')) { if (wppa_switch('start_slideonly')) { $startindex = -1; // There are no navigations, so start running, overrule everything } else { $startindex = 0; } } // Vertical align if (wppa('is_slideonly')) { $ali = wppa('ss_widget_valign') ? wppa('ss_widget_valign') : ($ali = 'fit'); wppa_add_js_page_data("\n" . 'wppaFullValign[' . wppa('mocc') . '] = "' . $ali . '";'); } else { wppa_add_js_page_data("\n" . 'wppaFullValign[' . wppa('mocc') . '] = "' . wppa_opt('fullvalign') . '";'); } // Horizontal align wppa_add_js_page_data("\n" . 'wppaFullHalign[' . wppa('mocc') . '] = "' . wppa_opt('fullhalign') . '";'); // Portrait only ? if (wppa('portrait_only')) { wppa_add_js_page_data("\n" . 'wppaPortraitOnly[' . wppa('mocc') . '] = true;'); } // Start command with appropriate $startindex: -2 = at norate, -1 run from first, >=0 still at index // If we use lightbox on slideshow, wait for documen.ready, if we do not use lightbox, go immediately. if (wppa_opt('slideshow_linktype') == 'lightbox' || wppa_opt('slideshow_linktype') == 'lightboxsingle' || wppa_opt('film_linktype') == 'lightbox') { wppa_add_js_page_data("\n" . 'jQuery( document ).ready( function() { wppaStartStop( ' . wppa('mocc') . ', ' . $startindex . ' ); } );'); } else { wppa_add_js_page_data("\n" . 'wppaStartStop( ' . wppa('mocc') . ', ' . $startindex . ' );'); } wppa_add_js_page_data("\n" . '</script>'); } else { wppa_out('<span style="color:red;">' . 'Error, wppa_run_slidecontainer() called with wrong argument: ' . $type . '. Possible values: \'single\' or \'slideshow\'' . '</span>'); } }
function wppa_get_video_body($id, $for_lb = false, $w = '0', $h = '0') { $is_video = wppa_is_video($id, true); // Not a video? no go if (!$is_video) { return ''; } // See what file types are present extract(wp_parse_args($is_video, array('mp4' => false, 'ogv' => false, 'webm' => false))); // Collect other data $width = $w ? $w : wppa_get_videox($id); $height = $h ? $h : wppa_get_videoy($id); $source = wppa_get_photo_url($id); $source = substr($source, 0, strrpos($source, '.')); $class = $for_lb ? ' class="wppa-overlay-img"' : ''; $is_opera = strpos($_SERVER["HTTP_USER_AGENT"], 'OPR'); $is_ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident'); $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari'); wppa_dbg_msg('Mp4:' . $mp4 . ', Opera:' . $is_opera . ', Ie:' . $is_ie . ', Saf:' . $is_safari); // Assume the browser supports html5 $ext = ''; if ($is_opera) { if ($ogv) { $ext = 'ogv'; } elseif ($webm) { $ext = 'webm'; } elseif ($mp4) { $ext = 'mp4'; } } elseif ($is_safari || $is_ie) { if ($mp4) { $ext = 'mp4'; } } else { if ($mp4) { $ext = 'mp4'; } elseif ($webm) { $ext = 'webm'; } elseif ($ogv) { $ext = 'ogv'; } } if ($ext) { $mime = str_replace('ogv', 'ogg', 'video/' . $ext); $result = '<source src="' . $source . '.' . $ext . '" type="' . $mime . '">'; } $result .= __a('There is no filetype available for your browser, or your browser does not support html5 video', 'wppa'); return $result; }
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&wppa-owner=' . $thumb['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $thumb['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $thumb['owner'] . '&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&wppa-owner=' . $data[$author]['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $data[$author]['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $data[$author]['owner'] . '&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; }
function wppa_the_coverphotos($albumid, $images, $srcs, $photo_pos, $photolinks, $title, $imgattrs_a, $events) { global $wpdb; if (!$images) { return; } // Find the photo frame style $photoframestyle = 'style="text-align:center; "'; // Open the coverphoto frame wppa_out('<div id="coverphoto_frame_' . $albumid . '_' . wppa('mocc') . '" class="coverphoto-frame" ' . $photoframestyle . '>'); // Process the images $n = count($images); for ($idx = '0'; $idx < $n; $idx++) { $image = $images[$idx]; $src = $srcs[$idx]; if (wppa_has_audio($image['id'])) { $src = wppa_fix_poster_ext($src, $image['id']); } $imgattr = $imgattrs_a[$idx]['style']; $imgwidth = $imgattrs_a[$idx]['width']; $imgheight = $imgattrs_a[$idx]['height']; $frmwidth = $imgwidth + '10'; // + 2 * 1 border + 2 * 4 padding $imgattr_a = $imgattrs_a[$idx]; $photolink = $photolinks[$idx]; if ($photolink) { if ($photolink['is_lightbox']) { $thumb = $image; $title = wppa_get_lbtitle('cover', $thumb['id']); if (wppa_is_video($thumb['id'])) { $siz['0'] = wppa_get_videox($thumb['id']); $siz['1'] = wppa_get_videoy($thumb['id']); } else { $siz['0'] = wppa_get_photox($thumb['id']); $siz['1'] = wppa_get_photoy($thumb['id']); } $link = wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']); if (wppa_has_audio($thumb['id'])) { $link = wppa_fix_poster_ext($link, $thumb['id']); } $is_video = wppa_is_video($thumb['id']); $has_audio = wppa_has_audio($thumb['id']); wppa_out('<a' . ' href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[alw-' . wppa('mocc') . '-' . $albumid . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >'); // the cover image if ($thumb['id'] == $image['id']) { if (wppa_is_video($image['id'])) { wppa_out("\n\t\t" . '<video preload="metadata" class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . '>' . wppa_get_video_body($image['id']) . '</video>'); } else { wppa_out("\n\t\t" . '<img class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $src . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . ' ' . wppa_get_imgalt($image['id']) . '>'); } } wppa_out('</a> '); } else { // Link is NOT lightbox $href = $photolink['url'] == '#' ? '' : 'href="' . wppa_convert_to_pretty($photolink['url']) . '" '; wppa_out('<a ' . $href . 'target="' . $photolink['target'] . '" title="' . $photolink['title'] . '" onclick="' . $photolink['onclick'] . '" >'); if (wppa_is_video($image['id'])) { wppa_out('<video preload="metadata" ' . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' >' . wppa_get_video_body($image['id']) . '</video>'); } else { wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />'); } wppa_out('</a> '); } } else { wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />'); } } // Close the coverphoto frame wppa_out('</div>'); }
function wppa_get_picture_html($args) { // Init $defaults = array('id' => '0', 'type' => '', 'class' => ''); $args = wp_parse_args($args, $defaults); $id = strval(intval($args['id'])); $type = $args['type']; $class = $args['class']; // Check existance of required args foreach (array('id', 'type') as $item) { if (!$args[$item]) { wppa_dbg_msg('Missing ' . $item . ' in call to wppa_get_picture_html()', 'red', 'force'); return false; } } // Check validity of args if (!wppa_photo_exists($id)) { wppa_dbg_msg('Photo ' . $id . ' does not exist in call to wppa_get_picture_html(). Type = ' . $type, 'red', 'force'); return false; } $types = array('sphoto', 'mphoto', 'xphoto', 'cover', 'thumb', 'ttthumb', 'comthumb', 'fthumb', 'twthumb', 'ltthumb', 'albthumb'); if (!in_array($type, $types)) { wppa_dbg_msg('Unimplemented type ' . $type . ' in call to wppa_get_picture_html()', 'red', 'force'); return false; } // Get other data $link = wppa_get_imglnk_a($type, $id); $isthumb = strpos($type, 'thumb') !== false; $file = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_path($id) : wppa_get_photo_path($id), $id); $href = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_url($id) : wppa_get_photo_url($id), $id); $autocol = wppa('auto_colwidth') || wppa('fullsize') > 0 && wppa('fullsize') <= 1.0; $title = $link ? esc_attr($link['title']) : esc_attr(stripslashes(wppa_get_photo_name($id))); $alt = wppa_get_imgalt($id); // Find image style switch ($type) { case 'sphoto': $style = 'width:100%;margin:0;'; if (!wppa_in_widget()) { switch (wppa_opt('fullimage_border_width')) { case '': $style .= 'padding:0;' . 'border:none;'; break; case '0': $style .= 'padding:0;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;'; break; default: $style .= 'padding:' . (wppa_opt('fullimage_border_width') - '1') . 'px;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;' . 'background-color:' . wppa_opt('bgcolor_fullimg') . ';'; // If we do round corners... if (wppa_opt('bradius') > '0') { // then also here $style .= 'border-radius:' . wppa_opt('fullimage_border_width') . 'px;'; } } } break; case 'mphoto': case 'xphoto': $style = 'width:100%;margin:0;padding:0;border:none;'; break; default: wppa_dbg_msg('Style for type ' . $type . ' is not implemented yet in wppa_get_picture_html()', 'red', 'force'); return false; } if ($link['is_lightbox']) { $style .= 'cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;'; $title = wppa_zoom_in($id); } // Create the html $result = ''; // The link if ($link) { // Link is lightbox if ($link['is_lightbox']) { $lbtitle = wppa_get_lbtitle($type, $id); $videobody = esc_attr(wppa_get_video_body($id)); $audiobody = esc_attr(wppa_get_audio_body($id)); $videox = wppa_get_videox($id); $videoy = wppa_get_videoy($id); $result .= '<a' . ' href="' . $link['url'] . '"' . ($lbtitle ? ' ' . wppa('lbtitle') . '="' . $lbtitle . '"' : '') . ($videobody ? ' data-videohtml="' . $videobody . '"' : '') . ($audiobody ? ' data-audiohtml="' . $audiobody . '"' : '') . ($videox ? ' data-videonatwidth="' . $videox . '"' : '') . ($videoy ? ' data-videonatheight="' . $videoy . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ($link['target'] ? ' target="' . $link['target'] . '"' : '') . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"' . ' >'; } else { $result .= '<a' . (wppa_is_mobile() ? ' ontouchstart="wppaStartTime();" ontouchend="wppaTapLink(\'' . $id . '\',\'' . $link['url'] . '\');" ' : ' onclick="_bumpClickCount( \'' . $id . '\' );window.open(\'' . $link['url'] . '\', \'' . $link['target'] . '\' )"') . ' title="' . $link['title'] . '"' . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >'; } } // The image // Video? if (wppa_is_video($id)) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => !$link, 'style' => $style, 'class' => $class)); } else { $result .= '<img' . ' id="ph-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $href . '"' . ' ' . wppa_get_imgalt($id) . ($class ? ' class="' . $class . '" ' : '') . ($title ? ' title="' . $title . '" ' : '') . ' style="' . $style . '"' . ' />'; } // Close the link if ($link) { $result .= '</a>'; } // Add audio? sphoto if (wppa_has_audio($id)) { $result .= '<div style="position:relative;z-index:11;" >'; // Find style for audio controls switch ($type) { case 'sphoto': $pad = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') + 1; $bot = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') - 1; $style = 'margin:0;' . 'padding:0 ' . $pad . 'px;' . 'bottom:' . $bot . 'px;'; $class = 'size-medium wppa-sphoto wppa-sphoto-' . wppa('mocc'); break; case 'mphoto': case 'xphoto': $style = 'margin:0;' . 'padding:0;' . 'bottom:0;'; $class = 'size-medium wppa-' . $type . ' wppa-' . $type . '-' . wppa('mocc'); break; default: $style = 'margin:0;' . 'padding:0;'; $class = ''; } // Get the html for audio $result .= wppa_get_audio_html(array('id' => $id, 'cursor' => 'cursor:pointer;', 'style' => $style . 'position:absolute;' . 'box-sizing:border-box;' . 'width:100%;' . 'border:none;' . 'height:' . wppa_get_audio_control_height() . 'px;' . 'border-radius:0;', 'class' => $class)); $result .= '</div>'; } // Update statistics if (!wppa_in_widget()) { wppa_bump_viewcount('photo', $id); } // Done ! 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); }
function wppa_album_photos_bulk($album) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); // Init $count = '0'; $abort = false; if (isset($_POST['wppa-bulk-action'])) { check_admin_referer('wppa-bulk', 'wppa-bulk'); if (isset($_POST['wppa-bulk-photo'])) { $ids = $_POST['wppa-bulk-photo']; $newalb = isset($_POST['wppa-bulk-album']) ? $_POST['wppa-bulk-album'] : '0'; $status = isset($_POST['wppa-bulk-status']) ? $_POST['wppa-bulk-status'] : ''; $owner = isset($_POST['wppa-bulk-owner']) ? $_POST['wppa-bulk-owner'] : ''; $totcount = count($ids); if (!is_numeric($newalb)) { wp_die('Security check failure 1'); } if (is_array($ids)) { foreach (array_keys($ids) as $id) { $skip = false; switch ($_POST['wppa-bulk-action']) { case 'wppa-bulk-delete': wppa_delete_photo($id); break; case 'wppa-bulk-move-to': if ($newalb) { $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A); if (wppa_switch('void_dups')) { // Check for already exists $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb)); if ($exists) { // Already exists wppa_error_message(sprintf(__('A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb)); $skip = true; } } if ($skip) { continue; } wppa_flush_treecounts($photo['album']); // Current album wppa_flush_treecounts($newalb); // New album $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `album` = %s WHERE `id` = %s', $newalb, $id)); wppa_move_source($photo['filename'], $photo['album'], $newalb); } else { wppa_error_message('Unexpected error #4 in wppa_album_photos_bulk().'); } break; case 'wppa-bulk-copy-to': if ($newalb) { $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A); if (wppa_switch('void_dups')) { // Check for already exists $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb)); if ($exists) { // Already exists wppa_error_message(sprintf(__($exists . 'A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb)); $skip = true; } } if ($skip) { continue; } wppa_copy_photo($id, $newalb); wppa_flush_treecounts($newalb); } else { wppa_error_message('Unexpected error #3 in wppa_album_photos_bulk().'); } break; case 'wppa-bulk-status': if (!in_array($status, array('publish', 'pending', 'featured', 'scheduled', 'gold', 'silver', 'bronze', 'private'))) { wppa_log('error', 'Unknown status ' . strip_tags($status) . ' found in wppa-photo-admin-autosave.php -> wppa_album_photos_bulk()'); $status = 'publish'; } if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { if ($status == 'publish' || $status == 'pending' || wppa_user_is('administrator') || !wppa_switch('ext_status_restricted')) { $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `status` = '" . $status . "' WHERE `id` = " . $id); wppa_flush_treecounts($id, wppa_get_photo_item($id, 'album')); } else { wp_die('Security check failure 2'); } } else { wp_die('Security check failure 3'); } break; case 'wppa-bulk-owner': if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) { if ($owner) { $owner = sanitize_user($owner); $exists = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->users . "` WHERE `user_login` = '" . $owner . "'"); if ($exists) { $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `owner` = '" . $owner . "' WHERE `id` = " . $id); } else { wppa_error_message('A user with login name ' . $owner . ' does not exist.'); $skip = true; } } else { wp_die('Missing required arg in bulk change owner'); } } else { wp_die('Security check failure 4'); } break; default: wppa_error_message('Unimplemented bulk action requested in wppa_album_photos_bulk().'); break; } if (!$skip) { $count++; } if (wppa_is_time_up()) { wppa_error_message(sprintf(__('Time is out after processing %d out of %d items.', 'wp-photo-album-plus'), $count, $totcount)); $abort = true; } if ($abort) { break; } } } else { wppa_error_message('Unexpected error #2 in wppa_album_photos_bulk().'); } } else { wppa_error_message('Unexpected error #1 in wppa_album_photos_bulk().'); } if ($count && !$abort) { switch ($_POST['wppa-bulk-action']) { case 'wppa-bulk-delete': $message = sprintf(__('%d photos deleted.', 'wp-photo-album-plus'), $count); break; case 'wppa-bulk-move-to': $message = sprintf(__('%1$s photos moved to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb)); break; case 'wppa-bulk-copy-to': $message = sprintf(__('%1$s photos copied to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb)); break; case 'wppa-bulk-status': $message = sprintf(__('Changed status to %1$s on %2$s photos.', 'wp-photo-album-plus'), $status, $count); break; case 'wppa-bulk-owner': $message = sprintf(__('Changed owner to %1$s on %2$s photos.', 'wp-photo-album-plus'), $owner, $count); break; default: $message = sprintf(__('%d photos processed.', 'wp-photo-album-plus'), $count); break; } wppa_ok_message($message); } } $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; if ($album) { if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']) . '&bulk'); wppa_show_search_statistics(); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; //$wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ) ); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&bulk'); } if ($photos) { wppa_admin_page_links($page, $pagesize, $count, $link, '#manage-photos'); ?> <script type="text/javascript" > function wppaBulkActionChange( elm, id ) { wppa_setCookie( 'wppa_bulk_action',elm.value,365 ); if ( elm.value == 'wppa-bulk-move-to' || elm.value == 'wppa-bulk-copy-to' ) jQuery( '#wppa-bulk-album' ).css( 'display', 'inline' ); else jQuery( '#wppa-bulk-album' ).css( 'display', 'none' ); if ( elm.value == 'wppa-bulk-status' ) jQuery( '#wppa-bulk-status' ).css( 'display', 'inline' ); else jQuery( '#wppa-bulk-status' ).css( 'display', 'none' ); if ( elm.value == 'wppa-bulk-owner' ) jQuery( '#wppa-bulk-owner' ).css( 'display', 'inline' ); else jQuery( '#wppa-bulk-owner' ).css( 'display', 'none' ); } function wppaBulkDoitOnClick() { var photos = jQuery( '.wppa-bulk-photo' ); var count=0; for ( i=0; i< photos.length; i++ ) { var photo = photos[i]; if ( photo.checked ) count++; } if ( count == 0 ) { alert( 'No photos selected' ); return false; } var action = document.getElementById( 'wppa-bulk-action' ).value; switch ( action ) { case '': alert( 'No action selected' ); return false; break; case 'wppa-bulk-delete': break; case 'wppa-bulk-move-to': case 'wppa-bulk-copy-to': var album = document.getElementById( 'wppa-bulk-album' ).value; if ( album == 0 ) { alert( 'No album selected' ); return false; } break; case 'wppa-bulk-status': var status = document.getElementById( 'wppa-bulk-status' ).value; if ( status == 0 ) { alert( 'No status selected' ); return false; } break; case 'wppa-bulk-owner': var owner = documnet.getElementById( 'wppa-bulk-owner' ).value; if ( owner == 0 ) { alert( 'No new owner selected' ); return false; } break; default: alert( 'Unimplemented action requested: '+action ); return false; break; } return true; } function wppaSetThumbsize( elm ) { var thumbsize = elm.value; wppa_setCookie( 'wppa_bulk_thumbsize',thumbsize,365 ); jQuery( '.wppa-bulk-thumb' ).css( 'max-width', thumbsize+'px' ); jQuery( '.wppa-bulk-thumb' ).css( 'max-height', ( thumbsize/2 )+'px' ); jQuery( '.wppa-bulk-dec' ).css( 'height', ( thumbsize/2 )+'px' ); } jQuery( document ).ready( function() { var action = wppa_getCookie( 'wppa_bulk_action' ); document.getElementById( 'wppa-bulk-action' ).value = action; if ( action == 'wppa-bulk-move-to' || action == 'wppa-bulk-copy-to' ) { jQuery( '#wppa-bulk-album' ).css( 'display','inline' ); document.getElementById( 'wppa-bulk-album' ).value = wppa_getCookie( 'wppa_bulk_album' ); } if ( action == 'wppa-bulk-status' ) { jQuery( '#wppa-bulk-status' ).css( 'display','inline' ); document.getElementById( 'wppa-bulk-status' ).value = wppa_getCookie( 'wppa_bulk_status' ); } if ( action == 'wppa-bulk-owner' ) { jQuery( '#wppa-bulk-owner' ).css( 'display','inline' ); document.getElementById( 'wppa-bulk-owner' ).value = wppa_getCookie( 'wppa_bulk_owner' ); } } ); </script> <form action="<?php echo $link . '&wppa-page=' . $page . '#manage-photos'; ?> " method="post" > <?php wp_nonce_field('wppa-bulk', 'wppa-bulk'); ?> <h3> <span style="font-weight:bold;" ><?php _e('Bulk action:', 'wp-photo-album-plus'); ?> </span> <select id="wppa-bulk-action" name="wppa-bulk-action" onchange="wppaBulkActionChange( this, 'bulk-album' )" > <option value="" ></option> <option value="wppa-bulk-delete" ><?php _e('Delete', 'wp-photo-album-plus'); ?> </option> <option value="wppa-bulk-move-to" ><?php _e('Move to', 'wp-photo-album-plus'); ?> </option> <option value="wppa-bulk-copy-to" ><?php _e('Copy to', 'wp-photo-album-plus'); ?> </option> <?php if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { ?> <option value="wppa-bulk-status" ><?php _e('Set status to', 'wp-photo-album-plus'); ?> </option> <?php } ?> <?php if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) { ?> <option value="wppa-bulk-owner" ><?php _e('Set owner to', 'wp-photo-album-plus'); ?> </option> <?php } ?> </select> <select name="wppa-bulk-album" id="wppa-bulk-album" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_album',this.value,365 );" > <?php echo wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true)); ?> </select> <select name="wppa-bulk-status" id="wppa-bulk-status" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_status',this.value,365 );" > <option value="" ><?php _e('- select a status -', 'wp-photo-album-plus'); ?> </option> <option value="pending" ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="publish" ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <?php if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled'; } else { $dis = ''; } ?> <option value="featured"<?php echo $dis; ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php echo $dis; ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php echo $dis; ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php echo $dis; ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="scheduled" <?php echo $dis; ?> ><?php _e('Scheduled', 'wp-photo-album-plus'); ?> </option> <option value="private" <?php echo $dis; ?> ><?php _e('Private', 'wp-photo-album-plus'); ?> </option> </select> <!-- Owner --> <?php $users = wppa_get_users(); if (count($users)) { ?> <select name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );"> <option value="" ><?php _e('- select an owner -', 'wp-photo-album-plus'); ?> </option> <?php foreach ($users as $user) { echo '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . ' (' . $user['user_login'] . ')</option>'; } ?> </select> <?php } else { ?> <input name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );" /> <?php } ?> <!-- Submit --> <input type="submit" onclick="return wppaBulkDoitOnClick()" class="button-primary" value="<?php _e('Doit!', 'wp-photo-album-plus'); ?> " /> <span style="font-family:sans-serif; font-size:12px; font-style:italic; font-weight:normal;" > <?php _e('Pressing this button will reload the page after executing the selected action', 'wp-photo-album-plus'); ?> </span> </h3> <table class="widefat" > <thead style="font-weight:bold;" > <td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td> <td><?php _e('ID', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Preview', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Name', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Description', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Status', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Owner', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Remark', 'wp-photo-album-plus'); ?> </td> </thead> <tbody> <?php foreach ($photos as $photo) { ?> <?php $id = $photo['id']; ?> <tr id="photoitem-<?php echo $photo['id']; ?> " > <!-- Checkbox --> <td> <input type="hidden" id="photo-nonce-<?php echo $photo['id']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $photo['id']); ?> " /> <input type="checkbox" name="wppa-bulk-photo[<?php echo $photo['id']; ?> ]" class="wppa-bulk-photo" /> </td> <!-- ID and delete link --> <td><?php echo $photo['id']; ?> <br /><a onclick="if ( confirm( '<?php _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxDeletePhoto( <?php echo $photo['id']; ?> , '<td colspan=3 >', '</td>' )" style="color:red;font-weight:bold;"><?php _e('Delete', 'wp-photo-album-plus'); ?> </a> </td> <!-- Preview --> <td style="min-width:240px; text-align:center;" > <?php if (wppa_is_video($photo['id'])) { ?> <a href="<?php echo str_replace('xxx', 'mp4', wppa_get_photo_url($photo['id'])); ?> " target="_blank" title="Click to see fullsize" > <?php // Animating size changes of a video tag is not a good idea. It will rapidly screw up browser cache and cpu ?> <?php echo wppa_get_video_html(array('id' => $id, 'height' => '60', 'controls' => false, 'tagid' => 'pa-id-' . $id, 'events' => ' onmouseover="jQuery( this ).css( \'height\', \'160\' )" onmouseout="jQuery( this ).css( \'height\', \'60\' )"', 'preload' => 'metadata', 'use_thumb' => true)); ?> <!-- <video preload="metadata" style="height:60px;" onmouseover="jQuery( this ).css( 'height', '160' )" onmouseout="jQuery( this ).css( 'height', '60' )" > <?php // echo wppa_get_video_body( $photo['id'] ) ?> </video> --> </a> <?php } else { ?> <a href="<?php echo wppa_fix_poster_ext(wppa_get_photo_url($photo['id']), $photo['id']); ?> " target="_blank" title="Click to see fullsize" > <img class="wppa-bulk-thumb" src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']); ?> " style="height:60px;" onmouseover="jQuery( this ).stop().animate( {height:120}, 100 )" onmouseout="jQuery( this ).stop().animate( {height:60}, 100 )" /> </a> <?php } ?> </td> <td style="width:25%;" > <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> <?php if (wppa_is_video($photo['id'])) { echo '<br />' . wppa_get_videox($photo['id']) . ' x ' . wppa_get_videoy($photo['id']) . ' px.'; } else { $sp = wppa_get_source_path($photo['id']); if (is_file($sp)) { $ima = getimagesize($sp); if (is_array($ima)) { echo '<br />' . $ima['0'] . ' x ' . $ima['1'] . ' px.'; } } } ?> </td> <!-- Description --> <td style="width:25%;" > <textarea class="wppa-bulk-dec" style="height:50px; width:100%" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" ><?php echo stripslashes($photo['description']); ?> </textarea> </td> <!-- Status --> <td> <?php if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { ?> <select id="status-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'status', this ); wppaPhotoStatusChange( <?php echo $photo['id']; ?> ); "> <option value="pending" <?php if ($photo['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($photo['status'] == 'publish') { echo 'selected="selected"'; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <?php if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled'; } else { $dis = ''; } ?> <option value="featured" <?php if ($photo['status'] == 'featured') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($photo['status'] == 'gold') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($photo['status'] == 'silver') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($photo['status'] == 'bronze') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="scheduled" <?php if ($photo['status'] == 'scheduled') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Scheduled', 'wp-photo-album-plus'); ?> </option> <option value="private" <?php if ($photo['status'] == 'private') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Private', 'wp-photo-album-plus'); ?> </option> </select> <?php } else { if ($photo['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'featured') { e('Featured'); } elseif ($photo['status'] == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'private') { _e('Private', 'wp-photo-album-plus'); } } ?> </td> <!-- Owner --> <td> <?php echo $photo['owner']; ?> </td> <!-- Remark --> <td id="photostatus-<?php echo $photo['id']; ?> " style="width:25%;" > <?php _e('Not modified', 'wp-photo-album-plus'); ?> <script type="text/javascript">wppaPhotoStatusChange( <?php echo $photo['id']; ?> )</script> </td> </tr> <?php } ?> </tbody> <tfoot style="font-weight:bold;" > <td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td> <td><?php _e('ID', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Preview', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Name', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Description', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Status', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Owner', 'wp-photo-album-plus'); ?> </td> <td><?php _e('Remark', 'wp-photo-album-plus'); ?> </td> </tfoot> </table> </form> <?php wppa_admin_page_links($page, $pagesize, $count, $link); } else { if ($page == '1') { if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } else { $page_1 = $page - '1'; echo sprintf(__('Page %d is empty, try <a href="%s" >page %d</a>.', 'wp-photo-album-plus'), $page, $link . '&wppa-page=' . $page_1 . '#manage-photos', $page_1); } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 2', 'red', 'force'); } }
/** @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; }