Load_TextDomain(); // Setup the Widget data $this->WP_Widget ( False, $this->t('Galleries'), Array('description' => $this->t('Shows galleries on your sidebar.'))); $this->base_url = get_option('siteurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))); // Register as Widget Add_Action ('widgets_init', Array($this, 'Register')); } Function Register(){ Register_Widget(get_class($this)); Add_Action('wp_head', Array($this, 'Include_CSS')); } 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('Galleries'); If ($settings['limit'] == '') $settings['limit'] = 5; // Get posts If (method_exists('wp_plugin_post_special_properties', 'get_gallery_posts')) $arr_gallery = wp_plugin_post_special_properties::get_gallery_posts($settings['limit']); Else 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_gallery_posts(); } /* End of If-Class-Exists-Condition */ /* End of File */