"; _e('Debugging Enabled','post-expirator'); echo "
"; _e('Debugging Table Emptied','post-expirator'); echo "
|
';
echo '';
} else {
echo __('Status: Disabled','post-expirator').' '; echo ''; } ?> View Debug Logs |
|||||||||||
|
'.str_replace($search,$replace,$expirationdateFooterContents).'
'; return $text.$add_to_footer; } add_action('the_content','postexpirator_add_footer',0); /** * Check for Debug */ function postExpiratorDebug() { $debug = get_option('expirationdateDebug'); if ($debug == 1) { if (!defined('POSTEXPIRATOR_DEBUG')) define('POSTEXPIRATOR_DEBUG',1); require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php'); // Load Class return new postExpiratorDebug(); } else { if (!defined('POSTEXPIRATOR_DEBUG')) define('POSTEXPIRATOR_DEBUG',0); return false; } } /** * Add Stylesheet */ function postexpirator_css() { $myStyleUrl = plugins_url('style.css', __FILE__); // Respects SSL, Style.css is relative to the current file $myStyleFile = WP_PLUGIN_DIR . '/post-expirator/style.css'; if ( file_exists($myStyleFile) ) { wp_register_style('postexpirator-css', $myStyleUrl); wp_enqueue_style('postexpirator-css'); } } add_action('admin_init','postexpirator_css'); /** * Post Expirator Activation/Upgrade */ function postexpirator_upgrade() { // Check for current version, if not exists, run activation $version = get_option('postexpiratorVersion'); if ($version === false) { //not installed, run default activation postexpirator_activate(); update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } else { if (version_compare($version,'1.6.1') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); update_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT); } if (version_compare($version,'1.6.2') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.0.0-rc1') == -1) { global $wpdb; // Schedule Events/Migrate Config $results = $wpdb->get_results($wpdb->prepare('select post_id, meta_value from ' . $wpdb->postmeta . ' as postmeta, '.$wpdb->posts.' as posts where postmeta.post_id = posts.ID AND postmeta.meta_key = %s AND postmeta.meta_value >= %d','expiration-date',time())); foreach ($results as $result) { wp_schedule_single_event($result->meta_value,'postExpiratorExpire',array($result->post_id)); $opts = array(); $opts['id'] = $result->post_id; $posttype = get_post_type($result->post_id); if ($posttype == 'page') { $opts['expireType'] = strtolower(get_option('expirationdateExpiredPageStatus','Draft')); } else { $opts['expireType'] = strtolower(get_option('expirationdateExpiredPostStatus','Draft')); } $cat = get_post_meta($result->post_id,'_expiration-date-category',true); if ((isset($cat) && !empty($cat))) { $opts['category'] = $cat; $opts['expireType'] = 'category'; } update_post_meta($result->post_id,'_expiration-date-options',$opts); } // update meta key to new format $wpdb->query($wpdb->prepare("UPDATE $wpdb->postmeta SET meta_key = %s WHERE meta_key = %s",'_expiration-date','expiration-date')); // migrate defaults $pagedefault = get_option('expirationdateExpiredPageStatus'); $postdefault = get_option('expirationdateExpiredPostStatus'); if ($pagedefault) update_option('expirationdateDefaultsPage',array('expireType' => $pagedefault)); if ($postdefault) update_option('expirationdateDefaultsPost',array('expireType' => $postdefault)); delete_option('expirationdateCronSchedule'); delete_option('expirationdateAutoEnabled'); delete_option('expirationdateExpiredPageStatus'); delete_option('expirationdateExpiredPostStatus'); update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.0.1') == -1) { // Forgot to do this in 2.0.0 if (is_multisite()) { global $current_blog; wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id); } else wp_clear_scheduled_hook('expirationdate_delete'); update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.1.0') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.1.1') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.2.0') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.2.1') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.3.0') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.3.1') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } if (version_compare($version,'2.3.1.1') == -1) { update_option('postexpiratorVersion',POSTEXPIRATOR_VERSION); } } } add_action('admin_init','postexpirator_upgrade'); /** * Called at plugin activation */ function postexpirator_activate () { if (get_option('expirationdateDefaultDateFormat') === false) update_option('expirationdateDefaultDateFormat',POSTEXPIRATOR_DATEFORMAT); if (get_option('expirationdateDefaultTimeFormat') === false) update_option('expirationdateDefaultTimeFormat',POSTEXPIRATOR_TIMEFORMAT); if (get_option('expirationdateFooterContents') === false) update_option('expirationdateFooterContents',POSTEXPIRATOR_FOOTERCONTENTS); if (get_option('expirationdateFooterStyle') === false) update_option('expirationdateFooterStyle',POSTEXPIRATOR_FOOTERSTYLE); if (get_option('expirationdateDisplayFooter') === false) update_option('expirationdateDisplayFooter',POSTEXPIRATOR_FOOTERDISPLAY); if (get_option('expirationdateDebug') === false) update_option('expirationdateDebug',POSTEXPIRATOR_DEBUGDEFAULT); if (get_option('expirationdateDefaultDate') === false) update_option('expirationdateDefaultDate',POSTEXPIRATOR_EXPIREDEFAULT); } /** * Called at plugin deactivation */ function expirationdate_deactivate () { global $current_blog; delete_option('expirationdateExpiredPostStatus'); delete_option('expirationdateExpiredPageStatus'); delete_option('expirationdateDefaultDateFormat'); delete_option('expirationdateDefaultTimeFormat'); delete_option('expirationdateDisplayFooter'); delete_option('expirationdateFooterContents'); delete_option('expirationdateFooterStyle'); delete_option('expirationdateCategory'); delete_option('expirationdateCategoryDefaults'); delete_option('expirationdateDebug'); delete_option('postexpiratorVersion'); delete_option('expirationdateCronSchedule'); delete_option('expirationdateDefaultDate'); delete_option('expirationdateDefaultDateCustom'); delete_option('expirationdateAutoEnabled'); delete_option('expirationdateDefaultsPage'); delete_option('expirationdateDefaultsPost'); ## what about custom post types? - how to cleanup? if (is_multisite()) wp_clear_scheduled_hook('expirationdate_delete_'.$current_blog->blog_id); else wp_clear_scheduled_hook('expirationdate_delete'); require_once(plugin_dir_path(__FILE__).'post-expirator-debug.php'); $debug = new postExpiratorDebug(); $debug->removeDbTable(); } register_deactivation_hook (__FILE__, 'expirationdate_deactivate'); class Walker_PostExpirator_Category_Checklist extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this var $disabled = ''; function setDisabled() { $this->disabled = 'disabled="disabled"'; } function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); $output .= "$indent