270 |
271 |
rate_us_url, str_replace('%plugin%', $plugin_data['Name'], $this->rate_us_message)); ?>
272 |
273 |
prefix.'-dismiss-suggestions'))
288 | $this->update_dismissed_timestamp('suggestions');
289 | }
290 |
291 |
292 |
293 | /**
294 | * Dismiss rate plugin
295 | */
296 | public function dismiss_rate_us() {
297 | if (!empty($_POST['nonce']) && wp_verify_nonce( $_POST['nonce'], $this->prefix.'-dismiss-rate-us'))
298 | $this->update_dismissed_timestamp('rate_us');
299 | }
300 |
301 |
302 |
303 | // Plugins information retrieval
304 | // ---------------------------------------------------------------------------------------------------
305 |
306 |
307 |
308 | /**
309 | * Retrieve uninstalled plugins
310 | */
311 | private function get_missing_plugins() {
312 |
313 | // Initialize
314 | $inactive = array();
315 |
316 | // Check plugins directory
317 | $directories = array_merge(self::get_mu_plugins_directories(), self::get_plugins_directories());
318 | if (!empty($directories)) {
319 | $required = array_keys($this->suggestions);
320 | foreach ($required as $plugin) {
321 | if (!in_array($plugin, $directories))
322 | $inactive[] = $plugin;
323 | }
324 | }
325 |
326 | // Check inactives
327 | if (empty($inactive))
328 | return false;
329 |
330 | // Done
331 | return $inactive;
332 | }
333 |
334 |
335 |
336 | /**
337 | * Collects all active plugins
338 | */
339 | private function get_plugins_directories() {
340 |
341 | // Initialize
342 | $directories = array();
343 |
344 | // Plugins split directory
345 | $split = '/'.basename(WP_CONTENT_DIR).'/'.basename(WP_PLUGIN_DIR).'/';
346 |
347 | // Multisite plugins
348 | if (is_multisite()) {
349 | $ms_plugins = wp_get_active_network_plugins();
350 | if (!empty($ms_plugins) && is_array($ms_plugins)) {
351 | foreach ($ms_plugins as $file) {
352 | $directory = explode($split, $file);
353 | $directory = explode('/', ltrim($directory[1], '/'));
354 | $directory = $directory[0];
355 | if (!in_array($directory, $directories))
356 | $directories[] = $directory;
357 | }
358 | }
359 | }
360 |
361 | // Active plugins
362 | $plugins = wp_get_active_and_valid_plugins();
363 | if (!empty($plugins) && is_array($plugins)) {
364 | foreach ($plugins as $file) {
365 | $directory = explode($split, $file);
366 | $directory = explode('/', ltrim($directory[1], '/'));
367 | $directory = $directory[0];
368 | if (!in_array($directory, $directories))
369 | $directories[] = $directory;
370 | }
371 | }
372 |
373 | // Done
374 | return $directories;
375 | }
376 |
377 |
378 |
379 | /**
380 | * Retrieve mu-plugins directories
381 | */
382 | private function get_mu_plugins_directories() {
383 |
384 | // Initialize
385 | $directories = array();
386 |
387 | // Dependencies
388 | if (!function_exists('get_plugins'))
389 | require_once(ABSPATH.'wp-admin/includes/plugin.php');
390 |
391 | // Retrieve mu-plugins
392 | $plugins = get_plugins('/../mu-plugins');
393 | if (!empty($plugins) && is_array($plugins)) {
394 | foreach ($plugins as $path => $info) {
395 | $directory = dirname($path);
396 | if (!in_array($directory, array('.', '..')))
397 | $directories[] = $directory;
398 | }
399 | }
400 |
401 | // Done
402 | return $directories;
403 | }
404 |
405 |
406 |
407 | /**
408 | * Plugin install/activate URL
409 | */
410 | private function get_install_url($plugin) {
411 |
412 | // Check existing plugin
413 | $exists = @file_exists(WP_PLUGIN_DIR.'/'.$plugin);
414 |
415 | // Activate
416 | if ($exists) {
417 |
418 | // Existing plugin
419 | $path = $plugin.'/'.$this->suggestions[$plugin]['filename'];
420 | return admin_url('plugins.php?action=activate&plugin='.$path.'&_wpnonce='.wp_create_nonce('activate-plugin_'.$path));
421 |
422 | // Install
423 | } else {
424 |
425 | // New plugin
426 | return admin_url('update.php?action=install-plugin&plugin='.$plugin.'&_wpnonce='.wp_create_nonce('install-plugin_'.$plugin));
427 | }
428 | }
429 |
430 |
431 |
432 | /**
433 | * Determines the admin notices display
434 | */
435 | private function disable_nag_notices() {
436 | return (defined('DISABLE_NAG_NOTICES') && DISABLE_NAG_NOTICES);
437 | }
438 |
439 |
440 |
441 | // Plugin related
442 | // ---------------------------------------------------------------------------------------------------
443 |
444 |
445 |
446 | /**
447 | * Plugin uninstall hook
448 | */
449 | public static function uninstall() {
450 | $admin_notices = self::instance();
451 | $admin_notices->delete_activation_timestamp();
452 | $admin_notices->delete_dismissed_timestamp('suggestions');
453 | $admin_notices->delete_dismissed_timestamp('rate_us');
454 | }
455 |
456 |
457 |
458 | // Activation timestamp management
459 | // ---------------------------------------------------------------------------------------------------
460 |
461 |
462 |
463 | /**
464 | * Retrieves the plugin activation timestamp
465 | */
466 | private function get_activation_timestamp() {
467 | return (int) get_option($this->prefix.'_activated_on');
468 | }
469 |
470 |
471 |
472 | /**
473 | * Updates activation timestamp
474 | */
475 | private function update_activation_timestamp() {
476 | update_option($this->prefix.'_activated_on', time(), true);
477 | }
478 |
479 |
480 |
481 | /**
482 | * Removes activation timestamp
483 | */
484 | private function delete_activation_timestamp() {
485 | delete_option($this->prefix.'_activated_on');
486 | }
487 |
488 |
489 |
490 | // Dismissed timestamp management
491 | // ---------------------------------------------------------------------------------------------------
492 |
493 |
494 |
495 | /**
496 | * Current timestamp by key
497 | */
498 | private function get_dismissed_timestamp($key) {
499 | return (int) get_option($this->prefix.'_dismissed_'.$key.'_on');
500 | }
501 |
502 |
503 |
504 | /**
505 | * Update with the current timestamp
506 | */
507 | private function update_dismissed_timestamp($key) {
508 | update_option($this->prefix.'_dismissed_'.$key.'_on', time(), true);
509 | }
510 |
511 |
512 |
513 | /**
514 | * Removes dismissied option
515 | */
516 | private function delete_dismissed_timestamp($key) {
517 | delete_option($this->prefix.'_dismissed_'.$key.'_on');
518 | }
519 |
520 |
521 |
522 | // Javascript code
523 | // ---------------------------------------------------------------------------------------------------
524 |
525 |
526 |
527 | /**
528 | * Footer script for Suggestions
529 | */
530 | public function admin_footer_suggestions() { ?>
531 |
532 |
546 |
547 |
555 |
556 |
570 |
571 | {$key} = $value;
640 | }
641 |
642 | // Done
643 | return true;
644 | }
645 |
646 |
647 |
648 | }
--------------------------------------------------------------------------------
/notices/boot-check-php.php:
--------------------------------------------------------------------------------
1 | =')) {
42 | unset($ltbConfig);
43 | return;
44 | }
45 |
46 | // Debug point
47 | /* error_log('boot-check-hp ini '.time());
48 | error_log($_SERVER['REQUEST_URI']);
49 | error_log(print_r($_REQUEST, true));
50 | error_log('boot-check-php end '.time()); */
51 |
52 | // Plugin name
53 | $pluginDir = defined('WP_PLUGIN_DIR')? WP_PLUGIN_DIR : dirname(dirname(dirname(__FILE__)));
54 | $pluginData = function_exists('get_plugin_data')? get_plugin_data($pluginDir.'/'.$_REQUEST['plugin']) : null;
55 | $pluginName = (!empty($pluginData) && is_array($pluginData) && !empty($pluginData['Name']))? $pluginData['Name'] : basename(dirname($_REQUEST['plugin']));
56 |
57 | // Prepare message
58 | $ltbMessage = $ltbConfig['boot-check-php']['version-message'];
59 | $ltbMessage = str_replace('%plugin%', $pluginName, $ltbMessage);
60 | $ltbMessage = str_replace('%php_current_version%', PHP_VERSION, $ltbMessage);
61 | $ltbMessage = str_replace('%php_version_required%', $ltbConfig['boot-check-php']['version-required'], $ltbMessage);
62 |
63 | // Unset unused
64 | unset($ltbConfig);
65 | unset($pluginDir);
66 | unset($pluginData);
67 | unset($pluginName);
68 |
69 | // Force PHP error
70 | trigger_error($ltbMessage, E_USER_ERROR);
71 |
72 | // Exit to avoid custom error handlers using `return true;`
73 | die($ltbMessage);
--------------------------------------------------------------------------------
/plugin.php:
--------------------------------------------------------------------------------
1 | "Decisions, not options." — WordPress.org
28 |
29 | > "Everything should be made as simple as possible, but not simpler." — Albert Einstein, et al
30 |
31 | > "Write programs that do one thing and do it well... write programs to work together." — Doug McIlroy
32 |
33 | > "The innovation that this industry talks about so much is bullshit. Anybody can innovate... 99% of it is 'get the work done.' The real work is in the details." — Linus Torvalds
34 |
35 | ### Support Issues
36 |
37 | Please do not submit Pull Requests. Instead, kindly create a new Issue with relevant information if you are an experienced developer, otherwise you may become a [**LittleBizzy.com Member**](https://www.littlebizzy.com/members) if your company requires official support.
38 |
--------------------------------------------------------------------------------
/readme.txt:
--------------------------------------------------------------------------------
1 | === Plugin Name ===
2 |
3 | Contributors: littlebizzy
4 | Donate link: https://www.patreon.com/littlebizzy
5 | Tags: five, keywords, separated, by, commas
6 | Requires at least: 4.4
7 | Tested up to: 5.0
8 | Requires PHP: 7.2
9 | Multisite support: No
10 | Stable tag: 1.2.3
11 | License: GPLv3
12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html
13 | Text Domain: plugin-name-littlebizzy
14 | Domain Path: /lang
15 | Prefix: ABCXYZ
16 |
17 | Description of the plugin goes here, limited to 150 characters or less and should be a single well-written sentence that includes some of your most important keywords.
18 |
19 | == Description ==
20 |
21 | Description of the plugin goes here, limited to 150 characters or less and should be a single well-written sentence that includes some of your most important keywords.
22 |
23 | * [**Join our FREE Facebook group for support**](https://www.facebook.com/groups/littlebizzy/)
24 | * [**Worth a 5-star review? Thank you!**](https://wordpress.org/support/plugin/example-littlebizzy/reviews/?rate=5#new-post)
25 | * [Plugin Homepage](https://www.littlebizzy.com/plugins/disable-emojis)
26 | * [Plugin GitHub](https://github.com/littlebizzy/disable-emojis)
27 | * [SlickStack](https://slickstack.io)
28 |
29 | #### The Long Version ####
30 |
31 | Here you can place a longer description of the plugin and its features, separated into paragraphs.
32 |
33 | code snippet is indented with four spaces;
34 |
35 | #### Compatibility ####
36 |
37 | This plugin has been designed for use on LEMP (Nginx) web servers with PHP 7.0 and MySQL 5.7 to achieve best performance. All of our plugins are meant for single site WordPress installations only; for both performance and security reasons, we highly recommend against using WordPress Multisite for the vast majority of projects.
38 |
39 | Note: Any WordPress plugin may also be loaded as "Must-Use" by using the [Autoloader](https://github.com/littlebizzy/autoloader) script within the `mu-plugins` directory.
40 |
41 | #### Defined Constants ####
42 |
43 | The following defined constants are supported by this plugin:
44 |
45 | * `define('DISABLE_NAG_NOTICES', true);`
46 |
47 | Why no quotes? Adding quotes evaluates the 'false' or "false" values as a string, and the boolean evaluation of any string returns true (except for empty strings).
48 |
49 | It is a little bit weird but PHP works this way because it does not require strong data typing. There are special operatos (the triple equality ===) to ensure the right data type, but adds complexity and it is used normally where you are not sure of the input variable data type.
50 |
51 | It is true that there are constants that expects both boolean and string values, but the important thing here is that the false value does not contain quotes, e.g.:
52 |
53 | define('DISABLE_CART_FRAGMENTS', true);
54 | define('DISABLE_CART_FRAGMENTS', false);
55 | define('DISABLE_CART_FRAGMENTS', '123,456,789');
56 |
57 | #### Plugin Features ####
58 |
59 | * Parent Plugin: [**SEO Genius**](https://www.littlebizzy.com/plugins/seo-genius)
60 | * Disable Nag Notices: [[Yes](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices#Disable_Nag_Notices)]
61 | * Settings Page: No
62 | * PHP Namespaces: Yes
63 | * Object-Oriented Code: Yes
64 | * Includes Media (images, icons, etc): No
65 | * Includes CSS: No
66 | * Database Storage: Yes
67 | * Transients: No
68 | * WP Options Table: Yes
69 | * Other Tables: No
70 | * Creates New Tables: No
71 | * Database Queries: Backend Only
72 | * Query Types: Options API
73 | * Multisite Support: No
74 | * Uninstalls Data: Yes
75 |
76 | #### Inspiration ####
77 |
78 | * [Some Name](https://wordpress.org/plugins/plugin-name/)
79 | * [Another Name](https://wordpress.org/plugins/plugin-name/)
80 |
81 | #### Special Thanks ####
82 |
83 | [Alex Georgiou](https://www.alexgeorgiou.gr), [Automattic](https://automattic.com), [Brad Touesnard](https://bradt.ca), [Daniel Auener](http://www.danielauener.com), [Delicious Brains](https://deliciousbrains.com), [Greg Rickaby](https://gregrickaby.com), [Matt Mullenweg](https://ma.tt), [Mika Epstein](https://halfelf.org), [Mike Garrett](https://mikengarrett.com), [Samuel Wood](http://ottopress.com), [Scott Reilly](http://coffee2code.com), [Jan Dembowski](https://profiles.wordpress.org/jdembowski), [Jeff Starr](https://perishablepress.com), [Jeff Chandler](https://jeffc.me), [Jeff Matson](https://jeffmatson.net), [Jeremy Wagner](https://jeremywagner.me), [John James Jacoby](https://jjj.blog), [Leland Fiegel](https://leland.me), [Luke Cavanagh](https://github.com/lukecav), [Mike Jolley](https://mikejolley.com), [Pau Iglesias](https://pauiglesias.com), [Paul Irish](https://www.paulirish.com), [Rahul Bansal](https://profiles.wordpress.org/rahul286), [Roots](https://roots.io), [rtCamp](https://rtcamp.com), [Ryan Hellyer](https://geek.hellyer.kiwi), [WP Chat](https://wpchat.com), [WP Tavern](https://wptavern.com)
84 |
85 | #### Disclaimer ####
86 |
87 | We released this plugin in response to our managed hosting clients asking for better access to their server, and our primary goal will remain supporting that purpose. Although we are 100% open to fielding requests from the WordPress community, we kindly ask that you keep the above-mentioned goals in mind... thanks!
88 |
89 | #### Keywords ####
90 |
91 | * Terms:
92 |
93 | * Phrases:
94 |
95 | * Plugins:
96 |
97 | ### Philosophy ####
98 |
99 | Inspired by the likes of Unix and W. Edwards Deming, we believe in creating high quality software "components" that can stand on their own, or be integrated into other software. At a certain point, this approach has practical limits, which is why we are beginning to combine certain features into premium plugins. Still, we aim to reduce redundancy wherever possible, and present a unified UI in our premium plugins that in fact combines multiple small indepdent functions behind the scenes.
100 | https://www.johndcook.com/blog/2010/06/30/where-the-unix-philosophy-breaks-down/
101 |
102 | == Installation ==
103 |
104 | 1. Upload to `/wp-content/plugins/some-name-littlebizzy`
105 | 2. Activate via WP Admin > Plugins
106 | 3. Test plugin is working
107 |
108 | == Frequently Asked Questions ==
109 |
110 | = How can I change this plugin's settings? =
111 |
112 | There is a settings page where you can exclude certain types of query strings.
113 |
114 | = I have a suggestion, how can I let you know? =
115 |
116 | Please avoid leaving negative reviews in order to get a feature implemented. Instead, we kindly ask that you post your feedback on the wordpress.org support forums by tagging this plugin in your post. If needed, you may also contact our homepage.
117 |
118 | == Changelog ==
119 |
120 | = 1.1.1 =
121 |
122 | * Moved context method to Plugin class and removed from Factory class
123 | * New enabled method in Plugin class for quick plugin constant checks
124 | * Minor structure changes in Context class
125 |
126 | = 1.1.0 =
127 | * major changes/new features
128 | * tested with PHP 7.1
129 | * tested with PHP 7.2
130 |
131 | = 1.0.1 =
132 | * minor tweaks/patches
133 |
134 | = 1.0.0 =
135 | * initial release
136 | * tested with PHP 7.0
137 | * uses PHP namespaces
138 | * object-oriented codebase
139 |
--------------------------------------------------------------------------------