Changeset 577173
- Timestamp:
- 07/25/2012 02:18:51 PM (14 years ago)
- Location:
- wp-infobox/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
wp-infobox.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-infobox/trunk/readme.txt
r252200 r577173 1 1 === WP-Infobox === 2 2 Contributors: windyjonas 3 Donate link: http s://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=jonas%2enordstrom%40gmail%2ecom&lc=SE&item_name=Jonas%20Nordstrom%2c%20Windy%20Media&item_number=wp%2dinfobox¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted3 Donate link: http://flattr.com/thing/700831/plugins 4 4 Tags: infobox, content filter, info box, more info 5 Requires at least: 2.86 Tested up to: 3. 07 Stable tag: 0. 75 Requires at least: 3.0 6 Tested up to: 3.4.1 7 Stable tag: 0.8 8 8 9 9 Add an info box to individual posts … … 19 19 20 20 Use the included css, or put your own wp-infobox.css in your theme directory. 21 22 Requires php5! 21 23 22 24 == Installation == … … 38 40 == Changelog == 39 41 42 = 0.8 = 43 * tested on most recent version of WordPress 44 40 45 = 0.7 = 41 46 * Added possibility to customise css -
wp-infobox/trunk/wp-infobox.php
r252200 r577173 2 2 /* 3 3 Plugin Name: WP-Infobox 4 Plugin URI: http://jonasnordstrom.se/ wordpress-plugins4 Plugin URI: http://jonasnordstrom.se/plugins/wp-infobox/ 5 5 Description: Add an info box to posts. You can add title, ingress, a bullet list and "more text" 6 Version: 0. 76 Version: 0.8 7 7 Author: Jonas Nordstrom 8 8 Author URI: http://jonasnordstrom.se … … 26 26 27 27 28 if ( !class_exists("WPInfobox")) {28 if ( ! class_exists( "WPInfobox" ) ) { 29 29 class WPInfobox { 30 30 … … 32 32 protected $max_items; 33 33 protected $css; 34 protected $on_posts; 35 protected $on_pages; 34 36 35 37 // Constructor 36 38 public function WPInfobox() { 37 // This should really be set as a plugin option. TODO 38 $this->max_items = get_option('wpinfobox_maxitems', '10'); 39 $this->include_css = get_option('wpinfobox_css', 'on'); 39 $this->max_items = get_option( 'wpinfobox_maxitems', '10' ); 40 $this->css = get_option( 'wpinfobox_css', 'on' ); 41 $this->on_posts = get_option( 'wpinfobox_on_posts', 'on' ); 42 $this->on_pages = get_option( 'wpinfobox_on_pages', 'on' ); 40 43 } 41 44 … … 43 46 public function init_wpinfobox() { 44 47 // Set up localization 45 $plugin_dir = basename( dirname(__FILE__));48 $plugin_dir = basename( dirname( __FILE__ ) ); 46 49 load_plugin_textdomain( 'wpinfobox', 'wp-content/plugins/'. $plugin_dir.'/languages', $plugin_dir.'/languages' ); 47 50 } … … 54 57 update_option('wpinfobox_maxitems', $_POST[ 'wpinfobox_maxitems' ]); 55 58 update_option('wpinfobox_css', $_POST[ 'wpinfobox_css' ] ? $_POST[ 'wpinfobox_css' ] : 'off'); 59 update_option('wpinfobox_on_posts', $_POST[ 'wpinfobox_on_posts' ] ? $_POST[ 'wpinfobox_on_posts' ] : 'off'); 60 update_option('wpinfobox_on_pages', $_POST[ 'wpinfobox_on_pages' ] ? $_POST[ 'wpinfobox_on_pages' ] : 'off'); 56 61 ?> 57 62 <div class="updated"><p><strong><?php _e('Settings saved.', 'wpinfobox' ); ?></strong></p></div> … … 74 79 <tr> 75 80 <td><?php _e("Include css", "wpinfobox"); ?></td> 76 <td><input type="checkbox" id="wpinfobox_css" name="wpinfobox_css" <?php echo (get_option( 'wpinfobox_css' ) == 'on' ? 'checked="checked"' : '' ); ?>" /></td> 81 <td> 82 <input type="checkbox" id="wpinfobox_css" name="wpinfobox_css" 83 <?php echo (get_option( 'wpinfobox_css' ) == 'on' ? 'checked="checked"' : '' ); ?> /> 84 </td> 85 </tr> 86 <tr> 87 <td><?php _e("Activate for posts", "wpinfobox"); ?></td> 88 <td> 89 <input type="checkbox" id="wpinfobox_on_posts" name="wpinfobox_on_posts" 90 <?php echo (get_option( 'wpinfobox_on_posts' ) == 'on' ? 'checked="checked"' : '' ); ?> /> 91 </td> 92 </tr> 93 <tr> 94 <td><?php _e("Activate for pages", "wpinfobox"); ?></td> 95 <td> 96 <input type="checkbox" id="wpinfobox_on_pages" name="wpinfobox_on_pages" 97 <?php echo (get_option( 'wpinfobox_on_pages' ) == 'on' ? 'checked="checked"' : '' ); ?> /> 98 </td> 77 99 </tr> 78 100 <tr> … … 91 113 92 114 // A meta box is added to "write post", in main column 93 // TODO: Option to set this for post and/or pages (or other post types)94 115 public function init_admin() { 95 add_meta_box('wp-infobox', __('Info Box', 'wpinfobox'), array(&$this, 'insert_form'), 'post', 'normal'); 116 if (get_option( 'wpinfobox_on_posts' )): 117 add_meta_box('wp-infobox', __('Info Box', 'wpinfobox'), array(&$this, 'insert_form'), 'post', 'normal'); 118 endif; 119 if (get_option( 'wpinfobox_on_pages' )): 120 add_meta_box('wp-infobox', __('Info Box', 'wpinfobox'), array(&$this, 'insert_form'), 'page', 'normal'); 121 endif; 96 122 add_options_page(__('Info Box Settings', "wpinfobox"), __('Info Box Settings', "wpinfobox"), 'administrator', basename(__FILE__), array(&$this, 'wpinfobox_admin_page') ); 97 123 } … … 124 150 </tr> 125 151 <?php 126 for ($i=1; $i <= $this->max_items; $i++) { 127 ?> 152 for ( $i=1; $i <= $this->max_items; $i++ ) { ?> 128 153 <tr valign="top"> 129 154 <td><label for="wpinfobox_item_<?php echo $i?>"><?php echo __("Item", 'wpinfobox') .' '. $i . ':';?></label></td> … … 182 207 $title = get_post_meta($post->ID, 'wpinfobox_title', true); 183 208 184 // Only display info x on single pages209 // Only display infobox on single pages 185 210 // TODO: Set this as an option 186 211 if (is_single() && !empty($title)) { … … 228 253 return; 229 254 230 if ( @file_exists(STYLESHEETPATH . '/wp-infobox.css') ) {255 if ( @file_exists(STYLESHEETPATH . '/wp-infobox.css') ) { 231 256 $css_file = get_stylesheet_directory_uri() . '/wp-infobox.css'; 232 257 } elseif ( @file_exists(TEMPLATEPATH . '/pagenavi-css.css') ) { … … 235 260 $css_file = plugins_url('css/wp-infobox.css', __FILE__); 236 261 } 237 238 wp_register_style( 'wp-infobox-styles', $css_file ); 239 wp_enqueue_style( 'wp-infobox-styles' ); 240 } 262 wp_register_style( 'wp-infobox-styles', $css_file ); 263 wp_enqueue_style( 'wp-infobox-styles' ); 264 } 241 265 } 242 266 } … … 251 275 add_action( 'admin_menu', array(&$wpinfobox, 'init_admin' )); 252 276 add_action( 'save_post', array(&$wpinfobox, 'add_meta_data')); 253 add_action( 'wp_print_styles', array(&$wpinfobox, 'add_style'));277 add_action( 'wp_print_styles', array(&$wpinfobox, 'add_style')); 254 278 add_filter( 'the_content', array (&$wpinfobox, 'content_filter')); 255 279 ?>
Note: See TracChangeset
for help on using the changeset viewer.