function pgee_auto_generate($the_post = '') { global $wp_query; if (!is_object($the_post)) { return ''; } if ('' == trim($the_post->post_excerpt) && '' == trim($the_post->post_content)) { return ''; } pgee_txtdomain(); if (!empty($the_post->post_password)) { // if there's a password (from WP) if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $the_post->post_password) { // and it doesn't match the cookie return __('Protected post.', 'excerpt-editor'); } } $autoopt = get_option('pgee_auto_options', array()); $replaceopt = get_option('pgee_replace_options', array()); $excerpt = trim($the_post->post_excerpt); if (empty($excerpt)) { $generated = true; $pl = strlen($the_post->post_content); if ($pl <= $autoopt['pgee_length'] || $pl - 5 <= strlen($excerpt)) { $autoopt['more_link'] = 0; $excerpt = $the_post->post_content; } else { $excerpt = pgee_make($the_post->post_content); } } if ($wp_query->is_feed) { if (!empty($autoopt['more_link'])) { $more_text = sprintf(stripslashes($autoopt['more_text']), $the_post->post_title); $excerpt .= ' <a href="' . get_permalink($the_post->ID) . '">' . $more_text . '</a>'; } $excerpt = ent2ncr($excerpt); $excerpt = convert_chars($excerpt); return $excerpt; } $excerpt = wptexturize($excerpt); $excerpt = convert_smilies($excerpt); $excerpt = convert_chars($excerpt); $excerpt = wpautop($excerpt); $p = false; $excerpt = trim($excerpt); if (substr($excerpt, -4) == '</p>') { $excerpt = substr($excerpt, 0, -4); $p = true; } if ($generated && substr($excerpt, -1) != '>') { $excerpt .= '… '; } if (!empty($autoopt['more_link'])) { if (substr($excerpt, -1) != '>') { $tg = 'span'; } else { $tg = 'div'; } $more_text = sprintf(stripslashes($autoopt['more_text']), $the_post->post_title); $excerpt .= ' <' . $tg . ' class="pgee-read-more"><a href="' . get_permalink($the_post->ID) . '">' . $more_text . '</a>'; if (!empty($autoopt['more_link_cc']) && empty($replaceopt['no_cmnt_count'])) { if ($the_post->comment_count > 1) { $excerpt .= ' | <a href="' . get_permalink($the_post->ID) . '#comments">' . $the_post->comment_count . ' ' . __('Comments', 'excerpt-editor') . '</a>'; } if ($the_post->comment_count == 1) { $excerpt .= ' | <a href="' . get_permalink($the_post->ID) . '#comments"> 1 ' . __('Comment', 'excerpt-editor') . '</a>'; } } $excerpt .= '</' . $tg . '>'; } if ($p) { $excerpt .= '</p>'; } return $excerpt; }
$months = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE {$what} ORDER BY post_date ASC"); // from WP if (!empty($_POST['pgee_edit_gonext'])) { $id = (int) $_POST['pgee_edit_next']; } elseif (!empty($_POST['pgee_list'])) { $id = (int) $_POST['pgee_list']; } else { $id = $all[0]->ID; } if ($id) { $post = get_post($id, ARRAY_A); } if (trim($post['post_excerpt']) != '' && empty($_POST['pgee_edit_getcont'])) { $output = $post['post_excerpt']; } elseif ($post['post_content'] != '' || !empty($_POST['pgee_edit_getcont'])) { $output = pgee_make($post['post_content'], true); } else { $output = ''; } ?> <div class="wrap"> <h2><?php _e('Excerpt Editor', 'excerpt-editor'); if (count($all) > 1) { echo ' - ' . count($all) . ' '; if (!empty($opt['pgee_posts']) && empty($opt['pgee_pages'])) { _e('Posts selected.', 'excerpt-editor'); } elseif (empty($opt['pgee_posts']) && !empty($opt['pgee_pages'])) { _e('Pages selected.', 'excerpt-editor'); } else {