function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
function wppa_get_masonry_title($id) { $result = ''; $thumb = wppa_cache_thumb($id); // Name if (wppa_switch('thumb_text_name') || wppa_switch('thumb_text_owner')) { $result .= wppa_get_photo_name($id, wppa_switch('thumb_text_owner'), false, false, wppa_switch('thumb_text_name')) . "\n"; } // Description if (wppa_switch('thumb_text_desc') || $thumb['status'] == 'pending' || $thumb['status'] == 'scheduled') { $result .= wppa_get_photo_desc($id, wppa_switch('allow_foreign_shortcodes_thumbs')) . "\n"; } // Rating if (wppa_switch('thumb_text_rating')) { $rating = wppa_get_rating_by_id($id); if ($rating && wppa_switch('show_rating_count')) { $result .= ' ( ' . wppa_get_rating_count_by_id($id) . ' )' . "\n"; } } // Viewcount if (wppa_switch('thumb_text_viewcount')) { $result .= sprintf(_n('%d view', '%d views', $thumb['views'], 'wp-photo-album-plus'), $thumb['views']); } $result = strip_tags(rtrim($result, "\n")); return $result; }
function wppa_get_lbtitle($type, $id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red'); } $thumb = wppa_cache_thumb($id); $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox'); $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner'); $do_desc = wppa_switch('ovl_' . $type . '_desc'); $do_sm = wppa_switch('share_on_lightbox'); $result = ''; if ($do_download) { if (wppa_opt('art_monkey_display') == 'button') { $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' value="' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '"' . ' />'; } else { $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', ' . $id . ' );"' . ' >' . __('Download:', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')) . '</a>'; } } else { if ($do_name) { $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')); } } if ($do_name && $do_desc) { $result .= '<br />'; } if ($do_desc) { $result .= wppa_get_photo_desc($thumb['id']); } if (($do_name || $do_desc) && $do_sm) { $result .= '<br />'; } if ($do_sm) { $result .= wppa_get_share_html($thumb['id'], 'lightbox'); } $result = esc_attr($result); return $result; }
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_get_lbtitle($type, $id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red'); } $thumb = wppa_cache_thumb($id); $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox'); if ($type == 'xphoto') { $type = 'mphoto'; } $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner'); $do_desc = wppa_switch('ovl_' . $type . '_desc'); $do_sm = wppa_switch('share_on_lightbox'); $result = ''; if ($do_download) { if (wppa_opt('art_monkey_display') == 'button') { $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button wppa-ovl-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' value="' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '"' . ' />'; } else { $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' >' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '</a>'; } } else { if ($do_name) { $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')); } } if ($do_name && $do_desc) { $result .= '<br />'; } if ($do_desc) { $result .= wppa_get_photo_desc($thumb['id']); } if (($do_name || $do_desc) && $do_sm) { $result .= '<br />'; } if (wppa_opt('rating_max') != '1' && wppa_opt('rating_display_type') == 'graphic') { $result .= wppa_get_rating_range_html($id, true); } elseif (wppa_opt('rating_display_type') == 'likes' && wppa_switch('ovl_rating')) { $result .= wppa_get_slide_rating_vote_only('always', $id, 'is_lightbox'); } if ($do_sm) { $result .= wppa_get_share_html($thumb['id'], 'lightbox'); } if (wppa_may_user_fe_edit($id)) { if ($type == 'slide') { $parg = esc_js('\'' . wppa_encrypt_photo($id) . '\''); } else { $parg = '\'' . wppa_encrypt_photo($id) . '\''; } if (wppa_opt('upload_edit') == 'classic') { $result .= ' <input' . ' type="button"' . ' style="float:right; margin-right:6px;"' . ' class="wppa-ovl-button"' . ' onclick="' . ($type == 'slide' ? '_wppaStop( ' . wppa('mocc') . ' );' : '') . 'wppaEditPhoto( ' . wppa('mocc') . ', ' . $parg . ' );"' . ' value="' . esc_attr(__(wppa_opt('fe_edit_button'))) . '"' . ' />'; } } $result = esc_attr($result); return $result; }
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_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; } }
/** @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); }
/** @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>'; }