WooCommerce_simply_order_export

The WooCommerce Simply Order Export WooCommerce simply order export class.

Defined (1)

The class is defined in the following location(s).

/main.php  
  1. class WooCommerce_simply_order_export { 
  2.  
  3. /** 
  4. * @var string 
  5. */ 
  6. public $version = '2.1.6'; 
  7.  
  8. /** 
  9. * Plugin Settings 
  10. */ 
  11. public $settings; 
  12.  
  13. /** 
  14. * Instance of the class. 
  15. */ 
  16. static $instance = null; 
  17.  
  18. /** 
  19. * Returns the current instance of the class 
  20. */ 
  21. static function instance() { 
  22.  
  23. if( is_null(self::$instance) ) { 
  24. self::$instance = new self(); 
  25.  
  26. return self::$instance; 
  27.  
  28. /** 
  29. * Constructor 
  30. */ 
  31. function __construct() { 
  32.  
  33. register_activation_hook( __FILE__, array( __CLASS__, 'install' ) ); 
  34. $this->define_constants(); 
  35. $this->includes(); 
  36. add_action( 'init', array($this, 'init') ); 
  37.  
  38. /** 
  39. * Fires at 'init' hook 
  40. */ 
  41. function init() { 
  42.  
  43. $this->load_plugin_textdomain(); 
  44. $this->set_variables(); 
  45. $this->instantiate(); 
  46. $this->settings = $this->wsoe_settings(); 
  47.  
  48. /** 
  49. * Call notice function, only if this is the first time plugin has been installed. 
  50. */ 
  51. wsoe_call_notices_func(); 
  52.  
  53. /** 
  54. * Load locale 
  55. */ 
  56. function load_plugin_textdomain() { 
  57.  
  58. load_plugin_textdomain( 'woocommerce-simply-order-export', false, plugin_basename( dirname( __FILE__ ) ) . "/languages" ); 
  59.  
  60. /** 
  61. * Sets the variables 
  62. */ 
  63. function __set( $name, $value ) { 
  64.  
  65. /** 
  66. * Check for valid names 
  67. */ 
  68. if( in_array( $name, array( 'wpg_order_export', 'wpg_order_columns' ) ) ) {  
  69. $GLOBALS[$name] = $value; 
  70.  
  71. /** 
  72. * Define all constants 
  73. */ 
  74. function define_constants() { 
  75.  
  76. define('WSOE_BASENAME', plugin_basename(__FILE__)); 
  77. define('WSOE_BASE', plugin_dir_path(__FILE__)); 
  78. define( 'WSOE_URL', plugins_url('', __FILE__) ); /** plugin url */ 
  79. define( 'WSOE_CSS', WSOE_URL. "/assets/css/" ); /** Define all necessary variables first */ 
  80. define( 'WSOE_JS', WSOE_URL. "/assets/js/" ); 
  81. define( 'WSOE_IMG', WSOE_URL. "/assets/img/" ); 
  82.  
  83. /** 
  84. * Set necessary variables. 
  85. */ 
  86. function set_variables() { 
  87.  
  88. $this->wpg_order_columns = apply_filters( 'wpg_order_columns', array( 
  89. 'wc_settings_tab_order_id'=>__( 'Order ID', 'woocommerce-simply-order-export' ),  
  90. 'wc_settings_tab_customer_name'=>__( 'Customer Name', 'woocommerce-simply-order-export' ),  
  91. 'wc_settings_tab_product_name'=>__( 'Product Name', 'woocommerce-simply-order-export' ),  
  92. 'wc_settings_tab_product_quantity'=>__( 'Product Quantity', 'woocommerce-simply-order-export' ),  
  93. 'wc_settings_tab_product_variation'=>__( 'Variation details', 'woocommerce-simply-order-export' ),  
  94. 'wc_settings_tab_amount'=> __( 'Order Amount', 'woocommerce-simply-order-export' ),  
  95. 'wc_settings_tab_customer_email'=> __( 'Customer Email', 'woocommerce-simply-order-export' ),  
  96. 'wc_settings_tab_customer_phone'=>__( 'Phone Number', 'woocommerce-simply-order-export' ),  
  97. 'wc_settings_tab_order_status'=>__( 'Order Status', 'woocommerce-simply-order-export' ) 
  98. ); 
  99.  
  100. /** 
  101. * Include helper classes 
  102. */ 
  103. function includes() { 
  104. // Includes PHP files located in 'lib' and 'classes' folder 
  105. foreach( array_merge( glob ( dirname(__FILE__). "/lib/*.php" ), glob ( dirname(__FILE__). "/classes/*.php" ) ) as $lib_filename ) { 
  106. require_once( $lib_filename ); 
  107.   
  108. /** 
  109. * Runs when plugin is activated. 
  110. */ 
  111. static function install() { 
  112.  
  113. ob_start(); 
  114.  
  115. global $wpg_order_columns; 
  116.  
  117. $wpg_order_columns = is_array($wpg_order_columns) ? $wpg_order_columns : array(); 
  118.  
  119. foreach( $wpg_order_columns as $key=>$val ) { 
  120.  
  121. $option = get_option( $key, null ); 
  122. if( empty( $option ) ) { 
  123. update_option($key, 'yes'); 
  124.  
  125. ob_end_clean(); 
  126.  
  127. /** 
  128. * Instantiate necessary classes. 
  129. */ 
  130. function instantiate() { 
  131.  
  132. $this->wpg_order_export = new wpg_order_export(); 
  133.  
  134. /** 
  135. * Settings for the plugin. 
  136. */ 
  137. public function wsoe_settings() { 
  138.  
  139. $default_settings = array( 'wsoe_export_filename'=>'', 'wsoe_order_statuses'=> array(), 'wsoe_delimiter'=>', ', 'wsoe_fix_chars'=>0 ); 
  140. $extensions = array( 'add-on'=>false, 'scheduler'=>false ); 
  141.  
  142. /** 
  143. * Fill up the settings. 
  144. */ 
  145. $plugin_settings = get_option( 'wsoe_advanced_settings_core', array() ); 
  146. $plugin_settings = wp_parse_args( $plugin_settings, $default_settings ); 
  147.  
  148. /** 
  149. * Check if add-on plugin is installed 
  150. */ 
  151. if( class_exists('wsoe_addon') ) { 
  152. $extensions['add-on'] = true; 
  153.  
  154. /** 
  155. * Check if scheduler plugin is installed 
  156. */ 
  157. if( class_exists('wsoe_schedular') ) { 
  158. $extensions['scheduler'] = true; 
  159.  
  160. return apply_filters( 'wsoe_settings', array( 'plugin_settings'=> $plugin_settings, 'extensions'=>$extensions ) ); 
  161.  
  162. /** 
  163. * Flushes the setting and fills up with the new values. 
  164. */ 
  165. public function flush_settings() { 
  166. $this->settings = $this->wsoe_settings(); 
  167.