function wppa_get_photo_desc($id, $do_shortcodes = false, $do_geo = false) { // Verify args if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red'); return ''; } // Get data $thumb = wppa_cache_thumb($id); $desc = $thumb['description']; // Raw data $desc = stripslashes($desc); // Unescape $desc = __($desc); // qTranslate // To prevent recursive rendering of scripts or shortcodes: $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc); // Geo if ($thumb['location'] && !wppa('in_widget') && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') { wppa_do_geo($id, $thumb['location']); } // Other keywords if (strpos($desc, 'w#') !== false) { // Is there any 'w#' ? // Keywords $desc = str_replace('w#albumname', wppa_get_album_name($thumb['album']), $desc); $desc = str_replace('w#albumid', $thumb['album'], $desc); $keywords = array('name', 'filename', 'owner', 'id', 'tags', 'views', 'album'); foreach ($keywords as $keyword) { $replacement = __(trim(stripslashes($thumb[$keyword]))); if ($replacement == '') { $replacement = '‹' . __a('none', 'wppa') . '›'; } $desc = str_replace('w#' . $keyword, $replacement, $desc); } $desc = str_replace('w#url', wppa_get_lores_url($id), $desc); $desc = str_replace('w#hrurl', esc_attr(wppa_get_hires_url($id)), $desc); $desc = str_replace('w#tnurl', wppa_get_tnres_url($id), $desc); $desc = str_replace('w#pl', wppa_get_source_pl($id), $desc); // Art monkey sizes if (strpos($desc, 'w#amx') !== false || strpos($desc, 'w#amy') !== false || strpos($desc, 'w#amfs') !== false) { $amxy = wppa_get_artmonkey_size_a($id); if (is_array($amxy)) { $desc = str_replace('w#amx', $amxy['x'], $desc); $desc = str_replace('w#amy', $amxy['y'], $desc); $desc = str_replace('w#amfs', $amxy['s'], $desc); } else { $desc = str_replace('w#amx', 'N.a.', $desc); $desc = str_replace('w#amy', 'N.a.', $desc); $desc = str_replace('w#amfs', 'N.a.', $desc); } } // Timestamps $timestamps = array('timestamp', 'modified'); foreach ($timestamps as $timestamp) { if ($thumb[$timestamp]) { $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $thumb[$timestamp]), $desc); } else { $desc = str_replace('w#' . $timestamp, '‹' . __a('unknown') . '›', $desc); } } // Custom data fields if (wppa_switch('custom_fields')) { $custom = $thumb['custom']; $custom_data = $custom ? unserialize($custom) : array('', '', '', '', '', '', '', '', '', ''); for ($i = '0'; $i < '10'; $i++) { if (wppa_opt('custom_caption_' . $i)) { // Field defined if (wppa_switch('custom_visible_' . $i)) { // May be displayed $desc = str_replace('w#cc' . $i, __(wppa_opt('custom_caption_' . $i)) . ':', $desc); // Caption $desc = str_replace('w#cd' . $i, __(stripslashes($custom_data[$i])), $desc); // Data } else { // May not be displayed $desc = str_replace('w#cc' . $i, '', $desc); // Remove $desc = str_replace('w#cd' . $i, '', $desc); // Remove } } else { // Field not defined $desc = str_replace('w#cc' . $i, '', $desc); // Remove $desc = str_replace('w#cd' . $i, '', $desc); // Remove } } } } // Shortcodes if ($do_shortcodes) { $desc = do_shortcode($desc); } else { $desc = strip_shortcodes($desc); } // Remove shortcodes if not wanted $desc = wppa_html($desc); // Enable html $desc = balanceTags($desc, true); // Balance tags $desc = wppa_filter_iptc($desc, $id); // Render IPTC tags $desc = wppa_filter_exif($desc, $id); // Render EXIF tags $desc = make_clickable($desc); // Auto make a tags for links $desc = convert_smilies($desc); // Make smilies visible // CMTooltipGlossary on board? $desc = wppa_filter_glossary($desc); return $desc; }
function wppa_get_photo_desc($id, $do_shortcodes = false, $do_geo = false) { // Verify args if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red'); return ''; } // Get data $thumb = wppa_cache_thumb($id); $desc = $thumb['description']; // Raw data $desc = stripslashes($desc); // Unescape $desc = __($desc, 'wp-photo-album-plus'); // qTranslate // To prevent recursive rendering of scripts or shortcodes: $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc); // Geo if ($thumb['location'] && !wppa_in_widget() && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') { wppa_do_geo($id, $thumb['location']); } // Other keywords $desc = wppa_translate_photo_keywords($id, $desc); // Shortcodes if ($do_shortcodes) { $desc = do_shortcode($desc); } else { $desc = strip_shortcodes($desc); } // Remove shortcodes if not wanted $desc = wppa_html($desc); // Enable html $desc = balanceTags($desc, true); // Balance tags $desc = wppa_filter_iptc($desc, $id); // Render IPTC tags $desc = wppa_filter_exif($desc, $id); // Render EXIF tags $desc = make_clickable($desc); // Auto make a tags for links $desc = convert_smilies($desc); // Make smilies visible // CMTooltipGlossary on board? $desc = wppa_filter_glossary($desc); return $desc; }