Plugin Directory

Changeset 1580310


Ignore:
Timestamp:
01/23/2017 01:10:48 PM (9 years ago)
Author:
happymox
Message:

new SPP version 1.2.0

Location:
selectable-post-and-page/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • selectable-post-and-page/trunk/assets/css/wp-spp-admin.css

    r1565380 r1580310  
    4646}
    4747
    48 .spp-excerpt-length input{
     48.spp-excerpt-length input,
     49.spp-random-post-num input,
     50.spp-right input{
    4951    float: right;
    5052    text-align: center;
    5153}
    5254
     55.spp-right-2 input{
     56    float: right;
     57    text-align: left;
     58}
     59
  • selectable-post-and-page/trunk/assets/js/wp-spp-admin.js

    r1565380 r1580310  
    2121       
    2222        if ( post_type === 'Page' ) {
    23             //$( parent_next_p ).hide();
    2423            $( parent_next_p ).slideUp();
    2524            get_selected_data( false, widget_id, rlt_cont, orderby, order, saved_posts );
     
    2827        if ( post_type === 'Post' ) {
    2928            var cat_val = $( parent_next_p ).find( 'select' ).val();
    30             //$( parent_next_p ).show();
    3129            $( parent_next_p ).slideDown();
    3230            get_selected_data( cat_val, widget_id, rlt_cont, orderby, order, saved_posts );
     
    8381            $( container ).empty().html(d);
    8482        });
    85         /*
    86         $.ajax({
    87             url: ajaxurl,
    88             type: 'GET',
    89             cache: false,
    90             data: {
    91                 action: 'wp_spp_category_result_edit_form',
    92                 cat: selected_cat,
    93                 id: widget_id,
    94                 page: ( selected_cat === false ) ? true : false
    95             },
    96             success: function( d ){
    97                 $( container ).empty().html(d);
    98             }
    99         });*/
    10083    }
    10184
     
    11497        }
    11598    });
     99   
     100    $( 'body' ).on( 'change', 'input[type=checkbox]', function( e ){
     101        var id = $( this ).attr( 'id' );
     102        if ( id.indexOf( 'random_post' ) !== -1) {
     103            if (  $(this).is(':checked') ) {
     104                $( ".spp-result-list" ).slideUp();
     105                $( ".spp-random-post-num" ).slideDown();
     106            } else {
     107                $( ".spp-result-list" ).slideDown();
     108                $( ".spp-random-post-num" ).slideUp();
     109            }
     110        }
     111    });
    116112});
  • selectable-post-and-page/trunk/readme.txt

    r1565588 r1580310  
    11=== Selectable Post and Page ===
    22Contributors: HappyMox, odonbaatar
    3 Tags: widget, categories, feature image, posts, recent posts, tags, thumbnails, widget, widgets
     3Tags: widget, widgets, posts, categories, pages, feature image, random post, post thumbnails, random featured images
    44Requires at least: 4.7
    55Tested up to: 4.7
     
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    9 
    10 An advanced posts display widget with many options. Display posts in your sidebars any way you'd like!
    119
    1210== Description ==
     
    1816* Use for any sidebar.
    1917* Get post(s) directly by a list of selected posts.
    20 * Widget to display the post feature image.
     18* Widget to display the post feature image.
     19* It will be displayed at random as the featured image of any post without an image.
    2120
    2221== Installation ==
     
    2726== Screenshots ==
    2827Use for widget and sidebar
    29 1. Configuring a Selectable Post and Page in wp-admin with the Post and selected category displayed.
    30 1. Configuring a Selectable Post and Page in wp-admin with the selected page in lists displayed.
    31 1. Location of a Selectable Post and Page in wp-admin with widgets displayed.
    32 1. In the fontpage, sigle page or post and category list: Selectable Post and Page displayed pages(named by chrismas day and children's day) using right sidebar.
    33 1. In the fontpage, sigle page or post and category list: Selectable Post and Page displayed selected post (Post World's fastest land Animal is now racing, category: Fastest Animal) by category.
    34 1. In the footer of site: Displaying a selected post and pages.
    35 
    36 
    3728
    3829== Changelog ==
     30= 1.2.0 =
     31* Added Random Post option.
     32* Improve some code.
     33* Added input of "More" and "Date".
     34
    3935= 1.0.0 =
    4036* Initial release.
  • selectable-post-and-page/trunk/selectable-post-and-page.php

    r1565380 r1580310  
    22/*
    33Plugin Name: Selectable Post and Page
    4 Plugin URI: http://happymox.wordpress.com/2016/12/28/selectable-post-and-page/
    5 Description: Adds a widget that can display posts from a single category and page.
     4Plugin URI: https://wordpress.org/plugins/selectable-post-and-page/
     5Description: Add a widget that can display posts from random, a single category and page.
    66Author: HappyMox
    77Text Domain: selectable-post-and-page
    8 Version: 1.0.0
     8Version: 1.2.0
    99Author URI: http://happymox.wordpress.com
    1010*/
     
    1414
    1515if( !defined( 'WP_SPP_VERSION' ) ) {
    16     define( 'WP_SPP_VERSION', '1.0.0' ); // Version of plugin
     16    define( 'WP_SPP_VERSION', '1.2.0' ); // Version of plugin
    1717}
    1818
     
    3939// Script File
    4040require_once( WP_SPP_DIR . '/include/class-wp-spp-script.php' );
     41
    4142
    4243/**
     
    6768                array( $this, 'wp_spp_category_result_edit_form' )
    6869        );
     70       
     71        // custom image cropped for SPP
     72        add_image_size( 'spp-widget-thumb', 100, 100, true );
    6973    }
    7074   
     
    8387            }
    8488    }
    85    
    86         if( isset( $instance["posts"] ) ){
    87             // Get array of post info.
    88             $cat_posts = new WP_Query( array( 'post__in' => $instance["posts"],
     89       
     90        // Get array of post info.
     91        if( isset( $instance["random_post"] ) ) {
     92            $qry_arg = array( 'posts_per_page' => $instance["random_post_num"],
     93                'post_status' => 'publish',
     94                'post_type'=> strtolower( $instance['post_type'] ),
     95                'orderby' => 'rand');
     96        } else if( isset( $instance["posts"] ) ){
     97            $qry_arg = array( 'post__in' => $instance["posts"],
    8998                'post_status' => 'publish',
    9099                'post_type'=> strtolower( $instance['post_type'] ),
    91100                'orderby' => $instance['orderby'],
    92                 'order' => $instance[ 'order_type' ])
    93             );
     101                'order' => $instance[ 'order_type' ]);
     102        } else {
     103            $qry_arg = '';
     104        }
     105       
     106        if ( $qry_arg != '' ) {
     107            $cat_posts = new WP_Query( $qry_arg );
    94108        }
    95109
     
    104118                "return '...<div  style=\"text-align: right;\">"
    105119                . "<a href=\"' . get_permalink() . '\">"
    106                 . __( '> More', 'selectable-post-and-page' )
     120                . __( '> ' . $instance['more_text'], 'selectable-post-and-page' )
    107121                . "</a></div>';"
    108122        );
     123       
    109124
    110125    if( absint( $instance['excerpt_length'] ) > 0 ){
     
    119134        if( isset( $cat_posts ) ){
    120135            while( $cat_posts->have_posts() ){
    121                 $cat_posts->the_post();?>
     136                $cat_posts->the_post(); ?>
    122137                <div class="post-item">
    123                     <h4 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
    124                     <?php if ( isset( $instance['post_date'] ) ):?>
    125                     <p class="post-meta">Date <?php the_time('m/d/Y'); ?></p>
     138                    <h4 class="post-title">
     139                        <a href="<?php the_permalink();?>" rel="bookmark" title="<?php the_title_attribute();?>">
     140                            <?php the_title();?>
     141                        </a>
     142                    </h4>
     143                    <?php //if ($instance['post_date'] == false):?>
     144                    <?php if (!isset( $instance['post_date'] )):?>
     145                    <div style="height: 3px;"></div>
    126146                    <?php endif; ?>
    127147                   
    128                     <?php if ( function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && has_post_thumbnail() ) : ?>
     148                    <?php if (isset( $instance['post_date'] )):?>
     149                    <p class="post-meta"><?php echo $instance['date_text'];?> <?php the_time('m/d/Y');?></p>
     150                    <?php endif; ?>
     151                   
     152                    <?php if (function_exists('the_post_thumbnail') && current_theme_supports("post-thumbnails") && has_post_thumbnail()): ?>
    129153                    <div class="post-thumbnail-side">
    130154                        <a class="thumbnail-frame-side" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><!-- nothing to see here --></a>
     
    132156                    </div>
    133157                    <?php endif; ?>
    134 
     158                   
     159                    <?php if( $instance['excerpt_length'] > 0 ):?>
    135160                    <div class="cat-post-content">
    136                         <?php if( $instance['excerpt_length'] > 0 ):?>
    137                         <?php the_excerpt(); ?>
    138                         <?php endif; ?>
     161                        <?php the_excerpt();?>
    139162                    </div>
     163                    <?php endif; ?>
    140164                </div><?php
    141165            }
     
    168192        $instance['post_type'] = isset( $instance[ 'post_type' ] ) ? $instance['post_type'] : 'Post';
    169193        $instance[ 'post_date' ] = isset( $instance[ 'post_date' ] ) ? $instance[ 'post_date' ] : false;
     194        $instance[ 'random_post' ] = isset( $instance[ 'random_post' ] ) ? $instance[ 'random_post' ] : false;
     195        $instance[ 'random_post_num' ] = ( isset( $instance[ 'random_post_num' ] ) && $instance[ 'random_post_num' ] > 0 ) ? $instance[ 'random_post_num' ] : 1;
     196       
     197        $instance['more_text'] = isset( $instance[ 'more_text' ] ) ? $instance['more_text'] : 'More';
     198        $instance['date_text'] = isset( $instance[ 'date_text' ] ) ? $instance['date_text'] : 'Date';
    170199        $output = '';
    171200       
    172         $cat = ($instance['post_type'] == 'Page')? false :$cat;
     201        $cat = ($instance['post_type'] == 'Page')?false:$cat;
    173202       
    174203        $args = array( 'posts_per_page' => 100,
     
    180209        );
    181210        $selected_posts = new WP_Query( $args );
    182        
    183      
     211
    184212        if( isset( $selected_posts ) ) {
    185213            $num = 1;
     
    205233            <label for="<?php echo $this->get_field_id( "hide_widget_title" );?>">
    206234                <input type="checkbox" id="<?php echo $this->get_field_id( "hide_widget_title" ); ?>" name="<?php echo $this->get_field_name( "hide_widget_title" ); ?>" <?php checked( (bool) $instance['hide_widget_title'], true ); ?> />
    207                 <?php _e( "Hide Title", 'selectable-post-and-page' ); ?>
     235                <?php _e( "Hide Widget title", 'selectable-post-and-page' ); ?>
    208236            </label>
    209237        </p>
     
    220248                <label for="<?php echo $this->get_field_id( "post_type" ) . $value; ?>">
    221249                    <?php _e( $desc, 'selectable-post-and-page' ); ?>
    222             </label>
     250                </label>
    223251            <?php }?>
    224252               
     
    257285            </select>
    258286        </p>
    259         <p class="spp-result-list">
    260             <h4><?php _e( 'Selectable Posts', 'selectable-post-and-page' ); ?>:</h4>
    261             <div class="selectablepost-<?php echo $this->number . $this->id_base;?> spp-category_result">
    262                <?php echo $output;?>
     287        <p>
     288            <input type="checkbox" id="<?php echo $this->get_field_id( "random_post" )?>" name="<?php echo $this->get_field_name( "random_post" )?>" <?php checked( (bool) $instance['random_post'], true ); ?> />
     289            <label for="<?php echo $this->get_field_id( "random_post" )?>">
     290                <?php _e( 'Random post', 'selectable-post-and-page' ); ?>
     291            </label>
     292        </p>
     293        <p class="spp-random-post-num"<?php echo ($instance['random_post'] == false)?' style="display: none;"':'' ?>>
     294            <label for="<?php echo $this->get_field_id( "random_post_num" ); ?>">
     295                <?php _e( 'Number of posts to show:', 'selectable-post-and-page' ); ?>
     296            </label>
     297            <input type="text" id="<?php echo $this->get_field_id( "random_post_num" ); ?>" name="<?php echo $this->get_field_name( "random_post_num" ); ?>" value="<?php echo absint($instance['random_post_num']); ?>" size="3" />
     298    </p>
     299        <div class="spp-result-list"<?php echo ($instance['random_post'] != false)?' style="display: none;"':'' ?>>
     300            <h4><?php _e( 'Selectable Posts:', 'selectable-post-and-page' ); ?></h4>
     301            <div class="<?php echo 'selectablepost-'.$this->number . $this->id_base. ' spp-category_result'; ?>">
     302               <?php echo $output; ?>
    263303            </div>
    264         </p>
     304        </div>
     305       
    265306        <p class="spp-excerpt-length">
    266307            <label for="<?php echo $this->get_field_id( "excerpt_length" ); ?>">
     
    269310            <input type="text" id="<?php echo $this->get_field_id( "excerpt_length" ); ?>" name="<?php echo $this->get_field_name( "excerpt_length" ); ?>" value="<?php echo absint($excerpt_length); ?>" size="3" />
    270311    </p>
     312        <!--------- Begin: More ------------->
    271313        <p>
    272314            <input type="checkbox" id="<?php echo $this->get_field_id( "read_more_link" )?>" name="<?php echo $this->get_field_name( "read_more_link" )?>" <?php checked( (bool) $instance['read_more_link'], true ); ?> />
     
    275317            </label>
    276318        </p>
     319        <p class="spp-right-2">
     320            <label for="<?php echo $this->get_field_id( "more_text" ); ?>">
     321                <?php _e( 'Text (for more):', 'selectable-post-and-page' ); ?>
     322            </label>
     323            <input type="text" id="<?php echo $this->get_field_id( "more_text" ); ?>" name="<?php echo $this->get_field_name( "more_text" ); ?>" value="<?php echo $instance['more_text']?>" size="23" />
     324        </p>
     325        <!--------- End: More ------------->
    277326        <p>
    278327            <input type="checkbox" id="<?php echo $this->get_field_id( "post_date" )?>" name="<?php echo $this->get_field_name( "post_date" )?>" <?php checked( (bool) $instance['post_date'], true ); ?> />
     
    280329                <?php _e( 'Display Post\'s Date', 'selectable-post-and-page' ); ?>
    281330            </label>
     331        </p>
     332        <p class="spp-right-2">
     333            <label for="<?php echo $this->get_field_id( "date_text" ); ?>">
     334                <?php _e( 'Text (for date):', 'selectable-post-and-page' ); ?>
     335            </label>
     336            <input type="text" id="<?php echo $this->get_field_id( "date_text" ); ?>" name="<?php echo $this->get_field_name( "date_text" ); ?>" value="<?php echo $instance['date_text']?>" size="23" />
    282337        </p>
    283338    <?php
     
    331386
    332387add_action( 'widgets_init', create_function( '', 'return register_widget("Selectable_Post_And_Page");' ) );
     388
     389function SPP_activate(){
     390    //add_action( 'widgets_init', create_function( '', 'return register_widget("Selectable_Post_And_Page");' ) );
     391}
     392register_activation_hook( WP_SPP_DIR, 'SPP_active' );
     393//register_activation_hook( WP_SPP_DIR, array( 'Selectable_Post_And_Page', 'SPP_active') );
     394
     395
     396
     397
Note: See TracChangeset for help on using the changeset viewer.