Plugin Directory

Changeset 144330


Ignore:
Timestamp:
08/10/2009 09:31:48 AM (17 years ago)
Author:
hanok
Message:

Version 1.3 con soporte de Widget

Location:
facebook-fan-box/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • facebook-fan-box/trunk/facebook-fan-box.php

    r143630 r144330  
    33Plugin Name: Facebook Fan Box
    44Plugin URI: http://www.hnkweb.com/2009/08/03/facebook-fan-box-wordpress-plugin/
    5 Description: Display Facebook Fan Box
    6 Version: 1.2
     5Description: Displays a Facebook Fan Box
     6Version: 1.3
    77Author: Marcos Esperon
    88Author URI: http://www.hnkweb.com/
     
    2525*/
    2626
     27$ffb_options['widget_fields']['api_key'] = array('label'=>'API Key:', 'type'=>'text', 'default'=>'', 'class'=>'widefat', 'size'=>'', 'help'=>'');
     28$ffb_options['widget_fields']['profile_id'] = array('label'=>'Profile ID:', 'type'=>'text', 'default'=>'', 'class'=>'widefat', 'size'=>'', 'help'=>'');
     29$ffb_options['widget_fields']['stream'] = array('label'=>'Stream:', 'type'=>'checkbox', 'default'=>true, 'class'=>'', 'size'=>'', 'help'=>'');
     30$ffb_options['widget_fields']['connections'] = array('label'=>'Connections:', 'type'=>'text', 'default'=>'10', 'class'=>'', 'size'=>'3', 'help'=>'(Limit 100)');
     31$ffb_options['widget_fields']['width'] = array('label'=>'Width:', 'type'=>'text', 'default'=>'300', 'class'=>'', 'size'=>'3', 'help'=>'(Value in px)');
     32$ffb_options['widget_fields']['css'] = array('label'=>'CSS:', 'type'=>'text', 'default'=>'', 'class'=>'widefat', 'size'=>'', 'help'=>'(External URL file)');
     33$ffb_options['widget_fields']['iframe'] = array('label'=>'iFrame:', 'type'=>'checkbox', 'default'=>false, 'class'=>'', 'size'=>'', 'help'=>'');
     34
    2735function facebook_fan_box($api_key, $profile_id, $stream = 1, $connections = 10, $width = 300, $css = '', $iframe = 0) {
    2836    $output = '';
     
    3846  echo $output;
    3947}
     48
     49function widget_ffb_init() {
     50
     51    if ( !function_exists('register_sidebar_widget') )
     52        return;
     53   
     54    $check_options = get_option('widget_ffb');
     55 
     56    function widget_ffb($args) {
     57
     58        global $ffb_options;
     59       
     60        // $args is an array of strings that help widgets to conform to
     61        // the active theme: before_widget, before_title, after_widget,
     62        // and after_title are the array keys. Default tags: li and h2.
     63        extract($args);
     64       
     65        $options = get_option('widget_ffb');
     66       
     67        // fill options with default values if value is not set
     68        $item = $options;
     69        foreach($ffb_options['widget_fields'] as $key => $field) {
     70            if (! isset($item[$key])) {
     71                $item[$key] = $field['default'];
     72            }
     73        }   
     74       
     75    $api_key = $item['api_key'];
     76    $profile_id = $item['profile_id'];
     77    $stream = ($item['stream']) ? 1 : 0;
     78    $connections = $item['connections'];
     79    $width = $item['width'];
     80    $css = $item['css'];
     81    $iframe = ($item['iframe']) ? 1 : 0;
     82   
     83        // These lines generate our output.
     84    echo $before_widget;
     85    facebook_fan_box($api_key, $profile_id, $stream, $connections, $width, $css, $iframe);
     86        echo $after_widget;
     87               
     88    }
     89
     90    // This is the function that outputs the form to let the users edit
     91    // the widget's title. It's an optional feature that users cry for.
     92    function widget_ffb_control() {
     93   
     94        global $ffb_options;
     95
     96        // Get our options and see if we're handling a form submission.
     97        $options = get_option('widget_ffb');
     98        if ( isset($_POST['ffb-submit']) ) {
     99
     100            foreach($ffb_options['widget_fields'] as $key => $field) {
     101                $options[$key] = $field['default'];
     102                $field_name = sprintf('%s', $key);       
     103                if ($field['type'] == 'text') {
     104                    $options[$key] = strip_tags(stripslashes($_POST[$field_name]));
     105                } elseif ($field['type'] == 'checkbox') {
     106                    $options[$key] = isset($_POST[$field_name]);
     107                }
     108            }
     109
     110            update_option('widget_ffb', $options);
     111        }
     112   
     113        foreach($ffb_options['widget_fields'] as $key => $field) {
     114            $field_name = sprintf('%s', $key);
     115            $field_checked = '';
     116            if ($field['type'] == 'text') {
     117                $field_value = (isset($options[$key])) ? htmlspecialchars($options[$key], ENT_QUOTES) : htmlspecialchars($field['default'], ENT_QUOTES);
     118            } elseif ($field['type'] == 'checkbox') {
     119                $field_value = (isset($options[$key])) ? $options[$key] :$field['default'] ;
     120                if ($field_value == 1) {
     121                    $field_checked = 'checked="checked"';
     122                }
     123            }
     124      $jump = ($field['type'] != 'checkbox') ? '<br />' : '&nbsp;';
     125      $field_class = $field['class'];
     126      $field_size = ($field['class'] != '') ? '' : 'size="'.$field['size'].'"';
     127      $field_help = ($field['help'] == '') ? '' : '<small>'.$field['help'].'</small>';
     128            printf('<p class="ffb_field"><label for="%s">%s</label>%s<input id="%s" name="%s" type="%s" value="%s" class="%s" %s %s /> %s</p>',
     129          $field_name, __($field['label']), $jump, $field_name, $field_name, $field['type'], $field_value, $field_class, $field_size, $field_checked, $field_help);
     130        }
     131
     132        echo '<input type="hidden" id="ffb-submit" name="ffb-submit" value="1" />';
     133    }   
     134   
     135    function widget_ffb_register() {       
     136    $title = 'Facebook Fan Box';
     137    // Register widget for use
     138    register_sidebar_widget($title, 'widget_ffb');   
     139    // Register settings for use, 300x100 pixel form
     140    register_widget_control($title, 'widget_ffb_control');
     141    }
     142
     143    widget_ffb_register();
     144}
     145
     146// Run our code later in case this loads prior to any required plugins.
     147add_action('widgets_init', 'widget_ffb_init');
    40148?>
  • facebook-fan-box/trunk/readme.txt

    r143630 r144330  
    44Requires at least: 2.0.0
    55Tested up to: 2.8
    6 Stable tag: 1.2
     6Stable tag: 1.3
    77
    8 Display a Facebook Fan Box on your blog.
     8Display a Facebook Fan Box on your blog. Put the Facebook Fan Box in your sidebar using the widget mode or call the function inside your template.
    99
    1010== Description ==
    1111
    12 If you have a page in Facebook about your blog and want to show the Facebook Fan Box with the recent updates and fans, just insert this line of code anywhere in your theme:
     12If you have a page in Facebook about your blog and want to show the Facebook Fan Box with the recent updates and fans, just activate this widget or insert this line of code anywhere in your theme:
    1313
    1414`<?php facebook_fan_box('API_KEY', 'PROFILE_ID'); ?>`
     
    3030- IFRAME: If you are unable to use JavaScript method for some reason, you can use add a Fan Box using an HTML iframe tag (Default value is 0).
    3131
    32 
    3332== Installation ==
    3433
    35341. Upload the entire facebook-fan-box folder to your wp-content/plugins/ directory.
     35
    36362. Activate the plugin through the 'Plugins' menu in WordPress.
    37 3. There is no options screen - configuration is done in your code and, optionally, by modifying the plugin:
    3837
    39    Visit http://www.facebook.com/pages/create.php to create a new page in Facebook.
     383. Visit http://www.facebook.com/pages/create.php to create a new page in Facebook.
     39   Then visit http://www.facebook.com/developers/wizard.php to obtain the API_KEY and PROFILE_ID
    4040
    41    Then visit http://www.facebook.com/developers/wizard.php to obtain the API_KEY and PROFILE_ID
     414. Use this information to call the function inside your template or activate the widget.
    4242
    4343== Screenshots ==
     
    5252== Changelog == 
    5353
     54= 1.3 = 
     55* widget support.
     56
    5457= 1.2 = 
    5558* iFrame check change.
Note: See TracChangeset for help on using the changeset viewer.