Changeset 1680091
- Timestamp:
- 06/16/2017 07:35:16 PM (9 years ago)
- Location:
- keep-in-touch/trunk
- Files:
-
- 1 added
- 6 edited
-
class-keep-in-touch-msg.php (modified) (5 diffs)
-
class-keep-in-touch-options.php (added)
-
class-keep-in-touch-schedule.php (modified) (5 diffs)
-
class-keep-in-touch-settings.php (modified) (9 diffs)
-
class-keep-in-touch-utils.php (modified) (2 diffs)
-
class-keep-in-touch-widget.php (modified) (1 diff)
-
keep-in-touch.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
keep-in-touch/trunk/class-keep-in-touch-msg.php
r1644786 r1680091 3 3 defined('ABSPATH') or die ('No direct access to this file.'); 4 4 5 include_once('class-keep-in-touch-utils.php'); 6 include_once('class-keep-in-touch-db.php'); 7 include_once('class-virtual-page.php'); 5 require_once('class-keep-in-touch-utils.php'); 6 require_once('class-keep-in-touch-options.php'); 7 require_once('class-keep-in-touch-db.php'); 8 require_once('class-virtual-page.php'); 8 9 9 10 class Keep_In_Touch_Msg … … 29 30 static function emit_subscription_anti_robot($email) 30 31 { 31 $use_full_name = ( get_option('keep_in_touch_use_full_name') == 'yes');32 $use_full_name = (Keep_In_Touch_Options::get_option_use_full_name(false) == true); 32 33 33 34 Virtual_Page::create_from_content(array( … … 117 118 static function emit_subscription_confirmation($email, $confirmation_code) 118 119 { 119 $common_content = wpautop( get_option("keep_in_touch_subscription_confirmation_text"));120 $common_content = wpautop(Keep_In_Touch_Options::get_option_subscription_confirmation_text('')); 120 121 121 122 wp_mail( … … 277 278 if ($query->found_posts == 0) 278 279 { 279 if (!Keep_In_Touch_ Utils::bool(get_option('keep_in_touch_send_empty_digest_message')))280 if (!Keep_In_Touch_Options::get_option_send_empty_digest_message(false)) 280 281 return; 281 $message = wpautop( get_option('keep_in_touch_empty_digest_message_text'));282 $message = wpautop(Keep_In_Touch_Options::get_option_empty_digest_message_text('')); 282 283 } 283 284 else … … 308 309 static private function get_configured_header_image_url() 309 310 { 310 if ( get_option('keep_in_touch_header_image_option') == 'get_header_image')311 if (Keep_In_Touch_Options::get_option_header_image_option('') == 'get_header_image') 311 312 { 312 313 return get_header_image(); 313 314 } 314 315 315 if ( get_option('keep_in_touch_header_image_option') == 'custom_path')316 { 317 $custom_path = get_option('keep_in_touch_header_image_custom_path');316 if (Keep_In_Touch_Options::get_option_header_image_option('') == 'custom_path') 317 { 318 $custom_path = Keep_In_Touch_Options::get_option_header_image_custom_path(''); 318 319 if (Keep_In_Touch_Utils::starts_with('/', $custom_path)) 319 320 return get_home_url(null, $custom_path); -
keep-in-touch/trunk/class-keep-in-touch-schedule.php
r1628720 r1680091 3 3 defined('ABSPATH') or die ('No direct access to this file.'); 4 4 5 include_once(ABSPATH . 'wp-includes/locale.php'); 6 include_once('class-keep-in-touch-utils.php'); 7 include_once('class-keep-in-touch-msg.php'); 5 require_once(ABSPATH . 'wp-includes/locale.php'); 6 require_once('class-keep-in-touch-utils.php'); 7 require_once('class-keep-in-touch-options.php'); 8 require_once('class-keep-in-touch-msg.php'); 8 9 9 10 class Keep_In_Touch_Schedule … … 14 15 self::reschedule_weekly_event(); 15 16 } 16 17 17 18 static function unschedule_events() 18 19 { … … 22 23 23 24 static function handle_daily_event() 24 { 25 { 25 26 Keep_In_Touch_Msg::send_daily_digest(); 26 self::reschedule_daily_event();27 //self::reschedule_daily_event(); 27 28 } 28 29 … … 33 34 } 34 35 36 static function add_my_schedules($schedules) 37 { 38 $schedules['every_minute'] = array( 39 'interval' => MINUTE_IN_SECONDS, 40 'display' => __('Every minute') 41 ); 42 $schedules['weekly'] = array( 43 'interval' => 7 * DAY_IN_SECONDS, 44 'display' => __('Weekly') 45 ); 46 return $schedules; 47 } 48 35 49 static private function reschedule_over_one_minute($hook) 36 50 { 37 51 wp_schedule_single_event( 38 strtotime('today ' . date('H:i', time() + get_option('gmt_offset') * 3600 + 1 * 60) . ' ' . Keep_In_Touch_Utils::format_time_offset(get_option('gmt_offset') * 3600)), 52 strtotime('today ' . date('H:i', time() + get_option('gmt_offset') * 3600 + 1 * 60) . ' ' . Keep_In_Touch_Utils::format_time_offset(get_option('gmt_offset') * 3600)), 39 53 $hook 40 54 ); … … 44 58 { 45 59 wp_clear_scheduled_hook('keep_in_touch_daily_event_hook'); 46 47 $t0 = get_option('keep_in_touch_delivery_time') . ' ' . Keep_In_Touch_Utils::format_time_offset(get_option('gmt_offset') * 3600); 48 $t1 = strtotime('today ' . $t0); 49 $t2 = strtotime('tomorrow ' . $t0); 50 $t = ($t1 > floor(time() / 60) * 60) ? $t1 : $t2; 51 52 wp_schedule_single_event($t, 'keep_in_touch_daily_event_hook'); 53 //self::reschedule_over_one_minute('keep_in_touch_daily_event_hook'); 60 $t = strtotime(Keep_In_Touch_Options::get_option_delivery_time(0, 0)); 61 wp_schedule_event(($t < time()) ? $t + DAY_IN_SECONDS : $t, 'daily', 'keep_in_touch_daily_event_hook'); 54 62 } 55 63 56 64 static function reschedule_weekly_event() 57 65 { 58 66 wp_clear_scheduled_hook('keep_in_touch_weekly_event_hook'); 59 60 $t0 = get_option('keep_in_touch_delivery_time') . ' ' . Keep_In_Touch_Utils::format_time_offset(get_option('gmt_offset') * 3600);61 $t1 = strtotime( 'sunday ' .$t0);62 $t2 = strtotime('next sunday' . $t0);67 //$t0 = Keep_In_Touch_Options::get_option_delivery_time(0, 0) . ' ' . Keep_In_Touch_Utils::format_time_offset(get_option('gmt_offset') * 3600); 68 $t0 = Keep_In_Touch_Options::convert_option_weekday_to_weekday_name(Keep_In_Touch_Options::get_option_delivery_weekday(0)) . ' ' . Keep_In_Touch_Options::get_option_delivery_time(0, 0); 69 $t1 = strtotime($t0); 70 $t2 = strtotime('next ' . $t0); 63 71 $t = ($t1 > floor(time() / 60) * 60) ? $t1 : $t2; 64 65 wp_schedule_single_event($t, 'keep_in_touch_weekly_event_hook'); 66 //self::reschedule_over_one_minute('keep_in_touch_weekly_event_hook'); 72 73 wp_schedule_event($t2, 'weekly', 'keep_in_touch_weekly_event_hook'); 74 } 75 76 static function init() 77 { 78 add_action( 'keep_in_touch_daily_event_hook', array( 'Keep_In_Touch_Schedule', 'handle_daily_event' ) ); 79 add_action( 'keep_in_touch_weekly_event_hook', array( 'Keep_In_Touch_Schedule', 'handle_weekly_event' ) ); 80 add_filter( 'cron_schedules', array('Keep_In_Touch_Schedule', 'add_my_schedules' ) ); 67 81 } 68 82 } -
keep-in-touch/trunk/class-keep-in-touch-settings.php
r1644792 r1680091 3 3 defined('ABSPATH') or die ('No direct access to this file.'); 4 4 5 include_once(ABSPATH . 'wp-includes/locale.php'); 6 include_once('class-keep-in-touch-utils.php'); 7 include_once('class-keep-in-touch-msg.php'); 5 require_once(ABSPATH . 'wp-includes/locale.php'); 6 require_once('class-keep-in-touch-utils.php'); 7 require_once('class-keep-in-touch-options.php'); 8 require_once('class-keep-in-touch-msg.php'); 8 9 9 10 class Keep_In_Touch_Settings … … 22 23 if ($_POST['form'] == 'keep_in_touch_subscription_settings') 23 24 { 24 update_option('keep_in_touch_use_full_name', Keep_In_Touch_Utils::options_bool($_POST['use_full_name']));25 update_option('keep_in_touch_subscription_confirmation_text', stripslashes(trim($_POST['subscription_confirmation_text'])));26 update_option('keep_in_touch_send_empty_digest_message', Keep_In_Touch_Utils::options_bool($_POST['send_empty_digest_message']));27 update_option('keep_in_touch_empty_digest_message_text', stripslashes(trim($_POST['empty_digest_message_text'])));25 Keep_In_Touch_Options::update_option_use_full_name($_POST['use_full_name']); 26 Keep_In_Touch_Options::update_option_subscription_confirmation_text($_POST['subscription_confirmation_text']); 27 Keep_In_Touch_Options::update_option_send_empty_digest_message($_POST['send_empty_digest_message']); 28 Keep_In_Touch_Options::update_option_empty_digest_message_text($_POST['empty_digest_message_text']); 28 29 } 29 30 else if ($_POST['form'] == 'keep_in_touch_digest_delivery_settings') 30 31 { 31 update_option('keep_in_touch_delivery_weekday',$_POST['delivery_weekday']);32 update_option('keep_in_touch_delivery_time', Keep_In_Touch_Utils::format_time($_POST['delivery_hour'] * 3600 + $_POST['delivery_minute'] * 60));32 Keep_In_Touch_Options::update_option_delivery_weekday($_POST['delivery_weekday']); 33 Keep_In_Touch_Options::update_option_delivery_time($_POST['delivery_hour'], $_POST['delivery_minute']); 33 34 Keep_In_Touch_Schedule::reschedule_daily_event(); 34 35 Keep_In_Touch_Schedule::reschedule_weekly_event(); 35 update_option('keep_in_touch_header_image_option', $_POST['header_image_option']);36 update_option('keep_in_touch_header_image_custom_path', trim($_POST['header_image_custom_path']));36 Keep_In_Touch_Options::update_option_header_image_option($value); 37 Keep_In_Touch_Options::update_option_header_image_custom_path($_POST['header_image_custom_path']); 37 38 } 38 39 else if ($_POST['form'] == 'keep_in_touch_send_digest_now' and isset($_POST['send_daily_digest'])) … … 60 61 <h3 class="hndle"><?php echo __('Subscription settings', 'keep-in-touch'); ?></h3> 61 62 <div class="inside"> 62 <?php $checked = Keep_In_Touch_Utils::checkbox_state( get_option('keep_in_touch_use_full_name')); ?>63 <?php $checked = Keep_In_Touch_Utils::checkbox_state(Keep_In_Touch_Options::get_option_use_full_name(false)); ?> 63 64 <form method="POST" action="<?php echo admin_url('options-general.php?page=keep-in-touch'); ?>"> 64 65 <input type="hidden" name="form" value="keep_in_touch_subscription_settings" /> 65 66 <table class="form-table"> 66 67 <tr> 67 <th scope="row"><?php echo __('Request full name', 'keep-in-touch'); ?> /></th>68 <th scope="row"><?php echo __('Request full name', 'keep-in-touch'); ?></th> 68 69 <td><input type="checkbox" name="use_full_name" value="yes" <?php echo $checked; ?>/></td> 69 70 </tr> 70 71 <tr> 71 72 <th scope="row"><?php echo __('Successful subscription message', 'keep-in-touch'); ?></th> 72 <td><textarea type="text" name="subscription_confirmation_text" style="height:8em"><?php echo get_option('keep_in_touch_subscription_confirmation_text'); ?></textarea></td>73 </tr> 74 <?php $checked = Keep_In_Touch_Utils::checkbox_state( get_option('keep_in_touch_send_empty_digest_message')); ?>73 <td><textarea type="text" name="subscription_confirmation_text" style="height:8em"><?php echo Keep_In_Touch_Options::get_option_subscription_confirmation_text(''); ?></textarea></td> 74 </tr> 75 <?php $checked = Keep_In_Touch_Utils::checkbox_state(Keep_In_Touch_Options::get_option_send_empty_digest_message(false)); ?> 75 76 <tr> 76 77 <th scope="row"><?php echo __('Send empty digest message', 'keep-in-touch'); ?></th> … … 79 80 <tr> 80 81 <th scope="row"><?php echo __('Empty digest message', 'keep-in-touch'); ?></th> 81 <td><textarea type="text" name="empty_digest_message_text" style="height:8em"><?php echo get_option('keep_in_touch_empty_digest_message_text'); ?></textarea></td>82 <td><textarea type="text" name="empty_digest_message_text" style="height:8em"><?php echo Keep_In_Touch_Options::get_option_empty_digest_message_text(''); ?></textarea></td> 82 83 </tr> 83 84 <tr> … … 97 98 for ($wdi = 0; $wdi < 7; $wdi++) 98 99 { 99 $selected = (($wdi ==get_option('keep_in_touch_delivery_weekday'))?'selected="selected" ':'');100 $selected = (($wdi == Keep_In_Touch_Options::get_option_delivery_weekday(0)) ? 'selected="selected" ' : ''); 100 101 echo '<option ' . $selected . 'value="' . $wdi . '">' . $wp_locale->get_weekday($wdi) . '</option>'; 101 102 } … … 105 106 { 106 107 for ($h = 0; $h < 24; $h++) 107 echo '<option ' . (($h==self::get_hour( get_option('keep_in_touch_delivery_time')))?'selected="selected" ':'') . 'value="' . sprintf('%02d', $h) . '">' . sprintf('%02d', $h) . '</option>';108 echo '<option ' . (($h==self::get_hour(Keep_In_Touch_Options::get_option_delivery_time(0, 0))) ? 'selected="selected" ' : '') . 'value="' . sprintf('%02d', $h) . '">' . sprintf('%02d', $h) . '</option>'; 108 109 } 109 110 … … 112 113 foreach (array(0, 15, 30, 45) as $m) 113 114 { 114 $selected = (($m==self::get_minute( get_option('keep_in_touch_delivery_time')))?'selected="selected" ':'');115 $selected = (($m==self::get_minute(Keep_In_Touch_Options::get_option_delivery_time(0, 0))) ? 'selected="selected" ' : ''); 115 116 $value = sprintf('%02d', $m); 116 117 echo '<option ' . $selected . 'value="' . $value . '">' . $value . '</option>'; … … 156 157 <td> 157 158 <select name="header_image_option"> 158 <option value="get_header_image" <?php echo (( get_option('keep_in_touch_header_image_option') == 'get_header_image') ? 'selected="selected"' : ''); ?>><?php echo __('Use get_header_image()', 'keep-in-touch'); ?></option>159 <option value="custom_path" <?php echo (( get_option('keep_in_touch_header_image_option') == 'custom_path') ? 'selected="selected"' : ''); ?>><?php echo __('Use custom path', 'keep-in-touch'); ?></option>159 <option value="get_header_image" <?php echo ((Keep_In_Touch_Options::get_option_header_image_option('') == 'get_header_image') ? 'selected="selected"' : ''); ?>><?php echo __('Use get_header_image()', 'keep-in-touch'); ?></option> 160 <option value="custom_path" <?php echo ((Keep_In_Touch_Options::get_option_header_image_option('') == 'custom_path') ? 'selected="selected"' : ''); ?>><?php echo __('Use custom path', 'keep-in-touch'); ?></option> 160 161 </select> 161 <input type="text" name="header_image_custom_path" placeholder="<?php echo __('Enter custom path to header image', 'keep-in-touch'); ?>" size="80" value="<?php echo get_option('keep_in_touch_header_image_custom_path'); ?>"/>162 <input type="text" name="header_image_custom_path" placeholder="<?php echo __('Enter custom path to header image', 'keep-in-touch'); ?>" size="80" value="<?php echo Keep_In_Touch_Options::get_option_header_image_custom_path(''); ?>"/> 162 163 </td> 163 164 </tr> … … 259 260 static private function generate_subscribers_list() 260 261 { 261 $use_full_name = (get_option('keep_in_touch_use_full_name', 'no') == 'yes');262 $use_full_name = Keep_In_Touch_Options::get_option_use_full_name(false); 262 263 $subscribers = Keep_In_Touch_Db::get_all_confirmed_subscribers(); 263 264 echo '<div class="postbox">'; -
keep-in-touch/trunk/class-keep-in-touch-utils.php
r1638717 r1680091 1 1 <?php 2 3 defined('ABSPATH') or die ('No direct access to this file.');4 2 5 3 class Keep_In_Touch_Utils … … 141 139 } 142 140 143 static function bool($option)144 {145 if ((bool)$option and ($option == 'no')) return false;146 return (bool)$option;147 }148 149 static function options_bool($option)150 {151 return (self::bool($option) ? 'yes' : 'no');152 }153 154 141 static function checkbox_state($option) 155 142 { 156 return ( self::bool($option)? 'checked="yes"' : '');143 return ($option ? 'checked="yes"' : ''); 157 144 } 158 145 -
keep-in-touch/trunk/class-keep-in-touch-widget.php
r1644786 r1680091 3 3 defined('ABSPATH') or die ('No direct access to this file.'); 4 4 5 include_once('class-keep-in-touch-utils.php');5 require_once('class-keep-in-touch-utils.php'); 6 6 7 7 class Keep_In_Touch_Widget extends WP_Widget -
keep-in-touch/trunk/keep-in-touch.php
r1644786 r1680091 19 19 //define('WP_DEBUG_LOG', true); 20 20 21 include_once(ABSPATH . 'wp-includes/locale.php'); 22 include_once('class-keep-in-touch-utils.php'); 23 include_once('class-keep-in-touch-db.php'); 24 include_once('class-keep-in-touch-msg.php'); 25 include_once('class-keep-in-touch-settings.php'); 26 include_once('class-keep-in-touch-schedule.php'); 27 include_once('class-keep-in-touch-widget.php'); 21 require_once(ABSPATH . 'wp-includes/locale.php'); 22 require_once('class-keep-in-touch-utils.php'); 23 require_once('class-keep-in-touch-options.php'); 24 require_once('class-keep-in-touch-db.php'); 25 require_once('class-keep-in-touch-msg.php'); 26 require_once('class-keep-in-touch-settings.php'); 27 require_once('class-keep-in-touch-schedule.php'); 28 require_once('class-keep-in-touch-widget.php'); 28 29 29 30 … … 32 33 static private function set_initial_options() 33 34 { 34 if ( !get_option('keep_in_touch_use_full_name'))35 update_option('keep_in_touch_use_full_name', Keep_In_Touch_Db::db_bool(true));36 if ( !get_option('keep_in_touch_subscription_confirmation_text'))37 update_option('keep_in_touch_subscription_confirmation_text',__(35 if (Keep_In_Touch_Options::get_option_use_full_name() == null) 36 Keep_In_Touch_Options::update_option_use_full_name(true); 37 if (Keep_In_Touch_Options::get_option_subscription_confirmation_text() == null) 38 Keep_In_Touch_Options::update_option_subscription_confirmation_text(__( 38 39 'Your subscription is now confirmed. You will be receiving updates from us. Welcome and enjoy!', 'keep-in-touch')); 39 if ( !get_option('keep_in_touch_send_empty_digest_message'))40 update_option('keep_in_touch_send_empty_digest_message', Keep_In_Touch_Db::db_bool(true));41 if ( !get_option('keep_in_touch_empty_digest_message_text'))42 update_option('keep_in_touch_empty_digest_message_text',__(40 if (Keep_In_Touch_Options::get_option_send_empty_digest_message() == null) 41 Keep_In_Touch_Options::update_option_send_empty_digest_message(true); 42 if (Keep_In_Touch_Options::get_option_empty_digest_message_text() == null) 43 Keep_In_Touch_Options::update_option_empty_digest_message_text(__( 43 44 "As it seems, we haven't been very active lately.\n\n" . 44 45 "There are no new posts.\n\n" . … … 160 161 load_plugin_textdomain('keep-in-touch', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); 161 162 self::set_initial_options(); 163 164 Keep_In_Touch_Schedule::init(); 165 162 166 if (self::is_virtual_page()) 163 167 self::handle_virtual_page(); … … 183 187 add_action( 'admin_enqueue_scripts', array( 'Keep_In_Touch', 'load_css' ) ); 184 188 add_action( 'admin_menu', array( 'Keep_In_Touch', 'plugin_menu' ) ); 185 add_action( 'keep_in_touch_daily_event_hook', array( 'Keep_In_Touch_Schedule', 'handle_daily_event' ) );186 add_action( 'keep_in_touch_weekly_event_hook', array( 'Keep_In_Touch_Schedule', 'handle_weekly_event' ) );187 189 188 190 //How-to:
Note: See TracChangeset
for help on using the changeset viewer.