Plugin Directory

Changeset 484143

Timestamp:
01/03/2012 10:25:41 PM (13 years ago)
Author:
johnciacia
Message:

adding activation hook

Location:
propel/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • propel/trunk/propel.php

    r484103 r484143  
    44Plugin URI: http://www.johnciacia.com/propel/
    55Description: Easily manage your projects, clients, tasks, and files.
    6 Version: 2.0
     6Version: 2.0
    77Author: John Ciacia
    88Author URI: http://www.johnciacia.com
     
    5555        add_action( 'init', array( __CLASS__, 'init'));
    5656       
    57         register_activation_hook( __FILE__, array( __CLASS__, 'install' ) );
    5857        require_once( __DIR__ . '/functions.php' );
    5958        require_once( __DIR__ . '/post-types/project.php' );
     
    121120            wp_enqueue_style('propel-ui');
    122121    }   
    123    
    124    
    125     /**
    126     * @since 1.0
    127     */
    128     public static function install ()
    129     {
     122
     123   
     124}
     125
     126class Propel_Options {
     127   
     128    public static function get_option($option) {
     129        $options = get_option('propel_options');
     130
     131        if( isset( $options[$option] ) )
     132            return $options[$option];
     133
     134        return 0;
     135    }
     136
     137    public static function initialize() {
     138        add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
     139        add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
     140
     141    }
     142
     143    public static function admin_menu() {
     144        add_options_page( 'Propel', 'Propel', 'manage_options', 'propel-options', array( __CLASS__, 'options' ) );         
     145    }
     146
     147    public static function options() {
     148    ?>
     149    <div class="wrap">
     150        <h2>Propel Options</h2>
     151        <form action="options.php" method="post">
     152            <?php settings_fields( 'propel_options' ); ?>
     153            <?php do_settings_sections( 'propel' ); ?>
     154
     155            <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes' ); ?>" />
     156        </form>
     157    </div>
     158
     159    <?php
     160    }
     161
     162    public static function admin_init(){
     163        register_setting( 'propel_options', 'propel_options', array( __CLASS__, 'options_validate' ) );
     164        add_settings_section('propel_main', 'Main Settings', array( __CLASS__, 'plugin_section_text' ), 'propel');
     165        //add_settings_field('propel_beta_options', 'Beta Options', array( __CLASS__, 'propel_beta_options' ), 'propel', 'propel_main' );
     166        add_settings_field('propel_ui_options', 'UI Options', array( __CLASS__, 'propel_ui_options' ), 'propel', 'propel_main' );
     167    }
     168
     169    public static function plugin_section_text() {
     170        echo '<p>These options allow you to customize Propel.</p>';
     171    }
     172
     173    public static function propel_beta_options() {
     174        $options = get_option('propel_options');
     175
     176        echo '<input name="propel_options[dnd]" id="propel_dnd" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['dnd']), false ) . ' /> Enable Drag and Drop Ordering';
     177        echo '<br />';
     178        echo '<input name="propel_options[user_restrictions]" id="propel_user_restrictions" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['user_restrictions']), false ) . ' /> Enable User Restrictions';
     179        echo '<br />';
     180        echo '<input name="propel_options[time_tracking]" id="propel_time_tracking" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['time_tracking']), false ) . ' /> Enable Time Tracking';
     181    }
     182
     183    public static function propel_ui_options() {
     184        $options = get_option('propel_options');
     185
     186        echo '<input name="propel_options[show_start_date]" id="show_start_date" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_start_date']), false ) . ' /> Show Start Date';
     187        echo '<br />';
     188
     189        echo '<input name="propel_options[show_end_date]" id="show_end_date" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_end_date']), false ) . ' /> Show End Date';
     190        echo '<br />';
     191       
     192        echo '<input name="propel_options[show_client]" id="show_client" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_client']), false ) . ' /> Show Client';
     193        echo '<br />';
     194        echo '<input name="propel_options[show_progress]" id="show_progress" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_progress']), false ) . ' /> Show Project Progress';
     195        echo '<br />';
     196        echo '<br /><br />';
     197
     198    }
     199
     200    public static function options_validate($input) {
     201        return $input;
     202    }
     203
     204    public static function option( $option ) {
     205        $options = get_option('propel_options');
     206        return (isset($options[$option])) ? (bool)$options[$option] : false;
     207    }
     208}
     209
     210function propel_get_priorities() {
     211    return array( 'Low', 'Medium', 'High' );
     212}
     213
     214
     215
     216register_activation_hook( __FILE__, 'propel_install' );
     217function propel_install () {
    130218        add_option( 'propel_theme', WP_PLUGIN_URL . '/propel/themes/smoothness/jquery-ui-1.8.6.custom.css' );
    131219        /*
     
    142230        add_option( 'PROPEL_DBVERSION', PROPEL_CURRENT_DBVERSION );
    143231    }
    144    
    145 }
    146 
    147 class Propel_Options {
    148    
    149     public static function get_option($option) {
    150         $options = get_option('propel_options');
    151 
    152         if( isset( $options[$option] ) )
    153             return $options[$option];
    154 
    155         return 0;
    156     }
    157 
    158     public static function initialize() {
    159         add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
    160         add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
    161 
    162     }
    163 
    164     public static function admin_menu() {
    165         add_options_page( 'Propel', 'Propel', 'manage_options', 'propel-options', array( __CLASS__, 'options' ) );         
    166     }
    167 
    168     public static function options() {
    169     ?>
    170     <div class="wrap">
    171         <h2>Propel Options</h2>
    172         <form action="options.php" method="post">
    173             <?php settings_fields( 'propel_options' ); ?>
    174             <?php do_settings_sections( 'propel' ); ?>
    175 
    176             <input name="Submit" type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes' ); ?>" />
    177         </form>
    178     </div>
    179 
    180     <?php
    181     }
    182 
    183     public static function admin_init(){
    184         register_setting( 'propel_options', 'propel_options', array( __CLASS__, 'options_validate' ) );
    185         add_settings_section('propel_main', 'Main Settings', array( __CLASS__, 'plugin_section_text' ), 'propel');
    186         //add_settings_field('propel_beta_options', 'Beta Options', array( __CLASS__, 'propel_beta_options' ), 'propel', 'propel_main' );
    187         add_settings_field('propel_ui_options', 'UI Options', array( __CLASS__, 'propel_ui_options' ), 'propel', 'propel_main' );
    188     }
    189 
    190     public static function plugin_section_text() {
    191         echo '<p>These options allow you to customize Propel.</p>';
    192     }
    193 
    194     public static function propel_beta_options() {
    195         $options = get_option('propel_options');
    196 
    197         echo '<input name="propel_options[dnd]" id="propel_dnd" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['dnd']), false ) . ' /> Enable Drag and Drop Ordering';
    198         echo '<br />';
    199         echo '<input name="propel_options[user_restrictions]" id="propel_user_restrictions" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['user_restrictions']), false ) . ' /> Enable User Restrictions';
    200         echo '<br />';
    201         echo '<input name="propel_options[time_tracking]" id="propel_time_tracking" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['time_tracking']), false ) . ' /> Enable Time Tracking';
    202     }
    203 
    204     public static function propel_ui_options() {
    205         $options = get_option('propel_options');
    206 
    207         echo '<input name="propel_options[show_start_date]" id="show_start_date" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_start_date']), false ) . ' /> Show Start Date';
    208         echo '<br />';
    209 
    210         echo '<input name="propel_options[show_end_date]" id="show_end_date" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_end_date']), false ) . ' /> Show End Date';
    211         echo '<br />';
    212        
    213         echo '<input name="propel_options[show_client]" id="show_client" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_client']), false ) . ' /> Show Client';
    214         echo '<br />';
    215         echo '<input name="propel_options[show_progress]" id="show_progress" type="checkbox" value="1" class="code" ' . checked( 1, isset($options['show_progress']), false ) . ' /> Show Project Progress';
    216         echo '<br />';
    217         echo '<br /><br />';
    218 
    219     }
    220 
    221     public static function options_validate($input) {
    222         return $input;
    223     }
    224 
    225     public static function option( $option ) {
    226         $options = get_option('propel_options');
    227         return (isset($options[$option])) ? (bool)$options[$option] : false;
    228     }
    229 }
    230 
    231 function propel_get_priorities() {
    232     return array( 'Low', 'Medium', 'High' );
    233 }
  • propel/trunk/readme.txt

    r484103 r484143  
    44Requires at least: 3.0
    55Tested up to: 3.3
    6 Stable tag: 2.0
     6Stable tag: 2.0
    77
    88This plugin allows users to manage projects and tasks.
Note: See TracChangeset for help on using the changeset viewer.