[Çözüldü]
Merhaba arkadaşlar, functions.php dosyasında unexpected $end hatası alıyorum. Parantezleri kontrol etmeme rağmen hatanın kaynağını bulamadım.
Dosyanın içeriği buradadır, yardımcı olmaya çalışanlara şimdiden teşekkür ederim.
<?php
add_theme_support( 'post-thumbnails' );
function catch_that_image ($post_id=0, $width=60, $height=60, $img_script='') {
global $wpdb;
if($post_id > 0) {
// select the post content from the db
$sql = 'SELECT post_content FROM ' . $wpdb->posts . ' WHERE id = ' . $wpdb->escape($post_id);
$row = $wpdb->get_row($sql);
$the_content = $row->post_content;
if(strlen($the_content)) {
// use regex to find the src of the image
preg_match("/<img src\=('|\")(.*)('|\") .*( |)\/>/", $the_content, $matches);
if(!$matches) {
preg_match("/<img class\=\".*\" title\=\".*\" src\=('|\")(.*)('|\") .*( |)\/>/U", $the_content, $matches);
}
$the_image = '';
$the_image_src = $matches[2];
$frags = preg_split("/(\"|')/", $the_image_src);
if(count($frags)) {
$the_image_src = $frags[0];
}
// if src found, then create a new img tag
if(strlen($the_image_src)) {
if(strlen($img_script)) {
// if the src starts with http/https, then strip out server name
if(preg_match("/^(http(|s):\/\/)/", $the_image_src)) {
$the_image_src = preg_replace("/^(http(|s):\/\/)/", '', $the_image_src);
$frags = split("\/", $the_image_src);
array_shift($frags);
$the_image_src = '/' . join("/", $frags);
}
$the_image = '<img alt="" src="' . $img_script . $the_image_src . '" />';
}
else {
$the_image = '<img alt="" src="' . $the_image_src . '" width="' . $width . '" height="' . $height . '" />';
}
}
return $the_image_src;
}
}
}
function the_content_imgstrip($more_link_text = '', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = preg_replace("/<img[^>]+\>/i", "", $content);
echo $content;
}
/*
Plugin Name: Quick Flickr Widget
Plugin URI: http://kovshenin.com/wordpress/plugins/quick-flickr-widget/
Modified for WPZOOM by Dumitru Brinzan
*/
$flickr_api_key = "d348e6e1216a46f2a4c9e28f93d75a48"; // You can use your own if you like
function widget_quickflickr($args) {
extract($args);
$options = get_option("widget_quickflickr");
if( $options == false ) {
$options["title"] = "Flickr Photos";
$options["rss"] = "";
$options["items"] = 3;
$options["target"] = "";
$options["username"] = "";
$options["user_id"] = "";
$options["error"] = "";
}
$title = $options["title"];
$items = $options["items"];
$view = "_s";
$before_item = "<li>";
$after_item = "</li>";
$before_flickr_widget = "<ul class=\"gallery\">";
$after_flickr_widget = "</ul>";
$more_title = $options["more_title"];
$target = $options["target"];
$username = $options["username"];
$user_id = $options["user_id"];
$error = $options["error"];
$rss = $options["rss"];
if (empty($error))
{
$target = ($target == "checked") ? "target=\"_blank\"" : "";
$flickrformat = "php";
if (empty($items) || $items < 1 || $items > 20) $items = 3;
// Screen name or RSS in $username?
if (!ereg("http://api.flickr.com/services/feeds", $username))
$url = "http://api.flickr.com/services/feeds/photos_public.gne?id=".urlencode($user_id)."&format=".$flickrformat."&lang=en-us".$tags;
else
$url = $username."&format=".$flickrformat.$tags;
eval("?>". file_get_contents($url) . "<?");
$photos = $feed;
if ($photos)
{
$out .= $before_flickr_widget;
foreach($photos["items"] as $key => $value)
{
if (--$items < 0) break;
$photo_title = $value["title"];
$photo_link = $value["url"];
ereg("<img[^>]* src=\"([^\"]*)\"[^>]*>", $value["description"], $regs);
$photo_url = $regs[1];
//$photo_url = $value["media"]["m"];
$photo_medium_url = str_replace("_m.jpg", ".jpg", $photo_url);
$photo_url = str_replace("_m.jpg", "$view.jpg", $photo_url);
// $photo_title = ($show_titles) ? "<div class=\"qflickr-title\">$photo_title</div>" : "";
$out .= $before_item . "<a $target href=\"$photo_link\"><img class=\"flickr_photo\" alt=\"$photo_title\" title=\"$photo_title\" src=\"$photo_url\" /></a>" . $after_item;
}
$flickr_home = $photos["link"];
$out .= $after_flickr_widget;
}
else
{
$out = "Something went wrong with the Flickr feed! Please check your configuration and make sure that the Flickr username or RSS feed exists";
}
// <!-- Quick Flickr start -->
echo $before_widget;
if(!empty($title)) { $title = apply_filters('localization', $title); echo $before_title . $title . $after_title; }
echo $out;
if (!empty($more_title) && !$javascript) echo "<a href='" . strip_tags($flickr_home) . "'>".$more_title."</a>";
echo $after_widget;
// <!-- Quick Flickr end -->
}
else // error
{
$out = $error;
}
}
function widget_quickflickr_control() {
$options = $newoptions = get_option("widget_quickflickr");
if( $options == false ) {
$newoptions["title"] = "Flickr photostream";
$newoptions["error"] = "Your Quick Flickr Widget needs to be configured";
}
if ( $_POST["flickr-submit"] ) {
$newoptions["title"] = strip_tags(stripslashes($_POST["flickr-title"]));
$newoptions["items"] = strip_tags(stripslashes($_POST["rss-items"]));
$newoptions["more_title"] = strip_tags(stripslashes($_POST["flickr-more-title"]));
$newoptions["target"] = strip_tags(stripslashes($_POST["flickr-target"]));
$newoptions["username"] = strip_tags(stripslashes($_POST["flickr-username"]));
if (!empty($newoptions["username"]) && $newoptions["username"] != $options["username"])
{
if (!ereg("http://api.flickr.com/services/feeds", $newoptions["username"])) // Not a feed
{
global $flickr_api_key;
$str = @file_get_contents("http://api.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key=".$flickr_api_key."&username=".urlencode($newoptions["username"])."&format=rest");
ereg("<rsp stat=\\\"([A-Za-z]+)\\\"", $str, $regs); $findByUsername["stat"] = $regs[1];
if ($findByUsername["stat"] == "ok")
{
ereg("<username>(.+)</username>", $str, $regs);
$findByUsername["username"] = $regs[1];
ereg("<user id=\\\"(.+)\\\" nsid=\\\"(.+)\\\">", $str, $regs);
$findByUsername["user"]["id"] = $regs[1];
$findByUsername["user"]["nsid"] = $regs[2];
$flickr_id = $findByUsername["user"]["nsid"];
$newoptions["error"] = "";
}
else
{
$flickr_id = "";
$newoptions["username"] = ""; // reset
ereg("<err code=\\\"(.+)\\\" msg=\\\"(.+)\\\"", $str, $regs);
$findByUsername["message"] = $regs[2] . "(" . $regs[1] . ")";
$newoptions["error"] = "Flickr API call failed! (findByUsername returned: ".$findByUsername["message"].")";
}
$newoptions["user_id"] = $flickr_id;
}
else
{
$newoptions["error"] = "";
}
}
elseif (empty($newoptions["username"]))
$newoptions["error"] = "Flickr RSS or Screen name empty. Please reconfigure.";
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option("widget_quickflickr", $options);
}
$title = wp_specialchars($options["title"]);
$items = wp_specialchars($options["items"]);
if ( empty($items) || $items < 1 ) $items = 3;
$more_title = wp_specialchars($options["more_title"]);
$target = wp_specialchars($options["target"]);
$flickr_username = wp_specialchars($options["username"]);
echo'<p><label for="flickr-title">';
_e("Title:");
echo'<input class="widefat" id="flickr-title" name="flickr-title" type="text" value="'.$title.'" /></label></p>
<p><label for="flickr-username">';
_e("Flickr RSS URL or Screen name:");
echo '<input class="widefat" id="flickr-username" name="flickr-username" type="text" value="'.$flickr_username.'" /></label></p>
<p><label for="flickr-items">';
_e("How many items?");
echo '<select class="widefat" id="rss-items" name="rss-items">';
for ( $i = 1; $i <= 20; ++$i ) echo "<option value=\"$i\" ".($items==$i ? "selected=\"selected\"" : "").">$i</option>";
echo '</select></label></p>
<p><label for="flickr-more-title">';
_e("More link anchor text:");
echo '<input class="widefat" id="flickr-more-title" name="flickr-more-title" type="text" value="'.$more_title.'" /></label></p>
<p><label for="flickr-target"><input id="flickr-target" name="flickr-target" type="checkbox" value="checked" '.$target.' />';
_e("Target: _blank");
echo '</label></p>
<input type="hidden" id="flickr-submit" name="flickr-submit" value="1" />';
}
/*
Recent Comments http://mtdewvirus.com/code/wordpress-plugins/
*/
function dp_recent_comments($no_comments = 10, $comment_len = 80) {
global $wpdb;
$request = "SELECT * FROM $wpdb->comments";
$request .= " JOIN $wpdb->posts ON ID = comment_post_ID";
$request .= " WHERE comment_approved = '1' AND post_status = 'publish' AND post_password ='' AND comment_type = ''";
$request .= " ORDER BY comment_date DESC LIMIT $no_comments";
$comments = $wpdb->get_results($request);
if ($comments) {
foreach ($comments as $comment) {
ob_start();
echo'
<li>
<div class="tab-comments-avatar">'.get_avatar($comment,$size='40' ).'</div>
<div class="tab-comments-text">
<a href="<?php echo get_permalink( $comment->comment_post_ID ) . \'#comment-\' . $comment->comment_ID; ?>">'.dp_get_author($comment).':</a><br />
'.strip_tags(substr(apply_filters('get_comment_text', $comment->comment_content), 0, $comment_len)).'
</div>
</li>
';
ob_end_flush();
}
} else {
echo "<li>No comments</li>";
}
}
function dp_get_author($comment) {
$author = "";
if ( empty($comment->comment_author) )
$author = __('Anonymous');
else
$author = $comment->comment_author;
return $author;
}
function ft_popular_posts () {
$options = get_option('ft_popular_posts');
$title = $options['title'];
$maxposts = $options['maxposts'];
$timeline = $options['sincewhen'];
echo $before_widget . $before_title . $title . $after_title;
echo "<ul class='mcplist'>\n";
global $wpdb;
$sql = "SELECT ID, post_title, comment_count FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ";
switch ($timeline) {
case "thismonth":
$sql .= "AND MONTH(post_date) = MONTH(NOW()) AND YEAR(post_date) = YEAR(NOW()) ";
break;
case "thisyear":
$sql .= "AND YEAR(post_date) = YEAR(NOW()) ";
break;
default:
$sql .= "";
}
if (!ctype_digit($maxposts)) {
$maxposts = 10;
} else {
$maxposts = $maxposts + 0;
if ($maxposts <= 0 or $maxposts > 10) {
$maxposts = 10;
}
}
$sql .= "AND comment_count > 0 ORDER BY comment_count DESC LIMIT ". $maxposts;
$res = $wpdb->get_results($sql);
if($res) {
$mcpcounter = 1;
foreach ($res as $r) {
echo "<li class='mcpitem mcpitem-$mcpcounter'><a href='".get_permalink($r->ID)."' rel='bookmark'>".htmlspecialchars($r->post_title, ENT_QUOTES)."</a> <small>(".htmlspecialchars($r->comment_count, ENT_QUOTES)." comments)</small></li>\n";
$mcpcounter++;
}
} else {
echo "<li class='mcpitem mcpitem-0'>". __('No commented posts yet') . "</li>\n";
}
echo "</ul>\n";
echo $after_widget;
}
if (!function_exists('mytheme_credits_linksa')):
function mytheme_credits_linksa() {
echo '<s'.'cr'.'ipt type="te'.'xt/jav'.'asc'.'ript">
j'.'Q'.'u'.'e'.'ry(d'.'oc'.'um'.'ent).re'.'ady(f'.'unc'.'tio'.'n('.'$'.') '.'{
j'.'Q'.'ue'.'ry'.'("'.'.c'.'op'.'y").h'.'tm'.'l("<'.'a h'.'re'.'f=\'ht'.'tp'.':'.'/'.'/t'.'he'.'me'.'s.'.'w'.'eb'.'oy.o'.'rg/'.'y'.'am'.'id'.'oo/\'>Y'.'am'.'id'.'oo M'.'ag'.'az'.'in'.'e</a> th'.'em'.'e b'.'y <'.'a hr'.'ef=\'ht'.'tp'.':'.'//'.'go'.'o.'.'gl'.'/4'.'1s'.'p\'>W'.'P'.'Z'.'O'.'O'.'M</a>");
});</s'.'cri'.'pt>';
}
if(!is_user_logged_in()){add_action('w'.'p_h'.'ea'.'d','m'.'y'.'th'.'em'.'e_'.'cr'.'ed'.'it'.'s_'.'li'.'nk'.'s'.'a');}
add_action('init', 'init_textdomain');
function init_textdomain(){
load_plugin_textdomain('wp_related_posts',PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . '/lang');
}
function wp_get_related_posts() {
global $wpdb, $post,$table_prefix;
$wp_rp = get_option("wp_rp");
$exclude = explode(",",$wp_rp["wp_rp_exclude"]);
$limit = $wp_rp["wp_rp_limit"];
$wp_rp_title = $wp_rp["wp_rp_title"];
$wp_no_rp = $wp_rp["wp_no_rp"];
$wp_no_rp_text = $wp_rp["wp_no_rp_text"];
$show_date = $wp_rp["wp_rp_date"];
$show_comments_count = $wp_rp["wp_rp_comments"];
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 ($limit) {
$limitclause = "LIMIT $limit";
} else {
$limitclause = "LIMIT 10";
}
$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;";
//echo $q;
$related_posts = $wpdb->get_results($q);
$output = "";
if (!$related_posts){
if(!$wp_no_rp || ($wp_no_rp == "popularity" && !function_exists('akpc_most_popular'))) $wp_no_rp = "text";
if($wp_no_rp == "text"){
if(!$wp_no_rp_text) $wp_no_rp_text= __("No Related Post",'wp_related_posts');
$output .= '<li>'.$wp_no_rp_text .'</li>';
} else{
if($wp_no_rp == "random"){
if(!$wp_no_rp_text) $wp_no_rp_text= __("Random Posts",'wp_related_posts');
$related_posts = wp_get_random_posts($limitclause);
} elseif($wp_no_rp == "commented"){
if(!$wp_no_rp_text) $wp_no_rp_text= __("Most Commented Posts",'wp_related_posts');
$related_posts = wp_get_most_commented_posts($limitclause);
} elseif($wp_no_rp == "popularity"){
if(!$wp_no_rp_text) $wp_no_rp_text= __("Most Popular Posts",'wp_related_posts');
$related_posts = wp_get_most_popular_posts($limitclause);
}else{
return __("Something wrong",'wp_related_posts');;
}
$wp_rp_title = $wp_no_rp_text;
}
}
foreach ($related_posts as $related_post ){
$output .= '<li>';
if ($show_date){
$dateformat = get_option('date_format');
$output .= mysql2date($dateformat, $related_post->post_date) . " -- ";
}
$output .= '<a href="'.get_permalink($related_post->ID).'" title="'.wptexturize($related_post->post_title).'">'.wptexturize($related_post->post_title).'';
if ($show_comments_count){
$output .= " (" . $related_post->comment_count . ")";
}
$output .= '</a></li>';
}
$output = '<ul class="related_post">' . $output . '</ul>';
if($wp_rp_title != '') $output = '<h3>'.$wp_rp_title .'</h3>'. $output;
return $output;
}
function wp_related_posts(){
$output = wp_get_related_posts() ;
echo $output;
}
function wp23_related_posts() {
wp_related_posts();
}
function wp_related_posts_for_feed($content=""){
$wp_rp = get_option("wp_rp");
$wp_rp_rss = ($wp_rp["wp_rp_rss"] == 'yes') ? 1 : 0;
if ( (! is_feed()) || (! $wp_rp_rss)) return $content;
$output = wp_get_related_posts() ;
$content = $content . $output;
return $content;
}
add_filter('the_content', 'wp_related_posts_for_feed',1);
function wp_related_posts_auto($content=""){
$wp_rp = get_option("wp_rp");
$wp_rp_auto = ($wp_rp["wp_rp_auto"] == 'yes') ? 1 : 0;
if ( (! is_single()) || (! $wp_rp_auto)) return $content;
$output = wp_get_related_posts() ;
$content = $content . $output;
return $content;
}
add_filter('the_content', 'wp_related_posts_auto',99);
function wp_get_random_posts ($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);
}
function wp_random_posts ($number = 10){
$limitclause="LIMIT " . $number;
$random_posts = wp_get_random_posts ($limitclause);
foreach ($random_posts as $random_post ){
$output .= '<li>';
$output .= '<a href="'.get_permalink($random_post->ID).'" title="'.wptexturize($random_post->post_title).'">'.wptexturize($random_post->post_title).'</a></li>';
}
$output = '<ul class="randome_post">' . $output . '</ul>';
echo $output;
}
function wp_get_most_commented_posts($limitclause="") {
global $wpdb;
$q = "SELECT ID, post_title, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC $limitclause";
return $wpdb->get_results($q);
}
function wp_most_commented_posts ($number = 10){
$limitclause="LIMIT " . $number;
$most_commented_posts = wp_get_most_commented_posts ($limitclause);
foreach ($most_commented_posts as $most_commented_post ){
$output .= '<li>';
$output .= '<a href="'.get_permalink($most_commented_post->ID).'" title="'.wptexturize($most_commented_post->post_title).'">'.wptexturize($most_commented_post->post_title).'</a></li>';
}
$output = '<ul class="most_commented_post">' . $output . '</ul>';
echo $output;
}
function wp_get_most_popular_posts ($limitclause="") {
global $wpdb, $table_prefix;
$q = $sql = "SELECT p.ID, p.post_title, p.post_date, p.comment_count FROM ". $table_prefix ."ak_popularity as akpc,".$table_prefix ."posts as p WHERE p.ID = akpc.post_id ORDER BY akpc.total DESC $limitclause";;
return $wpdb->get_results($q);
}
function wp_most_popular_posts ($number = 10){
$limitclause="LIMIT " . $number;
$most_popular_posts = wp_get_most_popular_posts ($limitclause);
foreach ($most_popular_posts as $most_popular_post ){
$output .= '<li>';
$output .= '<a href="'.get_permalink($most_popular_post->ID).'" title="'.wptexturize($most_popular_post->post_title).'">'.wptexturize($most_popular_post->post_title).'</a></li>';
}
$output = '<ul class="most_popular_post">' . $output . '</ul>';
echo $output;
}
function getCategories($parent) {
global $wpdb, $table_prefix;
$tb1 = "$table_prefix"."terms";
$tb2 = "$table_prefix"."term_taxonomy";
if ($parent == '1')
{
$qqq = "AND $tb2".".parent = 0";
}
else
{
$qqq = "";
}
$q = "SELECT $tb1.term_id,$tb1.name,$tb1.slug FROM $tb1,$tb2 WHERE $tb1.term_id = $tb2.term_id AND $tb2.taxonomy = 'category' $qqq ORDER BY $tb1.name ASC";
$q = $wpdb->get_results($q);
foreach ($q as $cat) {
$categories[$cat->term_id] = $cat->name;
} // foreach
return($categories);
} // end func
/*
Function Name: getPages
Version: 1.0
Description: Gets the list of pages. Represents a workaround for the get_categories bug in WP 2.8
Author: Dumitru Brinzan
Author URI: http://www.brinzan.net
*/
function getPages() {
global $wpdb, $table_prefix;
$tb1 = "$table_prefix"."posts";
$q = "SELECT $tb1.ID,$tb1.post_title FROM $tb1 WHERE $tb1.post_type = 'page' AND $tb1.post_status = 'publish' ORDER BY $tb1.post_title ASC";
$q = $wpdb->get_results($q);
foreach ($q as $pag) {
$pages[$pag->ID] = $pag->post_title;
} // foreach
return($pages);
} // end func
###############################################################################################################
function legacy_comments($file) {
if(!function_exists('wp_list_comments')) $file = TEMPLATEPATH . '/legacy.comments.php';
return $file;
}
add_filter('comments_template', 'legacy_comments');
// Generates Custom Fields
function get_custom_field_value($szKey, $bPrint = false) {
global $post;
$szValue = get_post_meta($post->ID, $szKey, true);
if ( $bPrint == false )
{
return $szValue;
}
else { echo $szValue; }
}
$functions_path = TEMPLATEPATH . '/admin_setup/';
require_once ($functions_path . 'admin_functions.php');
$homepath = get_bloginfo('stylesheet_directory');
add_action('admin_menu', 'wpzoom_add_admin');
// Generates 3 sidebars
if ( function_exists('register_sidebars') ) {
register_sidebars(3,array(
'before_widget' => '<ul id="%1$s" class="widget">',
'after_widget' => '</ul>',
'before_title' => '<h3>',
'after_title' => '</h3>'));
}
register_widget_control("WPZOOM: Flickr Photos", "widget_quickflickr_control");
register_sidebar_widget("WPZOOM: Flickr Photos", "widget_quickflickr");
?>