Load_TextDomain(); // Setup the Widget data $this->WP_Widget ( False, $this->t('Featured posts'), Array('description' => $this->t('Shows featured posts in your sidebar.'))); $this->base_url = get_option('siteurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))); // Hooks Add_Action ('widgets_init', Array($this, 'Register')); Add_Action('wp_head', Array($this, 'Include_CSS')); } Function Register(){ // Register as Widget Register_Widget(get_class($this)); } Function Load_TextDomain(){ $this->text_domain = get_class($this); load_textdomain ($this->text_domain, DirName(__FILE__).'/language/'.get_locale().'.mo'); } Function t ($text, $context = ''){ // Translates the string $text with context $context If ($context == '') return __($text, $this->text_domain); Else return _x($text, $context, $this->text_domain); } Function Include_CSS(){ Echo ''; } Function widget ($args, $settings){ If ($settings['title'] == '') $settings['title'] = $this->t('Featured posts'); If ($settings['limit'] == '') $settings['limit'] = 5; // Get posts If (method_exists('wp_plugin_post_special_properties', 'get_featured_posts')) $arr_feat = wp_plugin_post_special_properties::get_featured_posts($settings['limit']); Else return False; // Bail out if there are no featured posts If (Empty($arr_feat)) return False; // print html to sidebar Echo $args['before_widget']; Echo $args['before_title'].$settings['title'].$args['after_title']; Echo ''; Echo $args['after_widget']; } Function form ($settings){ // Show Form Echo $this->t('Title:').'
'; Echo $this->t('Number of posts:').'
'; } Function update ($new_settings, $old_settings){ return $new_settings; } } /* End of Class */ New widget_featured_posts(); } /* End of If-Class-Exists-Condition */ /* End of File */