Plugin Directory

Changeset 910600


Ignore:
Timestamp:
05/08/2014 04:35:01 PM (12 years ago)
Author:
sanny_rss
Message:

Version 1.1

Location:
wp-auto-featured-image/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-auto-featured-image/trunk/css/wafi-style.css

    r898584 r910600  
    8585  padding-bottom: 15px;
    8686}
     87.note {
     88  color: #706C6C;
     89  float: left;
     90  font-size: 12px;
     91  width: 100%;
     92}
     93div.updated {
     94  float: left;
     95  width: 98%;
     96}
     97form.paypal select, form.paypal input{
     98  float: left;
     99}
     100form.paypal {
     101  float: left;
     102  margin-bottom: 10px;
     103  width: 100%;
     104}
  • wp-auto-featured-image/trunk/js/wafi-script.js

    r900041 r910600  
    4545        jQuery('.button-primary').click();
    4646    }   
     47   
     48   
     49    jQuery('.cat_include').click(function(){
     50        jQuery('.cat_include').prop('checked',false);
     51        jQuery('.cat_include').prop('checked',true);
     52    });
    4753});
    4854
  • wp-auto-featured-image/trunk/readme.txt

    r900041 r910600  
    11=== Wordpress Auto Featured Image ===
    22Contributors: sanny_rss
    3 Tags: Featured Image, Auto Featured Image, Default Featured Image, Auto, Default, Post Thumbnail, Auto Post Thumbnail, Set Post Thumbnail
     3Tags: Featured Image, Auto Featured Image, Default Featured Image, Auto, Default, Post Thumbnail, Auto Post Thumbnail, Set Post Thumbnail, Auto Post Thumbnail, WordPress Post Thumbnail
    44Donate link: http://royalsoftwareservices.com/donate/
    55Requires at least: 3.0
    66Tested up to: 3.9
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1212
    1313== Description ==
    14 Bored to set default images each time for a page, post or custom type or want a image to auto attach as thumbnail if a user ignores setting up a thumbnail? Here is the solution:
     14Bored to set default images each time for a page, post or custom type or want an image to auto set as thumbnail if a user ignores setting up a thumbnail? Here is the solution:
    1515
    1616This plugin provides you an easy way to set a default thumbnail image for your posts, pages or custom post types. You can select an image from your local machine or media library.
    1717
    18 You can access this from the WordPress dashboard => "WAFI" (admin menu)
     18You can access this from the WordPress dashboard under Settings => "WAFI" (admin menu)
    1919
    2020Option to choose:
    2121
    2222* Select an image to set.
     23* Select for specific categories.
    2324* Choose post types for which it will trigger.
    2425
     
    5152== Changelog ==
    5253
     54= 1.1 =
     55* Restrict to specific categoriers.
     56* Allow Categories for all post types or for POST only.
     57* Menu moved under 'Settings'.
     58
    5359= 1.0 =
    5460* First release.
     
    5763== Upgrade Notice ==
    5864
     65= 1.1 =
     66* Restrict to specific categoriers.
     67* Allow Categories for all post types or for POST only.
     68* Menu moved under 'Settings'.
     69
    5970= 1.0 =
    6071First Version.
  • wp-auto-featured-image/trunk/wp-auto-featured-image.php

    r900157 r910600  
    3737define( 'WP_Auto_FI_DIR', WP_PLUGIN_DIR . '/wp-auto-featured-image' );
    3838define( 'WP_Auto_FI_URL', WP_PLUGIN_URL . '/wp-auto-featured-image' );
     39define( 'WP_Auto_ADMIN_URL', get_admin_url(null, 'admin.php?page=wp_auto_featured_image')  );
    3940
    4041
     
    4243add_action('admin_menu', 'wpafi_admin_add_page');
    4344function wpafi_admin_add_page() {
    44     add_menu_page('Wordpress Auto Featured Image', 'WP AFI', 'manage_options', 'wp_auto_featured_image', 'wpafi_start');
    45 }
     45    add_options_page('Wordpress Auto Featured Image', 'WP AFI', 'manage_options', 'wp_auto_featured_image', 'wpafi_start');
     46}
     47
     48# Setting option in PLUGIN page
     49add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'my_plugin_action_links' );
     50function my_plugin_action_links( $links ) {
     51   $links[] = '<a href="'. WP_Auto_ADMIN_URL.'">Settings</a>';
     52   $links[] = '<a href="http://www.royalsoftwareservices.com/plugins/" target="_blank">Documentation</a>';
     53   return $links;
     54}
     55
     56
    4657
    4758# Menu Callback and backend design
    4859function wpafi_start() { ?>
    4960<div class="wrap wp_afi">
     61<?php if( isset($_GET['settings-updated']) ) { ?>
     62    <div id="message" class="updated">
     63        <p><strong><?php _e('Settings saved.') ?></strong></p>
     64    </div>
     65<?php } ?>
    5066<h2>Wordpress Auto Featured Image</h2>
    5167<div class="content_area">
     
    6985                <div class="inside">
    7086                <p class="multi-option">Have you encountered any problem with our plugin and need our help? Do you need to ask us any question?</p>
    71                 <p>You can post your question or issues at WordPress <a target="_blank" href="http://wordpress.org/support/plugin/wp-auto-featured-image">Support</a> or can directly mail me at <a href="mailto:[email protected]">[email protected]</a>.</p>
     87                <p>You can post your question or issues at WordPress <a target="_blank" href="http://wordpress.org/support/plugin/wp-auto-featured-image">Support</a> or can directly  <a href="mailto:[email protected]?subject=Support Request For Wordpress Auto Featured Image From <?php bloginfo('url');?>">mail me</a>.</p>
    7288              </div>
    7389        </div>
     
    7995                <div class="inside">
    8096                <p class="multi-option">
    81                 We need your support to make this and other plugins more smarter and helpful for you, if this plugin saved few minutes of your effort, kindly get some time for a favor to us and</p>
    82                 <p>1) <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-auto-featured-image">Rate this plugin.</a><br/>
    83                  2) Make a small <a href="http://www.royalsoftwareservices.com/donate/" target="_blank"> donation</a> for us. </p>
     97                We need your support to make this and other plugins more smarter and helpful for you, if this plugin saved any minutes of your timeffort, kindly get some time for a favor to us and</p>
     98                <p>
     99                 1) <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-auto-featured-image">Rate this plugin.</a><br/>
     100                 2) Make a small <a href="http://www.royalsoftwareservices.com/donate/" target="_blank"> donation</a> for us.
     101                </p>
     102<form target="_blank" class="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" name="_xclick">
     103<input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="[email protected]" />
     104<input type="hidden" name="item_name" value="Donate for plugin support" /><input type="hidden" name="currency_code" value="USD" />
     105<select name="amount">
     106<option value="05.00">05</option>
     107<option value="10.00">10</option>
     108<option value="15.00">15</option>
     109<option value="20.00">20</option>
     110<option value="25.00">25</option>
     111<option value="50.00">50</option>
     112</select>
     113<input type="image" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" />
     114</form>
    84115                <p>Any help would be very appreciated. Thanks for using this plugin.<br/>
    85116                Have a good day!!</p>
     117              </div>
     118        </div>
     119    </div>   
     120    <div class="metabox-holder">
     121        <div class="postbox-container postbox" style="width: 99%;"> 
     122                <h3 class="hndle"><span>Hire Me</span></h3>
     123                <div class="inside">
     124                <p class="multi-option">Do you want more customization on this plugin? or want to develope a new plugin?</p>
     125                <p><strong><a href="mailto:[email protected]?subject=Hire Request From <?php bloginfo('url');?>">Hire me</a> at just $15/hour.</strong></p>
    86126              </div>
    87127        </div>
     
    98138    add_settings_section('wpafi_main', 'General Settings', 'wpafi_desp', 'wp_auto_featured_image');
    99139    add_settings_field('wpafi_post_type', 'Include Post Types:', 'wpafi_post_types', 'wp_auto_featured_image', 'wpafi_main');
     140    add_settings_field('wpafi_categories', 'Only for these categories:', 'wpafi_categories', 'wp_auto_featured_image', 'wpafi_main');   
     141    add_settings_field('wpafi_categories_all', 'Apply categories filter for all post types:', 'wpafi_categories_all', 'wp_auto_featured_image', 'wpafi_main');
    100142    add_settings_field('wpafi_default_thumb', 'Set Default Thumbnail:', 'wpafi_default_thumb', 'wp_auto_featured_image', 'wpafi_main');
    101143    add_settings_field('wpafi_default_thumb_id', '', 'wpafi_default_thumb_id', 'wp_auto_featured_image', 'wpafi_main');
     
    127169}
    128170
     171function wpafi_categories_all() {
     172$options = get_option('wpafi_options');
     173// print_r($options);
     174
     175if($options['wpafi_categories_all'] == 'yes'){
     176    $yes = 'checked="checked';
     177    $no = '';
     178} else {
     179    $no = 'checked="checked';
     180    $yes = '';
     181}
     182        echo '
     183        <input type="radio" '.$yes.' class="cat_include" name="wpafi_options[wpafi_categories_all]" id="wpafi_text_string-yes" value="yes" />
     184        <label class="post-type" for="wpafi_text_string-yes">Yes</label>
     185        <input type="radio" '.$no.' class="cat_include" name="wpafi_options[wpafi_categories_all]" id="wpafi_text_string-no" value="no" />
     186        <label class="post-type" for="wpafi_text_string-no">No</label>';
     187        echo '<span class="note clear">If you set `yes`, only posts (for all selected post types) will be modified that comes under selected categories, if `no` is selected category restriction will only work for WordPress default posts. This setting will not effect for pages.</span>';
     188}
     189
     190
     191function wpafi_categories() {
     192$options = get_option('wpafi_options');
     193$wpafi_cats = get_categories( array('type'=> 'post','hide_empty'=> 0,'orderby' => 'name', 'order'=> 'ASC' ));
     194
     195    foreach ( $wpafi_cats as $wpafi_cat ) {
     196        $selected = '';
     197        if($options['wpafi_categories']) {
     198            if((is_array($options['wpafi_categories'])) && (in_array($wpafi_cat->slug,$options['wpafi_categories']))) { $selected = " checked='checked'"; }
     199        }
     200        echo '
     201        <input type="checkbox"'.$selected.' name="wpafi_options[wpafi_categories][]" id="wpafi_text_string-'.$wpafi_cat->slug.'" value="'.$wpafi_cat->slug.'" />
     202        <label class="post-type" for="wpafi_text_string-'.$wpafi_cat->slug.'">'.$wpafi_cat->name.'</label>';
     203    }
     204    echo '<span class="note clear">Leave this unchecked if you want to work this plugin for all categories. This setting will not effect for pages.</span>';
     205}
     206
    129207function wpafi_default_thumb() {
    130208$options = get_option('wpafi_options');
    131209    if(empty($options['wpafi_default_thumb'])) {
    132210        echo '<input type="text" id="default_thumb_url" name="wpafi_options[wpafi_default_thumb]" value="" />                         
    133               <input id="upload_default_thumb" class="button" type="button" value="Upload Image" />';
     211              <input id="upload_default_thumb" class="button" type="button" value="Upload Thumbnail" />';
    134212    } else {
    135213        echo '
    136         <input id="upload_default_thumb" class="button" type="button" value="Update Image" />
     214        <input id="upload_default_thumb" class="button" type="button" value="Update Thumbnail" />
    137215        <input type="hidden" id="default_thumb_url" name="wpafi_options[wpafi_default_thumb]" value="'.$options["wpafi_default_thumb"].'" />
    138216        <input id="delete_thumb" name="delete_thumb" type="button" class="button" value="Delete Thumbnail" />
     
    181259add_action('save_post', 'wpfi_set_thumbnail' );
    182260function wpfi_set_thumbnail( $post_id ) {
    183 global $wpdb;
    184 extract($_POST);
    185 $options = get_option('wpafi_options');
    186 
    187 
    188 if(!empty($options['wpafi_post_type'])){
    189     # Check if this suppose to be set thumbnail
    190     if(empty($options['wpafi_post_type'])){
    191     return;
    192     }
    193     if((in_array($post_type, $options['wpafi_post_type']) == 0) || has_post_thumbnail( $post_id ) || empty($options['wpafi_default_thumb_id'])) {
    194         return;
    195     }
    196    
    197     # Set thumbnail here
    198     set_post_thumbnail( $post_id, $options['wpafi_default_thumb_id']); 
    199 }   
     261   
     262    global $wpdb;
     263    extract($_POST);
     264    $options = get_option('wpafi_options');
     265
     266    # Check if this suppose to be set thumbnail.
     267    if((!empty($options['wpafi_post_type'])) && (is_array($options['wpafi_post_type'])) && (in_array($post_type, $options['wpafi_post_type']) != 0) && (has_post_thumbnail( $post_id ) == false)) {
     268   
     269        # If category filter is on.
     270        if((is_array($options['wpafi_categories'])) && ($post_type != 'page')){
     271               
     272                #if restricted for default POST
     273                if($options['wpafi_categories_all'] == 'no'){
     274                    if(in_category($options['wpafi_categories'], $post_id) && ($post_type == 'post')){
     275                        # Set thumbnail here
     276                        set_post_thumbnail( $post_id, $options['wpafi_default_thumb_id']);
     277                    }           
     278                } elseif($options['wpafi_categories_all'] == 'yes'){
     279                    if(in_category($options['wpafi_categories'], $post_id)){
     280                        # Set thumbnail here
     281                        set_post_thumbnail( $post_id, $options['wpafi_default_thumb_id']);
     282                    }
     283                }
     284        } else {
     285            # Set thumbnail here
     286            set_post_thumbnail( $post_id, $options['wpafi_default_thumb_id']);
     287        }
     288    }
    200289}
    201290
Note: See TracChangeset for help on using the changeset viewer.