Plugin Directory

Changeset 1611754


Ignore:
Timestamp:
03/10/2017 07:55:31 AM (9 years ago)
Author:
sethcarstens
Message:

moved class out of main plugin file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sm-sticky-clicky-star/trunk/sm-sticky-clicky-star.php

    r1207225 r1611754  
    1111 * Text Domain: sm_sticky_clicky_star
    1212 *
    13  * @package sm-sticky-clicky-star
     13 * @package  sm-sticky-clicky-star
    1414 * @category plugin
    15  * @author Seth Carstens <seth.carstens@gmail.com>
     15 * @author   Seth Carstens <seth.carstens@gmail.com>
    1616 */
    1717
    1818//avoid direct calls to this file, because now WP core and framework has been used
    1919if ( ! function_exists( 'add_filter' ) ) {
    20     header('Status: 403 Forbidden'); header('HTTP/1.1 403 Forbidden'); exit();
     20    header( 'Status: 403 Forbidden' );
     21    header( 'HTTP/1.1 403 Forbidden' );
     22    exit();
    2123}
    2224
    23 if(!class_exists('sm_sticky_clicky_star'))
    24 {
    25     class sm_sticky_clicky_star
    26     {
    27         public $installed_dir;
    28         public $installed_url;
     25require_once( 'class-sm-sticky-clicky-star.php' );
    2926
    30         /**
    31          * Construct the plugin object
    32          */
    33         public function __construct()
    34         {
    35             $this->installed_dir = dirname(__FILE__);
    36             $this->installed_url = plugins_url('/', __FILE__);
    37             //only load the sticky clicky star plugin functions if the user has the capability to "sticky" posts.
    38             add_action('init', array($this,'init'));
    39         } // END public function __construct
    40 
    41         /**
    42          * Initialize the plugin -either for admin (back end) or public (front end)
    43          */
    44         function init() {
    45 
    46             if(current_user_can('edit_others_posts') || current_user_can('edit_post_sticky') ) {
    47                 require_once($this->installed_dir.'/sm-sticky-clicky-star-admin.php');
    48                 new sm_sticky_clicky_star_admin($this);
    49             }
    50         }
    51 
    52         /**
    53          * Activate the plugin
    54          */
    55         public static function activate()
    56         {
    57             // get the "admin" role object and add capability
    58             $role = get_role( 'administrator' );
    59             $role->add_cap( 'edit_post_sticky' );
    60         } // END public static function activate
    61 
    62         /**
    63          * Deactivate the plugin
    64          */
    65         public static function deactivate()
    66         {
    67             global $wp_roles;
    68             foreach (array_keys($wp_roles->roles) as $role) {
    69                 $wp_roles->remove_cap($role, 'edit_post_sticky');
    70             }
    71         } // END public static function deactivate
    72 
    73     } // END class sm_sticky_clicky_star
    74 } // END if(!class_exists('sm_sticky_clicky_star'))
    75 
    76 if(class_exists('sm_sticky_clicky_star'))
    77 {
     27if ( class_exists( 'sm_sticky_clicky_star' ) ) {
    7828    // Installation and uninstallation hooks
    79     register_activation_hook(__FILE__, array('sm_sticky_clicky_star', 'activate'));
    80     register_deactivation_hook(__FILE__, array('sm_sticky_clicky_star', 'deactivate'));
     29    register_activation_hook( __FILE__, array( 'sm_sticky_clicky_star', 'activate' ) );
     30    register_deactivation_hook( __FILE__, array( 'sm_sticky_clicky_star', 'deactivate' ) );
    8131
    8232    // instantiate the plugin class
Note: See TracChangeset for help on using the changeset viewer.