Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
  1 <?php
  2 
  3 /**
  4  * Fired during plugin activation.
  5  *
  6  * This class defines all code necessary to run during the plugin's activation.
  7  *
  8  * @class     WC_POS_Deactivator
  9  * @package   WooCommerce POS
 10  * @author    Paul Kilmurray <paul@kilbot.com.au>
 11  * @link      http://www.woopos.com.au
 12  */
 13 
 14 namespace WC_POS;
 15 
 16 class Deactivator {
 17 
 18   /**
 19    *
 20    */
 21   public function __construct(){
 22     register_deactivation_hook( PLUGIN_FILE, array( $this, 'deactivate' ) );
 23   }
 24 
 25   /**
 26    * Fired when the plugin is deactivated.
 27    *
 28    * @param $network_wide
 29    */
 30   public function deactivate( $network_wide ) {
 31 
 32     if ( function_exists( 'is_multisite' ) && is_multisite() ) {
 33 
 34       if ( $network_wide ) {
 35 
 36         // Get all blog ids
 37         $blog_ids = $this->get_blog_ids();
 38 
 39         foreach ( $blog_ids as $blog_id ) {
 40 
 41           switch_to_blog( $blog_id );
 42           $this->single_deactivate();
 43 
 44           restore_current_blog();
 45 
 46         }
 47 
 48       } else {
 49         $this->single_deactivate();
 50       }
 51 
 52     } else {
 53       $this->single_deactivate();
 54     }
 55 
 56   }
 57 
 58   /**
 59    * Get all blog ids of blogs in the current network that are:
 60    * - not archived
 61    * - not spam
 62    * - not deleted
 63    */
 64   private static function get_blog_ids() {
 65 
 66     global $wpdb;
 67 
 68     // get an array of blog ids
 69     $sql = "SELECT blog_id FROM $wpdb->blogs
 70       WHERE archived = '0' AND spam = '0'
 71       AND deleted = '0'";
 72 
 73     return $wpdb->get_col( $sql );
 74 
 75   }
 76 
 77   /**
 78    * Fired when the plugin is deactivated.
 79    */
 80   public function single_deactivate() {
 81 
 82     // remove pos capabilities
 83     $this->remove_pos_capability();
 84 
 85     // remove pos rewrite rule
 86     flush_rewrite_rules( false ); // false will not overwrite .htaccess
 87   }
 88 
 89   /**
 90    * remove default pos capabilities to administrator and
 91    * shop_manager roles
 92    */
 93   static private function remove_pos_capability(){
 94     $roles = array('administrator', 'shop_manager');
 95     $caps = array('manage_woocommerce_pos', 'access_woocommerce_pos');
 96     foreach($roles as $slug) :
 97       $role = get_role($slug);
 98       if($role) : foreach($caps as $cap) :
 99         $role->remove_cap($cap);
100       endforeach; endif;
101     endforeach;
102   }
103 
104 }
105 
API documentation generated by ApiGen