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 +88 -35 2.22.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",
@@ -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_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 ) ),
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 ?>