Plugin Directory

Changeset 577173


Ignore:
Timestamp:
07/25/2012 02:18:51 PM (14 years ago)
Author:
windyjonas
Message:

Tested with most recent version of WordPress

Location:
wp-infobox/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-infobox/trunk/readme.txt

    r252200 r577173  
    11=== WP-Infobox ===
    22Contributors: windyjonas
    3 Donate link: https://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&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
     3Donate link: http://flattr.com/thing/700831/plugins
    44Tags: infobox, content filter, info box, more info
    5 Requires at least: 2.8
    6 Tested up to: 3.0
    7 Stable tag: 0.7
     5Requires at least: 3.0
     6Tested up to: 3.4.1
     7Stable tag: 0.8
    88 
    99Add an info box to individual posts
     
    1919
    2020Use the included css, or put your own wp-infobox.css in your theme directory.
     21
     22Requires php5!
    2123
    2224== Installation ==
     
    3840== Changelog ==
    3941
     42= 0.8 =
     43* tested on most recent version of WordPress
     44
    4045= 0.7 =
    4146* Added possibility to customise css
  • wp-infobox/trunk/wp-infobox.php

    r252200 r577173  
    22/*
    33Plugin Name: WP-Infobox
    4 Plugin URI: http://jonasnordstrom.se/wordpress-plugins
     4Plugin URI: http://jonasnordstrom.se/plugins/wp-infobox/
    55Description: Add an info box to posts. You can add title, ingress, a bullet list and "more text"
    6 Version: 0.7
     6Version: 0.8
    77Author: Jonas Nordstrom
    88Author URI: http://jonasnordstrom.se
     
    2626
    2727
    28 if (!class_exists("WPInfobox")) {
     28if ( ! class_exists( "WPInfobox" ) ) {
    2929    class WPInfobox {
    3030
     
    3232        protected $max_items;
    3333        protected $css;
     34        protected $on_posts;
     35        protected $on_pages;
    3436
    3537        // Constructor
    3638        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' );
    4043        }
    4144
     
    4346        public function init_wpinfobox() {
    4447            // Set up localization
    45             $plugin_dir = basename(dirname(__FILE__));
     48            $plugin_dir = basename( dirname( __FILE__ ) );
    4649            load_plugin_textdomain( 'wpinfobox', 'wp-content/plugins/'. $plugin_dir.'/languages', $plugin_dir.'/languages' );
    4750        }
     
    5457                update_option('wpinfobox_maxitems', $_POST[ 'wpinfobox_maxitems' ]);
    5558                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');
    5661                ?>
    5762                <div class="updated"><p><strong><?php _e('Settings saved.', 'wpinfobox' ); ?></strong></p></div>
     
    7479                    <tr>
    7580                        <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>
    7799                    </tr>
    78100                    <tr>
     
    91113
    92114        // 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)
    94115        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;
    96122            add_options_page(__('Info Box Settings', "wpinfobox"), __('Info Box Settings', "wpinfobox"), 'administrator', basename(__FILE__), array(&$this, 'wpinfobox_admin_page') );
    97123        }
     
    124150            </tr>
    125151            <?php
    126             for ($i=1; $i <= $this->max_items; $i++) {
    127                 ?>
     152            for ( $i=1; $i <= $this->max_items; $i++ ) { ?>
    128153                <tr valign="top">
    129154                    <td><label for="wpinfobox_item_<?php echo $i?>"><?php echo __("Item", 'wpinfobox') .' '. $i . ':';?></label></td>
     
    182207            $title = get_post_meta($post->ID, 'wpinfobox_title', true);
    183208
    184             // Only display infox on single pages
     209            // Only display infobox on single pages
    185210            // TODO: Set this as an option
    186211            if (is_single() && !empty($title)) {
     
    228253                return;
    229254
    230             if ( @file_exists(STYLESHEETPATH . '/wp-infobox.css') ) {
     255      if ( @file_exists(STYLESHEETPATH . '/wp-infobox.css') ) {
    231256                $css_file = get_stylesheet_directory_uri() . '/wp-infobox.css';
    232257            } elseif ( @file_exists(TEMPLATEPATH . '/pagenavi-css.css') ) {
     
    235260                $css_file = plugins_url('css/wp-infobox.css', __FILE__);
    236261            }
    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    }
    241265    }
    242266}
     
    251275add_action( 'admin_menu', array(&$wpinfobox, 'init_admin' ));
    252276add_action( 'save_post', array(&$wpinfobox, 'add_meta_data'));
    253 add_action('wp_print_styles', array(&$wpinfobox, 'add_style'));
     277add_action( 'wp_print_styles', array(&$wpinfobox, 'add_style'));
    254278add_filter( 'the_content', array (&$wpinfobox, 'content_filter'));
    255279?>
Note: See TracChangeset for help on using the changeset viewer.