'This Flickr widget populates photos from a Flickr ID.' ); parent::WP_Widget( false, __( 'Phoenix - Flickr', 'phoenix' ), $widget_ops ); } function widget( $args, $instance ) { extract( $args, EXTR_SKIP ); $instance = $this->phoenix_enforce_defaults( $instance ); extract( $instance, EXTR_SKIP ); echo $before_widget; echo $before_title; ?> flickr', 'phoenix' ); ?>
phoenix_enforce_defaults( $new_instance ); return $new_instance; } function phoenix_enforce_defaults( $instance ) { $defaults = $this->phoenix_get_settings(); $instance = wp_parse_args( $instance, $defaults ); if ( $instance['limit'] < 1 ) $instance['limit'] = 1; elseif ( $instance['limit'] > 10 ) $instance['limit'] = 10; $instance['width'] = absint( $instance['width'] ); if ( $instance['width'] < 1 ) $instance['width'] = $defaults['width']; $instance['height'] = absint( $instance['height'] ); if ( $instance['height'] < 1 ) $instance['height'] = $defaults['height']; if ( $instance['sorting'] != 'random' ) $instance['sorting'] = $defaults['sorting']; if ( !in_array( $instance['size'], array( 's', 'm', 't' ) ) ) $instance['size'] = $defaults['size']; if ( $instance['type'] != 'group' ) $instance['type'] = $defaults['type']; return $instance; } /** * Provides an array of the settings with the setting name as the key and the default value as the value * This cannot be called get_settings() or it will override WP_Widget::get_settings() */ function phoenix_get_settings() { // Set the default to a blank string $settings = array_fill_keys( $this->settings, '' ); // Now set the more specific defaults $settings['limit'] = 10; $settings['width'] = 300; $settings['height'] = 200; $settings['size'] = 's'; $settings['sorting'] = 'latest'; $settings['type'] = 'user'; return $settings; } function form( $instance ) { $instance = $this->phoenix_enforce_defaults( $instance ); extract( $instance, EXTR_SKIP ); ?>