• CFDB uses a block of code for the purpose of converting dates to jalali. code is located in CF7DBPlugin.php:

    // See if wp-jalali is active and if so, have it convert the date
    // using its 'jdate' function
    else if (is_plugin_active('wp-jalali/wp-jalali.php')) {
    	$jDateFile = WP_PLUGIN_DIR . '/wp-jalali/inc/jalali-core.php';
    	if(@file_exists($jDateFile)) {
    	    include_once($jDateFile);
    		if (function_exists('jdate')) {
    			//return jdate('l, F j, Y');
    			if (CF7DBPlugin::$customDateFormat) {
    				return jdate(CF7DBPlugin::$customDateFormat, $time);
    			}
    			else {
    				return jdate(CF7DBPlugin::$dateFormat . ' ' . CF7DBPlugin::$timeFormat, $time);
    			}
    		}
    	}
    }

    the above code looks for a file which no longer exists. jdate function is automatically loaded and there is no need to include the file containing it. Hence I think changing the above code with the following would be appropriate.

    // See if wp-jalali is active and if so, have it convert the date
    // using its 'jdate' function
    else if (is_plugin_active('wp-jalali/wp-jalali.php')) {
    	if (function_exists('jdate')) {
    		//return jdate('l, F j, Y');
    		if (CF7DBPlugin::$customDateFormat) {
    			return jdate(CF7DBPlugin::$customDateFormat, $time);
    		}
    		else {
    			return jdate(CF7DBPlugin::$dateFormat . ' ' . CF7DBPlugin::$timeFormat, $time);
    		}
    	}
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    Did you test the code to see if it works?

    Yes, I tested it and it works fine.

    Plugin Author Michael Simpson

    (@msimpson)

    Thank you very much.

    I’ll additionally consolidate the “if” statements and add that change to my next update.

    
    // See if wp-jalali is active and if so, have it convert the date
    // using its 'jdate' function
    else if (is_plugin_active('wp-jalali/wp-jalali.php') && function_exists('jdate')) {
        if (CF7DBPlugin::$customDateFormat) {
            return jdate(CF7DBPlugin::$customDateFormat, $time);
        } else {
            return jdate(CF7DBPlugin::$dateFormat . ' ' . CF7DBPlugin::$timeFormat, $time);
        }
    }
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘problem with jalali date’ is closed to new replies.