Changeset 346599
- Timestamp:
- 02/16/2011 10:05:56 PM (15 years ago)
- Location:
- wp-tweet-button/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
wp-tweet-button.php (modified) (67 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-tweet-button/trunk/readme.txt
r315651 r346599 3 3 Tags: twitter, tweet button, retweet, tweet, autotweet, WP Tweet Button, advanced, tweeting, social media, button, SEO, share, shortener, awe.sm, b2l.me, bit.ly, cli.gs, sl.ly, snipr, su.pr, tinyurl, analytics, google analytics, campaign, campaign tracking, auto tweeting, auto posts 4 4 Requires at least: 2.7.2 5 Tested up to: 3.0. 15 Tested up to: 3.0.5 6 6 Stable tag: trunk 7 7 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6331357 … … 124 124 == Changelog == 125 125 126 = 2.0.3 = 127 * Transposh Translation Filter support. 128 * Added option to remove styles in RSS feeds. 129 * Improved compatibility with All in One SEO (thanks to monodistortion) 130 126 131 = 2.0.2 = 127 132 * Bugfix related to Auto-Tweeting and custom menus. -
wp-tweet-button/trunk/wp-tweet-button.php
r315652 r346599 2 2 /* 3 3 Plugin Name: WP Tweet Button 4 Version: 2.0. 24 Version: 2.0.3 5 5 Plugin URI: http://0xtc.com/plugins/wp-tweet-button 6 6 Description: The WordPress implementation of the official Twitter Tweet Button. … … 26 26 (string:html) 27 27 Use this hook to manipulate the generated button html code. 28 28 29 29 # wp_tweet_button_options 30 30 (Array) … … 34 34 (Array) 35 35 Use this hook together with the wp_tweet_button_options hook to add new shorteners to the configuration. 36 37 36 */ 38 37 … … 41 40 var $txtdom = 'wp-tweet-button'; 42 41 var $readyState = false; 42 var $excerptState = false; 43 43 var $postid; 44 /** 45 * The following are default settings for the plugin's configuration. 46 * Most of these settings can be accessed from the plugin's settings page. 47 */ 44 48 var $options = array( 45 49 'tw_hook_prio'=> '75', … … 78 82 'tw_style_c'=> '', 79 83 'tw_count'=> 'horizontal', 84 'tw_nostyle_feed'=> '', 80 85 'tw_force_manual'=> '', 81 86 'tw_display_single'=> '1', … … 91 96 'tw_use_rel_me'=> '', 92 97 'tw_add_rel_shortlink'=> '', 98 'tw_no_https_shortlinks'=> '1', 93 99 'tw_post_type_exclude'=>'', 94 100 'tw_config_ver'=>'', … … 101 107 'tw_script_infooter'=>'0' 102 108 ); 109 /** 110 * These are settings from the list above that have boolean values (true or false / 1 or 0) 111 * It is used for cleanup and validation actions. 112 */ 103 113 var $boolops = array( 104 114 'tw_debug', … … 120 130 'tw_url_samecount', 121 131 'tw_auto_tweet_pages', 122 'tw_auto_tweet_posts' 132 'tw_auto_tweet_posts', 133 'tw_no_https_shortlinks', 134 'tw_nostyle_feed' 123 135 ); 136 /** 137 * These are TinyArro.ws domains. 138 * Due to javascript ristrictions there is currently no method to automatically add 139 * TinyArro.ws domains to a tweet button dialog. 140 * Although TinyArro.ws is not supported we're declaring them here in the hope of one day 141 * being able to use them. 142 */ 124 143 var $tinyarrow_hosts = array( 125 144 'xn--ogi.ws'=>'➨.ws', … … 138 157 'ta.gd '=>'ta.gd' 139 158 ); 140 159 /** 160 * The following array is used to extract data about shorteners and 161 * their configuration. 162 */ 141 163 var $shortenerdata = array( 142 164 'none' => array( … … 256 278 ) 257 279 ); 280 281 /** 282 * Auto-tweet provider URL. 283 */ 284 258 285 var $wptbsrv = 'http://wptbsrv.0xtc.com/a/'; 259 286 287 /** 288 * This function is used during development to output debug data. 289 */ 260 290 function decho ($var_name,$thingie){ 261 291 if ($this->tw_get_option('tw_debug') != '1') return false; … … 269 299 } 270 300 301 /** 302 * This function isn't actually used but is left here for historical reasons. Yeah, that's it...historical reasons. 303 */ 271 304 function init() { 272 305 $this->tw_readoptions(); 273 306 } 274 307 308 /** 309 * Commits options to database. 310 */ 275 311 function tw_writeoptions(){ 276 312 update_option($this->optionsname, $this->options); 277 313 } 278 314 315 /** 316 * Validate and write settings. 317 */ 279 318 function tw_updateoptions() { 280 319 if( isset($_POST['tw_where']) ) { … … 296 335 } 297 336 337 /** 338 * Validate and read configuration into class. 339 */ 298 340 function tw_readoptions() { 299 341 $values = $this->options; … … 326 368 } 327 369 370 /** 371 * This function reads individual settings 372 */ 328 373 function tw_get_option($optionname){ 329 374 return $this->options[$optionname]; 330 375 } 331 376 377 /** 378 * This function sets individual settings 379 */ 332 380 function tw_set_option($optionname=null, $value=null){ 333 381 $this->options[$optionname]=$value; 334 382 } 335 383 384 /** 385 * Clear cached shortURLs if requested. 386 */ 336 387 function tw_flush_cached_shortlinks(){ 337 388 if ($_POST['tw_flush_cached_shortlinks']=='1'){ … … 346 397 } 347 398 399 /** 400 * Clear page cache if requested 401 */ 348 402 function tw_flush_cache(){ 349 403 $msg = ''; … … 360 414 } 361 415 416 /** 417 * Find the author's twitter name from various settings. 418 */ 362 419 function tw_get_twitter_name(){ 363 420 $viauser=false; … … 379 436 } 380 437 438 /** 439 * This function decides the format of the tweet text based on preferences and limitations. 440 */ 381 441 function tw_get_text($entitydecode=false){ 442 global $post; 382 443 if(is_int($this->postid)) { 383 444 $post = get_post($this->postid); 384 445 } else { 385 global $post; 386 } 446 $this->postid = $post->ID; 447 } 448 387 449 if (get_post_meta($post->ID, '_twitterrelated_custom_text', true)){ 388 450 if ($entitydecode){ … … 401 463 } 402 464 465 /** 466 * Applies formatting and transformations to texts. 467 */ 403 468 function tw_preptext($text){ 404 469 if(is_int($this->postid)) { … … 415 480 } 416 481 482 /** 483 * Adds relational tag "me" to header. 484 */ 417 485 function tw_add_rel_me(){ 418 486 echo '<link rel="me" href="http://twitter.com/'.$this->tw_get_twitter_name().'" />'; 419 487 } 488 489 /** 490 * Adds relational tag "shortlink" to header. 491 */ 420 492 function tw_add_rel_shortlink(){ 421 493 echo '<link rel="shortlink" href="'.$this->tw_get_short_url().'" />'; 422 494 } 423 495 496 /** 497 * Used once to hook up actions. 498 */ 499 function tw_hook_up_actions (){ 500 add_action('admin_menu', array(&$this, 'tw_options')); 501 add_action('admin_init', array(&$this, 'tw_init')); 502 add_action('admin_menu', array(&$this, 'tw_tweet_button_post_options_box')); 503 504 add_action('new_to_publish', array(&$this, 'tw_post_tweet_button_box_process')); 505 add_action('new_to_future', array(&$this, 'tw_post_tweet_button_box_process')); 506 add_action('new_to_draft', array(&$this, 'tw_post_tweet_button_box_process')); 507 add_action('future_to_draft', array(&$this, 'tw_post_tweet_button_box_process')); 508 add_action('future_to_future', array(&$this, 'tw_post_tweet_button_box_process')); 509 add_action('draft_to_future', array(&$this, 'tw_post_tweet_button_box_process')); 510 add_action('draft_to_draft', array(&$this, 'tw_post_tweet_button_box_process')); 511 add_action('draft_to_publish', array(&$this, 'tw_post_tweet_button_box_process')); 512 add_action('pending_to_publish', array(&$this, 'tw_post_tweet_button_box_process')); 513 514 add_action('publish_post', array(&$this, 'tw_post_tweet_button_box_process')); 515 add_action('publish_page', array(&$this, 'tw_post_tweet_button_box_process')); 516 517 add_action('publish_post', array(&$this, 'tw_send_auto_tweet'),100,1); 518 add_action('new_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 519 add_action('draft_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 520 add_action('pending_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 521 522 add_action('profile_update', array(&$this, 'tw_account_cleanup')); 523 } 524 525 /** 526 * The function that runs the show. 527 */ 424 528 function wpTweetButton(){ 425 529 if(is_int($this->postid)) { … … 427 531 } else { 428 532 global $post; 533 $this->postid = $post->ID; 429 534 } 430 535 $this->options = $this->tw_readoptions(); … … 433 538 add_action('future_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 434 539 if (is_admin()){ 435 add_action('admin_menu', array(&$this, 'tw_options')); 436 add_action('admin_init', array(&$this, 'tw_init')); 437 add_action('admin_menu', array(&$this, 'tw_tweet_button_post_options_box')); 438 add_action('new_to_publish', array(&$this, 'tw_post_tweet_button_box_process')); 439 add_action('publish_post', array(&$this, 'tw_post_tweet_button_box_process')); 440 441 add_action('publish_post', array(&$this, 'tw_send_auto_tweet'),100,1); 442 add_action('new_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 443 add_action('draft_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 444 add_action('pending_to_publish', array(&$this, 'tw_send_auto_tweet'),100,1); 445 446 add_action('profile_update', array(&$this, 'tw_account_cleanup')); 447 540 $this->tw_hook_up_actions(); 448 541 $uri=null; 449 542 if($this->tw_updateoptions()){ … … 463 556 $oauth = filter_input(INPUT_GET, 'oauth', FILTER_SANITIZE_STRING); 464 557 } else { 465 // for hosts that refuse to upgrade to php5 (This is less secure)466 558 $t1 = $_GET['t1']; 467 559 $t2 = $_GET['t2']; … … 500 592 add_filter('the_title', array(&$this,'tw_set_placement_ready'), 9); 501 593 add_filter('the_content', array(&$this, 'tw_update'),$this->tw_get_option('tw_hook_prio')); 502 add_filter('get_the_excerpt', array(&$this, 'tw_remove_filter'), 9); 594 add_filter('get_the_excerpt', array(&$this,'tw_enter_excerpt'), 1); 595 add_filter('get_the_excerpt', array(&$this,'tw_exit_excerpt'), 9999); 596 // add_filter('get_the_excerpt', array(&$this, 'tw_remove_filter'), 9); 597 // ---------------------- 503 598 if ($this->tw_get_option('tw_display_excerpt') == '1') add_filter('the_excerpt', array(&$this, 'tw_update'), $this->tw_get_option('tw_hook_prio')); 504 599 add_action('init', array(&$this, 'tw_add_script')); … … 512 607 } 513 608 609 /** 610 * This is called if a post is in excerpt mode. It sets $this->excerptState to 611 * true, so we can test for it later. 612 */ 613 function tw_enter_excerpt($the_excerpt) { 614 $this->excerptState = true; 615 return $the_excerpt; 616 } 617 618 function tw_exit_excerpt($the_excerpt) { 619 $this->excerptState = false; 620 return $the_excerpt; 621 } 622 623 /** 624 * This writes a twitter username to the user's settings. 625 */ 514 626 function tw_account_cleanup($user_id) { 515 627 $twitter_username = $_POST['twitter']; … … 523 635 524 636 637 /** 638 * This function sets the readyState when the title is displayed. 639 * This prevents that the tweet button isn't rendered in the header area. 640 */ 525 641 function tw_set_placement_ready($title){ 526 642 $this->readyState=true; … … 528 644 } 529 645 646 /** 647 * Deprecated function that removed content filter and added kit again at a later time 648 */ 530 649 function tw_remove_filter($content) { 531 650 remove_action('the_content', array(&$this, 'tw_update'),$this->tw_get_option('tw_hook_prio')); … … 534 653 } 535 654 655 /** 656 * Deprecated function that added content filter 657 */ 536 658 function tw_add_content_filter ($content){ 537 659 add_filter('the_content', array(&$this, 'tw_update'),$this->tw_get_option('tw_hook_prio')); … … 539 661 } 540 662 663 /** 664 * Function returns a list of hashtags (#one #two #three) based on post tags. 665 */ 541 666 function tw_get_hash_tags(){ 542 667 if(is_int($this->postid)) { … … 555 680 } 556 681 682 /** 683 * Function returns a list of category hash tags (#one #two #three) based on post categories. 684 */ 557 685 function tw_get_hash_cats(){ 558 686 if(is_int($this->postid)) { … … 571 699 } 572 700 701 /** 702 * Universal function for gettings the URL of a post. 703 */ 573 704 function tw_get_the_url($bwdata=false){ 574 705 $shortener = $this->tw_get_option('tw_url_shortener'); … … 581 712 } 582 713 714 /** 715 * Function returns the post's relationship with a twitter account. 716 */ 583 717 function tw_get_related_text($urenc=false){ 584 718 if(is_int($this->postid)) { … … 601 735 } 602 736 737 /** 738 * Function returns attributes for HTML5 based buttons 739 */ 603 740 function tw_build_options_data() { 604 741 if(is_int($this->postid)) { … … 606 743 } else { 607 744 global $post; 745 $this->postid = $post->ID; 608 746 } 609 747 $textprefix = null; … … 644 782 } 645 783 784 /** 785 * Function returns url parameters for legacy buttons 786 */ 646 787 function tw_build_options($bwdata=false) { 647 788 if(is_int($this->postid)) { … … 649 790 } else { 650 791 global $post; 792 $this->postid = $post->ID; 651 793 } 652 794 $textprefix =null; … … 674 816 } 675 817 818 /** 819 * Function is an HTTP tool for requesting HTML. 820 */ 676 821 function tw_nav_browse($url, $use_POST_method = false, $POST_data = null) { 677 822 if(function_exists('wp_remote_request') && function_exists('wp_remote_retrieve_response_code') && function_exists('wp_remote_retrieve_body') && $use_POST_method == 'GET') { … … 715 860 } 716 861 862 /** 863 * Function returns the "long" url for a post. 864 */ 717 865 // hook: wp_tweet_button_long_url 718 866 function tw_get_long_url($addtrack=false) { 867 global $my_transposh_plugin; 868 719 869 if(is_int($this->postid)) { 720 870 $post = get_post($this->postid); … … 729 879 $perms = trim(get_permalink($post->ID)); 730 880 } 731 if ($addtrack && $this->tw_get_option('tw_ga_code') && $this->tw_get_option('tw_enable_ga_code')==1) { 881 882 if (is_object($my_transposh_plugin)){ 883 if ($my_transposh_plugin->target_language) { 884 $perms= transposh_utils::rewrite_url_lang_param($perms, $my_transposh_plugin->home_url, $my_transposh_plugin->enable_permalinks_rewrite, $my_transposh_plugin->target_language, $my_transposh_plugin->edit_mode); 885 } 886 } 887 if ($addtrack && $this->tw_get_option('tw_ga_code') && $this->tw_get_option('tw_enable_ga_code')==1) { 732 888 if (strstr($perms,'?')){$prestr='&';} else {$prestr='?';} 733 889 $tmptxt= str_replace('?', '', $this->tw_get_option('tw_ga_code')); … … 739 895 $perms = $perms . $prestr . $tmptxt; 740 896 } 897 741 898 $perms = apply_filters('wp_tweet_button_long_url', $perms); 742 899 if (strstr($perms,admin_url())){return false;} … … 745 902 } 746 903 904 /** 905 * Function strips www. prefix from URLs. 906 */ 747 907 function tw_strip_www($content){ 748 908 $str = str_replace('http://www.','http://',$content); … … 751 911 } 752 912 913 /** 914 * Function returns the "short" url for a post (or not...). 915 */ 753 916 // hook: wp_tweet_button_url 754 917 function tw_get_short_url() { … … 757 920 } else { 758 921 global $post; 922 $this->postid = $post->ID; 759 923 } 760 924 $perms = $this->tw_get_long_url(true); 761 925 if ($perms == false) return false; 926 if (strstr($perms,'https://') && $this->tw_get_option('tw_no_https_shortlinks')=='1') return $perms; 927 if (strstr($perms,'preview=true')) return $perms; 762 928 $selectedshortener=$this->tw_get_option('tw_url_shortener'); 763 929 if ( 764 ($post && get_post_status($post->ID)!= 'publish') ||930 // ($post && $post->post_status != 'publish') || 765 931 ($selectedshortener == 'none')) { 766 932 return $perms; … … 808 974 $fetch_url = trim($this->tw_nav_browse($request_url, $method, $POST_data)); 809 975 } 810 if ( !empty( $fetch_url ) && ($fetch_url != $perms) && strstr($fetch_url,'http://') ) {976 if ( !empty( $fetch_url ) && ($fetch_url != $perms) && strstr($fetch_url,'http://') && (!strstr($perms,'preview=true'))) { 811 977 if (!update_post_meta($post->ID, '_activeshortener', $selectedshortener )) { 812 978 add_post_meta($post->ID, '_activeshortener', $selectedshortener); … … 819 985 } 820 986 } else { 821 $fetch_url = $perms; 987 // $fetch_url = $perms; 822 988 } 823 989 } else { … … 833 999 } 834 1000 1001 /** 1002 * Function generates a tweet button. 1003 * $bwdata can be used to return HTML5 (true) or not (false) 1004 */ 835 1005 // Hook : wp_tweet_button 836 1006 function tw_generate_button($bwdata=false) { … … 851 1021 if ($alignment=='center') $alignstr = ';float:none;margin:0 auto;text-align:center;'; 852 1022 } 853 $button = '<div class="tw_button" style="' . $this->tw_get_option('tw_style_c') . $alignstr . '">'; 854 $button .= '<a href="http://twitter.com/share'.$this->tw_build_options($bwdata).'" ' . $data . $relstr . ' class="twitter-share-button" target="_blank" style="width:55px;height:22px;background:transparent url(\''. WP_PLUGIN_URL.'/wp-tweet-button/tweetn.png\') no-repeat 0 0;text-align:left;text-indent:-9999px;display:block;">'.$tw_text.'</a>'; 1023 1024 if ($this->tw_get_option('tw_nostyle_feed') == ''){ 1025 $StyleStrDiv = ' style="' . $this->tw_get_option('tw_style_c') . $alignstr . '"'; 1026 $StyleStrBtn = ' style="width:55px;height:22px;background:transparent url(\''. WP_PLUGIN_URL.'/wp-tweet-button/tweetn.png\') no-repeat 0 0;text-align:left;text-indent:-9999px;display:block;"'; 1027 } else { 1028 $StyleStrDiv = ''; 1029 $StyleStrBtn = ''; 1030 } 1031 1032 $button = '<div class="tw_button"'.$StyleStrDiv.'>'; 1033 $button .= '<a href="http://twitter.com/share'.$this->tw_build_options($bwdata).'" class="twitter-share-button" target="_blank" ' . $data . $relstr . $StyleStrBtn.'>'.$tw_text.'</a>'; 855 1034 $button .= '</div>'; 856 1035 $button = apply_filters( 'wp_tweet_button', $button ); … … 858 1037 } 859 1038 1039 /** 1040 * Function places button in content. 1041 */ 860 1042 function tw_update($content) { 861 1043 if(is_int($this->postid)) { … … 863 1045 } else { 864 1046 global $post; 1047 $this->postid = $post->ID; 865 1048 } 866 1049 if ( 867 1050 (!$this->readyState) || 1051 ($this->tw_get_option('tw_display_excerpt') == '' && $this->excerptState) || 868 1052 (get_post_meta($post->ID, '_exclude_tweet_button', true)) || 869 1053 ($this->tw_get_option('tw_display_feed') == '' && is_feed()) || … … 912 1096 } 913 1097 1098 /** 1099 * Function returns a tweet button. 1100 */ 914 1101 function tweetbutton($post,$bwdata=false) { 915 1102 if (isset($post->ID)){ … … 925 1112 } 926 1113 927 // Put the script for the button in your head or foot 1114 /** 1115 * Function places twitter script in your header or footer 1116 */ 928 1117 function tw_add_script() { 929 1118 if ($this->tw_get_option('tw_url_shortener')=='awesm') { … … 938 1127 } 939 1128 1129 /** 1130 * Function outputs CSS for the settings page 1131 */ 940 1132 function tw_drawcss_admin(){ 941 1133 ?><style type="text/css"> … … 968 1160 } 969 1161 1162 /** 1163 * Function returns settings page 1164 */ 970 1165 function tw_options_page(){ 971 1166 if( function_exists( 'add_meta_box' )) { … … 993 1188 } 994 1189 1190 /** 1191 * Function returns a row on the settings page 1192 */ 995 1193 function tw_row_head($rh,$lfor=""){ 996 1194 return ' … … 1002 1200 } 1003 1201 1202 /** 1203 * Function outputs the settings page contents 1204 */ 1004 1205 function tw_options_box() { 1005 1206 $msg['w3'] = __('W3 Total Cache page cache has been cleared',$this->txtdom); … … 1335 1536 <input type="checkbox" value="1" name="tw_flush_cached_shortlinks" id="tw_flush_cached_shortlinks" /> 1336 1537 <label for="tw_flush_cached_shortlinks"><?php _e('Delete all previously saved shortlinks when I save.',$this->txtdom); ?></label><br /> 1337 1538 <input type="checkbox" value="1" <?php if ($this->tw_get_option('tw_no_https_shortlinks') == '1') echo 'checked="checked"'; ?> name="tw_no_https_shortlinks" id="tw_no_https_shortlinks" /> 1539 <label for="tw_no_https_shortlinks"><?php _e('Do not shrink HTTPS URLs.',$this->txtdom); ?></label><br /> 1338 1540 </td> 1339 1541 <td class="twhdata twhhlp" crowspan="<?php echo ($this->shortenerdata['tinyarrow']['enabled']!='false') ? '7' : '6';?>" valign="top" style="border-top:1px solid #fff;"> … … 1442 1644 <input type="checkbox" value="1" <?php if ($this->tw_get_option('tw_script_infooter') == '1') echo 'checked="checked"'; ?> name="tw_script_infooter" id="tw_script_infooter" /> 1443 1645 <label for="tw_script_infooter"><?php _e('Place script in footer.',$this->txtdom); ?></label><br /> 1646 <input type="checkbox" value="1" <?php if ($this->tw_get_option('tw_nostyle_feed') == '1') echo 'checked="checked"'; ?> name="tw_nostyle_feed" id="tw_nostyle_feed" /> 1647 <label for="tw_nostyle_feed"><?php _e('No styles in feeds.',$this->txtdom); ?></label><br /> 1444 1648 <?php 1445 1649 if (function_exists('w3tc_pgcache_flush')) { … … 1507 1711 } 1508 1712 1713 /** 1714 * Function saves per-post options 1715 */ 1509 1716 function tw_post_tweet_button_box_process($post_ID) { 1510 1717 $thepost = get_post($post_ID); 1718 $this->postid = $post_ID; 1511 1719 if (!empty($_POST)){ 1512 1720 if ($_POST['tw_do_not_send_auto_tweet'] == '1') { … … 1545 1753 } 1546 1754 1547 1755 /** 1756 * Function regulates and manages autotweeting 1757 */ 1548 1758 function tw_send_auto_tweet($post_id){ 1549 1759 global $post_type_object; … … 1558 1768 if ($thepost->post_type == 'revision' || ($thepost->post_status != 'publish' && $thepost->post_status != 'future') || $thepost->post_password != '' ) return false; 1559 1769 if ( 1560 (1561 ($this->tw_get_option('tw_auto_tweet_posts') == '1' && $post_type_object->hierarchical=='') ||1562 ($this->tw_get_option('tw_auto_tweet_pages') == '1' && $post_type_object->hierarchical=='1')1563 ) &&1770 ( 1771 ($this->tw_get_option('tw_auto_tweet_posts') == '1' && $post_type_object->hierarchical=='') || 1772 ($this->tw_get_option('tw_auto_tweet_pages') == '1' && $post_type_object->hierarchical=='1') 1773 ) && 1564 1774 $this->tw_get_option('tw_auto_tweet_token') != '' && 1565 1775 $this->tw_get_option('tw_auto_tweet_token_secret') != '' && … … 1587 1797 } 1588 1798 1799 /** 1800 * Function validates, edits and optimizes tweet text for an autotweet 1801 */ 1589 1802 function tw_validate_tweet($text, $url){ 1590 1803 $max = 134; … … 1657 1870 } 1658 1871 } 1659 1872 1873 /** 1874 * Function outputs the per-post settings dialog. 1875 */ 1660 1876 function tw_post_tweet_button_box() { 1661 1877 if(is_int($this->postid)) { … … 1718 1934 } 1719 1935 1936 /** 1937 * Function hooks per-post settings dialog 1938 */ 1720 1939 function tw_tweet_button_post_options_box() { 1721 1940 if ( version_compare(get_bloginfo('version'), '2.7', '>=')) { … … 1726 1945 } 1727 1946 1947 /** 1948 * Function registers settings record 1949 */ 1728 1950 function tw_init(){ 1729 1951 if(function_exists('register_setting')){ … … 1732 1954 } 1733 1955 1956 /** 1957 * Function cleans up returned twitter usernames 1958 */ 1734 1959 function tw_sanitize_username($username){ 1735 1960 $username = str_replace(array('http://','https://','twitter.com/','twitter.com','@'),'',$username); … … 1737 1962 } 1738 1963 1739 // Release the Kraken! 1964 /** 1965 * Function releases the Kraken. 1966 */ 1740 1967 function tw_activate(){ 1741 1968 add_option('wp_tweet_button',array()); … … 1743 1970 } 1744 1971 1972 /** 1973 * Function adds settings page to the menu. 1974 */ 1745 1975 function tw_options() { 1746 1976 add_options_page('WP Tweet Button', 'WP Tweet Button', 8, basename(__FILE__), array(&$this, 'tw_options_page')); 1747 1977 } 1748 1978 1979 /** 1980 * Function adds Twitter as a contact method in the Wordpress user settings. 1981 */ 1749 1982 function tw_add_twitter_contactmethod($contactmethods) { 1750 1983 $contactmethods['twitter'] = 'Twitter <span class="description">(username)</span>'; … … 1753 1986 } 1754 1987 1988 /** 1989 * Function manages manual tweetbutton() calls to generate a button. 1990 */ 1755 1991 function tweetbutton($thepost='',$bwdata=false,$type='d'){ 1756 1992 global $wpTweetButton, $post; … … 1763 1999 } 1764 2000 2001 /** 2002 * Other things...and stuff... 2003 */ 2004 /** 2005 * Class, exciting and new. Create one or even a few. Bugs, a coder's reward. Ruins flow and it comes back to you. Wordpress, soon will be making another run and Wordpress promises something for everyone.... 2006 */ 1765 2007 $wpTweetButton = new wpTweetButton(); 1766 2008 load_plugin_textdomain($wpTweetButton->txtdom,null,dirname( plugin_basename( __FILE__ ) ).'/lang/'); 1767 2009 register_activation_hook( __FILE__, array(&$wpTweetButton, 'tw_activate')); 2010 1768 2011 ?>
Note: See TracChangeset
for help on using the changeset viewer.