Easy_Peasy_MailChimp

Easy Google Analytics class.

Defined (1)

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

/easy-peasy-mailchimp.php  
  1. class Easy_Peasy_MailChimp { 
  2.  
  3. /** 
  4. * Constructor - get the plugin hooked in and ready 
  5. * @since 1.0.0 
  6. */ 
  7. public function __construct() { 
  8.  
  9. // Define constants 
  10. define( 'EPM_VERSION', '1.0.5' ); 
  11. define( 'EPM_SLUG', plugin_basename(__FILE__)); 
  12. define( 'EPM_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); 
  13. define( 'EPM_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); 
  14.  
  15. //Filters 
  16. register_activation_hook(__FILE__, array( $this, 'plugin_activation_check'));  
  17.  
  18. add_filter( "plugin_action_links_".EPM_SLUG , array( $this, 'epm_add_settings_link') ); 
  19. add_filter( 'plugin_row_meta', array( $this, 'epm_plugin_row_meta'), 10, 2 ); 
  20.  
  21. //Actions 
  22. add_action('plugins_loaded', array($this, 'epm_load_plugin_textdomain')); 
  23. add_action('admin_menu', array($this, 'epm_add_options_link'), 10); 
  24. add_action('epm_settings_sidebar', array($this, 'epm_add_settings_box'), 10); 
  25. add_action('epm_settings_sidebar', array($this, 'epm_add_settings_box_advert'), 10); 
  26. add_action('epm_next_to_settings_title', array($this, 'epm_add_links_to_title')); 
  27.  
  28. // Load required files 
  29. $this->epm_includes(); 
  30.  
  31.  
  32. /** 
  33. * Add Settings Link To WP-Plugin Page 
  34. * @since 1.0.0 
  35. */ 
  36. public function epm_add_settings_link( $links ) { 
  37. $settings_link = '<a href="options-general.php?page=epm-settings">'.__('Settings', 'easy-peasy-mailchimp').'</a>'; 
  38. array_push( $links, $settings_link ); 
  39. return $links; 
  40.  
  41. /** 
  42. * Plugin row meta links 
  43. * @since 1.8 
  44. */ 
  45. function epm_plugin_row_meta( $input, $file ) { 
  46. if ( $file != 'easy-peasy-mailchimp/easy-peasy-mailchimp.php' ) 
  47. return $input; 
  48.  
  49. $links = array( 
  50. '<a href="http://themeforest.net/user/ThemesDepot/portfolio" target="_blank">' . esc_html__( 'Get Premium WordPress Themes', 'easy-peasy-mailchimp' ) . '</a>',  
  51. '<a href="http://profiles.wordpress.org/alessandrotesoro/" target="_blank">' . esc_html__( 'Get More Free Plugins', 'easy-peasy-mailchimp' ) . '</a>',  
  52. ); 
  53.  
  54. $input = array_merge( $input, $links ); 
  55.  
  56. return $input; 
  57.  
  58. /** 
  59. * Localization 
  60. * @since 1.0.0 
  61. */ 
  62. public function epm_load_plugin_textdomain() { 
  63. load_plugin_textdomain( 'easy-peasy-mailchimp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
  64.  
  65. /** 
  66. * Include required files 
  67. * @since 1.0.0 
  68. */ 
  69. private function epm_includes() { 
  70.  
  71. // Plugin options handler 
  72. global $epm_options; 
  73. require_once EPM_PLUGIN_DIR . '/includes/admin/settings/register-settings.php'; 
  74. $epm_options = epm_get_settings(); 
  75.  
  76. if(is_admin()) { 
  77. require_once EPM_PLUGIN_DIR . '/includes/admin/settings/display-settings.php'; 
  78.  
  79. // Load MailChimp API Class 
  80. require_once EPM_PLUGIN_DIR . '/includes/MailChimp.php'; 
  81.  
  82. // Easy Peasy MailChimp Template Manager 
  83. require_once EPM_PLUGIN_DIR . '/includes/template.php'; 
  84.  
  85. // Easy Peasy MailChimp Shortcode 
  86. require_once EPM_PLUGIN_DIR . '/includes/shortcode.php'; 
  87.  
  88. // Easy Peasy Ajax Handler 
  89. require_once EPM_PLUGIN_DIR . '/includes/ajax.php';  
  90.  
  91.  
  92. /** 
  93. * Add Plugin Menu Page 
  94. * @since 1.0.0 
  95. */ 
  96. public function epm_add_options_link() { 
  97. global $epm_settings_page; 
  98. $epm_settings_page = add_submenu_page( 'options-general.php', __( 'Easy Peasy MailChimp Settings', 'easy-peasy-mailchimp' ), __( 'MailChimp Settings', 'easy-peasy-mailchimp' ), 'manage_options', 'epm-settings', 'epm_options_page' ); 
  99.  
  100. /** 
  101. * Add box into the sidebar of the settings page. 
  102. * @since 1.0.0 
  103. */ 
  104. public function epm_add_settings_box() { 
  105.  
  106. echo '<div class="postbox"> 
  107. <h3 class="hndle">'.__('MailChimp Form Usage', 'easy-peasy-mailchimp').'</h3> 
  108. <div class="inside"> 
  109. '.__('To display a mailchimp signup form use the shortcode below here.', 'easy-peasy-mailchimp').' 
  110. <br/><br/> 
  111. <code>[epm_mailchimp]</code> 
  112. </div> 
  113.  
  114. <div id="major-publishing-actions"> 
  115. <a href="http://kb.mailchimp.com/article/where-can-i-find-my-api-key" target="_blank" class="button">'.__('Get Your API Key', 'easy-peasy-mailchimp').'</a> 
  116. <a href="http://kb.mailchimp.com/article/how-can-i-find-my-list-id" target="_blank" class="button">'.__('Get Your List ID', 'easy-peasy-mailchimp').'</a>  
  117. </div> 
  118. </div>'; 
  119.  
  120. /** 
  121. * Add box into the sidebar of the settings page. 
  122. * @since 1.0.0 
  123. */ 
  124. public function epm_add_settings_box_advert() { 
  125.  
  126. echo '<div class="postbox"> 
  127. <h3 class="hndle">'.__('Premium WordPress Themes', 'easy-peasy-mailchimp').'</h3> 
  128. <div class="inside"> 
  129. '.__('Are you looking for Premium WordPress Themes? <a href="http://themesdepot.org" target="_blank">ThemesDepot</a> provides premium and affordable WordPress themes for any kind of website.', 'easy-peasy-mailchimp').' 
  130. </div> 
  131.  
  132. <div id="major-publishing-actions"> 
  133. <a href="http://themeforest.net/user/ThemesDepot/portfolio?ref=ThemesDepot" target="_blank" class="button-primary">'.__('Browse Premium Themes', 'easy-peasy-mailchimp').'</a> 
  134. </div> 
  135. </div>'; 
  136.  
  137. /** 
  138. * Add links next to title in settings page 
  139. * @since 1.0.0 
  140. */ 
  141. public function epm_add_links_to_title() { 
  142.  
  143. echo '<a href="http://profiles.wordpress.org/alessandrotesoro/" class="add-new-h2" target="_blank">'.__('Get More Free Plugins', 'easy-peasy-mailchimp').'</a>'; 
  144. echo '<a href="http://themeforest.net/user/ThemesDepot/portfolio?ref=ThemesDepot" class="add-new-h2" target="_blank">'.__('Browse Premium WordPress Themes', 'easy-peasy-mailchimp').'</a>'; 
  145.  
  146. /** 
  147. * Prevents Plugin Activation if host is crap. 
  148. * Yes, my darling friends, php 5.2 was deprecated in 2011  
  149. * Run away from your host if you're still using php 5.2 
  150. * @since 1.0.4 
  151. */ 
  152. function plugin_activation_check() {  
  153. if (version_compare(PHP_VERSION, '5.3', '<')) {  
  154. deactivate_plugins(basename(__FILE__)); // Deactivate ourself  
  155. wp_die("Sorry, but you can't run this plugin, it requires PHP 5.3 or higher. Contact your host and request a php update.");  
  156. }  
  157.