Changeset 144330
- Timestamp:
- 08/10/2009 09:31:48 AM (17 years ago)
- Location:
- facebook-fan-box/trunk
- Files:
-
- 2 edited
-
facebook-fan-box.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
facebook-fan-box/trunk/facebook-fan-box.php
r143630 r144330 3 3 Plugin Name: Facebook Fan Box 4 4 Plugin URI: http://www.hnkweb.com/2009/08/03/facebook-fan-box-wordpress-plugin/ 5 Description: Display Facebook Fan Box6 Version: 1. 25 Description: Displays a Facebook Fan Box 6 Version: 1.3 7 7 Author: Marcos Esperon 8 8 Author URI: http://www.hnkweb.com/ … … 25 25 */ 26 26 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 27 35 function facebook_fan_box($api_key, $profile_id, $stream = 1, $connections = 10, $width = 300, $css = '', $iframe = 0) { 28 36 $output = ''; … … 38 46 echo $output; 39 47 } 48 49 function 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 />' : ' '; 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. 147 add_action('widgets_init', 'widget_ffb_init'); 40 148 ?> -
facebook-fan-box/trunk/readme.txt
r143630 r144330 4 4 Requires at least: 2.0.0 5 5 Tested up to: 2.8 6 Stable tag: 1. 26 Stable tag: 1.3 7 7 8 Display a Facebook Fan Box on your blog. 8 Display 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. 9 9 10 10 == Description == 11 11 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: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 activate this widget or insert this line of code anywhere in your theme: 13 13 14 14 `<?php facebook_fan_box('API_KEY', 'PROFILE_ID'); ?>` … … 30 30 - 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). 31 31 32 33 32 == Installation == 34 33 35 34 1. Upload the entire facebook-fan-box folder to your wp-content/plugins/ directory. 35 36 36 2. 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:38 37 39 Visit http://www.facebook.com/pages/create.php to create a new page in Facebook. 38 3. 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 40 40 41 Then visit http://www.facebook.com/developers/wizard.php to obtain the API_KEY and PROFILE_ID 41 4. Use this information to call the function inside your template or activate the widget. 42 42 43 43 == Screenshots == … … 52 52 == Changelog == 53 53 54 = 1.3 = 55 * widget support. 56 54 57 = 1.2 = 55 58 * iFrame check change.
Note: See TracChangeset
for help on using the changeset viewer.