'widget_ex_attachments', 'description' => __( 'Attach files in widget', 'ex_attachments_widget' ) ); $this->WP_Widget( 'widget_ex_attachments', __( 'Attach Files', 'ex_attachments_widget' ), $widget_ops ); $this->alt_option_name = 'widget_ex_attachments'; add_action( 'save_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'register_widget_styles' ) ); } /** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output **/ function widget( $args, $instance ) { global $wpdb, $assetsUrl, $filetype_icons; $cache = wp_cache_get( 'widget_ex_attachments', 'widget' ); if ( !is_array( $cache ) ) $cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = null; if ( isset( $cache[$args['widget_id']] ) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract( $args, EXTR_SKIP ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Attachments', 'ex_attachments_widget' ) : $instance['title'], $instance, $this->id_base); $icons = empty( $instance['icons']) ? 'no' : $instance['icons']; echo $before_widget; echo $before_title; echo $title; // Can set this with a widget option, or omit altogether echo $after_title; $data = json_decode($instance['data'], true); ?>
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_ex_attachments'] ) ) delete_option( 'widget_ex_attachments' ); return $instance; } function flush_widget_cache() { wp_cache_delete( 'widget_ex_attachments', 'widget' ); } /** * Displays the form for this widget on the Widgets page of the WP Admin area. **/ function form( $instance ) { $title = isset( $instance['title']) ? esc_attr( $instance['title'] ) : __( 'Attachments', 'ex_attachments_widget' ); $icons = isset( $instance['icons']) ? $instance['icons'] : 'no'; $data = json_decode($instance['data'], true); preg_match('/.*?-([0-9]+)$/i', $this->id, $matches); ?>

:


/>   />   />