'Widgets' == Frequently Asked Questions == = How do I upload an image? = The JetBook Black Widget does not provide a mechanism for uploading images or files. You can however upload an image in the 'Write' section of Wordpress. From there you can click on the 'Add an Image' icon (next to 'Add Media' label). After uploading an image, copy the 'Link URL' for use in your JetBook Black Widget. = How many images can be display? = Each instance of the widget can only display one image, but you can create as many instances as you need. == Screenshots == 1. JetBook Black Widget control interface 2. JetBook Black Widget in sidebar */ ?> $widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract( $widget_args, EXTR_SKIP ); // Data is stored as array: array( number => data for that instance of the widget, ... ) $options = get_option('widget_jetbookblack'); if ( !isset($options[$number]) ) return; if ($options[$number]['link']) { if ($options[$number]['new_window']) $before_image = ""; else $before_image = ""; $after_image = ""; } if ($options[$number]['image']) $title = preg_replace('/\?.*/', "", basename($options[$number]['image'])); ?>
"; } ?>

<?php echo $options[$number]['alt']; ?>

$widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract( $widget_args, EXTR_SKIP ); // Data is stored as array: array( number => data for that instance of the widget, ... ) $options = get_option('widget_jetbookblack'); if ( !is_array($options) ) $options = array(); // We need to update the data if ( !$updated && !empty($_POST['sidebar']) ) { // Tells us what sidebar to put the data in $sidebar = (string) $_POST['sidebar']; $sidebars_widgets = wp_get_sidebars_widgets(); if ( isset($sidebars_widgets[$sidebar]) ) $this_sidebar =& $sidebars_widgets[$sidebar]; else $this_sidebar = array(); foreach ( $this_sidebar as $_widget_id ) { if ( 'widget_jetbookblack' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; if ( !in_array( "jetbookblack-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed unset($options[$widget_number]); } } foreach ( (array) $_POST['widget-jetbookblack'] as $widget_number => $widget_jetbookblack ) { if ( !isset($widget_jetbookblack['image']) && isset($options[$widget_number]) ) // user clicked cancel continue; $image = wp_specialchars( $widget_jetbookblack['image'] ); $alt = wp_specialchars( $widget_jetbookblack['alt'] ); $link = wp_specialchars( $widget_jetbookblack['link'] ); $new_window = isset( $widget_jetbookblack['new_window'] ); $options[$widget_number] = compact('image', 'alt', 'link', 'new_window'); } update_option('widget_jetbookblack', $options); $updated = true; // So that we don't go through this more than once } // Here we echo out the form if ( -1 == $number ) { // We echo out a template for a form which can be converted to a specific form later via JS $image = ''; $alt = ''; $link = ''; $new_window = ''; $number = '%i%'; } else { $image = attribute_escape($options[$number]['image']); $alt = attribute_escape($options[$number]['alt']); $link = attribute_escape($options[$number]['link']); $new_window = attribute_escape($options[$number]['new_window']); } ?>

'widget_jetbookblack', 'description' => __('Display an image')); $control_ops = array( 'id_base' => 'jetbookblack'); $name = __('JetBook Black Widget'); $registered = false; foreach ( array_keys($options) as $o ) { // Old widgets can have null values for some reason if ( !isset($options[$o]['image']) ) continue; $id = "jetbookblack-$o"; // Never never never translate an id $registered = true; wp_register_sidebar_widget( $id, $name, 'widget_jetbookblack', $widget_ops, array( 'number' => $o ) ); wp_register_widget_control( $id, $name, 'widget_jetbookblack_control', $control_ops, array( 'number' => $o ) ); } // If there are none, we register the widget's existance with a generic template if ( !$registered ) { wp_register_sidebar_widget( 'jetbookblack-1', $name, 'widget_jetbookblack', $widget_ops, array( 'number' => -1 ) ); wp_register_widget_control( 'jetbookblack-1', $name, 'widget_jetbookblack_control', $control_ops, array( 'number' => -1 ) ); } } // Hook for the registration add_action( 'widgets_init', 'widget_jetbookblack_register' ) ?>