MC4WP_Lite

The MailChimp for WordPress Lite MC4WP Lite class.

Defined (1)

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

/includes/class-plugin.php  
  1. class MC4WP_Lite { 
  2.  
  3. /** 
  4. * @var MC4WP_Lite_Form_Manager 
  5. */ 
  6. private $form_manager; 
  7.  
  8. /** 
  9. * @var MC4WP_Lite_Checkbox_Manager 
  10. */ 
  11. private $checkbox_manager; 
  12.  
  13. /** 
  14. * @var MC4WP_API 
  15. */ 
  16. private $api; 
  17.  
  18. /** 
  19. * @var MC4WP_Lite The one and only true plugin instance 
  20. */ 
  21. private static $instance; 
  22.  
  23. /** 
  24. * @return MC4WP_Lite 
  25. */ 
  26. public static function instance() { 
  27. return self::$instance; 
  28.  
  29. /** 
  30. * Instantiates the plugin 
  31. * @return bool 
  32. */ 
  33. public static function init() { 
  34.  
  35. if( self::$instance instanceof MC4WP_Lite ) { 
  36. return false; 
  37.  
  38. self::$instance = new MC4WP_Lite; 
  39. return true; 
  40.  
  41.  
  42. /** 
  43. * Constructor 
  44. */ 
  45. private function __construct() { 
  46.  
  47. // checkboxes 
  48. $this->checkbox_manager = new MC4WP_Lite_Checkbox_Manager(); 
  49.  
  50. // forms 
  51. add_action( 'init', array( $this, 'init_form_listener' ) ); 
  52. add_action( 'init', array( $this, 'init_form_manager' ) ); 
  53.  
  54. // widget 
  55. add_action( 'widgets_init', array( $this, 'register_widget' ) ); 
  56.  
  57. /** 
  58. * Initialise the form listener 
  59. * @hooked `init` 
  60. */ 
  61. public function init_form_listener() { 
  62. $listener = new MC4WP_Form_Listener(); 
  63. $listener->listen( $_REQUEST ); 
  64.  
  65. /** 
  66. * Initialise the form manager 
  67. * @hooked `template_redirect` 
  68. */ 
  69. public function init_form_manager() { 
  70. $this->form_manager = new MC4WP_Lite_Form_Manager(); 
  71. $this->form_manager->init(); 
  72.  
  73. /** 
  74. * @return MC4WP_Lite_Checkbox_Manager 
  75. */ 
  76. public function get_checkbox_manager() { 
  77. return $this->checkbox_manager; 
  78.  
  79. /** 
  80. * @return MC4WP_Lite_Form_Manager 
  81. */ 
  82. public function get_form_manager() { 
  83. return $this->form_manager; 
  84.  
  85. /** 
  86. * @return MC4WP_API 
  87. */ 
  88. public function get_api() { 
  89.  
  90. if( $this->api === null ) { 
  91. $opts = mc4wp_get_options(); 
  92. $this->api = new MC4WP_API( $opts['general']['api_key'] ); 
  93.  
  94. return $this->api; 
  95.  
  96. public function register_widget() { 
  97. register_widget( 'MC4WP_Lite_Widget' ); 
  98.