function wppa_do_filmthumb($id, $idx, $do_for_feed = false, $glue = false) { $thumb = wppa_cache_thumb($id); $result = ''; $src = wppa_fix_poster_ext(wppa_get_thumb_path($thumb['id']), $thumb['id']); $max_size = wppa_opt('thumbsize'); if (wppa_in_widget()) { $max_size /= 2; } $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget(); $imgattr_a = wppa_get_imgstyle_a($thumb['id'], $src, $max_size, 'optional', 'fthumb'); $imgstyle = $imgattr_a['style']; $imgwidth = $imgattr_a['width']; $imgheight = $imgattr_a['height']; $cursor = $imgattr_a['cursor']; $url = wppa_fix_poster_ext(wppa_get_thumb_url($thumb['id'], '', $imgwidth, $imgheight), $thumb['id']); $furl = str_replace('/thumbs', '', $url); $events = wppa_get_imgevents('film', $thumb['id'], 'nopopup', $idx); $thumbname = wppa_get_photo_name($thumb['id']); $target = wppa_switch('film_blank') || $thumb['linktarget'] == '_blank' ? 'target="_blank" ' : ''; $psotitle = $thumb['linktitle'] ? 'title="' . esc_attr($thumb['linktitle']) . '" ' : ''; $psourl = wppa_switch('film_overrule') && $thumb['linkurl'] ? 'href="' . $thumb['linkurl'] . '" ' . $target . $psotitle : ''; $imgalt = wppa_get_imgalt($thumb['id']); if (wppa_opt('film_linktype') == 'lightbox') { // $title = esc_attr( wppa_zoom_in( $thumb['id'] ) ); } else { $events .= ' onclick="wppaGotoKeepState( ' . wppa('mocc') . ', ' . $idx . ' )"'; $events .= ' ondblclick="wppaStartStop( ' . wppa('mocc') . ', -1 )"'; } if (is_feed()) { if ($do_for_feed) { $style_a = wppa_get_imgstyle_a($thumb['id'], $src, '100', '4', 'thumb'); $style = $style_a['style']; $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $url . '"' . ' ' . $imgalt . ' title="' . $thumbname . '"' . ' style="' . $style . '"' . ' />' . '</a>'; } } else { // If ! $do_for_feed: pre-or post-ambule. To avoid dup id change it in that case $tmp = $do_for_feed ? 'film' : 'pre'; $style = $glue ? 'style="' . wppa_get_thumb_frame_style($glue, 'film') . '"' : ''; $result .= '<div' . ' id="' . $tmp . '_wppatnf_' . $thumb['id'] . '_' . wppa('mocc') . '"' . ' class="thumbnail-frame"' . ' ' . $style . ' >'; if ($psourl) { // True only when pso activated and data present $result .= '<a ' . $psourl . '>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $title = wppa_get_lbtitle('slide', $thumb['id']); $videohtml = esc_attr(wppa_get_video_body($thumb['id'])); $audiohtml = esc_attr(wppa_get_audio_body($thumb['id'])); $result .= '<a href="' . $furl . '"' . ($videohtml ? ' data-videohtml="' . $videohtml . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >'; } if ($tmp == 'pre' && wppa_opt('film_linktype') == 'lightbox') { $cursor = 'cursor:default;'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '<!--'; } if (wppa_is_video($thumb['id'])) { $result .= wppa_get_video_html(array('id' => $thumb['id'], 'width' => $imgattr_a['width'], 'height' => $imgattr_a['height'], 'controls' => false, 'margin_top' => $imgattr_a['margin-top'], 'margin_bottom' => $imgattr_a['margin-bottom'], 'cursor' => $imgattr_a['cursor'], 'events' => $events, 'tagid' => 'wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc'))); } else { $result .= '<img' . ' id="wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc') . '"' . ' class="wppa-' . $tmp . '-' . wppa('mocc') . '"' . ' src="' . $url . '"' . ' ' . $imgalt . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' data-title="' . ($psourl ? esc_attr($thumb['linktitle']) : '') . '"' . ' />'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '-->'; } if ($psourl) { // True only when pso activated and data present $result .= '</a>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $result .= '</a>'; } $result .= '</div>'; } wppa_out($result); }
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_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_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_zoom_in($id) { if ($id === false) { return ''; } if (wppa_switch('show_zoomin')) { if (wppa_opt('magnifier')) { return __('Zoom in', 'wp-photo-album-plus'); } else { return esc_attr(stripslashes(wppa_get_photo_name($id))); } } else { return ''; } }
function wppa_get_keywords($id) { static $wppa_void_keywords; if (!$id) { return ''; } if (empty($wppa_void_keywords)) { $wppa_void_keywords = array(__('Not Defined', 'wp-photo-album-plus'), __('Manual', 'wp-photo-album-plus'), __('Program AE', 'wp-photo-album-plus'), __('Aperture-priority AE', 'wp-photo-album-plus'), __('Shutter speed priority AE', 'wp-photo-album-plus'), __('Creative (Slow speed)', 'wp-photo-album-plus'), __('Action (High speed)', 'wp-photo-album-plus'), __('Portrait', 'wp-photo-album-plus'), __('Landscape', 'wp-photo-album-plus'), __('Bulb', 'wp-photo-album-plus'), __('Average', 'wp-photo-album-plus'), __('Center-weighted average', 'wp-photo-album-plus'), __('Spot', 'wp-photo-album-plus'), __('Multi-spot', 'wp-photo-album-plus'), __('Multi-segment', 'wp-photo-album-plus'), __('Partial', 'wp-photo-album-plus'), __('Other', 'wp-photo-album-plus'), __('No Flash', 'wp-photo-album-plus'), __('Fired', 'wp-photo-album-plus'), __('Fired, Return not detected', 'wp-photo-album-plus'), __('Fired, Return detected', 'wp-photo-album-plus'), __('On, Did not fire', 'wp-photo-album-plus'), __('On, Fired', 'wp-photo-album-plus'), __('On, Return not detected', 'wp-photo-album-plus'), __('On, Return detected', 'wp-photo-album-plus'), __('Off, Did not fire', 'wp-photo-album-plus'), __('Off, Did not fire, Return not detected', 'wp-photo-album-plus'), __('Auto, Did not fire', 'wp-photo-album-plus'), __('Auto, Fired', 'wp-photo-album-plus'), __('Auto, Fired, Return not detected', 'wp-photo-album-plus'), __('Auto, Fired, Return detected', 'wp-photo-album-plus'), __('No flash function', 'wp-photo-album-plus'), __('Off, No flash function', 'wp-photo-album-plus'), __('Fired, Red-eye reduction', 'wp-photo-album-plus'), __('Fired, Red-eye reduction, Return not detected', 'wp-photo-album-plus'), __('Fired, Red-eye reduction, Return detected', 'wp-photo-album-plus'), __('On, Red-eye reduction', 'wp-photo-album-plus'), __('Red-eye reduction, Return not detected', 'wp-photo-album-plus'), __('On, Red-eye reduction, Return detected', 'wp-photo-album-plus'), __('Off, Red-eye reduction', 'wp-photo-album-plus'), __('Auto, Did not fire, Red-eye reduction', 'wp-photo-album-plus'), __('Auto, Fired, Red-eye reduction', 'wp-photo-album-plus'), __('Auto, Fired, Red-eye reduction, Return not detected', 'wp-photo-album-plus'), __('Auto, Fired, Red-eye reduction, Return detected', 'wp-photo-album-plus'), 'album', 'albums', 'content', 'http', 'source', 'wp', 'uploads', 'thumbs', 'wp-content', 'wppa-source', 'border', 'important', 'label', 'padding', 'segment', 'shutter', 'style', 'table', 'times', 'value', 'views', 'wppa-label', 'wppa-value', 'weighted', 'wppa-pl', 'datetime', 'exposureprogram', 'focallength', 'isospeedratings', 'meteringmode', 'model', 'photographer', str_replace('/', '', site_url())); // make a string $temp = implode(',', $wppa_void_keywords); // Downcase $temp = strtolower($temp); // Remove spaces and funny chars $temp = str_replace(array(' ', '-', '"', "'", '\\', '>', '<', ',', ':', ';', '!', '?', '=', '_', '[', ']', '(', ')', '{', '}'), ',', $temp); $temp = str_replace(',,', ',', $temp); //wppa_log('dbg', $temp); // Make array $wppa_void_keywords = explode(',', $temp); // Sort array sort($wppa_void_keywords); // Remove dups $start = 0; foreach (array_keys($wppa_void_keywords) as $key) { if ($key > 0) { if ($wppa_void_keywords[$key] == $wppa_void_keywords[$start]) { unset($wppa_void_keywords[$key]); } else { $start = $key; } } } } $text = wppa_get_photo_name($id) . ' ' . wppa_get_photo_desc($id); $text = str_replace(array('/', '-'), ' ', $text); $words = wppa_index_raw_to_words($text); foreach (array_keys($words) as $key) { if (wppa_is_int($words[$key]) || in_array($words[$key], $wppa_void_keywords) || strlen($words[$key]) < 5) { unset($words[$key]); } } $result = implode(', ', $words); return $result; }
function _wppa_sidebar_page_options() { global $wpdb; $options_error = false; if (isset($_GET['walbum'])) { $walbum = wppa_walbum_sanitize($_GET['walbum']); wppa_update_option('wppa_widget_album', $walbum); } if (isset($_REQUEST['wppa-set-submit'])) { if (!wp_verify_nonce($_REQUEST['wppa-update-check'], 'wppa-update-check')) { echo 'Trying:' . $_REQUEST['wppa-update-check']; } if (isset($_POST['wppa-widgettitle'])) { wppa_update_option('wppa_widgettitle', $_POST['wppa-widgettitle']); } if (isset($_POST['wppa-potd-align'])) { wppa_update_option('wppa_potd_align', $_POST['wppa-potd-align']); } if (isset($_POST['wppa-widget-albums'])) { wppa_update_option('wppa_widget_album', wppa_walbum_sanitize($_POST['wppa-widget-albums'])); } if (isset($_POST['wppa-widget-photo'])) { wppa_update_option('wppa_widget_photo', $_POST['wppa-widget-photo']); } if (isset($_POST['wppa-widget-method'])) { wppa_update_option('wppa_widget_method', $_POST['wppa-widget-method']); } if (isset($_REQUEST['wppa-widget-period'])) { wppa_update_option('wppa_widget_period', $_REQUEST['wppa-widget-period']); } if (isset($_POST['wppa-widget-subtitle'])) { wppa_update_option('wppa_widget_subtitle', $_POST['wppa-widget-subtitle']); } if (isset($_POST['wppa-widget-linkpage'])) { wppa_update_option('wppa_widget_linkpage', $_POST['wppa-widget-linkpage']); } if (isset($_POST['wppa-widget-linkurl'])) { wppa_update_option('wppa_widget_linkurl', $_POST['wppa-widget-linkurl']); } if (isset($_POST['wppa-widget-linktitle'])) { wppa_update_option('wppa_widget_linktitle', $_POST['wppa-widget-linktitle']); } if (isset($_POST['wppa-widget-linktype'])) { wppa_update_option('wppa_widget_linktype', $_POST['wppa-widget-linktype']); } if (isset($_POST['wppa-widget-status-filter'])) { wppa_update_option('wppa_widget_status_filter', $_POST['wppa-widget-status-filter']); } if (isset($_POST['wppa-potd-offset'])) { wppa_update_option('wppa_potd_offset', $_POST['wppa-potd-offset']); } if (isset($_POST['wppa-potd-widget-width'])) { if (wppa_check_numeric($_POST['wppa-potd-widget-width'], '100', __('Widget Photo Width.', 'wp-photo-album-plus'))) { wppa_update_option('wppa_potd_widget_width', $_POST['wppa-potd-widget-width']); } else { $options_error = true; } } if (!$options_error && isset($_POST['wppa-set-submit'])) { wppa_update_message(__('Changes Saved. Don\'t forget to activate the widget!', 'wp-photo-album-plus')); } } wppa_initialize_runtime('force'); ?> <div class="wrap"> <?php $iconurl = WPPA_URL . '/images/settings32.png'; ?> <div id="icon-album" class="icon32" style="background: transparent url(<?php echo $iconurl; ?> ) no-repeat"> <br /> </div> <h2><?php _e('Photo of the Day Widget Settings', 'wp-photo-album-plus'); ?> </h2> <?php $action_url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day'); ?> <form action="<?php echo $action_url; ?> " method="post"> <?php echo wp_nonce_field('wppa-update-check', 'wppa-update-check'); ?> <table class="form-table wppa-table wppa-photo-table"> <tbody> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Title:', 'wp-photo-album-plus'); ?> </label> </th> <td> <input type="text" name="wppa-widgettitle" id="wppa-widgettitle" value="<?php echo wppa_opt('widgettitle'); ?> " /> <span class="description"><br/><?php _e('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Widget Photo Width:', 'wp-photo-album-plus'); ?> </label> </th> <td> <input type="text" name="wppa-potd-widget-width" id="wppa-potd-widget-width" value="<?php echo wppa_opt('potd_widget_width'); ?> " style="width: 50px;" /> <?php _e('pixels.', 'wp-photo-album-plus'); echo ' '; _e('Horizontal alignment:', 'wp-photo-album-plus'); ?> <select name="wppa-potd-align" id="wppa-potd-align"> <?php $ali = wppa_opt('potd_align'); ?> <?php $sel = 'selected="selected"'; ?> <option value="none" <?php if ($ali == 'none') { echo $sel; } ?> ><?php _e('--- none ---', 'wp-photo-album-plus'); ?> </option> <option value="left" <?php if ($ali == 'left') { echo $sel; } ?> ><?php _e('left', 'wp-photo-album-plus'); ?> </option> <option value="center" <?php if ($ali == 'center') { echo $sel; } ?> ><?php _e('center', 'wp-photo-album-plus'); ?> </option> <option value="right" <?php if ($ali == 'right') { echo $sel; } ?> ><?php _e('right', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Enter the desired display width and alignment of the photo in the sidebar.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <tr valign="top"> <th scope="row"> <label ><?php _e('Use album(s):', 'wp-photo-album-plus'); ?> </label> </th> <td> <script type="text/javascript"> /* <![CDATA[ */ function wppaCheckWa() { document.getElementById('wppa-spin').style.visibility = 'visible'; document.getElementById('wppa-upd').style.visibility = 'hidden'; var album = document.getElementById('wppa-wa').value; if ( album != 'all' && album != 'sep' && album != 'all-sep' && album != 'topten' && album != 'clr' ) album = document.getElementById('wppa-was').value + ',' + album; var url = "<?php echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day'); ?> &walbum=" + album; document.location.href = url; } /* ]]> */ </script> <?php _e('Select:', 'wp-photo-album-plus'); ?> <select name="wppa-widget-album" id="wppa-wa" onchange="wppaCheckWa()" ><?php echo wppa_walbum_select(wppa_opt('widget_album')); ?> </select> <img id="wppa-spin" src="<?php echo wppa_get_imgdir(); ?> wpspin.gif" style="visibility:hidden;"/> <?php _e('Or Edit:', 'wp-photo-album-plus'); ?> <input type="text" name="wppa-widget-albums" id="wppa-was" value="<?php echo wppa_opt('widget_album'); ?> " /> <input class="button-primary" name="wppa-upd" id="wppa-upd" value="<?php _e('Update thumbnails', 'wp-photo-album-plus'); ?> " onclick="wppaCheckWa()" /> <span class="description"><br/> <?php _e('Select or edit the album(s) you want to use the photos of for the widget.', 'wp-photo-album-plus'); ?> <br /> <?php _e('If you want a <b>- special -</b> selection or get rid of it, you may need to use <b>- start over -</b> first.', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Status filter --> <tr valign="top" > <th scope="row" > <label ><?php _e('Status filter:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $sel = 'selected="selected"'; ?> <?php $filter = wppa_opt('widget_status_filter'); ?> <select name="wppa-widget-status-filter" > <option value="" <?php if ($filter == 'none') { echo $sel; } ?> ><?php _e('- none -', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($filter == 'publish') { echo $sel; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <option value="featured" <?php if ($filter == 'featured') { echo $sel; } ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($filter == 'gold') { echo $sel; } ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($filter == 'silver') { echo $sel; } ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($filter == 'bronze') { echo $sel; } ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="anymedal" <?php if ($filter == 'anymedal') { echo $sel; } ?> ><?php _e('Any medal', 'wp-photo-album-plus'); ?> </option> </select> </td> </tr> <tr valign="top" > <th scope="row"> <label ><?php _e('Display method:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $sel = 'selected="selected"'; ?> <?php $method = wppa_opt('widget_method'); ?> <select name="wppa-widget-method" id="wppa-wm" onchange="wppaCheckWidgetMethod()" > <option value="1" <?php if ($method == '1') { echo $sel; } ?> ><?php _e('Fixed photo', 'wp-photo-album-plus'); ?> </option> <option value="2" <?php if ($method == '2') { echo $sel; } ?> ><?php _e('Random', 'wp-photo-album-plus'); ?> </option> <option value="3" <?php if ($method == '3') { echo $sel; } ?> ><?php _e('Last upload', 'wp-photo-album-plus'); ?> </option> <option value="4" <?php if ($method == '4') { echo $sel; } ?> ><?php _e('Change every', 'wp-photo-album-plus'); ?> </option> </select> <?php $period = wppa_opt('widget_period'); $text = esc_attr(__('The page will now be reloaded', 'wp-photo-album-plus')); $onchange = esc_attr('alert(\'' . $text . '\');wppaPotdChangePeriod()'); ?> <script type="text/javascript" > function wppaPotdChangePeriod() { var url = '<?php echo $action_url; ?> '; url += '&wppa-set-submit=1'; url += '&wppa-update-check='+jQuery('#wppa-update-check').val(); url += '&wppa-widget-period='+jQuery('#wppa-wp').val(); document.location.href = url; } </script> <select name="wppa-widget-period" id="wppa-wp" onchange="<?php echo $onchange; ?> " > <option value="0" <?php if ($period == '0') { echo $sel; } ?> ><?php _e('pageview.', 'wp-photo-album-plus'); ?> </option> <option value="1" <?php if ($period == '1') { echo $sel; } ?> ><?php _e('hour.', 'wp-photo-album-plus'); ?> </option> <option value="24" <?php if ($period == '24') { echo $sel; } ?> ><?php _e('day.', 'wp-photo-album-plus'); ?> </option> <option value="168" <?php if ($period == '168') { echo $sel; } ?> ><?php _e('week.', 'wp-photo-album-plus'); ?> </option> <option value="736" <?php if ($period == '736') { echo $sel; } ?> ><?php _e('month.', 'wp-photo-album-plus'); ?> </option> <option value="day-of-week" <?php if ($period == 'day-of-week') { echo $sel; } ?> ><?php _e('day of week is order#', 'wp-photo-album-plus'); ?> </option> <option value="day-of-month" <?php if ($period == 'day-of-month') { echo $sel; } ?> ><?php _e('day of month is order#', 'wp-photo-album-plus'); ?> </option> <option value="day-of-year" <?php if ($period == 'day-of-year') { echo $sel; } ?> ><?php _e('day of year is order#', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Select how the widget should display.', 'wp-photo-album-plus'); ?> </span> <div class="wppa-order" > <?php if (substr(wppa_opt('widget_period'), 0, 7) == 'day-of-') { switch (substr(wppa_opt('widget_period'), 7)) { case 'week': $n_days = '7'; $date_key = 'w'; break; case 'month': $n_days = '31'; $date_key = 'd'; break; case 'year': $n_days = '366'; $date_key = 'z'; break; } while (get_option('wppa_potd_offset', '0') > $n_days) { update_option('wppa_potd_offset', get_option('wppa_potd_offset') - $n_days); } echo sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), date_i18n($date_key)) . ' '; echo '<select name="wppa-potd-offset" >'; $day = '0'; while ($day < $n_days) { echo '<option value="' . $day . '" ' . (get_option('wppa_potd_offset', '0') == $day ? 'selected="selected"' : '') . ' >' . $day . '</option>'; $day++; } echo '</select>'; $photo_order = date_i18n($date_key) - get_option('wppa_potd_offset', '0'); while ($photo_order < '1') { $photo_order += $n_days; } echo '. ' . sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order); $photo = wppa_get_potd(); if ($photo) { echo ' <img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" style="width:100px;" />'; } else { echo ' ' . __('Not found.', 'wp-photo-album-plus'); } } ?> </div> </td> </tr> <?php $linktype = wppa_opt('widget_linktype'); if ($linktype != 'custom') { ?> <tr> <th scope="row"> <label ><?php _e('Link to:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php _e('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus'); ?> </td> </tr> <?php } else { ?> <tr class="wppa-wlu" > <th scope="row"> <label ><?php _e('Link to:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php _e('Title:', 'wp-photo-album-plus'); ?> <input type="text" name="wppa-widget-linktitle" id="wppa-widget-linktitle" value="<?php echo wppa_opt('widget_linktitle'); ?> "style="width:20%" /> <?php _e('Url:', 'wp-photo-album-plus'); ?> <input type="text" name="wppa-widget-linkurl" id="wppa-widget-linkurl" value="<?php echo wppa_opt('widget_linkurl'); ?> " style="width:50%" /> <span class="description"><br/><?php _e('Enter the title and the url. Do\'nt forget the HTTP://', 'wp-photo-album-plus'); ?> </span> </td> </tr> <?php } ?> <!--<script type="text/javascript">wppaCheckWidgetLink()</script>--> <tr> <th scope="row"> <label ><?php _e('Subtitle:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $subtit = wppa_opt('widget_subtitle'); ?> <select name="wppa-widget-subtitle" id="wppa-st" > <option value="none" <?php if ($subtit == 'none') { echo $sel; } ?> ><?php _e('--- none ---', 'wp-photo-album-plus'); ?> </option> <option value="name" <?php if ($subtit == 'name') { echo $sel; } ?> ><?php _e('Photo Name', 'wp-photo-album-plus'); ?> </option> <option value="desc" <?php if ($subtit == 'desc') { echo $sel; } ?> ><?php _e('Description', 'wp-photo-album-plus'); ?> </option> <option value="owner" <?php if ($subtit == 'owner') { echo $sel; } ?> ><?php _e('Owner', 'wp-photo-album-plus'); ?> </option> </select> <span class="description"><br/><?php _e('Select the content of the subtitle.', 'wp-photo-album-plus'); ?> </span> </td> </tr> </tbody> </table> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> <?php $alb = wppa_opt('widget_album'); $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : ''; $photos = wppa_get_widgetphotos($alb, $opt); if (empty($photos)) { echo '<p>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</p>'; } else { $curid = wppa_opt('widget_photo'); // Process photos foreach ($photos as $photo) { $id = $photo['id']; // Open container div echo '<div' . ' class="photoselect"' . ' style="' . 'width:180px;' . 'height:300px;' . '" >'; // Open image container div echo '<div' . ' style="' . 'width:180px;' . 'height:135px;' . 'overflow:hidden;' . 'text-align:center;' . '" >'; // The image if a video if (wppa_is_video($id)) { echo wppa_get_video_html(array('id' => $id, 'style' => 'width:180px;')); } else { echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'max-width:180px;' . 'max-height:135px;' . 'margin:auto;' . '"' . ' alt="' . esc_attr(wppa_get_photo_name($photo['id'])) . '" />'; // Audio ? if (wppa_has_audio($id)) { echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:180px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;')); } } // Close image container div echo '</div>'; ?> <div style="clear:both;width:100%;margin:3px 0;" > <div style="font-size:9px; line-height:10px;float:left;"><?php echo '(#' . $photo['p_order'] . ')'; ?> </div> <input style="float:right;" type="radio" name="wppa-widget-photo" id="wppa-widget-photo<?php echo $id; ?> " value="<?php echo $id; ?> " <?php if ($id == $curid) { echo 'checked="checked"'; } ?> /> </div> <div style="clear:both;overflow:auto;height:150px" > <div style="font-size:11px; overflow:hidden;"><?php echo wppa_get_photo_name($photo['id']); ?> </div> <div style="font-size:9px; line-height:10px;"><?php echo wppa_get_photo_desc($photo['id']); ?> </div> </div> </div> <?php } echo '<div class="clear"></div>'; } ?> <script type="text/javascript">wppaCheckWidgetMethod();</script> <br /> <p> <input type="submit" class="button-primary" name="wppa-set-submit" value="<?php _e('Save Changes', 'wp-photo-album-plus'); ?> " /> </p> </form> </div> <?php }
function wppa_add_to_cart($atts) { global $post; $thumb = wppa('current_photo'); extract(shortcode_atts(array('name' => wppa_get_photo_name($thumb['id']), 'price' => 0.01, 'qty_field' => '', 'b_title' => __('Buy now', 'wp-photo-album-plus'), 'options' => '', 'options_name' => '', 'qty_field' => '', 'fshipping' => '', 'weight' => ''), $atts)); $cart =& $_SESSION['wfcart']; // load the cart from the session $scabn_options = get_option('scabn_options'); $currency = apply_filters('scabn_display_currency_symbol', NULL); // Slideshow? if (wppa('is_slide')) { $action_url = wppa_get_slide_callback_url($thumb['id']); $item_url = $action_url . '&wppa-single=1'; $action_url = wppa_convert_to_pretty($action_url); $item_url = wppa_convert_to_pretty($item_url); } else { $action_url = wppa_get_thumb_callback_url(); if (!strpos($action_url, '&')) { $action_url = str_replace('&', '&', $action_url); } $item_url = wppa_get_slide_callback_url($thumb['id']) . '&wppa-single=1'; $action_url = wppa_convert_to_pretty($action_url); $item_url = wppa_convert_to_pretty($item_url); } $output = ' <div class="wppa-addtocart"> <form method="post" class="wppa-cartform ' . $name . '" action="' . $action_url . '"> ' . wp_nonce_field('add_to_cart', 'scabn-add', false, false) . ' <input type="hidden" value="add_item" name="action" /> <input type="hidden" class="item_url" value="' . $item_url . '" name="item_url" /> <input type="hidden" value="' . $cart->random() . '" name="randomid" /> <input type="hidden" value="' . $name . '" name="item_id" /> <input type="hidden" class="item_name" value="' . $name . '" name="item_name" /> <input type="hidden" class="item_price" value="' . $price . '" name="item_price" />'; if ($fshipping) { $output .= ' <input type="hidden" class="item_shipping" value="' . $fshipping . '" name="item_shipping" />'; } if ($weight) { $output .= ' <input type="hidden" class="item_weight" value="' . $weight . '" name="item_weight" />'; } if ($options) { if ($options_name) { $output .= $options_name . ': '; } $output .= ' <input type="hidden" value="' . $options_name . '" name="item_options_name" class="item_options_name" />'; $item_options = explode(',', $options); $output .= ' <select style="max-width:200px; margin:0" name="item_options" class="item_options" >'; foreach ($item_options as $option) { $info = explode(':', $option); if (count($info) == 1) { $output .= ' <option value="' . $info[0] . '">' . $info[0] . ' (' . $currency . number_format($price, 2) . ')</option>'; } else { $output .= ' <option value="' . $info[0] . ':' . $info[1] . '">' . $info[0] . ' (' . $currency . number_format($info[1], 2) . ')</option>'; } } $output .= ' </select>'; } else { $output .= sprintf(__('Unit Price: %s each', 'wp-photo-album-plus'), $currency . number_format($price, 2)) . ' '; } if ($qty_field) { $output .= __('Qty:', 'wp-photo-album-plus') . ' <input type="text" style="max-width:50px; margin:0;" class="item_qty" value="1" size="2" name="item_qty" />'; } else { $output .= '<input type="hidden" class="item_qty" value="1" size="2" name="item_qty" />'; } $output .= ' <input type="submit" id="' . $name . '" class="add" name="add" value="' . $b_title . '"/> </form> </div>'; return $output; }
function wppa_create_textual_watermark_file($args) { // See what we have $args = wp_parse_args((array) $args, array('content' => '---preview---', 'pos' => 'cencen', 'id' => '', 'font' => wppa_opt('wppa_textual_watermark_font'), 'text' => '', 'style' => wppa_opt('wppa_textual_watermark_type'), 'filebasename' => 'dummy', 'url' => false, 'width' => '', 'height' => '', 'transp' => '0')); // We may have been called from wppa_get_water_file_and_pos() just to find the settings // In this case there is no id given. $id = $args['id']; if (!$id && $args['content'] != '---preview---') { return false; } if ($id && wppa_is_video($id)) { // return false; } // Set special values in case of preview if ($args['content'] == '---preview---') { $preview = true; $fontsize = $args['font'] == 'system' ? 5 : 12; $padding = 6; $linespacing = ceil($fontsize * 2 / 3); } else { $preview = false; $fontsize = wppa_opt('wppa_textual_watermark_size'); if ($args['font'] == 'system') { $fontsize = min($fontsize, 5); } $padding = 12; $linespacing = ceil($fontsize * 2 / 3); } // Set font specific vars $fontfile = $args['font'] == 'system' ? '' : WPPA_UPLOAD_PATH . '/fonts/' . $args['font'] . '.ttf'; // Output file if ($preview) { $filename = WPPA_UPLOAD_PATH . '/fonts/wmf' . $args['filebasename'] . '.png'; } else { $filename = WPPA_UPLOAD_PATH . '/temp/wmf' . $args['filebasename'] . '.png'; } // Preprocess the text if (!$args['text']) { switch ($args['content']) { case '---preview---': $text = strtoupper(substr($args['font'], 0, 1)) . strtolower(substr($args['font'], 1)); break; case '---filename---': $text = wppa_get_photo_item($id, 'filename'); break; case '---name---': $text = wppa_get_photo_name($id); break; case '---description---': $text = strip_tags(wppa_strip_tags(wppa_get_photo_desc($id), 'style&script')); break; case '---predef---': $text = wppa_opt('wppa_textual_watermark_text'); if ($args['font'] != 'system') { $text = str_replace('( c )', '©', $text); $text = str_replace('( R )', '®', $text); } $text = html_entity_decode($text); $text = str_replace('w#site', get_bloginfo('url'), $text); $text = str_replace('w#owner', wppa_get_photo_item($id, 'owner'), $text); $text = str_replace('w#id', $id, $text); $text = str_replace('w#name', wppa_get_photo_name($id), $text); $text = str_replace('w#filename', wppa_get_photo_item($id, 'filename'), $text); $text = str_replace('w#timestamp', wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), wppa_get_photo_item($id, 'timestamp')), $text); $text = trim($text); break; default: wppa_log('Error', 'Unimplemented arg ' . $arg . ' in wppa_create_textual_watermark_file()'); return false; } } else { $text = $args['text']; } // Any text anyway? if (!strlen($text)) { wppa_log('Error', 'No text for textual watermark. photo=' . $id); return false; // No text -> no watermark } // Split text on linebreaks $text = str_replace("\n", '\\n', $text); $lines = explode('\\n', $text); // Trim and remove empty lines $temp = $lines; $lines = array(); foreach ($temp as $line) { $line = trim($line); if ($line) { $lines[] = $line; } } // Find image width if ($args['width']) { $image_width = $args['width']; } else { $image_width = ''; } if ($args['height']) { $image_height = $args['height']; } else { $image_height = ''; } if ($preview) { if (!$image_width) { $image_width = 2000; } if (!$image_height) { $image_height = 1000; } } else { // $temp = getimagesize( wppa_get_photo_path( $id ) ); $temp = wppa_get_imagexy($id); if (!is_array($temp)) { wppa_log('Error', 'Trying to apply a watermark on a non image file. Id = ' . $id); return false; // not an image } if (!$image_width) { $image_width = $temp[0]; } if (!$image_height) { $image_height = $temp[1]; } } $width_fits = false; while (!$width_fits) { // Find pixel linelengths foreach (array_keys($lines) as $key) { $lines[$key] = trim($lines[$key]); if ($args['font'] == 'system') { $lengths[$key] = strlen($lines[$key]) * imagefontwidth($fontsize); } else { $temp = imagettfbbox($fontsize, 0.0, $fontfile, $lines[$key]); $lengths[$key] = $temp[2] - $temp[0]; } } $maxlen = wppa_array_max($lengths); // Find canvas size $nlines = count($lines); if ($args['font'] == 'system') { $lineheight = imagefontheight($fontsize); } else { $temp = imagettfbbox($fontsize, 0.0, $fontfile, $lines[0]); $lineheight = $temp[3] - $temp[7]; } $canvas_width = wppa_array_max($lengths) + 4 * $padding; $canvas_height = ($lineheight + $linespacing) * count($lines) + 2 * $padding; // Does it fit? if ($canvas_width > $image_width) { // Break the longest line into two sublines. There should be a space in the right half, if not: fail $i = 0; $l = 0; foreach (array_keys($lines) as $key) { if (strlen($lines[$key]) > $l) { $i = $key; $l = strlen($lines[$key]); } } $temp = $lines; $lines = array(); $j = 0; while ($j < $i) { $lines[$j] = $temp[$j]; $j++; } // $j = $i; $llen = strlen($temp[$i]); $spos = floor($llen / 2); while ($spos < $llen && substr($temp[$i], $spos, 1) != ' ') { $spos++; } if ($spos == $llen) { // Unable to find a space, give up wppa_log('Error', 'Trying to apply a watermark that is too wide for the image. Id = ' . $id); return false; // too wide } $lines[$j] = substr($temp[$i], 0, $spos); $lines[$j + 1] = trim(str_replace($lines[$j], '', $temp[$i])); $i++; // $j = $i + 1; while ($j <= count($temp)) { $lines[$j] = $temp[$i]; $j++; } } else { $width_fits = true; } if ($canvas_height > $image_height) { wppa_log('Error', 'Trying to apply a watermark that is too high for the image. Id = ' . $id); return false; // not an image } } // Create canvas $canvas = imagecreatetruecolor($canvas_width, $canvas_height); $bgcolor = imagecolorallocatealpha($canvas, 0, 0, 0, 127); // Transparent $white = imagecolorallocatealpha($canvas, 255, 255, 255, $args['transp']); $black = imagecolorallocatealpha($canvas, 0, 0, 0, $args['transp']); imagefill($canvas, 0, 0, $bgcolor); // imagerectangle( $canvas, 0, 0, $canvas_width-1, $canvas_height-1, $white ); // debug // Define the text colors switch ($args['style']) { case 'tvstyle': case 'whiteonblack': $fg = $white; $bg = $black; break; case 'utopia': case 'blackonwhite': $fg = $black; $bg = $white; break; case 'white': $fg = $white; $bg = $bgcolor; break; case 'black': $fg = $black; $bg = $bgcolor; break; } // Plot the text foreach (array_keys($lines) as $lineno) { if (strpos($args['pos'], 'lft') !== false) { $indent = 0; } elseif (strpos($args['pos'], 'rht') !== false) { $indent = $maxlen - $lengths[$lineno]; } else { $indent = floor(($maxlen - $lengths[$lineno]) / 2); } switch ($args['style']) { case 'tvstyle': case 'utopia': for ($i = -1; $i <= 1; $i++) { for ($j = -1; $j <= 1; $j++) { if ($args['font'] == 'system') { imagestring($canvas, $fontsize, 2 * $padding + $i + $indent, $padding + $lineno * ($lineheight + $linespacing) + $j, $lines[$lineno], $bg); } else { imagettftext($canvas, $fontsize, 0, 2 * $padding + $i + $indent, $padding + ($lineno + 1) * $lineheight + $lineno * $linespacing + $j, $bg, $fontfile, $lines[$lineno]); } } } if ($args['font'] == 'system') { imagestring($canvas, $fontsize, 2 * $padding + $indent, $padding + $lineno * ($lineheight + $linespacing), $lines[$lineno], $fg); } else { imagettftext($canvas, $fontsize, 0, 2 * $padding + $indent, $padding + ($lineno + 1) * $lineheight + $lineno * $linespacing, $fg, $fontfile, $lines[$lineno]); } break; case 'blackonwhite': case 'whiteonblack': case 'white': case 'black': $lft = $padding + $indent; $rht = 3 * $padding + $indent + $lengths[$lineno]; $top = $lineno * ($lineheight + $linespacing) + $padding; $bot = ($lineno + 1) * ($lineheight + $linespacing) + $padding; imagefilledrectangle($canvas, $lft, $top + 1, $rht, $bot, $bg); // imagerectangle( $canvas, $lft, $top, $rht, $bot, $fg ); // debug $top = $padding + $lineno * ($lineheight + $linespacing) + floor($linespacing / 2); $lft = 2 * $padding + $indent; $bot = $padding + ($lineno + 1) * ($lineheight + $linespacing) - ceil($linespacing / 2); if ($args['font'] == 'system') { imagestring($canvas, $fontsize, $lft, $top, $lines[$lineno], $fg); } else { imagettftext($canvas, $fontsize, 0, $lft, $bot - 1, $fg, $fontfile, $lines[$lineno]); } break; } } imagesavealpha($canvas, true); imagepng($canvas, $filename); imagedestroy($canvas); if ($preview || $args['url']) { $url = str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $filename); return $url; } else { return $filename; } }
function wppa_get_share_html($id, $key = '', $js = true) { global $wppa_locale; $do_it = false; if (!wppa('is_slideonly') || $key == 'lightbox') { if (wppa_switch('share_on') && !wppa_in_widget()) { $do_it = true; } if (wppa_switch('share_on_widget') && wppa_in_widget()) { $do_it = true; } if (wppa_switch('share_on_lightbox')) { $do_it = true; } } if (!$do_it) { return ''; } // The share url if (wppa_in_widget()) { if (wppa_opt('widget_sm_linktype') == 'home') { $share_url = home_url(); } else { $share_url = get_permalink(wppa_get_the_landing_page('wppa_widget_sm_linkpage', __('Social media landing page', 'wp-photo-album-plus'))); $alb = wppa_get_photo_item($id, 'album'); $oc = wppa_opt('widget_sm_linkpage_oc'); $share_url .= '?wppa-album=' . $alb . '&wppa-photo=' . $id . '&wppa-cover=0&wppa-occur=' . $oc; if (wppa_switch('share_single_image')) { $share_url .= '&wppa-single=1'; } } } else { $share_url = wppa_get_image_page_url_by_id($id, wppa_switch('share_single_image')); $share_url = str_replace('&', '&', $share_url); } // The share title $photo_name = wppa_get_photo_name($id); // The share description $photo_desc = wppa_html(wppa_get_photo_desc($id)); $photo_desc = strip_shortcodes(wppa_strip_tags($photo_desc, 'all')); // The default description $site = str_replace('&', __('and', 'wp-photo-album-plus'), get_bloginfo('name')); $see_on_site = sprintf(__('See this image on %s', 'wp-photo-album-plus'), $site); // The share image. Must be the fullsize image for facebook. // If you take the thumbnail, facebook takes a different image at random. $share_img = wppa_get_photo_url($id); // The icon size if (wppa_in_widget() && $key != 'lightbox' || $key == 'thumb') { $s = '16'; } else { $s = wppa_opt('share_size'); } // qr code if (wppa_switch('share_qr') && $key != 'thumb') { $src = 'http://api.qrserver.com/v1/create-qr-code/' . '?data=' . urlencode($share_url) . '&size=80x80' . '&color=' . trim(wppa_opt('qr_color'), '#') . '&bgcolor=' . trim(wppa_opt('qr_bgcolor'), '#'); $qr = '<div style="float:left; padding:2px;" >' . '<img' . ' src="' . $src . '"' . ' title="' . esc_attr($share_url) . '"' . ' alt="' . __('QR code', 'wp-photo-album-plus') . '"' . ' />' . '</div>'; } else { $qr = ''; } // twitter share button if (wppa_switch('share_twitter')) { $tweet = urlencode($see_on_site) . ': '; $tweet_len = strlen($tweet) + '1'; $tweet .= urlencode($share_url); // find first '/' after 'http( s )://' rest doesnt count for twitter chars $url_len = strpos($share_url, '/', 8) + 1; $tweet_len += $url_len > 1 ? $url_len : strlen($share_url); $rest_len = 140 - $tweet_len; if (wppa_switch('show_full_name')) { if ($rest_len > strlen($photo_name)) { $tweet .= ' ' . urlencode($photo_name); $rest_len -= strlen($photo_name); $rest_len -= '2'; } else { $tweet .= ' ' . urlencode(substr($photo_name, 0, $rest_len)) . '...'; $rest_len -= strlen(substr($photo_name, 0, $rest_len)); $rest_len -= '5'; } } if ($photo_desc) { if ($rest_len > strlen($photo_desc)) { $tweet .= ': ' . urlencode($photo_desc); } elseif ($rest_len > 8) { $tweet .= ': ' . urlencode(substr($photo_desc, 0, $rest_len)) . '...'; } } $tw = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Tweet %s on Twitter', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://twitter.com/intent/tweet?text=' . $tweet . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'twitter.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Twitter', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $tw = ''; } // Google if (wppa_switch('share_google')) { $go = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Google+', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="https://plus.google.com/share?url=' . urlencode($share_url) . '"' . ' onclick="javascript:window.open( this.href, \\"\\", \\"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600\\" );return false;"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'google.png"' . ' style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Google+', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $go = ''; } // Pinterest $desc = urlencode($see_on_site) . ': ' . urlencode($photo_desc); if (strlen($desc) > 500) { $desc = substr($desc, 0, 495) . '...'; } if (wppa_switch('share_pinterest')) { $pi = '<div style="float:left; padding:0 2px;" >' . '<a' . ' title="' . sprintf(__('Share %s on Pinterest', 'wp-photo-album-plus'), esc_attr($photo_name)) . '"' . ' href="http://pinterest.com/pin/create/button/?url=' . urlencode($share_url) . '&media=' . urlencode(str_replace('/thumbs/', '/', $share_img)) . '&description=' . $desc . '"' . ' target="_blank"' . ' >' . '<img' . ' src="' . wppa_get_imgdir() . 'pinterest.png" style="height:' . $s . 'px;vertical-align:top;"' . ' alt="' . esc_attr(__('Share on Pinterest', 'wp-photo-album-plus')) . '"' . ' />' . '</a>' . '</div>'; } else { $pi = ''; } // LinkedIn if (wppa_switch('share_linkedin') && $key != 'thumb' && $key != 'lightbox') { $li = '<script' . ' type="text/javascript"' . ' src="//platform.linkedin.com/in.js"' . ' >' . 'lang: ' . $wppa_locale . '</script>' . '<script' . ' type="IN/Share"' . ' data-url="' . urlencode($share_url) . '"' . ' data-counter="top"' . ' >' . '</script>'; if ($js) { $li = str_replace('<', '[', $li); } } else { $li = ''; } // Facebook $fb = ''; $need_fb_init = false; $small = 'thumb' == $key; if ('lightbox' == $key) { if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) { $lbs = 'max-width:62px; max-height:96px; overflow:show;'; } else { $lbs = 'max-width:62px; max-height:64px; overflow:show;'; } } else { $lbs = ''; } // Share if (wppa_switch('share_facebook') && !wppa_switch('facebook_like')) { if ($small) { $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-type="icon"' . ' >' . '</div>'; } else { $disp = wppa_opt('fb_display'); if ('standard' == $disp) { $disp = 'button'; } $fb .= '<div' . ' class="fb-share-button"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-type="' . $disp . '"' . ' >' . '</div>'; } $need_fb_init = true; } // Like if (wppa_switch('facebook_like') && !wppa_switch('share_facebook')) { if ($small) { $fb .= '<div' . ' class="fb-like"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' >' . '</div>'; } else { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' >' . '</div>'; } $need_fb_init = true; } // Like and share if (wppa_switch('facebook_like') && wppa_switch('share_facebook')) { if ($small) { $fb .= '<div' . ' class="fb-like"' . ' style="float:left;"' . ' data-href="' . $share_url . '"' . ' data-layout="button"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>'; } else { $fb .= '<div' . ' class="fb-like"' . ' style="float:left; ' . $lbs . '"' . ' data-width="200"' . ' data-href="' . $share_url . '"' . ' data-layout="' . wppa_opt('fb_display') . '"' . ' data-action="like"' . ' data-show-faces="false"' . ' data-share="true"' . ' >' . '</div>'; } $need_fb_init = true; } // Comments if (wppa_switch('facebook_comments') && !wppa_in_widget() && $key != 'thumb' && $key != 'lightbox') { $width = wppa('auto_colwidth') ? '100%' : wppa_get_container_width(true); if (wppa_switch('facebook_comments')) { $fb .= '<div style="color:blue;clear:both" >' . __('Comment on Facebook:', 'wp-photo-album-plus') . '</div>'; $fb .= '<div class="fb-comments" data-href="' . $share_url . '" data-width=' . $width . '></div>'; $need_fb_init = true; } } // Need init? if ($need_fb_init) { if ($js && $key != 'thumb') { $fb .= '[script>wppaFbInit();[/script>'; } else { $fb .= '<script>wppaFbInit();</script>'; } } return $qr . $tw . $go . $pi . $li . $fb . '<div style="clear:both"></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_sequence($album) { global $wpdb; if ($album) { $photoorder = wppa_get_photo_order($album, 'norandom'); $is_descending = strpos($photoorder, 'DESC') !== false; $is_p_order = strpos($photoorder, 'p_order') !== false; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . $photoorder, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&bulk'); $size = '180'; if ($photos) { ?> <style> .sortable-placeholder { width: <?php echo $size; ?> px; height: <?php echo $size; ?> px; margin: 5px; border: 1px solid #cccccc; border-radius:3px; float: left; } .ui-state-default { position: relative; width: <?php echo $size; ?> px; height: <?php echo $size; ?> px; margin: 5px; border-radius:3px; float: left; } .wppa-publish { border: 1px solid; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 ); } .wppa-featured { border: 1px solid; background-color: rgb( 224, 255, 224 ); border-color: rgb( 85, 238, 85 ); } .wppa-pending { border: 1px solid; background-color: rgb( 255, 235, 232 ); border-color: rgb( 204, 0, 0 ); } </style> <script> jQuery( function() { jQuery( "#sortable" ).sortable( { cursor: "move", placeholder: "sortable-placeholder", stop: function( event, ui ) { var ids = jQuery( ".wppa-sort-item" ); var seq = jQuery( ".wppa-sort-seqn" ); var idx = 0; var descend = <?php if ($is_descending) { echo 'true'; } else { echo 'false'; } ?> ; while ( idx < ids.length ) { var newvalue; if ( descend ) newvalue = ids.length - idx; else newvalue = idx + 1; var oldvalue = seq[idx].value; var photo = ids[idx].value; if ( newvalue != oldvalue ) { wppaDoSeqUpdate( photo, newvalue ); } idx++; } } } ); } ); function wppaDoSeqUpdate( photo, seqno ) { var data = 'action=wppa&wppa-action=update-photo&photo-id='+photo+'&item=p_order&wppa-nonce='+document.getElementById( 'photo-nonce-'+photo ).value+'&value='+seqno; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState == 4 && xmlhttp.status != 404 ) { var ArrValues = xmlhttp.responseText.split( "||" ); if ( ArrValues[0] != '' ) { alert( 'The server returned unexpected output:\n'+ArrValues[0] ); } switch ( ArrValues[1] ) { case '0': // No error jQuery( '#wppa-seqno-'+photo ).html( seqno ); break; case '99': // Photo is gone jQuery( '#wppa-seqno-'+photo ).html( '<span style="color"red" >deleted</span>' ); break; default: // Any error jQuery( '#wppa-seqno-'+photo ).html( '<span style="color"red" >Err:'+ArrValues[1]+'</span>' ); break; } } } xmlhttp.open( 'POST',wppaAjaxUrl,true ); xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" ); xmlhttp.send( data ); jQuery( "#wppa-sort-seqn-"+photo ).attr( 'value', seqno ); // set hidden value to new value to prevent duplicate action var spinnerhtml = '<img src="'+wppaImageDirectory+'wpspin.gif'+'" />'; jQuery( '#wppa-seqno-'+photo ).html( spinnerhtml ); } </script> <?php if (!$is_p_order) { wppa_warning_message(__('Setting photo sequence order has only effect if the photo order method is set to <b>Order#</b>', 'wp-photo-album-plus')); } ?> <div class="widefat" style="border-color:#cccccc" > <div id="sortable"> <?php foreach ($photos as $photo) { if (wppa_is_video($photo['id'])) { $imgs['0'] = wppa_get_videox($photo['id']); $imgs['1'] = wppa_get_videoy($photo['id']); } else { // $imgs = getimagesize( wppa_get_thumb_path( $photo['id'] ) ); $imgs['0'] = wppa_get_thumbx($photo['id']); $imgs['1'] = wppa_get_thumby($photo['id']); } if (!$imgs['0']) { // missing thuimbnail, prevent division by zero $imgs['0'] = 200; $imgs['1'] = 150; } $mw = $size - '20'; $mh = $mw * '3' / '4'; if ($imgs[1] / $imgs[0] > $mh / $mw) { // more portrait than 200x150, y is limit $mt = '15'; } else { // x is limit $mt = ($mh - $imgs[1] / $imgs[0] * $mw) / '2' + '15'; } ?> <div id="photoitem-<?php echo $photo['id']; ?> " class="ui-state-default wppa-<?php echo $photo['status']; ?> " style="background-image:none; text-align:center; cursor:move;" > <?php if (wppa_is_video($photo['id'])) { ?> <?php $id = $photo['id']; ?> <?php $imgstyle = 'max-width:' . $mw . 'px; max-height:' . $mh . 'px; margin-top:' . $mt . 'px;'; ?> <?php echo wppa_get_video_html(array('id' => $id, 'controls' => false, 'tagid' => 'pa-id-' . $id, 'preload' => 'metadata', 'class' => 'wppa-bulk-thumb', 'style' => $imgstyle, 'use_thumb' => true)); ?> <!-- <video preload="metadata" class="wppa-bulk-thumb" style="max-width:<?php echo $mw; ?> px; max-height:<?php echo $mh; ?> px; margin-top: <?php echo $mt; ?> px;" > // echo //wppa_get_video_body( $photo['id'] ) ?> </video> --> <?php } else { ?> <img class="wppa-bulk-thumb" src="<?php echo wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']); ?> " style="max-width:<?php echo $mw; ?> px; max-height:<?php echo $mh; ?> px; margin-top: <?php echo $mt; ?> px;" /> <?php } ?> <div style="font-size:9px; position:absolute; bottom:24px; text-align:center; width:<?php echo $size; ?> px;" ><?php echo wppa_get_photo_name($photo['id']); ?> </div> <div style="text-align: center; width: <?php echo $size; ?> px; position:absolute; bottom:8px;" > <span style="margin-left:15px;float:left"><?php echo __('Id: ', 'wp-photo-album-plus') . $photo['id']; ?> </span> <?php if (wppa_is_video($photo['id'])) { _e('Video', 'wp-photo-album-plus'); } ?> <?php if (wppa_has_audio($photo['id'])) { _e('Audio', 'wp-photo-album-plus'); } ?> <span style="float:right; margin-right:15px;"><?php echo __('Ord: ', 'wp-photo-album-plus') . '<span id="wppa-seqno-' . $photo['id'] . '" >' . $photo['p_order']; ?> </span> </div> <input type="hidden" id="photo-nonce-<?php echo $photo['id']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $photo['id']); ?> " /> <input type="hidden" class="wppa-sort-item" value="<?php echo $photo['id']; ?> " /> <input type="hidden" class="wppa-sort-seqn" id="wppa-sort-seqn-<?php echo $photo['id']; ?> " value="<?php echo $photo['p_order']; ?> " /> </div> <?php } ?> </div> <div style="clear:both;"></div> </div> <?php } else { echo '<h3>' . __('The album is empty.', 'wp-photo-album-plus') . '</h3>'; } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 3', '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; }
function _wppa_sidebar_page_options() { global $wpdb; global $wppa_defaults; wppa_set_defaults(); $onch = 'myReload()'; // Handle spinner js and declare functions echo '<script type="text/javascript" >' . 'var didsome=false;' . 'jQuery(document).ready(function() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'none\');' . '});' . 'function myReload() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'block\');' . '_wppaRefreshAfter = true;' . '};' . 'function wppaSetFixed(id) {' . 'if (jQuery(\'#wppa-widget-photo-\' + id).attr(\'checked\') == \'checked\' ) {' . '_wppaRefreshAfter = true;' . 'wppaAjaxUpdateOptionValue(\'potd_photo\', id);' . '}' . '};' . '</script>'; // The spinner echo '<img' . ' id="wppa-spinner"' . ' style="position:fixed;top:50%;left:50%;z-index:1000;margin-top:-33px;margin-left:-33px;display:block;"' . ' src="' . wppa_get_imgdir('loader.gif') . '"' . '/>'; // Open wrapper echo '<div class="wrap">'; // The settings icon echo '<img src="' . wppa_get_imgdir('settings32.png') . '" />'; // The Page title echo '<h1 style="display:inline;" >' . __('Photo of the Day (Widget) Settings', 'wp-photo-album-plus') . '</h1>' . __('Changes are updated immediately. The page will reload if required.', 'wp-photo-album-plus') . '<br /> '; // The nonce wp_nonce_field('wppa-nonce', 'wppa-nonce'); // The settings table echo '<table class="widefat wppa-table wppa-setting-table">'; // The header echo '<thead style="font-weight: bold; " class="wppa_table_1">' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>'; // Open the table body echo '<tbody class="wppa_table" >'; $name = __('Widget Title:', 'wp-photo-album-plus'); $desc = __('The title of the widget.', 'wp-photo-album-plus'); $help = esc_js(__('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wp-photo-album-plus')); $slug = 'wppa_potd_title'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '1', $name, $desc, $html, $help); $name = __('Widget Photo Width:', 'wp-photo-album-plus'); $desc = __('Enter the desired display width of the photo in the sidebar.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_widget_width'; $html = wppa_input($slug, '40px', '', __('pixels wide', 'wp-photo-album-plus')); wppa_setting($slug, '2', $name, $desc, $html, $help); $name = __('Horizontal alignment:', 'wp-photo-album-plus'); $desc = __('Enter the desired display alignment of the photo in the sidebar.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_align'; $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('left', 'wp-photo-album-plus'), __('center', 'wp-photo-album-plus'), __('right', 'wp-photo-album-plus')); $vals = array('none', 'left', 'center', 'right'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '3', $name, $desc, $html, $help); $linktype = wppa_opt('potd_linktype'); if ($linktype == 'custom') { $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('Enter the url. Do\'nt forget the HTTP://', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linkurl'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '4', $name, $desc, $html, $help); $name = __('Link Title:', 'wp-photo-album-plus'); $desc = __('The balloon text when hovering over the photo.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linktitle'; $html = wppa_input($slug, '85%'); wppa_setting($slug, '4a', $name, $desc, $html, $help); } else { $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_linkurl'; $html = ''; wppa_setting($slug, '4', $name, $desc, $html, $help); } $name = __('Subtitle:', 'wp-photo-album-plus'); $desc = __('Select the content of the subtitle.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_subtitle'; $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('Photo Name', 'wp-photo-album-plus'), __('Description', 'wp-photo-album-plus'), __('Owner', 'wp-photo-album-plus')); $vals = array('none', 'name', 'desc', 'owner'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '5', $name, $desc, $html, $help); $name = __('Counter:', 'wp-photo-album-plus'); $desc = __('Display a counter of other photos in the album.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_counter'; $html = wppa_checkbox($slug); wppa_setting($slug, '6', $name, $desc, $html, $help); $name = __('Link to:', 'wp-photo-album-plus'); $desc = __('The counter links to.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_counter_link'; $opts = array(__('thumbnails', 'wp-photo-album-plus'), __('slideshow', 'wp-photo-album-plus'), __('single image', 'wp-photo-album-plus')); $vals = array('thumbs', 'slide', 'single'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '7', $name, $desc, $html, $help); $name = __('Type of album(s) to use:', 'wp-photo-album-plus'); $desc = __('Select physical or virtual.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_album_type'; $opts = array(__('physical albums', 'wp-photo-album-plus'), __('virtual albums', 'wp-photo-album-plus')); $vals = array('physical', 'virtual'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '8', $name, $desc, $html, $help); $name = __('Albums to use:', 'wp-photo-album-plus'); $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_album'; if (get_option('wppa_potd_album_type') == 'physical') { $html = '<select' . ' id="wppa_potd_album"' . ' name="wppa_potd_album"' . ' style="float:left; max-width: 100%;"' . ' multiple="multiple"' . ' onchange="didsome=true;wppaAjaxUpdateOptionValue(\'potd_album\', this, true)"' . ' onmouseout="if(didsome)document.location.reload(true);"' . ' size="10"' . ' >' . wppa_album_select_a(array('path' => true, 'optionclass' => 'potd_album', 'selected' => get_option('wppa_potd_album'))) . '</select>' . '<img id="img_potd_album" class="" src="' . wppa_get_imgdir() . 'star.ico" title="' . __('Setting unmodified', 'wp-photo-album-plus') . '" style="padding:0 4px; float:left; height:16px; width:16px;" />'; wppa_setting($slug, '9', $name, $desc, $html, $help); } else { $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus'); $opts = array(__('- all albums -', 'wp-photo-album-plus'), __('- all -separate- albums -', 'wp-photo-album-plus'), __('- all albums except -separate-', 'wp-photo-album-plus'), __('- top rated photos -', 'wp-photo-album-plus')); $vals = array('all', 'sep', 'all-sep', 'topten'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '9', $name, $desc, $html, $help); } if (get_option('wppa_potd_album_type') == 'physical') { $name = __('Include (grand)children:', 'wp-photo-album-plus'); $desc = __('Include the photos of all sub albums?', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_include_subs'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '9a', $name, $desc, $html, $help); $name = __('Inverse selection:', 'wp-photo-album-plus'); $desc = __('Use any album, except the selection made above.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_inverse'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '9b', $name, $desc, $html, $help); } $name = __('Status filter:', 'wp-photo-album-plus'); $desc = __('Use only photos with a certain status.', 'wp-photo-album-plus'); $help = esc_js(__('Select - none - if you want no filtering on status.', 'wp-photo-album-plus')); $slug = 'wppa_potd_status_filter'; $opts = array(__('- none -', 'wp-photo-album-plus'), __('Publish', 'wp-photo-album-plus'), __('Featured', 'wp-photo-album-plus'), __('Gold', 'wp-photo-album-plus'), __('Silver', 'wp-photo-album-plus'), __('Bronze', 'wp-photo-album-plus'), __('Any medal', 'wp-photo-album-plus')); $vals = array('none', 'publish', 'featured', 'gold', 'silver', 'bronze', 'anymedal'); $html = wppa_select($slug, $opts, $vals); wppa_setting($slug, '10', $name, $desc, $html, $help); $name = __('Display method:', 'wp-photo-album-plus'); $desc = __('Select the way a photo will be selected.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_method'; $opts = array(__('Fixed photo', 'wp-photo-album-plus'), __('Random', 'wp-photo-album-plus'), __('Last upload', 'wp-photo-album-plus'), __('Change every', 'wp-photo-album-plus')); $vals = array('1', '2', '3', '4'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '11', $name, $desc, $html, $help); if (get_option('wppa_potd_method') == '4') { // Change every $name = __('Change every period:', 'wp-photo-album-plus'); $desc = __('The time period a certain photo is used.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_period'; $opts = array(__('pageview.', 'wp-photo-album-plus'), __('hour.', 'wp-photo-album-plus'), __('day.', 'wp-photo-album-plus'), __('week.', 'wp-photo-album-plus'), __('month.', 'wp-photo-album-plus'), __('day of week is order#', 'wp-photo-album-plus'), __('day of month is order#', 'wp-photo-album-plus'), __('day of year is order#', 'wp-photo-album-plus')); $vals = array('0', '1', '24', '168', '736', 'day-of-week', 'day-of-month', 'day-of-year'); $html = wppa_select($slug, $opts, $vals, $onch); wppa_setting($slug, '11a', $name, $desc, $html, $help); $wppa_widget_period = get_option('wppa_potd_period'); if (substr($wppa_widget_period, 0, 7) == 'day-of-') { switch (substr($wppa_widget_period, 7)) { case 'week': $n_days = '7'; $date_key = 'w'; break; case 'month': $n_days = '31'; $date_key = 'd'; break; case 'year': $n_days = '366'; $date_key = 'z'; break; } while (get_option('wppa_potd_offset', '0') > $n_days) { update_option('wppa_potd_offset', get_option('wppa_potd_offset') - $n_days); } while (get_option('wppa_potd_offset', '0') < '0') { update_option('wppa_potd_offset', get_option('wppa_potd_offset') + $n_days); } $name = __('Day offset:', 'wp-photo-album-plus'); $desc = __('The difference between daynumber and photo order number.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_offset'; $opts = array(); $day = '0'; while ($day < $n_days) { $opts[] = $day; $day++; } $vals = $opts; $html = '<span style="float:left;" >' . sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), wppa_local_date($date_key)) . '</span> ' . wppa_select($slug, $opts, $vals, $onch); $photo_order = wppa_local_date($date_key) - get_option('wppa_potd_offset', '0'); while ($photo_order < '0') { $photo_order += $n_days; } $html .= sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order); wppa_setting($slug, '11b', $name, $desc, $html, $help); } } $name = __('Preview', 'wp-photo-album-plus'); $desc = __('Current "photo of the day":', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_photo'; $photo = wppa_get_potd(); if ($photo) { $html = '<div style="display:inline-block;width:25%;text-align:center;vertical-align:middle;">' . '<img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" />' . '</div>' . '<div style="display:inline-block;width:75%;text-align:center;vertical-align:middle;" >' . __('Album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($photo['album']) . '<br />' . __('Uploader', 'wp-photo-album-plus') . ': ' . $photo['owner'] . '</div>'; } else { $html = __('Not found.', 'wp-photo-album-plus'); } wppa_setting($slug, '12', $name, $desc, $html, $help); $name = __('Show selection', 'wp-photo-album-plus'); $desc = __('Show the photos in the current selection.', 'wp-photo-album-plus'); $help = ''; $slug = 'wppa_potd_preview'; $html = wppa_checkbox($slug, $onch); wppa_setting($slug, '13', $name, $desc, $html, $help); // Cose table body echo '</tbody>'; // Table footer echo '<tfoot style="font-weight: bold;" >' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</tfoot>' . '</table>'; // Diagnostic // echo // 'Diagnostic: wppa_potd_album = ' . get_option( 'wppa_potd_album' ) . ' wppa_potd_photo = ' . get_option( 'wppa_potd_photo' ); // Status star must be here for js echo '<img' . ' id="img_potd_photo"' . ' src="' . wppa_get_imgdir('star.ico') . '" style="height:12px;display:none;"' . ' />'; // The potd photo pool echo '<table class="widefat wppa-table wppa-setting-table" >'; // Table header echo '<thead>' . '<tr>' . '<td>' . __('Photos in the current selection', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>'; // Table body if (wppa_switch('potd_preview')) { echo '<tbody>' . '<tr>' . '<td>'; // Get the photos $alb = wppa_opt('potd_album'); $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : ''; $photos = wppa_get_widgetphotos($alb, $opt); // Count them $cnt = count($photos); // Find current $curid = wppa_opt('potd_photo'); // See if we do this if (empty($photos)) { _e('No photos in the selection', 'wp-photo-album-plus'); } elseif ($cnt > '5000') { echo sprintf(__('There are too many photos in the selection to show a preview ( %d )', 'wp-photo-album-plus'), $cnt); } else { // Yes, display the pool foreach ($photos as $photo) { $id = $photo['id']; // Open container div echo '<div' . ' class="photoselect"' . ' style="' . 'width:180px;' . 'height:300px;' . '" >'; // Open image container div echo '<div' . ' style="' . 'width:180px;' . 'height:135px;' . 'overflow:hidden;' . 'text-align:center;' . '" >'; // The image if a video if (wppa_is_video($id)) { echo wppa_get_video_html(array('id' => $id, 'style' => 'width:180px;')); } else { echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'max-width:180px;' . 'max-height:135px;' . 'margin:auto;' . '"' . ' alt="' . esc_attr(wppa_get_photo_name($id)) . '" />'; // Audio ? if (wppa_has_audio($id)) { echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:180px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;')); } } // Close image container div echo '</div>'; // The order# and select radio box echo '<div style="clear:both;width:100%;margin:3px 0;position:relative;top:5px;" >' . '<div style="font-size:9px; line-height:10px;float:left;">(#' . $photo['p_order'] . ')</div>'; if (get_option('wppa_potd_method') == '1') { // Only if fixed photo echo '<input' . ' style="float:right;"' . ' type="radio"' . ' name="wppa-widget-photo"' . ' id="wppa-widget-photo-' . $id . '"' . ' value="' . $id . '"' . ($id == $curid ? 'checked="checked"' : '') . ' onchange="wppaSetFixed(' . $id . ');"' . ' />'; } echo '</div>'; // The name/desc boxecho echo '<div style="clear:both;overflow:hidden;height:150px;position:relative;top:10px;" >' . '<div style="font-size:11px; overflow:hidden;">' . wppa_get_photo_name($id) . '</div>' . '<div style="font-size:9px; line-height:10px;">' . wppa_get_photo_desc($id) . '</div>' . '</div>'; // Close container echo '</div>'; } echo '<div class="clear"></div>'; } // Close the table echo '</td>' . '</tr>' . '</tbody>'; } echo '</table>'; // Close wrap echo '</div>'; }