WooCommerce_Delivery_Notes

The WooCommerce Print Invoices & Delivery Notes WooCommerce Delivery Notes class.

Defined (1)

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

/woocommerce-delivery-notes.php  
  1. class WooCommerce_Delivery_Notes { 
  2.  
  3. public static $plugin_prefix; 
  4. public static $plugin_url; 
  5. public static $plugin_path; 
  6. public static $plugin_basefile; 
  7.  
  8. public $writepanel; 
  9. public $settings; 
  10. public $print; 
  11.  
  12. /** 
  13. * Constructor 
  14. */ 
  15. public function __construct() { 
  16. self::$plugin_prefix = 'wcdn_'; 
  17. self::$plugin_basefile = plugin_basename(__FILE__); 
  18. self::$plugin_url = plugin_dir_url(self::$plugin_basefile); 
  19. self::$plugin_path = trailingslashit(dirname(__FILE__)); 
  20.  
  21. /** 
  22. * Load the hooks 
  23. */ 
  24. public function load() { 
  25. // load the hooks 
  26. add_action( 'plugins_loaded', array($this, 'load_localisation') ); 
  27. add_action( 'init', array( $this, 'load_hooks' ) ); 
  28. add_action( 'admin_init', array( $this, 'load_admin_hooks' ) ); 
  29.  
  30. /** 
  31. * Load the main plugin classes and functions 
  32. */ 
  33. public function includes() { 
  34. include_once( 'classes/class-wcdn-writepanel.php' ); 
  35. include_once( 'classes/class-wcdn-settings.php' ); 
  36. include_once( 'classes/class-wcdn-print.php' ); 
  37.  
  38. /** 
  39. * Load the localisation  
  40. */ 
  41. public function load_localisation() {  
  42. load_plugin_textdomain( 'woocommerce-delivery-notes', false, dirname( self::$plugin_basefile ) . '/../../languages/woocommerce-delivery-notes/' ); 
  43. load_plugin_textdomain( 'woocommerce-delivery-notes', false, dirname( self::$plugin_basefile ) . '/languages' ); 
  44.  
  45. /** 
  46. * Load the init hooks 
  47. */ 
  48. public function load_hooks() {  
  49. if ( $this->is_woocommerce_activated() ) { 
  50. $this->includes(); 
  51. $this->writepanel = new WooCommerce_Delivery_Notes_Writepanel(); 
  52. $this->writepanel->load(); 
  53. $this->settings = new WooCommerce_Delivery_Notes_Settings(); 
  54. $this->settings->load(); 
  55. $this->print = new WooCommerce_Delivery_Notes_Print(); 
  56. $this->print->load(); 
  57.  
  58. /** 
  59. * Load the admin hooks 
  60. */ 
  61. public function load_admin_hooks() { 
  62. if ( $this->is_woocommerce_activated() ) { 
  63. add_filter( 'plugin_row_meta', array( $this, 'add_support_links' ), 10, 2 );  
  64. add_filter( 'plugin_action_links_' . self::$plugin_basefile, array( $this, 'add_settings_link') ); 
  65.  
  66. /** 
  67. * Add various support links to plugin page 
  68. */ 
  69. public function add_support_links( $links, $file ) { 
  70. if ( !current_user_can( 'install_plugins' ) ) { 
  71. return $links; 
  72.  
  73. if ( $file == WooCommerce_Delivery_Notes::$plugin_basefile ) { 
  74. $links[] = '<a href="http://wordpress.org/extend/plugins/woocommerce-delivery-notes/faq/" target="_blank" title="' . __( 'FAQ', 'woocommerce-delivery-notes' ) . '">' . __( 'FAQ', 'woocommerce-delivery-notes' ) . '</a>'; 
  75. $links[] = '<a href="http://wordpress.org/support/plugin/woocommerce-delivery-notes" target="_blank" title="' . __( 'Support', 'woocommerce-delivery-notes' ) . '">' . __( 'Support', 'woocommerce-delivery-notes' ) . '</a>'; 
  76. return $links; 
  77.  
  78. /** 
  79. * Add settings link to plugin page 
  80. */ 
  81. public function add_settings_link( $links ) { 
  82. $settings = sprintf( '<a href="%s" title="%s">%s</a>' , admin_url( 'admin.php?page=woocommerce&tab=' . $this->settings->tab_name ) , __( 'Go to the settings page', 'woocommerce-delivery-notes' ) , __( 'Settings', 'woocommerce-delivery-notes' ) ); 
  83. array_unshift( $links, $settings ); 
  84. return $links;  
  85.  
  86. /** 
  87. * Check if woocommerce is activated 
  88. */ 
  89. public function is_woocommerce_activated() { 
  90. $blog_plugins = get_option( 'active_plugins', array() ); 
  91. $site_plugins = get_site_option( 'active_sitewide_plugins', array() ); 
  92.  
  93. if ( in_array( 'woocommerce/woocommerce.php', $blog_plugins ) || isset( $site_plugins['woocommerce/woocommerce.php'] ) ) { 
  94. return true; 
  95. } else { 
  96. return false;