WordPress.org

Support

Support » Plugins and Hacks » [Plugin: St-Daily-Tip] Request addition of Title and Listview

[Plugin: St-Daily-Tip] Request addition of Title and Listview

  • glenjochy

    @glenjochy

    For my own usage of ST Daily Tips, I’ve added one extra field to hold a Title, and an extra function to display all previously shown tips.

    Could you please add this to the standard plugin, so I won’t have to add my changes with every update of the plugin?

    st-daily-tip.php changes:

    function select_tipprevlist(){
    	global $wpdb;
    	global $table_suffix;
    
    	$ptipresult = "";
    	$ptable_name = $wpdb->prefix . $table_suffix;
    	$ptable_result = $wpdb->get_results($wpdb->prepare("SELECT TipTitle, tip_text, shown_date FROM $ptable_name WHERE Shown_Date != '0000-00-00' AND DATE(Shown_Date)<DATE(NOW()) ORDER BY DATE(Shown_Date) DESC;"));
    
    	foreach ( $ptable_result as $ptable_row )
    	{
    		$item_tip = $ptable_row->tip_text;
    		$item_title = $ptable_row->TipTitle;
    		$item_lastshown = $ptable_row->shown_date;
    		$formatted_item_lastshown = date("d-m-Y", strtotime($item_lastshown));
    		if ($item_tip != null) {
    			$ptipresult .= "<div style='line-height: 1.4em; margin: 10px 30px 5px 10px;'><div style='color:#808080'>" . $formatted_item_lastshown . ": " . $item_title . "</div><div style='margin:0px 15px 0px 25px;'>" . $item_tip . "</div></div>";
    		}
    	}
    
    	return $ptipresult;
    }
    
    function add_daily_tipprevlist($text)
    {
    	$tiplist = select_tipprevlist();
    	$text = str_replace("[stdailytiplist]", $tiplist, $text);
    	return $text;
    }
    
    add_filter('the_content','add_daily_tipprevlist');

    in function select_today_tip, just before returning $today_tip:

    //combine title and tip content
    		$today_tip = "<h2><strong>" . $today_tipTitle . "</strong></h2><div>" . $today_tip . "</div>";

    and then ofcourse the added field in the table:
    in update:

    $wpdb->query("alter table ". $table_name ." add column TipTitle text NOT NULL");

    or in create

    TipTitle text NOT NULL,

    And the necessary changes to the admin page to enter the titles.

    Would you be so kind as to add this functionality to your version of the plugin? Any changes you deem necessary are welcome ofcourse… I’m very unexperienced in php, more so in C#…

    Kind regards,
    Ralph

    http://wordpress.org/extend/plugins/st-daily-tip/

Viewing 2 replies - 1 through 2 (of 2 total)
  • This is a feature that I would like to use as well. It would be great if the devs could add this functionality to the plugin.
    Thanks!

    Where exactly do I have to insert the additional function in the original php-script?

    Could you also write a function to deliver a print routine for the tip for the day?

    Thanks for your help.

    G√ľnther Schwalb

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: St-Daily-Tip] Request addition of Title and Listview’ is closed to new replies.