WordPress.org

Plugin Directory

Changeset 1276558


Ignore:
Timestamp:
10/30/15 18:51:41 (22 months ago)
Author:
eduardozulian
Message:

Publishing version: 1.3

Location:
a-featured-page-widget/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • a-featured-page-widget/trunk/a-featured-page-widget.php

    r729526 r1276558  
    44Plugin URI: http://github.com/eduardozulian/a-featured-page-widget 
    55Description: Feature a page and display its excerpt and post thumbnail. 
    6 Version: 1.2 
     6Version: 1.3 
    77Author: Eduardo Zulian 
    88Author URI: http://flutuante.com.br 
     
    1212 
    1313This program is free software; you can redistribute it and/or modify 
    14 it under the terms of the GNU General Public License, version 2, as  
     14it under the terms of the GNU General Public License, version 2, as 
    1515published by the Free Software Foundation. 
    1616 
     
    2929 */ 
    3030function afpw_load_textdomain() { 
    31  
    3231    load_plugin_textdomain( 'a-featured-page-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
    33      
    3432} 
    3533 
     
    4038 */ 
    4139function afpw_enqueue_stylesheet() { 
    42  
    43     wp_register_style( 'a-featured-page-widget', plugins_url( 'css/a-featured-page-widget.css', __FILE__) ); 
     40    wp_register_style( 'a-featured-page-widget', plugins_url( 'css/a-featured-page-widget.css', __FILE__ ) ); 
    4441    wp_enqueue_style( 'a-featured-page-widget' ); 
    45      
    4642} 
    4743 
     
    5248 */ 
    5349function afpw_register_widget() { 
    54  
    5550    register_widget( 'A_Featured_Page_Widget' ); 
    56      
    5751} 
    5852 
     
    6660class A_Featured_Page_Widget extends WP_Widget { 
    6761 
     62    /** 
     63     * Sets up a new widget instance. 
     64     * 
     65     * @access public 
     66     */ 
    6867    public function __construct() { 
    6968        parent::__construct( 
     
    7574 
    7675    /** 
    77      * Front-end display of widget. 
     76     * Outputs the content for a new widget instance. 
    7877     * 
    7978     * @see WP_Widget::widget() 
    8079     * 
    81      * @param array $args Widget arguments. 
    82      * @param array $instance Saved values from database. 
     80     * @param array $args       Widget arguments. 
     81     * @param array $instance   Saved values from database. 
    8382     */ 
    84     function widget( $args, $instance ) {     
    85         extract($args);      
     83    function widget( $args, $instance ) { 
     84        extract( $args ); 
    8685 
    8786        if ( isset( $instance['page'] ) && $instance['page'] != -1 ) { 
    88          
     87 
    8988            $page_id = (int) $instance['page']; 
    9089            $link_text = isset( $instance['link-text'] ) ? strip_tags( $instance['link-text'] ) : apply_filters( 'afpw_link_text', __( 'Continue reading', 'a-featured-page-widget' ) ); 
    9190            $image_size = isset( $instance['image-size'] ) ? strip_tags( $instance['image-size'] ) : 'thumbnail'; 
    92          
     91 
    9392            $p = new WP_Query( array( 'page_id' => $page_id ) ); 
    94          
     93 
    9594            if ( $p->have_posts() ) { 
    96              
    9795                $p->the_post(); 
    98                  
     96 
    9997                $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? get_the_title() : $instance['title'], $instance, $this->id_base ); 
    100                  
     98 
    10199                echo $before_widget; 
    102100                echo $before_title; 
     
    104102                echo $after_title; 
    105103                ?> 
    106                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>            
     104                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
    107105                    <?php if ( $image_size != 'no-thumbnail' && has_post_thumbnail() ) : ?> 
    108                     <a class="thumbnail-link" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">                      
    109                         <?php the_post_thumbnail( $image_size ); ?> 
    110                     </a> 
     106                        <div class="post-thumbnail entry-image"> 
     107                            <a class="thumbnail-link" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">                      
     108                                <?php the_post_thumbnail( $image_size ); ?> 
     109                            </a> 
     110                        </div> 
    111111                    <?php endif; ?> 
    112                      
     112 
    113113                    <div class="entry-content"> 
    114114                        <?php the_excerpt(); ?> 
     
    117117                        <?php endif; ?> 
    118118                    </div> 
    119                      
    120119                </div> 
    121                  
     120 
    122121                <?php 
    123122                echo $after_widget; 
    124      
     123 
    125124                wp_reset_postdata(); 
    126              
    127125            } 
    128126        } 
     
    135133        $instance['image-size'] = strip_tags( $new_instance['image-size'] ); 
    136134        $instance['link-text'] = strip_tags( $new_instance['link-text'] ); 
    137          
     135 
    138136        return $instance; 
    139137    } 
     
    151149        <p> 
    152150            <label for="<?php echo $this->get_field_id( 'page' ); ?>"><?php _e( 'Page:', 'a-featured-page-widget' ); ?></label> 
     151 
    153152            <?php 
    154             // Mimic wp_dropdown_pages() funcionality to add a 'widefat' class to the <select> tag 
     153            /** 
     154             *  Mimics wp_dropdown_pages() funcionality to add a 'widefat' class to the <select> tag 
     155             */ 
    155156            $args = array( 
    156                 'depth' => 0, 
    157                 'child_of' => 0, 
    158                 'selected' => $page, 
    159                 'name' => $this->get_field_name( 'page' ), 
    160                 'id' => $this->get_field_id( 'page' ), 
    161                 'show_option_none' => '', 
     157                'depth'                 => 0, 
     158                'child_of'              => 0, 
     159                'selected'              => $page, 
     160                'name'                  => $this->get_field_name( 'page' ), 
     161                'id'                    => $this->get_field_id( 'page' ), 
     162                'show_option_none'      => '', 
    162163                'show_option_no_change' => '', 
    163                 'option_none_value' => '' 
     164                'option_none_value'     => '' 
    164165            ); 
    165      
     166 
    166167            extract( $args, EXTR_SKIP ); 
    167             $pages = get_pages($args); 
    168              
     168            $pages = get_pages( $args ); 
     169 
    169170            if ( ! empty( $pages ) ) : ?> 
    170171                <select class="widefat" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $id ); ?>"> 
     
    195196    <?php 
    196197    } 
    197      
     198 
    198199    /** 
    199      * Get all the registered image sizes along with their dimensions 
     200     * Returns all the registered image sizes along with their dimensions 
    200201     * 
    201202     * @global array $_wp_additional_image_sizes 
     
    208209 
    209210        $default_image_sizes = array( 'thumbnail', 'medium', 'large' ); 
    210           
     211 
    211212        foreach ( $default_image_sizes as $size ) { 
    212213            $image_sizes[$size]['width']    = intval( get_option( "{$size}_size_w") ); 
     
    214215            $image_sizes[$size]['crop'] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false; 
    215216        } 
    216          
    217         if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) 
     217 
     218        if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { 
    218219            $image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes ); 
    219              
     220        } 
     221 
    220222        return $image_sizes; 
    221223    } 
  • a-featured-page-widget/trunk/css/a-featured-page-widget.css

    r723350 r1276558  
    11/* Some harm reduction for big images in small widget areas */ 
    2 .widget_a_featured_page_widget .entry-image img { 
     2.widget_a_featured_page_widget img { 
    33    height: auto; 
    44    max-width: 100%; 
  • a-featured-page-widget/trunk/readme.md

    r729526 r1276558  
    77**Tags:** widget, sidebar, page widget, featured page, pages   
    88**Requires at least:** 3.0   
    9 **Tested up to:** 3.6   
    10 **Stable tag:** 1.2   
     9**Tested up to:** 4.3   
     10**Stable tag:** 1.3   
    1111**License:** GPLv2 or later   
    1212**License URI:** http://www.gnu.org/licenses/gpl-2.0.html 
     
    1919 
    2020* Portuguese (Brazil) 
     21 
     22### Contributing ### 
     23[A Featured Page Widget](https://github.com/eduardozulian/a-featured-page-widget) is available on GitHub. If you want to contribute, please fork it and send a pull request! 
    2124 
    2225## Installation ## 
  • a-featured-page-widget/trunk/readme.txt

    r729526 r1276558  
    44Tags: widget, sidebar, page widget, featured page, pages 
    55Requires at least: 3.0 
    6 Tested up to: 3.6 
    7 Stable tag: 1.2 
     6Tested up to: 4.3 
     7Stable tag: 1.3 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1414 
    1515This plugin creates a widget that features a specific page, showing its excerpt. You can also choose a post thumbnail among the registered ones in your theme. 
     16 
     17= Contributing = 
     18[A Featured Page Widget](https://github.com/eduardozulian/a-featured-page-widget) is available on GitHub. If you want to contribute, please fork it and send a pull request! 
    1619 
    1720= Languages = 
Note: See TracChangeset for help on using the changeset viewer.