PluginProbe
Another Mailchimp Widget / 2.0.9
Another Mailchimp Widget v2.0.9
trunk 2.0.9 2.1.0
another-mailchimp-widget / another-mailchimp-widget.php

another-mailchimp-widget.php in Another Mailchimp Widget 2.0.9, at another-mailchimp-widget.php

173 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Another MailChimp Widget
4 * Plugin URI: https://motopress.com/products/another-mailchimp-widget/
5 * Description: Simple MailChimp subscription form to your lists and groups.
6 * Author: MotoPress
7 * Version: 2.0.9
8 * Author URI: https://motopress.com/
9 * License: GPL2
10 * Text Domain: another-mailchimp-widget
11 * Domain Path: /languages
12 */
13
14 register_activation_hook( __FILE__, array( Another_mailChimp_widget::get_instance(), 'on_activation' ) );
15 add_action( 'plugins_loaded', array( 'Another_mailChimp_widget', 'get_instance' ) );
16
17 /**
18 * Class Another_mailChimp_widget
19 */
20 class Another_mailChimp_widget {
21
22 protected static $instance;
23
24 /**
25 * Another_mailChimp_widget constructor.
26 */
27 public function __construct() {
28
29 spl_autoload_register( array( $this, 'buffered_autoloader' ) );
30
31 $this->include_all();
32 $this->init();
33
34 if ( ! defined( 'AN_MC_TEMPLATE_PATH' ) ) {
35 define( 'AN_MC_TEMPLATE_PATH', $this->template_path() );
36 }
37 if ( ! defined( 'AN_MC_PLUGIN_URL' ) ) {
38 define( 'AN_MC_PLUGIN_URL', $this->get_plugin_url() );
39 }
40 if ( ! defined( 'AN_MC_TEMPLATES_PATH' ) ) {
41 define( 'AN_MC_TEMPLATES_PATH', $this::get_plugin_dir() . 'templates/' );
42 }
43
44 }
45
46 /**
47 * Include classes into plugin
48 */
49 public function include_all() {
50
51 $plugin_dir = $this::get_plugin_dir();
52
53 include $plugin_dir . 'classes/class-view.php';
54
55 include $plugin_dir . 'functions/functions.php';
56
57 include $plugin_dir . 'lib/an_mc_plugin.class.php';
58
59 include_once $plugin_dir . 'shortcodes/registrator.php';
60
61 }
62
63 /**
64 * Get plugin dir
65 * @return string
66 */
67 public static function get_plugin_dir() {
68 if ( ! defined( 'AN_MC_PLUGIN_PATH' ) ) {
69
70 $file = Another_mailChimp_widget::get_plugin_file();
71 $path = trailingslashit( plugin_dir_path( $file ) );
72
73 define( 'AN_MC_PLUGIN_PATH', $path );
74 } else {
75 $path = AN_MC_PLUGIN_PATH;
76 }
77
78 return $path;
79 }
80
81 /**
82 * Get plugin File
83 *
84 * @return string
85 */
86 public static function get_plugin_file() {
87 global $wp_version, $network_plugin;
88
89 if ( version_compare( $wp_version, '3.9', '<' ) && isset( $network_plugin ) ) {
90 $pluginFile = $network_plugin;
91 } else {
92 $pluginFile = __FILE__;
93 }
94
95 return $pluginFile;
96 }
97
98 /**
99 * init plugin data
100 */
101 public function init() {
102 spl_autoload_register( array( $this, 'buffered_autoloader' ) );
103 AN_MC_Plugin::get_instance()->init_action();
104 }
105
106 /**
107 * Get the template path.
108 *
109 * @return string
110 */
111 public function template_path() {
112 return apply_filters( 'an_mc_template_path', 'another-mailchimp-widget/' );
113 }
114
115 /**
116 * Get plugin URL
117 */
118 public function get_plugin_url() {
119 $path = plugins_url( plugin_basename( __DIR__ ) );
120
121 return trailingslashit( $path );
122 }
123
124 /**
125 * @return Another_mailChimp_widget
126 */
127 public static function get_instance() {
128 if ( null === self::$instance ) {
129 self::$instance = new self();
130 }
131
132 return self::$instance;
133 }
134
135 /**
136 * On activation
137 */
138 public function on_activation() {
139 AN_MC_Plugin::get_instance()->set_up_options();
140 }
141
142 /**
143 * On deactivation
144 */
145 public function on_deactivation() {
146 }
147
148 /**
149 * on uninstall
150 */
151 public function on_uninstall() {
152 }
153
154 /**
155 *
156 * Autoloader
157 *
158 * @param $class
159 *
160 * @return string
161 */
162 public function buffered_autoloader( $class ) {
163 try {
164 set_include_path( get_include_path() . PATH_SEPARATOR . realpath( $this::get_plugin_dir() . '/lib/' ) );
165 spl_autoload( $class, '.class.php' );
166 ini_restore('include_path');
167 } catch ( Exception $e ) {
168 $message = $e->getMessage();
169
170 return $message;
171 }
172 }
173 }