__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 '