Changeset 723666
- Timestamp:
- 06/06/2013 07:45:22 PM (13 years ago)
- Location:
- ig-twitter-cards/trunk
- Files:
-
- 6 edited
-
class-ig-twitter-cards-admin.php (modified) (10 diffs)
-
class-ig-twitter-cards-frontend.php (modified) (3 diffs)
-
class-ig-twitter-cards.php (modified) (1 diff)
-
ig-twitter-cards.php (modified) (1 diff)
-
js/admin.js (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ig-twitter-cards/trunk/class-ig-twitter-cards-admin.php
r694019 r723666 41 41 add_action( 'edit_user_profile_update', array( $this, 'save_user_twitter_field' ) ); 42 42 43 if( $this-> _get_option('show_on_post_page') == 'yes' ) {43 if( $this->get_option('show_on_post_page') == 'yes' ) { 44 44 //add metabox on post pages in admin 45 45 add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); … … 143 143 ?> 144 144 <div id="<?php echo parent::plugin_id; ?>-mb-inner"> 145 <table width="95%" border="0"> 145 <table width="97%" border="0"> 146 <?php do_action( 'ig_twitter_cards_post_mb_ui', $post ); ?> 146 147 <tr> 147 <td width="2 0%">148 <label for="ig_tc_author_twitter">Author's Twitter <strong>:</strong></label>148 <td width="22%"> 149 <label for="ig_tc_author_twitter">Author's Twitter Handle <strong>:</strong></label> 149 150 <div style="display: inline-block; float: right;">@</div> 150 151 </td> 151 152 <td> 152 153 <input name="ig_tc_author_twitter" id="ig_tc_author_twitter" class="regular-text" value="<?php echo $mb_options['author_twitter']; ?>" /> 154 <span class="description">Does not override the Site Twitter Handle</span> 153 155 </td> 154 156 </tr> … … 164 166 </tr> 165 167 <tr class="ig-tc-mb-player-ui"> 166 <td><label for="ig_tc_player_url"> PlayerURL <strong>:</strong></label><span class="ig-tc-required">*</span></td>168 <td><label for="ig_tc_player_url">Video Source URL <strong>:</strong></label><span class="ig-tc-required">*</span></td> 167 169 <td> 168 170 <input name="ig_tc_player_url" id="ig_tc_player_url" class="regular-text" value="<?php echo $mb_options['player_url']; ?>" /> 169 171 </td> 170 172 </tr> 173 171 174 <tr class="ig-tc-mb-player-ui"> 172 <td><label for="ig_tc_player_width">Player Width <strong>:</strong></label><span class="ig-tc-required">*</span></td> 175 <td><label for="ig_tc_player_aspect_ratio">Video Aspect Ratio <strong>:</strong></label></td> 176 <td> 177 <select id="ig_tc_player_aspect_ratio" name="ig_tc_player_aspect_ratio"> 178 <option value="" selected></option> 179 <option value="4:3">4:3</option> 180 <option value="16:9">16:9</option> 181 <option value="16:10">16:10</option> 182 </select> 183 <span class="description">Select aspect ratio of video to auto calculate video width or height</span> 184 </td> 185 </tr> 186 187 <tr class="ig-tc-mb-player-ui"> 188 <td><label for="ig_tc_player_width">Video Width <strong>:</strong></label><span class="ig-tc-required">*</span></td> 173 189 <td> 174 190 <input name="ig_tc_player_width" id="ig_tc_player_width" class="regular-text" value="<?php echo $mb_options['player_width']; ?>" /> 175 <span class="description">Enter playerwidth in pixels</span>191 <span class="description">Enter video width in pixels</span> 176 192 </td> 177 193 </tr> 178 194 <tr class="ig-tc-mb-player-ui"> 179 <td><label for="ig_tc_player_height"> PlayerHeight <strong>:</strong></label><span class="ig-tc-required">*</span></td>195 <td><label for="ig_tc_player_height">Video Height <strong>:</strong></label><span class="ig-tc-required">*</span></td> 180 196 <td> 181 197 <input name="ig_tc_player_height" id="ig_tc_player_height" class="regular-text" value="<?php echo $mb_options['player_height']; ?>" /> 182 <span class="description">Enter playerheight in pixels</span>198 <span class="description">Enter video height in pixels</span> 183 199 </td> 184 200 </tr> 185 201 <tr class="ig-tc-mb-player-ui"> 186 <td><label for="ig_tc_player_image"> Player Image URL<strong>:</strong></label><span class="ig-tc-required">*</span></td>202 <td><label for="ig_tc_player_image">Image for Player Card <strong>:</strong></label><span class="ig-tc-required">*</span></td> 187 203 <td> 188 204 <input name="ig_tc_player_image" id="ig_tc_player_image" class="regular-text" value="<?php echo $mb_options['player_image']; ?>" /> … … 246 262 } 247 263 264 $data = apply_filters( 'ig_twitter_cards_post_mb_data', $data, $_POST, $post_id ); 265 248 266 //if any of player data is missing then make it summary card 249 267 if( empty( $data['player_url'] ) || empty( $data['player_width'] ) || empty( $data['player_height'] ) || empty( $data['player_image'] ) ) { … … 313 331 <tr> 314 332 <td width="28%"> 315 <label for="site_twitter_name">Site Twitter Name</label> <span class="ig-tc-required">*</span>333 <label for="site_twitter_name">Site Twitter Handle</label> <span class="ig-tc-required">*</span> 316 334 <div style="display: inline-block; float: right;">@</div> 317 335 </td> 318 336 <td width="35%"> 319 <input name="site_twitter_name" id="site_twitter_name" class="ig-tc-option regular-text" value="<?php echo $this-> _get_option( 'site_twitter_name' ); ?>" />337 <input name="site_twitter_name" id="site_twitter_name" class="ig-tc-option regular-text" value="<?php echo $this->get_option( 'site_twitter_name' ); ?>" /> 320 338 </td> 321 339 <td><span class="description">Should be a valid Twitter username</span></td> … … 324 342 <td><label for="fallback_image_url">Fallback Image URL</label></td> 325 343 <td> 326 <input name="fallback_image_url" id="fallback_image_url" class="ig-tc-option regular-text" value="<?php echo $this-> _get_option( 'fallback_image_url' ); ?>" />344 <input name="fallback_image_url" id="fallback_image_url" class="ig-tc-option regular-text" value="<?php echo $this->get_option( 'fallback_image_url' ); ?>" /> 327 345 </td> 328 346 <td> </td> … … 332 350 <td> 333 351 <select name="show_on_post_page" id="show_on_post_page" class="ig-tc-option"> 334 <option value="yes" <?php selected( $this-> _get_option( 'show_on_post_page' ), 'yes' ) ?>>YES</option>335 <option value="no" <?php selected( $this-> _get_option( 'show_on_post_page' ), 'no' ) ?>>NO</option>352 <option value="yes" <?php selected( $this->get_option( 'show_on_post_page' ), 'yes' ) ?>>YES</option> 353 <option value="no" <?php selected( $this->get_option( 'show_on_post_page' ), 'no' ) ?>>NO</option> 336 354 </select> 337 355 </td> … … 341 359 <td><label for="home_title">Title for Home/Archive Page</label> <span class="ig-tc-required">*</span></td> 342 360 <td> 343 <input name="home_title" id="home_title" class="ig-tc-option regular-text" value="<?php echo $this-> _get_option( 'home_title' ); ?>" />361 <input name="home_title" id="home_title" class="ig-tc-option regular-text" value="<?php echo $this->get_option( 'home_title' ); ?>" /> 344 362 </td> 345 363 <td><span class="description">No HTML in Title</span></td> … … 348 366 <td><label for="home_desc">Description for Home/Archive Page</label> <span class="ig-tc-required">*</span></td> 349 367 <td> 350 <textarea name="home_desc" id="home_desc" class="ig-tc-option large-text" rows="5" cols="55"><?php echo $this-> _get_option( 'home_desc' ); ?></textarea>368 <textarea name="home_desc" id="home_desc" class="ig-tc-option large-text" rows="5" cols="55"><?php echo $this->get_option( 'home_desc' ); ?></textarea> 351 369 </td> 352 370 <td> </td> … … 498 516 499 517 //load stylesheet 500 wp_enqueue_style( parent::plugin_id . '-admin', plugins_url( 'css/admin.css', __FILE__ ), false );518 wp_enqueue_style( parent::plugin_id . '-admin', plugins_url( 'css/admin.css', __FILE__ ), false, IG_TWITTER_CARDS_VERSION ); 501 519 //load jQuery::msg stylesheet 502 wp_enqueue_style( parent::plugin_id . '-jquery-msg', plugins_url( 'css/jquery.msg.css', __FILE__ ), false );520 wp_enqueue_style( parent::plugin_id . '-jquery-msg', plugins_url( 'css/jquery.msg.css', __FILE__ ), false, IG_TWITTER_CARDS_VERSION ); 503 521 504 522 //load jQuery::center script 505 wp_enqueue_script( parent::plugin_id . '-jquery-center', plugins_url( 'js/jquery.center.min.js', __FILE__ ), array( 'jquery' ) );523 wp_enqueue_script( parent::plugin_id . '-jquery-center', plugins_url( 'js/jquery.center.min.js', __FILE__ ), array( 'jquery' ), IG_TWITTER_CARDS_VERSION ); 506 524 //load jQuery::msg script 507 wp_enqueue_script( parent::plugin_id . '-jquery-msg', plugins_url( 'js/jquery.msg.min.js', __FILE__ ), array( parent::plugin_id . '-jquery-center' ) );525 wp_enqueue_script( parent::plugin_id . '-jquery-msg', plugins_url( 'js/jquery.msg.min.js', __FILE__ ), array( parent::plugin_id . '-jquery-center' ), IG_TWITTER_CARDS_VERSION ); 508 526 //load our script 509 wp_enqueue_script( parent::plugin_id . '-admin', plugins_url( 'js/admin.js', __FILE__ ), array( parent::plugin_id . '-jquery-msg' ) );527 wp_enqueue_script( parent::plugin_id . '-admin', plugins_url( 'js/admin.js', __FILE__ ), array( parent::plugin_id . '-jquery-msg' ), IG_TWITTER_CARDS_VERSION ); 510 528 511 529 //some vars in JS that we'll need -
ig-twitter-cards/trunk/class-ig-twitter-cards-frontend.php
r694019 r723666 152 152 unset( $image ); 153 153 } else { 154 $this->_tags['twitter:image'] = esc_url( $this-> _get_option( 'fallback_image_url' ) );154 $this->_tags['twitter:image'] = esc_url( $this->get_option( 'fallback_image_url' ) ); 155 155 if( empty( $this->_tags['twitter:image'] ) ) { 156 156 unset( $this->_tags['twitter:image'] ); … … 160 160 $this->_tags['twitter:url'] = get_home_url(); 161 161 162 $this->_tags['twitter:title'] = $this-> _get_option( 'home_title' );163 164 $this->_tags['twitter:description'] = $this-> _get_option( 'home_desc' );165 166 $this->_tags['twitter:image'] = esc_url( $this-> _get_option( 'fallback_image_url' ) );162 $this->_tags['twitter:title'] = $this->get_option( 'home_title' ); 163 164 $this->_tags['twitter:description'] = $this->get_option( 'home_desc' ); 165 166 $this->_tags['twitter:image'] = esc_url( $this->get_option( 'fallback_image_url' ) ); 167 167 if( empty( $this->_tags['twitter:image'] ) ) { 168 168 unset( $this->_tags['twitter:image'] ); … … 175 175 */ 176 176 private function _add_site_twitter() { 177 $site_twitter = $this-> _get_option( 'site_twitter_name' );177 $site_twitter = $this->get_option( 'site_twitter_name' ); 178 178 if( empty( $site_twitter ) ) { 179 179 return; -
ig-twitter-cards/trunk/class-ig-twitter-cards.php
r694019 r723666 124 124 * since direct access to the $_options var is not allowed 125 125 */ 126 p rotected function _get_option( $option_name ) {126 public function get_option( $option_name ) { 127 127 if( ! empty($option_name) && is_string($option_name) && isset( $this->_options[$option_name] ) ) { 128 128 return $this->_options[$option_name]; -
ig-twitter-cards/trunk/ig-twitter-cards.php
r694019 r723666 4 4 Plugin URI: http://blog.igeek.info/wp-plugins/ig-twitter-cards/ 5 5 Description: This plugin enables Twitter Cards on a site. Check Twitter Cards documentation for details - https://dev.twitter.com/docs/cards 6 Version: 1. 06 Version: 1.1 7 7 Author: Amit Gupta 8 8 Author URI: http://blog.igeek.info/ 9 9 License: GPL v2 10 10 */ 11 12 if( ! defined('IG_TWITTER_CARDS_VERSION') ) { 13 define( 'IG_TWITTER_CARDS_VERSION', 1.1 ); 14 } 11 15 12 16 add_action( 'init', 'ig_twitter_cards_loader' ); -
ig-twitter-cards/trunk/js/admin.js
r694019 r723666 10 10 jQuery(document).ready(function($) { 11 11 12 function hide_jq_msg() { 13 $.msg( 'unblock' ); 12 var ig_tc_admin = { 13 hide_jq_msg: function() { 14 $.msg( 'unblock' ); 15 }, 16 get_aspect_ratio: function() { 17 var aspect_ratio = $('#ig_tc_player_aspect_ratio').val(); 18 19 console.log( 'aspect_ratio = ' + aspect_ratio ); 20 21 if( ! aspect_ratio || aspect_ratio === null || aspect_ratio.indexOf( ':' ) <= 0 ) { 22 return false; 23 } 24 25 return aspect_ratio.split( ':' ); 26 } 14 27 } 15 28 … … 33 46 }, 34 47 function(data) { 35 setTimeout( hide_jq_msg, 2000 );48 setTimeout( ig_tc_admin.hide_jq_msg, 2000 ); 36 49 if( ! data || ! data.nonce || ! data.msg ) { 37 50 $.msg( 'replace', '<span class="ig-tc-error">Unable to save options</span>' ); … … 64 77 65 78 /** 66 * For the meta-box UI 79 ********************************** 80 ******** For Metabox UI ********** 81 ********************************** 82 */ 83 84 /** 85 * Show/Hide player card options based on selected card type 67 86 */ 68 87 $('#ig_tc_card_type').on( 'change', function(){ … … 76 95 $('#ig_tc_card_type').trigger( 'change' ); 77 96 97 /** 98 * Calculate height based specified width and aspect ratio selected 99 */ 100 $('#ig_tc_player_width').on( 'keyup', function(){ 101 var aspect_ratio = ig_tc_admin.get_aspect_ratio(); 102 103 if( aspect_ratio === false ) { 104 return; 105 } 106 107 $('#ig_tc_player_height').val( parseInt( ( parseInt( aspect_ratio[1] ) * parseInt( $('#ig_tc_player_width').val() ) ) / parseInt( aspect_ratio[0] ) ) ); 108 } ); 109 110 /** 111 * Calculate width based specified height and aspect ratio selected 112 */ 113 $('#ig_tc_player_height').on( 'keyup', function(){ 114 var aspect_ratio = ig_tc_admin.get_aspect_ratio(); 115 116 if( aspect_ratio === false ) { 117 return; 118 } 119 120 $('#ig_tc_player_width').val( parseInt( ( parseInt( aspect_ratio[0] ) * parseInt( $('#ig_tc_player_height').val() ) ) / parseInt( aspect_ratio[1] ) ) ); 121 } ); 122 78 123 }); 79 124 -
ig-twitter-cards/trunk/readme.txt
r694027 r723666 3 3 Tags: twitter, twitter cards, meta, summary card, player card, cards, social, share, social sharing 4 4 Requires at least: 3.4 5 Tested up to: 3. 5.15 Tested up to: 3.6 6 6 Stable tag: trunk 7 License: G PL v27 License: GNU GPL v2 8 8 9 9 A plugin to enable Twitter Cards for your WordPress website. … … 64 64 == ChangeLog == 65 65 66 = v1.1 = 67 68 * Updated labels for admin UI elements 69 * Added `ig_twitter_cards_post_mb_ui` & `ig_twitter_cards_post_mb_data` hooks to extend card options UI on post screen in wp-admin 70 * Added aspect ratio calculation for video in card options UI on post screen in wp-admin 71 66 72 = v1.0 = 67 73
Note: See TracChangeset
for help on using the changeset viewer.