Forums

[resolved] [Plugin: Quote Of The day] Day and/or hour never expires (3 posts)

  1. opajaap
    Member
    Posted 2 years ago #

    The quote never expires when each day or hour is selected.
    The fix is below in cd-qotd.php: see the /* Fixed */ comments (4 times):

    function cd_qotd_quote() {
    	global $wpdb,$blog_id;
    	ob_start();
    	// get current quote data
    	$cd_qotd_quote = get_option('cd_qotd_quote');
    	if ($cd_qotd_quote <= '0') {
    		$cd_qotd_quote = $wpdb->get_var("SELECT qid FROM cd_qotd WHERE blog_id='$blog_id' LIMIT 1");
    		if ($cd_qotd_quote <= '0') {
    			echo 'No Quote defined.';
    			exit;
    		}
    	}
    	$cd_qotd_time = get_option('cd_qotd_time');
    	$cd_qotd_freq = get_option('cd_qotd_freq');
    	$cd_qotd_type = get_option('cd_qotd_type');
    
    	if ($cd_qotd_freq == '1') {
    		$cd_qotd_expire = $cd_qotd_time;
    	} elseif ($cd_qotd_freq == '2') {
    		$cd_qotd_expire = $cd_qotd_time + (60 * 60);		/* Fixed */
    	} elseif ($cd_qotd_freq == '3') {
    		$cd_qotd_expire = $cd_qotd_time + (24 * 60 * 60);	/* Fixed */
    	}
    
    	if (mktime() >= $cd_qotd_expire) {			/* Fixed */
    		$qotd_query = "SELECT * FROM cd_qotd WHERE blog_id='$blog_id' ORDER BY RAND(NOW()) LIMIT 1";
    		update_option('cd_qotd_time', $cd_qotd_expire);
    	} else {
    		$qotd_query = "SELECT * FROM cd_qotd WHERE blog_id='$blog_id' AND qid='$cd_qotd_quote'";
    	}
    	$result = $wpdb->get_results($qotd_query, OBJECT);
    	update_option('cd_qotd_quote', $result[0]->cid);		/* Fixed */

    http://wordpress.org/extend/plugins/cd-qotd/

  2. opajaap
    Member
    Posted 2 years ago #

    Sorry, the above has one typo.
    The last line should read:

    update_option('cd_qotd_quote', $result[0]->qid);		/* Fixed */

    With love from OpaJaap

  3. opajaap
    Member
    Posted 2 years ago #

    Fixed in rev 1.1.0

    Thank you

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags