That calendar looks like its from the days of DOS. You want a fully animated jquery calendar.
Can someone please tell me what code I should insert in this functions.php file to make my users’ classifieds ads expire after the final event date? I don’t want my ‘What’s On’ categories to contain events that have finished.
The ‘events’ categories are all separated from ‘listing’ categories in my wordpress site, but I’m not sure if you need a specific metatag to help with this coding. Listing ads (as opposed to event ads) don’t have dates. Listing ads run for 30, 90 or 365 days (admin decides). These need to expire as normal. But events should expire the date after the final show. The field for the last show is ‘END DATE’ on the ‘Place an Ad’ form. Not sure what the meta tag is for that either.
<?php
/*************************************************************
* Do not modify unless you know what you're doing, SERIOUSLY!
*************************************************************/
error_reporting(E_ERROR);
define('TAGKW_TEXT_COUNT',40);
load_theme_textdomain('default');
//load_textdomain( 'default', TEMPLATEPATH.'/en_US.mo' );
// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
global $blog_id;
if(get_option('upload_path') && !strstr(get_option('upload_path'),'wp-content/uploads'))
{
$upload_folder_path = "wp-content/blogs.dir/$blog_id/files/";
}else
{
$upload_folder_path = "wp-content/uploads/";
}
global $blog_id;
if($blog_id){ $thumb_url = "&bid=$blog_id";}
if ( function_exists( 'add_theme_support' ) ){
add_theme_support( 'post-thumbnails' );
}
### Rating Logs Table Name
global $wpdb;
$term_icon_column=$wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
if(!$term_icon_column)
{
$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
}
$rating_table_name = $wpdb->prefix.'ratings';
require(TEMPLATEPATH . "/product_menu.php");
if(get_option('ptthemes_captcha_dislay')=='No'){}else
{
include_once (TEMPLATEPATH . '/library/captcha/captcha_function.php');
}
include_once (TEMPLATEPATH . '/language.php');
include_once (TEMPLATEPATH . '/library/includes/post_custom_settings.php'); // custom fields settings + database settings
include_once (TEMPLATEPATH . '/library/includes/post_custom_fields.php'); // custom fields HTML Tag coding
// Theme variables
include_once (TEMPLATEPATH . '/library/functions/theme_variables.php');
//custom post type
include_once (TEMPLATEPATH . '/library/functions/custom_post_type.php');
//** ADMINISTRATION FILES **//
if(file_exists($functions_path . 'multi_city_functions.php'))
{
include_once ($functions_path . 'multi_city_functions.php');
}
// Theme admin functions
include_once ($functions_path . 'admin_functions.php');
// Theme admin options
include_once ($functions_path . 'admin_options.php');
// Theme admin Settings
include_once ($functions_path . 'admin_settings.php');
//** FRONT-END FILES **//
// Widgets
include_once ($functions_path . 'widgets_functions.php');
// Custom
include_once ($functions_path . 'custom_functions.php');
// Comments
include_once ($functions_path . 'comments_functions.php');
include_once ($functions_path . 'yoast-canonical.php');
include_once ($functions_path . 'yoast-breadcrumbs.php');
include_once ($functions_path . 'most-popular.php');
include_once ($functions_path . 'image_resizer.php');
include_once (TEMPLATEPATH . '/library/rating/post_rating.php');
//Listing filters type
include_once (TEMPLATEPATH . '/library/functions/listing_filters.php');
//theme.php
function autoinstall_admin_header()
{
global $wpdb;
if(strstr($_SERVER['REQUEST_URI'],'themes.php') && $_REQUEST['template']=='' && $_GET['page']=='')
{
if($_REQUEST['dummy']=='del')
{
delete_dummy_data();
$dummy_deleted = '<p><b>All Dummy data has been removed from your database successfully!</b></p>';
}
if($_REQUEST['dummy_insert'])
{
include_once (TEMPLATEPATH . '/auto_install.php');
$wpdb->query("INSERT INTO `".$multicity_db_table_name."` (`city_id`, `cityname`, `lat`, `lng`, `scall_factor`, `is_zoom_home`, `categories`) VALUES (NULL, 'Philadelphia', '39.953438023308465', '-75.14579772949219', '13', 'Yes', '')"); //MULTI CITY DATA INSETS
}
if($_REQUEST['activated']=='true')
{
$theme_actived_success = '<p class="message">Theme activated successfully.</p>';
}
$post_counts = $wpdb->get_var("select count(post_id) from $wpdb->postmeta where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1");
if($post_counts>0)
{
$dummy_data_msg = '<p> <b>Sample data has been populated on your site. Wish to delete sample data?</b><br />If you have problem with image, please copy images/dummy folder to wp-content/uploads <br /> <a class="button_delete" href="'.site_url().'/wp-admin/themes.php?dummy=del">Yes Delete Please!</a><p>';
}else
{
$dummy_data_msg = '<p> <b>Would you like to auto install this theme and populate sample data on your site?</b> <br /> <a class="button_insert" href="'.site_url().'/wp-admin/themes.php?dummy_insert=1">Yes, insert sample data please</a></p>';
}
define('THEME_ACTIVE_MESSAGE','
<style>
.highlight { width:60% !important; background:#FFFFE0 !important; overflow:hidden; display:table; border:2px solid #558e23 !important; padding:15px 20px 0px 20px !important; -moz-border-radius:11px !important; -webkit-border-radius:11px !important; }
.highlight p { color:#444 !important; font:15px Arial, Helvetica, sans-serif !important; text-align:center; }
.highlight p.message { font-size:13px !important; }
.highlight p a { color:#ff7e00; text-decoration:none !important; }
.highlight p a:hover { color:#000; }
.highlight p a.button_insert
{ display:block; width:230px; margin:10px auto 0 auto; background:#5aa145; padding:10px 15px; color:#fff; border:1px solid #4c9a35; -moz-border-radius:5px; -webkit-border-radius:5px; }
.highlight p a:hover.button_insert { background:#347c1e; color:#fff; border:1px solid #4c9a35; }
.highlight p a.button_delete
{ display:block; width:140px; margin:10px auto 0 auto; background:#dd4401; padding:10px 15px; color:#fff; border:1px solid #9e3000; -moz-border-radius:5px; -webkit-border-radius:5px; }
.highlight p a:hover.button_delete { background:#c43e03; color:#fff; border:1px solid #9e3000; }
#message0 { display:none !important; }
</style>
<div class="updated highlight fade"> '.$theme_actived_success.$dummy_deleted.$dummy_data_msg.'</div>');
echo THEME_ACTIVE_MESSAGE;
}
}
add_action("admin_head", "autoinstall_admin_header"); // please comment this line if you wish to DEACTIVE SAMPLE DATA INSERT.
function delete_dummy_data()
{
global $wpdb;
//delete_option('sidebars_widgets'); //delete widgets
$productArray = array();
$pids_sql = "select p.ID from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1";
$pids_info = $wpdb->get_results($pids_sql);
foreach($pids_info as $pids_info_obj)
{
wp_delete_post($pids_info_obj->ID);
}
}
/////////////////PLACE PRICE SETTINGS CODING START/////////////////
global $wpdb,$table_prefix;
$price_db_table_name = $table_prefix . "price";
if($wpdb->get_var("SHOW TABLES LIKE \\"$price_db_table_name\\"") != $price_db_table_name)
{
$price_table = 'CREATE TABLE IF NOT EXISTS `'.$price_db_table_name.'` (
`pid` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`amount` float(12,2) NOT NULL,
`cat` varchar(255) NOT NULL,
`status` tinyint(2) NOT NULL DEFAULT \\'1\\',
`days` int(10) NOT NULL,
`is_featured` tinyint(4) NOT NULL DEFAULT \\'0\\',
`title_desc` text NOT NULL,
PRIMARY KEY (`pid`)
)';
$wpdb->query($price_table);
$price_insert = '
INSERT INTO `'.$price_db_table_name.'` (`pid`, `title`, `amount`, `status`, `days`,`is_featured`) VALUES
(1, "Free", 0.00, 1, 30, 0),
(2, "Featured", 10.00, 1, 90, 1)';
$wpdb->query($price_insert);
}else
{
$wpdb->query("ALTER TABLE $price_db_table_name ADD `is_featured` TINYINT( 4 ) NOT NULL DEFAULT '0'");
$wpdb->query("ALTER TABLE $price_db_table_name ADD `title_desc` TEXT NOT NULL");
$wpdb->query("ALTER TABLE $price_db_table_name ADD `cat` varchar( 255 ) NOT NULL");
}
/////////////////PLACE PRICE SETTINGS CODING END/////////////////
/////////////////PLACE EXPIRY SETTINGS CODING START/////////////////
global $table_prefix, $wpdb;
$table_name = $table_prefix . "place_expire_session";
$current_date = date('Y-m-d');
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
{
global $table_prefix, $wpdb,$table_name;
$sql = 'DROP TABLE `' . $table_name . '`'; // drop the existing table
mysql_query($sql);
$sql = 'CREATE TABLE `'.$table_name.'` (
`session_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`execute_date` DATE NOT NULL ,
`is_run` TINYINT( 4 ) NOT NULL DEFAULT "0"
) ENGINE = MYISAM ;';
mysql_query($sql);
}
$today_executed = $wpdb->get_var("select session_id from $table_name where execute_date=\\"$current_date\\"");
if($today_executed && $today_executed>0)
{
}else
{
if(get_option('ptthemes_listing_expiry_disable'))
{
if(get_option('ptthemes_listing_preexpiry_notice_disable'))
{
$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
if($number_of_grace_days=='')
{
$number_of_grace_days=1;
}
$postid_str = $wpdb->get_results("select p.ID,p.post_author,p.post_date, p.post_title from $wpdb->posts p where (p.post_type='post' or p.post_type='event') and p.post_status='publish' and datediff(\\"$current_date\\",date_format(p.post_date,'%Y-%m-%d')) > (select meta_value from $wpdb->postmeta pm where post_id=p.ID and meta_value>0 and meta_key='alive_days')-$number_of_grace_days");
foreach($postid_str as $postid_str_obj)
{
$ID = $postid_str_obj->ID;
$post_author = $postid_str_obj->post_author;
$post_date = date('dS m,Y',strtotime($postid_str_obj->post_date));
$post_title = $postid_str_obj->post_title;
$userinfo = $wpdb->get_results("select user_email,display_name,user_login from $wpdb->users where ID=\\"$ID\\"");
$user_email = $userinfo[0]->user_email;
$display_name = $userinfo[0]->display_name;
$user_login = $userinfo[0]->user_login;
$fromEmail = get_site_emailId();
$fromEmailName = get_site_emailName();
$alivedays = get_post_meta($ID,'alive_days',true);
$productlink = get_permalink($ID);
$loginurl = site_url().'/?ptype=login';
$siteurl = site_url();
$client_message = "<p>Dear $display_name,<p><p>Your listing -<a href=\\"$productlink\\"><b>$post_title</b></a> posted on <u>$post_date</u> for $alivedays days is scheduled to expire in $number_of_grace_days day(s). When your listing expires, it will no longer appear on the site.</p>
<p> If you want your ad to continue, please login to your member area of our site and renew. You canlogin here <a href=\\"$loginurl\\">$loginurl</a>.</p>
<p>Your login ID is <b>$user_login</b> and Email ID is <b>$user_email</b>.</p>
<p>Thank you,<br /><a href=\\"$siteurl\\">$fromEmailName</a>.</p>";
$subject = 'Place listing expiration Notification';
$headers = 'MIME-Version: 1.0' . "\\r\
";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\\r\
";
$headers .= 'To: '.$display_name.' <'.$user_email.'>' . "\\r\
";
$headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\\r\
";
@mail($user_email,$subject,$client_message,$headers);///To client email
}
}
$postid_str = $wpdb->get_var("select group_concat(p.ID) from $wpdb->posts p where p.post_type='post' and p.post_status='publish' and datediff(\\"$current_date\\",date_format(p.post_date,'%Y-%m-%d')) > (select meta_value from $wpdb->postmeta pm where post_id=p.ID and meta_key='alive_days')");
if($postid_str)
{
$listing_ex_status = get_option('ptthemes_listing_ex_status');
if($listing_ex_status=='')
{
$listing_ex_status = 'draft';
}
$wpdb->query("update $wpdb->posts set post_status=\\"$listing_ex_status\\" where ID in ($postid_str)");
}
$wpdb->query("insert into $table_name (execute_date,is_run) values (\\"$current_date\\",'1')");
}
}
/////////////////PLACE EXPIRY SETTINGS CODING END/////////////////
?>
This is the code for functions.php. I would love some help. I’m looking for a calendar too. I’ll try looking up jquery calendars…