PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 4.0.1
WP Popular Posts v4.0.1
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / includes / class-wordpress-popular-posts.php
wordpress-popular-posts / includes Last commit date
class-wordpress-popular-posts-activator.php 8 years ago class-wordpress-popular-posts-deactivator.php 8 years ago class-wordpress-popular-posts-helper.php 8 years ago class-wordpress-popular-posts-i18n.php 8 years ago class-wordpress-popular-posts-image.php 8 years ago class-wordpress-popular-posts-loader.php 8 years ago class-wordpress-popular-posts-output.php 8 years ago class-wordpress-popular-posts-query.php 8 years ago class-wordpress-popular-posts-settings.php 8 years ago class-wordpress-popular-posts-template.php 8 years ago class-wordpress-popular-posts-translate.php 8 years ago class-wordpress-popular-posts-widget.php 8 years ago class-wordpress-popular-posts.php 8 years ago widget-form.php 8 years ago
class-wordpress-popular-posts.php
232 lines
1 <?php
2
3 class WordPressPopularPosts {
4
5 /**
6 * The unique identifier of this plugin.
7 *
8 * @since 4.0.0
9 * @access protected
10 * @var string $plugin_name
11 */
12 protected $plugin_name;
13
14 /**
15 * The current version of this plugin.
16 *
17 * @since 4.0.0
18 * @access protected
19 * @var string $version
20 */
21 protected $version;
22
23 /**
24 * Constructor.
25 *
26 * @since 4.0.0
27 */
28 public function __construct(){
29
30 $this->plugin_name = 'wordpress-popular-posts';
31 $this->version = '4.0.0';
32
33 $this->load_dependencies();
34 $this->set_locale();
35 $this->define_admin_hooks();
36 $this->define_public_hooks();
37
38 }
39
40 /**
41 * Loads the required dependencies for this plugin.
42 *
43 * @since 4.0.0
44 * @access private
45 */
46 private function load_dependencies(){
47
48 /**
49 * The class responsible for defining internationalization functionality of the plugin.
50 */
51 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-i18n.php';
52
53 /**
54 * The class responsible for translating objects.
55 */
56 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-translate.php';
57
58 /**
59 * Settings class.
60 */
61 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-settings.php';
62
63 /**
64 * Helper class.
65 */
66 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-helper.php';
67
68 /**
69 * Template functions.
70 */
71 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-template.php';
72
73 /**
74 * The class responsible for handling the actions and filters of the plugin.
75 */
76 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-loader.php';
77
78 /**
79 * The class responsible for querying the database.
80 */
81 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-query.php';
82
83 /**
84 * The class responsible for creating images.
85 */
86 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-image.php';
87
88 /**
89 * The class responsible for building the HTML output.
90 */
91 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-output.php';
92
93 /**
94 * The widget class.
95 */
96 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordpress-popular-posts-widget.php';
97
98 /**
99 * The class responsible for defining all actions that occur on the admin-facing side of the site.
100 */
101 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordpress-popular-posts-admin.php';
102
103 /**
104 * The class responsible for defining all actions that occur on the public-facing side of the site.
105 */
106 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordpress-popular-posts-public.php';
107
108 /**
109 * Get loader.
110 */
111 $this->loader = new WPP_Loader();
112
113 }
114
115 /**
116 * Register all of the hooks related to the admin area functionality of the plugin.
117 *
118 * @since 4.0.0
119 * @access private
120 */
121 public function define_admin_hooks() {
122
123 $plugin_admin = new WPP_Admin( $this->get_plugin_name(), $this->get_version() );
124
125 // Check admin notices
126 $this->loader->add_action( 'admin_notices', $plugin_admin, 'check_admin_notices' );
127 // Upgrade check
128 $this->loader->add_action( 'init', $plugin_admin, 'upgrade_check' );
129 // Hook fired when a new blog is activated on WP Multisite
130 $this->loader->add_action( 'wpmu_new_blog', $plugin_admin, 'activate_new_site' );
131 // Hook fired when a blog is deleted on WP Multisite
132 $this->loader->add_filter( 'wpmu_drop_tables', $plugin_admin, 'delete_site_data', 10, 2 );
133 // Load WPP's admin styles and scripts
134 $this->loader->add_action( 'admin_print_styles', $plugin_admin, 'enqueue_styles' );
135 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
136 // Add admin screen
137 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' );
138 // Thickbox setup
139 $this->loader->add_action( 'admin_init', $plugin_admin, 'thickbox_setup' );
140 // Contextual help
141 $this->loader->add_action( 'admin_head', $plugin_admin, 'add_contextual_help' );
142 // Add plugin settings link
143 $this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'add_plugin_settings_link', 10, 2 );
144 // Update chart
145 $this->loader->add_action( 'wp_ajax_wpp_update_chart', $plugin_admin, 'update_chart' );
146 // Get lists
147 $this->loader->add_action( 'wp_ajax_wpp_get_most_viewed', $plugin_admin, 'get_most_viewed' );
148 $this->loader->add_action( 'wp_ajax_wpp_get_most_commented', $plugin_admin, 'get_most_commented' );
149 // Delete plugin data
150 $this->loader->add_action( 'wp_ajax_wpp_clear_data', $plugin_admin, 'clear_data' );
151 // Empty plugin's images cache
152 $this->loader->add_action( 'wp_ajax_wpp_clear_thumbnail', $plugin_admin, 'clear_thumbnails' );
153 // Flush cached thumbnail on featured image change
154 $this->loader->add_action( 'update_postmeta', $plugin_admin, 'flush_post_thumbnail', 10, 4 );
155 // Purge post data on post/page deletion
156 $this->loader->add_action( 'admin_init', $plugin_admin, 'purge_post_data' );
157 // Purge old data on demand
158 $this->loader->add_action( 'wpp_cache_event', $plugin_admin, 'purge_data' );
159 // Initialize widget
160 $this->loader->add_action( 'widgets_init', $plugin_admin, 'register_widget' );
161
162 }
163
164 /**
165 * Register all of the hooks related to the public area functionality of the plugin.
166 *
167 * @since 4.0.0
168 * @access private
169 */
170 public function define_public_hooks() {
171
172 $plugin_public = new WPP_Public( $this->get_plugin_name(), $this->get_version() );
173
174 // Register logging AJAX hook
175 $this->loader->add_action( 'wp_ajax_update_views_ajax', $plugin_public, 'update_views' );
176 $this->loader->add_action( 'wp_ajax_nopriv_update_views_ajax', $plugin_public, 'update_views' );
177 // Add WPP's stylesheet and scripts
178 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
179 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
180 // Add [wpp] shortcode
181 $this->loader->add_shortcode( 'wpp', $plugin_public, 'wpp_shortcode' );
182
183 }
184
185 /**
186 * Define the locale for this plugin for internationalization.
187 *
188 * Uses the Plugin_Name_i18n class in order to set the domain and to register the hook
189 * with WordPress.
190 *
191 * @since 4.0.0
192 * @access private
193 */
194 private function set_locale() {
195
196 $plugin_i18n = new WPP_i18n();
197 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
198
199 }
200
201 /**
202 * The name of the plugin used to uniquely identify it within the context of
203 * WordPress and to define internationalization functionality.
204 *
205 * @since 4.0.0
206 * @return string The name of the plugin.
207 */
208 public function get_plugin_name() {
209 return $this->plugin_name;
210 }
211
212 /**
213 * Retrieve the version number of the plugin.
214 *
215 * @since 4.0.0
216 * @return string The version number of the plugin.
217 */
218 public function get_version() {
219 return $this->version;
220 }
221
222 /**
223 * Run the loader to execute all of the hooks with WordPress.
224 *
225 * @since 4.0.0
226 */
227 public function run() {
228 $this->loader->run();
229 }
230
231 } // End WordPressPopularPosts class
232