Ana sayfa » WordPress » Sharebar “Warning: Missing argument 2 for wpdb” hatası ve çözümü
WordPress

Sharebar “Warning: Missing argument 2 for wpdb” hatası ve çözümü

Merhaba,

Bugün blog sayfamı WordPress 3.5 sürümüne güncelledim. Bu güncellemeyle birlikte post sayfalarında aşağıdaki hatayı alıyordum:

[box type=”alert”]Warning: Missing argument 2 for wpdb::prepare(), called in /home/***/public_html/wp-content/plugins/sharebar/sharebar.php on line 112 and defined in /home/hitman/public_html/wp-includes/wp-db.php on line 990[/box] [box type=”alert”]Warning: Missing argument 2 for wpdb::prepare(), called in /home/***/public_html/wp-content/plugins/sharebar/sharebar.php on line 124 and defined in /home/hitman/public_html/wp-includes/wp-db.php on line 990[/box]

Ben de  sharebar.php  dosyasında aşağıdaki değişiklikleri yaptım.

112. ve 124. satırlar arasında

$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC")); $str .= "\n";<br>

olan satırı aşağıdaki şekilde düzenledim:

$results =$wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC", null)); $str .= "\n";<br>

ve 125. satırda olan

$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC")); $str .= "\n";<br>

bölümünü aşağıdaki şekilde düzenledim:

$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC", null)); $str .= "\n";<br>

Üşenenler için sharebar.php‘nin yeni hali aşağıdaki gibi:

<?php<br>/*<br>Plugin Name: Sharebar<br>Plugin URI: http://devgrow.com/sharebar-wordpress-plugin/<br>Description: Adds a dynamic bar with sharing icons (Facebook, Twitter, etc.) that changes based on browser size and page location. More info and demo at: <a href="http://devgrow.com/sharebar-wordpress-plugin/">Sharebar Plugin Home</a><br>Version: 1.2.4<br>Author: Monjurul Dolon<br>Author URI: http://mdolon.com/<br>License: GPL2<br>*/<br>/* Copyright 2010 Monjurul Dolon (email : [email protected])<br><br>This program is free software; you can redistribute it and/or modify<br> it under the terms of the GNU General Public License, version 2, as<br> published by the Free Software Foundation.<br><br>This program is distributed in the hope that it will be useful,<br> but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> GNU General Public License for more details.<br><br>You should have received a copy of the GNU General Public License<br> along with this program; if not, write to the Free Software<br> Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA<br>*/<br>$sharebar_options = array("auto_posts","auto_pages","horizontal","width","position","credit","leftoffset","rightoffset","swidth","twitter_username","sbg","sborder");<br><br>function sharebar_install(){<br> global $wpdb;<br> $table = $wpdb->prefix."sharebar";<br> if($wpdb->get_var("SHOW TABLES LIKE '$table'") != $table) {<br> $structure = "CREATE TABLE $table (<br> id mediumint(9) NOT NULL AUTO_INCREMENT,<br> position mediumint(9) NOT NULL,<br> enabled int(1) NOT NULL,<br> name VARCHAR(80) NOT NULL,<br> big text NOT NULL,<br> small text NULL,<br> UNIQUE KEY id (id)<br> );";<br> $wpdb->query($structure);<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('1','1','digg', '<script type=\"text/javascript\">(function() { var s = document.createElement(\'SCRIPT\'), s1 = document.getElementsByTagName(\'SCRIPT\')[0]; s.type = \'text/javascript\'; s.async = true; s.src = \'http://widgets.digg.com/buttons.js\'; s1.parentNode.insertBefore(s, s1); })(); </script><a class=\"DiggThisButton DiggMedium\"></a>', '<script type=\"text/javascript\">(function() { var s = document.createElement(\'SCRIPT\'), s1 = document.getElementsByTagName(\'SCRIPT\')[0]; s.type = \'text/javascript\'; s.async = true; s.src = \'http://widgets.digg.com/buttons.js\'; s1.parentNode.insertBefore(s, s1); })(); </script><a class=\"DiggThisButton DiggCompact\"></a>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('1','2','twitter', '<a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-count=\"vertical\" data-via=\"[twitter]\">Tweet</a><script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script>', '<a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-count=\"horizontal\" data-via=\"[twitter]\">Tweet</a><script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','3','facebook', '<iframe src=\"http://www.facebook.com/plugins/like.php?href=[url]&layout=box_count&show_faces=false&width=60&action=like&colorscheme=light&height=45\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:45px; height:60px;\" allowTransparency=\"true\"></iframe>', '<iframe src=\"http://www.facebook.com/plugins/like.php?href=[url]&layout=button_count&show_faces=false&width=85&action=like&colorscheme=light&height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:85px; height:21px;\" allowTransparency=\"true\"></iframe>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('1','4','sharethis', '<script type=\"text/javascript\" src=\"http://w.sharethis.com/button/buttons.js\"></script><span class=\"st_facebook_vcount\" displayText=\"Share\"></span><span class=\"st_email\" displayText=\"Email\"></span><span class=\"st_sharethis\" displayText=\"Share\"></span>', '<span class=\"st_facebook_hcount\" displayText=\"Share\"></span><span class=\"st_email\" displayText=\"Email\"></span><span class=\"st_sharethis\" displayText=\"Share\"></span>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','5','buzz', '<a title=\"Post to Google Buzz\" class=\"google-buzz-button\" href=\"http://www.google.com/buzz/post\" data-button-style=\"normal-count\"></a><script type=\"text/javascript\" src=\"http://www.google.com/buzz/api/button.js\"></script>', '<a title=\"Post to Google Buzz\" class=\"google-buzz-button\" href=\"http://www.google.com/buzz/post\" data-button-style=\"small-count\"></a><script type=\"text/javascript\" src=\"http://www.google.com/buzz/api/button.js\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','6','reddit', '<script type=\"text/javascript\" src=\"http://reddit.com/static/button/button2.js\"></script>', '<script type=\"text/javascript\" src=\"http://reddit.com/static/button/button1.js\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','7','dzone', '<script language=\"javascript\" src=\"http://widgets.dzone.com/links/widgets/zoneit.js\"></script>', '<script language=\"javascript\" src=\"http://widgets.dzone.com/links/widgets/zoneit.js\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','8','stumbleupon', '<script src=\"http://www.stumbleupon.com/hostedbadge.php?s=5\"></script>', '<script src=\"http://www.stumbleupon.com/hostedbadge.php?s=2\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','9','yahoo', '<script type=\"text/javascript\" src=\"http://d.yimg.com/ds/badge2.js\" badgetype=\"square\">[url]</script>', '<script type=\"text/javascript\" src=\"http://d.yimg.com/ds/badge2.js\" badgetype=\"small-votes\">[url]</script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','10','designfloat', '<script type=\"text/javascript\">submit_url = \'[url]\';</script><script type=\"text/javascript\" src=\"http://www.designfloat.com/evb2/button.php\"></script>', '<script type=\"text/javascript\">submit_url = \'[url]\';</script><script type=\"text/javascript\" src=\"http://www.designfloat.com/evb/button.php\"></script>')");<br> $wpdb->query("INSERT INTO $table(enabled, position,name, big, small)<br> VALUES('0','11','email', '<a href=\"mailto:?subject=[url]\" class=\"sharebar-button email\">Email</a>', '<a href=\"mailto:?subject=[url]\" class=\"sharebar-button email\">Email</a>')");<br> add_option('sharebar_auto_posts', 1);<br> add_option('sharebar_auto_pages', 1);<br> add_option('sharebar_horizontal', 1);<br> add_option('sharebar_credit', 0);<br> add_option('sharebar_minwidth','1000');<br> add_option('sharebar_position','left');<br> add_option('sharebar_leftoffset','20');<br> add_option('sharebar_rightoffset','10');<br> add_option('sharebar_swidth','65');<br> add_option('sharebar_twitter_username','ThinkDevGrow');<br> add_option('sharebar_bg','#ffffff');<br> add_option('sharebar_border','#cccccc');<br> }<br>}<br><br>function sharebar_reset(){<br> global $wpdb;<br> $table = $wpdb->prefix."sharebar";<br> $wpdb->query("DROP TABLE IF EXISTS $table");<br> sharebar_install();<br>}<br><br>function sharebar_menu(){<br> global $wpdb, $sharebar_options;<br> foreach($sharebar_options as $option) $$option = get_option('sharebar_'.$option);<br> include 'sharebar-admin.php';<br>}<br><br>function sharebar_settings($settings){<br> global $sharebar_options;<br> foreach($sharebar_options as $option) update_option('sharebar_'.$option,$settings[$option]);<br>}<br>function sharebar_auto($content){<br> if((get_option('sharebar_auto_posts') && is_single()) || (get_option('sharebar_auto_pages') && is_page())){ $str = sharebar(false); $str .= sharebar_horizontal(false); }<br> $newcontent = $str.$content;<br> return $newcontent;<br>}<br><br>function sharebar($print = true){<br> global $wpdb, $post;<br> $sharebar_hide = get_post_meta($post->ID, 'sharebar_hide', true);<br> $sbg = get_option('sharebar_sbg');<br> $sborder = get_option('sharebar_sborder');<br> if(empty($sharebar_hide)) {<br> $credit = get_option('sharebar_credit');<br> $str = '<ul id="sharebar" style="background:#'.$sbg.';border-color:#'.$sborder.';">';<br> /*$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC")); $str .= "\n";*/<br> $results =$wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC", null)); $str .= "\n";<br> foreach($results as $result){ $str .= '<li>'.sharebar_filter($result->big).'</li>'; }<br> if($credit) $str .= '<li class="credit"><a href="http://devgrow.com/sharebar" target="_blank">Sharebar</a></li>';<br> $str .= '</ul>';<br> if($print) echo $str; else return $str;<br> }<br>}<br><br>function sharebar_horizontal($print = true){<br> if(get_option('sharebar_horizontal')){<br> global $wpdb;<br> $str = '<ul id="sharebarx">';<br> /*$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC")); $str .= "\n";*/<br> $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC", null)); $str .= "\n";<br> foreach($results as $result) { $str .= '<li>'.sharebar_filter($result->small).'</li>'; }<br> $str .= '</ul>';<br> if($print) echo $str; else return $str;<br> }<br>}<br><br>function sharebar_button($name, $size = 'big'){<br> global $wpdb;<br> $item = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."sharebar WHERE name='$name'"));<br> if($size == 'big') echo stripslashes($item->big); else echo stripslashes($item->small);<br>}<br><br>function sharebar_update_button($id, $uptask){<br> global $wpdb;<br> if($uptask == 'enable')<br> $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."sharebar SET enabled='1' WHERE id='%d'", $id));<br> elseif($uptask == 'disable')<br> $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->prefix."sharebar SET enabled='0' WHERE id='%d'", $id));<br> elseif($uptask == 'delete')<br> $wpdb->query($wpdb->prepare("DELETE FROM ".$wpdb->prefix."sharebar WHERE id=%d LIMIT 1", $id));<br>}<br><br>function sharebar_init(){<br> if(!is_admin()) wp_enqueue_script('sharebar', get_bloginfo('wpurl').'/wp-content/plugins/sharebar/js/sharebar.js',array('jquery'));<br>}<br><br>function sharebar_header(){<br> global $sharebar_options;<br> foreach($sharebar_options as $option) $$option = get_option('sharebar_'.$option);<br> if(function_exists('wp_enqueue_script') && (is_single() || is_page())) {<br> echo '<link rel="stylesheet" href="'.get_bloginfo('wpurl').'/wp-content/plugins/sharebar/css/sharebar.css" type="text/css" media="screen" />';<br> if($horizontal) $hori = 'true'; else $hori = 'false';<br> if(!$width) $width = 1000;<br> echo "\n"; ?><script type="text/javascript">jQuery(document).ready(function($) { $('.sharebar').sharebar({horizontal:'<?php echo $hori; ?>',swidth:'<?php echo $swidth; ?>',minwidth:<?php echo $width; ?>,position:'<?php echo $position; ?>',leftOffset:<?php echo $leftoffset; ?>,rightOffset:<?php echo $rightoffset; ?>}); });</script><?php echo "\n"; ?><!-- Sharebar Plugin by Monjurul Dolon (http://mdolon.com/) - more info at: http://devgrow.com/sharebar-wordpress-plugin --><?php echo "\n"; ?><?php<br> }<br>}<br><br>function sharebar_filter($input){<br> global $post;<br> $code = array('[title]','[url]','[author]','[twitter]');<br> $values = array($post->post_title,get_permalink(),get_the_author(),get_option('sharebar_twitter_username'));<br> return str_replace($code,$values,$input);<br>}<br><br>function sharebar_admin_actions(){<br> if(current_user_can('manage_options')) add_options_page("Sharebar", "Sharebar", 1, "Sharebar", "sharebar_menu");<br>}<br><br>function sharebar_custom_boxes() {<br> add_meta_box( 'Sharebar', 'Sharebar Settings', 'sharebar_post_options', 'post', 'side', 'low');<br> add_meta_box( 'Sharebar', 'Sharebar Settings', 'sharebar_post_options', 'page', 'side', 'low');<br>}<br><br>function sharebar_post_options(){<br> global $post;<br> $sharebar_hide = get_post_meta($post->ID, 'sharebar_hide', true); ?><br> <p><br> <input name="sharebar_hide" id="sharebar_hide" type="checkbox" <?php checked(true, $sharebar_hide, true) ?> /><br> <label for="sharebar_hide">Disable Sharebar on this post?</label><br> </p><br> <?php<br>}<br><br>function sharebar_save_post_options($post_id) {<br> if (!isset($_POST['sharebar_hide']) || empty($_POST['sharebar_hide'])) {<br> delete_post_meta($post_id, 'sharebar_hide');<br> return;<br> }<br> $post = get_post($post_id);<br> if (!$post || $post->post_type == 'revision') return;<br> update_post_meta($post_id, 'sharebar_hide', true);<br>}<br><br>function sharebar_admin_head(){<br> echo '<br> <link rel="stylesheet" media="screen" type="text/css" href="'.get_bloginfo('wpurl').'/wp-content/plugins/sharebar/css/colorpicker.css" /><br> <script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/sharebar/js/colorpicker.js"></script><br> <script type="text/javascript"><br> jQuery(document).ready(function($) {<br> var ids = ["sbg","sborder"];<br> $.each(ids, function() {<br> var id = this;<br> $("#"+this).ColorPicker({<br> onSubmit: function(hsb, hex, rgb, el) {<br> $(el).val(hex);<br> $(el).ColorPickerHide();<br> },<br> onBeforeShow: function () {<br> $(this).ColorPickerSetColor(this.value);<br> },<br> onChange: function(hsb, hex, rgb, el) {<br> $("#"+id).val(hex);<br> }<br> });<br> });<br> });<br> </script>';<br>}<br><br>function cleanInput($input) {<br><br>$search = array(<br> '@<script[^>]*?>.*?</script>@si', // Strip out javascript<br> '@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags<br> '@<style[^>]*?>.*?</style>@siU', // Strip style tags properly<br> '@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments<br> );<br><br>$output = preg_replace($search, '', $input);<br> return $output;<br>}<br><br>function sanitize($input) {<br> if (is_array($input)) {<br> foreach($input as $var=>$val) {<br> $output[$var] = sanitize($val);<br> }<br> }<br> else {<br> if (get_magic_quotes_gpc()) {<br> $input = stripslashes($input);<br> }<br> $input = cleanInput($input);<br> $output = mysql_real_escape_string($input);<br> }<br> return $output;<br>}<br>add_filter('the_content', 'sharebar_auto');<br>add_action('init', 'sharebar_init');<br>add_action('wp_head', 'sharebar_header');<br>add_action('admin_head', 'sharebar_admin_head');<br>add_action('activate_sharebar/sharebar.php', 'sharebar_install');<br>add_action('admin_menu', 'sharebar_admin_actions');<br>add_action('add_meta_boxes', 'sharebar_custom_boxes');<br>add_action('draft_post', 'sharebar_save_post_options');<br>add_action('publish_post', 'sharebar_save_post_options');<br>add_action('save_post', 'sharebar_save_post_options');<br><br>?><br>

Yazar hakkında

Mehmet Tahta

Egenin gözbebeği İzmir'de yaşıyor, Dokuz Eylül Üniversitesi Yönetim Bilişim Sistemleri yüksek lisans öğrencisi. DMOZ, GNU, WordPress, jQuery ve Ubuntu projelerine katkıda bulunur; ayda yılda bir de bu blog sayfasını günceller.

Yorum ekle

Yorum eklemek ister misiniz?

Yazılar E-posta Adresinize Gelsin

Abone olmak için aşağıdaki forma e-posta adresinizi yazıp gönderilen onay e-postasını onaylamanız yeterlidir.

İletişim bilgileriniz hiçbir şekilde 3. parti uygulama ile paylaşılmamaktadır.