Changeset 1336467
- Timestamp:
- 01/26/2016 04:48:13 PM (10 years ago)
- Location:
- click-tweet/trunk
- Files:
-
- 4 edited
-
assets/css/click-and-tweet.css (modified) (4 diffs)
-
assets/js/click-and-tweet-admin.js (modified) (1 diff)
-
click-and-tweet.php (modified) (15 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
click-tweet/trunk/assets/css/click-and-tweet.css
r1332391 r1336467 83 83 width:100%; 84 84 max-width: 640px; 85 padding: 4% 4% 8%;85 padding: 4%; 86 86 margin: 4% auto; 87 87 background-color: #FFFFFF; … … 234 234 } 235 235 236 .click-and-tweet-card.center-top {237 padding-top: 10%;238 }239 240 236 .click-and-tweet-card.center-top .click-and-tweet-twitter-logo{ 241 position: absolute;242 top: 6%;243 237 left: 50%; 244 238 -webkit-transform: translateX(-50%); … … 246 240 } 247 241 248 .click-and-tweet-card.center-bottom {249 padding-bottom: 12%;250 }251 252 242 .click-and-tweet-card.center-bottom .click-and-tweet-twitter-logo{ 253 position: absolute;254 bottom: 20%;255 243 left: 50%; 256 244 -webkit-transform: translateX(-50%); … … 269 257 text-align: center; 270 258 font-size: 14px; 271 position: absolute;272 bottom: 1rem;273 left: 0;274 259 opacity: 0.75; 275 260 font-weight: 300; 276 } 261 padding: 6px; 262 } 263 264 /*Settings page*/ 265 .tweet-color-setting .iris-palette{ 266 display: none; 267 } 268 .tweet-color-setting .iris-palette:first-child{ 269 display: block; 270 } -
click-tweet/trunk/assets/js/click-and-tweet-admin.js
r1331546 r1336467 8 8 }); 9 9 10 $('.tweet-color-field').wpColorPicker(); 10 var myOptions = { 11 defaultColor: false, 12 hide: true, 13 palettes: ['#55acee','','','',''] 14 }; 15 16 $('.tweet-color-field').wpColorPicker(myOptions); 11 17 12 18 }); -
click-tweet/trunk/click-and-tweet.php
r1332391 r1336467 4 4 * Plugin URI: http://spacestud.io 5 5 * Description: Quote text in your WordPress posts for easy sharing on twitter. 6 * Version: 0. 4.16 * Version: 0.6 7 7 * Author: Space Studio 8 8 * Author URI: http://spacestud.io … … 57 57 * @var string 58 58 */ 59 protected $version = '0. 4.1';59 protected $version = '0.6'; 60 60 61 61 /** … … 97 97 98 98 /** 99 * Types of url Shorteners 100 * @var array 101 */ 102 protected $urlShorteners = [ 103 'none' => 'None', 104 'wp' => 'WordPress', 105 'google' => 'Google' 106 ]; 107 108 /** 109 * Google shortener api key 110 * @var string 111 */ 112 protected $clickAndTweetApiKey = 'AIzaSyBqZoC8D1Dif4NDQoN0GnVnAWFbwfXCT-Y'; 113 114 /** 115 * Types of Posts 116 * @var array 117 */ 118 protected $postTypes = ['post', 'page']; 119 120 /** 99 121 * admin pages 100 122 * @var array … … 122 144 123 145 $this->init(); 146 } 147 148 /** 149 * Allowed post types of plugin. 150 * @return array 151 */ 152 public function getPostTypes() 153 { 154 return apply_filters('click_and_tweet_post_types', $this->postTypes); 155 } 156 157 /** 158 * Checks to see if editor is allowed on post 159 * @return boolean 160 */ 161 public function isAllowed() 162 { 163 global $post; 164 165 if(in_array($post->post_type, $this->getPostTypes())){ 166 return true; 167 } 168 return false; 124 169 } 125 170 … … 143 188 add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']); 144 189 add_shortcode('clickandtweet', [$this, 'clickAndTweetShortCode']); 190 add_action('post_updated', [$this, 'checkPermalinkChanges'], 10, 3); 145 191 } 146 192 … … 154 200 return; 155 201 } 202 203 wp_enqueue_style( 204 $handle = 'click-and-tweet-css', 205 $src = plugins_url('/assets/css/click-and-tweet.css', __FILE__), 206 $deps = false, 207 $ver = $this->version, 208 $media = '' 209 ); 156 210 157 211 wp_enqueue_style( 'wp-color-picker' ); … … 338 392 339 393 add_settings_field( 340 $id = 'use_twitter_shortlink',341 $title = 'Url Shortlink',342 $callback = array($this, 'callbackTwitterShortlinkField'),343 $page = 'click_and_tweet_settings',344 $section = 'click_and_tweet_settings'345 );346 347 add_settings_field(348 394 $id = 'use_auto_truncate', 349 395 $title = 'Auto Truncate', … … 374 420 $callback = array($this, 'callbackTweetColorField'), 375 421 $page = 'click_and_tweet_settings', 376 $section = 'appearance_settings' 377 ); 422 $section = 'appearance_settings', 423 $args = ['class' => 'tweet-color-setting'] 424 ); 425 426 add_settings_field( 427 $id = 'url_shorteners', 428 $title = 'URL Shorteners', 429 $callback = array($this, 'callbackUrlShortenerField'), 430 $page = 'click_and_tweet_settings', 431 $section = 'url_shortener_section' 432 ); 433 378 434 379 435 add_settings_section( … … 398 454 ); 399 455 456 add_settings_section( 457 $id = 'url_shortener_section', 458 $title = 'URL Shorteners', 459 $callback = array($this, 'callbackUrlShortenerSection'), 460 $page = 'click_and_tweet_settings' 461 ); 400 462 } 401 463 … … 414 476 415 477 public function callbackAppearanceSection() 478 { 479 echo ''; 480 } 481 482 public function callbackUrlShortenerSection() 416 483 { 417 484 echo ''; … … 436 503 $html = "<input type='radio' name='click_and_tweet_settings[use_default_username]' value='1' $checked_yes /> On <input type='radio' name='click_and_tweet_settings[use_default_username]' value='0' $checked_no /> Off"; 437 504 $html .= "<p class='description'>Display your username in tweets by default?</p>"; 438 echo $html;439 }440 441 /*442 * function to turn the twitter shortlink on or off.443 */444 public function callbackTwitterShortlinkField()445 {446 $checked_yes = (isset($this->settings['use_twitter_shortlink']) && $this->settings['use_twitter_shortlink'] == 1) ? 'checked' : '';447 $checked_no = (!isset($this->settings['use_twitter_shortlink']) || $this->settings['use_twitter_shortlink'] == 0) ? 'checked' : '';448 $html = "<input type='radio' name='click_and_tweet_settings[use_twitter_shortlink]' value='1' $checked_yes /> On <input type='radio' name='click_and_tweet_settings[use_twitter_shortlink]' value='0' $checked_no /> Off";449 $html .= "<p class='description'>Display Shortlink Url instead of Permalink.</p>";450 505 echo $html; 451 506 } … … 508 563 509 564 } 565 566 /** 567 * callback function for the url shortener field. 568 */ 569 public function callbackUrlShortenerField() 570 { 571 $options = ''; 572 $selected = isset($this->settings['url_shorteners']) ? $this->settings['url_shorteners'] : ''; 573 574 foreach ($this->urlShorteners as $key => $value) { 575 $isSelected = ($key == $selected) ? ' selected' : ''; 576 $options .= "<option value=\"$key\"$isSelected>$value</option>"; 577 } 578 579 $selectMenu = "<select name=\"click_and_tweet_settings[url_shorteners]\">$options</select>"; 580 581 echo $selectMenu; 582 583 } 584 510 585 /** 511 586 * sanitizes the setting for the twitter handle and adds '@' to the beginning. … … 525 600 public function editorButton() 526 601 { 527 if ( get_user_option('rich_editing') == 'true') {602 if ($this->isAllowed() && get_user_option('rich_editing') == 'true') { 528 603 add_filter('mce_external_plugins', [$this, 'tinyMcePlugin']); 529 604 add_filter('mce_buttons', [$this, 'tinyMceButton']); … … 642 717 private function getUrl() 643 718 { 644 if((isset($this->settings['use_twitter_shortlink']) && $this->settings['use_twitter_shortlink'] == 1)) { 645 return $url = wp_get_shortlink(); 646 } 647 648 return $url = get_permalink();; 719 if(isset($this->settings['url_shorteners'])) { 720 721 if($this->settings['url_shorteners'] == 'wp') { 722 return $url = wp_get_shortlink(); 723 } 724 725 if($this->settings['url_shorteners'] == 'google') { 726 727 return $url = $this->getGoogleShortUrl(); 728 } 729 } 730 731 return $url = get_permalink(); 649 732 } 650 733 … … 765 848 $linkContent = "{$this->filterContent($content)}"; 766 849 850 switch($atts['position']) { 851 case 'left-center': 852 case 'left-top': 853 case 'left-bottom': 854 case 'right-center': 855 case 'right-top': 856 case 'right-bottom': 857 case 'center-top': 858 $tweet = "{$twitterLogo}<a {$linkAttributes}>{$linkContent}</a>"; 859 break; 860 default: 861 $tweet = "<a {$linkAttributes}>{$linkContent}</a>{$twitterLogo}"; 862 } 863 767 864 $content = "<div class=\"click-and-tweet-card$position\"> 768 {$twitterLogo}<a {$linkAttributes}>{$linkContent}</a>865 $tweet 769 866 <span class=\"call-to-action-text\">{$this->filterCallToAction()}</span> 770 867 </div>"; 771 868 772 869 return $content; 870 } 871 872 /* 873 * Function to get the url shortened using the google api. 874 * Adds post meta if it doesnt exist. 875 */ 876 public function getGoogleShortUrl() 877 { 878 global $post; 879 880 if(! $googleShortUrl = get_post_meta($post->ID, 'click_and_tweet_google_url', true)) { 881 882 $key = $this->clickAndTweetApiKey; 883 $url = 'https://www.googleapis.com/urlshortener/v1/url?key='.$key; 884 885 $response = wp_remote_post( $url, array( 886 'method' => 'POST', 887 'headers' => array('content-type' => 'application/json'), 888 'body' => json_encode(array('longUrl' => get_permalink())), 889 )); 890 891 $urlBody = json_decode($response['body'], true); 892 $googleShortUrl = $urlBody['id']; 893 894 add_post_meta($post->ID, 'click_and_tweet_google_url', $googleShortUrl); 895 896 } 897 898 return $googleShortUrl; 899 } 900 901 /** 902 * Checks to see if the post was updated to get new permalink. 903 */ 904 public function checkPermalinkChanges($post_ID, $postAfterUpdate, $postBeforeUpdate) 905 { 906 global $post; 907 if($postAfterUpdate->post_name != $postBeforeUpdate->post_name) { 908 delete_post_meta($post->ID, 'click_and_tweet_google_url'); 909 } 773 910 } 774 911 -
click-tweet/trunk/readme.txt
r1332391 r1336467 47 47 48 48 == Changelog == 49 = 0.6 = 50 * Added Url Shortener option using Google Api. 51 * Added Twitters primary color as an option to the color palette. 52 * Added an action hook to specify post types for developers. 53 * Styling Enhancements on mobile devices. 54 49 55 = 0.4.1 = 50 56 * Made some styling changes updates.
Note: See TracChangeset
for help on using the changeset viewer.