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 +262 -77 2.32.7 View file →
@@ -4,17 +4,18 @@
4 4 Text Domain: timed-content
5 5 Domain Path: /lang
6 6 Plugin URI: http://wordpress.org/plugins/timed-content/
7 7 Description: Plugin to show or hide portions of a Page or Post based on specific date/time characteristics. These actions can either be processed either server-side or client-side, depending on the desired effect.
8 -Author: K. Tough
9 -Version: 2.3
8 +Author: K. Tough, Arno Welzel
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.3" );
15 - define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/timed-content' );
16 - define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
14 + define( "TIMED_CONTENT_VERSION", "2.7" );
15 + define( "TIMED_CONTENT_SLUG", "timed-content" );
16 + define( "TIMED_CONTENT_PLUGIN_URL", plugins_url() . '/' . TIMED_CONTENT_SLUG );
17 + define( "TIMED_CONTENT_CLIENT_TAG", "timed-content-client" );
17 18 define( "TIMED_CONTENT_SERVER_TAG", "timed-content-server" );
18 19 define( "TIMED_CONTENT_RULE_TAG", "timed-content-rule" );
19 20 define( "TIMED_CONTENT_ZERO_TIME", "1970-Jan-01 00:00:00 +000" ); // Start of Unix Epoch
20 21 define( "TIMED_CONTENT_END_TIME", "2038-Jan-19 03:14:07 +000" ); // End of Unix Epoch
@@ -35,14 +36,156 @@
35 36 * the possibility of name collisions with other plugins.
36 37 */
37 38 class timedContentPlugin {
38 39
40 + function __construct() {
41 + //constructor
42 +
43 + }
44 +
39 45 function timedContentPlugin() {
40 - //constructor
46 + self::__construct();
41 47
42 48 }
49 +
50 + /** https://core.trac.wordpress.org/ticket/25768
51 + *
52 + * Modified from the original patch to use the currently set
53 + * timezone from PHP, like PHP's date(), and to make the code
54 + * more readable.
55 + *
56 + * @param $j
57 + * @param $req_format
58 + * @param bool $i
59 + * @param bool $gmt
60 + * @return bool|string
61 + */
62 + function fix_date_i18n($j, $req_format, $i = false, $gmt = false)
63 + {
64 + /* @var $wp_locale WP_Locale */
65 + global $wp_locale;
66 + $timestamp = $i;
43 67
44 - /**
68 + // get current timestamp if $i is false
69 + if (false === $timestamp)
70 + {
71 + if ($gmt)
72 + $timestamp = time();
73 + else
74 + $timestamp = current_time('timestamp');
75 + }
76 +
77 +
78 + // get components of the date (timestamp) as array
79 + $date_components = getdate($timestamp);
80 +
81 + // numeric representation of a month, with leading zeros
82 + $date_month = $wp_locale->get_month($date_components['mon']);
83 + $date_month_abbrev = $wp_locale->get_month_abbrev($date_month);
84 + // numeric representation of the day of the week
85 + $date_weekday = $wp_locale->get_weekday($date_components['wday']);
86 + $date_weekday_abbrev = $wp_locale->get_weekday_abbrev($date_weekday);
87 + // get if hour is Ante meridiem or Post meridiem
88 + $meridiem = $date_components['hours'] >= 12 ? 'pm' : 'am';
89 + // lowercase Ante meridiem and Post meridiem hours
90 + $date_meridiem = $wp_locale->get_meridiem($meridiem);
91 + // uppercase Ante meridiem and Post meridiem
92 + $date_meridiem_capital = $wp_locale->get_meridiem(strtoupper($meridiem));
93 +
94 + // escape literals
95 + $date_weekday_abbrev = backslashit($date_weekday_abbrev);
96 + $date_month = backslashit($date_month);
97 + $date_weekday = backslashit($date_weekday);
98 + $date_month_abbrev = backslashit($date_month_abbrev);
99 + $date_meridiem = backslashit($date_meridiem);
100 + $date_meridiem_capital = backslashit($date_meridiem_capital);
101 +
102 + // the translated format string
103 + $translated_date_format_string = '';
104 + // the 2 arrays map a format literal to its translation (e. g. 'F' to the escaped month translation)
105 + $translate_formats = array('D', 'F', 'l', 'M', 'a', 'A', 'c', 'r');
106 + $translations = array(
107 + $date_weekday_abbrev, // D
108 + $date_month, // F
109 + $date_weekday, // l
110 + $date_month_abbrev, // M
111 + $date_meridiem, // a
112 + $date_meridiem_capital, // A
113 + 'Y-m-d\TH:i:sP', // c
114 + sprintf('%s, d %s Y H:i:s O', $date_weekday_abbrev, $date_month_abbrev), // r
115 + );
116 +
117 + // find each format literal that needs translation and replace it by its translation
118 + // respects the escaping
119 + // iterate $req_format from ending to beginning
120 + for ($i = strlen($req_format) - 1; $i > -1; $i--)
121 + {
122 + // test if current char is format literal that needs translation
123 + $translate_formats_index = array_search($req_format[$i], $translate_formats);
124 +
125 + if ($translate_formats_index !== false)
126 + {
127 + // counts the slashes (the escape char) in front of the current char
128 + $slashes_counter = 0;
129 +
130 + // count all slashes left-hand side of the current char
131 + for ($j = $i - 1; $j > -1; $j--)
132 + {
133 + if ($req_format[$j] == '\\')
134 + $slashes_counter++;
135 + else
136 + break;
137 + }
138 +
139 + // number of slashes is even
140 + if ($slashes_counter % 2 == 0)
141 + // current char is not escaped, therefore it is a format literal
142 + $translated_date_format_string = $translations[$translate_formats_index] . $translated_date_format_string;
143 + else
144 + // current char is escaped, therefore it is not a format literal, just add it unchanged
145 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
146 + }
147 + else
148 + // current char is no a format literal, just add it unchanged
149 + $translated_date_format_string = $req_format[$i] . $translated_date_format_string;
150 + }
151 +
152 + $req_format = $translated_date_format_string;
153 +
154 + if ($gmt)
155 + // get GMT date string
156 + $date_formatted = gmdate($req_format, $timestamp);
157 + else
158 + {
159 + // get Wordpress time zone
160 + // $timezone_string = get_option('timezone_string');
161 + // Haha, just kidding. Let's get the currently set timezone, as God and Rasmus intended
162 + $timezone_string = date_default_timezone_get();
163 +
164 + if ($timezone_string)
165 + {
166 + // create time zone object
167 + $timezone_object = timezone_open($timezone_string);
168 + // create date object from time zone object
169 + $local_date_object = date_create(null, $timezone_object);
170 + // set time and date of $local_date_object to $timestamp
171 + $date_components = isset($date_components) ? $date_components : getdate($timestamp);
172 + date_date_set($local_date_object, $date_components['year'], $date_components['mon'], $date_components['mday']);
173 + date_time_set($local_date_object, $date_components['hours'], $date_components['minutes'], $date_components['seconds']);
174 + // format date according to the Wordpress time zone
175 + $date_formatted = date_format($local_date_object, $req_format);
176 + }
177 + else
178 + {
179 + // fall back if no Wordpress time zone set
180 + $date_formatted = date($req_format, $i);
181 + }
182 + }
183 +
184 + return $date_formatted;
185 + }
186 +
187 + /**
45 188 * Creates the Timed Content Rule post type and registers it with Wordpress
46 189 *
47 190 */
48 191 function timedContentRuleTypeInit()
@@ -81,9 +224,8 @@
81 224 );
82 225 register_post_type( TIMED_CONTENT_RULE_TYPE, $args );
83 226 }
84 227
85 -
86 228 /**
87 229 * Filter to customize CRUD messages for Timed Content Rules
88 230 *
89 231 * @param array $messages Array of currently defined messages for post types
@@ -437,11 +579,12 @@
437 579 $monthly_pattern_day = $args['monthly_pattern_day'];
438 580 $exceptions_dates = $args['exceptions_dates'];
439 581 //print_r($days_of_week);
440 582
583 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
441 584 $temp_tz = date_default_timezone_get();
442 585 date_default_timezone_set( $timezone );
443 - $right_now_t = time();
586 + $right_now_t = current_time( 'timestamp', 1 );
444 587
445 588 $instance_start = strtotime( $this->__datetimeToEnglish( $instance_start_date, $instance_start_time ) . " " . $timezone ); // Beginning of first occurrence
446 589 $instance_end = strtotime( $this->__datetimeToEnglish( $instance_end_date, $instance_end_time ) . " " . $timezone ); // End of first occurrence
447 590 $current = $instance_start;
@@ -454,22 +597,22 @@
454 597
455 598 if ( $human_readable == true ) {
456 599 $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
457 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 + }
458 611 } else {
459 612 $active_periods[$period_count]["start"] = $current;
460 613 $active_periods[$period_count]["end"] = $end_current;
461 614 }
462 - if ( $right_now_t < $current ) {
463 - $active_periods[$period_count]["status"] = "upcoming";
464 - $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
465 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
466 - $active_periods[$period_count]["status"] = "active";
467 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
468 - } else {
469 - $active_periods[$period_count]["status"] = "expired";
470 - $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
471 - }
472 615 $period_count++;
473 616
474 617 if ( $recurr_type == "recurrence_duration_end_date" )
475 618 $loop_test = "return ( \$current < \$last_occurrence_start );";
@@ -494,12 +637,14 @@
494 637 } elseif ( $freq == 4 )
495 638 $current = $this->__getNextYear( $current, $interval_multiplier );
496 639
497 640 $exception_period = false;
498 - foreach ( $exceptions_dates as $date ) {
499 - if ( ( $current >= $date ) && ( $current < strtotime( "+1 day", $date ) ) ) {
500 - $exception_period = true;
501 - break;
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 + }
502 647 }
503 648 }
504 649
505 650 if ( ( eval ( $loop_test ) ) && ( !($exception_period) ) ) {
@@ -506,22 +651,22 @@
506 651 $end_current = $current + ( $instance_end - $instance_start );
507 652 if ( $human_readable == true ) {
508 653 $active_periods[$period_count]["start"] = date_i18n( TIMED_CONTENT_DT_FORMAT, $current );
509 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 + }
510 665 } else {
511 666 $active_periods[$period_count]["start"] = $current;
512 667 $active_periods[$period_count]["end"] = $end_current;
513 668 }
514 - if ( $right_now_t < $current ) {
515 - $active_periods[$period_count]["status"] = "upcoming";
516 - $active_periods[$period_count]["time"] = sprintf( _x( '%s from now.', 'Human readable time difference', 'timed-content' ), human_time_diff( $current, $right_now_t ) );
517 - } elseif ( ( $current <= $right_now_t ) && ( $right_now_t <= $end_current ) ) {
518 - $active_periods[$period_count]["status"] = "active";
519 - $active_periods[$period_count]["time"] = __( "Right now!", 'timed-content' );
520 - } else {
521 - $active_periods[$period_count]["status"] = "expired";
522 - $active_periods[$period_count]["time"] = sprintf( _x( '%s ago.', 'Human readable time difference', 'timed-content' ), human_time_diff( $end_current, $right_now_t ) );
523 - }
524 669 if ( !($exception_period) )
525 670 $period_count++;
526 671 }
527 672
@@ -526,8 +671,9 @@
526 671 }
527 672
528 673 }
529 674 date_default_timezone_set( $temp_tz );
675 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
530 676 return $active_periods;
531 677 }
532 678
533 679 /**
@@ -819,10 +965,20 @@
819 965
820 966 $the_class = TIMED_CONTENT_CLIENT_TAG . $show_attr . $hide_attr ;
821 967 $the_tag = ( $display == "div" ? "div" : "span" );
822 968
823 - $the_HTML = "<" . $the_tag . " class='" . $the_class . "'" . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">" . do_shortcode( $content ) . "</" . $the_tag . ">";
969 + $the_filter = "timed_content_filter";
970 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
824 971
972 + $the_HTML = "<"
973 + . $the_tag
974 + . " class='"
975 + . $the_class
976 + . "'"
977 + . ( ( $show_attr != "" ) ? " style='display: none;'" : "" ) .">"
978 + . str_replace( ']]>', ']]&gt;', apply_filters( $the_filter, $content ) )
979 + . "</" . $the_tag . ">";
980 +
825 981 return $the_HTML;
826 982 }
827 983
828 984 /**
@@ -836,12 +992,16 @@
836 992 global $post;
837 993 extract( shortcode_atts( array( 'show' => TIMED_CONTENT_ZERO_TIME , 'hide' => TIMED_CONTENT_END_TIME, 'debug' => 'false' ), $atts ) );
838 994 $show_t = strtotime( $this->__datetimeToEnglish( $show ) );
839 995 $hide_t = strtotime( $this->__datetimeToEnglish( $hide ) );
840 - $right_now_t = time();
996 + $right_now_t = current_time( 'timestamp', 1 );
841 997 $debug_message = "";
842 998
999 + $the_filter = "timed_content_filter";
1000 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1001 +
843 1002 if ( ( $debug == "true" ) && ( current_user_can( "edit_post", $post->post_id ) ) ) {
1003 + add_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
844 1004 $temp_tz = date_default_timezone_get();
845 1005 date_default_timezone_set( get_option( 'timezone_string' ) );
846 1006
847 1007 $right_now = date_i18n( TIMED_CONTENT_DT_FORMAT, $right_now_t );
@@ -872,21 +1032,27 @@
872 1032 $debug_message .= "<p>" . sprintf( __( 'The %s attribute is currently set to', 'timed-content' ), "<code>hide</code>" ) . ": " . $hide . ",<br />\n"
873 1033 . __( 'The Timed Content plugin thinks the intended date/time is', 'timed-content') . ": " . date_i18n( TIMED_CONTENT_DT_FORMAT, $hide_t )
874 1034 . " (" . $hide_diff_str . ").</p>\n";
875 1035
876 - $debug_message .= "<p>" . __( 'Current Date/Time:', 'timed-content') . "&nbsp;" . $right_now . "</p>\n";
877 - $debug_message .= "<p>" . _x( 'Content:', "Noun", 'timed-content') . "&nbsp;" . $content . "</p>\n";
1036 + $debug_message .= "<p>" . __( 'Current Date/Time:', 'timed-content') . "&nbsp;" . $right_now . "<br />\n";
1037 + $debug_message .= __( 'Content Filter:', 'timed-content') . "&nbsp;" . $the_filter . "</p>\n";
1038 + $debug_message .= "<p>" . _x( 'Content:', "Noun", 'timed-content') . "&nbsp;" . $content . "</p>\n";
878 1039
879 1040 $debug_message .= "</div>\n";
880 1041
881 1042 date_default_timezone_set( $temp_tz );
1043 + remove_filter('date_i18n', array( &$this, "fix_date_i18n" ), 10, 4);
882 1044 }
883 -
884 - if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) )
885 - return $debug_message . do_shortcode( $content ) . "\n";
886 - else
887 - return $debug_message . "\n";
888 1045
1046 +
1047 + if ( ( $show_t <= $right_now_t ) && ( $right_now_t <= $hide_t ) ) {
1048 + do_action("timed_content_server_show", $post->ID, $show, $hide, $content);
1049 + return $debug_message . str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content)) . "\n";
1050 + } else {
1051 + do_action("timed_content_server_hide", $post->ID, $show, $hide, $content);
1052 + return $debug_message . "\n";
1053 + }
1054 +
889 1055 }
890 1056
891 1057 /**
892 1058 * Processes the [timed-content-rule] shortcode.
@@ -895,13 +1061,19 @@
895 1061 * @param null $content
896 1062 * @return string
897 1063 */
898 1064 function rulesShowHTML( $atts, $content = null ) {
899 - extract( shortcode_atts( array( 'id' => '0' ), $atts ) );
1065 + global $post;
1066 + extract( shortcode_atts( array( 'id' => 0 ), $atts ) );
1067 + if ( !is_numeric( $id ) ) {
1068 + $page = get_page_by_title( $id, OBJECT, TIMED_CONTENT_RULE_TYPE );
1069 + if ( $page == null ) return;
1070 + $id = $page->ID;
1071 + }
900 1072 if ( TIMED_CONTENT_RULE_TYPE != get_post_type( $id ) ) return;
901 1073
902 1074 $prefix = TIMED_CONTENT_RULE_POSTMETA_PREFIX;
903 - $right_now_t = time();
1075 + $right_now_t = current_time( 'timestamp', 1 );
904 1076 $rule_is_active = false;
905 1077
906 1078 $active_periods = $this->getRulePeriodsById( $id, false );
907 1079 $action_is_show = (bool) get_post_meta( $id, $prefix . 'action', true );
@@ -911,13 +1083,19 @@
911 1083 $rule_is_active = true;
912 1084 break;
913 1085 }
914 1086 }
915 -
916 - if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) )
917 - return do_shortcode( $content );
918 - else
919 - return "";
1087 +
1088 + $the_filter = "timed_content_filter";
1089 + $the_filter = apply_filters( "timed_content_filter_override", $the_filter );
1090 +
1091 + if ( ( ( $rule_is_active == true ) && ( $action_is_show == true ) ) || ( ( $rule_is_active == false ) && ( $action_is_show == false ) ) ) {
1092 + do_action("timed_content_rule_show", $post->ID, $id, $content);
1093 + return str_replace(']]>', ']]&gt;', apply_filters($the_filter, $content));
1094 + } else {
1095 + do_action("timed_content_rule_hide", $post->ID, $id, $content);
1096 + return "";
1097 + }
920 1098 }
921 1099
922 1100 /**
923 1101 * Enqueues the JavaScript code necessary for the functionality of the [timed-content-client] shortcode.
@@ -980,13 +1158,14 @@
980 1158 function addAdminHeaderCode() {
981 1159 if ( ( isset( $_GET['post_type'] ) && $_GET['post_type'] == TIMED_CONTENT_RULE_TYPE )
982 1160 || ( isset( $post_type ) && $post_type == TIMED_CONTENT_RULE_TYPE )
983 1161 || ( isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == TIMED_CONTENT_RULE_TYPE ) ) {
984 - wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
1162 + wp_enqueue_style( 'thickbox' );
1163 + wp_enqueue_style( 'timed-content-css', TIMED_CONTENT_CSS, false, TIMED_CONTENT_VERSION );
985 1164 // Enqueue the JavaScript file that manages the meta box UI
986 1165 wp_enqueue_script( 'timed-content-admin_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin.js', array( 'jquery' ), TIMED_CONTENT_VERSION );
987 1166 // Enqueue the JavaScript file that makes AJAX requests
988 - wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'jquery-ui-dialog' ), TIMED_CONTENT_VERSION );
1167 + wp_enqueue_script( 'timed-content-ajax_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-ajax.js', array( 'jquery', 'thickbox' ), TIMED_CONTENT_VERSION );
989 1168
990 1169 // Set up local variables used in the Admin JavaScript file
991 1170 wp_localize_script( 'timed-content-admin_js', 'timedContentRuleAdmin', array(
992 1171 'no_exceptions_label' => __( "- No exceptions set -", 'timed-content' ) ) );
@@ -995,12 +1174,12 @@
995 1174 wp_localize_script( 'timed-content-ajax_js', 'timedContentRuleAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
996 1175 'start_label' => _x( 'Start', 'Scheduled Dates/Times dialog - Beginning of active period table header', 'timed-content' ),
997 1176 'end_label' => _x( 'End', 'Scheduled Dates/Times dialog - End of active period table header', 'timed-content' ),
998 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' ),
999 1180 'dialog_width' => 800,
1000 1181 'dialog_height' => 500,
1001 - 'close_label' => _x( 'Close', 'Scheduled Dates/Times dialog - Close button HTML label', 'timed-content' ),
1002 - 'loadingimg' => TIMED_CONTENT_PLUGIN_URL . '/img/wpspin.gif',
1003 1182 'error' => __( "Error", 'timed-content' ),
1004 1183 'error_desc' => __( "Something unexpected has happened along the way. The specific details are below:", 'timed-content' ) ) );
1005 1184 }
1006 1185 }
@@ -1033,14 +1212,13 @@
1033 1212 if ( version_compare( $wp_version, "3.8", "<" ) )
1034 1213 $image = "/clock.gif";
1035 1214 else
1036 1215 $image = "";
1037 - wp_enqueue_script( 'timed-content-admin_tinymce_js', TIMED_CONTENT_PLUGIN_URL . '/js/timed-content-admin-tinymce.js', array(), TIMED_CONTENT_VERSION );
1038 - wp_localize_script( 'timed-content-admin_tinymce_js',
1039 - 'timedContentAdminTinyMCEOptionsVars',
1040 - array( 'version' => TIMED_CONTENT_VERSION,
1041 - 'desc' => __( "Add Timed Content shortcodes", 'timed-content' ),
1042 - '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 ) );
1043 1221 }
1044 1222 }
1045 1223
1046 1224 /**
@@ -1090,26 +1268,22 @@
1090 1268 * Display a dialog box for this plugin's associated TinyMCE plugin. Called from TinyMCE via AJAX.
1091 1269 *
1092 1270 */
1093 1271 function timedContentPluginGetTinyMCEDialog() {
1094 - include( "lib/jquery-ui-datetime-i18n.php" );
1272 + include("lib/jquery-ui-datetime-i18n.php");
1095 1273
1096 - wp_enqueue_style( 'timed-content-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS, false, TIMED_CONTENT_VERSION );
1097 - wp_enqueue_script( 'jquery-ui-datepicker' );
1098 - if( !( wp_script_is( 'timed-content-jquery-ui-datepicker-i18n-js', 'registered' ) ) ) {
1099 - wp_register_script( 'timed-content-jquery-ui-datepicker-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/timed-content-datepicker-i18n.js", array( 'jquery', 'jquery-ui-datepicker' ), TIMED_CONTENT_VERSION );
1100 - wp_enqueue_script( 'timed-content-jquery-ui-datepicker-i18n-js' );
1101 - wp_localize_script( 'timed-content-jquery-ui-datepicker-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n );
1274 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-css', TIMED_CONTENT_JQUERY_UI_CSS);
1275 + wp_enqueue_script('jquery-ui-datepicker');
1276 + wp_register_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS);
1277 + wp_enqueue_style(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-css');
1278 + wp_register_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array('jquery', 'jquery-ui-datepicker'), TIMED_CONTENT_VERSION);
1279 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js');
1280 + if (!(wp_script_is(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'registered'))) {
1281 + wp_register_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/content-protector-datetime-i18n.js", array('jquery', 'jquery-ui-datepicker', TIMED_CONTENT_SLUG . '-jquery-ui-timepicker-js'), TIMED_CONTENT_VERSION);
1282 + wp_enqueue_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js');
1283 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQDatepickerI18n', $jquery_ui_datetime_datepicker_i18n);
1284 + wp_localize_script(TIMED_CONTENT_SLUG . '-jquery-ui-datetime-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n);
1102 1285 }
1103 - wp_register_style( 'timed-content-jquery-ui-timepicker-css', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_CSS, array( TIMED_CONTENT_JQUERY_UI_CSS ), TIMED_CONTENT_VERSION );
1104 - wp_enqueue_style( 'timed-content-jquery-ui-timepicker-css' );
1105 - wp_register_script( 'timed-content-jquery-ui-timepicker-js', TIMED_CONTENT_JQUERY_UI_TIMEPICKER_JS, array( 'jquery', 'jquery-ui-datepicker' ), TIMED_CONTENT_VERSION );
1106 - wp_enqueue_script( 'timed-content-jquery-ui-timepicker-js' );
1107 - if( !( wp_script_is( 'timed-content-jquery-ui-timepicker-i18n-js', 'registered' ) ) ) {
1108 - wp_register_script( 'timed-content-jquery-ui-timepicker-i18n-js', TIMED_CONTENT_PLUGIN_URL . "/js/timed-content-timepicker-i18n.js", array( 'jquery', 'jquery-ui-datepicker', 'timed-content-jquery-ui-timepicker-js' ), TIMED_CONTENT_VERSION );
1109 - wp_enqueue_script( 'timed-content-jquery-ui-timepicker-i18n-js' );
1110 - wp_localize_script( 'timed-content-jquery-ui-timepicker-i18n-js', 'TimedContentJQTimepickerI18n', $jquery_ui_datetime_timepicker_i18n );
1111 - }
1112 1286
1113 1287 ob_start();
1114 1288 include( "tinymce_plugin/dialog.php" );
1115 1289 $content = ob_get_contents();
@@ -1232,9 +1406,10 @@
1232 1406 __( 'Rule Description/Schedule', 'timed-content' ),
1233 1407 "<div id=\"schedule_desc\" style=\"font-style: italic;\">"
1234 1408 . ( isset( $_GET['post'] ) && ( TIMED_CONTENT_RULE_TYPE === get_post_type( $_GET['post'] ) ) ? $this->getScheduleDescriptionById( intval( $_GET['post'] ) ) : $this->getScheduleDescriptionById( intval( 0 ) ) )
1235 1409 . "</div>"
1236 - . "<div style=\"padding-top: 10px;\"><input type=\"button\" class=\"button-primary\" id=\"timed_content_rule_test\" value=\"" . __( 'Show Projected Dates/Times', 'timed-content' ) . "\" /></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>",
1237 1412 TIMED_CONTENT_RULE_POSTMETA_PREFIX,
1238 1413 array( TIMED_CONTENT_RULE_TYPE ),
1239 1414 array() );
1240 1415 $ocf = new customFieldsInterface( "timed_content_rule_initial_event",
@@ -1266,8 +1441,9 @@
1266 1441 /* translators: date/time format for debugging messages. http://ca2.php.net/manual/en/function.date.php */
1267 1442 define( "TIMED_CONTENT_DT_FORMAT", __( "l, F jS, Y, g:i A T" , 'timed-content' ) );
1268 1443
1269 1444 }
1445 +
1270 1446 }
1271 1447
1272 1448 } //End Class timedContentPlugin
1273 1449
@@ -1277,9 +1453,18 @@
1277 1453 }
1278 1454
1279 1455 // Actions and Filters
1280 1456 if ( isset( $timedContentPluginInstance ) ) {
1281 - add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1457 + global $wp_version;
1458 +
1459 + add_filter('timed_content_filter', 'wptexturize');
1460 + add_filter('timed_content_filter', 'convert_smilies');
1461 + add_filter('timed_content_filter', 'convert_chars');
1462 + add_filter('timed_content_filter', 'wpautop');
1463 + add_filter('timed_content_filter', 'prepend_attachment');
1464 + add_filter('timed_content_filter', 'do_shortcode');
1465 +
1466 + add_action( "plugins_loaded", array( &$timedContentPluginInstance, "i18nInit" ), 1 );
1282 1467 add_action( "init", array( &$timedContentPluginInstance, "timedContentRuleTypeInit" ), 2 );
1283 1468 add_action( "init", array( &$timedContentPluginInstance, "setUpCustomFields" ), 2 );
1284 1469 add_action( "wp_head", array( &$timedContentPluginInstance, "addHeaderCode" ), 1 );
1285 1470 add_filter( "manage_" . TIMED_CONTENT_RULE_TYPE . "_posts_columns", array( &$timedContentPluginInstance, "addDescColumnHead" ) );