Plugin Directory

Changeset 723666


Ignore:
Timestamp:
06/06/2013 07:45:22 PM (13 years ago)
Author:
amit
Message:

added v1.1

Location:
ig-twitter-cards/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ig-twitter-cards/trunk/class-ig-twitter-cards-admin.php

    r694019 r723666  
    4141        add_action( 'edit_user_profile_update', array( $this, 'save_user_twitter_field' ) );
    4242
    43         if( $this->_get_option('show_on_post_page') == 'yes' ) {
     43        if( $this->get_option('show_on_post_page') == 'yes' ) {
    4444            //add metabox on post pages in admin
    4545            add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
     
    143143?>
    144144        <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 ); ?>
    146147            <tr>
    147                 <td width="20%">
    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>
    149150                    <div style="display: inline-block; float: right;">@</div>
    150151                </td>
    151152                <td>
    152153                    <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>
    153155                </td>
    154156            </tr>
     
    164166            </tr>
    165167            <tr class="ig-tc-mb-player-ui">
    166                 <td><label for="ig_tc_player_url">Player URL <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>
    167169                <td>
    168170                    <input name="ig_tc_player_url" id="ig_tc_player_url" class="regular-text" value="<?php echo $mb_options['player_url']; ?>" />
    169171                </td>
    170172            </tr>
     173
    171174            <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>
    173189                <td>
    174190                    <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 player width in pixels</span>
     191                    <span class="description">Enter video width in pixels</span>
    176192                </td>
    177193            </tr>
    178194            <tr class="ig-tc-mb-player-ui">
    179                 <td><label for="ig_tc_player_height">Player Height <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>
    180196                <td>
    181197                    <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 player height in pixels</span>
     198                    <span class="description">Enter video height in pixels</span>
    183199                </td>
    184200            </tr>
    185201            <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>
    187203                <td>
    188204                    <input name="ig_tc_player_image" id="ig_tc_player_image" class="regular-text" value="<?php echo $mb_options['player_image']; ?>" />
     
    246262        }
    247263
     264        $data = apply_filters( 'ig_twitter_cards_post_mb_data', $data, $_POST, $post_id );
     265
    248266        //if any of player data is missing then make it summary card
    249267        if( empty( $data['player_url'] ) || empty( $data['player_width'] ) || empty( $data['player_height'] ) || empty( $data['player_image'] ) ) {
     
    313331                <tr>
    314332                    <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>
    316334                        <div style="display: inline-block; float: right;">@</div>
    317335                    </td>
    318336                    <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' ); ?>" />
    320338                    </td>
    321339                    <td><span class="description">Should be a valid Twitter username</span></td>
     
    324342                    <td><label for="fallback_image_url">Fallback Image URL</label></td>
    325343                    <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' ); ?>" />
    327345                    </td>
    328346                    <td>&nbsp</td>
     
    332350                    <td>
    333351                        <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>
    336354                        </select>
    337355                    </td>
     
    341359                    <td><label for="home_title">Title for Home/Archive Page</label> <span class="ig-tc-required">*</span></td>
    342360                    <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' ); ?>" />
    344362                    </td>
    345363                    <td><span class="description">No HTML in Title</span></td>
     
    348366                    <td><label for="home_desc">Description for Home/Archive Page</label> <span class="ig-tc-required">*</span></td>
    349367                    <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>
    351369                    </td>
    352370                    <td>&nbsp</td>
     
    498516
    499517        //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 );
    501519        //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 );
    503521
    504522        //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 );
    506524        //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 );
    508526        //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 );
    510528
    511529        //some vars in JS that we'll need
  • ig-twitter-cards/trunk/class-ig-twitter-cards-frontend.php

    r694019 r723666  
    152152                unset( $image );
    153153            } 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' ) );
    155155                if( empty( $this->_tags['twitter:image'] ) ) {
    156156                    unset( $this->_tags['twitter:image'] );
     
    160160            $this->_tags['twitter:url'] = get_home_url();
    161161
    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' ) );
    167167            if( empty( $this->_tags['twitter:image'] ) ) {
    168168                unset( $this->_tags['twitter:image'] );
     
    175175     */
    176176    private function _add_site_twitter() {
    177         $site_twitter = $this->_get_option( 'site_twitter_name' );
     177        $site_twitter = $this->get_option( 'site_twitter_name' );
    178178        if( empty( $site_twitter ) ) {
    179179            return;
  • ig-twitter-cards/trunk/class-ig-twitter-cards.php

    r694019 r723666  
    124124     * since direct access to the $_options var is not allowed
    125125     */
    126     protected function _get_option( $option_name ) {
     126    public function get_option( $option_name ) {
    127127        if( ! empty($option_name) && is_string($option_name) && isset( $this->_options[$option_name] ) ) {
    128128            return $this->_options[$option_name];
  • ig-twitter-cards/trunk/ig-twitter-cards.php

    r694019 r723666  
    44Plugin URI: http://blog.igeek.info/wp-plugins/ig-twitter-cards/
    55Description: This plugin enables Twitter Cards on a site. Check Twitter Cards documentation for details - https://dev.twitter.com/docs/cards
    6 Version: 1.0
     6Version: 1.1
    77Author: Amit Gupta
    88Author URI: http://blog.igeek.info/
    99License: GPL v2
    1010*/
     11
     12if( ! defined('IG_TWITTER_CARDS_VERSION') ) {
     13    define( 'IG_TWITTER_CARDS_VERSION', 1.1 );
     14}
    1115
    1216add_action( 'init', 'ig_twitter_cards_loader' );
  • ig-twitter-cards/trunk/js/admin.js

    r694019 r723666  
    1010jQuery(document).ready(function($) {
    1111
    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        }
    1427    }
    1528
     
    3346            },
    3447            function(data) {
    35                 setTimeout( hide_jq_msg, 2000 );
     48                setTimeout( ig_tc_admin.hide_jq_msg, 2000 );
    3649                if( ! data || ! data.nonce || ! data.msg ) {
    3750                    $.msg( 'replace', '<span class="ig-tc-error">Unable to save options</span>' );
     
    6477
    6578    /**
    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
    6786     */
    6887    $('#ig_tc_card_type').on( 'change', function(){
     
    7695    $('#ig_tc_card_type').trigger( 'change' );
    7796
     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
    78123});
    79124
  • ig-twitter-cards/trunk/readme.txt

    r694027 r723666  
    33Tags: twitter, twitter cards, meta, summary card, player card, cards, social, share, social sharing
    44Requires at least: 3.4
    5 Tested up to: 3.5.1
     5Tested up to: 3.6
    66Stable tag: trunk
    7 License: GPL v2
     7License: GNU GPL v2
    88
    99A plugin to enable Twitter Cards for your WordPress website.
     
    6464== ChangeLog ==
    6565
     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
    6672= v1.0 =
    6773
Note: See TracChangeset for help on using the changeset viewer.