sandyfischler
Forum Replies Created
-
Forum: Hacks
In reply to: Custom Widget CodeExcellent! Thank you. I’ve gotten my widget to successfully show up in the widget list and do what is intended.
My indentation is a little messy (newbies, sheesh!) but here is how it comes out:
<?php /* Plugin Name: Fuller Donation Widgets Description: Donation channel widgets Author: Sandy Fischler Version: 1 */ /* Start Adding Functions Below this Line */ class fuller_of_openstrap_donation_page_one extends WP_Widget { function fuller_of_openstrap_donation_page_one() { // Instantiate the parent object parent::__construct( false, 'Fuller Donation Widget 1' ); } function widget( $args, $instance ) { // Widget output extract( $args ); // these are the widget options $title = apply_filters('widget_title', $instance['title']); $text = $instance['text']; $textarea = $instance['textarea']; echo $before_widget; // Display the widget echo '<div class="widget-text wp_widget_plugin_box">'; // Check if title is set if ( $title ) { echo $before_title . $title . $after_title; } // Check if text is set if( $text ) { echo '<p class="wp_widget_plugin_text">'.$text.'</p>'; } // Check if textarea is set if( $textarea ) { echo '<p class="wp_widget_plugin_textarea">'.$textarea.'</p>'; } echo '</div>'; echo $after_widget; } function update( $new_instance, $old_instance ) { // Save widget options $instance = $old_instance; // Fields $instance['title'] = strip_tags($new_instance['title']); $instance['text'] = strip_tags($new_instance['text']); $instance['textarea'] = strip_tags($new_instance['textarea']); return $instance; } function form( $instance ) { // Output admin widget options form if( $instance) { $title = esc_attr($instance['title']); $text = esc_attr($instance['text']); $textarea = esc_textarea($instance['textarea']); } else { $title = ''; $text = ''; $textarea = ''; } ?> <p> <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'wp_widget_plugin'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text:', 'wp_widget_plugin'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>" type="text" value="<?php echo $text; ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('textarea'); ?>"><?php _e('Textarea:', 'wp_widget_plugin'); ?></label> <textarea class="widefat" id="<?php echo $this->get_field_id('textarea'); ?>" name="<?php echo $this->get_field_name('textarea'); ?>"><?php echo $textarea; ?></textarea> </p> <?php } } function myplugin_register_widgets() { register_widget( 'fuller_of_openstrap_donation_page_one' ); } add_action( 'widgets_init', 'myplugin_register_widgets' ); /* Stop Adding Functions Below this Line */ ?>
Now, my next issue is that I need to register the areas where I want it to appear. This widget (will be widgetS) are going to appear on a page in the content section just below the main page content but before the footer. I’ve added this code as specified in the Codex but my widgetized area is not showing up.
<?php //* Start the engine include_once( get_template_directory() . '/lib/init.php'): <?php /** * Register our sidebars and widgetized areas. * */ function arphabet_widgets_init() { register_sidebar( array( 'name' => 'Donation Page Widget One', 'id' => 'donation_left_1', 'before_widget' => '<div>', 'after_widget' => '</div>', 'before_title' => '<h2 class="rounded">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'arphabet_widgets_init' ); ?>
Forum: Fixing WordPress
In reply to: CSS Div Element BordersThere are places where our sidebar is longer than our content box and places where our content box is longer than the sidebar.
Thanks for the fast response!