Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Programista- okładka
- Version: 0.1
- Description: Wyświetla aktualną okładkę "Programisty"
- Author: michak
- */
- class Programista_Widget extends WP_Widget {
- function __construct() {
- parent::__construct('programista_widget', __( 'Programista- okładka', 'text_domain' ),
- array( 'description' => __( 'Okładka aktualnego "Programisty"', 'text_domain' ), ));
- }
- private function widget_content($instance) {
- $src = "http://programistamag.pl/wp-content/uploads/magazines/covers/" . $instance['latest_number'] . "_okladka.jpg";
- $content = "<img width='" . $instance['scale'] . "' height='" . $instance['scale'] . "' src='" . $src . "'></img>";
- return $content;
- }
- public function widget($args, $instance) {
- echo $args['before_widget'];
- if (!empty( $instance['title'])) {
- echo $args['before_title'] .
- apply_filters('widget_title', $instance['title']) .
- $args['after_title'];
- }
- echo __($this->widget_content($instance), 'text_domain' );
- echo $args['after_widget'];
- }
- public function form($instance) {
- $title = !empty($instance['title']) ? $instance['title'] : "";
- $latest_number = !empty($instance['latest_number']) ? $instance['latest_number'] : __('36', 'text_domain');
- $scale = !empty($instance['scale']) ? $instance['scale'] : __('100%', 'text_domain');
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Tytuł:'); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
- <label for="<?php echo $this->get_field_id('latest_number'); ?>"><?php _e('Ostatni numer:'); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id('latest_number'); ?>" name="<?php echo $this->get_field_name('latest_number'); ?>" type="text" value="<?php echo esc_attr($latest_number); ?>">
- <label for="<?php echo $this->get_field_id('scale'); ?>"><?php _e('Skalowanie (wartość % lub piksele):'); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id('scale'); ?>" name="<?php echo $this->get_field_name('scale'); ?>" type="text" value="<?php echo esc_attr($scale); ?>">
- </p>
- <?php
- }
- };
- function register_programista_widget() {
- register_widget('Programista_Widget');
- }
- add_action('widgets_init', 'register_programista_widget');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement