';
}
// feed copyright
function insert_feedinfo_SHe($content){
if (is_feed()){
$options = get_option('SHe_options');
$insert = '
' . $options['feedinfo'] . '' . get_option('blogname') . '' . '
' . "\n";
$content = $content . $insert;
}
return $content;
}
// Google AD after index first post
function index_ggad_SHe(){
global $wp_query;
$options = get_option('SHe_options');
if ($options['indexggad'] == ''){
return;
}else{
$output = '';
if ($wp_query->current_post == 0) :
$output .= '
'."\n";
$output .= $options['indexggad'];
$output .= "\n".'
';
echo "$output\n";
endif;
}
}
// get random posts
function random_posts_SHe ($limitclause='') {
global $wpdb, $tableposts, $post;
$q = "SELECT ID, post_title, post_date, comment_count FROM $tableposts WHERE post_status = 'publish' AND post_type = 'post' AND ID != $post->ID ORDER BY RAND() $limitclause";
return $wpdb->get_results($q);
}
// echo random posts
function random_posts (){
$options = get_option('SHe_options');
$number = $options['rd_limit'];
$limitclause='LIMIT ' . $number;
$random_posts = random_posts_SHe ($limitclause);
foreach ($random_posts as $random_post ){
$output .= '
' . "\n";
$output .= ''.wptexturize($random_post->post_title).'' . "\n" . '' . "\n";
}
echo $output;
}
// echo related posts
function related_posts_SHe() {
global $wpdb, $post,$table_prefix;
$options = get_option('SHe_options');
$rp_limit = $options['rp_limit'];
$rp_title = $options['rp_title'];
if ( $exclude != '' ) {
$q = "SELECT tt.term_id FROM ". $table_prefix ."term_taxonomy tt, " . $table_prefix . "term_relationships tr WHERE tt.taxonomy = 'category' AND tt.term_taxonomy_id = tr.term_taxonomy_id AND tr.object_id = $post->ID";
$cats = $wpdb->get_results($q);
foreach(($cats) as $cat) {
if (in_array($cat->term_id, $exclude) != false){
return;
}
}
}
if(!$post->ID){return;}
$now = current_time('mysql', 1);
$tags = wp_get_post_tags($post->ID);
$taglist = "'" . $tags[0]->term_id. "'";
$tagcount = count($tags);
if ($tagcount > 1) {
for ($i = 1; $i <= $tagcount; $i++) {
$taglist = $taglist . ", '" . $tags[$i]->term_id . "'";
}
}
if ($rp_limit) {
$limitclause = 'LIMIT ' . $rp_limit;
} else {
$limitclause = 'LIMIT 5';
}
$q = "SELECT p.ID, p.post_title, p.post_date, p.comment_count, count(t_r.object_id) as cnt FROM $wpdb->term_taxonomy t_t, $wpdb->term_relationships t_r, $wpdb->posts p WHERE t_t.taxonomy ='post_tag' AND t_t.term_taxonomy_id = t_r.term_taxonomy_id AND t_r.object_id = p.ID AND (t_t.term_id IN ($taglist)) AND p.ID != $post->ID AND p.post_status = 'publish' AND p.post_date_gmt < '$now' GROUP BY t_r.object_id ORDER BY cnt DESC, p.post_date_gmt DESC $limitclause;";
$related_posts = $wpdb->get_results($q);
$output = '';
if (!$related_posts){
$related_posts = random_posts_SHe($limitclause);
$rp_title = __('Random posts','freephp');
}
foreach ($related_posts as $related_post ){
$output .= '
' . "\n";
$output .= ''.wptexturize($related_post->post_title).'';
$output .= '' . "\n" . '' . "\n";
}
$output = '
' . "\n";
if($rp_title != '') $output = '
'.$rp_title .'
' . "\n" . $output;
echo $output;
}
// recent comments with get_avatar
function recent_comments_SHe($show_pass_post = false) {
$options = get_option('SHe_options');
$no_comments = $options['rc_limit'];
$admin_email = get_option('admin_email');
global $wpdb, $tablecomments, $tableposts;
$request = "SELECT ID, comment_ID, comment_content, post_title, comment_author_email, comment_author FROM $tableposts, $tablecomments WHERE
$tableposts.ID=$tablecomments.comment_post_ID AND (post_status = 'publish' AND comment_author_email !='$admin_email' OR post_status = 'static') AND comment_type = ''";
if(!$show_pass_post) { $request .= "AND post_password ='' "; }
$request .= "AND comment_approved = '1' ORDER BY $tablecomments.comment_date DESC LIMIT $no_comments";
$comments = $wpdb->get_results($request);
$output = '';
foreach ($comments as $comment) {
$comment_author = stripslashes($comment->comment_author);
$comment_excerpt = mb_strimwidth(strip_tags(apply_filters('the_comment', $comment->comment_content)), 0, 40,"");
$permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
$output .= '
' . "\n";
$output .= '
' . "\n";
$output .= get_avatar($comment, 24) . '
' . "\n";
$output .= '
' . "\n";
$output .= '
' . $comment_excerpt . '...
' . "\n";
$output .= '
' . "\n";
}
echo $output;
}
// archives list
function archives_list_SHe() {
global $wpdb,$month;
$lastpost = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_date <'" . current_time('mysql') . "' AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC LIMIT 1");
$output = get_option('SHe_archives_'.$lastpost);
if(empty($output)){
$output = '';
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'SHe_archives_%'");
$q = "SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM $wpdb->posts p WHERE post_date <'" . current_time('mysql') . "' AND post_status='publish' AND post_type='post' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
$monthresults = $wpdb->get_results($q);
if ($monthresults) {
foreach ($monthresults as $monthresult) {
$thismonth = zeroise($monthresult->month, 2);
$thisyear = $monthresult->year;
$q = "SELECT ID, post_date, post_title, comment_count FROM $wpdb->posts p WHERE post_date LIKE '$thisyear-$thismonth-%' AND post_date AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC";
$postresults = $wpdb->get_results($q);
if ($postresults) {
$text = sprintf('%s %d', $month[zeroise($monthresult->month,2)], $monthresult->year);
$postcount = count($postresults);
$output .= '
- ' . $text . ' (' . count($postresults) . ' ' . __('Posts','freephp') . ')
' . "\n";
foreach ($postresults as $postresult) {
if ($postresult->post_date != '0000-00-00 00:00:00') {
$url = get_permalink($postresult->ID);
$arc_title = $postresult->post_title;
if ($arc_title)
$text = wptexturize(strip_tags($arc_title));
else
$text = $postresult->ID;
$title_text = __('View this post','freephp') . ', "' . wp_specialchars($text, 1) . '"';
$output .= '- ' . mysql2date('m/d', $postresult->post_date) . ': ' . "$text";
$output .= ' (' . $postresult->comment_count . ')';
$output .= '
' . "\n";
}
}
}
$output .= '
' . "\n";
}
update_option('SHe_archives_'.$lastpost,$output);
}else{
$output = '
'. __('Sorry, no posts matched your criteria.','freephp') .'
' . "\n";
}
}
echo $output;
}
// copyright info
function copyright_info() {
global $wpdb;
$post_datetimes = $wpdb->get_results("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970");
if (!($post_datetimes)) {
$copyright = __('Copyright © ', 'freephp') . get_the_time('Y') . ' ' . get_option('blogname');
echo $copyright;
} else {
$firstpost_year = $post_datetimes[0]->firstyear;
$lastpost_year = $post_datetimes[0]->lastyear;
$copyright = __('Copyright © ', 'freephp') . $firstpost_year;
if($firstpost_year != $lastpost_year) {
$copyright .= '-'. $lastpost_year;
}
$copyright .= ' ';
$copyright .= get_option('blogname');
echo $copyright;
}
}
// image info
function image_info_SHe() {
printf( __('This entry was posted on %1$s at %2$s and is filed under ', 'freephp'), get_the_time(__('F jS, Y', 'freephp')),get_the_time(__('H:i', 'freephp'))); the_category(', ');
if (is_attachment()) :
$imgmeta = wp_get_attachment_metadata( $id );
printf(__('
Size: %1$d x %2$d .
Aperture: f/%3$f .
Camera: %4$s .
Times: %5$s .
Focal length: %6$f mm.
ISO: %7$s .
Shutter speed: %8$f seconds.
', 'freephp'), $imgmeta['width'], $imgmeta['height'], $imgmeta['image_meta']['aperture'], $imgmeta['image_meta']['camera'], date("Y-m-d H:i", $imgmeta['image_meta']['created_timestamp']), $imgmeta['image_meta']['focal_length'], $imgmeta['image_meta']['iso'], number_format($imgmeta['image_meta']['shutter_speed'],5));
endif;
edit_post_link(__('Edit this entry.', 'freephp'),'','');
}
// sidebar login
function login_widget_SHe() {
$NOWURL=$_SERVER["REQUEST_URI"];
$URL=get_option('home');
$URLL=get_option('siteurl');
$loginout=wp_logout_url($NOWURL);
if (!is_user_logged_in()) {
?>