Plugin Directory

Changeset 1294734


Ignore:
Timestamp:
11/26/2015 07:45:29 AM (10 years ago)
Author:
dansod
Message:

Version 1.6.0

Location:
subscribe-to-category
Files:
54 added
4 edited

Legend:

Unmodified
Added
Removed
  • subscribe-to-category/trunk/classes/class-settings.php

    r1061089 r1294734  
    9696      // Set class property
    9797      $this->options = get_option( 'stc_settings' );
    98       $time_in_seconds_i18n = strtotime( date_i18n( 'Y-m-d H:i:s' ) ) + $this->get_next_cron_time( 'stc_schedule_email' );
     98      $time_in_seconds_i18n = strtotime( date_i18n( 'Y-m-d H:i:s' ) ) + self::get_next_cron_time( 'stc_schedule_email' );
    9999      $next_run = gmdate( 'Y-m-d H:i:s', $time_in_seconds_i18n );
    100100      ?>
     
    165165     * @since  1.0.0
    166166    */
    167     public function get_next_cron_time( $cron_name ){
     167    public static function get_next_cron_time( $cron_name ){
    168168
    169169      foreach( _get_cron_array() as $timestamp => $crons ){
  • subscribe-to-category/trunk/classes/class-subscribe.php

    r1234449 r1294734  
    1414  $stc_subscribe = new STC_Subscribe();
    1515}
    16 
    1716
    1817  class STC_Subscribe {
     
    724723    }
    725724
     725    /**
     726     * Filter to show categories by attribute 'category_id_in' in shortcode
     727     *
     728     * @param  array  $cats_all All categories
     729     * @param  string $cats_id_in  Categories entered in shortcode
     730     *
     731     * @since 1.6.0
     732     *
     733     * @return array            Array with categories to show
     734     */
     735    private function filter_categories_id_in( $cats_all = '', $cats_id_in = '' ){
     736
     737      if(empty( $cats_all ))
     738        return false;
     739
     740      $cats_id_in = explode(',', str_replace(', ', ',', $cats_id_in ) );
     741
     742      $filtered_cats = array();
     743      foreach( $cats_id_in as $cat_id_in ){
     744        foreach ($cats_all as $cat ) {
     745          if( $cat_id_in == $cat->cat_ID )
     746            $filtered_cats[] = $cat;
     747        }
     748      }
     749
     750      return $filtered_cats;
     751
     752    } 
     753
     754    /**
     755     * Filter to exclude categories by attribute 'category_id_not_in' in shortcode
     756     *
     757     * @param  array  $cats_all    All categories
     758     * @param  string $cats_id_not_in Categories entered in shortcode
     759     *
     760     * @since 1.6.0
     761     *
     762     * @return array                Array with categories to show
     763     */
     764    private function filter_categories_id_not_in( $cats_all = '', $cats_id_not_in = '' ){
     765     
     766      if(empty( $cats_all ))
     767        return false;
     768
     769      $cats_id_not_in = explode(',', str_replace(', ', ',', $cats_id_not_in ) );       
     770
     771        $filtered_cats = $cats_all;
     772         
     773          foreach ($cats_all as $key => $cat ) {
     774
     775            foreach( $cats_id_not_in as $cat_id_not_in ){
     776              if( mb_strtolower( $cat_id_not_in ) == mb_strtolower( $cat->cat_ID ) )
     777                unset($filtered_cats[$key]);
     778            }
     779         
     780        }
     781
     782        return $filtered_cats;
     783 
     784    }     
     785
    726786    /**
    727787     * Html for subscribe form
     
    736796        'category_in' => false,
    737797        'category_not_in' => false,
     798        'category_id_in' => false,
     799        'category_id_not_in' => false,
     800       
    738801      ), $atts ));
    739802
     
    747810      if( !empty( $category_in ) ){
    748811        $cats = $this->filter_categories_in( $cats, $category_in );
     812       
     813      }elseif( !empty( $category_id_in ) ){
     814        $cats = $this->filter_categories_id_in( $cats, $category_id_in );
     815
    749816      }elseif( !empty( $category_not_in ) ){
    750817        $cats = $this->filter_categories_not_in( $cats, $category_not_in );
     818
     819      }elseif( !empty( $category_id_not_in ) ){
     820        $cats = $this->filter_categories_id_not_in( $cats, $category_id_not_in );
     821
    751822      }
    752823
     
    792863
    793864          <div class="stc-categories"<?php echo $post_stc_unsubscribe == 1 ? ' style="display:none;"' : NULL; ?>>
    794             <h3><?php _e('Categories', STC_TEXTDOMAIN ); ?></h3>
    795             <?php if( $this->show_all_categories === true ) : ?>
    796             <div class="checkbox">
    797               <label>
    798                 <input type="checkbox" id="stc-all-categories" name="stc_all_categories" value="1">
    799                 <?php _e('All categories', STC_TEXTDOMAIN ); ?>
    800               </label>
    801             </div>
     865            <?php if(! empty( $cats )) :?>
     866              <?php if (count ($cats) > 1 ) : ?>
     867                <h3><?php _e('Categories', STC_TEXTDOMAIN ); ?></h3>
     868                <?php if( $this->show_all_categories === true ) : ?>
     869                  <div class="checkbox">
     870                    <label>
     871                      <input type="checkbox" id="stc-all-categories" name="stc_all_categories" value="1">
     872                      <?php _e('All categories', STC_TEXTDOMAIN ); ?>
     873                    </label>
     874                  </div>
     875                <?php endif; ?>
     876              <?php endif; ?>
     877              <div class="stc-categories-checkboxes">
     878                <?php if(count($cats)>1 ) : ?>
     879                  <?php foreach ($cats as $cat ) : ?>
     880                    <div class="checkbox">
     881                  <label>
     882                    <input type="checkbox" name="stc_categories[]" value="<?php echo $cat->cat_ID ?>">
     883                    <?php echo $cat->cat_name; ?>
     884                  </label>
     885                    </div>
     886                  <?php endforeach; ?>
     887                <?php else: ?>
     888                  <input type="hidden" name="stc_categories[]" value="<?php echo $cats[0]->cat_ID ?>">
     889                <?php endif; ?>
     890              </div><!-- .stc-categories-checkboxes -->
    802891            <?php endif; ?>
    803             <div class="stc-categories-checkboxes">
    804             <?php if(! empty( $cats ) ) : ?>
    805                     <?php foreach ($cats as $cat ) : ?>
    806             <div class="checkbox">
    807                     <label>
    808                         <input type="checkbox" name="stc_categories[]" value="<?php echo $cat->cat_ID ?>">
    809                         <?php echo $cat->cat_name; ?>
    810                     </label>
    811             </div>
    812                   <?php endforeach; ?>
    813           <?php endif; ?>
    814           </div><!-- .stc-categories-checkboxes -->
    815892          </div><!-- .stc-categories -->
     893
    816894
    817895                <input type="hidden" name="action" value="stc_subscribe_me" />
  • subscribe-to-category/trunk/readme.txt

    r1234449 r1294734  
    33Tags: subscribe to post, subscribe to category, subscribe to news, subscribe
    44Requires at least: 3.9
    5 Tested up to: 4.3
    6 Stable tag: 1.3
     5Tested up to: 4.3.1
     6Stable tag: 1.6.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2828*   Options for leave no trace - deletes post meta and subscribers created by this plugin.
    2929*   Option for re-send a post on update that has already been sent.
    30 *   Shortcode attributes for showing and hiding some categories from subscribe form.
     30*   Implementation by widget or short code.
    3131
    3232
     
    49492. Activate the plugin through the 'Plugins' menu in WordPress Admin
    50503. Save your settings 'Settings > Subscribe'.
    51 4. Create a page and add shortcode [stc-subscribe] to display stc form subscription.
     514. Create a page and add shortcode [stc-subscribe] or use the STC Widget to display stc form subscription.
    5252
    5353= Shortcode Attributes =
    5454'category_in' - Use this attribute if you only want one or several categories to be available for subscription. Value to be entered is the name of the category.
     55'category_id_in' - The difference to above is to use the category ID instead of category name.
     56
    5557'category_not_in' - Use this attribute if you want to exclude categories to be available for subscription. Value to be entered is the name of the category.
     58'category_id_not_in' - The difference to above is to use the category ID instead of category name.
    5659
    57 For both attributes you can use a comma sign to separate multiple categories, like [stc-subscribe category_in="news, article"].
     60For the above attributes you can use a comma sign to separate multiple categories, like [stc-subscribe category_in="news, article"].
    5861
    5962= Filter and hooks =
     
    105108== Changelog ==
    106109
     110= 1.6.0 =
     111* Added a Widget for subscription form
     112* Don't show category list if only one is available (thanks to davefx)
     113* Extended short code attributes with an option to use category id instead of category name (thanks to Stingray_454)
     114
    107115= 1.3 =
    108116* Added hooks and filters to make the plugin extensible
     
    117125* Possibillity to re-send a post on update that has already been sent. This option needs to be activated in the settings for the plugin.
    118126* Attribute 'category_in' added to shortcode to show only entered categories in the subscribe form. Multiple categories are separated by a comma sign.
    119 * Attribute 'category_not_in' added to shortcode to exclude categories in the subscribe form. Multiple categories are separated by a comma sign.
     127* Attribute 'category_not_in' added to shortcode to exclude categories in the subscribe form. Multiple categories are separated by a comma sign. 
    120128
    121129
  • subscribe-to-category/trunk/subscribe-to-category.php

    r1234449 r1294734  
    44  Plugin URI: http://dcweb.nu
    55  Description: Lets your visitor subscribe to posts for one or several categories.
    6   Version: 1.3
     6  Version: 1.6.0
    77  Author: Daniel Söderström
    88  Author URI: http://dcweb.nu/
     
    2323  require_once( 'classes/class-settings.php' );
    2424  require_once( 'classes/class-subscribe.php' );
     25  require_once( 'classes/class-stc-widget.php' );
    2526
    2627  // Create instance for main class
Note: See TracChangeset for help on using the changeset viewer.