Plugin Directory

Changeset 949573


Ignore:
Timestamp:
07/16/2014 11:29:30 AM (12 years ago)
Author:
kushsharma
Message:

Added shortcode feature

Location:
kush-micro-news/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kush-micro-news/trunk/assets/css/style.css

    r949376 r949573  
    134134#micro-news-board .editB{
    135135    float:right;
    136     width:50px;
     136    width:70px;
    137137    position:absolute;
    138138    top:0px;
    139     right:25px;
     139    right:45px;
    140140}
    141141
     
    242242
    243243#add-micro-news input[type=submit]{
    244     width:100px;   
    245     padding: 5px;
     244    width:100px;       
    246245}
    247246
  • kush-micro-news/trunk/includes/admin.php

    r949376 r949573  
    7575   
    7676    if(isset($_POST['titleColor']) && $_POST['titleColor']!="")
    77         {
    78             update_option( "kush_mn_color_title",$_POST['titleColor']);
    79             $what='Changes Saved !';
    80         }           
    81        
    82 
     77    {
     78        update_option( "kush_mn_color_title",$_POST['titleColor']);
     79        $what='Changes Saved !';
     80    }
     81   
     82    if(isset($_POST['linkColorField']) && $_POST['linkColorField']!="")
     83    {
     84        update_option( "kush_mn_color_link",$_POST['linkColorField']);
     85        $what='Changes Saved !';
     86    }
    8387   
    8488}
     
    102106            <input type="text" name="myRename" value="<?php echo get_option("kush_mn_widget_name");?>"/>
    103107            <h5 style="display:inline-block;margin:0;">(Try not to use any special character like inverted commas)</h5>
    104         </div>
    105         <div class="options">
    106             <label for="chkBorder">Enable colorful borders:</label>
    107             <input type="checkbox" name="chkBorder" value="true" <?php $sBor=get_option('kush_mn_show_lborder');if($sBor=='true'){echo 'checked';}?>/>
    108         </div>
     108        </div>     
    109109        <div class="options">           
    110110            <label for="titleColor">Title Color:</label>
     
    139139        </div>
    140140        <div class="options">
     141            <label for="linkColorField">Link Color:</label>
     142            <input type="text" name="linkColorField" value="<?php echo get_option('kush_mn_color_link');?>" />
     143            <select name="linkColorList" onclick="check_custom_color(this,'link')">
     144                <option value="#8bbf36">Green [Default]</option>
     145                <option value="#666666">Grey</option>
     146                <option value="#0066CC">Light Blue</option>
     147                <option value="#000000">Black</option>
     148                <option value="#fff2a8">Golden</option>
     149                <option value="#F25555">Red</option>
     150                <option value="#FFD700">Yellow</option>
     151                <option value="#FFB6C1">Pink</option>
     152                <option value="#191970">Midnight Blue</option>             
     153            </select>
     154        </div>
     155        <div class="options">
     156            <label for="chkBorder">Enable colorful borders:</label>
     157            <input type="checkbox" name="chkBorder" value="true" <?php $sBor=get_option('kush_mn_show_lborder');if($sBor=='true'){echo 'checked';}?>/>
     158        </div>
     159        <div class="options">
    141160            <label for="chkHover">Enable link hover effect:</label>
    142161            <input type="checkbox" name="chkHover" value="true" <?php $lHov=get_option('kush_mn_show_linkclean');if($lHov=='true'){echo 'checked';}?>/>
     
    165184        if(elem == 'title')
    166185            form.titleColor.value = obj.value;
    167         else
     186        else if(elem == 'text')
    168187            form.textColor.value = obj.value;
     188        else
     189            form.linkColorField.value = obj.value;
    169190    }   
    170191</script>
  • kush-micro-news/trunk/includes/core.php

    r949376 r949573  
    11<?php
    22
    3 function kush_micro_news_output($no_of_news=0){
     3function kush_micro_news_output($no_of_news=0,$header="true"){
    44    //this is responsible for displaying the final output to user site in widgets or anywhere this function is called!
    5 
     5    //$header attribute will decide whether to show Micro News Header or not
    66global $wpdb;
    77$table_name = $wpdb->prefix . "kushmicronews";
    88
    9     $color = array('#55A4F2','#8bbf36','#fff2a8','#33363B',' #F25555','#222','#999966','#FF66FF');
     9    $color = array('#55A4F2','#8bbf36','#fff2a8','#33363B','#F25555','#666666','#999966','#FF66FF');
    1010    $i=0;//counter for multiple colors.
    1111    if($no_of_news==0)
     
    1616    $titleColor = get_option('kush_mn_color_title');
    1717    $textColor = get_option('kush_mn_color_text');
     18    $linkColor = get_option('kush_mn_color_link');
    1819   
    1920    $rows = $wpdb->get_results( "SELECT * FROM `$table_name` ORDER BY `time` DESC LIMIT 0, $no_of_news ");
    20 ?>
    2121
    22 <div id="micro-news" class="clearfix">
    23     <h2 class="head"><strong><?php echo $widgetName; ?></strong></h2>
    24     <?php
    25     foreach ( $rows as $row )
     22    $output_html = "";//this will contain final output
     23
     24
     25    $output_html .= '<div id="micro-news" class="clearfix">';
     26
     27    if($header=="true"){
     28        $output_html .= '<h2 class="head"><strong>'.$widgetName.'</strong></h2>';
     29    }//header if closed
     30
     31   
     32    foreach ( $rows as $row )       
    2633    {   
    27     ?> 
    28         <div class="wrapNews <?php echo $row->id;?>" style="border-color:<?php if($showBorder=='true'){echo $color[$i];}?>">
    29             <h3 class="title" style="color:<?php echo $titleColor?>"><?php echo $row->name;?></h3>     
    30             <div class="text" style="color:<?php echo $textColor?>"><?php echo $row->text;?>
    31                 <span class="postedOn"> on <?php $date=strtotime($row->time); echo date('d M Y',$date);?></span>
    32             </div>
     34        $date=strtotime($row->time);
     35        $formateddate = date('d M Y',$date);
     36   
     37        $output_html .='<div class="wrapNews '.$row->id.'" style="border-color:';
     38        if($showBorder=='true')//check border color
     39            {$output_html .=$color[$i];}
     40        $output_html .='">';
     41
     42            //show title
     43            $output_html .='<h3 class="title" style="color:'.$titleColor.'">'.$row->name.'</h3>';   
     44           
     45            //show text
     46            $output_html .='<div class="text" style="color:'.$textColor.'">'.$row->text.' ';
     47                $output_html .='<span class="postedOn"> on '.$formateddate.'</span>';
     48            $output_html .='</div>';
    3349           
    34             <?php if($row->url):?>
    35             <span class="link <?php if($cleanHov!='true'){echo 'clean';}?>"><a href="<?php echo $row->url;?>" title="<?php echo $row->name;?>" target="_blank">Read Full story &raquo;</a></span>
    36             <?php endif;?>
    37         </div>
     50            //show url if present
     51            if($row->url):
     52                $output_html .='<span class="link ';
     53                if($cleanHov!='true')//check if show link color inverted
     54                    $output_html .='clean';
     55                $output_html .='"><a href="'.$row->url.'" title="'.$row->name.'" target="_blank" style="color:'.$linkColor.'">Read Full story &raquo;</a></span>';
     56            endif;
     57
     58        $output_html .='</div>';//wrapNews ends
    3859   
    39     <?php
     60        //this will reloop border color
    4061        if($i>=7)
    4162            $i=0;
     
    4465           
    4566    }//foreach loop
    46     ?>
    47 </div>
    48 <?php //micro news ends
     67   
     68$output_html .='</div>';//micro news ends
     69
     70return $output_html;
    4971}//kush_micro_news_output function ends
    5072
     
    165187}
    166188
    167 
    168 
    169189?>
  • kush-micro-news/trunk/index.php

    r949376 r949573  
    33Plugin Name: Kush Micro News
    44Description: Spread the news in shortest possible way. Use links to refer data and title to concise it.
    5 Version: 1.4.0
     5Version: 1.4.1
    66Author: Kush Sharma
    77Author Email: thekushsharma@gmail.com
     
    2121}
    2222add_action('init','kush_micronews_load_depen_reg');
     23add_action('init','kush_micronews_create_shortcode');
    2324
    2425add_action('wp_enqueue_scripts','kush_micronews_load_depen');
    2526add_action('admin_enqueue_scripts','kush_micronews_load_depen');
    2627
     28
     29function kush_micronews_load_depen(){
    2730//load dependent libraries
    28 function kush_micronews_load_depen(){
    29 
    3031    if(is_admin())
    3132        {//load admin files only in admin
     
    5253kush_micronews_load();
    5354
     55function kush_micronews_create_shortcode(){
     56    // this will create shortcode [kushmicronews news="5" header="true"]
     57   
     58    function micronews_shortcode( $atts ) {
     59        $a = shortcode_atts( array( 'news' => '5', 'header' => 'true' ), $atts );
     60
     61        return kush_micro_news_output($a['news'],$a['header']);
     62    }
     63    add_shortcode( 'kushmicronews', 'micronews_shortcode' );
     64}
     65   
     66
    5467register_activation_hook(__FILE__, 'kush_micronews_activation');
    5568register_deactivation_hook(__FILE__, 'kush_micronews_deactivation');
     
    7083           
    7184            echo $before_widget;           
    72             kush_micro_news_output($no_news);           
     85            echo kush_micro_news_output($no_news);         
    7386            echo $after_widget;
    7487        }
     
    153166        add_option('kush_mn_color_title','#0066cc');
    154167        add_option('kush_mn_color_text','#666666');
     168        add_option('kush_mn_color_link','#8bbf36;');
    155169     
    156170    }
    157     kush_mn_install(); 
    158    
     171    kush_mn_install();
     172
    159173}
    160174
  • kush-micro-news/trunk/readme.txt

    r949376 r949573  
    55Requires at least: 3.0.1
    66Tested up to: 3.9.1
    7 Stable tag: 1.4.0
     7Stable tag: 1.4.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626How much better can a plugin be ? Wait there is more :
    2727
    28 *   You can add new news from your wordpress panel with easy GUI interface.
     28*   You can add new news from your wordpress panel with easy GUI interface.
    2929*   Edit/Delete old news if you have messed up something.
    3030*   It is already styled with cool rainbow like colors(not kidding).
     
    3232*   Comes with widget, can be placed where you like.
    3333*   Colors of text and title can be changed from settings.
     34*   Shortcode to output news in post and pages.
    3435*   Developed and maintained by a single guy, so be kind while reporting bugs and don't forget to rate. Thats it!
    3536   
     
    40411. Upload `micro-news-kush` folder to the `/wp-content/plugins/` directory
    41422. Activate the plugin through the 'Plugins' menu in WordPress
    42 3. Place `<?php if(function_exists('kush_micro_news_output')){kush_micro_news_output();} ?>` in your template file.
     433. Place `<?php if(function_exists('kush_micro_news_output')){echo kush_micro_news_output();} ?>` in your template file.
    43444. You can also use Kush Micro News Widget to place in your desired location.
     455. Shortcode [kushmicronews] is also available to show news in a page or post.
    4446
    4547* The location where you gonna output this plugin should have atleast 200px width to present itself well.
     
    5961All of your data is stored in a seperate table inside wordpress database, you can download backup in (.sql) extension anytime you want. This feature is available in Settings page.
    6062
     63= How can i show news in a page or post? =
     64
     65Use shortcode '[kushmicronews news="5" header="true"]' inside wordpress editor where you want news to display itself. You can use this in any of your page or post but keep in mind that page should have enough free space for all the content.
     66-   'news' attribute will decide how many news should be displayed. Default : 5
     67-   'header' attribute will decide whether "Micro News" header is visible. It takes two parameters "true" or "false". Default : "true"
     68
    6169= Will it look like the rest of my site? =
    6270
     
    7583
    7684== Changelog ==
     85
     86= 1.4.1 =
     87* Added feature of shortcode to output news in post & pages
     88* Can change link color
     89* Minor Visual Bug Fix.
    7790
    7891= 1.4.0 =
     
    115128
    116129= 1.0.1 =
    117 * Database connectivity fixed
     130* Database connectivity fixed.
    118131
    119132= 1.0 =
  • kush-micro-news/trunk/uninstall.php

    r949294 r949573  
    1414delete_option('kush_mn_color_title');
    1515delete_option('kush_mn_color_text');
     16delete_option('kush_mn_color_link');
    1617
    1718global $wpdb;
Note: See TracChangeset for help on using the changeset viewer.