__construct(); } /** * PHP 5 Constructor */ function __construct() { add_action('widgets_init', array(&$this, 'register_widget')); } function register_widget() { global $owad; if ( $owad->supported_by_host() ) { wp_register_sidebar_widget('owad', 'One Word A Day', array( &$this, 'frontend') ); wp_register_widget_control('owad', 'One Word A Day', array( &$this, 'backend') ); } else { wp_register_sidebar_widget('owad', 'One Word A Day', array( &$this, 'frontend_no_support') ); wp_register_widget_control('owad', 'One Word A Day', array( &$this, 'backend_no_support') ); } } function frontend( $args ) { // there is an issue. this function is executed in the backend as well if ( ! is_admin() ) { global $owad; extract( $args ); echo $before_widget; echo $before_title .'One Word A Day'. $after_title; echo $owad->print_word(); echo $owad->print_archive_words(); echo $after_widget; } } function backend() { global $owad_default_options; $options = get_option('owad'); $options = wp_parse_args( $options, $owad_default_options ); /******************************************************************************/ if ( isset( $_POST["owad-save-widget"] )) { $set_to_default = true; foreach( $_POST["owad_post_category"] as $el ) { if ( !empty($el)) $set_to_default = false; } if ( $set_to_default ) $options["owad_post_category"] = $owad_default_options["owad_post_category"]; else $options["owad_post_category"] = $_POST["owad_post_category"]; $options["owad_daily_post"] = (bool) $_POST["owad_daily_post"]; $options["owad_post_author"] = (int) $_POST["owad_post_author"]; update_option( "owad", $options ); } /******************************************************************************/ echo '
Create a daily post:
yes
no

'; /******************************************************************************/ // The post settings block echo '
'; // The categories echo '

In which categories should be posted?

'; $cats = get_categories( array( "hide_empty" => false ) ); foreach( $cats as $cat) echo 'cat_ID, $options["owad_post_category"] )) ? 'checked="checked"' : "" ) .' value="'. $cat->cat_ID .'"/> ' . $cat->cat_name ."
"; echo "

"; // Which user should be used? echo '

Who should be the post author?

'; echo ''; echo "

"; echo "
"; } function backend_no_support() { global $owad; echo $owad->no_support_text(); } // This is just a dummy becuase a sidebar widget has to be registered. function frontend_no_support() { } } ?>