WordPress.org

Plugin Directory

Changeset 507914


Ignore:
Timestamp:
02/20/12 21:40:37 (2 years ago)
Author:
Jayjdk
Message:
  • HUGE code improvements
  • The ypf_show_video() function now takes an array of options instead of parameters
  • Both the shortcode and template tag now accepts more arguments (see FAQ)
  • You can no longer use the old embed code
  • Small bug fixes
Location:
youtube-profile-field/trunk
Files:
5 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • youtube-profile-field/trunk/admin.php

    r372150 r507914  
    44 
    55function ypf_add_options_page() { 
    6     add_options_page( 'Youtube Profile Field Options', 'Youtube Profile Field', 'manage_options', 'youtube-profile-field', 'ypf_plugin_options' ); 
     6    add_options_page( __( 'Youtube Profile Field Options', 'youtubeprofile' ), __( 'Youtube Profile Field', 'youtubeprofile' ), 'manage_options', 'youtube-profile-field', 'ypf_plugin_options' ); 
    77} 
    88 
     
    4343        __( 'Videos to show', 'youtubeprofile' ), 
    4444        'ypf_setting_input_number', 
    45         'ypf_options', 
    46         'ypf_options_main' 
    47     ); 
    48  
    49     add_settings_field( 
    50         'ypf_embed_code', 
    51         __( 'Use old embed code', 'youtubeprofile' ), 
    52         'ypf_setting_embed_code', 
    5345        'ypf_options', 
    5446        'ypf_options_main' 
     
    109101} 
    110102 
    111 // Embed code 
    112 function ypf_setting_embed_code() { 
    113     $options = get_option( 'ypf_options' ); ?> 
    114  
    115     <input id="ypf_embed_code" name="ypf_options[embed_code]" type="checkbox" value="1" <?php checked( '1', $options['embed_code'] ); ?> /> &nbsp;&nbsp;&nbsp; <?php 
    116  
    117     _e( 'There are two styles of embed codes that are available for YouTube videos. The new embed code begins with "&lt;iframe..." and supports both Flash and HTML5 video. The older style of embed code begins with "&lt;object..." and only support Flash playback.', 'youtubeprofile' ); 
    118 } 
    119  
    120103// Heading start field 
    121104function ypf_setting_input_heading_start() { 
     
    139122function ypf_setting_input_width() { 
    140123    $options = get_option( 'ypf_options' ); 
    141     $text_string = $options['width']; 
     124    $text_string = (isset( $options['width'] ) ) ? $options['width'] : '0'; 
    142125 
    143126    echo "<input id='ypf_width' name='ypf_options[width]' type='text' value='$text_string' /> "; 
     
    148131function ypf_setting_input_height() { 
    149132    $options = get_option( 'ypf_options' ); 
    150     $text_string = $options['height']; 
     133    $text_string = (isset( $options['height'] ) ) ? $options['height'] : '0'; 
    151134 
    152135    echo "<input id='ypf_height' name='ypf_options[height]' type='text' value='$text_string' /> "; 
     
    156139// Validate user input  
    157140function ypf_validate_options( $input ) { 
    158  
    159141    $input['count'] = intval( $input['count'] ); 
    160142    $input['width'] = intval( $input['width'] ); 
    161143    $input['height'] = intval( $input['height'] ); 
    162  
    163     $input['embed_code'] = ( $input['embed_code'] == 1 ? 1 : 0 ); 
    164144 
    165145    $input['headingStart'] = wp_kses_data( esc_html( $input['headingStart'] ) ); 
     
    172152function ypf_section_help() { 
    173153 
    174     echo '<h4>' . __( 'Recommended video sizes', 'youtubeprofile' ) . '</h4>'; 
     154    echo '<h4>' . __( 'Recommended video sizes:', 'youtubeprofile' ) . '</h4>'; 
    175155 
    176156    echo '<ul style="list-style: inside square;"> 
  • youtube-profile-field/trunk/index.php

    r372150 r507914  
    11<?php 
    2 /* 
     2/** 
    33 * Plugin Name: Youtube Profile Field 
    44 * Plugin URI: http://jayj.dk/template/plugins/youtube-profile-field/ 
     
    66 * Author: Jayjdk 
    77 * Author URI: http://jayj.dk 
    8  * Version: 2.1 
     8 * Version: 2.2 
    99 * License: GPLv2 or later 
    1010 */ 
    1111  
    1212/* 
    13 This program is free software; you can redistribute it and/or 
    14 modify it under the terms of the GNU General Public License 
    15 as published by the Free Software Foundation; either version 2 
    16 of the License, or (at your option) any later version. 
    17  
    18 This program is distributed in the hope that it will be useful, 
    19 but WITHOUT ANY WARRANTY; without even the implied warranty of 
    20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    21 GNU General Public License for more details. 
    22  
    23 You should have received a copy of the GNU General Public License 
    24 along with this program; if not, write to the Free Software 
    25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
     13    This program is free software; you can redistribute it and/or 
     14    modify it under the terms of the GNU General Public License 
     15    as published by the Free Software Foundation; either version 2 
     16    of the License, or (at your option) any later version. 
     17 
     18    This program is distributed in the hope that it will be useful, 
     19    but WITHOUT ANY WARRANTY; without even the implied warranty of 
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     21    GNU General Public License for more details. 
     22 
     23    You should have received a copy of the GNU General Public License 
     24    along with this program; if not, write to the Free Software 
     25    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
    2626*/ 
    2727 
    28 // Load translation 
    29 load_plugin_textdomain( 'youtubeprofile', false, 'youtube-profile-field/langs' );  
    30  
     28register_activation_hook( __FILE__, 'ypf_install' ); 
     29register_uninstall_hook( __FILE__, 'ypf_uninstall½23' ); 
     30 
     31/* Load the textdomain for translation */ 
     32load_plugin_textdomain( 'youtubeprofile', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 
     33 
     34/** 
     35 * Install function 
     36 * 
     37 * Set up default options on install 
     38 * 
     39 * @since 2.2 
     40 */ 
     41function ypf_install() { 
     42    $default_options = array( 
     43        'count'        => '1', 
     44        'headingStart' => '&lt;h4&gt;', 
     45        'headingEnd'   => '&lt;/h4&gt;', 
     46        'width'        => 0, 
     47        'height'       => 0 
     48    ); 
     49 
     50    update_option( 'ypf_options', $default_options ); 
     51} 
     52 
     53/** 
     54 * Uninstall function 
     55 * 
     56 * Remove the options from the database 
     57 * 
     58 * @since 1.0.0 
     59 */ 
     60function ypf_uninstall() { 
     61    if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) 
     62        exit(); 
     63 
     64    delete_option( 'ypf_options' ); 
     65 
     66} 
     67 
     68/** 
     69 * Load plugin settings page 
     70 */ 
    3171if ( is_admin() ) 
    3272    include_once dirname( __FILE__ ) . '/admin.php'; 
    3373 
    34  
    3574/* 
    3675 * Get the video 
    3776 * 
    38  * @param   array   $options   
    39  * @param   int     $userid     ID of the user where the videos should be retrieved from 
     77 * @param   array   $options    Array with arguments. Can contain count, user_id, width, height, headingStart, headingEnd 
    4078 * @since 2.1 
    4179 */ 
    42 function ypf_get_video( $options, $userid ) { 
    43  
    44     // Get options 
    45     $count = ( $options[0] ) ? $options[0] : $options['count']; 
    46      
    47     $heading_start = $options['headingStart']; 
    48     $heading_end = $options['headingEnd']; 
    49  
    50     // Get the width from the Media settings or the theme width 
     80function ypf_get_video( $options ) { 
     81 
     82    /** 
     83     * Get width and height 
     84     */ 
     85 
     86    // Get default width from the media options or the theme $content_width 
    5187    $default_width = ( get_option( 'embed_size_w' ) ) ? get_option( 'embed_size_w' ) : (int) $GLOBALS['content_width']; 
    5288 
    53     $width = ( $options['width'] ) ? $options['width'] : $default_width; 
    54     $height = ( $options['height'] ) ? $options['height'] : get_option( 'embed_size_h' ); 
    55      
     89    // If the width isn't set in the options or arguments, return the default width 
     90    if ( $options['width'] == 0 ) 
     91        $options['width'] = $default_width; 
     92 
     93    // Set height if empty 
     94    if ( $options['height'] == 0 ) 
     95        $options['height'] = round($options['width'] / (16/9)); // 16:9 aspect ratio 
     96 
    5697    // Get the username 
    57     $username = get_the_author_meta( 'youtube', $userid );  
     98    $username = get_the_author_meta( 'youtube', $options['user_id'] );  
    5899 
    59100    // Get the videos 
    60101    include_once( ABSPATH . WPINC . '/feed.php' ); 
    61102 
    62     $rss = fetch_feed( "http://gdata.youtube.com/feeds/base/users/$username/uploads" ); 
     103    $rss = fetch_feed( "http://gdata.youtube.com/feeds/base/users/{$username}/uploads" ); 
     104 
     105    // Is count set to 0? (why would some one do that??) 
     106    if ( $options['count'] === 0 ) 
     107        return; 
     108 
     109    // Is count set to all? 
     110    if ( $options['count'] == 'all' ) 
     111        $options['count'] = '0'; // 0 will return all items in the RSS feed 
    63112 
    64113    // Checks that the object is created correctly  
    65114    if ( ! is_wp_error( $rss ) ) : 
    66         $maxitems = $rss->get_item_quantity( intval( $count ) ); 
     115        $maxitems  = $rss->get_item_quantity( intval( $options['count'] ) ); 
    67116        $rss_items = $rss->get_items( 0, $maxitems ); 
    68117    endif; 
     
    74123        foreach ( $rss_items as $item ) :  
    75124 
    76             // Get video ID - why don't Youtube give us this? 
     125            // Get video link 
    77126            $url = $item->get_permalink(); 
    78127 
    79             if ( preg_match('![?&]{1}v=([^&]+)!', $url . '&', $m )) 
    80                 $id = $m[1]; 
    81  
    82             // If using the old embed code 
    83             if ( $options['embed_code'] == 1 ) { ?> 
    84  
    85                 <div class="youtube-video"> 
    86                     <?php if ( ! empty( $heading_start ) ) { ?> 
    87                         <?php echo html_entity_decode( $heading_start ); ?> 
    88                             <a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a> 
    89                         <?php echo html_entity_decode( $heading_end ); ?> 
    90                     <?php } ?> 
    91  
    92                     <object type="application/x-shockwave-flash" width="<?php echo intval( $width ); ?>" height="<?php echo intval( $height ); ?>" data="http://www.youtube.com/v/<?php echo esc_attr( $id ); ?>&amp;fs=1"> 
    93                         <param name="movie" value="http://www.youtube.com/v/<?php echo esc_attr( $id ); ?>&amp;fs=1" /> 
    94                         <param name="allowFullScreen" value="true" /> 
    95                         <param name="wmode" value="transparent" /> 
    96                     </object> 
    97                 </div> 
    98  
    99             <?php 
    100             } else { ?> 
    101  
    102                 <div class="youtube-video"> 
    103                     <?php if ( ! empty( $heading_start ) ) { ?> 
    104                         <?php echo html_entity_decode( $heading_start ); ?> 
    105                             <a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a> 
    106                         <?php echo html_entity_decode( $heading_end ); ?> 
    107                     <?php } ?> 
    108  
    109                     <iframe title="<?php echo esc_attr( $item->get_title() ); ?>" width="<?php echo intval( $width ); ?>" height="<?php echo intval( $height ); ?>" src="http://www.youtube.com/embed/<?php echo esc_attr( $id ); ?>?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe> 
    110                 </div> 
    111  
    112             <?php 
    113             } 
    114  
     128            // Get title 
     129            $title = $item->get_title(); 
     130 
     131            // Get video ID 
     132            if ( preg_match('![?&]{1}v=([^&]+)!', $url . '&', $m ) ) 
     133                $id = $m[1]; 
     134            else 
     135                return __( 'Error: No video ID found.', 'youtubeprofile' ); 
     136 
     137    ?> 
     138            <div class="youtube-video"> 
     139                <?php 
     140                    // Get the headingStart option 
     141                    if ( ! empty( $options['headingStart'] ) ) 
     142                        echo html_entity_decode( $options['headingStart'] ); 
     143                ?> 
     144 
     145                    <a href="<?php echo esc_url( $url ); ?>"><?php echo $title; ?></a> 
     146 
     147                <?php 
     148                    // Get the headingEnd option 
     149                    if ( ! empty( $options['headingEnd'] ) ) 
     150                        echo html_entity_decode( $options['headingEnd'] ); 
     151                ?> 
     152 
     153                <iframe title="<?php echo esc_attr( $title ); ?>" width="<?php echo intval( $options['width'] ); ?>" height="<?php echo intval( $options['height'] ); ?>" src="http://www.youtube.com/embed/<?php echo esc_attr( $id ); ?>?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe> 
     154 
     155            </div><?php 
     156     
    115157        endforeach; 
    116158 
     
    125167 * Show the video 
    126168 * 
    127  * @param   int     $count  Number of videos 
    128  * @param   int     $userid     ID of the user where the videos should be retrieved from 
    129  * @since 2.0.2 
    130  */ 
    131 function ypf_show_video( $count = '', $userid = 1 ) { 
    132  
    133     /* Get options */ 
    134     $default_options = get_option( 'ypf_options' ); 
    135     $options = wp_parse_args( func_get_args(), $default_options ); 
    136  
    137     return ypf_get_video( $options, $userid ); 
     169 * @param   array   $args   Array with arguments. Can contain count, user_id, width, height, headingStart, headingEnd  
     170 * @since   2.0.2 
     171 */ 
     172function ypf_show_video( $args = array() ) { 
     173 
     174    // Backward compatibility for earlier plugin versions than 2.2 
     175    if ( ! is_array( $args ) ) { 
     176        $args = array(); 
     177        $numargs = func_num_args(); 
     178 
     179        $args['count'] = func_get_arg(0); 
     180 
     181        if ( $numargs >= 2 ) 
     182            $args['user_id'] = func_get_arg(1); 
     183    } 
     184 
     185    // Get default options 
     186    $defaults = get_option( 'ypf_options' ); 
     187    $defaults['user_id'] = get_the_author_meta( 'ID' ); 
     188 
     189    // Merge the parameters and default options 
     190    $options = wp_parse_args( $args, $defaults ); 
     191 
     192    return ypf_get_video( $options ); 
    138193} 
    139194 
     
    141196 * The [youtube-user] shortcode 
    142197 * 
     198 * Parameter you can use: count/display, user/user_id, ID, width, height, headingStart, headingEnd  
     199 * 
    143200 * @since 1.0 
    144201 */ 
    145 function ypf_youtube_user_shortcode( $atts ) { 
    146  
    147     extract( shortcode_atts(array( 
    148         'display' => '1', 
    149         'id' => '', 
    150     ), $atts) ); 
    151  
    152     // Get options 
    153     $options = get_option( 'ypf_options' ); 
    154     $embed = $options['embed_code']; 
    155      
    156     $default_width = ( get_option( 'embed_size_w' ) ) ? get_option( 'embed_size_w' ) : (int) $GLOBALS['content_width']; 
    157  
    158     $width = ( $options['width'] ) ? $options['width'] : $default_width; 
    159     $height = ( $options['height'] ) ? $options['height'] : get_option( 'embed_size_h' ); 
    160  
    161     if ( $id ) :  
    162      
    163         ob_start(); 
    164          
    165         // Use old object embed code 
    166         if ( $options['embed_code'] == 1 ) { ?> 
    167  
    168             <div class="youtube-video"> 
    169                 <object type="application/x-shockwave-flash" width="<?php echo intval( $width ); ?>" height="<?php echo intval( $height ); ?>" data="http://www.youtube.com/v/<?php echo esc_attr( $id ); ?>&amp;fs=1"> 
    170                     <param name="movie" value="http://www.youtube.com/v/<?php echo esc_attr( $id ); ?>&amp;fs=1" /> 
    171                     <param name="allowFullScreen" value="true" /> 
    172                     <param name="wmode" value="transparent" /> 
    173                 </object> 
    174             </div> 
    175  
    176         <?php 
    177         } else { ?> 
    178  
    179             <div class="youtube-video"> 
    180                 <iframe width="<?php echo intval( $width ); ?>" height="<?php echo intval( $height ); ?>" src="http://www.youtube.com/embed/<?php echo esc_attr( $id ); ?>?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe> 
    181             </div> 
    182  
    183         <?php 
    184         } 
    185  
     202function ypf_youtube_user_shortcode( $args ) { 
     203 
     204    // Get default options 
     205    $defaults = get_option( 'ypf_options' ); 
     206 
     207    $args = shortcode_atts(array( 
     208        'display' => $defaults['count'], // count can be used instead 
     209        'id'      => '', // If you just want to display a video, just paste the link in the post content instead of using this shortcode 
     210        'user'    => get_the_author_meta( 'ID' ), 
     211    ), $args ); 
     212 
     213    // Rename display to count 
     214    $args['count'] = $args['display']; 
     215 
     216    // Rename user to user_id 
     217    $args['user_id'] = $args['user']; 
     218 
     219    unset($args['display'], $args['user']); 
     220 
     221    // Merge the parameters and default options 
     222    $options = wp_parse_args( $args, $defaults ); 
     223 
     224    // There's an ID! Get the video 
     225    if ( ! empty( $args['id'] ) ) : 
     226 
     227        // Get default width from the media options or the theme $content_width 
     228        $default_width = ( get_option( 'embed_size_w' ) ) ? get_option( 'embed_size_w' ) : (int) $GLOBALS['content_width']; 
     229 
     230        // If the width isn't set in the options or arguments, return the default width 
     231        if ( $options['width'] == 0 ) 
     232            $options['width'] = $default_width; 
     233 
     234        // Set height if empty. The aspect ratio is 16:9 
     235        if ( $options['height'] == 0 ) 
     236            $options['height'] = round($options['width'] / (16/9)); // 16:9 aspect ratio 
     237 
     238        ob_start(); ?> 
     239 
     240        <div class="youtube-video"> 
     241            <iframe width="<?php echo intval( $options['width'] ); ?>" height="<?php echo intval( $options['height'] ); ?>" src="http://www.youtube.com/embed/<?php echo esc_attr( $args['id']  ); ?>?rel=0&amp;hd=1" frameborder="0" allowfullscreen></iframe> 
     242 
     243        </div> 
     244 
     245    <?php 
    186246        return ob_get_clean(); 
    187  
    188     // Latest videos 
    189     else : 
    190  
    191         return ypf_show_video( $display, get_the_author_meta( 'ID' ) ); 
    192  
    193     endif; // $id; 
     247    endif; 
     248 
     249    return ypf_get_video( $options ); 
    194250} 
    195251 
     
    210266 */ 
    211267function ypf_plugin_action_links( $links, $file ) { 
    212     static $this_plugin; 
    213  
    214     if ( ! $this_plugin ) 
    215         $this_plugin = plugin_basename( __FILE__ ); 
     268    static $this_plugin; 
     269 
     270    if ( ! $this_plugin ) 
     271        $this_plugin = plugin_basename( __FILE__ ); 
    216272         
    217     if ( $file == $this_plugin ) { 
    218         $settings_link = '<a href="' . admin_url( 'options-general.php?page=youtube-profile-field' ) . '">Settings</a>'; 
    219         array_unshift( $links, $settings_link ); 
    220     } 
    221  
    222     return $links; 
    223 } 
    224  
    225 add_filter( 'plugin_action_links', 'ypf_plugin_action_links', 10, 2) ; 
    226  
    227 /** 
    228  * Install hook 
    229  */ 
    230 register_activation_hook( __FILE__, 'ypf_install' ); 
    231  
    232 function ypf_install() { 
    233  
    234     // Deactivate the plugin if using older than 3.1 
    235     if ( version_compare( get_bloginfo( 'version' ), '3.1', '<' ) ) { 
    236         deactivate_plugins( basename( __FILE__ ) ); 
    237     } 
    238  
    239     // Default options 
    240     $ypf_options = array( 
    241         'count' => '1', 
    242         'headingStart' => '&lt;h4&gt;', 
    243         'headingEnd' => '&lt;/h4&gt;', 
    244         'embed_code' => 0 
    245     ); 
    246  
    247     update_option( 'ypf_options', $ypf_options ); 
    248 } 
     273    if ( $file == $this_plugin ) { 
     274        $settings_link = '<a href="' . admin_url( 'options-general.php?page=youtube-profile-field' ) . '">' . __( 'Settings', 'youtubeprofile' ) . '</a>'; 
     275        array_unshift( $links, $settings_link ); 
     276    } 
     277 
     278    return $links; 
     279} 
     280 
     281add_filter( 'plugin_action_links', 'ypf_plugin_action_links', 10, 2 ); 
    249282 
    250283?> 
  • youtube-profile-field/trunk/readme.txt

    r372554 r507914  
    44Tags: youtube, video, rss, profile, field, username, user, shortcode 
    55Requires at least: 3.1 
    6 Tested up to: 3.2-bleeding 
    7 Stable tag: 2.1 
     6Tested up to: 3.3 
     7Stable tag: 2.2 
    88 
    99Adds an additional field to the user profile page and allow you to show your videos on your website. 
     
    1717== Installation == 
    1818 
    19 Installation Instructions: 
     191. Install the plugin either via the WordPress.org plugin directory, or by uploading the files to your `/wp-content/plugins/` directory. 
     202. Activate the plugin through the 'Plugins' menu in WordPress 
     213. Go to `Users > Your Profile` and enter your Youtube username in the field called "Youtube username" under "Contact Info" 
     224. Optional: Go to the settings page `Settings > Youtube Profile Field` and change the settings to fit you. 
    2023 
    21 1. Install the plugin either via <code>Plugins > Add New</code>, or by uploading the files to your server 
    22      
    23     If uploading to server: 
    24     1.1 Download the plugin and unzip it. 
    25     1.2 Put the youtube-profile-field folder into the <code>wp-content/plugins/</code> directory. 
    26      
    27 3. Go to the Plugins page in your WordPress Administration area and click 'Activate' next to Youtube Profile Field. 
    28 4. Go to your Profile page. Under "Contact Info" is there a input field called Youtube username. Enter your username 
    29 5. Optional: Go to the Youtube Profile Field options page (under Settings) and enter the information needed. 
    30  
    31 <h3>How to use it in template files:</h3> 
    32  
    33 You can easily show your latest Youtube files in your template files. Just use: <br /> 
    34  
    35 <code> 
    36     &lt;?php  
    37     if ( function_exists('ypf_show_video') ) { 
    38         echo ypf_show_video($count, $userid); 
    39     } 
    40     ?&gt; 
    41 </code>  
    42  
    43 <p>It accept 2 parameters.</p> 
    44  
    45 <p> 
    46     <code>$count</code> <em><small>Optional</small></em> <br /> 
    47     Number of videos you want to show. Will override the one entered in the options panel.  
    48 </p> 
    49  
    50 <p> 
    51     <code>$userid</code> <em><small>Optional</small></em> <br /> 
    52     Choose want user you want to show videos from. You don't need to enter one if you use the function inside the loop.  
    53     If you use it outside the loop you might want to enter one (or it will use ID 1). 
    54 </p> 
    55  
    56  
    57 <h3>How to use it in <code>author.php</code>:</h3> 
    58  
    59 <p>To get the ID of the current user on author.php, do you first need to <a href="http://codex.wordpress.org/Author_Templates#Setting_Up_for_Author_Information">Setup Author Information</a> 
    60 <br /> 
    61  
    62 After that just use</p> 
    63  
    64 <code> 
    65     &lt;?php  
    66     if ( function_exists('ypf_show_video') ) { 
    67         echo ypf_show_video('', $curauth->ID) 
    68     } 
    69     ?&gt; 
    70 </code> 
    71  
    72 <h3>How to use it in posts, pages and text widgets</h3> 
    73  
    74 <p> 
    75 You can use this shortcode if you want to display the videos in posts, pages or text widgets. 
    76 </p> 
    77  
    78 <code>[youtube-user]</code> 
    79  
    80 <p>It will show 1 video. If you want to display more, just use</p> 
    81  
    82 <code>[youtube-user display="3"]</code> <small>3 is the number of videos</small> 
    83  
    84 <p>You can also show a specific video</p> 
    85  
    86 <code>[youtube-user id="ql0kn-yI2OY"]</code> <small>ql0kn-yI2OY is the video ID</small> 
    8724 
    8825== Frequently Asked Questions == 
    8926 
    90 = It don't work - What should I do? = 
     27= How do I use the shortcode? = 
    9128 
    92 First of all, make sure that the plugin is activated. Another reason can be that you don't have entered your Youtube username on your profile page. 
     29The shortcode is: `[youtube-user]` 
    9330 
    94 = Is it compatible with version 3.0 or lower? = 
    95 No, sorry. This plugin requires 3.1 or higher. 
     31You can use these parameters: 
    9632 
    97 = I get an error message when I'm trying to use the template tag or shortcode = 
    98 Make sure that you have entered your Youtube username in your profile. 
     33* count/display - The number of videos you want to show. Ex: `[youtube-user count="2"]` 
     34* user/user_id  - The ID of the user you want to show videos from. Default is the post author. Ex:  `[youtube-user user="3"]` 
     35* width         - If you want a different width than the default 
     36* height        - If you want a different height than the default. If you leave it empty, the plugin will calculate a height using the width 
     37* headingStart  - If you want to overwrite the default. 
     38* headingEnd    - If you want to overwrite the default. 
     39* ID            - If you want to show a specific video you can use this. You **shouldn't** use this since WordPress now supports oEmbed. 
    9940 
    100 = I see no videos after updating to 2.1 = 
    101 If you use the template tag, make sure you have <code>echo ypf_show_video);</code> 
     41= How do I use the template tag? = 
     42 
     43The template tag is  
     44 
     45<code> 
     46if ( function_exists( 'ypf_show_video' ) ) { 
     47    echo ypf_show_video(); 
     48} 
     49</code> 
     50 
     51It accepts an array of parameters. 
     52 
     53You can use these parameters: 
     54 
     55* count         - The number of videos you want to show. You can use 'all' to show all that the Youtube RSS contains 
     56* user_id       - The ID of the user you want to show videos from. Default is the post author. 
     57* width         - If you want a different width than the default 
     58* height        - If you want a different height than the default. If you leave it empty, the plugin will calculate a height using the width 
     59* headingStart  - If you want to overwrite the default. 
     60* headingEnd    - If you want to overwrite the default. 
     61 
     62Example: 
     63<code> 
     64if ( function_exists( 'ypf_show_video' ) ) { 
     65    echo ypf_show_video( array( 'count' => 2, 'user_id' => 2 ) ); // 2 videos from user ID 2 
     66} 
     67</code> 
     68 
    10269 
    10370= The video size is strange - What's wrong? = 
    104 If you don't enter video sizes in the plugin options, it will use the width and height from 'Media'. 
     71If you don't enter video sizes in the plugin options, it will use the width from 'Media' and calculate the height using the 16:9 aspect ratio. 
    10572 
    106 Here's some recommended video sizes: 
     73Here's some video sizes: 
    10774 
    108 *480x295 
    109 *560x340 
    110 *640x385 
    111 *853x505 
     75* 480x295 
     76* 560x340 
     77* 640x385 
     78* 853x505 
    11279 
    11380= After upgrading to 2.0.2 my videos won't show anymore - What's wrong? = 
     
    11582 
    11683<code> 
    117     &lt;?php  
    118     if ( function_exists( 'ypf_show_video' ) ) { 
    119         echo ypf_show_video( $count, $userid ); 
    120     } 
    121     ?&gt; 
    122 </code>  
     84if ( function_exists( 'ypf_show_video' ) ) { 
     85    echo ypf_show_video(); 
     86} 
     87</code> 
    12388 
    12489 
     
    127921. A page with videos 
    128932. The profile page with the Youtube username field 
    129 3. Plugin settings 
    13094 
    13195== Changelog == 
     96 
     97= 2.2 = 
     98* HUGE code improvements 
     99* The `ypf_show_video()` function now takes an array of options instead of parameters 
     100* Both the shortcode and template tag now accepts more arguments (see FAQ) 
     101* You can no longer use the old embed code 
     102* Small bug fixes 
    132103 
    133104= 2.1 = 
     
    182153If using the template tag, make sure to have <code>echo</code> in front of it. 
    183154A lot of bug fixes 
    184  
    185 == Support == 
    186  
    187 Support is provided at email - [Contactform here](http://jayj.dk/kontakt) 
Note: See TracChangeset for help on using the changeset viewer.