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 +900 -940 2.152.7 View file →
@@ -5,26 +5,26 @@
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 8 Author: K. Tough, Arno Welzel
9 -Version: 2.15
9 +Version: 2.7
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.15" );
14 + define( "TIMED_CONTENT_VERSION", "2.7" );
15 15 define( "TIMED_CONTENT_SLUG", "timed-content" );
16 - define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/' . TIMED_CONTENT_SLUG );
16 + define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/' . TIMED_CONTENT_SLUG );
17 17 define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
18 - define( "TIMED_CONTENT_SERVER_TAG", "timed-content-server" );
19 - define( "TIMED_CONTENT_RULE_TAG", "timed-content-rule" );
20 - define( "TIMED_CONTENT_ZERO_TIME", "1970-Jan-01 00:00:00 +000" ); // Start of Unix Epoch
21 - define( "TIMED_CONTENT_END_TIME", "2038-Jan-19 03:14:07 +000" ); // End of Unix Epoch
22 - define( "TIMED_CONTENT_RULE_TYPE", "timed_content_rule" );
23 - define( "TIMED_CONTENT_RULE_POSTMETA_PREFIX", TIMED_CONTENT_RULE_TYPE . "_" );
18 + define( "TIMED_CONTENT_SERVER_TAG", "timed-content-server" );
19 + define( "TIMED_CONTENT_RULE_TAG", "timed-content-rule" );
20 + define( "TIMED_CONTENT_ZERO_TIME", "1970-Jan-01 00:00:00 +000" ); // Start of Unix Epoch
21 + define( "TIMED_CONTENT_END_TIME", "2038-Jan-19 03:14:07 +000" ); // End of Unix Epoch
22 + define( "TIMED_CONTENT_RULE_TYPE", "timed_content_rule" );
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 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 + // Required for styling the jQuery UI Datepicker and jQuery UI Timepicker
27 27 define( "TIMED_CONTENT_JQUERY_UI_CSS", TIMED_CONTENT_PLUGIN_URL . "/css/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" );
28 28 define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS", TIMED_CONTENT_PLUGIN_URL . "/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.js" );
29 29 define( "TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS", TIMED_CONTENT_PLUGIN_URL . "/js/jquery-ui-timepicker-0.3.3/jquery.ui.timepicker.css" );
30 30
@@ -35,218 +35,196 @@
35 35 * Class that contains all of the functions required to run the plugin. This cuts down on
36 36 * the possibility of name collisions with other plugins.
37 37 */
38 38 class timedContentPlugin {
39 -
40 - function __construct() {
41 - //constructor
39 +
40 + function __construct() {
41 + //constructor
42 42
43 - }
43 + }
44 44
45 - function timedContentPlugin() {
46 - self::__construct();
45 + function timedContentPlugin() {
46 + self::__construct();
47 47
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;
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;
67 67
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');
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 + }
75 76
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 77
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));
78 + // get components of the date (timestamp) as array
79 + $date_components = getdate($timestamp);
98 80
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);
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));
106 93
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 - );
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);
121 101
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);
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 + );
129 116
130 - if ($translate_formats_index !== false)
131 - {
132 - // counts the slashes (the escape char) in front of the current char
133 - $slashes_counter = 0;
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);
134 124
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 - }
125 + if ($translate_formats_index !== false)
126 + {
127 + // counts the slashes (the escape char) in front of the current char
128 + $slashes_counter = 0;
143 129
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 - }
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 + }
156 138
157 - $req_format = $translated_date_format_string;
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 + }
158 151
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();
152 + $req_format = $translated_date_format_string;
168 153
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 - }
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();
188 163
189 - return $date_formatted;
190 - }
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 + }
191 183
192 - /**
184 + return $date_formatted;
185 + }
186 +
187 + /**
193 188 * Creates the Timed Content Rule post type and registers it with Wordpress
194 189 *
195 190 */
196 - function timedContentRuleTypeInit()
197 - {
198 - $labels = array(
199 - 'name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' ),
200 - 'singular_name' => _x( 'Timed Content Rule', 'post type singular name', 'timed-content' ),
201 - 'add_new' => _x( 'Add New', 'Menu item/button label on Timed Content Rules admin page', 'timed-content' ),
202 - 'add_new_item' => __( 'Add New Timed Content Rule', 'timed-content' ),
203 - 'edit_item' => __( 'Edit Timed Content Rule', 'timed-content' ),
204 - 'new_item' => __( 'New Timed Content Rule', 'timed-content' ),
205 - 'view_item' => __( 'View Timed Content Rule', 'timed-content' ),
206 - 'search_items' => __( 'Search Timed Content Rules', 'timed-content' ),
207 - 'not_found' => __( 'No Timed Content Rules found', 'timed-content' ),
208 - 'not_found_in_trash' => __( 'No Timed Content Rules found in Trash', 'timed-content' ),
209 - 'parent_item_colon' => '',
210 - 'menu_name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' )
211 - );
212 - $args = array(
213 - 'labels' => $labels,
214 - 'description' => __( 'Create regular schedules to show or hide selected content in a Page or Post.', 'timed-content' ),
215 - 'public' => false,
216 - 'publicly_queryable' => false,
217 - 'exclude_from_search' => false,
218 - 'show_ui' => true,
219 - 'show_in_menu' => true,
220 - 'show_in_nav_menus' => true,
221 - 'show_in_admin_bar' => true,
222 - 'query_var' => false,
223 - 'rewrite' => false,
224 - 'capability_type' => 'post',
225 - 'has_archive' => false,
226 - 'hierarchical' => false,
227 - 'menu_position' => 5,
228 - 'supports' => array( 'title' )
229 - );
230 - register_post_type( TIMED_CONTENT_RULE_TYPE, $args );
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 - }
191 + function timedContentRuleTypeInit()
192 + {
193 + $labels = array(
194 + 'name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' ),
195 + 'singular_name' => _x( 'Timed Content Rule', 'post type singular name', 'timed-content' ),
196 + 'add_new' => _x( 'Add New', 'Menu item/button label on Timed Content Rules admin page', 'timed-content' ),
197 + 'add_new_item' => __( 'Add New Timed Content Rule', 'timed-content' ),
198 + 'edit_item' => __( 'Edit Timed Content Rule', 'timed-content' ),
199 + 'new_item' => __( 'New Timed Content Rule', 'timed-content' ),
200 + 'view_item' => __( 'View Timed Content Rule', 'timed-content' ),
201 + 'search_items' => __( 'Search Timed Content Rules', 'timed-content' ),
202 + 'not_found' => __( 'No Timed Content Rules found', 'timed-content' ),
203 + 'not_found_in_trash' => __( 'No Timed Content Rules found in Trash', 'timed-content' ),
204 + 'parent_item_colon' => '',
205 + 'menu_name' => _x( 'Timed Content Rules', 'post type general name', 'timed-content' )
206 + );
207 + $args = array(
208 + 'labels' => $labels,
209 + 'description' => __( 'Create regular schedules to show or hide selected content in a Page or Post.', 'timed-content' ),
210 + 'public' => false,
211 + 'publicly_queryable' => false,
212 + 'exclude_from_search' => false,
213 + 'show_ui' => true,
214 + 'show_in_menu' => true,
215 + 'show_in_nav_menus' => true,
216 + 'show_in_admin_bar' => true,
217 + 'query_var' => false,
218 + 'rewrite' => false,
219 + 'capability_type' => 'post',
220 + 'has_archive' => false,
221 + 'hierarchical' => false,
222 + 'menu_position' => 5,
223 + 'supports' => array( 'title' )
224 + );
225 + register_post_type( TIMED_CONTENT_RULE_TYPE, $args );
226 + }
249 227
250 228 /**
251 229 * Filter to customize CRUD messages for Timed Content Rules
252 230 *
@@ -253,31 +231,31 @@
253 231 * @param array $messages Array of currently defined messages for post types
254 232 * @return mixed Array of messages with appropriate messages for Timed Content Rules added in
255 233 */
256 234 function timedContentRuleUpdatedMessages( $messages ) {
257 - global $post;
235 + global $post;
258 236
259 - /* translators: date and time format to activate rule. http://ca2.php.net/manual/en/function.date.php*/
237 + /* translators: date and time format to activate rule. http://ca2.php.net/manual/en/function.date.php*/
260 238 $post_date = date_i18n( __( 'M j, Y @ G:i', 'timed-content' ), strtotime( $post->post_date ) );
261 239
262 - $messages[TIMED_CONTENT_RULE_TYPE] = array(
263 - 0 => '', // Unused. Messages start at index 1.
264 - 1 => __( 'Timed Content Rule updated.', 'timed-content' ),
265 - 2 => __( 'Custom field updated.', 'timed-content' ),
266 - 3 => __( 'Custom field deleted.', 'timed-content' ),
267 - 4 => __( 'Timed Content Rule updated.', 'timed-content' ),
268 - /* translators: %s: date and time of the revision */
269 - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Timed Content Rule restored to revision from %s', 'timed-content' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
270 - 6 => __( 'Timed Content Rule published.', 'timed-content' ),
271 - 7 => __( 'Timed Content Rule saved.', 'timed-content' ),
272 - 8 => __( 'Timed Content Rule submitted.', 'timed-content' ),
273 - /* translators: %s: date and time to activate rule. */
274 - 9 => sprintf( __( 'Timed Content Rule scheduled for: %s.' , 'timed-content' ), "<strong>" . $post_date . "</strong>" ),
275 - 10 => __( 'Timed Content Rule draft updated.', 'timed-content' )
276 - );
277 -
278 - return $messages;
279 - }
240 + $messages[TIMED_CONTENT_RULE_TYPE] = array(
241 + 0 => '', // Unused. Messages start at index 1.
242 + 1 => __( 'Timed Content Rule updated.', 'timed-content' ),
243 + 2 => __( 'Custom field updated.', 'timed-content' ),
244 + 3 => __( 'Custom field deleted.', 'timed-content' ),
245 + 4 => __( 'Timed Content Rule updated.', 'timed-content' ),
246 + /* translators: %s: date and time of the revision */
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,
248 + 6 => __( 'Timed Content Rule published.', 'timed-content' ),
249 + 7 => __( 'Timed Content Rule saved.', 'timed-content' ),
250 + 8 => __( 'Timed Content Rule submitted.', 'timed-content' ),
251 + /* translators: %s: date and time to activate rule. */
252 + 9 => sprintf( __( 'Timed Content Rule scheduled for: %s.' , 'timed-content' ), "<strong>" . $post_date . "</strong>" ),
253 + 10 => __( 'Timed Content Rule draft updated.', 'timed-content' )
254 + );
255 +
256 + return $messages;
257 + }
280 258
281 259 function __datetimeToEnglish( $date, $time = "" ) {
282 260 $months = array( "January",
283 261 "February",
@@ -313,11 +291,11 @@
313 291 * @param int $current UNIX timestamp of the date/time before incrementing
314 292 * @param int $interval_multiplier Number of days to advance
315 293 * @return int Unix timestamp of the new date/time
316 294 */
317 - function __getNextDay( $current, $interval_multiplier ) {
318 - return strtotime( $interval_multiplier . " day", $current );
319 - }
295 + function __getNextDay( $current, $interval_multiplier ) {
296 + return strtotime( $interval_multiplier . " day", $current );
297 + }
320 298
321 299 /**
322 300 * Advances a date/time by a set number of hours
323 301 *
@@ -325,10 +303,10 @@
325 303 * @param int $interval_multiplier Number of hours to advance
326 304 * @return int Unix timestamp of the new date/time
327 305 */
328 306 function __getNextHour( $current, $interval_multiplier ) {
329 - return strtotime( $interval_multiplier . " hour", $current );
330 - }
307 + return strtotime( $interval_multiplier . " hour", $current );
308 + }
331 309
332 310 /**
333 311 * Advances a date/time by a set number of weeks
334 312 *
@@ -343,31 +321,31 @@
343 321 * @return int Unix timestamp of the new date/time
344 322 */
345 323 function __getNextWeek( $current, $interval_multiplier, $days = array() ) {
346 324 // If $days is empty, advance $interval_multiplier weeks from $current and return the timestamp
347 - if ( empty( $days ) ) return strtotime( $interval_multiplier . " week", $current );
325 + if ( empty( $days ) ) return strtotime( $interval_multiplier . " week", $current );
348 326
349 327 // Otherwise, set up an array combining the days of the week to repeat on and the current day
350 328 // (keys and values of the array will be the same, and the array is sorted)
351 - $currentDayOfWeekIndex = date( "w", $current );
329 + $currentDayOfWeekIndex = date( "w", $current );
352 330 $days = array_merge( array( $currentDayOfWeekIndex ), $days );
353 331 $days = array_unique( $days );
354 332 $days = array_values( $days );
355 333 sort( $days );
356 - $daysOfWeek = array_combine( $days, $days );
334 + $daysOfWeek = array_combine( $days, $days );
357 335
358 336 // If the current day is the last one of the days of the week to repeat on, jump ahead to
359 337 // the next week to be repeating on and get the earliest day in the array
360 - if ( $currentDayOfWeekIndex == max( $daysOfWeek ) )
361 - $pattern = ( ( 7 - $currentDayOfWeekIndex ) + ( 7 * ( $interval_multiplier - 1 ) ) + ( min( array_keys( $daysOfWeek ) ) ) ) . " day";
338 + if ( $currentDayOfWeekIndex == max( $daysOfWeek ) )
339 + $pattern = ( ( 7 - $currentDayOfWeekIndex ) + ( 7 * ( $interval_multiplier - 1 ) ) + ( min( array_keys( $daysOfWeek ) ) ) ) . " day";
362 340 // Otherwise, cycle through the array until we find the next day to repeat on
363 - else {
364 - $nextDayOfWeekIndex = $currentDayOfWeekIndex;
365 - do {} while ( !isset( $daysOfWeek[++$nextDayOfWeekIndex] ) );
366 - $pattern = ( $nextDayOfWeekIndex - $currentDayOfWeekIndex ) . " day";
367 - }
368 - return strtotime( $pattern, $current );
369 - }
341 + else {
342 + $nextDayOfWeekIndex = $currentDayOfWeekIndex;
343 + do {} while ( !isset( $daysOfWeek[++$nextDayOfWeekIndex] ) );
344 + $pattern = ( $nextDayOfWeekIndex - $currentDayOfWeekIndex ) . " day";
345 + }
346 + return strtotime( $pattern, $current );
347 + }
370 348
371 349 /**
372 350 * Advances a date/time by a set number of months
373 351 *
@@ -381,87 +359,87 @@
381 359 * @return int Unix timestamp of the new date/time
382 360 */
383 361 function __getNextMonth( $current, $start, $interval_multiplier ) {
384 362
385 - // For most days in the month, it's pretty easy. Get the day of month of the starting date.
386 - $startDay = date( "j", $start );
387 -
388 - // If it's before or on the 28th, just jump the number of months and be done with it.
389 - if ( $startDay <= 28 )
390 - return strtotime( $interval_multiplier . " month", $current );
391 -
392 - // If it's on the 29th, 30th, or 31st, it gets tricky. Some months don't have those days - so on those
393 - // months we need to repeat on the last day of the month instead, but we also need to jump back to the
394 - // correct day the following month. Let's say we want to repeat something on the 31st every month: this
395 - // is what we expect to see for a pattern:
396 - //
397 - // .
398 - // .
399 - // .
400 - // December 31st
401 - // January 31st
402 - // February 28th
403 - // March 31st
404 - // April 30th
405 - // .
406 - // .
407 - // .
408 - //
409 - // Unfortunately, PHP relative date handling isn't that smart (add "+1 month" to January 31st, and you
410 - // end up in March), so we'll have to figure it out ourselves by figuring out how many days to jump instead.
363 + // For most days in the month, it's pretty easy. Get the day of month of the starting date.
364 + $startDay = date( "j", $start );
365 +
366 + // If it's before or on the 28th, just jump the number of months and be done with it.
367 + if ( $startDay <= 28 )
368 + return strtotime( $interval_multiplier . " month", $current );
369 +
370 + // If it's on the 29th, 30th, or 31st, it gets tricky. Some months don't have those days - so on those
371 + // months we need to repeat on the last day of the month instead, but we also need to jump back to the
372 + // correct day the following month. Let's say we want to repeat something on the 31st every month: this
373 + // is what we expect to see for a pattern:
374 + //
375 + // .
376 + // .
377 + // .
378 + // December 31st
379 + // January 31st
380 + // February 28th
381 + // March 31st
382 + // April 30th
383 + // .
384 + // .
385 + // .
386 + //
387 + // Unfortunately, PHP relative date handling isn't that smart (add "+1 month" to January 31st, and you
388 + // end up in March), so we'll have to figure it out ourselves by figuring out how many days to jump instead.
411 389
412 - // We'll need to calculate this for each interval and return the timestamp after the last jump.
413 - $temp_current = $current;
414 - for ( $i = 0; $i < $interval_multiplier; $i++ ) {
415 - // The pattern for jumping will be different in each interval.
390 + // We'll need to calculate this for each interval and return the timestamp after the last jump.
391 + $temp_current = $current;
392 + for ( $i = 0; $i < $interval_multiplier; $i++ ) {
393 + // The pattern for jumping will be different in each interval.
416 394 /** @noinspection PhpUnusedLocalVariableInspection */
417 395 $temp_pattern = "";
418 -
419 - // Get the month number of the current date.
396 +
397 + // Get the month number of the current date.
420 398 //$currentMonth = date( "n", $temp_current );
421 -
422 - // Get the number of days in the month of the current date.
423 - $lastDayThisMonth = date( "t", strtotime( "this month", $temp_current ) );
424 -
425 - // Get the number of days for the next month relative to the current date .
426 - // Subtract 3 days from the next month to counter known month skipping bugs in PHP's relative date
427 - // handling, that being the difference between the shortest possible month (non-leap February - 28 days)
428 - // and the longest (Jan., Mar., May, Jul., Aug., Oct., Dec. - 31 days). This may be fixed in PHP 5.3.x
429 - // but this should be backwards-compatible anyway.
430 - $lastDayNextMonth = date( "t", strtotime( "-3 day next month", $temp_current ) );
431 -
432 - // If the current month is longer than next month, follow this block
433 - if ( $lastDayThisMonth > $lastDayNextMonth ) {
434 - // If we're repeating on the last day of this month, jump the number of days next month
435 - if ( $startDay == $lastDayThisMonth )
436 - $temp_pattern = $lastDayNextMonth . " days";
437 - // If the start day doesn't exist in the next month (i.e., no "31st" in June), jump the
438 - // number of days next month plus the difference between the start day and the number of days this month
439 - elseif ( $startDay > $lastDayNextMonth )
440 - $temp_pattern = ( $lastDayThisMonth + $lastDayNextMonth - $startDay ). " days";
441 - // Otherwise, jump ahead the number of days in this month
442 - else
443 - $temp_pattern = $lastDayThisMonth . " days";
444 - }
445 - // Or, if the current month is shorter than next month
446 - elseif ( $lastDayThisMonth < $lastDayNextMonth ) {
447 - // If the start day doesn't exist in this month (i.e., no "31st" in June), jump the
448 - // number of days next month plus the difference between the start day and the number of days this month
449 - if ( $startDay >= $lastDayThisMonth )
450 - $temp_pattern = $startDay . " days";
451 - // Otherwise, jump ahead the number of days in this month
452 - else
453 - $temp_pattern = $lastDayThisMonth . " days";
454 - }
455 - // If the current month and next month are equally long, jumping by "1 month" is fine
456 - else
457 - $temp_pattern = "1 month";
458 -
459 - $temp_current = strtotime( $temp_pattern, $temp_current );
460 - }
461 - return $temp_current;
399 +
400 + // Get the number of days in the month of the current date.
401 + $lastDayThisMonth = date( "t", strtotime( "this month", $temp_current ) );
402 +
403 + // Get the number of days for the next month relative to the current date .
404 + // Subtract 3 days from the next month to counter known month skipping bugs in PHP's relative date
405 + // handling, that being the difference between the shortest possible month (non-leap February - 28 days)
406 + // and the longest (Jan., Mar., May, Jul., Aug., Oct., Dec. - 31 days). This may be fixed in PHP 5.3.x
407 + // but this should be backwards-compatible anyway.
408 + $lastDayNextMonth = date( "t", strtotime( "-3 day next month", $temp_current ) );
409 +
410 + // If the current month is longer than next month, follow this block
411 + if ( $lastDayThisMonth > $lastDayNextMonth ) {
412 + // If we're repeating on the last day of this month, jump the number of days next month
413 + if ( $startDay == $lastDayThisMonth )
414 + $temp_pattern = $lastDayNextMonth . " days";
415 + // If the start day doesn't exist in the next month (i.e., no "31st" in June), jump the
416 + // number of days next month plus the difference between the start day and the number of days this month
417 + elseif ( $startDay > $lastDayNextMonth )
418 + $temp_pattern = ( $lastDayThisMonth + $lastDayNextMonth - $startDay ). " days";
419 + // Otherwise, jump ahead the number of days in this month
420 + else
421 + $temp_pattern = $lastDayThisMonth . " days";
422 + }
423 + // Or, if the current month is shorter than next month
424 + elseif ( $lastDayThisMonth < $lastDayNextMonth ) {
425 + // If the start day doesn't exist in this month (i.e., no "31st" in June), jump the
426 + // number of days next month plus the difference between the start day and the number of days this month
427 + if ( $startDay >= $lastDayThisMonth )
428 + $temp_pattern = $startDay . " days";
429 + // Otherwise, jump ahead the number of days in this month
430 + else
431 + $temp_pattern = $lastDayThisMonth . " days";
432 + }
433 + // If the current month and next month are equally long, jumping by "1 month" is fine
434 + else
435 + $temp_pattern = "1 month";
436 +
437 + $temp_current = strtotime( $temp_pattern, $temp_current );
438 + }
439 + return $temp_current;
462 440
463 - }
441 + }
464 442
465 443 /**
466 444 * Advances a date/time to the 'n'th weekday of the next month (eg., first Wednesday, third Monday, last Friday, etc.).
467 445 *
@@ -474,49 +452,49 @@
474 452 * @return int Unix timestamp of the new date/time
475 453 */
476 454 function __getNthWeekdayOfMonth( $current, $ordinal, $day ) {
477 455
478 - // First, get the month/year we need to work with
479 - $the_month = date( "F", $current );
480 - $the_year = date( "Y", $current );
481 - $lastDayThisMonth = date( "t", $current );
482 -
483 - // Get the time for the $current timestamp
484 - $current_time = date( "g:i A", $current );
485 - $the_day = "";
486 -
487 - if ( $day == 7 ) { // If $day is "day of the month", get the day of month based on the ordinal
488 - switch ( $ordinal ) {
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 //
494 - default: $the_day = "1"; break;
495 - }
496 - } else { // If $day is one of the days of the week...
497 - $day_range = array();
498 - switch ( $ordinal ) { // ...get a 7-day range based on the ordinal...
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 //
504 - default: $day_range = range( 1, 7 ); break;
505 - }
506 - foreach ( $day_range as $a_day ) { // ...and find the matching weekday in that range.
507 - if ( $day == date( "w", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
508 - $the_day = $a_day;
509 - break;
510 - }
511 - }
512 - }
513 -
514 - // Build the date/time string for the correct day and return its timestamp
515 - $pattern = $the_month . " " . $the_day . ", " . $the_year . ", " . $current_time;
516 - return strtotime( $pattern );
517 -
518 - }
456 + // First, get the month/year we need to work with
457 + $the_month = date( "F", $current );
458 + $the_year = date( "Y", $current );
459 + $lastDayThisMonth = date( "t", $current );
460 +
461 + // Get the time for the $current timestamp
462 + $current_time = date( "g:i A", $current );
463 + $the_day = "";
464 +
465 + if ( $day == 7 ) { // If $day is "day of the month", get the day of month based on the ordinal
466 + switch ( $ordinal ) {
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 //
472 + default : $the_day = "1"; break;
473 + }
474 + } else { // If $day is one of the days of the week...
475 + $day_range = array();
476 + switch ( $ordinal ) { // ...get a 7-day range based on the ordinal...
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 //
482 + default : $day_range = range( 1, 7 ); break;
483 + }
484 + foreach ( $day_range as $a_day ) { // ...and find the matching weekday in that range.
485 + if ( $day == date( "w", strtotime( $the_month . " " . $a_day . ", " . $the_year ) ) ) {
486 + $the_day = $a_day;
487 + break;
488 + }
489 + }
490 + }
491 +
492 + // Build the date/time string for the correct day and return its timestamp
493 + $pattern = $the_month . " " . $the_day . ", " . $the_year . ", " . $current_time;
494 + return strtotime( $pattern );
495 +
496 + }
519 497
520 498 /**
521 499 * Advances a date/time by a set number of years
522 500 *
@@ -524,10 +502,10 @@
524 502 * @param int $interval_multiplier Number of years to advance
525 503 * @return int Unix timestamp of the new date/time
526 504 */
527 505 function __getNextYear( $current, $interval_multiplier ) {
528 - return strtotime( $interval_multiplier . " year", $current );
529 - }
506 + return strtotime( $interval_multiplier . " year", $current );
507 + }
530 508
531 509 /**
532 510 * Validates the various Timed Content Rule parameters and returns a series of error messages.
533 511 *
@@ -534,43 +512,43 @@
534 512 * @param $args Array of Timed Content Rule parameters
535 513 * @return array Array of error messages
536 514 */
537 515 function __validate( $args ) {
538 - $errors = array();
539 -
540 - $instance_start = strtotime( $this->__datetimeToEnglish( $args['instance_start']['date'], $args['instance_start']['time'] ) . ' ' . $args['timezone'] );
541 - $instance_end = strtotime( $this->__datetimeToEnglish( $args['instance_end']['date'], $args['instance_end']['time'] ) . ' ' . $args['timezone'] );
542 - $end_date = strtotime( $this->__datetimeToEnglish( $args['end_date'], $args['instance_start']['time'] ) . ' ' . $args['timezone'] );
543 -
544 - if ( $args['instance_start']['date'] == "" )
545 - $errors[] = __( "Date in Starting Date/Time must not be empty.", 'timed-content' );
546 - if ( $args['instance_start']['time'] == "" )
547 - $errors[] = __( "Time in Starting Date/Time must not be empty.", 'timed-content' );
548 - if ( $args['instance_end']['date'] == "" )
549 - $errors[] = __( "Date in Ending Date/Time must not be empty.", 'timed-content' );
550 - if ( $args['instance_end']['time'] == "" )
551 - $errors[] = __( "Time in Ending Date/Time must not be empty.", 'timed-content' );
552 - if ( $args['interval_multiplier'] == "" )
553 - $errors[] = __( "Repeat How Often? must not be empty.", 'timed-content' );
554 - if ( !is_numeric( $args['interval_multiplier'] ) )
555 - $errors[] = __( "Repeat How Often? must be a number.", 'timed-content' );
556 - if ( ( $args['num_repeat'] == "" ) && ( $args['recurr_type'] == "recurrence_duration_num_repeat" ) )
557 - $errors[] = __( "Repeat How Many Times? must not be empty.", 'timed-content' );
558 - if ( ( !is_numeric( $args['num_repeat'] ) ) && ( $args['recurr_type'] == "recurrence_duration_num_repeat" ) )
559 - $errors[] = __( "Repeat How Many Times? must be a number.", 'timed-content' );
560 - if ( ( $args['end_date'] == "" ) && ( $args['recurr_type'] == "recurrence_duration_end_date" ) )
561 - $errors[] = __( "End Date must not be empty.", 'timed-content' );
562 - if ( false === $instance_start )
563 - $errors[] = __( "Starting Date/Time must be valid.", 'timed-content' );
564 - if ( false === $instance_end )
565 - $errors[] = __( "Ending Date/Time must be valid.", 'timed-content' );
566 - if ( $instance_start > $instance_end )
567 - $errors[] = __( "Starting Date/Time must be before Ending Date/Time.", 'timed-content' );
568 - if ( ( $instance_end > $end_date ) && ( $args['recurr_type'] == "recurrence_duration_end_date" ) )
569 - $errors[] = __( "End Date must be after Ending Date/Time.", 'timed-content' );
570 -
571 - return $errors;
572 - }
516 + $errors = array();
517 +
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'] );
521 +
522 + if ( $args['instance_start']['date'] == "" )
523 + $errors[] = __( "Date in Starting Date/Time must not be empty.", 'timed-content' );
524 + if ( $args['instance_start']['time'] == "" )
525 + $errors[] = __( "Time in Starting Date/Time must not be empty.", 'timed-content' );
526 + if ( $args['instance_end']['date'] == "" )
527 + $errors[] = __( "Date in Ending Date/Time must not be empty.", 'timed-content' );
528 + if ( $args['instance_end']['time'] == "" )
529 + $errors[] = __( "Time in Ending Date/Time must not be empty.", 'timed-content' );
530 + if ( $args['interval_multiplier'] == "" )
531 + $errors[] = __( "Repeat How Often? must not be empty.", 'timed-content' );
532 + if ( !is_numeric( $args['interval_multiplier'] ) )
533 + $errors[] = __( "Repeat How Often? must be a number.", 'timed-content' );
534 + if ( ( $args['num_repeat'] == "" ) && ( $args['recurr_type'] == "recurrence_duration_num_repeat" ) )
535 + $errors[] = __( "Repeat How Many Times? must not be empty.", 'timed-content' );
536 + if ( ( !is_numeric( $args['num_repeat'] ) ) && ( $args['recurr_type'] == "recurrence_duration_num_repeat" ) )
537 + $errors[] = __( "Repeat How Many Times? must be a number.", 'timed-content' );
538 + if ( ( $args['end_date'] == "" ) && ( $args['recurr_type'] == "recurrence_duration_end_date" ) )
539 + $errors[] = __( "End Date must not be empty.", 'timed-content' );
540 + if ( false === $instance_start )
541 + $errors[] = __( "Starting Date/Time must be valid.", 'timed-content' );
542 + if ( false === $instance_end )
543 + $errors[] = __( "Ending Date/Time must be valid.", 'timed-content' );
544 + if ( $instance_start > $instance_end )
545 + $errors[] = __( "Starting Date/Time must be before Ending Date/Time.", 'timed-content' );
546 + if ( ( $instance_end > $end_date ) && ( $args['recurr_type'] == "recurrence_duration_end_date" ) )
547 + $errors[] = __( "End Date must be after Ending Date/Time.", 'timed-content' );
548 +
549 + return $errors;
550 + }
573 551
574 552 /**
575 553 * Calculates the active periods for a Timed Content Rule
576 554 *
@@ -581,129 +559,123 @@
581 559 * is set to true or false.
582 560 */
583 561 function __getRulePeriods( $args ) {
584 562 $active_periods = array();
585 - $period_count = 0;
563 + $period_count = 0;
586 564
587 - $human_readable = $args['human_readable'];
588 - $freq = $args['freq'];
589 - $timezone = $args['timezone'];
590 - $recurr_type = $args['recurr_type'];
591 - $num_repeat = intval( $args['num_repeat'] );
592 - $end_date = $args['end_date'];
593 - $days_of_week = $args['days_of_week'];
594 - $interval_multiplier = $args['interval_multiplier'];
595 - $instance_start_date = $args['instance_start']['date'];
596 - $instance_start_time = $args['instance_start']['time'];
597 - $instance_end_date = $args['instance_end']['date'];
598 - $instance_end_time = $args['instance_end']['time'];
599 - $monthly_pattern = $args['monthly_pattern'];
600 - $monthly_pattern_ord = $args['monthly_pattern_ord'];
601 - $monthly_pattern_day = $args['monthly_pattern_day'];
602 - $exceptions_dates = $args['exceptions_dates'];
565 + $human_readable = $args['human_readable'];
566 + $freq = $args['freq'];
567 + $timezone = $args['timezone'];
568 + $recurr_type = $args['recurr_type'];
569 + $num_repeat = intval( $args['num_repeat'] );
570 + $end_date = $args['end_date'];
571 + $days_of_week = $args['days_of_week'];
572 + $interval_multiplier = $args['interval_multiplier'];
573 + $instance_start_date = $args['instance_start']['date'];
574 + $instance_start_time = $args['instance_start']['time'];
575 + $instance_end_date = $args['instance_end']['date'];
576 + $instance_end_time = $args['instance_end']['time'];
577 + $monthly_pattern = $args['monthly_pattern'];
578 + $monthly_pattern_ord = $args['monthly_pattern_ord'];
579 + $monthly_pattern_day = $args['monthly_pattern_day'];
580 + $exceptions_dates = $args['exceptions_dates'];
603 581 //print_r($days_of_week);
604 582
605 - add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
606 - $temp_tz = date_default_timezone_get();
607 - date_default_timezone_set( $timezone );
583 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
584 + $temp_tz = date_default_timezone_get();
585 + date_default_timezone_set( $timezone );
608 586 $right_now_t = current_time( 'timestamp', 1 );
609 587
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 -
616 - $instance_start = strtotime( $this->__datetimeToEnglish( $instance_start_date, $instance_start_time ) . " " . $timezone ); // Beginning of first occurrence
617 - $instance_end = strtotime( $this->__datetimeToEnglish( $instance_end_date, $instance_end_time ) . " " . $timezone ); // End of first occurrence
618 - $current = $instance_start;
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
590 + $current = $instance_start;
619 591 $end_current = $instance_end;
620 592
621 - if ( $recurr_type == "recurrence_duration_num_repeat" )
622 - $last_occurrence_start = strtotime( TIMED_CONTENT_END_TIME );
623 - else
624 - $last_occurrence_start = strtotime( $this->__datetimeToEnglish( $end_date, $instance_start_time ) . " " . $timezone );
593 + if ( $recurr_type == "recurrence_duration_num_repeat" )
594 + $last_occurrence_start = strtotime( TIMED_CONTENT_END_TIME );
595 + else
596 + $last_occurrence_start = strtotime( $this->__datetimeToEnglish( $end_date, $instance_start_time ) . " " . $timezone );
625 597
626 - if ( $human_readable == true ) {
627 - $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
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 - }
639 - } else {
640 - $active_periods[$period_count]["start"] = $current;
641 - $active_periods[$period_count]["end"] = $end_current;
642 - }
643 - $period_count++;
598 + if ( $human_readable == true ) {
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 + }
611 + } else {
612 + $active_periods[$period_count]["start"] = $current;
613 + $active_periods[$period_count]["end"] = $end_current;
614 + }
615 + $period_count++;
644 616
645 - if ( $recurr_type == "recurrence_duration_end_date" )
646 - $loop_test = "return ( \$current < \$last_occurrence_start );";
647 - else
648 - $loop_test = "return ( \$period_count <= \$num_repeat );";
649 -
650 - while ( eval ( $loop_test ) ) {
651 - $temp_current = "";
652 - if ( $freq == 0 )
653 - $current = $this->__getNextHour( $current, $interval_multiplier );
654 - elseif ( $freq == 1 )
655 - $current = $this->__getNextDay( $current, $interval_multiplier );
656 - elseif ( $freq == 2 )
657 - $current = $this->__getNextWeek( $current, $interval_multiplier, $days_of_week );
658 - elseif ( $freq == 3 ) {
659 - $current = $this->__getNextMonth( $current, $instance_start, $interval_multiplier );
660 - $temp_current = $current;
661 - if ( $monthly_pattern == "yes" )
662 - $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
663 - else
664 - $current = $temp_current;
665 - } elseif ( $freq == 4 )
666 - $current = $this->__getNextYear( $current, $interval_multiplier );
617 + if ( $recurr_type == "recurrence_duration_end_date" )
618 + $loop_test = "return ( \$current < \$last_occurrence_start );";
619 + else
620 + $loop_test = "return ( \$period_count <= \$num_repeat );";
621 +
622 + while ( eval ( $loop_test ) ) {
623 + $temp_current = "";
624 + if ( $freq == 0 )
625 + $current = $this->__getNextHour( $current, $interval_multiplier );
626 + elseif ( $freq == 1 )
627 + $current = $this->__getNextDay( $current, $interval_multiplier );
628 + elseif ( $freq == 2 )
629 + $current = $this->__getNextWeek( $current, $interval_multiplier, $days_of_week );
630 + elseif ( $freq == 3 ) {
631 + $current = $this->__getNextMonth( $current, $instance_start, $interval_multiplier );
632 + $temp_current = $current;
633 + if ( $monthly_pattern == "yes" )
634 + $current = $this->__getNthWeekdayOfMonth( $current, $monthly_pattern_ord, $monthly_pattern_day );
635 + else
636 + $current = $temp_current;
637 + } elseif ( $freq == 4 )
638 + $current = $this->__getNextYear( $current, $interval_multiplier );
667 639
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 - }
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 + }
677 649
678 - if ( ( eval ( $loop_test ) ) && ( !($exception_period) ) ) {
650 + if ( ( eval ( $loop_test ) ) && ( !($exception_period) ) ) {
679 651 $end_current = $current + ( $instance_end - $instance_start );
680 - if ( $human_readable == true ) {
681 - $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
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 - }
693 - } else {
694 - $active_periods[$period_count]["start"] = $current;
695 - $active_periods[$period_count]["end"] = $end_current;
696 - }
652 + if ( $human_readable == true ) {
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 + }
665 + } else {
666 + $active_periods[$period_count]["start"] = $current;
667 + $active_periods[$period_count]["end"] = $end_current;
668 + }
697 669 if ( !($exception_period) )
698 - $period_count++;
699 - }
670 + $period_count++;
671 + }
700 672
701 - }
702 - date_default_timezone_set( $temp_tz );
703 - remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
704 - return $active_periods;
705 - }
673 + }
674 + date_default_timezone_set( $temp_tz );
675 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
676 + return $active_periods;
677 + }
706 678
707 679 /**
708 680 * Wrapper for calling timedContentPlugin::__getRulePeriods() by the ID of a Timed Content Rule
709 681 *
@@ -713,70 +685,70 @@
713 685 * returned as UNIX timestamps.
714 686 * @return array Array of active periods
715 687 */
716 688 function getRulePeriodsById( $ID, $human_readable = false ) {
717 - if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $ID ) )
689 + if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $ID ) )
718 690 return array();
719 691
720 - $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
721 - $args = array();
722 -
723 - $args['human_readable'] = (bool) $human_readable;
724 - $args['freq'] = get_post_meta( $ID, $prefix . 'frequency', true );
725 - $args['timezone'] = get_post_meta( $ID, $prefix . 'timezone', true );
726 - $args['recurr_type'] = get_post_meta( $ID, $prefix . 'recurrence_duration', true );
727 - $args['num_repeat'] = get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true );
728 - $args['end_date'] = get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true );
729 - $args['days_of_week'] = get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true );
730 - if ( $args['freq'] == 0 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true );
731 - if ( $args['freq'] == 1 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'daily_num_of_days', true );
732 - if ( $args['freq'] == 2 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true );
733 - if ( $args['freq'] == 3 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'monthly_num_of_months', true );
734 - if ( $args['freq'] == 4 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'yearly_num_of_years', true );
735 - $args['instance_start'] = get_post_meta( $ID, $prefix . 'instance_start', true );
736 - $args['instance_end'] = get_post_meta( $ID, $prefix . 'instance_end', true );
737 - $args['monthly_pattern'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true );
738 - $args['monthly_pattern_ord'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true );
739 - $args['monthly_pattern_day'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true );
740 - $args['exceptions_dates'] = get_post_meta( $ID, $prefix . 'exceptions_dates', true );
692 + $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
693 + $args = array();
694 +
695 + $args['human_readable'] = (bool) $human_readable;
696 + $args['freq'] = get_post_meta( $ID, $prefix . 'frequency', true );
697 + $args['timezone'] = get_post_meta( $ID, $prefix . 'timezone', true );
698 + $args['recurr_type'] = get_post_meta( $ID, $prefix . 'recurrence_duration', true );
699 + $args['num_repeat'] = get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true );
700 + $args['end_date'] = get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true );
701 + $args['days_of_week'] = get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true );
702 + if ( $args['freq'] == 0 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true );
703 + if ( $args['freq'] == 1 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'daily_num_of_days', true );
704 + if ( $args['freq'] == 2 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true );
705 + if ( $args['freq'] == 3 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'monthly_num_of_months', true );
706 + if ( $args['freq'] == 4 ) $args['interval_multiplier'] = get_post_meta( $ID, $prefix . 'yearly_num_of_years', true );
707 + $args['instance_start'] = get_post_meta( $ID, $prefix . 'instance_start', true );
708 + $args['instance_end'] = get_post_meta( $ID, $prefix . 'instance_end', true );
709 + $args['monthly_pattern'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month', true );
710 + $args['monthly_pattern_ord'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_nth', true );
711 + $args['monthly_pattern_day'] = get_post_meta( $ID, $prefix . 'monthly_nth_weekday_of_month_weekday', true );
712 + $args['exceptions_dates'] = get_post_meta( $ID, $prefix . 'exceptions_dates', true );
741 713
742 - return $this->__getRulePeriods( $args );
714 + return $this->__getRulePeriods( $args );
743 715
744 - }
716 + }
745 717
746 718 /**
747 719 * Wrapper for calling timedContentPlugin::__getRulePeriods() based on the contents of the form fields
748 720 * of the Add Timed Content Rule and Edit Timed Content Rule screens. Output is sent to output as JSON
749 721 */
750 - function timedContentPluginGetRulePeriodsAjax() {
751 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
752 - $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
753 - $args = array();
754 -
755 - $args['human_readable'] = ( ( ( isset( $_POST[$prefix . 'human_readable'] ) ) && ( $_POST[$prefix . 'human_readable'] == 'true' ) ) ? (bool)$_POST[$prefix . 'human_readable'] : false );
756 - $args['freq'] = $_POST[$prefix . 'frequency'];
757 - $args['timezone'] = $_POST[$prefix . 'timezone'];
758 - $args['recurr_type'] = $_POST[$prefix . 'recurrence_duration'];
759 - $args['num_repeat'] = $_POST[$prefix . 'recurrence_duration_num_repeat'];
760 - $args['end_date'] = $_POST[$prefix . 'recurrence_duration_end_date'];
761 - $args['days_of_week'] = ( isset( $_POST[$prefix . 'weekly_days_of_week_to_repeat'] ) ? $_POST[$prefix . 'weekly_days_of_week_to_repeat'] : array() );
762 - $args['interval_multiplier'] = $_POST[$prefix . 'interval_multiplier'];
763 - $args['instance_start'] = $_POST[$prefix . 'instance_start'];
764 - $args['instance_end'] = $_POST[$prefix . 'instance_end'];
765 - $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
766 - $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
767 - $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
768 - $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
722 + function timedContentPluginGetRulePeriodsAjax() {
723 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
724 + $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
725 + $args = array();
726 +
727 + $args['human_readable'] = ( ( ( isset( $_POST[$prefix . 'human_readable'] ) ) && ( $_POST[$prefix . 'human_readable'] == 'true' ) ) ? (bool)$_POST[$prefix . 'human_readable'] : false );
728 + $args['freq'] = $_POST[$prefix . 'frequency'];
729 + $args['timezone'] = $_POST[$prefix . 'timezone'];
730 + $args['recurr_type'] = $_POST[$prefix . 'recurrence_duration'];
731 + $args['num_repeat'] = $_POST[$prefix . 'recurrence_duration_num_repeat'];
732 + $args['end_date'] = $_POST[$prefix . 'recurrence_duration_end_date'];
733 + $args['days_of_week'] = ( isset( $_POST[$prefix . 'weekly_days_of_week_to_repeat'] ) ? $_POST[$prefix . 'weekly_days_of_week_to_repeat'] : array() );
734 + $args['interval_multiplier'] = $_POST[$prefix . 'interval_multiplier'];
735 + $args['instance_start'] = $_POST[$prefix . 'instance_start'];
736 + $args['instance_end'] = $_POST[$prefix . 'instance_end'];
737 + $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
738 + $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
739 + $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
740 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
769 741
770 - $response = json_encode( $this->__getRulePeriods( $args ) );
771 -
772 - // response output
773 - header( "Content-Type: application/json" );
774 - echo $response;
775 - }
776 - die();
742 + $response = json_encode( $this->__getRulePeriods( $args ) );
743 +
744 + // response output
745 + header( "Content-Type: application/json" );
746 + echo $response;
747 + }
748 + die();
777 749
778 - }
750 + }
779 751
780 752 /**
781 753 * Returns a human-readable description of a Timed Content Rule
782 754 *
@@ -783,106 +755,106 @@
783 755 * @param $args Array of Timed Content Rule parameters
784 756 * @return string
785 757 */
786 758 function __getScheduleDescription( $args ) {
787 - include("lib/Arrays_Definitions.php");
759 + include("lib/Arrays_Definitions.php");
788 760
789 - $interval_multiplier = 1;
790 - $desc = "";
791 -
792 - $errors = $this->__validate( $args );
793 - if ( $errors ) {
794 - $messages = "<div class=\"tcr-warning\">\n";
795 - $messages .= "<p class=\"heading\">" . __( "Warning!", 'timed-content' ) . "</p>\n";
796 - $messages .= "<p>" . __( "Some problems have been detected. Although you can still publish this rule, it may not work the way you expect.", 'timed-content' ) . "</p>\n";
797 - $messages .= "<ul>\n";
798 - foreach ( $errors as $error )
799 - $messages .= " <li>" . $error . "</li>\n";
800 - $messages .= "</ul>\n";
801 - $messages .= "<p>" . __( "Check that all of the conditions for this rule are correct, and use Show Projected Dates/Times to ensure your rule is working properly.", 'timed-content' ) . "</p>\n";
802 - $messages .= "</div>\n";
803 - return $messages;
804 - }
805 -
806 - if ( $args['action'] )
807 - $action = __( "Show the content", 'timed-content' );
808 - else
809 - $action = __( "Hide the content", 'timed-content' );
810 - $freq = $args['freq'];
811 - $timezone = $args['timezone'];
812 - $recurr_type = $args['recurr_type'];
813 - $num_repeat = intval( $args['num_repeat'] );
814 - $end_date = $args['end_date'];
815 - $days_of_week = $args['days_of_week'];
816 - $interval_multiplier = $args['interval_multiplier'];
817 - $instance_start_date = $args['instance_start']['date'];
818 - $instance_start_time = $args['instance_start']['time'];
819 - $instance_end_date = $args['instance_end']['date'];
820 - $instance_end_time = $args['instance_end']['time'];
821 - $monthly_pattern = $args['monthly_pattern'];
822 - $monthly_pattern_ord = $args['monthly_pattern_ord'];
823 - $monthly_pattern_day = $args['monthly_pattern_day'];
824 - $exceptions_dates = $args['exceptions_dates'];
761 + $interval_multiplier = 1;
762 + $desc = "";
763 +
764 + $errors = $this->__validate( $args );
765 + if ( $errors ) {
766 + $messages = "<div class=\"tcr-warning\">\n";
767 + $messages .= "<p class=\"heading\">" . __( "Warning!", 'timed-content' ) . "</p>\n";
768 + $messages .= "<p>" . __( "Some problems have been detected. Although you can still publish this rule, it may not work the way you expect.", 'timed-content' ) . "</p>\n";
769 + $messages .= "<ul>\n";
770 + foreach ( $errors as $error )
771 + $messages .= " <li>" . $error . "</li>\n";
772 + $messages .= "</ul>\n";
773 + $messages .= "<p>" . __( "Check that all of the conditions for this rule are correct, and use Show Projected Dates/Times to ensure your rule is working properly.", 'timed-content' ) . "</p>\n";
774 + $messages .= "</div>\n";
775 + return $messages;
776 + }
777 +
778 + if ( $args['action'] )
779 + $action = __( "Show the content", 'timed-content' );
780 + else
781 + $action = __( "Hide the content", 'timed-content' );
782 + $freq = $args['freq'];
783 + $timezone = $args['timezone'];
784 + $recurr_type = $args['recurr_type'];
785 + $num_repeat = intval( $args['num_repeat'] );
786 + $end_date = $args['end_date'];
787 + $days_of_week = $args['days_of_week'];
788 + $interval_multiplier = $args['interval_multiplier'];
789 + $instance_start_date = $args['instance_start']['date'];
790 + $instance_start_time = $args['instance_start']['time'];
791 + $instance_end_date = $args['instance_end']['date'];
792 + $instance_end_time = $args['instance_end']['time'];
793 + $monthly_pattern = $args['monthly_pattern'];
794 + $monthly_pattern_ord = $args['monthly_pattern_ord'];
795 + $monthly_pattern_day = $args['monthly_pattern_day'];
796 + $exceptions_dates = $args['exceptions_dates'];
825 797
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 );
827 -
828 - if ( $freq == 0 )
829 - $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every hour.', 'Repeat this action every %d hours.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
830 - elseif ( $freq == 1 )
831 - $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every day.', 'Repeat this action every %d days.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
832 - elseif ( $freq == 2 ) {
833 - if ( ( $days_of_week ) && ( is_array( $days_of_week ) ) ) {
834 - $days = array(); $days_list = "";
835 - foreach ( $days_of_week as $v )
836 - $days[] = $timed_content_rule_days_array[$v];
837 - switch ( count( $days ) ) {
838 - case 1: $days_list = sprintf( _x( '%1$s', 'List of one weekday', 'timed-content' ), $days[0] ); break;
839 - case 2: $days_list = sprintf( _x( '%1$s and %2$s', 'List of two weekdays', 'timed-content' ), $days[0], $days[1] ); break;
840 - case 3: $days_list = sprintf( _x( '%1$s, %2$s, and %3$s', 'List of three weekdays', 'timed-content' ), $days[0], $days[1], $days[2] ); break;
841 - case 4: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, and %4$s', 'List of four weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3] ); break;
842 - case 5: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, and %5$s', 'List of five weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4] ); break;
843 - case 6: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, %5$s, and %6$s', 'List of six weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4], $days[5] ); break;
844 - case 7: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, %5$s, %6$s, and %7$s', 'List of all weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4], $days[5], $days[6] ); break;
845 - }
846 - if ( $interval_multiplier == 1 )
847 - $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every week on %s.', 'List the weekdays to repeat the rule when frequency is every week. %s is the list of weekdays.', 'timed-content' ), $days_list );
848 - else
849 - $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every %1$d weeks on %2$s.', 'List the weekdays to repeat the rule when frequency is every %1$d weeks. %2$s is the list of weekdays.', 'timed-content' ), $interval_multiplier, $days_list );
850 - } else
851 - $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every week.', 'Repeat this action every %d weeks.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
852 -
853 - } elseif ( $freq == 3 ) {
854 - if ( $monthly_pattern == "yes" ) {
855 - if ( $interval_multiplier == 1 )
856 - $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] );
857 - else
858 - $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] );
859 - } else
860 - $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every month.', 'Repeat this action every %d months.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
861 - } elseif ( $freq == 4 )
862 - $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every year.', 'Repeat this action every %d years.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
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 );
799 +
800 + if ( $freq == 0 )
801 + $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every hour.', 'Repeat this action every %d hours.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
802 + elseif ( $freq == 1 )
803 + $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every day.', 'Repeat this action every %d days.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
804 + elseif ( $freq == 2 ) {
805 + if ( ( $days_of_week ) && ( is_array( $days_of_week ) ) ) {
806 + $days = array(); $days_list = "";
807 + foreach ( $days_of_week as $v )
808 + $days[] = $timed_content_rule_days_array[$v];
809 + switch ( count( $days ) ) {
810 + case 1: $days_list = sprintf( _x( '%1$s', 'List of one weekday', 'timed-content' ), $days[0] ); break;
811 + case 2: $days_list = sprintf( _x( '%1$s and %2$s', 'List of two weekdays', 'timed-content' ), $days[0], $days[1] ); break;
812 + case 3: $days_list = sprintf( _x( '%1$s, %2$s, and %3$s', 'List of three weekdays', 'timed-content' ), $days[0], $days[1], $days[2] ); break;
813 + case 4: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, and %4$s', 'List of four weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3] ); break;
814 + case 5: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, and %5$s', 'List of five weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4] ); break;
815 + case 6: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, %5$s, and %6$s', 'List of six weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4], $days[5] ); break;
816 + case 7: $days_list = sprintf( _x( '%1$s, %2$s, %3$s, %4$s, %5$s, %6$s, and %7$s', 'List of all weekdays', 'timed-content' ), $days[0], $days[1], $days[2], $days[3], $days[4], $days[5], $days[6] ); break;
817 + }
818 + if ( $interval_multiplier == 1 )
819 + $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every week on %s.', 'List the weekdays to repeat the rule when frequency is every week. %s is the list of weekdays.', 'timed-content' ), $days_list );
820 + else
821 + $desc .= "&nbsp;" . sprintf( _x( 'Repeat this action every %1$d weeks on %2$s.', 'List the weekdays to repeat the rule when frequency is every %1$d weeks. %2$s is the list of weekdays.', 'timed-content' ), $interval_multiplier, $days_list );
822 + } else
823 + $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every week.', 'Repeat this action every %d weeks.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
824 +
825 + } elseif ( $freq == 3 ) {
826 + if ( $monthly_pattern == "yes" ) {
827 + if ( $interval_multiplier == 1 )
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] );
829 + else
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] );
831 + } else
832 + $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every month.', 'Repeat this action every %d months.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
833 + } elseif ( $freq == 4 )
834 + $desc .= "&nbsp;" . sprintf( _n( 'Repeat this action every year.', 'Repeat this action every %d years.', $interval_multiplier, 'timed-content' ), $interval_multiplier );
863 835
864 - if ( $recurr_type == "recurrence_duration_num_repeat" )
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 );
866 - elseif ( $recurr_type == "recurrence_duration_end_date" )
867 - $desc .= "&nbsp;" . sprintf( __( 'This rule will be active until %s.', 'timed-content' ), $end_date );
836 + if ( $recurr_type == "recurrence_duration_num_repeat" )
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 );
838 + elseif ( $recurr_type == "recurrence_duration_end_date" )
839 + $desc .= "&nbsp;" . sprintf( __( 'This rule will be active until %s.', 'timed-content' ), $end_date );
868 840
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 - }
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 + }
881 853
882 - $desc .= "&nbsp;" . sprintf( __( 'All times are in the %s timezone.', 'timed-content' ), $timezone );
883 - return $desc;
884 - }
854 + $desc .= "&nbsp;" . sprintf( __( 'All times are in the %s timezone.', 'timed-content' ), $timezone );
855 + return $desc;
856 + }
885 857
886 858 /**
887 859 * Wrapper for calling timedContentPlugin::__getScheduleDescription() by the ID of a Timed Content Rule
888 860 *
@@ -889,12 +861,12 @@
889 861 * @param int $ID ID of the Timed Content Rule
890 862 * @return string
891 863 */
892 864 function getScheduleDescriptionById( $ID ) {
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;
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;
897 869 $defaults = array();
898 870
899 871 foreach ( $timed_content_rule_occurrence_custom_fields as $field ) {
900 872 $defaults[$field['name']] = $field['default'];
@@ -901,40 +873,40 @@
901 873 }
902 874 foreach ( $timed_content_rule_pattern_custom_fields as $field ) {
903 875 $defaults[$field['name']] = $field['default'];
904 876 }
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 - }
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 + }
911 883
912 884 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
913 - $args = array();
914 -
915 - $args['action'] = ( false === get_post_meta( $ID, $prefix . 'action', true ) ? $defaults['action'] : get_post_meta( $ID, $prefix . 'action', true ) );
916 - $args['freq'] = ( false === get_post_meta( $ID, $prefix . 'frequency', true ) ? $defaults['frequency'] : get_post_meta( $ID, $prefix . 'frequency', true ) );
917 - $args['timezone'] = ( false === get_post_meta( $ID, $prefix . 'timezone', true ) ? $defaults['timezone'] : get_post_meta( $ID, $prefix . 'timezone', true ) );
918 - $args['recurr_type'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration', true ) ? $defaults['recurrence_duration'] : get_post_meta( $ID, $prefix . 'recurrence_duration', true ) );
919 - $args['num_repeat'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true ) ? $defaults['recurrence_duration_num_repeat'] : get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true ) );
920 - $args['end_date'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true ) ? $defaults['recurrence_duration_end_date'] : get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true ) );
921 - $args['days_of_week'] = ( false === get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true ) ? $defaults['weekly_days_of_week_to_repeat'] : get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true ) );
922 - if ( $args['freq'] == 0 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true ) ? $defaults['hourly_num_of_hours'] : get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true ) );
923 - if ( $args['freq'] == 1 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'daily_num_of_days', true ) ? $defaults['daily_num_of_days'] : get_post_meta( $ID, $prefix . 'daily_num_of_days', true ) );
924 - if ( $args['freq'] == 2 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true ) ? $defaults['weekly_num_of_weeks'] : get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true ) );
925 - if ( $args['freq'] == 3 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'monthly_num_of_months', true ) ? $defaults['monthly_num_of_months'] : get_post_meta( $ID, $prefix . 'monthly_num_of_months', true ) );
926 - if ( $args['freq'] == 4 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'yearly_num_of_years', true ) ? $defaults['yearly_num_of_years'] : get_post_meta( $ID, $prefix . 'yearly_num_of_years', true ) );
927 - $args['instance_start'] = ( false === get_post_meta( $ID, $prefix . 'instance_start', true ) ? $defaults['instance_start'] : get_post_meta( $ID, $prefix . 'instance_start', true ) );
928 - $args['instance_end'] = ( false === get_post_meta( $ID, $prefix . 'instance_end', true ) ? $defaults['instance_end'] : get_post_meta( $ID, $prefix . 'instance_end', true ) );
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 ) );
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 ) );
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 ) );
885 + $args = array();
886 +
887 + $args['action'] = ( false === get_post_meta( $ID, $prefix . 'action', true ) ? $defaults['action'] : get_post_meta( $ID, $prefix . 'action', true ) );
888 + $args['freq'] = ( false === get_post_meta( $ID, $prefix . 'frequency', true ) ? $defaults['frequency'] : get_post_meta( $ID, $prefix . 'frequency', true ) );
889 + $args['timezone'] = ( false === get_post_meta( $ID, $prefix . 'timezone', true ) ? $defaults['timezone'] : get_post_meta( $ID, $prefix . 'timezone', true ) );
890 + $args['recurr_type'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration', true ) ? $defaults['recurrence_duration'] : get_post_meta( $ID, $prefix . 'recurrence_duration', true ) );
891 + $args['num_repeat'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true ) ? $defaults['recurrence_duration_num_repeat'] : get_post_meta( $ID, $prefix . 'recurrence_duration_num_repeat', true ) );
892 + $args['end_date'] = ( false === get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true ) ? $defaults['recurrence_duration_end_date'] : get_post_meta( $ID, $prefix . 'recurrence_duration_end_date', true ) );
893 + $args['days_of_week'] = ( false === get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true ) ? $defaults['weekly_days_of_week_to_repeat'] : get_post_meta( $ID, $prefix . 'weekly_days_of_week_to_repeat', true ) );
894 + if ( $args['freq'] == 0 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true ) ? $defaults['hourly_num_of_hours'] : get_post_meta( $ID, $prefix . 'hourly_num_of_hours', true ) );
895 + if ( $args['freq'] == 1 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'daily_num_of_days', true ) ? $defaults['daily_num_of_days'] : get_post_meta( $ID, $prefix . 'daily_num_of_days', true ) );
896 + if ( $args['freq'] == 2 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true ) ? $defaults['weekly_num_of_weeks'] : get_post_meta( $ID, $prefix . 'weekly_num_of_weeks', true ) );
897 + if ( $args['freq'] == 3 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'monthly_num_of_months', true ) ? $defaults['monthly_num_of_months'] : get_post_meta( $ID, $prefix . 'monthly_num_of_months', true ) );
898 + if ( $args['freq'] == 4 ) $args['interval_multiplier'] = ( false === get_post_meta( $ID, $prefix . 'yearly_num_of_years', true ) ? $defaults['yearly_num_of_years'] : get_post_meta( $ID, $prefix . 'yearly_num_of_years', true ) );
899 + $args['instance_start'] = ( false === get_post_meta( $ID, $prefix . 'instance_start', true ) ? $defaults['instance_start'] : get_post_meta( $ID, $prefix . 'instance_start', true ) );
900 + $args['instance_end'] = ( false === get_post_meta( $ID, $prefix . 'instance_end', true ) ? $defaults['instance_end'] : get_post_meta( $ID, $prefix . 'instance_end', true ) );
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 ) );
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 ) );
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 ) );
933 905
934 - return $this->__getScheduleDescription( $args );
906 + return $this->__getScheduleDescription( $args );
935 907
936 - }
908 + }
937 909
938 910 /**
939 911 * Wrapper for calling timedContentPlugin::__getRulePeriods() based on the contents of the form fields
940 912 * of the Add Timed Content Rule and Edit Timed Content Rule screens. Output is sent to output as plain text
@@ -939,35 +911,35 @@
939 911 * Wrapper for calling timedContentPlugin::__getRulePeriods() based on the contents of the form fields
940 912 * of the Add Timed Content Rule and Edit Timed Content Rule screens. Output is sent to output as plain text
941 913 */
942 914 function timedContentPluginGetScheduleDescriptionAjax() {
943 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
944 - $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
945 - $args = array();
946 -
947 - $args['action'] = $_POST[$prefix . 'action'];
948 - $args['freq'] = $_POST[$prefix . 'frequency'];
949 - $args['timezone'] = $_POST[$prefix . 'timezone'];
950 - $args['recurr_type'] = $_POST[$prefix . 'recurrence_duration'];
951 - $args['num_repeat'] = $_POST[$prefix . 'recurrence_duration_num_repeat'];
952 - $args['end_date'] = $_POST[$prefix . 'recurrence_duration_end_date'];
953 - $args['days_of_week'] = ( isset( $_POST[$prefix . 'weekly_days_of_week_to_repeat'] ) ? $_POST[$prefix . 'weekly_days_of_week_to_repeat'] : array() );
954 - $args['interval_multiplier'] = $_POST[$prefix . 'interval_multiplier'];
955 - $args['instance_start'] = $_POST[$prefix . 'instance_start'];
956 - $args['instance_end'] = $_POST[$prefix . 'instance_end'];
957 - $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
958 - $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
959 - $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
960 - $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
915 + if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {
916 + $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
917 + $args = array();
918 +
919 + $args['action'] = $_POST[$prefix . 'action'];
920 + $args['freq'] = $_POST[$prefix . 'frequency'];
921 + $args['timezone'] = $_POST[$prefix . 'timezone'];
922 + $args['recurr_type'] = $_POST[$prefix . 'recurrence_duration'];
923 + $args['num_repeat'] = $_POST[$prefix . 'recurrence_duration_num_repeat'];
924 + $args['end_date'] = $_POST[$prefix . 'recurrence_duration_end_date'];
925 + $args['days_of_week'] = ( isset( $_POST[$prefix . 'weekly_days_of_week_to_repeat'] ) ? $_POST[$prefix . 'weekly_days_of_week_to_repeat'] : array() );
926 + $args['interval_multiplier'] = $_POST[$prefix . 'interval_multiplier'];
927 + $args['instance_start'] = $_POST[$prefix . 'instance_start'];
928 + $args['instance_end'] = $_POST[$prefix . 'instance_end'];
929 + $args['monthly_pattern'] = $_POST[$prefix . 'monthly_nth_weekday_of_month'];
930 + $args['monthly_pattern_ord'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_nth'];
931 + $args['monthly_pattern_day'] = $_POST[$prefix . 'monthly_nth_weekday_of_month_weekday'];
932 + $args['exceptions_dates'] = ( isset( $_POST[$prefix . 'exceptions_dates'] ) ? $_POST[$prefix . 'exceptions_dates'] : array() );
961 933
962 - $response = $this->__getScheduleDescription( $args );
963 -
964 - // response output
965 - header( "Content-Type: text/plain" );
966 - echo $response;
967 - }
968 - die();
969 - }
934 + $response = $this->__getScheduleDescription( $args );
935 +
936 + // response output
937 + header( "Content-Type: text/plain" );
938 + echo $response;
939 + }
940 + die();
941 + }
970 942
971 943 /**
972 944 * Processes the [timed-content-client] shortcode.
973 945 *
@@ -975,40 +947,40 @@
975 947 * @param null $content
976 948 * @return string
977 949 */
978 950 function clientShowHTML( $atts, $content = null ) {
979 - $show_attr = "";
980 - $hide_attr = "";
981 - extract( shortcode_atts( array( 'show' => '0:00:000' , 'hide' => '0:00:000' , 'display' => 'div' ), $atts ) );
982 -
983 - // Initialize show/hide arguments
984 - $s_min = 0; $s_sec = 0; $s_fade = 0;
985 - $h_min = 0; $h_sec = 0; $h_fade = 0;
986 - @list( $s_min, $s_sec, $s_fade ) = explode( ":", $show );
987 - @list( $h_min, $h_sec, $h_fade ) = explode( ":", $hide );
951 + $show_attr = "";
952 + $hide_attr = "";
953 + extract( shortcode_atts( array( 'show' => '0:00:000' , 'hide' => '0:00:000' , 'display' => 'div' ), $atts ) );
954 +
955 + // Initialize show/hide arguments
956 + $s_min = 0; $s_sec = 0; $s_fade = 0;
957 + $h_min = 0; $h_sec = 0; $h_fade = 0;
958 + @list( $s_min, $s_sec, $s_fade ) = explode( ":", $show );
959 + @list( $h_min, $h_sec, $h_fade ) = explode( ":", $hide );
988 960
989 - if ( ( (int)$s_min + (int)$s_sec ) > 0 )
990 - $show_attr = "_show_" . $s_min . "_" . $s_sec . "_" . $s_fade;
991 - if ( ( (int)$h_min + (int)$h_sec ) > 0 )
992 - $hide_attr = "_hide_" . $h_min . "_" . $h_sec . "_" . $h_fade;
993 -
994 - $the_class = TIMED_CONTENT_CLIENT_TAG . $show_attr . $hide_attr ;
995 - $the_tag = ( $display == "div" ? "div" : "span" );
961 + if ( ( (int)$s_min + (int)$s_sec ) > 0 )
962 + $show_attr = "_show_" . $s_min . "_" . $s_sec . "_" . $s_fade;
963 + if ( ( (int)$h_min + (int)$h_sec ) > 0 )
964 + $hide_attr = "_hide_" . $h_min . "_" . $h_sec . "_" . $h_fade;
965 +
966 + $the_class = TIMED_CONTENT_CLIENT_TAG . $show_attr . $hide_attr ;
967 + $the_tag = ( $display == "div" ? "div" : "span" );
996 968
997 - $the_filter = "timed_content_filter";
998 - $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
969 + $the_filter = "timed_content_filter";
970 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
999 971
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 . ">";
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 . ">";
1008 980
1009 - return $the_HTML;
1010 - }
981 + return $the_HTML;
982 + }
1011 983
1012 984 /**
1013 985 * Processes the [timed-content-server] shortcode.
1014 986 *
@@ -1015,32 +987,26 @@
1015 987 * @param array $atts
1016 988 * @param null $content
1017 989 * @return string
1018 990 */
1019 - function serverShowHTML( $atts, $content = null ) {
991 + function serverShowHTML( $atts, $content = null ) {
1020 992 global $post;
1021 - extract( shortcode_atts( array( 'show' => TIMED_CONTENT_ZERO_TIME , 'hide' => TIMED_CONTENT_END_TIME, 'debug' => 'false' ), $atts ) );
1022 - $show_t = strtotime( $this->__datetimeToEnglish( $show ) );
1023 - $hide_t = strtotime( $this->__datetimeToEnglish( $hide ) );
1024 - $right_now_t = current_time( 'timestamp', 1 );
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 );
993 + extract( shortcode_atts( array( 'show' => TIMED_CONTENT_ZERO_TIME , 'hide' => TIMED_CONTENT_END_TIME, 'debug' => 'false' ), $atts ) );
994 + $show_t = strtotime( $this->__datetimeToEnglish( $show ) );
995 + $hide_t = strtotime( $this->__datetimeToEnglish( $hide ) );
996 + $right_now_t = current_time( 'timestamp', 1 );
997 + $debug_message = "";
1035 998
1036 - if ( ( $debug == "true" ) && ( current_user_can( "edit_post", $post->post_id ) ) ) {
1037 - add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
1038 - $temp_tz = date_default_timezone_get();
1039 - date_default_timezone_set( get_option( 'timezone_string' ) );
999 + $the_filter = "timed_content_filter";
1000 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1040 1001
1041 - $right_now = date_i18n( TIMED_CONTENT_DT_FORMAT, $right_now_t );
1002 + if ( ( $debug == "true" ) && ( current_user_can( "edit_post", $post->post_id ) ) ) {
1003 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
1004 + $temp_tz = date_default_timezone_get();
1005 + date_default_timezone_set( get_option( 'timezone_string' ) );
1042 1006
1007 + $right_now = date_i18n( TIMED_CONTENT_DT_FORMAT, $right_now_t );
1008 +
1043 1009 if ( $show_t > $right_now_t )
1044 1010 $show_diff_str = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $show_t, $right_now_t ) );
1045 1011 else
1046 1012 $show_diff_str = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $show_t, $right_now_t ) );
@@ -1052,34 +1018,34 @@
1052 1018 $debug_message = "<div class=\"tcr-warning\">\n";
1053 1019 $debug_message .= "<p class=\"heading\">" . _x( "Notice", "Noun", 'timed-content' ) . "</p>\n";
1054 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";
1055 1021
1056 - if ( $show == TIMED_CONTENT_ZERO_TIME )
1057 - $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.', 'timed-content' ), "<code>show</code>" ) . "</p>\n";
1058 - else
1059 - $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>show</code>" ) . ": " . $show . ",<br />\n "
1060 - . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $show_t )
1061 - . " (" . $show_diff_str . ")</p>\n";
1022 + if ( $show == TIMED_CONTENT_ZERO_TIME )
1023 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.', 'timed-content' ), "<code>show</code>" ) . "</p>\n";
1024 + else
1025 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>show</code>" ) . ": " . $show . ",<br />\n "
1026 + . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $show_t )
1027 + . " (" . $show_diff_str . ")</p>\n";
1062 1028
1063 - if ( $hide == TIMED_CONTENT_END_TIME )
1064 - $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.' , 'timed-content' ), "<code>hide</code>" ) . "</p>\n";
1065 - else
1066 - $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>hide</code>" ) . ": " . $hide . ",<br />\n"
1067 - . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $hide_t )
1068 - . " (" . $hide_diff_str . ").</p>\n";
1029 + if ( $hide == TIMED_CONTENT_END_TIME )
1030 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is not set.' , 'timed-content' ), "<code>hide</code>" ) . "</p>\n";
1031 + else
1032 + $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>hide</code>" ) . ": " . $hide . ",<br />\n"
1033 + . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $hide_t )
1034 + . " (" . $hide_diff_str . ").</p>\n";
1069 1035
1070 1036 $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";
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";
1073 1039
1074 1040 $debug_message .= "</div>\n";
1075 1041
1076 - date_default_timezone_set( $temp_tz );
1077 - remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
1078 - }
1042 + date_default_timezone_set( $temp_tz );
1043 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
1044 + }
1079 1045
1080 1046
1081 - if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) ) {
1047 + if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) ) {
1082 1048 do_action("timed_content_server_show", $post->ID, $show, $hide, $content);
1083 1049 return $debug_message . str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content)) . "\n";
1084 1050 } else {
1085 1051 do_action("timed_content_server_hide", $post->ID, $show, $hide, $content);
@@ -1085,9 +1051,9 @@
1085 1051 do_action("timed_content_server_hide", $post->ID, $show, $hide, $content);
1086 1052 return $debug_message . "\n";
1087 1053 }
1088 1054
1089 - }
1055 + }
1090 1056
1091 1057 /**
1092 1058 * Processes the [timed-content-rule] shortcode.
1093 1059 *
@@ -1094,42 +1060,36 @@
1094 1060 * @param array $atts
1095 1061 * @param null $content
1096 1062 * @return string
1097 1063 */
1098 - function rulesShowHTML( $atts, $content = null ) {
1064 + function rulesShowHTML( $atts, $content = null ) {
1099 1065 global $post;
1100 - extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
1066 + extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
1101 1067 if ( !is_numeric( $id ) ) {
1102 1068 $page = get_page_by_title( $id, OBJECT, TIMED_CONTENT_RULE_TYPE );
1103 1069 if ( $page == null ) return;
1104 1070 $id = $page->ID;
1105 1071 }
1106 - if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $id ) ) return;
1072 + if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $id ) ) return;
1107 1073
1108 - $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
1109 - $right_now_t = current_time( 'timestamp', 1 );
1110 - $rule_is_active = false;
1074 + $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
1075 + $right_now_t = current_time( 'timestamp', 1 );
1076 + $rule_is_active = false;
1077 +
1078 + $active_periods = $this->getRulePeriodsById( $id, false );
1079 + $action_is_show = (bool) get_post_meta( $id, $prefix . 'action', true );
1080 +
1081 + foreach ( $active_periods as $period ) {
1082 + if ( ( $period['start'] <= $right_now_t ) && ( $right_now_t <= $period['end'] ) ) {
1083 + $rule_is_active = true;
1084 + break;
1085 + }
1086 + }
1111 1087
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 - }
1117 -
1118 - $active_periods = $this->getRulePeriodsById( $id, false );
1119 - $action_is_show = (bool) get_post_meta( $id, $prefix . 'action', true );
1120 -
1121 - foreach ( $active_periods as $period ) {
1122 - if ( ( $period['start'] <= $right_now_t ) && ( $right_now_t <= $period['end'] ) ) {
1123 - $rule_is_active = true;
1124 - break;
1125 - }
1126 - }
1088 + $the_filter = "timed_content_filter";
1089 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1127 1090
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 ) ) ) {
1091 + if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) ) {
1132 1092 do_action("timed_content_rule_show", $post->ID, $id, $content);
1133 1093 return str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content));
1134 1094 } else {
1135 1095 do_action("timed_content_rule_hide", $post->ID, $id, $content);
@@ -1134,19 +1094,19 @@
1134 1094 } else {
1135 1095 do_action("timed_content_rule_hide", $post->ID, $id, $content);
1136 1096 return "";
1137 1097 }
1138 - }
1098 + }
1139 1099
1140 1100 /**
1141 1101 * Enqueues the JavaScript code necessary for the functionality of the [timed-content-client] shortcode.
1142 1102 */
1143 1103 function addHeaderCode() {
1144 - if ( ! is_admin() ) {
1104 + if ( ! is_admin() ) {
1145 1105 wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
1146 1106 wp_enqueue_script( 'timed-content_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
1147 - }
1148 - }
1107 + }
1108 + }
1149 1109
1150 1110 /**
1151 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.
1152 1112 */
@@ -1167,9 +1127,9 @@
1167 1127 /**
1168 1128 * Enqueues the CSS code necessary for custom icons for the Timed Content Rules management screens
1169 1129 * and the TinyMCE editor. Echo'd to output.
1170 1130 */
1171 - function addPostTypeIcons() {
1131 + function addPostTypeIcons() {
1172 1132 wp_enqueue_style( 'ca-aliencyborg-dashicons', TIMED_CONTENT_CSS_DASHICONS, false, TIMED_CONTENT_VERSION );
1173 1133 ?>
1174 1134 <style type="text/css" media="screen">
1175 1135 #adminmenu #menu-posts-<?php echo TIMED_CONTENT_RULE_TYPE; ?>.menu-icon-post div.wp-menu-image:before {
@@ -1189,55 +1149,55 @@
1189 1149 content: '\e601';
1190 1150 }
1191 1151 </style>
1192 1152 <?php
1193 - }
1153 + }
1194 1154
1195 1155 /**
1196 1156 * Enqueues the JavaScript code necessary for the functionality of the Timed Content Rules management screens.
1197 1157 */
1198 - function addAdminHeaderCode() {
1199 - if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == TIMED_CONTENT_RULE_TYPE )
1200 - || ( isset( $post_type ) && $post_type == TIMED_CONTENT_RULE_TYPE )
1201 - || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == TIMED_CONTENT_RULE_TYPE ) ) {
1202 - wp_enqueue_style( 'thickbox' );
1203 - wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
1204 - // Enqueue the JavaScript file that manages the meta box UI
1205 - wp_enqueue_script( 'timed-content-admin_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
1206 - // Enqueue the JavaScript file that makes AJAX requests
1207 - wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'thickbox' ), TIMED_CONTENT_VERSION );
1158 + function addAdminHeaderCode() {
1159 + if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == TIMED_CONTENT_RULE_TYPE )
1160 + || ( isset( $post_type ) && $post_type == TIMED_CONTENT_RULE_TYPE )
1161 + || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == TIMED_CONTENT_RULE_TYPE ) ) {
1162 + wp_enqueue_style( 'thickbox' );
1163 + wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
1164 + // Enqueue the JavaScript file that manages the meta box UI
1165 + wp_enqueue_script( 'timed-content-admin_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
1166 + // Enqueue the JavaScript file that makes AJAX requests
1167 + wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'thickbox' ), TIMED_CONTENT_VERSION );
1208 1168
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' ) ) );
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' ) ) );
1212 1172
1213 - // Set up local variables used in the AJAX JavaScript file
1214 - wp_localize_script( 'timed-content-ajax_js', 'timedContentRuleAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1215 - 'start_label' => _x( 'Start', 'Scheduled Dates/Times dialog - Beginning of active period table header', 'timed-content' ),
1216 - 'end_label' => _x( 'End', 'Scheduled Dates/Times dialog - End of active period table header', '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' ) ) );
1224 - }
1225 - }
1173 + // Set up local variables used in the AJAX JavaScript file
1174 + wp_localize_script( 'timed-content-ajax_js', 'timedContentRuleAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1175 + 'start_label' => _x( 'Start', 'Scheduled Dates/Times dialog - Beginning of active period table header', 'timed-content' ),
1176 + 'end_label' => _x( 'End', 'Scheduled Dates/Times dialog - End of active period table header', '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' ) ) );
1184 + }
1185 + }
1226 1186
1227 1187 /**
1228 1188 * Initializes the TinyMCE plugin bundled with this Wordpress plugin
1229 1189 */
1230 1190 function initTinyMCEPlugin() {
1231 - if ( ( ! current_user_can( 'edit_posts' ) ) && ( ! current_user_can( 'edit_pages' ) ) )
1232 - return;
1233 -
1234 - // Add only in Rich Editor mode
1235 - if ( get_user_option( 'rich_editing' ) == 'true' ) {
1236 - add_filter( "mce_external_plugins", array( &$this, "addTimedContentTinyMCEPlugin" ) );
1237 - add_filter( "mce_buttons", array( &$this, "registerTinyMCEButton" ) );
1238 - }
1239 - }
1191 + if ( ( ! current_user_can( 'edit_posts' ) ) && ( ! current_user_can( 'edit_pages' ) ) )
1192 + return;
1193 +
1194 + // Add only in Rich Editor mode
1195 + if ( get_user_option( 'rich_editing' ) == 'true' ) {
1196 + add_filter( "mce_external_plugins", array( &$this, "addTimedContentTinyMCEPlugin" ) );
1197 + add_filter( "mce_buttons", array( &$this, "registerTinyMCEButton" ) );
1198 + }
1199 + }
1240 1200
1241 1201 /**
1242 1202 * Sets up variables to use in the TinyMCE plugin's plugin.js.
1243 1203 *
@@ -1252,13 +1212,13 @@
1252 1212 if ( version_compare( $wp_version, "3.8", "<" ) )
1253 1213 $image = "/clock.gif";
1254 1214 else
1255 1215 $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 ) );
1216 + wp_localize_script( 'editor',
1217 + 'timedContentAdminTinyMCEOptions',
1218 + array( 'version' => TIMED_CONTENT_VERSION,
1219 + 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ),
1220 + 'image' => $image ) );
1261 1221 }
1262 1222 }
1263 1223
1264 1224 /**
@@ -1266,11 +1226,11 @@
1266 1226 * @param array $buttons Array of menu buttons already registered with TinyMCE
1267 1227 * @return array The array of TinyMCE menu buttons with ours now loaded in as well
1268 1228 */
1269 1229 function registerTinyMCEButton( $buttons ) {
1270 - array_push( $buttons, "|", "timed_content" );
1271 - return $buttons;
1272 - }
1230 + array_push( $buttons, "|", "timed_content" );
1231 + return $buttons;
1232 + }
1273 1233
1274 1234 /**
1275 1235 * Loads the associated TinyMCE plugin into TinyMCE's plugin array
1276 1236 *
@@ -1277,11 +1237,11 @@
1277 1237 * @param array $plugin_array Array of plugins already registered with TinyMCE
1278 1238 * @return array The array of TinyMCE plugins with ours now loaded in as well
1279 1239 */
1280 1240 function addTimedContentTinyMCEPlugin( $plugin_array ) {
1281 - $plugin_array['timed_content'] = TIMED_CONTENT_PLUGIN_URL . "/tinymce_plugin/plugin.js";
1282 - return $plugin_array;
1283 - }
1241 + $plugin_array['timed_content'] = TIMED_CONTENT_PLUGIN_URL . "/tinymce_plugin/plugin.js";
1242 + return $plugin_array;
1243 + }
1284 1244
1285 1245 /**
1286 1246 * Generates JavaScript array of objects describing Timed Content Rules. Used in the dialog box created by
1287 1247 * timedContentPlugin::timedContentPluginGetTinyMCEDialog().
@@ -1295,12 +1255,12 @@
1295 1255 foreach ( $the_rules as $rule ) {
1296 1256 $desc = $this->getScheduleDescriptionById( $rule->ID );
1297 1257 // Only add a rule if there's no errors or warnings
1298 1258 if ( false === strpos( $desc, "tcr-warning" ) )
1299 - $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";
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";
1300 1260 }
1301 1261 if ( empty( $the_rules ) )
1302 - $the_js .= " { 'ID': -999, 'title': ' ---- ', 'desc': '" . __( 'No Timed Content Rules found', 'timed-content' ) . "' }\n";
1262 + $the_js .= " { 'ID': -999, 'title': ' ---- ', 'desc': '" . __( 'No Timed Content Rules found', 'timed-content' ) . "' }\n";
1303 1263
1304 1264 $the_js .= "];\n";
1305 1265 return $the_js;
1306 1266 }
@@ -1307,9 +1267,9 @@
1307 1267 /**
1308 1268 * Display a dialog box for this plugin's associated TinyMCE plugin. Called from TinyMCE via AJAX.
1309 1269 *
1310 1270 */
1311 - function timedContentPluginGetTinyMCEDialog() {
1271 + function timedContentPluginGetTinyMCEDialog() {
1312 1272 include("lib/jquery-ui-datetime-i18n.php");
1313 1273
1314 1274 wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS);
1315 1275 wp_enqueue_script('jquery-ui-datepicker');
@@ -1317,44 +1277,44 @@
1317 1277 wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css');
1318 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);
1319 1279 wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js');
1320 1280 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/timed-content-datetime-i18n.js", array('jquery', 'jquery-ui-datepicker', TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js'), TIMED_CONTENT_VERSION);
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);
1322 1282 wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js');
1323 1283 wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n);
1324 1284 wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n);
1325 1285 }
1326 1286
1327 - ob_start();
1328 - include( "tinymce_plugin/dialog.php" );
1329 - $content = ob_get_contents();
1330 - ob_end_clean();
1331 - echo $content;
1332 - die();
1333 - }
1287 + ob_start();
1288 + include( "tinymce_plugin/dialog.php" );
1289 + $content = ob_get_contents();
1290 + ob_end_clean();
1291 + echo $content;
1292 + die();
1293 + }
1334 1294
1335 1295 /**
1336 1296 * Adds support for i18n (internationalization)
1337 1297 *
1338 1298 */
1339 - function i18nInit() {
1340 - $plugin_dir = basename( dirname( __FILE__ ) ) . "/lang/";
1341 - load_plugin_textdomain( 'timed-content', false, $plugin_dir );
1342 - }
1343 -
1299 + function i18nInit() {
1300 + $plugin_dir = basename( dirname( __FILE__ ) ) . "/lang/";
1301 + load_plugin_textdomain( 'timed-content', false, $plugin_dir );
1302 + }
1303 +
1344 1304 /**
1345 1305 * Add custom columns to the Timed Content Rules overview page
1346 1306 *
1347 1307 */
1348 - function addDescColumnHead( $defaults ) {
1349 - unset( $defaults['date'] );
1308 + function addDescColumnHead( $defaults ) {
1309 + unset( $defaults['date'] );
1350 1310 $defaults['description'] = __( 'Description', 'timed-content' );
1351 1311 $defaults['shortcode'] = __( 'Shortcode', 'timed-content' );
1352 - return $defaults;
1353 - }
1312 + return $defaults;
1313 + }
1354 1314
1355 1315 /**
1356 - * Display content associated with custom columns on the Timed Content Rules overview page
1316 + * Display content associated with custom columns on the Timed Content Rules overview page
1357 1317 *
1358 1318 * @param $column_name Name of the column to be displayed
1359 1319 * @param $post_ID ID of the Timed Content Rule being listed
1360 1320 */
@@ -1367,9 +1327,9 @@
1367 1327 if ( $desc ) {
1368 1328 echo '<em>' . $desc . '</em>';
1369 1329 }
1370 1330 }
1371 - }
1331 + }
1372 1332
1373 1333 /**
1374 1334 * Display a count of Timed Content Rules in the Dashboard's Right Now widget for Wordpress versions 3.7.1 and below
1375 1335 *
@@ -1408,17 +1368,17 @@
1408 1368 /**
1409 1369 * Display a count of Timed Content Rules in the Dashboard's Right Now widget
1410 1370 *
1411 1371 */
1412 - function addRulesCount() {
1413 - if ( !post_type_exists( TIMED_CONTENT_RULE_TYPE ) ) {
1414 - return;
1415 - }
1372 + function addRulesCount() {
1373 + if ( !post_type_exists( TIMED_CONTENT_RULE_TYPE ) ) {
1374 + return;
1375 + }
1416 1376
1417 - $num_posts = wp_count_posts( TIMED_CONTENT_RULE_TYPE );
1418 - $num = number_format_i18n( $num_posts->publish );
1419 - $text = _n( 'Timed Content Rule', 'Timed Content Rules', intval( $num_posts->publish ), 'timed-content' );
1420 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) )
1377 + $num_posts = wp_count_posts( TIMED_CONTENT_RULE_TYPE );
1378 + $num = number_format_i18n( $num_posts->publish );
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' ) )
1421 1381 echo "<a href='edit.php?post_type=" . TIMED_CONTENT_RULE_TYPE . "'>"
1422 1382 . '<li class="' . TIMED_CONTENT_RULE_TYPE . '-count">'
1423 1383 . $num
1424 1384 . ' '
@@ -1424,12 +1384,12 @@
1424 1384 . ' '
1425 1385 . $text
1426 1386 . '</a></li>';
1427 1387
1428 - if ( $num_posts->pending > 0 ) {
1429 - $num = number_format_i18n( $num_posts->pending );
1430 - $text = _n( 'Timed Content Rule Pending', 'Timed Content Rules Pending', intval( $num_posts->pending ), 'timed-content' );
1431 - if ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) )
1388 + if ( $num_posts->pending > 0 ) {
1389 + $num = number_format_i18n( $num_posts->pending );
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' ) )
1432 1392 echo "<a href='edit.php?post_status=pending&post_type=" . TIMED_CONTENT_RULE_TYPE . "'>"
1433 1393 . '<li class="' . TIMED_CONTENT_RULE_TYPE . '-count">'
1434 1394 . $num
1435 1395 . ' '
@@ -1435,86 +1395,88 @@
1435 1395 . ' '
1436 1396 . $text
1437 1397 . '</a></li>';
1438 1398 }
1439 - }
1440 -
1441 - function setUpCustomFields() {
1442 - require_once( "lib/customFields-settings.php" );
1443 - require_once( "lib/customFieldsInterface.php" );
1399 + }
1400 +
1401 + function setUpCustomFields() {
1402 + require_once( "lib/customFields-settings.php" );
1403 + require_once( "lib/customFieldsInterface.php" );
1444 1404
1445 - $scf = new customFieldsInterface( "timed_content_rule_schedule",
1446 - __( 'Rule Description/Schedule', 'timed-content' ),
1447 - "<div id=\"schedule_desc\" style=\"font-style: italic;\">"
1448 - . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $this->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $this->getScheduleDescriptionById( intval( 0 ) ) )
1449 - . "</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>",
1452 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1453 - array( TIMED_CONTENT_RULE_TYPE ),
1454 - array() );
1455 - $ocf = new customFieldsInterface( "timed_content_rule_initial_event",
1456 - __( 'Action/Initial Event', 'timed-content' ),
1457 - __( 'Set the action to be taken and when it should first run.', 'timed-content' ),
1458 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1459 - array( TIMED_CONTENT_RULE_TYPE ),
1460 - $timed_content_rule_occurrence_custom_fields );
1461 - $pcf = new customFieldsInterface( "timed_content_rule_recurrence",
1462 - __( 'Repeating Pattern', 'timed-content' ),
1463 - __( 'Set how often the action should repeat.', 'timed-content' ),
1464 - TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1465 - array( TIMED_CONTENT_RULE_TYPE ),
1466 - $timed_content_rule_pattern_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 );
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 );
1479 1439
1480 1440 // Initially loaded at the top; defining this constant here means it can get i18n'd
1481 1441 /* translators: date/time format for debugging messages. http://ca2.php.net/manual/en/function.date.php */
1482 - define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1442 + define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1483 1443
1484 1444 }
1485 1445
1486 - }
1446 + }
1487 1447
1488 1448 } //End Class timedContentPlugin
1489 1449
1490 1450 // Initialize plugin
1491 1451 if ( class_exists( "timedContentPlugin" ) ) {
1492 - $timedContentPluginInstance = new timedContentPlugin();
1452 + $timedContentPluginInstance = new timedContentPlugin();
1493 1453 }
1494 1454
1495 1455 // Actions and Filters
1496 1456 if ( isset( $timedContentPluginInstance ) ) {
1497 - global $wp_version;
1457 + global $wp_version;
1498 1458
1499 - add_filter('timed_content_filter', 'convert_smilies');
1500 - add_filter('timed_content_filter', 'convert_chars');
1501 - add_filter('timed_content_filter', 'prepend_attachment');
1502 - add_filter('timed_content_filter', 'do_shortcode');
1503 -
1504 - add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1505 - add_action( "init", array( &$timedContentPluginInstance, "timedContentRuleTypeInit" ), 2 );
1506 - add_action( "init", array( &$timedContentPluginInstance, "setUpCustomFields" ), 2 );
1507 - add_action( "wp_head", array( &$timedContentPluginInstance, "addHeaderCode" ), 1 );
1508 - add_filter( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_columns", array( &$timedContentPluginInstance, "addDescColumnHead" ) );
1509 - add_action( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_custom_column", array( &$timedContentPluginInstance, "addDescColumnContent" ), 10, 2);
1510 - add_action( "admin_enqueue_scripts", array( &$timedContentPluginInstance, "addAdminHeaderCode" ), 1 );
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 );
1467 + add_action( "init", array( &$timedContentPluginInstance, "timedContentRuleTypeInit" ), 2 );
1468 + add_action( "init", array( &$timedContentPluginInstance, "setUpCustomFields" ), 2 );
1469 + add_action( "wp_head", array( &$timedContentPluginInstance, "addHeaderCode" ), 1 );
1470 + add_filter( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_columns", array( &$timedContentPluginInstance, "addDescColumnHead" ) );
1471 + add_action( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_custom_column", array( &$timedContentPluginInstance, "addDescColumnContent" ), 10, 2);
1472 + add_action( "admin_enqueue_scripts", array( &$timedContentPluginInstance, "addAdminHeaderCode" ), 1 );
1511 1473 add_action( "admin_init", array( &$timedContentPluginInstance, "setTinyMCEPluginVars" ), 1 );
1512 - add_action( "admin_init", array( &$timedContentPluginInstance, "initTinyMCEPlugin" ), 2 );
1513 - add_action( 'wp_ajax_timedContentPluginGetTinyMCEDialog', array( &$timedContentPluginInstance, "timedContentPluginGetTinyMCEDialog" ), 1 );
1514 - add_action( 'wp_ajax_timedContentPluginGetRulePeriodsAjax', array( &$timedContentPluginInstance, "timedContentPluginGetRulePeriodsAjax" ), 1 );
1515 - add_action( 'wp_ajax_timedContentPluginGetScheduleDescriptionAjax', array( &$timedContentPluginInstance, "timedContentPluginGetScheduleDescriptionAjax" ), 1 );
1516 - add_filter( "post_updated_messages", array( &$timedContentPluginInstance, "timedContentRuleUpdatedMessages" ), 1 );
1474 + add_action( "admin_init", array( &$timedContentPluginInstance, "initTinyMCEPlugin" ), 2 );
1475 + add_action( 'wp_ajax_timedContentPluginGetTinyMCEDialog', array( &$timedContentPluginInstance, "timedContentPluginGetTinyMCEDialog" ), 1 );
1476 + add_action( 'wp_ajax_timedContentPluginGetRulePeriodsAjax', array( &$timedContentPluginInstance, "timedContentPluginGetRulePeriodsAjax" ), 1 );
1477 + add_action( 'wp_ajax_timedContentPluginGetScheduleDescriptionAjax', array( &$timedContentPluginInstance, "timedContentPluginGetScheduleDescriptionAjax" ), 1 );
1478 + add_filter( "post_updated_messages", array( &$timedContentPluginInstance, "timedContentRuleUpdatedMessages" ), 1 );
1517 1479 if ( version_compare( $wp_version, "3.8", ">=" ) ) {
1518 1480 add_action( "dashboard_glance_items", array( &$timedContentPluginInstance, "addRulesCount" ) );
1519 1481 add_action( "admin_head", array( &$timedContentPluginInstance, "addPostTypeIcons" ), 1 );
1520 1482 } else {
@@ -1522,10 +1484,8 @@
1522 1484 add_action( "admin_head", array( &$timedContentPluginInstance, "addPostTypeIcons37" ), 1 );
1523 1485 }
1524 1486
1525 1487 add_shortcode( TIMED_CONTENT_CLIENT_TAG, array( &$timedContentPluginInstance, "clientShowHTML" ), 1 );
1526 - add_shortcode( TIMED_CONTENT_SERVER_TAG, array( &$timedContentPluginInstance, "serverShowHTML" ), 1 );
1527 - add_shortcode( TIMED_CONTENT_RULE_TAG, array( &$timedContentPluginInstance, "rulesShowHTML" ), 1 );
1528 -
1529 - add_filter('pre_get_posts', array( &$timedContentPluginInstance, "timedContentPreGetPosts") );
1488 + add_shortcode( TIMED_CONTENT_SERVER_TAG, array( &$timedContentPluginInstance, "serverShowHTML" ), 1 );
1489 + add_shortcode( TIMED_CONTENT_RULE_TAG, array( &$timedContentPluginInstance, "rulesShowHTML" ), 1 );
1530 1490 }
1531 1491 ?>