-
Notifications
You must be signed in to change notification settings - Fork 0
/
smart-featured-image.php
64 lines (54 loc) · 1.66 KB
/
smart-featured-image.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @wordpress-plugin
* Plugin Name: Smart Featured Image
* Plugin URI: https://www.grottopress.com/tutorials/smart-featured-image-wordpress-plugin/
* Description: Automagically add featured image to posts using images inserted into post content. Displays a configurable default image if none found.
* Version: 0.3.0
* Author: GrottoPress.com
* Author URI: https://www.grottopress.com
* License: MIT
* License URI: https://opensource.org/licenses/MIT
* Text Domain: smart-featured-image
* Domain Path: /lang
* Requires at least: 5.3
* Requires PHP: 7.0
*/
/**
* IMPORTANT: Keep code in this file compatible with PHP 5.2
*/
defined('WPINC') || exit(1);
require __DIR__.'/constants.php';
if (version_compare(PHP_VERSION, SFI_MIN_PHP, '<') ||
version_compare(get_bloginfo('version'), SFI_MIN_WP, '<')
) {
add_action('admin_notices', 'printSmartFeaturedImageNotice');
deactivateSmartFeaturedImage();
} else {
require __DIR__.'/vendor/autoload.php';
add_action('plugins_loaded', 'runSmartFeaturedImage', 0);
}
function runSmartFeaturedImage()
{
SmartFeaturedImage()->run();
}
function printSmartFeaturedImageNotice()
{
echo '<div class="notice notice-error">
<p>'.
sprintf(
esc_html__(
'%1$s plugin has been deactivated as it requires PHP >= %2$s and WordPress >= %3$s',
'smart-featured-image'
),
'<code>smart-featured-image</code>',
'<strong>'.SFI_MIN_PHP.'</strong>',
'<strong>'.SFI_MIN_WP.'</strong>'
).
'</p>
</div>';
}
function deactivateSmartFeaturedImage()
{
deactivate_plugins(SFI_PLUGIN_BASENAME);
}