Changeset 525874
- Timestamp:
- 04/01/2012 08:25:49 PM (14 years ago)
- Location:
- tm-lunch-menu/trunk
- Files:
-
- 1 added
- 4 edited
-
inc/meta-boxes/admin-settings.php (modified) (3 diffs)
-
inc/meta-boxes/widget-options.php (modified) (2 diffs)
-
index.php (modified) (12 diffs)
-
readme.txt (modified) (3 diffs)
-
screenshot-1.png (added)
Legend:
- Unmodified
- Added
- Removed
-
tm-lunch-menu/trunk/inc/meta-boxes/admin-settings.php
r470619 r525874 11 11 $settings['no_menu_msg'] = esc_attr($_POST['msg']); 12 12 $settings['weeks'] = esc_attr($_POST['weeks']); 13 $settings['format'] = esc_attr($_POST['date-format']); 13 14 $save_data = esc_attr($_POST['tm_lunch_menu_save_data']); 14 15 update_option('tm_lunch_menu_settings', $settings); … … 21 22 } 22 23 24 if(!is_array($settings['days'])) 25 $settings['days'] = array(1,2,3,4,5); 26 23 27 // Shortcut variables 24 28 $selected = ' selected="selected"'; 25 29 $checked = ' checked="checked"'; 30 31 global $tm_lunch_menu_days, $tm_lunch_menu_months; 26 32 ?> 27 <div class="wrap"><h2> Lunch Menu Settings</h2>33 <div class="wrap"><h2><?php _e('Lunch Menu Settings', 'tm-lunch-menu'); ?></h2> 28 34 <form action="" method="post"> 29 <p><label> Days to include in menus:</label><br>30 <input type="checkbox" value="0" name="days[]"<?php if(is_array($settings['days']) && in_array(0, $settings['days'])) echo $checked; ?> /> Sunday<br> 31 <input type="checkbox" value="1" name="days[]"<?php if(is_array($settings['days']) && in_array(1, $settings['days'])) echo $checked; ?> /> Monday<br>32 <input type="checkbox" value="2" name="days[]"<?php if(is_array($settings['days']) && in_array(2, $settings['days'])) echo $checked; ?> /> Tuesday<br>33 <input type="checkbox" value="3" name="days[]"<?php if(is_array($settings['days']) && in_array(3, $settings['days'])) echo $checked; ?> /> Wednesday<br>34 <input type="checkbox" value="4" name="days[]"<?php if(is_array($settings['days']) && in_array(4, $settings['days'])) echo $checked; ?> /> Thursday<br>35 <input type="checkbox" value="5" name="days[]"<?php if(is_array($settings['days']) && in_array(5, $settings['days'])) echo $checked; ?> /> Friday<br>36 <input type="checkbox" value="6" name="days[]"<?php if(is_array($settings['days']) && in_array(6, $settings['days'])) echo $checked; ?> /> Saturday</p>37 <p><label >Action to take when there is no current menu:</label><br>38 <select name="action" >39 <option value="hide"<?php if(isset($settings['no_menu']) && $settings['no_menu'] == 'hide') echo $selected; ?>> Hide widget</option>40 <option value="display"<?php if(isset($settings['no_menu']) && $settings['no_menu'] == 'display') echo $selected; ?>> Display custom message (see below)</option>35 <p><label><?php _e('Days to include in menus', 'tm-lunch-menu'); ?>:</label><br> 36 <?php 37 foreach($tm_lunch_menu_days as $key=>$day) { 38 echo '<input type="checkbox" value="'.$key.'" name="days[]" id="days-'.$key.'"'; 39 echo (in_array($key, $settings['days']))?' '.$checked:''; 40 echo ' /> <label for="days-'.$key.'">'.$day.'</label><br/>'; 41 } 42 ?> 43 <p><label for="tm-action"><?php _e('Action to take when there is no current menu', 'tm-lunch-menu'); ?>:</label><br> 44 <select name="action" id="tm-action"> 45 <option value="hide"<?php if(isset($settings['no_menu']) && $settings['no_menu'] == 'hide') echo $selected; ?>><?php _e('Hide widget', 'tm-lunch-menu'); ?></option> 46 <option value="display"<?php if(isset($settings['no_menu']) && $settings['no_menu'] == 'display') echo $selected; ?>><?php _e('Display custom message (see below)', 'tm-lunch-menu'); ?></option> 41 47 </select> 42 48 </p> 43 <p><label >Custom display message:</label> <input type="text" name="msg" value="<?php if(isset($settings['no_menu_msg'])) echo stripslashes($settings['no_menu_msg']); ?>" /></p>44 <p><label >Maximum number of weeks into the future to pull menus from:</label>45 <select name="weeks" >49 <p><label for="tm-msg"><?php _e('Custom display message', 'tm-lunch-menu'); ?>:</label> <input type="text" name="msg" id="tm-msg" value="<?php if(isset($settings['no_menu_msg'])) echo stripslashes($settings['no_menu_msg']); ?>" /></p> 50 <p><label for="tm-weeks"><?php _e('Maximum number of weeks into the future to pull menus from', 'tm-lunch-menu'); ?>:</label> 51 <select name="weeks" id="tm-weeks"> 46 52 <?php 47 53 $x = 0; $y = 10; … … 52 58 echo '>'.$x.'</option>'; 53 59 } ?> 54 </select> weeks60 </select> <?php _e('weeks', 'tm-lunch-menu'); ?> 55 61 </p> 56 62 57 63 <p> 58 <input type="checkbox" name="tm_lunch_menu_save_data" value="delete"<?php if($save_data == 'delete') echo $checked; ?> /> <label>Delete all data when plugin is deactivated</label> 64 <label for="date-format"><?php _e('Date display format', 'tm-lunch-menu'); ?>:</label> 65 <select name="date-format" id="date-format"> 66 <?php 67 $formats = array( 68 '%D, %M %d', 69 '%D, %F %d', 70 '%l, %M %d', 71 '%l, %F %d', 72 '%F %d, %l', 73 '%F %d, %D', 74 '%M %d, %l', 75 '%M %d, %D', 76 '%M %d', 77 '%F %d', 78 '%D, %d', 79 '%l, %d', 80 '%D', 81 '%l', 82 ); 83 foreach($formats as $format) { 84 $tmp = str_replace('%F', $tm_lunch_menu_months[1], $format); 85 $tmp = str_replace('%M', substr($tm_lunch_menu_months[1], 0, 3), $tmp); 86 $tmp = str_replace('%l', $tm_lunch_menu_days[1], $tmp); 87 $tmp = str_replace('%D', substr($tm_lunch_menu_days[1], 0, 3), $tmp); 88 $tmp = str_replace('%d', '21', $tmp); 89 echo '<option value="'.$format.'"'; 90 echo ($format == $settings['format'])?' '.$selected:''; 91 echo '>'.$tmp.'</option>'; 92 } 93 ?> 94 </select> 95 </p> 96 97 <p> 98 <input type="checkbox" name="tm_lunch_menu_save_data" id="tm_lunch_menu_save_data" value="delete"<?php if($save_data == 'delete') echo $checked; ?> /> 99 <label for="tm_lunch_menu_save_data"><?php _e('Delete all data when plugin is deactivated', 'tm-lunch-menu'); ?></label> 59 100 </p> 60 101 61 <p><input type="submit" class="button-primary" name="tm_settings_update" value=" Update Settings" />62 <input type="submit" class="button-primary" name="tm_settings_reset" value=" Reset to defaults" /></p>102 <p><input type="submit" class="button-primary" name="tm_settings_update" value="<?php _e('Update Settings', 'tm-lunch-menu'); ?>" /> 103 <input type="submit" class="button-primary" name="tm_settings_reset" value="<?php _e('Reset to defaults', 'tm-lunch-menu'); ?>" /></p> 63 104 </form> 64 105 </div> -
tm-lunch-menu/trunk/inc/meta-boxes/widget-options.php
r470619 r525874 6 6 ?> 7 7 <p> 8 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>9 <input id="<?php echo $this->get_field_id('title'); ?>"8 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'tm-lunch-menu'); ?>:</label> 9 <input id="<?php echo $this->get_field_id('title'); ?>" 10 10 name="<?php echo $this->get_field_name('title'); ?>" 11 11 type="text" 12 value="<?php echo $instance['title']; ?>" /> </label>12 value="<?php echo $instance['title']; ?>" /> 13 13 </p> 14 14 <p> 15 <label for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Max number of menus to show at one time:'); ?><br />16 <select id="<?php echo $this->get_field_id('numberposts'); ?>"15 <label for="<?php echo $this->get_field_id('numberposts'); ?>"><?php _e('Max number of menus to show at one time', 'tm-lunch-menu'); ?>:</label><br /> 16 <select id="<?php echo $this->get_field_id('numberposts'); ?>" 17 17 name="<?php echo $this->get_field_name('numberposts'); ?>"> 18 18 <?php … … 25 25 } 26 26 ?> 27 </select> </label>27 </select> 28 28 </p> 29 29 <p> 30 <label for="<?php echo $this->get_field_id('show_partial'); ?>"><?php _e('Remove individual menu items after their date has passed?'); ?><br />31 <select id="<?php echo $this->get_field_id('show_partial'); ?>"30 <label for="<?php echo $this->get_field_id('show_partial'); ?>"><?php _e('Remove individual menu items after their date has passed?', 'tm-lunch-menu'); ?></label><br /> 31 <select id="<?php echo $this->get_field_id('show_partial'); ?>" 32 32 name="<?php echo $this->get_field_name('show_partial'); ?>"> 33 <option value="0" <?php if($instance['show_partial'] == 0) echo $selected; ?>> No</option>34 <option value="1" <?php if($instance['show_partial'] == 1) echo $selected; ?>> Yes</option>35 </select> </label>33 <option value="0" <?php if($instance['show_partial'] == 0) echo $selected; ?>><?php _e('No', 'tm-lunch-menu'); ?></option> 34 <option value="1" <?php if($instance['show_partial'] == 1) echo $selected; ?>><?php _e('Yes', 'tm-lunch-menu'); ?></option> 35 </select> 36 36 </p> -
tm-lunch-menu/trunk/index.php
r470762 r525874 4 4 Plugin URI: 5 5 Description: Designed for easy display, editing, & scheduling of lunch menus or other similar lists, TM Lunch Menu uses a custom widget to display your menu on any page of your site. This plugin allows you to easily add a daily menu by simply filling in the meal for any day (and any number of days) of the week, set a menu start date and hit publish. Once published it will automatically show up in the custom "Lunch Menu" widget when its time comes. After a menu (or menu item) has expired it will automatically remove itself from the widget display. An integrated calendar style date-picker makes it even easier to select your menu's start date and the date is always shown next to every menu item so there is no confusion about what day the menu is for. NOTE: If you find something that does not work, please post in the WordPress.org forums and tag it with "tm-lunch-menu" so I can fix it! 6 Version: 1.0. 16 Version: 1.0.2 7 7 Author: David Wood 8 Author URI: http://iamdavidwood.com 8 Author URI: http://technicalmastermind.com/about-david-wood/ 9 Text Domain: tm-lunch-menu 9 10 ============================================================================================================ 10 11 This software is provided "as is" and any express or implied warranties, including, but not limited to, the … … 29 30 require(TM_LM_PATH . '/inc/meta_box.php'); // Custom meta box registration class 30 31 32 global $tm_lunch_menu_days, $tm_lunch_menu_months; 33 $tm_lunch_menu_days = array( 34 __('Sunday', 'tm-lunch-menu'), 35 __('Monday', 'tm-lunch-menu'), 36 __('Tuesday', 'tm-lunch-menu'), 37 __('Wednesday', 'tm-lunch-menu'), 38 __('Thursday', 'tm-lunch-menu'), 39 __('Friday', 'tm-lunch-menu'), 40 __('Saturday', 'tm-lunch-menu'), 41 ); 42 $tm_lunch_menu_months = array( 43 '', 44 __('January', 'tm-lunch-menu'), 45 __('February', 'tm-lunch-menu'), 46 __('March', 'tm-lunch-menu'), 47 __('April', 'tm-lunch-menu'), 48 __('May', 'tm-lunch-menu'), 49 __('June', 'tm-lunch-menu'), 50 __('July', 'tm-lunch-menu'), 51 __('August', 'tm-lunch-menu'), 52 __('September', 'tm-lunch-menu'), 53 __('October', 'tm-lunch-menu'), 54 __('November', 'tm-lunch-menu'), 55 __('December', 'tm-lunch-menu'), 56 ); 57 58 31 59 if(!class_exists('tm_lunch_menu')): 32 60 class tm_lunch_menu { 33 private $version = '1.0 ',61 private $version = '1.0.2', 34 62 $default_settings = array( 35 63 'days' => array(1,2,3,4,5), // Stored as numbers … … 66 94 } 67 95 68 function admin_enqueue_scripts(){ 69 wp_register_script('jquery-datepicker', plugins_url('/js/jquery.ui.datepicker.min.js', TM_LM_FILE), array('jquery-ui-core'), $this->version); 70 wp_enqueue_script('tm-date-time', plugins_url('/js/date-time.js', TM_LM_FILE), array('jquery-datepicker'), $this->version); 71 wp_enqueue_script('tm-lunchmenu-save', plugins_url('/js/tm_lunch_menusave.js', TM_LM_FILE), array('tm-date-time'), $this->version); 72 wp_localize_script('tm-date-time', 'tmDateTime', array('pluginURL' => TM_LM_URL)); 96 function admin_enqueue_scripts($hook){ 97 if($hook == 'post.php' || ($hook == 'post-new.php' && $_REQUEST['post_type'] == 'tm_lunch_menu')) { 98 wp_register_script('jquery-datepicker', plugins_url('/js/jquery.ui.datepicker.min.js', TM_LM_FILE), array('jquery-ui-core'), $this->version); 99 wp_enqueue_script('tm-date-time', plugins_url('/js/date-time.js', TM_LM_FILE), array('jquery-datepicker'), $this->version); 100 wp_enqueue_script('tm-lunchmenu-save', plugins_url('/js/tm_lunch_menusave.js', TM_LM_FILE), array('tm-date-time'), $this->version); 101 wp_localize_script('tm-date-time', 'tmDateTime', array('pluginURL' => TM_LM_URL)); 102 } 73 103 } 74 104 … … 78 108 79 109 function add_admin_page() { 80 $this->tm_help = add_submenu_page('edit.php?post_type=tm_lunch_menu', 'Lunch Menu Settings', 'Settings', 'manage_options', 'tm_lunch_menu_settings', array($this, 'admin_settings'));110 $this->tm_help = add_submenu_page('edit.php?post_type=tm_lunch_menu', __('Lunch Menu Settings', 'tm-lunch-menu'), __('Settings', 'tm-lunch-menu'), 'manage_options', 'tm_lunch_menu_settings', array($this, 'admin_settings')); 81 111 } 82 112 83 113 function admin_settings() { 84 114 if(!current_user_can('manage_options')) 85 wp_die( 'You do not have permission to view this page!');115 wp_die(__('You do not have permission to view this page!', 'tm-lunch-menu')); 86 116 // Page and functionality 87 117 require(TM_LM_PATH.'/inc/meta-boxes/admin-settings.php'); … … 92 122 // Add Lunch Menu post type 93 123 new wordpress_custom_post_type('tm_lunch_menu', array( 94 'singular' => __('Lunch Menu', ' lunch-menu'),95 'plural' => __('Lunch Menus', ' lunch-menu'),96 'textdomain' => ' lunch-menu',124 'singular' => __('Lunch Menu', 'tm-lunch-menu'), 125 'plural' => __('Lunch Menus', 'tm-lunch-menu'), 126 'textdomain' => 'tm-lunch-menu', 97 127 'args' => array( 98 128 'labels' => array( 99 'name' => __('Lunch Menus', ' lunch-menu'),100 'singular_name' => __('Lunch Menu', ' lunch-menu'),101 'add_new' => __('Add Lunch Menu', ' lunch-menu'),102 'add_new_item' => __('Add New Lunch Menu', ' lunch-menu'),103 'edit_item' => __('Edit Lunch Menu', ' lunch-menu'),104 'new_item' => __('New Lunch Menu', ' lunch-menu'),105 'view_item' => __('View Lunch Menu', ' lunch-menu'),106 'search_items' => __('Search Lunch Menus', ' lunch-menu'),107 'not_found' => __('No lunch menus found', ' lunch-menu'),108 'not_found_in_trash' => __('No lunch menus found in trash', ' lunch-menu')129 'name' => __('Lunch Menus', 'tm-lunch-menu'), 130 'singular_name' => __('Lunch Menu', 'tm-lunch-menu'), 131 'add_new' => __('Add Lunch Menu', 'tm-lunch-menu'), 132 'add_new_item' => __('Add New Lunch Menu', 'tm-lunch-menu'), 133 'edit_item' => __('Edit Lunch Menu', 'tm-lunch-menu'), 134 'new_item' => __('New Lunch Menu', 'tm-lunch-menu'), 135 'view_item' => __('View Lunch Menu', 'tm-lunch-menu'), 136 'search_items' => __('Search Lunch Menus', 'tm-lunch-menu'), 137 'not_found' => __('No lunch menus found', 'tm-lunch-menu'), 138 'not_found_in_trash' => __('No lunch menus found in trash', 'tm-lunch-menu') 109 139 ), 110 140 'supports' => array(''), 111 141 'public' => false, 112 142 'show_ui' => true, 113 /*'capability_type' => 's8_opportunity',114 'capabilities' => array(115 'edit_post' => 'edit_s8_opportunity',116 'edit_posts' => 'edit_s8_opportunities',117 'edit_published_posts' => 'edit_published_s8_opportunities',118 'edit_others_posts' => 'edit_others_s8_opportunities',119 'publish_posts' => 'publish_s8_opportunities',120 'read_post' => 'read_s8_opportunity',121 'read_private_posts' => 'read_private_s8_opportunities',122 'delete_post' => 'delete_s8_opportunity',123 'delete_posts' => 'delete_s8_opportunities',124 'delete_published_posts' => 'delete_published_s8_opportunities',125 'delete_others_posts' => 'delete_others_s8_opportunities'126 ),127 'map_meta_cap' => true*/128 143 ) 129 144 ) ); … … 135 150 new wordpress_meta_box( 136 151 $id = 'tm_lunch_menu_meta_box', 137 $title = 'Menu Details',152 $title = __('Menu Details', 'tm-lunch-menu'), 138 153 $content_path = TM_LM_PATH . '/inc/meta-boxes/lunch-details.php', $args = array('data' => array('_tm_lunch_date', '_tm_lunch_menu_day'), 139 154 'post_type' => 'tm_lunch_menu', … … 163 178 if($key == 'title'){ 164 179 $tmp[$key] = $column; 165 $tmp['tm_menu_start'] = 'Menu Start Date';180 $tmp['tm_menu_start'] = __('Menu Start Date', 'tm-lunch-menu'); 166 181 } 167 182 elseif($key == 'date') continue; … … 177 192 if( $column_name == 'tm_menu_start' ) { 178 193 $timestamp = get_post_meta($post->ID, '_tm_lunch_timestamp', true); 179 echo (is_numeric($timestamp))? date('m/d/Y', $timestamp): 'An error occurred!';194 echo (is_numeric($timestamp))? date('m/d/Y', $timestamp): __('An error occurred!', 'tm-lunch-menu'); 180 195 } 181 196 } … … 198 213 function update() { 199 214 // Store default settings in the database 200 update_option('tm_lunch_menu_settings', $this->default_settings);201 update_option('tm_lunch_menu_save_data', '');202 215 update_option('tm_lunch_menu_ver', $this->version); 203 216 } … … 228 241 class tm_lunch_menu_widget extends WP_Widget { 229 242 function tm_lunch_menu_widget() { 230 $name = __('Lunch Menu' ); // The widget name as users will see it231 $description = __('Displays current and upcoming menus from the Lunch Menu plugin.' ); // The widget description as users will see it243 $name = __('Lunch Menu', 'tm-lunch-menu'); // The widget name as users will see it 244 $description = __('Displays current and upcoming menus from the Lunch Menu plugin.', 'tm-lunch-menu'); // The widget description as users will see it 232 245 $this->WP_Widget( 233 246 $id_base = false, … … 252 265 function widget($args, $instance) { 253 266 // Setup widget display elements 267 global $tm_lunch_menu_days, $tm_lunch_menu_months; 254 268 $before_widget = $after_widget = $before_title = $after_title = ''; 255 269 extract($args, EXTR_IF_EXISTS); … … 290 304 if((in_array($start_day, $settings['days']) && !empty($items[$start_day]))) 291 305 if(($instance['show_partial'] == 1 && ($today <= ($timestamp + (86400 * $x)))) || $instance['show_partial'] == 0) { 292 echo '<strong>'.date('l, M j', $timestamp + (86400 * $x)).'</strong><br />'; 306 if(!$settings['format']) $settings['format'] = '%l, %M %d'; 307 $week_day = date('w', $timestamp + (86400 * $x)); 308 $month = date('n', $timestamp + (86400 * $x)); 309 $day = date('j', $timestamp + (86400 * $x)); 310 $tmp = str_replace('%F', $tm_lunch_menu_months[$month], $settings['format']); 311 $tmp = str_replace('%M', substr($tm_lunch_menu_months[$month], 0, 3), $tmp); 312 $tmp = str_replace('%l', $tm_lunch_menu_days[$week_day], $tmp); 313 $tmp = str_replace('%D', substr($tm_lunch_menu_days[$week_day], 0, 3), $tmp); 314 $tmp = str_replace('%d', $day, $tmp); 315 echo '<strong>'.$tmp.'</strong><br />'; 293 316 echo $items[$start_day].'<br/>'; 294 317 } -
tm-lunch-menu/trunk/readme.txt
r470762 r525874 4 4 Plugin URI: http://technicalmastermind.com/plugins/tm-lunch-menu/ 5 5 Tags: lunch menu, lunch, menu, technical mastermind, tm, daily menu, daily meal, daily list 6 Author URI: http:// iamdavidwood.com/6 Author URI: http://technicalmastermind.com/about-david-wood/ 7 7 Author: David Wood 8 8 Donate link: http://technicalmastermind.com/donate/ 9 9 Requires at least: 3.0 10 Tested up to: 3.3 10 Tested up to: 3.3.1 11 11 Stable tag: 1.0.1 12 Version: 1.0.1 12 13 Allows for easy widgetized display of simple lunch menus (or other day based lists). 13 14 14 15 == Description == 15 16 Designed for easy display, editing, & scheduling of lunch menus or other similar lists, TM Lunch Menu uses a custom widget to display your menu on any page of your site. This plugin allows you to easily add a daily menu by simply filling in the meal for any day (and any number of days) of the week, set a menu start date and hit publish. Once published it will automatically show up in the custom "Lunch Menu" widget when its time comes. After a menu (or menu item) has expired it will automatically remove itself from the widget display. An integrated calendar style date-picker makes it even easier to select your menu's start date and the date is always shown next to every menu item so there is no confusion about what day the menu is for. 16 17 17 If you find something that does not work, please post in the WordPress.org forums and tag it with "tm-lunch-menu" so I can fix it! 18 = A word on support and additional features = 19 While every attempt is made to ensure there are no bugs, if any are found or you would like to request that additional features be added, please let me know! In an effort to help others looking for similar answers and to help build the WordPress.org community I ask that all requests for support and features be made through the [WordPress.org forums](http://wordpress.org/tags/tm-lunch-menu?forum_id=10#postform). 18 20 19 21 == Installation == … … 24 26 25 27 == Upgrade Notice == 28 = 1.0.2 = 29 Internationalized everything and added ability to change date display format. 26 30 = 1.0.1 = 27 31 Fixed show-stopping bug where widget may not display … … 30 34 31 35 == Screenshots == 32 Coming soon! 36 1. An example of a simple menu 33 37 34 38 == Changelog == 39 = 1.0.2 = 40 * Added complete internationalization support 41 * Added option to change the date display format 42 * Other various improvments 35 43 = 1.0.1 = 36 44 * Fixed show-stopping bug where widget may not display
Note: See TracChangeset
for help on using the changeset viewer.