Denis & Liu Yang Version: 2.0 Author: Denis & LiuYang Author URI: http://17fav.com/ */ //=== Please DO NOT edit following lines unless you know actually what you do :P === define('BS_ALREADY_JQUERY',0); //if your template or plugin has been loaded jQuery without using wp_enquenue_script, change the value to 1 define('BS_ALREADY_JQUERY_DIMENSIONS',0); //if your template or plugin has been loaded jQuery-Dimensions plugin without using wp_enquenue_script, or with a name differ from jquery-dimensions change the value to 1 //===END JQUERY=== class WPBS { var $uid; var $popwin; var $insert2; var $insert2feed; var $insert2home; var $bs_server_url = 'http://17fav.com/'; var $imgbtn; var $iconbtn; var $postids; function WPBS() { $this->uid = get_option('bs_uid'); if ($this->uid === false) { // uid did not exists, we create it. $this->uid = $this->_generate_uid(); update_option('bs_uid',$this->uid); } if (false === get_option('bs_popwin')) { $this->popwin = false; } else { $this->popwin = get_option('bs_popwin'); } //initialize the button image $this->imgbtn = get_bloginfo('siteurl'). "/" .PLUGINDIR . "/" . dirname(plugin_basename (__FILE__))."/bookmark.gif"; $this->iconbtn = get_bloginfo('siteurl'). "/" .PLUGINDIR . "/" . dirname(plugin_basename (__FILE__))."/icons.gif"; //load jquery & dimensions plugin $this->_load_jquery_lib(); //initialize post ids $this->postids = array(); //actions add_action('wp_head',array(&$this,'bs_header')); add_action('wp_footer',array(&$this,'bs_footer')); add_action('admin_menu',array(&$this,'admin_page')); //auto add to single? if (false === get_option('bs_insert2')) { $this->insert2 = true; update_option('bs_insert2',$this->insert2); } else { $this->insert2 = get_option('bs_insert2'); } if (false === get_option('bs_insert2home')) { $this->insert2home = false; update_option('bs_insert2home',$this->insert2home); } else { $this->insert2home = get_option('bs_insert2home'); } if (false === get_option('bs_insert2feed')) { $this->insert2feed = true; update_option('bs_insert2feed',$this->insert2feed); } else { $this->insert2feed = get_option('bs_insert2feed'); } add_filter('the_content',array(&$this,'bs_add_content')); } function bs_string($feed_mode = false) { global $post; $fitems = array(); $fitems['blog_hash'] = $this->uid; $fitems['url'] = get_permalink($post->ID); $fitems['title'] = get_the_title($post->ID); if (has_excerpt($post->ID)) { $fitems['description'] = get_the_excerpt(); } else { $fitems['description'] = $this->_utrim(strip_tags($post->post_content),100); } $fitems['tags'] = ''; $tags = get_the_tags($post->ID); if (!is_wp_error($tags) && is_array($tags) && count($tags)) { $tagline = ''; foreach($tags as $tag) { if (strlen($tagline)) $tagline .= ","; $tagline .= $tag->name; } $fitems['tags'] = $tagline; } if (!$feed_mode) { $fitems['server'] = ''; $js = '"; $this->postids[] = $post->ID; $feed_str = ''; } else { $feed_str = ''; foreach ($fitems as $k=>$v) { $feed_str .= "$k=".urlencode($v)."&"; } $feed_str = "?$feed_str"; $feed_str = substr($feed_str,0,-1); } $btn = '17fav 收藏本文'; $btn = sprintf($btn,$feed_str,$post->ID,$this->imgbtn); return $btn.$js; } function bs_add_content($text) { if (is_home() && $this->insert2home) { return $text . $this->bs_string(false); } if(is_single() && $this->insert2) { return $text . $this->bs_string(false); } if(is_feed() && $this->insert2feed) { return $text . $this->bs_string(true); } return $text; } function bs_header() { $s = $this->_get_services(); $css = ''; echo $css; } function bs_footer() { $s = $this->_get_services(); $fav_pop = ''; $js = ''; echo $fav_pop; echo $js; } function uninstall() { } function admin_page() { add_options_page('收藏&分享','收藏&分享', 9, 'bookmark-share', array(&$this,'admin')); } function admin() { if (!empty($_POST['bs_submit'])) { update_option('bs_popwin',(bool)$_POST['bs_popwin']); update_option('bs_insert2',(bool)$_POST['bs_insert2']); update_option('bs_insert2home',(bool)$_POST['bs_insert2home']); update_option('bs_insert2feed',(bool)$_POST['bs_insert2feed']); } ?>

17fav.com - 收藏&分享

开启收藏页面 />在新窗口中 />在原页面
自动插入按钮 />自动插入按钮 />手动插入按钮
在首页文章列表中插入按钮 />是 />否
自动插入到 Feed />是 />否

=0; $i-=1){ $hex .= ' '.ord($r[$i]); $ch = ord($r[$i]); if (($ch & 128)==0) return substr($r,0,$i)."..."; if (($ch & 192)==192) return substr($r,0,$i)."..."; } return $r.$hex."..."; } } } function _load_jquery_lib() { if (!defined('BS_ALREADY_JQUERY') || !BS_ALREADY_JQUERY) { wp_enqueue_script('jquery-dimensions',get_bloginfo('siteurl'). "/" .PLUGINDIR . "/" . dirname(plugin_basename (__FILE__)).'/jquery.dimensions.js',array('jquery'),'1.1.2'); } else { if (!defined('BS_ALREADY_JQUERY_DIMENSIONS') || !BS_ALREADY_JQUERY_DIMENSIONS) { wp_enqueue_script('jquery-dimensions',get_bloginfo('siteurl'). "/" .PLUGINDIR . "/" . dirname(plugin_basename (__FILE__)).'/jquery.dimensions.js',array(),'1.1.2'); } } } } $wpbs = new WPBS; function bookmark_share() { global $wpbs; echo $wpbs->bs_string(false); } ?>