PluginProbe
Timed Content / 2.9
Timed Content v2.9
2.99 trunk 1.0 1.1 1.2 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.10 2.11 2.12 2.15 2.2 2.3 2.3.1 2.4 2.5 2.5.1 2.50 2.51 2.52 All 67 releases
← All changes | timed-content.php +389 -116 2.22.9 View file →
@@ -4,17 +4,18 @@
4 4 Text Domain: timed-content
5 5 Domain Path: /lang
6 6 Plugin URI: http://wordpress.org/plugins/timed-content/
7 7 Description: Plugin to show or hide portions of a Page or Post based on specific date/time characteristics. These actions can either be processed either server-side or client-side, depending on the desired effect.
8 -Author: K. Tough
9 -Version: 2.2
8 +Author: K. Tough, Arno Welzel
9 +Version: 2.9
10 10 Author URI: http://wordpress.org/plugins/timed-content/
11 11 */
12 12 if ( !class_exists( "timedContentPlugin" ) ) {
13 13
14 - define( "TIMED_CONTENT_VERSION", "2.2" );
15 - define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/timed-content' );
16 - define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
14 + define( "TIMED_CONTENT_VERSION", "2.9" );
15 + define( "TIMED_CONTENT_SLUG", "timed-content" );
16 + define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/' . TIMED_CONTENT_SLUG );
17 + define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
17 18 define( "TIMED_CONTENT_SERVER_TAG", "timed-content-server" );
18 19 define( "TIMED_CONTENT_RULE_TAG", "timed-content-rule" );
19 20 define( "TIMED_CONTENT_ZERO_TIME", "1970-Jan-01 00:00:00 +000" ); // Start of Unix Epoch
20 21 define( "TIMED_CONTENT_END_TIME", "2038-Jan-19 03:14:07 +000" ); // End of Unix Epoch
@@ -23,10 +24,10 @@
23 24 define( "TIMED_CONTENT_CSS", TIMED_CONTENT_PLUGIN_URL . "/css/timed-content.css" );
24 25 define( "TIMED_CONTENT_CSS_DASHICONS", TIMED_CONTENT_PLUGIN_URL . "/css/ca-aliencyborg-dashicons/style.css" );
25 26 // Required for styling the jQuery UI Datepicker and jQuery UI Timepicker
26 27 define( "TIMED_CONTENT_JQUERY_UI_CSS", TIMED_CONTENT_PLUGIN_URL . "/css/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" );
27 - define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS", TIMED_CONTENT_PLUGIN_URL."/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.js" );
28 - define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS", TIMED_CONTENT_PLUGIN_URL."/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.css" );
28 + define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS", TIMED_CONTENT_PLUGIN_URL . "/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.js" );
29 + define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS", TIMED_CONTENT_PLUGIN_URL . "/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.css" );
29 30
30 31
31 32 /**
32 33 * Class timedContentPlugin
@@ -35,14 +36,161 @@
35 36 * the possibility of name collisions with other plugins.
36 37 */
37 38 class timedContentPlugin {
38 39
40 + function __construct() {
41 + //constructor
42 +
43 + }
44 +
39 45 function timedContentPlugin() {
40 - //constructor
46 + self::__construct();
41 47
42 48 }
49 +
50 + /** https://core.trac.wordpress.org/ticket/25768
51 + *
52 + * Modified from the original patch to use the currently set
53 + * timezone from PHP, like PHP's date(), and to make the code
54 + * more readable.
55 + *
56 + * @param $j
57 + * @param $req_format
58 + * @param bool $i
59 + * @param bool $gmt
60 + * @return bool|string
61 + */
62 + function fix_date_i18n($j, $req_format, $i = false, $gmt = false)
63 + {
64 + /* @var $wp_locale WP_Locale */
65 + global $wp_locale;
66 + $timestamp = $i;
43 67
44 - /**
68 + // get current timestamp if $i is false
69 + if (false === $timestamp)
70 + {
71 + if ($gmt)
72 + $timestamp = time();
73 + else
74 + $timestamp = current_time('timestamp');
75 +
76 + // use debug parameter if current user is allowed to edit the post
77 + if(isset($_GET['tctest']) && current_user_can( "edit_post", $post->post_id)) {
78 + $dt = DateTime::createFromFormat('Y-m-d H:i:s', $_GET['tctest']);
79 + if($dt != FALSE) $timestamp = $dt->getTimestamp();
80 + }
81 + }
82 +
83 + // get components of the date (timestamp) as array
84 + $date_components = getdate($timestamp);
85 +
86 + // numeric representation of a month, with leading zeros
87 + $date_month = $wp_locale->get_month($date_components['mon']);
88 + $date_month_abbrev = $wp_locale->get_month_abbrev($date_month);
89 + // numeric representation of the day of the week
90 + $date_weekday = $wp_locale->get_weekday($date_components['wday']);
91 + $date_weekday_abbrev = $wp_locale->get_weekday_abbrev($date_weekday);
92 + // get if hour is Ante meridiem or Post meridiem
93 + $meridiem = $date_components['hours'] >= 12 ? 'pm' : 'am';
94 + // lowercase Ante meridiem and Post meridiem hours
95 + $date_meridiem = $wp_locale->get_meridiem($meridiem);
96 + // uppercase Ante meridiem and Post meridiem
97 + $date_meridiem_capital = $wp_locale->get_meridiem(strtoupper($meridiem));
98 +
99 + // escape literals
100 + $date_weekday_abbrev = backslashit($date_weekday_abbrev);
101 + $date_month = backslashit($date_month);
102 + $date_weekday = backslashit($date_weekday);
103 + $date_month_abbrev = backslashit($date_month_abbrev);
104 + $date_meridiem = backslashit($date_meridiem);
105 + $date_meridiem_capital = backslashit($date_meridiem_capital);
106 +
107 + // the translated format string
108 + $translated_date_format_string = '';
109 + // the 2 arrays map a format literal to its translation (e. g. 'F' to the escaped month translation)
110 + $translate_formats = array('D', 'F', 'l', 'M', 'a', 'A', 'c', 'r');
111 + $translations = array(
112 + $date_weekday_abbrev, // D
113 + $date_month, // F
114 + $date_weekday, // l
115 + $date_month_abbrev, // M
116 + $date_meridiem, // a
117 + $date_meridiem_capital, // A
118 + 'Y-m-d\TH:i:sP', // c
119 + sprintf('%s, d %s Y H:i:s O', $date_weekday_abbrev, $date_month_abbrev), // r
120 + );
121 +
122 + // find each format literal that needs translation and replace it by its translation
123 + // respects the escaping
124 + // iterate $req_format from ending to beginning
125 + for ($i = strlen($req_format) - 1; $i > -1; $i--)
126 + {
127 + // test if current char is format literal that needs translation
128 + $translate_formats_index = array_search($req_format[$i], $translate_formats);
129 +
130 + if ($translate_formats_index !== false)
131 + {
132 + // counts the slashes (the escape char) in front of the current char
133 + $slashes_counter = 0;
134 +
135 + // count all slashes left-hand side of the current char
136 + for ($j = $i - 1; $j > -1; $j--)
137 + {
138 + if ($req_format[$j] == '\\')
139 + $slashes_counter++;
140 + else
141 + break;
142 + }
143 +
144 + // number of slashes is even
145 + if ($slashes_counter % 2 == 0)
146 + // current char is not escaped, therefore it is a format literal
147 + $translated_date_format_string = $translations[$translate_formats_index] . $translated_date_format_string;
148 + else
149 + // current char is escaped, therefore it is not a format literal, just add it unchanged
150 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
151 + }
152 + else
153 + // current char is no a format literal, just add it unchanged
154 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
155 + }
156 +
157 + $req_format = $translated_date_format_string;
158 +
159 + if ($gmt)
160 + // get GMT date string
161 + $date_formatted = gmdate($req_format, $timestamp);
162 + else
163 + {
164 + // get Wordpress time zone
165 + // $timezone_string = get_option('timezone_string');
166 + // Haha, just kidding. Let's get the currently set timezone, as God and Rasmus intended
167 + $timezone_string = date_default_timezone_get();
168 +
169 + if ($timezone_string)
170 + {
171 + // create time zone object
172 + $timezone_object = timezone_open($timezone_string);
173 + // create date object from time zone object
174 + $local_date_object = date_create(null, $timezone_object);
175 + // set time and date of $local_date_object to $timestamp
176 + $date_components = isset($date_components) ? $date_components : getdate($timestamp);
177 + date_date_set($local_date_object, $date_components['year'], $date_components['mon'], $date_components['mday']);
178 + date_time_set($local_date_object, $date_components['hours'], $date_components['minutes'], $date_components['seconds']);
179 + // format date according to the Wordpress time zone
180 + $date_formatted = date_format($local_date_object, $req_format);
181 + }
182 + else
183 + {
184 + // fall back if no Wordpress time zone set
185 + $date_formatted = date($req_format, $i);
186 + }
187 + }
188 +
189 + return $date_formatted;
190 + }
191 +
192 + /**
45 193 * Creates the Timed Content Rule post type and registers it with Wordpress
46 194 *
47 195 */
48 196 function timedContentRuleTypeInit()
@@ -80,10 +228,26 @@
80 228 'supports' => array( 'title' )
81 229 );
82 230 register_post_type( TIMED_CONTENT_RULE_TYPE, $args );
83 231 }
232 +
233 + /**
234 + * Filter to change sort order to title
235 + *
236 + * @param array $messages Array of currently defined messages for post types
237 + * @return mixed Array of messages with appropriate messages for Timed Content Rules added in
238 + */
239 + function timedContentPreGetPosts($query) {
240 + if($query->is_admin) {
241 + if ($query->get('post_type') == TIMED_CONTENT_RULE_TYPE)
242 + {
243 + $query->set('orderby', 'title');
244 + $query->set('order', 'ASC');
245 + }
246 + }
247 + return $query;
248 + }
84 249
85 -
86 250 /**
87 251 * Filter to customize CRUD messages for Timed Content Rules
88 252 *
89 253 * @param array $messages Array of currently defined messages for post types
@@ -321,27 +485,27 @@
321 485 $the_day = "";
322 486
323 487 if ( $day == 7 ) { // If $day is "day of the month", get the day of month based on the ordinal
324 488 switch ( $ordinal ) {
325 - case 1 : $the_day = "1"; break; // First day of the month //
326 - case 2 : $the_day = "2"; break; // Second day of the month //
327 - case 3 : $the_day = "3"; break; // Third day of the month //
328 - case 4 : $the_day = "4"; break; // Fourth day of the month //
329 - case 5 : $the_day = $lastDayThisMonth; break; // Last day of the month //
489 + case 0 : $the_day = "1"; break; // First day of the month //
490 + case 1 : $the_day = "2"; break; // Second day of the month //
491 + case 2 : $the_day = "3"; break; // Third day of the month //
492 + case 3 : $the_day = "4"; break; // Fourth day of the month //
493 + case 4 : $the_day = $lastDayThisMonth; break; // Last day of the month //
330 494 default : $the_day = "1"; break;
331 495 }
332 496 } else { // If $day is one of the days of the week...
333 497 $day_range = array();
334 498 switch ( $ordinal ) { // ...get a 7-day range based on the ordinal...
335 - case 1 : $day_range = range( 1, 7 ); break; // First 7 days of the month //
336 - case 2 : $day_range = range( 8, 14 ); break; // Second 7 days of the month //
337 - case 3 : $day_range = range( 15, 21 ); break; // Third 7 days of the month //
338 - case 4 : $day_range = range( 22, 28 ); break; // Fourth 7 days of the month //
339 - case 5 : $day_range = range( $lastDayThisMonth - 6, $lastDayThisMonth ); break; // Last 7 days of the month //
499 + case 0 : $day_range = range( 1, 7 ); break; // First 7 days of the month //
500 + case 1 : $day_range = range( 8, 14 ); break; // Second 7 days of the month //
501 + case 2 : $day_range = range( 15, 21 ); break; // Third 7 days of the month //
502 + case 3 : $day_range = range( 22, 28 ); break; // Fourth 7 days of the month //
503 + case 4 : $day_range = range( $lastDayThisMonth - 6, $lastDayThisMonth ); break; // Last 7 days of the month //
340 504 default : $day_range = range( 1, 7 ); break;
341 505 }
342 506 foreach ( $day_range as $a_day ) { // ...and find the matching weekday in that range.
343 - if ( $day == date( "l", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
507 + if ( $day == date( "w", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
344 508 $the_day = $a_day;
345 509 break;
346 510 }
347 511 }
@@ -434,14 +598,22 @@
434 598 $instance_end_time = $args['instance_end']['time'];
435 599 $monthly_pattern = $args['monthly_pattern'];
436 600 $monthly_pattern_ord = $args['monthly_pattern_ord'];
437 601 $monthly_pattern_day = $args['monthly_pattern_day'];
602 + $exceptions_dates = $args['exceptions_dates'];
438 603 //print_r($days_of_week);
439 604
605 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
440 606 $temp_tz = date_default_timezone_get();
441 607 date_default_timezone_set( $timezone );
442 - $right_now_t = time();
608 + $right_now_t = current_time( 'timestamp', 1 );
443 609
610 + // use debug parameter if current user is allowed to edit the post
611 + if(isset($_GET['tctest']) && current_user_can( "edit_post", $post->post_id)) {
612 + $dt = DateTime::createFromFormat('Y-m-d H:i:s', $_GET['tctest']);
613 + if($dt != FALSE) $right_now_t = $dt->getTimestamp();
614 + }
615 +
444 616 $instance_start = strtotime( $this->__datetimeToEnglish( $instance_start_date, $instance_start_time ) . " " . $timezone ); // Beginning of first occurrence
445 617 $instance_end = strtotime( $this->__datetimeToEnglish( $instance_end_date, $instance_end_time ) . " " . $timezone ); // End of first occurrence
446 618 $current = $instance_start;
447 619 $end_current = $instance_end;
@@ -453,22 +625,22 @@
453 625
454 626 if ( $human_readable == true ) {
455 627 $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
456 628 $active_periods[$period_count]["end"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $end_current );
629 + if ( $right_now_t < $current ) {
630 + $active_periods[$period_count]["status"] = "upcoming";
631 + $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $right_now_t, $current ) );
632 + } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
633 + $active_periods[$period_count]["status"] = "active";
634 + $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
635 + } else {
636 + $active_periods[$period_count]["status"] = "expired";
637 + $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
638 + }
457 639 } else {
458 640 $active_periods[$period_count]["start"] = $current;
459 641 $active_periods[$period_count]["end"] = $end_current;
460 642 }
461 - if ( $right_now_t < $current ) {
462 - $active_periods[$period_count]["status"] = "upcoming";
463 - $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
464 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
465 - $active_periods[$period_count]["status"] = "active";
466 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
467 - } else {
468 - $active_periods[$period_count]["status"] = "expired";
469 - $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
470 - }
471 643 $period_count++;
472 644
473 645 if ( $recurr_type == "recurrence_duration_end_date" )
474 646 $loop_test = "return ( \$current < \$last_occurrence_start );";
@@ -485,37 +657,51 @@
485 657 $current = $this->__getNextWeek( $current, $interval_multiplier, $days_of_week );
486 658 elseif ( $freq == 3 ) {
487 659 $current = $this->__getNextMonth( $current, $instance_start, $interval_multiplier );
488 660 $temp_current = $current;
489 - if ( $monthly_pattern == "yes" ) $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
661 + if ( $monthly_pattern == "yes" )
662 + $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
663 + else
664 + $current = $temp_current;
490 665 } elseif ( $freq == 4 )
491 666 $current = $this->__getNextYear( $current, $interval_multiplier );
492 -
493 - if ( eval ( $loop_test ) ) {
667 +
668 + $exception_period = false;
669 + if ( is_array( $exceptions_dates ) ) {
670 + foreach ($exceptions_dates as $date) {
671 + if (($current >= $date) && ($current < strtotime("+1 day", $date))) {
672 + $exception_period = true;
673 + break;
674 + }
675 + }
676 + }
677 +
678 + if ( ( eval ( $loop_test ) ) && ( !($exception_period) ) ) {
494 679 $end_current = $current + ( $instance_end - $instance_start );
495 680 if ( $human_readable == true ) {
496 681 $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
497 682 $active_periods[$period_count]["end"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $end_current );
683 + if ( $right_now_t < $current ) {
684 + $active_periods[$period_count]["status"] = "upcoming";
685 + $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
686 + } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
687 + $active_periods[$period_count]["status"] = "active";
688 + $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
689 + } else {
690 + $active_periods[$period_count]["status"] = "expired";
691 + $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
692 + }
498 693 } else {
499 694 $active_periods[$period_count]["start"] = $current;
500 695 $active_periods[$period_count]["end"] = $end_current;
501 696 }
502 - if ( $right_now_t < $current ) {
503 - $active_periods[$period_count]["status"] = "upcoming";
504 - $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
505 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
506 - $active_periods[$period_count]["status"] = "active";
507 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
508 - } else {
509 - $active_periods[$period_count]["status"] = "expired";
510 - $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
511 - }
512 - $period_count++;
697 + if ( !($exception_period) )
698 + $period_count++;
513 699 }
514 700
515 - if ( ( $freq == 3 ) && ( $monthly_pattern == "yes" ) ) $current = $temp_current;
516 701 }
517 702 date_default_timezone_set( $temp_tz );
703 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
518 704 return $active_periods;
519 705 }
520 706
521 707 /**
@@ -550,9 +736,10 @@
550 736 $args['instance_end'] = get_post_meta( $ID, $prefix . 'instance_end', true );
551 737 $args['monthly_pattern'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true );
552 738 $args['monthly_pattern_ord'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true );
553 739 $args['monthly_pattern_day'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true );
554 -
740 + $args['exceptions_dates'] = get_post_meta( $ID, $prefix . 'exceptions_dates', true );
741 +
555 742 return $this->__getRulePeriods( $args );
556 743
557 744 }
558 745
@@ -577,9 +764,10 @@
577 764 $args['instance_end'] = $_POST[$prefix . 'instance_end'];
578 765 $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
579 766 $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
580 767 $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
581 -
768 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
769 +
582 770 $response = json_encode( $this->__getRulePeriods( $args ) );
583 771
584 772 // response output
585 773 header( "Content-Type: application/json" );
@@ -632,9 +820,10 @@
632 820 $instance_end_time = $args['instance_end']['time'];
633 821 $monthly_pattern = $args['monthly_pattern'];
634 822 $monthly_pattern_ord = $args['monthly_pattern_ord'];
635 823 $monthly_pattern_day = $args['monthly_pattern_day'];
636 -
824 + $exceptions_dates = $args['exceptions_dates'];
825 +
637 826 $desc = sprintf( _x( '%1$s on %2$s @ %3$s until %4$s @ %5$s.', 'Perform action (%1$s) from date/time of first active period (%2$s @ %3$s) until date/time of last active period (%4$s @ %5$s).', 'timed-content' ), $action, $instance_start_date, $instance_start_time, $instance_end_date, $instance_end_time );
638 827
639 828 if ( $freq == 0 )
640 829 $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every hour.', 'Repeat this action every %d hours.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
@@ -675,9 +864,22 @@
675 864 if ( $recurr_type == "recurrence_duration_num_repeat" )
676 865 $desc .= "&nbsp;" . sprintf( _n( 'This rule will be active for 1 repetition.', 'This rule will be active for %d repetitions.', $num_repeat, 'timed-content' ), $num_repeat );
677 866 elseif ( $recurr_type == "recurrence_duration_end_date" )
678 867 $desc .= "&nbsp;" . sprintf( __( 'This rule will be active until %s.', 'timed-content' ), $end_date );
679 -
868 +
869 + if ( ( $exceptions_dates ) && ( is_array( $exceptions_dates ) ) ) {
870 + sort( $exceptions_dates, SORT_NUMERIC );
871 + $exceptions_dates = array_unique( $exceptions_dates );
872 + if ( $exceptions_dates[0] == 0 )
873 + array_shift( $exceptions_dates );
874 + if ( !empty( $exceptions_dates ) ) {
875 + $formatted_dates = array();
876 + foreach ( $exceptions_dates as $a_date )
877 + $formatted_dates[] = date( _x( "F j, Y" , "Date format for schedule description", 'timed-content' ), $a_date );
878 + $desc .= "&nbsp;" . sprintf( __( 'This rule will be inactive on the following dates: %s.', 'timed-content' ), join( ", ", $formatted_dates ) );
879 + }
880 + }
881 +
680 882 $desc .= "&nbsp;" . sprintf( __( 'All times are in the %s timezone.', 'timed-content' ), $timezone );
681 883 return $desc;
682 884 }
683 885
@@ -687,9 +889,12 @@
687 889 * @param int $ID ID of the Timed Content Rule
688 890 * @return string
689 891 */
690 892 function getScheduleDescriptionById( $ID ) {
691 - global $timed_content_rule_occurrence_custom_fields, $timed_content_rule_pattern_custom_fields, $timed_content_rule_recurrence_custom_fields;
893 + global $timed_content_rule_occurrence_custom_fields,
894 + $timed_content_rule_pattern_custom_fields,
895 + $timed_content_rule_recurrence_custom_fields,
896 + $timed_content_rule_exceptions_custom_fields;
692 897 $defaults = array();
693 898
694 899 foreach ( $timed_content_rule_occurrence_custom_fields as $field ) {
695 900 $defaults[$field['name']] = $field['default'];
@@ -696,11 +901,14 @@
696 901 }
697 902 foreach ( $timed_content_rule_pattern_custom_fields as $field ) {
698 903 $defaults[$field['name']] = $field['default'];
699 904 }
700 - foreach ( $timed_content_rule_recurrence_custom_fields as $field ) {
701 - $defaults[$field['name']] = $field['default'];
702 - }
905 + foreach ( $timed_content_rule_recurrence_custom_fields as $field ) {
906 + $defaults[$field['name']] = $field['default'];
907 + }
908 + foreach ( $timed_content_rule_exceptions_custom_fields as $field ) {
909 + $defaults[$field['name']] = $field['default'];
910 + }
703 911
704 912 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
705 913 $args = array();
706 914
@@ -720,8 +928,9 @@
720 928 $args['instance_end'] = ( false === get_post_meta( $ID, $prefix . 'instance_end', true ) ? $defaults['instance_end'] : get_post_meta( $ID, $prefix . 'instance_end', true ) );
721 929 $args['monthly_pattern'] = ( false === get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true ) ? $defaults['monthly_nth_weekday_of_month'] : get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true ) );
722 930 $args['monthly_pattern_ord'] = ( false === get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true ) ? $defaults['monthly_nth_weekday_of_month_nth'] : get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true ) );
723 931 $args['monthly_pattern_day'] = ( false === get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true ) ? $defaults['monthly_nth_weekday_of_month_weekday'] : get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true ) );
932 + $args['exceptions_dates'] = ( false === get_post_meta( $ID, $prefix . 'exceptions_dates', true ) ? $defaults['exceptions_dates'] : get_post_meta( $ID, $prefix . 'exceptions_dates', true ) );
724 933
725 934 return $this->__getScheduleDescription( $args );
726 935
727 936 }
@@ -747,9 +956,10 @@
747 956 $args['instance_end'] = $_POST[$prefix . 'instance_end'];
748 957 $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
749 958 $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
750 959 $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
751 -
960 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
961 +
752 962 $response = $this->__getScheduleDescription( $args );
753 963
754 964 // response output
755 965 header( "Content-Type: text/plain" );
@@ -783,10 +993,20 @@
783 993
784 994 $the_class = TIMED_CONTENT_CLIENT_TAG . $show_attr . $hide_attr ;
785 995 $the_tag = ( $display == "div" ? "div" : "span" );
786 996
787 - $the_HTML = "<" . $the_tag . " class='" . $the_class . "'" . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">" . do_shortcode( $content ) . "</" . $the_tag . ">";
997 + $the_filter = "timed_content_filter";
998 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
788 999
1000 + $the_HTML = "<"
1001 + . $the_tag
1002 + . " class='"
1003 + . $the_class
1004 + . "'"
1005 + . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">"
1006 + . str_replace( ']]>', ']]&gt;', apply_filters( $the_filter, $content ) )
1007 + . "</" . $the_tag . ">";
1008 +
789 1009 return $the_HTML;
790 1010 }
791 1011
792 1012 /**
@@ -800,12 +1020,22 @@
800 1020 global $post;
801 1021 extract( shortcode_atts( array( 'show' => TIMED_CONTENT_ZERO_TIME , 'hide' => TIMED_CONTENT_END_TIME, 'debug' => 'false' ), $atts ) );
802 1022 $show_t = strtotime( $this->__datetimeToEnglish( $show ) );
803 1023 $hide_t = strtotime( $this->__datetimeToEnglish( $hide ) );
804 - $right_now_t = time();
1024 + $right_now_t = current_time( 'timestamp', 1 );
805 1025 $debug_message = "";
1026 +
1027 + // use debug parameter if current user is allowed to edit the post
1028 + if(isset($_GET['tctest']) && current_user_can( "edit_post", $post->post_id)) {
1029 + $dt = DateTime::createFromFormat('Y-m-d H:i:s', $_GET['tctest']);
1030 + if($dt != FALSE) $right_now_t = $dt->getTimestamp();
1031 + }
1032 +
1033 + $the_filter = "timed_content_filter";
1034 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
806 1035
807 1036 if ( ( $debug == "true" ) && ( current_user_can( "edit_post", $post->post_id ) ) ) {
1037 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
808 1038 $temp_tz = date_default_timezone_get();
809 1039 date_default_timezone_set( get_option( 'timezone_string' ) );
810 1040
811 1041 $right_now = date_i18n( TIMED_CONTENT_DT_FORMAT, $right_now_t );
@@ -836,21 +1066,27 @@
836 1066 $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>hide</code>" ) . ": " . $hide . ",<br />\n"
837 1067 . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $hide_t )
838 1068 . " (" . $hide_diff_str . ").</p>\n";
839 1069
840 - $debug_message .= "<p>" . __( 'Current Date/Time:', 'timed-content') . "&nbsp;" . $right_now . "</p>\n";
841 - $debug_message .= "<p>" . _x( 'Content:', "Noun", 'timed-content') . "&nbsp;" . $content . "</p>\n";
1070 + $debug_message .= "<p>" . __( 'Current Date/Time:', 'timed-content') . "&nbsp;" . $right_now . "<br />\n";
1071 + $debug_message .= __( 'Content Filter:', 'timed-content') . "&nbsp;" . $the_filter . "</p>\n";
1072 + $debug_message .= "<p>" . _x( 'Content:', "Noun", 'timed-content') . "&nbsp;" . $content . "</p>\n";
842 1073
843 1074 $debug_message .= "</div>\n";
844 1075
845 1076 date_default_timezone_set( $temp_tz );
1077 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
846 1078 }
847 -
848 - if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) )
849 - return $debug_message . do_shortcode( $content ) . "\n";
850 - else
851 - return $debug_message . "\n";
852 1079
1080 +
1081 + if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) ) {
1082 + do_action("timed_content_server_show", $post->ID, $show, $hide, $content);
1083 + return $debug_message . str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content)) . "\n";
1084 + } else {
1085 + do_action("timed_content_server_hide", $post->ID, $show, $hide, $content);
1086 + return $debug_message . "\n";
1087 + }
1088 +
853 1089 }
854 1090
855 1091 /**
856 1092 * Processes the [timed-content-rule] shortcode.
@@ -859,14 +1095,26 @@
859 1095 * @param null $content
860 1096 * @return string
861 1097 */
862 1098 function rulesShowHTML( $atts, $content = null ) {
863 - extract( shortcode_atts( array( 'id' => '0' ), $atts ) );
1099 + global $post;
1100 + extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
1101 + if ( !is_numeric( $id ) ) {
1102 + $page = get_page_by_title( $id, OBJECT, TIMED_CONTENT_RULE_TYPE );
1103 + if ( $page == null ) return;
1104 + $id = $page->ID;
1105 + }
864 1106 if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $id ) ) return;
865 1107
866 1108 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
867 - $right_now_t = time();
1109 + $right_now_t = current_time( 'timestamp', 1 );
868 1110 $rule_is_active = false;
1111 +
1112 + // use debug parameter if current user is allowed to edit the post
1113 + if(isset($_GET['tctest']) && current_user_can( "edit_post", $post->post_id)) {
1114 + $dt = DateTime::createFromFormat('Y-m-d H:i:s', $_GET['tctest']);
1115 + if($dt != FALSE) $right_now_t = $dt->getTimestamp();
1116 + }
869 1117
870 1118 $active_periods = $this->getRulePeriodsById( $id, false );
871 1119 $action_is_show = (bool) get_post_meta( $id, $prefix . 'action', true );
872 1120
@@ -875,13 +1123,19 @@
875 1123 $rule_is_active = true;
876 1124 break;
877 1125 }
878 1126 }
879 -
880 - if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) )
881 - return do_shortcode( $content );
882 - else
883 - return "";
1127 +
1128 + $the_filter = "timed_content_filter";
1129 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1130 +
1131 + if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) ) {
1132 + do_action("timed_content_rule_show", $post->ID, $id, $content);
1133 + return str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content));
1134 + } else {
1135 + do_action("timed_content_rule_hide", $post->ID, $id, $content);
1136 + return "";
1137 + }
884 1138 }
885 1139
886 1140 /**
887 1141 * Enqueues the JavaScript code necessary for the functionality of the [timed-content-client] shortcode.
@@ -944,25 +1198,30 @@
944 1198 function addAdminHeaderCode() {
945 1199 if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == TIMED_CONTENT_RULE_TYPE )
946 1200 || ( isset( $post_type ) && $post_type == TIMED_CONTENT_RULE_TYPE )
947 1201 || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == TIMED_CONTENT_RULE_TYPE ) ) {
948 - wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
1202 + wp_enqueue_style( 'thickbox' );
1203 + wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
949 1204 // Enqueue the JavaScript file that manages the meta box UI
950 1205 wp_enqueue_script( 'timed-content-admin_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
951 1206 // Enqueue the JavaScript file that makes AJAX requests
952 - wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'jquery-ui-dialog' ), TIMED_CONTENT_VERSION );
1207 + wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'thickbox' ), TIMED_CONTENT_VERSION );
953 1208
1209 + // Set up local variables used in the Admin JavaScript file
1210 + wp_localize_script( 'timed-content-admin_js', 'timedContentRuleAdmin', array(
1211 + 'no_exceptions_label' => __( "- No exceptions set -", 'timed-content' ) ) );
1212 +
954 1213 // Set up local variables used in the AJAX JavaScript file
955 1214 wp_localize_script( 'timed-content-ajax_js', 'timedContentRuleAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
956 1215 'start_label' => _x( 'Start', 'Scheduled Dates/Times dialog - Beginning of active period table header', 'timed-content' ),
957 1216 'end_label' => _x( 'End', 'Scheduled Dates/Times dialog - End of active period table header', 'timed-content' ),
958 - 'dialog_label' => _x( 'Scheduled Dates/Times', 'Scheduled Dates/Times dialog - dialog header', 'timed-content' ),
959 - 'dialog_width' => 800,
960 - 'dialog_height' => 500,
961 - 'close_label' => _x( 'Close', 'Scheduled Dates/Times dialog - Close button HTML label', 'timed-content' ),
962 - 'loadingimg' => TIMED_CONTENT_PLUGIN_URL . '/img/wpspin.gif',
963 - 'error' => __( "Error", 'timed-content' ),
964 - 'error_desc' => __( "Something unexpected has happened along the way. The specific details are below:", 'timed-content' ) ) );
1217 + 'dialog_label' => _x( 'Scheduled Dates/Times', 'Scheduled Dates/Times dialog - dialog header', 'timed-content' ),
1218 + 'button_loading_label' => __( 'Calculating Dates/Times', 'timed-content' ),
1219 + 'button_finished_label' => __( 'Show Projected Dates/Times', 'timed-content' ),
1220 + 'dialog_width' => 800,
1221 + 'dialog_height' => 500,
1222 + 'error' => __( "Error", 'timed-content' ),
1223 + 'error_desc' => __( "Something unexpected has happened along the way. The specific details are below:", 'timed-content' ) ) );
965 1224 }
966 1225 }
967 1226
968 1227 /**
@@ -993,14 +1252,13 @@
993 1252 if ( version_compare( $wp_version, "3.8", "<" ) )
994 1253 $image = "/clock.gif";
995 1254 else
996 1255 $image = "";
997 - wp_enqueue_script( 'timed-content-admin_tinymce_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin-tinymce.js', array(), TIMED_CONTENT_VERSION );
998 - wp_localize_script( 'timed-content-admin_tinymce_js',
999 - 'timedContentAdminTinyMCEOptionsVars',
1000 - array( 'version' => TIMED_CONTENT_VERSION,
1001 - 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ),
1002 - 'image' => $image ) );
1256 + wp_localize_script( 'editor',
1257 + 'timedContentAdminTinyMCEOptions',
1258 + array( 'version' => TIMED_CONTENT_VERSION,
1259 + 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ),
1260 + 'image' => $image ) );
1003 1261 }
1004 1262 }
1005 1263
1006 1264 /**
@@ -1050,26 +1308,22 @@
1050 1308 * Display a dialog box for this plugin's associated TinyMCE plugin. Called from TinyMCE via AJAX.
1051 1309 *
1052 1310 */
1053 1311 function timedContentPluginGetTinyMCEDialog() {
1054 - include( "lib/jquery-ui-datetime-i18n.php" );
1312 + include("lib/jquery-ui-datetime-i18n.php");
1055 1313
1056 - wp_enqueue_style( 'timed-content-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS, false, TIMED_CONTENT_VERSION );
1057 - wp_enqueue_script( 'jquery-ui-datepicker' );
1058 - if( !( wp_script_is( 'timed-content-jquery-ui-datepicker-i18n-js', 'registered' ) ) ) {
1059 - wp_register_script( 'timed-content-jquery-ui-datepicker-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/timed-content-datepicker-i18n.js", array( 'jquery', 'jquery-ui-datepicker' ), TIMED_CONTENT_VERSION );
1060 - wp_enqueue_script( 'timed-content-jquery-ui-datepicker-i18n-js' );
1061 - wp_localize_script( 'timed-content-jquery-ui-datepicker-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n );
1314 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS);
1315 + wp_enqueue_script('jquery-ui-datepicker');
1316 + wp_register_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS);
1317 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css');
1318 + wp_register_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array('jquery', 'jquery-ui-datepicker'), TIMED_CONTENT_VERSION);
1319 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js');
1320 + if (!(wp_script_is(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'registered'))) {
1321 + wp_register_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/content-protector-datetime-i18n.js", array('jquery', 'jquery-ui-datepicker', TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js'), TIMED_CONTENT_VERSION);
1322 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js');
1323 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n);
1324 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n);
1062 1325 }
1063 - wp_register_style( 'timed-content-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS, array( TIMED_CONTENT_JQUERY_UI_CSS ), TIMED_CONTENT_VERSION );
1064 - wp_enqueue_style( 'timed-content-jquery-ui-timepicker-css' );
1065 - wp_register_script( 'timed-content-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array( 'jquery', 'jquery-ui-datepicker' ), TIMED_CONTENT_VERSION );
1066 - wp_enqueue_script( 'timed-content-jquery-ui-timepicker-js' );
1067 - if( !( wp_script_is( 'timed-content-jquery-ui-timepicker-i18n-js', 'registered' ) ) ) {
1068 - wp_register_script( 'timed-content-jquery-ui-timepicker-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/timed-content-timepicker-i18n.js", array( 'jquery', 'jquery-ui-datepicker', 'timed-content-jquery-ui-timepicker-js' ), TIMED_CONTENT_VERSION );
1069 - wp_enqueue_script( 'timed-content-jquery-ui-timepicker-i18n-js' );
1070 - wp_localize_script( 'timed-content-jquery-ui-timepicker-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n );
1071 - }
1072 1326
1073 1327 ob_start();
1074 1328 include( "tinymce_plugin/dialog.php" );
1075 1329 $content = ob_get_contents();
@@ -1187,41 +1441,49 @@
1187 1441 function setUpCustomFields() {
1188 1442 require_once( "lib/customFields-settings.php" );
1189 1443 require_once( "lib/customFieldsInterface.php" );
1190 1444
1191 - $scf = new customFieldsInterface( "cfi_s",
1445 + $scf = new customFieldsInterface( "timed_content_rule_schedule",
1192 1446 __( 'Rule Description/Schedule', 'timed-content' ),
1193 1447 "<div id=\"schedule_desc\" style=\"font-style: italic;\">"
1194 - . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $this->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $this->getScheduleDescriptionById( intval( 0 ) ) )
1448 + . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $this->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $this->getScheduleDescriptionById( intval( 0 ) ) )
1195 1449 . "</div>"
1196 - . "<div style=\"padding-top: 10px;\"><input type=\"button\" class=\"button-primary\" id=\"timed_content_rule_test\" value=\"" . __( 'Show Projected Dates/Times', 'timed-content' ) . "\" /></div>",
1450 + . "<div id=\"tcr-dialogHolder\" style=\"display:none;\"></div>"
1451 + . "<div style=\"padding-top: 10px;\"><input type=\"button\" class=\"button button-primary\" id=\"timed_content_rule_test\" value=\"" . __( 'Show Projected Dates/Times', 'timed-content' ) . "\" /></div>",
1197 1452 TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1198 1453 array( TIMED_CONTENT_RULE_TYPE ),
1199 1454 array() );
1200 - $ocf = new customFieldsInterface( "cfi_o",
1455 + $ocf = new customFieldsInterface( "timed_content_rule_initial_event",
1201 1456 __( 'Action/Initial Event', 'timed-content' ),
1202 1457 __( 'Set the action to be taken and when it should first run.', 'timed-content' ),
1203 1458 TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1204 1459 array( TIMED_CONTENT_RULE_TYPE ),
1205 1460 $timed_content_rule_occurrence_custom_fields );
1206 - $pcf = new customFieldsInterface( "cfi_p",
1461 + $pcf = new customFieldsInterface( "timed_content_rule_recurrence",
1207 1462 __( 'Repeating Pattern', 'timed-content' ),
1208 1463 __( 'Set how often the action should repeat.', 'timed-content' ),
1209 1464 TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1210 1465 array( TIMED_CONTENT_RULE_TYPE ),
1211 1466 $timed_content_rule_pattern_custom_fields );
1212 - $rcf = new customFieldsInterface( "cfi_r",
1213 - __( 'Stopping Condition', 'timed-content' ),
1214 - __( 'Set how long or how many times the action should occur.', 'timed-content' ),
1215 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1216 - array( TIMED_CONTENT_RULE_TYPE ),
1217 - $timed_content_rule_recurrence_custom_fields );
1467 + $rcf = new customFieldsInterface( "timed_content_rule_stop_condition",
1468 + __( 'Stopping Condition', 'timed-content' ),
1469 + __( 'Set how long or how many times the action should occur.', 'timed-content' ),
1470 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1471 + array( TIMED_CONTENT_RULE_TYPE ),
1472 + $timed_content_rule_recurrence_custom_fields );
1473 + $ecf = new customFieldsInterface( "timed_content_rule_exceptions",
1474 + __( 'Exceptions', 'timed-content' ),
1475 + __( 'Set up any exceptions to this Timed Content Rule.', 'timed-content' ),
1476 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1477 + array( TIMED_CONTENT_RULE_TYPE ),
1478 + $timed_content_rule_exceptions_custom_fields );
1218 1479
1219 1480 // Initially loaded at the top; defining this constant here means it can get i18n'd
1220 1481 /* translators: date/time format for debugging messages. http://ca2.php.net/manual/en/function.date.php */
1221 - define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1482 + define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1222 1483
1223 1484 }
1485 +
1224 1486 }
1225 1487
1226 1488 } //End Class timedContentPlugin
1227 1489
@@ -1231,9 +1493,18 @@
1231 1493 }
1232 1494
1233 1495 // Actions and Filters
1234 1496 if ( isset( $timedContentPluginInstance ) ) {
1235 - add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1497 + global $wp_version;
1498 +
1499 + add_filter('timed_content_filter', 'wptexturize');
1500 + add_filter('timed_content_filter', 'convert_smilies');
1501 + add_filter('timed_content_filter', 'convert_chars');
1502 + add_filter('timed_content_filter', 'wpautop');
1503 + add_filter('timed_content_filter', 'prepend_attachment');
1504 + add_filter('timed_content_filter', 'do_shortcode');
1505 +
1506 + add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1236 1507 add_action( "init", array( &$timedContentPluginInstance, "timedContentRuleTypeInit" ), 2 );
1237 1508 add_action( "init", array( &$timedContentPluginInstance, "setUpCustomFields" ), 2 );
1238 1509 add_action( "wp_head", array( &$timedContentPluginInstance, "addHeaderCode" ), 1 );
1239 1510 add_filter( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_columns", array( &$timedContentPluginInstance, "addDescColumnHead" ) );
@@ -1255,6 +1526,8 @@
1255 1526
1256 1527 add_shortcode( TIMED_CONTENT_CLIENT_TAG, array( &$timedContentPluginInstance, "clientShowHTML" ), 1 );
1257 1528 add_shortcode( TIMED_CONTENT_SERVER_TAG, array( &$timedContentPluginInstance, "serverShowHTML" ), 1 );
1258 1529 add_shortcode( TIMED_CONTENT_RULE_TAG, array( &$timedContentPluginInstance, "rulesShowHTML" ), 1 );
1530 +
1531 + add_filter('pre_get_posts', array( &$timedContentPluginInstance, "timedContentPreGetPosts") );
1259 1532 }
1260 1533 ?>