PluginProbe
Timed Content / 2.9
Timed Content v2.9
2.99 trunk 1.0 1.1 1.2 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.10 2.11 2.12 2.15 2.2 2.3 2.3.1 2.4 2.5 2.5.1 2.50 2.51 2.52 All 67 releases
← All changes | lib/customFields-settings.php +95 -42 2.1 → 2.9 View file →
@@ -1,8 +1,26 @@
1 1 <?php
2 2 require_once("Arrays_Definitions.php");
3 +global $post,
4 + $timed_content_rule_occurrence_custom_fields,
5 + $timed_content_rule_pattern_custom_fields,
6 + $timed_content_rule_recurrence_custom_fields,
7 + $timed_content_rule_exceptions_custom_fields;
3 8 $now_t = current_time( "timestamp" );
4 -global $timed_content_rule_occurrence_custom_fields, $timed_content_rule_pattern_custom_fields, $timed_content_rule_recurrence_custom_fields;
9 +$post_id = ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? intval( $_GET['post'] ) : intval( 0 ) );
10 +$timed_content_rules_exceptions_dates = ( "" === get_post_meta( $post_id, TIMED_CONTENT_RULE_POSTMETA_PREFIX . "exceptions_dates", true ) ? array() : get_post_meta( $post_id, TIMED_CONTENT_RULE_POSTMETA_PREFIX . "exceptions_dates", true ) );
11 +if ( empty( $timed_content_rules_exceptions_dates ) )
12 + $timed_content_rules_exceptions_dates_array = array( "0" => __( "- No exceptions set -", 'timed-content' ) );
13 +else {
14 + sort( $timed_content_rules_exceptions_dates, SORT_NUMERIC );
15 + $timed_content_rules_exceptions_dates = array_unique( $timed_content_rules_exceptions_dates );
16 + $formatted_dates = array();
17 + foreach ( $timed_content_rules_exceptions_dates as $a_date ) {
18 + $a_date_idx = $a_date * 1000;
19 + $formatted_dates[$a_date_idx] = date(_x("F j, Y", "Date format for schedule description", 'timed-content'), $a_date);
20 + }
21 + $timed_content_rules_exceptions_dates_array = array_combine($timed_content_rules_exceptions_dates, $formatted_dates);
22 +}
5 23
6 24 $timed_content_rule_occurrence_custom_fields = array(
7 25 array(
8 26 "name" => "action",
@@ -21,10 +39,10 @@
21 39 "display" => "block",
22 40 "title" => __( "Starting Date/Time", 'timed-content' ),
23 41 "description" => __( "Sets the date and time for the beginning of the first active period for this rule.", 'timed-content' ),
24 42 "type" => "datetime",
25 - "default" => array( "date" => date( "F jS, Y", strtotime( "+1 hour", $now_t ) ),
26 - "time" => date( "g:i A", strtotime( "+1 hour", $now_t ) ) ),
43 + "default" => array( "date" => date_i18n( _x( "F jS, Y", "Starting Date/Time date format (http://ca2.php.net/manual/en/function.date.php)", 'timed-content'), strtotime( "+1 hour", $now_t ) ),
44 + "time" => date_i18n( _x( "g:i A", "Starting Date/Time time format (http://ca2.php.net/manual/en/function.date.php)", 'timed-content'), strtotime( "+1 hour", $now_t ) ) ),
27 45 "scope" => array( TIMED_CONTENT_RULE_TYPE ),
28 46 "capability" => "edit_posts"
29 47 ),
30 48 array(
@@ -32,10 +50,10 @@
32 50 "display" => "block",
33 51 "title" => __( "Ending Date/Time", 'timed-content' ),
34 52 "description" => __( "Sets the date and time for the end of the first active period for this rule.", 'timed-content' ),
35 53 "type" => "datetime",
36 - "default" => array( "date" => date( "F jS, Y", strtotime( "+2 hour", $now_t ) ),
37 - "time" => date( "g:i A", strtotime( "+2 hour", $now_t ) ) ),
54 + "default" => array( "date" => date_i18n( _x( "F jS, Y", "Ending Date/Time date format (http://ca2.php.net/manual/en/function.date.php)", 'timed-content'), strtotime( "+2 hour", $now_t ) ),
55 + "time" => date_i18n( _x( "g:i A", "Ending Date/Time time format (http://ca2.php.net/manual/en/function.date.php)", 'timed-content'), strtotime( "+2 hour", $now_t ) ) ),
38 56 "scope" => array( TIMED_CONTENT_RULE_TYPE ),
39 57 "capability" => "edit_posts"
40 58 ),
41 59 array(
@@ -43,9 +61,9 @@
43 61 "display" => "block",
44 62 "title" => __( "Timezone:", 'timed-content' ),
45 63 "description" => __( "Select a city in the timezone you wish to use for this rule.", 'timed-content' ),
46 64 "type" => "timezone-list",
47 - "default" => get_option('timezone_string'),
65 + "default" => get_option( 'timezone_string' ),
48 66 "scope" => array( TIMED_CONTENT_RULE_TYPE ),
49 67 "capability" => "edit_posts"
50 68 )
51 69 );
@@ -119,9 +137,9 @@
119 137 array(
120 138 "name" => "monthly_nth_weekday_of_month",
121 139 "display" => "none",
122 140 "title" => __( "Repeat On The Nth Weekday Of The Month?", 'timed-content' ),
123 - "description" => __( "If the frequency is set to Monthly, repeat this action on the Nth weekday of the month (i.e., every third Tuesday). Check this box to select a pattern below.", 'timed-content' ),
141 + "description" => __( "If the frequency is set to Monthly, repeat this action on the Nth weekday of the month (for example, 'every third Tuesday'). Check this box to select a pattern below.", 'timed-content' ),
124 142 "type" => "checkbox",
125 143 "default" => "no",
126 144 "scope" => array( TIMED_CONTENT_RULE_TYPE ),
127 145 "capability" => "edit_posts"
@@ -129,9 +147,9 @@
129 147 array(
130 148 "name" => "monthly_nth_weekday_of_month_nth",
131 149 "display" => "none",
132 150 "title" => __( "Nth Weekday Ordinal:", 'timed-content' ),
133 - "description" => __( "Select a value for the Nth (i.e., 'first', 'second', etc.) week of the month.", 'timed-content' ),
151 + "description" => __( "Select a value for the Nth (for example 'first', 'second', etc.) week of the month.", 'timed-content' ),
134 152 "type" => "list",
135 153 "default" => 0,
136 154 "values" => $timed_content_rule_ordinal_array,
137 155 "scope" => array( TIMED_CONTENT_RULE_TYPE ),
@@ -160,40 +178,75 @@
160 178 "capability" => "edit_posts"
161 179 )
162 180 );
163 181 $timed_content_rule_recurrence_custom_fields = array(
164 - array(
165 - "name" => "recurrence_duration",
166 - "display" => "block",
167 - "title" => __( "How Often To Repeat This Action?", 'timed-content' ),
168 - "description" => "",
169 - "type" => "radio",
170 - "values" => array( "recurrence_duration_end_date" => __( "Keep repeating until a given date", 'timed-content' ),
171 - "recurrence_duration_num_repeat" => __( "Repeat a set number of times", 'timed-content' ) ),
172 - "default" => "recurrence_duration_end_date",
173 - "scope" => array( TIMED_CONTENT_RULE_TYPE ),
174 - "capability" => "edit_posts"
175 - ),
176 - array(
177 - "name" => "recurrence_duration_end_date",
178 - "display" => "none",
179 - "title" => __( "End Date:", 'timed-content' ),
180 - "description" => __( "Using the settings above, repeat this action until this date.", 'timed-content' ),
181 - "type" => "date",
182 - "default" => date( "F jS, Y", strtotime( "+1 year", $now_t ) ),
183 - "scope" => array( TIMED_CONTENT_RULE_TYPE ),
184 - "capability" => "edit_posts"
185 - ),
186 - array(
187 - "name" => "recurrence_duration_num_repeat",
188 - "display" => "none",
189 - "title" => __( "Repeat How Many Times?", 'timed-content' ),
190 - "description" => __( "Using the settings above, repeat this action this many times.", 'timed-content' ),
191 - "type" => "number",
192 - "default" => "1",
193 - "min" => "1",
194 - "scope" => array( TIMED_CONTENT_RULE_TYPE ),
195 - "capability" => "edit_posts"
196 - )
197 - );
182 + array(
183 + "name" => "recurrence_duration",
184 + "display" => "block",
185 + "title" => __( "How Often To Repeat This Action?", 'timed-content' ),
186 + "description" => "",
187 + "type" => "radio",
188 + "values" => array( "recurrence_duration_end_date" => __( "Keep repeating until a given date", 'timed-content' ),
189 + "recurrence_duration_num_repeat" => __( "Repeat a set number of times", 'timed-content' ) ),
190 + "default" => "recurrence_duration_end_date",
191 + "scope" => array( TIMED_CONTENT_RULE_TYPE ),
192 + "capability" => "edit_posts"
193 + ),
194 + array(
195 + "name" => "recurrence_duration_end_date",
196 + "display" => "none",
197 + "title" => __( "End Date:", 'timed-content' ),
198 + "description" => __( "Using the settings above, repeat this action until this date.", 'timed-content' ),
199 + "type" => "date",
200 + "default" => date_i18n( _x( "F jS, Y", "End Date date format (http://ca2.php.net/manual/en/function.date.php)", 'timed-content'), strtotime( "+1 year", $now_t ) ),
201 + "scope" => array( TIMED_CONTENT_RULE_TYPE ),
202 + "capability" => "edit_posts"
203 + ),
204 + array(
205 + "name" => "recurrence_duration_num_repeat",
206 + "display" => "none",
207 + "title" => __( "Repeat How Many Times?", 'timed-content' ),
208 + "description" => __( "Using the settings above, repeat this action this many times.", 'timed-content' ),
209 + "type" => "number",
210 + "default" => "1",
211 + "min" => "1",
212 + "scope" => array( TIMED_CONTENT_RULE_TYPE ),
213 + "capability" => "edit_posts"
214 + )
215 +);
216 +$exceptions_dates_picker_on_select = <<<FUNC
217 +onSelect: function (dateText, inst) {
218 + //alert(dateText);
219 + jQuery("#timed_content_rule_exceptions_dates option[value='0']" ).remove();
220 + jQuery("#timed_content_rule_exceptions_dates").append( '<option value="' + parseInt(Date.parse(dateText) / 1000) + '">' + dateText + '</option>' );
221 + jQuery(this).val("");
222 + jQuery(this).trigger("change");
223 + },
224 +FUNC;
225 +
226 +$timed_content_rule_exceptions_custom_fields = array(
227 + array(
228 + "name" => "exceptions_dates_picker",
229 + "display" => "block",
230 + "title" => __( "Add Exception Date:", 'timed-content' ),
231 + "description" => __( "Select a date to add to the Exception Dates List.", 'timed-content' ),
232 + "type" => "date",
233 + "default" => "",
234 + "scope" => array( TIMED_CONTENT_RULE_TYPE ),
235 + "capability" => "edit_posts",
236 + "custom_functions" => $exceptions_dates_picker_on_select
237 + ),
238 + array(
239 + "name" => "exceptions_dates",
240 + "display" => "block",
241 + "title" => __( "Exception Dates List", 'timed-content' ),
242 + "description" => __( "Dates that this Timed Content Rule will not be active. Double-click on a date to remove it from the list.", 'timed-content' ),
243 + "type" => "menu",
244 + "values" => $timed_content_rules_exceptions_dates_array,
245 + "size" => "10",
246 + "default" => array(),
247 + "scope" => array( TIMED_CONTENT_RULE_TYPE ),
248 + "capability" => "edit_posts"
249 + )
250 +);
198 251
199 252 ?>