PluginProbe
Timed Content / 2.7
Timed Content v2.7
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 +557 -195 2.1.1 → 2.7 View file →
@@ -1,34 +1,33 @@
1 1 <?php
2 2 /*
3 3 Plugin Name: Timed Content
4 4 Text Domain: timed-content
5 +Domain Path: /lang
5 6 Plugin URI: http://wordpress.org/plugins/timed-content/
6 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.
7 -Author: K. Tough
8 -Version: 2.1.1
8 +Author: K. Tough, Arno Welzel
9 +Version: 2.7
9 10 Author URI: http://wordpress.org/plugins/timed-content/
10 11 */
11 12 if ( !class_exists( "timedContentPlugin" ) ) {
12 13
13 - define( "TIMED_CONTENT_VERSION", "2.1.1" );
14 - define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/timed-content' );
15 - define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
14 + define( "TIMED_CONTENT_VERSION", "2.7" );
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" );
16 18 define( "TIMED_CONTENT_SERVER_TAG", "timed-content-server" );
17 19 define( "TIMED_CONTENT_RULE_TAG", "timed-content-rule" );
18 20 define( "TIMED_CONTENT_ZERO_TIME", "1970-Jan-01 00:00:00 +000" ); // Start of Unix Epoch
19 21 define( "TIMED_CONTENT_END_TIME", "2038-Jan-19 03:14:07 +000" ); // End of Unix Epoch
20 - /* translators: date/time format for debugging messages. */
21 - define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
22 22 define( "TIMED_CONTENT_RULE_TYPE", "timed_content_rule" );
23 23 define( "TIMED_CONTENT_RULE_POSTMETA_PREFIX", TIMED_CONTENT_RULE_TYPE . "_" );
24 24 define( "TIMED_CONTENT_CSS", TIMED_CONTENT_PLUGIN_URL . "/css/timed-content.css" );
25 - // Required for styling the JQuery UI Datepicker and JQuery UI Timepicker
25 + define( "TIMED_CONTENT_CSS_DASHICONS", TIMED_CONTENT_PLUGIN_URL . "/css/ca-aliencyborg-dashicons/style.css" );
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" );
29 - require_once( "lib/customFields-settings.php" );
30 - require_once( "lib/customFieldsInterface.php" );
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" );
31 30
32 31
33 32 /**
34 33 * Class timedContentPlugin
@@ -37,14 +36,156 @@
37 36 * the possibility of name collisions with other plugins.
38 37 */
39 38 class timedContentPlugin {
40 39
40 + function __construct() {
41 + //constructor
42 +
43 + }
44 +
41 45 function timedContentPlugin() {
42 - //constructor
46 + self::__construct();
43 47
44 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;
45 67
46 - /**
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 +
77 +
78 + // get components of the date (timestamp) as array
79 + $date_components = getdate($timestamp);
80 +
81 + // numeric representation of a month, with leading zeros
82 + $date_month = $wp_locale->get_month($date_components['mon']);
83 + $date_month_abbrev = $wp_locale->get_month_abbrev($date_month);
84 + // numeric representation of the day of the week
85 + $date_weekday = $wp_locale->get_weekday($date_components['wday']);
86 + $date_weekday_abbrev = $wp_locale->get_weekday_abbrev($date_weekday);
87 + // get if hour is Ante meridiem or Post meridiem
88 + $meridiem = $date_components['hours'] >= 12 ? 'pm' : 'am';
89 + // lowercase Ante meridiem and Post meridiem hours
90 + $date_meridiem = $wp_locale->get_meridiem($meridiem);
91 + // uppercase Ante meridiem and Post meridiem
92 + $date_meridiem_capital = $wp_locale->get_meridiem(strtoupper($meridiem));
93 +
94 + // escape literals
95 + $date_weekday_abbrev = backslashit($date_weekday_abbrev);
96 + $date_month = backslashit($date_month);
97 + $date_weekday = backslashit($date_weekday);
98 + $date_month_abbrev = backslashit($date_month_abbrev);
99 + $date_meridiem = backslashit($date_meridiem);
100 + $date_meridiem_capital = backslashit($date_meridiem_capital);
101 +
102 + // the translated format string
103 + $translated_date_format_string = '';
104 + // the 2 arrays map a format literal to its translation (e. g. 'F' to the escaped month translation)
105 + $translate_formats = array('D', 'F', 'l', 'M', 'a', 'A', 'c', 'r');
106 + $translations = array(
107 + $date_weekday_abbrev, // D
108 + $date_month, // F
109 + $date_weekday, // l
110 + $date_month_abbrev, // M
111 + $date_meridiem, // a
112 + $date_meridiem_capital, // A
113 + 'Y-m-d\TH:i:sP', // c
114 + sprintf('%s, d %s Y H:i:s O', $date_weekday_abbrev, $date_month_abbrev), // r
115 + );
116 +
117 + // find each format literal that needs translation and replace it by its translation
118 + // respects the escaping
119 + // iterate $req_format from ending to beginning
120 + for ($i = strlen($req_format) - 1; $i > -1; $i--)
121 + {
122 + // test if current char is format literal that needs translation
123 + $translate_formats_index = array_search($req_format[$i], $translate_formats);
124 +
125 + if ($translate_formats_index !== false)
126 + {
127 + // counts the slashes (the escape char) in front of the current char
128 + $slashes_counter = 0;
129 +
130 + // count all slashes left-hand side of the current char
131 + for ($j = $i - 1; $j > -1; $j--)
132 + {
133 + if ($req_format[$j] == '\\')
134 + $slashes_counter++;
135 + else
136 + break;
137 + }
138 +
139 + // number of slashes is even
140 + if ($slashes_counter % 2 == 0)
141 + // current char is not escaped, therefore it is a format literal
142 + $translated_date_format_string = $translations[$translate_formats_index] . $translated_date_format_string;
143 + else
144 + // current char is escaped, therefore it is not a format literal, just add it unchanged
145 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
146 + }
147 + else
148 + // current char is no a format literal, just add it unchanged
149 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
150 + }
151 +
152 + $req_format = $translated_date_format_string;
153 +
154 + if ($gmt)
155 + // get GMT date string
156 + $date_formatted = gmdate($req_format, $timestamp);
157 + else
158 + {
159 + // get Wordpress time zone
160 + // $timezone_string = get_option('timezone_string');
161 + // Haha, just kidding. Let's get the currently set timezone, as God and Rasmus intended
162 + $timezone_string = date_default_timezone_get();
163 +
164 + if ($timezone_string)
165 + {
166 + // create time zone object
167 + $timezone_object = timezone_open($timezone_string);
168 + // create date object from time zone object
169 + $local_date_object = date_create(null, $timezone_object);
170 + // set time and date of $local_date_object to $timestamp
171 + $date_components = isset($date_components) ? $date_components : getdate($timestamp);
172 + date_date_set($local_date_object, $date_components['year'], $date_components['mon'], $date_components['mday']);
173 + date_time_set($local_date_object, $date_components['hours'], $date_components['minutes'], $date_components['seconds']);
174 + // format date according to the Wordpress time zone
175 + $date_formatted = date_format($local_date_object, $req_format);
176 + }
177 + else
178 + {
179 + // fall back if no Wordpress time zone set
180 + $date_formatted = date($req_format, $i);
181 + }
182 + }
183 +
184 + return $date_formatted;
185 + }
186 +
187 + /**
47 188 * Creates the Timed Content Rule post type and registers it with Wordpress
48 189 *
49 190 */
50 191 function timedContentRuleTypeInit()
@@ -51,9 +192,9 @@
51 192 {
52 193 $labels = array(
53 194 'name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' ),
54 195 'singular_name' => _x( 'Timed Content Rule', 'post type singular name', 'timed-content' ),
55 - 'add_new' => _x( 'Add New', TIMED_CONTENT_RULE_TYPE, 'timed-content' ),
196 + 'add_new' => _x( 'Add New', 'Menu item/button label on Timed Content Rules admin page', 'timed-content' ),
56 197 'add_new_item' => __( 'Add New Timed Content Rule', 'timed-content' ),
57 198 'edit_item' => __( 'Edit Timed Content Rule', 'timed-content' ),
58 199 'new_item' => __( 'New Timed Content Rule', 'timed-content' ),
59 200 'view_item' => __( 'View Timed Content Rule', 'timed-content' ),
@@ -60,9 +201,9 @@
60 201 'search_items' => __( 'Search Timed Content Rules', 'timed-content' ),
61 202 'not_found' => __( 'No Timed Content Rules found', 'timed-content' ),
62 203 'not_found_in_trash' => __( 'No Timed Content Rules found in Trash', 'timed-content' ),
63 204 'parent_item_colon' => '',
64 - 'menu_name' =>_x( 'Timed Content Rules', 'post type general name', 'timed-content' )
205 + 'menu_name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' )
65 206 );
66 207 $args = array(
67 208 'labels' => $labels,
68 209 'description' => __( 'Create regular schedules to show or hide selected content in a Page or Post.', 'timed-content' ),
@@ -83,9 +224,8 @@
83 224 );
84 225 register_post_type( TIMED_CONTENT_RULE_TYPE, $args );
85 226 }
86 227
87 -
88 228 /**
89 229 * Filter to customize CRUD messages for Timed Content Rules
90 230 *
91 231 * @param array $messages Array of currently defined messages for post types
@@ -92,10 +232,12 @@
92 232 * @return mixed Array of messages with appropriate messages for Timed Content Rules added in
93 233 */
94 234 function timedContentRuleUpdatedMessages( $messages ) {
95 235 global $post;
96 -// global $post_ID;
97 -
236 +
237 + /* translators: date and time format to activate rule. http://ca2.php.net/manual/en/function.date.php*/
238 + $post_date = date_i18n( __( 'M j, Y @ G:i', 'timed-content' ), strtotime( $post->post_date ) );
239 +
98 240 $messages[TIMED_CONTENT_RULE_TYPE] = array(
99 241 0 => '', // Unused. Messages start at index 1.
100 242 1 => __( 'Timed Content Rule updated.', 'timed-content' ),
101 243 2 => __( 'Custom field updated.', 'timed-content' ),
@@ -105,10 +247,10 @@
105 247 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Timed Content Rule restored to revision from %s', 'timed-content' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
106 248 6 => __( 'Timed Content Rule published.', 'timed-content' ),
107 249 7 => __( 'Timed Content Rule saved.', 'timed-content' ),
108 250 8 => __( 'Timed Content Rule submitted.', 'timed-content' ),
109 - /* translators: %s: date and time to activate rule */
110 - 9 => sprintf( __('Timed Content Rule scheduled for: <strong>%1$s</strong>.', 'timed-content' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ) ),
251 + /* translators: %s: date and time to activate rule. */
252 + 9 => sprintf( __( 'Timed Content Rule scheduled for: %s.' , 'timed-content' ), "<strong>" . $post_date . "</strong>" ),
111 253 10 => __( 'Timed Content Rule draft updated.', 'timed-content' )
112 254 );
113 255
114 256 return $messages;
@@ -113,8 +255,37 @@
113 255
114 256 return $messages;
115 257 }
116 258
259 + function __datetimeToEnglish( $date, $time = "" ) {
260 + $months = array( "January",
261 + "February",
262 + "March",
263 + "April",
264 + "May",
265 + "June",
266 + "July",
267 + "August",
268 + "September",
269 + "October",
270 + "November",
271 + "December" );
272 + $monthsI18N = array( __( "January", 'timed-content' ),
273 + __( "February", 'timed-content' ),
274 + __( "March", 'timed-content' ),
275 + __( "April", 'timed-content' ),
276 + __( "May", 'timed-content' ),
277 + __( "June", 'timed-content' ),
278 + __( "July", 'timed-content' ),
279 + __( "August", 'timed-content' ),
280 + __( "September", 'timed-content' ),
281 + __( "October", 'timed-content' ),
282 + __( "November", 'timed-content' ),
283 + __( "December", 'timed-content' ) );
284 + $english_date = str_replace( $monthsI18N, $months, $date );
285 + return $english_date . " " . $time;
286 + }
287 +
117 288 /**
118 289 * Advances a date/time by a set number of days
119 290 *
120 291 * @param int $current UNIX timestamp of the date/time before incrementing
@@ -155,9 +326,12 @@
155 326
156 327 // Otherwise, set up an array combining the days of the week to repeat on and the current day
157 328 // (keys and values of the array will be the same, and the array is sorted)
158 329 $currentDayOfWeekIndex = date( "w", $current );
159 - sort( array_values( array_unique( array_merge( array( $currentDayOfWeekIndex ), $days ) ) ) );
330 + $days = array_merge( array( $currentDayOfWeekIndex ), $days );
331 + $days = array_unique( $days );
332 + $days = array_values( $days );
333 + sort( $days );
160 334 $daysOfWeek = array_combine( $days, $days );
161 335
162 336 // If the current day is the last one of the days of the week to repeat on, jump ahead to
163 337 // the next week to be repeating on and get the earliest day in the array
@@ -289,27 +463,27 @@
289 463 $the_day = "";
290 464
291 465 if ( $day == 7 ) { // If $day is "day of the month", get the day of month based on the ordinal
292 466 switch ( $ordinal ) {
293 - case 1 : $the_day = "1"; break; // First day of the month //
294 - case 2 : $the_day = "2"; break; // Second day of the month //
295 - case 3 : $the_day = "3"; break; // Third day of the month //
296 - case 4 : $the_day = "4"; break; // Fourth day of the month //
297 - case 5 : $the_day = $lastDayThisMonth; break; // Last day of the month //
467 + case 0 : $the_day = "1"; break; // First day of the month //
468 + case 1 : $the_day = "2"; break; // Second day of the month //
469 + case 2 : $the_day = "3"; break; // Third day of the month //
470 + case 3 : $the_day = "4"; break; // Fourth day of the month //
471 + case 4 : $the_day = $lastDayThisMonth; break; // Last day of the month //
298 472 default : $the_day = "1"; break;
299 473 }
300 474 } else { // If $day is one of the days of the week...
301 475 $day_range = array();
302 476 switch ( $ordinal ) { // ...get a 7-day range based on the ordinal...
303 - case 1 : $day_range = range( 1, 7 ); break; // First 7 days of the month //
304 - case 2 : $day_range = range( 8, 14 ); break; // Second 7 days of the month //
305 - case 3 : $day_range = range( 15, 21 ); break; // Third 7 days of the month //
306 - case 4 : $day_range = range( 22, 28 ); break; // Fourth 7 days of the month //
307 - case 5 : $day_range = range( $lastDayThisMonth - 6, $lastDayThisMonth ); break; // Last 7 days of the month //
477 + case 0 : $day_range = range( 1, 7 ); break; // First 7 days of the month //
478 + case 1 : $day_range = range( 8, 14 ); break; // Second 7 days of the month //
479 + case 2 : $day_range = range( 15, 21 ); break; // Third 7 days of the month //
480 + case 3 : $day_range = range( 22, 28 ); break; // Fourth 7 days of the month //
481 + case 4 : $day_range = range( $lastDayThisMonth - 6, $lastDayThisMonth ); break; // Last 7 days of the month //
308 482 default : $day_range = range( 1, 7 ); break;
309 483 }
310 484 foreach ( $day_range as $a_day ) { // ...and find the matching weekday in that range.
311 - if ( $day == date( "l", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
485 + if ( $day == date( "w", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
312 486 $the_day = $a_day;
313 487 break;
314 488 }
315 489 }
@@ -340,11 +514,11 @@
340 514 */
341 515 function __validate( $args ) {
342 516 $errors = array();
343 517
344 - $instance_start = strtotime( $args['instance_start']['date'] . '' . $args['instance_start']['time'] . ' ' . $args['timezone'] );
345 - $instance_end = strtotime( $args['instance_end']['date'] . '' . $args['instance_end']['time'] . ' ' . $args['timezone'] );
346 - $end_date = strtotime( $args['end_date'] . '' . $args['instance_start']['time'] . ' ' . $args['timezone'] );
518 + $instance_start = strtotime( $this->__datetimeToEnglish( $args['instance_start']['date'], $args['instance_start']['time'] ) . ' ' . $args['timezone'] );
519 + $instance_end = strtotime( $this->__datetimeToEnglish( $args['instance_end']['date'], $args['instance_end']['time'] ) . ' ' . $args['timezone'] );
520 + $end_date = strtotime( $this->__datetimeToEnglish( $args['end_date'], $args['instance_start']['time'] ) . ' ' . $args['timezone'] );
347 521
348 522 if ( $args['instance_start']['date'] == "" )
349 523 $errors[] = __( "Date in Starting Date/Time must not be empty.", 'timed-content' );
350 524 if ( $args['instance_start']['time'] == "" )
@@ -402,16 +576,18 @@
402 576 $instance_end_time = $args['instance_end']['time'];
403 577 $monthly_pattern = $args['monthly_pattern'];
404 578 $monthly_pattern_ord = $args['monthly_pattern_ord'];
405 579 $monthly_pattern_day = $args['monthly_pattern_day'];
580 + $exceptions_dates = $args['exceptions_dates'];
406 581 //print_r($days_of_week);
407 582
583 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
408 584 $temp_tz = date_default_timezone_get();
409 585 date_default_timezone_set( $timezone );
410 - $right_now_t = time();
586 + $right_now_t = current_time( 'timestamp', 1 );
411 587
412 - $instance_start = strtotime( $instance_start_date . " " . $instance_start_time . " " . $timezone ); // Beginning of first occurrence
413 - $instance_end = strtotime( $instance_end_date . " " . $instance_end_time . " " . $timezone ); // End of first occurrence
588 + $instance_start = strtotime( $this->__datetimeToEnglish( $instance_start_date, $instance_start_time ) . " " . $timezone ); // Beginning of first occurrence
589 + $instance_end = strtotime( $this->__datetimeToEnglish( $instance_end_date, $instance_end_time ) . " " . $timezone ); // End of first occurrence
414 590 $current = $instance_start;
415 591 $end_current = $instance_end;
416 592
417 593 if ( $recurr_type == "recurrence_duration_num_repeat" )
@@ -416,27 +592,27 @@
416 592
417 593 if ( $recurr_type == "recurrence_duration_num_repeat" )
418 594 $last_occurrence_start = strtotime( TIMED_CONTENT_END_TIME );
419 595 else
420 - $last_occurrence_start = strtotime( $end_date . " " . $instance_start_time . " " . $timezone );
596 + $last_occurrence_start = strtotime( $this->__datetimeToEnglish( $end_date, $instance_start_time ) . " " . $timezone );
421 597
422 598 if ( $human_readable == true ) {
423 - $active_periods[$period_count]["start"] = date( TIMED_CONTENT_DT_FORMAT, $current );
424 - $active_periods[$period_count]["end"] = date( TIMED_CONTENT_DT_FORMAT, $end_current );
599 + $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
600 + $active_periods[$period_count]["end"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $end_current );
601 + if ( $right_now_t < $current ) {
602 + $active_periods[$period_count]["status"] = "upcoming";
603 + $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $right_now_t, $current ) );
604 + } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
605 + $active_periods[$period_count]["status"] = "active";
606 + $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
607 + } else {
608 + $active_periods[$period_count]["status"] = "expired";
609 + $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
610 + }
425 611 } else {
426 612 $active_periods[$period_count]["start"] = $current;
427 613 $active_periods[$period_count]["end"] = $end_current;
428 614 }
429 - if ( $right_now_t < $current ) {
430 - $active_periods[$period_count]["status"] = "upcoming";
431 - $active_periods[$period_count]["time"] = sprintf( __( '%s from now.', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
432 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
433 - $active_periods[$period_count]["status"] = "active";
434 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
435 - } else {
436 - $active_periods[$period_count]["status"] = "expired";
437 - $active_periods[$period_count]["time"] = sprintf( __( '%s ago.', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
438 - }
439 615 $period_count++;
440 616
441 617 if ( $recurr_type == "recurrence_duration_end_date" )
442 618 $loop_test = "return ( \$current < \$last_occurrence_start );";
@@ -453,37 +629,51 @@
453 629 $current = $this->__getNextWeek( $current, $interval_multiplier, $days_of_week );
454 630 elseif ( $freq == 3 ) {
455 631 $current = $this->__getNextMonth( $current, $instance_start, $interval_multiplier );
456 632 $temp_current = $current;
457 - if ( $monthly_pattern == "yes" ) $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
633 + if ( $monthly_pattern == "yes" )
634 + $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
635 + else
636 + $current = $temp_current;
458 637 } elseif ( $freq == 4 )
459 638 $current = $this->__getNextYear( $current, $interval_multiplier );
460 -
461 - if ( eval ( $loop_test ) ) {
639 +
640 + $exception_period = false;
641 + if ( is_array( $exceptions_dates ) ) {
642 + foreach ($exceptions_dates as $date) {
643 + if (($current >= $date) && ($current < strtotime("+1 day", $date))) {
644 + $exception_period = true;
645 + break;
646 + }
647 + }
648 + }
649 +
650 + if ( ( eval ( $loop_test ) ) && ( !($exception_period) ) ) {
462 651 $end_current = $current + ( $instance_end - $instance_start );
463 652 if ( $human_readable == true ) {
464 - $active_periods[$period_count]["start"] = date( TIMED_CONTENT_DT_FORMAT, $current );
465 - $active_periods[$period_count]["end"] = date( TIMED_CONTENT_DT_FORMAT, $end_current );
653 + $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
654 + $active_periods[$period_count]["end"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $end_current );
655 + if ( $right_now_t < $current ) {
656 + $active_periods[$period_count]["status"] = "upcoming";
657 + $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
658 + } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
659 + $active_periods[$period_count]["status"] = "active";
660 + $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
661 + } else {
662 + $active_periods[$period_count]["status"] = "expired";
663 + $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
664 + }
466 665 } else {
467 666 $active_periods[$period_count]["start"] = $current;
468 667 $active_periods[$period_count]["end"] = $end_current;
469 668 }
470 - if ( $right_now_t < $current ) {
471 - $active_periods[$period_count]["status"] = "upcoming";
472 - $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
473 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
474 - $active_periods[$period_count]["status"] = "active";
475 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
476 - } else {
477 - $active_periods[$period_count]["status"] = "expired";
478 - $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
479 - }
480 - $period_count++;
669 + if ( !($exception_period) )
670 + $period_count++;
481 671 }
482 672
483 - if ( ( $freq == 3 ) && ( $monthly_pattern == "yes" ) ) $current = $temp_current;
484 673 }
485 674 date_default_timezone_set( $temp_tz );
675 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
486 676 return $active_periods;
487 677 }
488 678
489 679 /**
@@ -518,9 +708,10 @@
518 708 $args['instance_end'] = get_post_meta( $ID, $prefix . 'instance_end', true );
519 709 $args['monthly_pattern'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true );
520 710 $args['monthly_pattern_ord'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true );
521 711 $args['monthly_pattern_day'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true );
522 -
712 + $args['exceptions_dates'] = get_post_meta( $ID, $prefix . 'exceptions_dates', true );
713 +
523 714 return $this->__getRulePeriods( $args );
524 715
525 716 }
526 717
@@ -545,9 +736,10 @@
545 736 $args['instance_end'] = $_POST[$prefix . 'instance_end'];
546 737 $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
547 738 $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
548 739 $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
549 -
740 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
741 +
550 742 $response = json_encode( $this->__getRulePeriods( $args ) );
551 743
552 744 // response output
553 745 header( "Content-Type: application/json" );
@@ -563,9 +755,9 @@
563 755 * @param $args Array of Timed Content Rule parameters
564 756 * @return string
565 757 */
566 758 function __getScheduleDescription( $args ) {
567 - require("lib/Arrays_Definitions.php");
759 + include("lib/Arrays_Definitions.php");
568 760
569 761 $interval_multiplier = 1;
570 762 $desc = "";
571 763
@@ -600,11 +792,12 @@
600 792 $instance_end_time = $args['instance_end']['time'];
601 793 $monthly_pattern = $args['monthly_pattern'];
602 794 $monthly_pattern_ord = $args['monthly_pattern_ord'];
603 795 $monthly_pattern_day = $args['monthly_pattern_day'];
796 + $exceptions_dates = $args['exceptions_dates'];
797 +
798 + $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 );
604 799
605 - $desc = sprintf( _x( '%1$s on %2$s @ %3$s until %4$s @ %5$s.', 'Dates/times of first active period', 'timed-content' ), $action, $instance_start_date, $instance_start_time, $instance_end_date, $instance_end_time );
606 -
607 800 if ( $freq == 0 )
608 801 $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every hour.', 'Repeat this action every %d hours.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
609 802 elseif ( $freq == 1 )
610 803 $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every day.', 'Repeat this action every %d days.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
@@ -631,11 +824,11 @@
631 824
632 825 } elseif ( $freq == 3 ) {
633 826 if ( $monthly_pattern == "yes" ) {
634 827 if ( $interval_multiplier == 1 )
635 - $desc .= "&nbsp;" . sprintf( __( 'Repeat this action every month on the %1$s %2$s of the month.', 'timed-content' ), $timed_content_rule_ordinal_array[$monthly_pattern_ord], $timed_content_rule_ordinal_days_array[$monthly_pattern_day] );
828 + $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every month on the %1$s %2$s of the month.', "Example: 'Repeat this action every month on the second Friday of the month.'", 'timed-content' ), $timed_content_rule_ordinal_array[$monthly_pattern_ord], $timed_content_rule_ordinal_days_array[$monthly_pattern_day] );
636 829 else
637 - $desc .= "&nbsp;" . sprintf( __( 'Repeat this action every %1$d months on the %2$s %3$s of the month.', 'timed-content' ), $interval_multiplier, $timed_content_rule_ordinal_array[$monthly_pattern_ord], $timed_content_rule_ordinal_days_array[$monthly_pattern_day] );
830 + $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every %1$d months on the %2$s %3$s of the month.', "Example: 'Repeat this action every 2 months on the second Friday of the month.'", 'timed-content' ), $interval_multiplier, $timed_content_rule_ordinal_array[$monthly_pattern_ord], $timed_content_rule_ordinal_days_array[$monthly_pattern_day] );
638 831 } else
639 832 $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every month.', 'Repeat this action every %d months.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
640 833 } elseif ( $freq == 4 )
641 834 $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every year.', 'Repeat this action every %d years.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
@@ -643,9 +836,22 @@
643 836 if ( $recurr_type == "recurrence_duration_num_repeat" )
644 837 $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 );
645 838 elseif ( $recurr_type == "recurrence_duration_end_date" )
646 839 $desc .= "&nbsp;" . sprintf( __( 'This rule will be active until %s.', 'timed-content' ), $end_date );
647 -
840 +
841 + if ( ( $exceptions_dates ) && ( is_array( $exceptions_dates ) ) ) {
842 + sort( $exceptions_dates, SORT_NUMERIC );
843 + $exceptions_dates = array_unique( $exceptions_dates );
844 + if ( $exceptions_dates[0] == 0 )
845 + array_shift( $exceptions_dates );
846 + if ( !empty( $exceptions_dates ) ) {
847 + $formatted_dates = array();
848 + foreach ( $exceptions_dates as $a_date )
849 + $formatted_dates[] = date( _x( "F j, Y" , "Date format for schedule description", 'timed-content' ), $a_date );
850 + $desc .= "&nbsp;" . sprintf( __( 'This rule will be inactive on the following dates: %s.', 'timed-content' ), join( ", ", $formatted_dates ) );
851 + }
852 + }
853 +
648 854 $desc .= "&nbsp;" . sprintf( __( 'All times are in the %s timezone.', 'timed-content' ), $timezone );
649 855 return $desc;
650 856 }
651 857
@@ -655,9 +861,12 @@
655 861 * @param int $ID ID of the Timed Content Rule
656 862 * @return string
657 863 */
658 864 function getScheduleDescriptionById( $ID ) {
659 - global $timed_content_rule_occurrence_custom_fields, $timed_content_rule_pattern_custom_fields, $timed_content_rule_recurrence_custom_fields;
865 + global $timed_content_rule_occurrence_custom_fields,
866 + $timed_content_rule_pattern_custom_fields,
867 + $timed_content_rule_recurrence_custom_fields,
868 + $timed_content_rule_exceptions_custom_fields;
660 869 $defaults = array();
661 870
662 871 foreach ( $timed_content_rule_occurrence_custom_fields as $field ) {
663 872 $defaults[$field['name']] = $field['default'];
@@ -664,11 +873,14 @@
664 873 }
665 874 foreach ( $timed_content_rule_pattern_custom_fields as $field ) {
666 875 $defaults[$field['name']] = $field['default'];
667 876 }
668 - foreach ( $timed_content_rule_recurrence_custom_fields as $field ) {
669 - $defaults[$field['name']] = $field['default'];
670 - }
877 + foreach ( $timed_content_rule_recurrence_custom_fields as $field ) {
878 + $defaults[$field['name']] = $field['default'];
879 + }
880 + foreach ( $timed_content_rule_exceptions_custom_fields as $field ) {
881 + $defaults[$field['name']] = $field['default'];
882 + }
671 883
672 884 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
673 885 $args = array();
674 886
@@ -688,8 +900,9 @@
688 900 $args['instance_end'] = ( false === get_post_meta( $ID, $prefix . 'instance_end', true ) ? $defaults['instance_end'] : get_post_meta( $ID, $prefix . 'instance_end', true ) );
689 901 $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 ) );
690 902 $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 ) );
691 903 $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 ) );
904 + $args['exceptions_dates'] = ( false === get_post_meta( $ID, $prefix . 'exceptions_dates', true ) ? $defaults['exceptions_dates'] : get_post_meta( $ID, $prefix . 'exceptions_dates', true ) );
692 905
693 906 return $this->__getScheduleDescription( $args );
694 907
695 908 }
@@ -715,9 +928,10 @@
715 928 $args['instance_end'] = $_POST[$prefix . 'instance_end'];
716 929 $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
717 930 $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
718 931 $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
719 -
932 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
933 +
720 934 $response = $this->__getScheduleDescription( $args );
721 935
722 936 // response output
723 937 header( "Content-Type: text/plain" );
@@ -751,10 +965,20 @@
751 965
752 966 $the_class = TIMED_CONTENT_CLIENT_TAG . $show_attr . $hide_attr ;
753 967 $the_tag = ( $display == "div" ? "div" : "span" );
754 968
755 - $the_HTML = "<" . $the_tag . " class='" . $the_class . "'" . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">" . do_shortcode( $content ) . "</" . $the_tag . ">";
969 + $the_filter = "timed_content_filter";
970 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
756 971
972 + $the_HTML = "<"
973 + . $the_tag
974 + . " class='"
975 + . $the_class
976 + . "'"
977 + . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">"
978 + . str_replace( ']]>', ']]&gt;', apply_filters( $the_filter, $content ) )
979 + . "</" . $the_tag . ">";
980 +
757 981 return $the_HTML;
758 982 }
759 983
760 984 /**
@@ -766,14 +990,18 @@
766 990 */
767 991 function serverShowHTML( $atts, $content = null ) {
768 992 global $post;
769 993 extract( shortcode_atts( array( 'show' => TIMED_CONTENT_ZERO_TIME , 'hide' => TIMED_CONTENT_END_TIME, 'debug' => 'false' ), $atts ) );
770 - $show_t = strtotime( $show );
771 - $hide_t = strtotime( $hide );
772 - $right_now_t = time();
994 + $show_t = strtotime( $this->__datetimeToEnglish( $show ) );
995 + $hide_t = strtotime( $this->__datetimeToEnglish( $hide ) );
996 + $right_now_t = current_time( 'timestamp', 1 );
773 997 $debug_message = "";
774 998
999 + $the_filter = "timed_content_filter";
1000 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1001 +
775 1002 if ( ( $debug == "true" ) && ( current_user_can( "edit_post", $post->post_id ) ) ) {
1003 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
776 1004 $temp_tz = date_default_timezone_get();
777 1005 date_default_timezone_set( get_option( 'timezone_string' ) );
778 1006
779 1007 $right_now = date_i18n( TIMED_CONTENT_DT_FORMAT, $right_now_t );
@@ -788,37 +1016,43 @@
788 1016 $hide_diff_str = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $hide_t, $right_now_t ) );
789 1017
790 1018 $debug_message = "<div class=\"tcr-warning\">\n";
791 1019 $debug_message .= "<p class=\"heading\">" . _x( "Notice", "Noun", 'timed-content' ) . "</p>\n";
792 - $debug_message .= "<p>" . __( "Debugging has been turned on for a <code>[timed-content-server]</code> shortcode on this Post/Page. Only website users who are currently logged in and can edit this Post/Page will see this. To turn off this message, remove the <code>debug</code> attribute from the shortcode.", 'timed-content' ) . "</p>\n";
1020 + $debug_message .= "<p>" . sprintf( __( 'Debugging has been turned on for a %1$s shortcode on this Post/Page. Only website users who are currently logged in and can edit this Post/Page will see this. To turn off this message, remove the %2$s attribute from the shortcode.', 'timed-content' ), "<code>[timed-content-server]</code>" , "<code>debug</code>" ) . "</p>\n";
793 1021
794 1022 if ( $show == TIMED_CONTENT_ZERO_TIME )
795 - $debug_message .= "<p>" . __( 'The <code>show</code> attribute is not set.', 'timed-content') . "</p>\n";
1023 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.', 'timed-content' ), "<code>show</code>" ) . "</p>\n";
796 1024 else
797 - $debug_message .= "<p>" . __( 'The <code>show</code> attribute is currently set to', 'timed-content') . ": " . $show . ",<br />\n "
1025 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>show</code>" ) . ": " . $show . ",<br />\n "
798 1026 . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $show_t )
799 1027 . " (" . $show_diff_str . ")</p>\n";
800 1028
801 1029 if ( $hide == TIMED_CONTENT_END_TIME )
802 - $debug_message .= "<p>" . __( 'The <code>hide</code> attribute is not set.' , 'timed-content') . "</p>\n";
1030 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.' , 'timed-content' ), "<code>hide</code>" ) . "</p>\n";
803 1031 else
804 - $debug_message .= "<p>" . __( 'The <code>hide</code> attribute is currently set to', 'timed-content') . ": " . $hide . ",<br />\n"
1032 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>hide</code>" ) . ": " . $hide . ",<br />\n"
805 1033 . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $hide_t )
806 1034 . " (" . $hide_diff_str . ").</p>\n";
807 1035
808 - $debug_message .= "<p>" . __( 'Current time', 'timed-content') . " : " . $right_now . "</p>\n";
809 - $debug_message .= "<p>" . __( 'Content', "Noun", 'timed-content') . " : " . $content . "</p>\n";
1036 + $debug_message .= "<p>" . __( 'Current Date/Time:', 'timed-content') . "&nbsp;" . $right_now . "<br />\n";
1037 + $debug_message .= __( 'Content Filter:', 'timed-content') . "&nbsp;" . $the_filter . "</p>\n";
1038 + $debug_message .= "<p>" . _x( 'Content:', "Noun", 'timed-content') . "&nbsp;" . $content . "</p>\n";
810 1039
811 1040 $debug_message .= "</div>\n";
812 1041
813 1042 date_default_timezone_set( $temp_tz );
1043 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
814 1044 }
815 -
816 - if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) )
817 - return $debug_message . do_shortcode( $content ) . "\n";
818 - else
819 - return $debug_message . "\n";
820 1045
1046 +
1047 + if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) ) {
1048 + do_action("timed_content_server_show", $post->ID, $show, $hide, $content);
1049 + return $debug_message . str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content)) . "\n";
1050 + } else {
1051 + do_action("timed_content_server_hide", $post->ID, $show, $hide, $content);
1052 + return $debug_message . "\n";
1053 + }
1054 +
821 1055 }
822 1056
823 1057 /**
824 1058 * Processes the [timed-content-rule] shortcode.
@@ -827,13 +1061,19 @@
827 1061 * @param null $content
828 1062 * @return string
829 1063 */
830 1064 function rulesShowHTML( $atts, $content = null ) {
831 - extract( shortcode_atts( array( 'id' => '0' ), $atts ) );
1065 + global $post;
1066 + extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
1067 + if ( !is_numeric( $id ) ) {
1068 + $page = get_page_by_title( $id, OBJECT, TIMED_CONTENT_RULE_TYPE );
1069 + if ( $page == null ) return;
1070 + $id = $page->ID;
1071 + }
832 1072 if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $id ) ) return;
833 1073
834 1074 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
835 - $right_now_t = time();
1075 + $right_now_t = current_time( 'timestamp', 1 );
836 1076 $rule_is_active = false;
837 1077
838 1078 $active_periods = $this->getRulePeriodsById( $id, false );
839 1079 $action_is_show = (bool) get_post_meta( $id, $prefix . 'action', true );
@@ -843,13 +1083,19 @@
843 1083 $rule_is_active = true;
844 1084 break;
845 1085 }
846 1086 }
847 -
848 - if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) )
849 - return do_shortcode( $content );
850 - else
851 - return "";
1087 +
1088 + $the_filter = "timed_content_filter";
1089 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1090 +
1091 + if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) ) {
1092 + do_action("timed_content_rule_show", $post->ID, $id, $content);
1093 + return str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content));
1094 + } else {
1095 + do_action("timed_content_rule_hide", $post->ID, $id, $content);
1096 + return "";
1097 + }
852 1098 }
853 1099
854 1100 /**
855 1101 * Enqueues the JavaScript code necessary for the functionality of the [timed-content-client] shortcode.
@@ -855,30 +1101,58 @@
855 1101 * Enqueues the JavaScript code necessary for the functionality of the [timed-content-client] shortcode.
856 1102 */
857 1103 function addHeaderCode() {
858 1104 if ( ! is_admin() ) {
859 - wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS );
1105 + wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
860 1106 wp_enqueue_script( 'timed-content_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
861 1107 }
862 1108 }
863 1109
1110 + /**
1111 + * Enqueues the CSS code necessary for custom icons for the Timed Content Rules management screens for WP 3.7.1 and under. Echo'd to output.
1112 + */
1113 + function addPostTypeIcons37() {
1114 + ?>
1115 + <style type="text/css" media="screen">
1116 + #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?> .wp-menu-image {
1117 + background: url(<?php echo TIMED_CONTENT_PLUGIN_URL; ?>/img/clock_icon.png) no-repeat 6px 6px !important;
1118 + }
1119 + #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>:hover .wp-menu-image, #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>.wp-has-current-submenu .wp-menu-image {
1120 + background-position: -22px 6px !important;
1121 + }
1122 + #icon-edit.icon32-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?> {background: url(<?php echo TIMED_CONTENT_PLUGIN_URL; ?>/img/clock_32x32.png) no-repeat;}
1123 + </style>
1124 + <?php
1125 + }
1126 +
864 1127 /**
865 - * Enqueues the CSS code necessary for custom icons for the Timed Content Rules management screens. Echo'd to output.
1128 + * Enqueues the CSS code necessary for custom icons for the Timed Content Rules management screens
1129 + * and the TinyMCE editor. Echo'd to output.
866 1130 */
867 1131 function addPostTypeIcons() {
868 -?>
869 -<style type="text/css" media="screen">
870 - #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?> .wp-menu-image {
871 - background: url(<?php echo TIMED_CONTENT_PLUGIN_URL; ?>/img/clock_icon.png) no-repeat 6px 6px !important;
872 - }
873 - #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>:hover .wp-menu-image, #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>.wp-has-current-submenu .wp-menu-image {
874 - background-position: -22px 6px !important;
875 - }
876 - #icon-edit.icon32-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?> {background: url(<?php echo TIMED_CONTENT_PLUGIN_URL; ?>/img/clock_32x32.png) no-repeat;}
877 -</style>
1132 + wp_enqueue_style( 'ca-aliencyborg-dashicons', TIMED_CONTENT_CSS_DASHICONS, false, TIMED_CONTENT_VERSION );
1133 + ?>
1134 + <style type="text/css" media="screen">
1135 + #adminmenu #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>.menu-icon-post div.wp-menu-image:before {
1136 + font-family: 'ca-aliencyborg-dashicons' !important;
1137 + content: '\e601';
1138 + }
1139 + #dashboard_right_now li.<?php echo TIMED_CONTENT_RULE_TYPE; ?>-count a:before {
1140 + font-family: 'ca-aliencyborg-dashicons' !important;
1141 + content: '\e601';
1142 + }
1143 + .mce-i-timed_content:before {
1144 + font: 400 24px/1 'ca-aliencyborg-dashicons' !important;
1145 + padding: 0;
1146 + vertical-align: top;
1147 + margin-left: -2px;
1148 + padding-right: 2px;
1149 + content: '\e601';
1150 + }
1151 + </style>
878 1152 <?php
879 1153 }
880 -
1154 +
881 1155 /**
882 1156 * Enqueues the JavaScript code necessary for the functionality of the Timed Content Rules management screens.
883 1157 */
884 1158 function addAdminHeaderCode() {
@@ -884,25 +1158,30 @@
884 1158 function addAdminHeaderCode() {
885 1159 if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == TIMED_CONTENT_RULE_TYPE )
886 1160 || ( isset( $post_type ) && $post_type == TIMED_CONTENT_RULE_TYPE )
887 1161 || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == TIMED_CONTENT_RULE_TYPE ) ) {
888 - wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS );
1162 + wp_enqueue_style( 'thickbox' );
1163 + wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
889 1164 // Enqueue the JavaScript file that manages the meta box UI
890 1165 wp_enqueue_script( 'timed-content-admin_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
891 1166 // Enqueue the JavaScript file that makes AJAX requests
892 - wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'jquery-ui-dialog' ), TIMED_CONTENT_VERSION );
1167 + wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'thickbox' ), TIMED_CONTENT_VERSION );
893 1168
1169 + // Set up local variables used in the Admin JavaScript file
1170 + wp_localize_script( 'timed-content-admin_js', 'timedContentRuleAdmin', array(
1171 + 'no_exceptions_label' => __( "- No exceptions set -", 'timed-content' ) ) );
1172 +
894 1173 // Set up local variables used in the AJAX JavaScript file
895 1174 wp_localize_script( 'timed-content-ajax_js', 'timedContentRuleAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
896 1175 'start_label' => _x( 'Start', 'Scheduled Dates/Times dialog - Beginning of active period table header', 'timed-content' ),
897 1176 'end_label' => _x( 'End', 'Scheduled Dates/Times dialog - End of active period table header', 'timed-content' ),
898 - 'dialog_label' => _x( 'Scheduled Dates/Times', 'Scheduled Dates/Times dialog - dialog header', 'timed-content' ),
899 - 'dialog_width' => 800,
900 - 'dialog_height' => 500,
901 - 'close_label' => _x( 'Close', 'Scheduled Dates/Times dialog - Close button HTML label', 'timed-content' ),
902 - 'loadingimg' => TIMED_CONTENT_PLUGIN_URL . '/img/wpspin.gif',
903 - 'error' => __( "Error", 'timed-content' ),
904 - 'error_desc' => __( "Something unexpected has happened along the way. The specific details are below:", 'timed-content' ) ) );
1177 + 'dialog_label' => _x( 'Scheduled Dates/Times', 'Scheduled Dates/Times dialog - dialog header', 'timed-content' ),
1178 + 'button_loading_label' => __( 'Calculating Dates/Times', 'timed-content' ),
1179 + 'button_finished_label' => __( 'Show Projected Dates/Times', 'timed-content' ),
1180 + 'dialog_width' => 800,
1181 + 'dialog_height' => 500,
1182 + 'error' => __( "Error", 'timed-content' ),
1183 + 'error_desc' => __( "Something unexpected has happened along the way. The specific details are below:", 'timed-content' ) ) );
905 1184 }
906 1185 }
907 1186
908 1187 /**
@@ -919,22 +1198,27 @@
919 1198 }
920 1199 }
921 1200
922 1201 /**
923 - * Sets up variables to use in the TinyMCE plugin's editor_plugin_src.js.
1202 + * Sets up variables to use in the TinyMCE plugin's plugin.js.
924 1203 *
925 1204 */
926 1205 function setTinyMCEPluginVars() {
1206 + global $wp_version;
927 1207 if ( ( ! current_user_can( 'edit_posts' ) ) && ( ! current_user_can( 'edit_pages' ) ) )
928 1208 return;
929 1209
930 1210 // Add only in Rich Editor mode
931 1211 if ( get_user_option( 'rich_editing' ) == 'true' ) {
932 - wp_enqueue_script( 'timed-content-admin_tinymce_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin-tinymce.js', array(), TIMED_CONTENT_VERSION );
933 - wp_localize_script( 'timed-content-admin_tinymce_js',
934 - 'timedContentAdminTinyMCEOptionsVars',
935 - array( 'version' => TIMED_CONTENT_VERSION,
936 - 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ) ) );
1212 + if ( version_compare( $wp_version, "3.8", "<" ) )
1213 + $image = "/clock.gif";
1214 + else
1215 + $image = "";
1216 + wp_localize_script( 'editor',
1217 + 'timedContentAdminTinyMCEOptions',
1218 + array( 'version' => TIMED_CONTENT_VERSION,
1219 + 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ),
1220 + 'image' => $image ) );
937 1221 }
938 1222 }
939 1223
940 1224 /**
@@ -953,9 +1237,9 @@
953 1237 * @param array $plugin_array Array of plugins already registered with TinyMCE
954 1238 * @return array The array of TinyMCE plugins with ours now loaded in as well
955 1239 */
956 1240 function addTimedContentTinyMCEPlugin( $plugin_array ) {
957 - $plugin_array['timed_content'] = TIMED_CONTENT_PLUGIN_URL . "/tinymce_plugin/editor_plugin.js";
1241 + $plugin_array['timed_content'] = TIMED_CONTENT_PLUGIN_URL . "/tinymce_plugin/plugin.js";
958 1242 return $plugin_array;
959 1243 }
960 1244
961 1245 /**
@@ -971,10 +1255,13 @@
971 1255 foreach ( $the_rules as $rule ) {
972 1256 $desc = $this->getScheduleDescriptionById( $rule->ID );
973 1257 // Only add a rule if there's no errors or warnings
974 1258 if ( false === strpos( $desc, "tcr-warning" ) )
975 - $the_js .= " { 'ID': " . $rule->ID . ", 'title': '" . esc_js( $rule->post_title ) . "', 'desc': '" . esc_js( $desc ) . "' },\n";
1259 + $the_js .= " { 'ID': " . $rule->ID . ", 'title': '" . esc_js( ( ( strlen( $rule->post_title ) > 0 ) ? $rule->post_title : _x( "(no title)", "No Timed Content Rule title", "timed-content" ) ) ) . "', 'desc': '" . esc_js( $desc ) . "' },\n";
976 1260 }
1261 + if ( empty( $the_rules ) )
1262 + $the_js .= " { 'ID': -999, 'title': ' ---- ', 'desc': '" . __( 'No Timed Content Rules found', 'timed-content' ) . "' }\n";
1263 +
977 1264 $the_js .= "];\n";
978 1265 return $the_js;
979 1266 }
980 1267 /**
@@ -981,17 +1268,25 @@
981 1268 * Display a dialog box for this plugin's associated TinyMCE plugin. Called from TinyMCE via AJAX.
982 1269 *
983 1270 */
984 1271 function timedContentPluginGetTinyMCEDialog() {
985 - wp_enqueue_style( 'timed-content-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS );
986 - wp_enqueue_script( 'jquery-ui-datepicker' );
987 - wp_register_style( 'timed-content-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS );
988 - wp_enqueue_style( 'timed-content-jquery-ui-timepicker-css' );
989 - wp_register_script( 'timed-content-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array('jquery', 'jquery-ui-datepicker'), TIMED_CONTENT_VERSION );
990 - wp_enqueue_script( 'timed-content-jquery-ui-timepicker-js' );
1272 + include("lib/jquery-ui-datetime-i18n.php");
991 1273
1274 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS);
1275 + wp_enqueue_script('jquery-ui-datepicker');
1276 + wp_register_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS);
1277 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css');
1278 + wp_register_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array('jquery', 'jquery-ui-datepicker'), TIMED_CONTENT_VERSION);
1279 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js');
1280 + if (!(wp_script_is(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'registered'))) {
1281 + 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);
1282 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js');
1283 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n);
1284 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n);
1285 + }
1286 +
992 1287 ob_start();
993 - include("tinymce_plugin/dialog.php");
1288 + include( "tinymce_plugin/dialog.php" );
994 1289 $content = ob_get_contents();
995 1290 ob_end_clean();
996 1291 echo $content;
997 1292 die();
@@ -997,14 +1292,14 @@
997 1292 die();
998 1293 }
999 1294
1000 1295 /**
1001 - * Displays a count of Timed Content Rules of the Dashboard's Right now widget
1296 + * Adds support for i18n (internationalization)
1002 1297 *
1003 1298 */
1004 1299 function i18nInit() {
1005 1300 $plugin_dir = basename( dirname( __FILE__ ) ) . "/lang/";
1006 - load_plugin_textdomain( 'timed-content', null, $plugin_dir );
1301 + load_plugin_textdomain( 'timed-content', false, $plugin_dir );
1007 1302 }
1008 1303
1009 1304 /**
1010 1305 * Add custom columns to the Timed Content Rules overview page
@@ -1034,11 +1329,45 @@
1034 1329 }
1035 1330 }
1036 1331 }
1037 1332
1333 + /**
1334 + * Display a count of Timed Content Rules in the Dashboard's Right Now widget for Wordpress versions 3.7.1 and below
1335 + *
1336 + */
1337 + function addRulesCount37() {
1338 + if ( !post_type_exists( TIMED_CONTENT_RULE_TYPE ) ) {
1339 + return;
1340 + }
1038 1341
1342 + $num_posts = wp_count_posts( TIMED_CONTENT_RULE_TYPE );
1343 + $num = number_format_i18n( $num_posts->publish );
1344 + $text = _n( 'Timed Content Rule', 'Timed Content Rules', intval( $num_posts->publish ), 'timed-content' );
1345 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
1346 + $num = "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $num . "</a>";
1347 + $text = "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $text . "</a>";
1348 + }
1349 + echo '<tr>';
1350 + echo '<td class="first b b-' . TIMED_CONTENT_RULE_TYPE . '">' . $num . '</td>';
1351 + echo '<td class="t ' . TIMED_CONTENT_RULE_TYPE . '">' . $text . '</td>';
1352 + echo '</tr>';
1353 +
1354 + if ( $num_posts->pending > 0 ) {
1355 + $num = number_format_i18n( $num_posts->pending );
1356 + $text = _n( 'Timed Content Rule Pending', 'Timed Content Rules Pending', intval( $num_posts->pending ), 'timed-content' );
1357 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
1358 + $num = "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $num . "</a>";
1359 + $text = "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $text . "</a>";
1360 + }
1361 + echo '<tr>';
1362 + echo '<td class="first b b-' . TIMED_CONTENT_RULE_TYPE . '">' . $num . '</td>';
1363 + echo '<td class="t ' . TIMED_CONTENT_RULE_TYPE . '">' . $text . '</td>';
1364 + echo '</tr>';
1365 + }
1366 + }
1367 +
1039 1368 /**
1040 - * Display a count of Timed Content Rules of the Dashboard's Right now widget
1369 + * Display a count of Timed Content Rules in the Dashboard's Right Now widget
1041 1370 *
1042 1371 */
1043 1372 function addRulesCount() {
1044 1373 if ( !post_type_exists( TIMED_CONTENT_RULE_TYPE ) ) {
@@ -1046,31 +1375,75 @@
1046 1375 }
1047 1376
1048 1377 $num_posts = wp_count_posts( TIMED_CONTENT_RULE_TYPE );
1049 1378 $num = number_format_i18n( $num_posts->publish );
1050 - $text = _n( 'Timed Content Rule', 'Timed Content Rules', intval( $num_posts->publish ) );
1051 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
1052 - $num = "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $num . "</a>";
1053 - $text = "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $text . "</a>";
1054 - }
1055 - echo '<tr>';
1056 - echo '<td class="first b b-' . TIMED_CONTENT_RULE_TYPE . '">' . $num . '</td>';
1057 - echo '<td class="t ' . TIMED_CONTENT_RULE_TYPE . '">' . $text . '</td>';
1058 - echo '</tr>';
1379 + $text = _n( 'Timed Content Rule', 'Timed Content Rules', intval( $num_posts->publish ), 'timed-content' );
1380 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) )
1381 + echo "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>"
1382 + . '<li class="' . TIMED_CONTENT_RULE_TYPE . '-count">'
1383 + . $num
1384 + . ' '
1385 + . $text
1386 + . '</a></li>';
1059 1387
1060 1388 if ( $num_posts->pending > 0 ) {
1061 1389 $num = number_format_i18n( $num_posts->pending );
1062 - $text = _n( 'Timed Content Rule Pending', 'Timed Content Rules Pending', intval( $num_posts->pending ) );
1063 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
1064 - $num = "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $num . "</a>";
1065 - $text = "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>" . $text . "</a>";
1066 - }
1067 - echo '<tr>';
1068 - echo '<td class="first b b-' . TIMED_CONTENT_RULE_TYPE . '">' . $num . '</td>';
1069 - echo '<td class="t ' . TIMED_CONTENT_RULE_TYPE . '">' . $text . '</td>';
1070 - echo '</tr>';
1071 - }
1390 + $text = _n( 'Timed Content Rule Pending', 'Timed Content Rules Pending', intval( $num_posts->pending ), 'timed-content' );
1391 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) )
1392 + echo "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>"
1393 + . '<li class="' . TIMED_CONTENT_RULE_TYPE . '-count">'
1394 + . $num
1395 + . ' '
1396 + . $text
1397 + . '</a></li>';
1398 + }
1072 1399 }
1400 +
1401 + function setUpCustomFields() {
1402 + require_once( "lib/customFields-settings.php" );
1403 + require_once( "lib/customFieldsInterface.php" );
1404 +
1405 + $scf = new customFieldsInterface( "timed_content_rule_schedule",
1406 + __( 'Rule Description/Schedule', 'timed-content' ),
1407 + "<div id=\"schedule_desc\" style=\"font-style: italic;\">"
1408 + . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $this->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $this->getScheduleDescriptionById( intval( 0 ) ) )
1409 + . "</div>"
1410 + . "<div id=\"tcr-dialogHolder\" style=\"display:none;\"></div>"
1411 + . "<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>",
1412 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1413 + array( TIMED_CONTENT_RULE_TYPE ),
1414 + array() );
1415 + $ocf = new customFieldsInterface( "timed_content_rule_initial_event",
1416 + __( 'Action/Initial Event', 'timed-content' ),
1417 + __( 'Set the action to be taken and when it should first run.', 'timed-content' ),
1418 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1419 + array( TIMED_CONTENT_RULE_TYPE ),
1420 + $timed_content_rule_occurrence_custom_fields );
1421 + $pcf = new customFieldsInterface( "timed_content_rule_recurrence",
1422 + __( 'Repeating Pattern', 'timed-content' ),
1423 + __( 'Set how often the action should repeat.', 'timed-content' ),
1424 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1425 + array( TIMED_CONTENT_RULE_TYPE ),
1426 + $timed_content_rule_pattern_custom_fields );
1427 + $rcf = new customFieldsInterface( "timed_content_rule_stop_condition",
1428 + __( 'Stopping Condition', 'timed-content' ),
1429 + __( 'Set how long or how many times the action should occur.', 'timed-content' ),
1430 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1431 + array( TIMED_CONTENT_RULE_TYPE ),
1432 + $timed_content_rule_recurrence_custom_fields );
1433 + $ecf = new customFieldsInterface( "timed_content_rule_exceptions",
1434 + __( 'Exceptions', 'timed-content' ),
1435 + __( 'Set up any exceptions to this Timed Content Rule.', 'timed-content' ),
1436 + TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1437 + array( TIMED_CONTENT_RULE_TYPE ),
1438 + $timed_content_rule_exceptions_custom_fields );
1439 +
1440 + // Initially loaded at the top; defining this constant here means it can get i18n'd
1441 + /* translators: date/time format for debugging messages. http://ca2.php.net/manual/en/function.date.php */
1442 + define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1443 +
1444 + }
1445 +
1073 1446 }
1074 1447
1075 1448 } //End Class timedContentPlugin
1076 1449
@@ -1080,38 +1453,20 @@
1080 1453 }
1081 1454
1082 1455 // Actions and Filters
1083 1456 if ( isset( $timedContentPluginInstance ) ) {
1084 - $scf = new customFieldsInterface( "cfi_s",
1085 - __( 'Rule Description/Schedule', 'timed-content' ),
1086 - "<div id=\"schedule_desc\" style=\"font-style: italic;\">"
1087 - . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $timedContentPluginInstance->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $timedContentPluginInstance->getScheduleDescriptionById( intval( 0 ) ) )
1088 - . "</div>"
1089 - . "<div style=\"padding-top: 10px;\"><input type=\"button\" class=\"button-primary\" id=\"timed_content_rule_test\" value=\"Show Projected Dates/Times\" /></div>",
1090 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1091 - array( TIMED_CONTENT_RULE_TYPE ),
1092 - array() );
1093 - $ocf = new customFieldsInterface( "cfi_o",
1094 - __( 'Action/Initial Event', 'timed-content' ),
1095 - __( 'Set the action to be taken and when it should first run.', 'timed-content' ),
1096 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1097 - array( TIMED_CONTENT_RULE_TYPE ),
1098 - $timed_content_rule_occurrence_custom_fields );
1099 - $pcf = new customFieldsInterface( "cfi_p",
1100 - __( 'Repeating Pattern', 'timed-content' ),
1101 - __( 'Set how often the action should repeat.', 'timed-content' ),
1102 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1103 - array( TIMED_CONTENT_RULE_TYPE ),
1104 - $timed_content_rule_pattern_custom_fields );
1105 - $rcf = new customFieldsInterface( "cfi_r",
1106 - __( 'Stopping Condition', 'timed-content' ),
1107 - __( 'Set how long or how many times the action should occur.', 'timed-content' ),
1108 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1109 - array( TIMED_CONTENT_RULE_TYPE ),
1110 - $timed_content_rule_recurrence_custom_fields );
1111 - add_action( "init", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1457 + global $wp_version;
1458 +
1459 + add_filter('timed_content_filter', 'wptexturize');
1460 + add_filter('timed_content_filter', 'convert_smilies');
1461 + add_filter('timed_content_filter', 'convert_chars');
1462 + add_filter('timed_content_filter', 'wpautop');
1463 + add_filter('timed_content_filter', 'prepend_attachment');
1464 + add_filter('timed_content_filter', 'do_shortcode');
1465 +
1466 + add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1112 1467 add_action( "init", array( &$timedContentPluginInstance, "timedContentRuleTypeInit" ), 2 );
1113 - add_action( "right_now_content_table_end", array( &$timedContentPluginInstance, "addRulesCount" ) );
1468 + add_action( "init", array( &$timedContentPluginInstance, "setUpCustomFields" ), 2 );
1114 1469 add_action( "wp_head", array( &$timedContentPluginInstance, "addHeaderCode" ), 1 );
1115 1470 add_filter( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_columns", array( &$timedContentPluginInstance, "addDescColumnHead" ) );
1116 1471 add_action( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_custom_column", array( &$timedContentPluginInstance, "addDescColumnContent" ), 10, 2);
1117 1472 add_action( "admin_enqueue_scripts", array( &$timedContentPluginInstance, "addAdminHeaderCode" ), 1 );
@@ -1116,14 +1471,21 @@
1116 1471 add_action( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_custom_column", array( &$timedContentPluginInstance, "addDescColumnContent" ), 10, 2);
1117 1472 add_action( "admin_enqueue_scripts", array( &$timedContentPluginInstance, "addAdminHeaderCode" ), 1 );
1118 1473 add_action( "admin_init", array( &$timedContentPluginInstance, "setTinyMCEPluginVars" ), 1 );
1119 1474 add_action( "admin_init", array( &$timedContentPluginInstance, "initTinyMCEPlugin" ), 2 );
1120 - add_action( "admin_head", array( &$timedContentPluginInstance, "addPostTypeIcons" ), 1 );
1121 1475 add_action( 'wp_ajax_timedContentPluginGetTinyMCEDialog', array( &$timedContentPluginInstance, "timedContentPluginGetTinyMCEDialog" ), 1 );
1122 1476 add_action( 'wp_ajax_timedContentPluginGetRulePeriodsAjax', array( &$timedContentPluginInstance, "timedContentPluginGetRulePeriodsAjax" ), 1 );
1123 1477 add_action( 'wp_ajax_timedContentPluginGetScheduleDescriptionAjax', array( &$timedContentPluginInstance, "timedContentPluginGetScheduleDescriptionAjax" ), 1 );
1124 1478 add_filter( "post_updated_messages", array( &$timedContentPluginInstance, "timedContentRuleUpdatedMessages" ), 1 );
1125 - add_shortcode( TIMED_CONTENT_CLIENT_TAG, array( &$timedContentPluginInstance, "clientShowHTML" ), 1 );
1479 + if ( version_compare( $wp_version, "3.8", ">=" ) ) {
1480 + add_action( "dashboard_glance_items", array( &$timedContentPluginInstance, "addRulesCount" ) );
1481 + add_action( "admin_head", array( &$timedContentPluginInstance, "addPostTypeIcons" ), 1 );
1482 + } else {
1483 + add_action( "right_now_content_table_end", array( &$timedContentPluginInstance, "addRulesCount37" ) );
1484 + add_action( "admin_head", array( &$timedContentPluginInstance, "addPostTypeIcons37" ), 1 );
1485 + }
1486 +
1487 + add_shortcode( TIMED_CONTENT_CLIENT_TAG, array( &$timedContentPluginInstance, "clientShowHTML" ), 1 );
1126 1488 add_shortcode( TIMED_CONTENT_SERVER_TAG, array( &$timedContentPluginInstance, "serverShowHTML" ), 1 );
1127 1489 add_shortcode( TIMED_CONTENT_RULE_TAG, array( &$timedContentPluginInstance, "rulesShowHTML" ), 1 );
1128 1490 }
1129 1491 ?>