w/ special thanks to Ryan Jarrett and Bruno Cantuaria. Version: 1.0.1 Author: Studio Hyperset, Inc. Author URI: http://studiohyperset.com License: GPL3 */ // Add css function admin_register_head() { $siteurl = get_option('siteurl'); $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/css/style.css'; echo "\n"; } add_action('admin_head', 'admin_register_head'); // Add JavaScript wp_enqueue_script('functions', '/wp-content/plugins/advanced-dates/js/functions.js'); // Define admin option group add_action('admin_init', 'advanceddates_group_init' ); function advanceddates_group_init(){ register_setting( 'advanceddates_group', 'advanceddates_global' ); register_setting( 'advanceddates_group', 'advanceddates_differential' ); register_setting( 'advanceddates_group', 'advanceddates_bypost' ); register_setting( 'advanceddates_group', 'advanceddates_freeze_global' ); } // New get_the_date function function get_advanced_dates($the_date) { global $post, $prefix; if (get_option('advanceddates_bypost') && get_post_meta($post->ID,$prefix.'post_enable',true)) { if (!get_post_meta($post->ID,$prefix.'post_freeze',true)) $year = date('Y') + get_post_meta($post->ID,$prefix.'post_differential',true); else $year = mysql2date('Y', $post->post_date) + get_post_meta($post->ID,$prefix.'post_differential',true); $the_date = str_replace(mysql2date("Y", $post->post_date),$year,$the_date); } elseif (get_option('advanceddates_global')) { if (!get_option('advanceddates_freeze_global')) $year = date('Y') + get_option('advanceddates_differential'); else $year = mysql2date('Y', $post->post_date) + get_option('advanceddates_differential'); $the_date = str_replace(mysql2date("Y", $post->post_date),$year,$the_date); } return $the_date; } add_filter('get_the_date', 'get_advanced_dates'); add_filter('the_date', 'get_advanced_dates'); // Add same functionality to the_time and get_the_time functions add_filter('get_the_time', 'get_advanced_dates'); add_filter('the_time', 'get_advanced_dates'); // Setup Advanced Dates metabox $prefix = 'advanceddates_meta_'; // a custom prefix to help us avoid pulling data from the wrong meta box $meta_box = array( 'id' => 'advanceddates_metabox', // the id of our meta box 'title' => 'Advanced Dates', // the title of the meta box 'page' => 'post', // display this meta box on post editing screens 'context' => 'side', 'priority' => 'default', // high, core, default or low 'fields' => array( // all of the options inside of our meta box array( 'name' => 'Enable?', 'id' => $prefix . 'post_enable', 'type' => 'checkbox', 'std' => '' ), array( 'name' => 'Differential:', 'id' => $prefix . 'post_differential', 'type' => 'text', 'std' => '0' ), array( 'name' => 'Freeze?', 'id' => $prefix . 'post_freeze', 'type' => 'checkbox', 'std' => '' ) ) ); function add_metaboxes() { global $meta_box; if (get_option('advanceddates_bypost')) { add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'], $meta_box['context'], $meta_box['priority']); add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', 'page', $meta_box['context'], $meta_box['priority']); $cps = get_post_types(array('_builtin' => false)); foreach ($cps as $cp) { add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $cp, $meta_box['context'], $meta_box['priority']); } } } add_action('admin_menu', 'add_metaboxes'); function mytheme_show_box() { global $meta_box, $post; // Use nonce for verification echo ''; echo '
| ', ' | ';
switch ($field['type']) {
case 'text':
echo '', ' '; break; case 'textarea': echo ' |
|---|---|
| ".$field['desc']." | |
Differential
Enter + x if you want your page/post to appear as if it's been written in the future (e.g., +150) and - x if you want it to appear as if it's been written in the past (e.g, -150). If you omit the "+" or "-," the plugin defaults to the former ("+").
Freezing Dates
This prevents the server from adjusting the date of a page/post when the calendar year rolls over. With this option enabled, a given page/post's date will always read x +/- the original publication year (where x = your differential). Without this option enabled, your page/post date will increase by one year every time a new calendar year begins.
Links
Advanced Dates :: Discussion | Support | Donate
SH :: WordPress Plugins | Facebook | Twitter
Extending the literary, documentary, and archival potential of WordPress, Studio Hyperset's "Advanced Dates" WordPress plugin allows publishers to easily customize the publication year of posts and pages.
» Share ideas and read more about the "Advanced Dates" plugin.
» Plugin support, feedback, and troubleshooting.
» Browse SH's other WordPress plugins.
» Like the plugin? Send a donation.
» Contact SH and/or link up with us on Facebook and Twitter.