| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* |
| 5 |
* @link https://magic-post-thumbnail.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* @package Magic_Post_Thumbnail |
| 8 |
* |
| 9 |
* @wordpress-plugin |
| 10 |
* Plugin Name: Magic Post Thumbnail |
| 11 |
* Plugin URI: http://wordpress.org/plugins/magic-post-thumbnail/ |
| 12 |
* Description: Add stunning images to your posts effortlessly, as featured images or within content. Magic Post Thumbnail sources them automatically from multiple image banks. |
| 13 |
* Version: 6.1.8 |
| 14 |
* Author: Magic Post Thumbnail |
| 15 |
* Author URI: https://magic-post-thumbnail.com/ |
| 16 |
* License: GPL-2.0+ |
| 17 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 18 |
* Text Domain: magic-post-thumbnail |
| 19 |
* Domain Path: /languages |
| 20 |
* |
| 21 |
* |
| 22 |
* |
| 23 |
* |
| 24 |
*/ |
| 25 |
// If this file is called directly, abort. |
| 26 |
if ( !defined( 'WPINC' ) ) { |
| 27 |
die; |
| 28 |
} |
| 29 |
if ( function_exists( 'mpt_freemius' ) ) { |
| 30 |
mpt_freemius()->set_basename( false, __FILE__ ); |
| 31 |
} else { |
| 32 |
if ( !function_exists( 'mpt_freemius' ) ) { |
| 33 |
function mpt_freemius() { |
| 34 |
global $mpt_freemius; |
| 35 |
if ( !isset( $mpt_freemius ) ) { |
| 36 |
// Include Freemius SDK. |
| 37 |
require_once dirname( __FILE__ ) . '/admin/partials/freemius/start.php'; |
| 38 |
$mpt_freemius = fs_dynamic_init( array( |
| 39 |
'id' => '2891', |
| 40 |
'slug' => 'magic-post-thumbnail', |
| 41 |
'type' => 'plugin', |
| 42 |
'public_key' => 'pk_0842b408e487a0001e564a31d3a37', |
| 43 |
'is_premium' => false, |
| 44 |
'premium_suffix' => 'Pro', |
| 45 |
'has_addons' => false, |
| 46 |
'has_paid_plans' => true, |
| 47 |
'has_affiliation' => 'selected', |
| 48 |
'is_org_compliant' => true, |
| 49 |
'menu' => array( |
| 50 |
'slug' => 'magic-post-thumbnail-admin-display', |
| 51 |
'first-path' => 'admin.php?page=magic-post-thumbnail-admin-display', |
| 52 |
'contact' => false, |
| 53 |
'support' => false, |
| 54 |
'affiliation' => false, |
| 55 |
'account' => false, |
| 56 |
'addons' => false, |
| 57 |
), |
| 58 |
'navigation' => 'tabs', |
| 59 |
'is_live' => true, |
| 60 |
) ); |
| 61 |
} |
| 62 |
return $mpt_freemius; |
| 63 |
} |
| 64 |
|
| 65 |
// Init Freemius. |
| 66 |
mpt_freemius(); |
| 67 |
// Signal that SDK was initiated. |
| 68 |
do_action( 'mpt_freemius_loaded' ); |
| 69 |
} |
| 70 |
/** |
| 71 |
* Currently plugin version. |
| 72 |
* Start at version 1.0.0 and use SemVer - https://semver.org |
| 73 |
* Rename this for your plugin and update it as you release new versions. |
| 74 |
*/ |
| 75 |
define( 'MAGIC_POST_THUMBNAIL_VERSION', '6.1.8' ); |
| 76 |
/** |
| 77 |
* The code that runs during plugin activation. |
| 78 |
* This action is documented in includes/class-magic-post-thumbnail-activator.php |
| 79 |
*/ |
| 80 |
function activate_magic_post_thumbnail() { |
| 81 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-magic-post-thumbnail-activator.php'; |
| 82 |
Magic_Post_Thumbnail_Activator::activate(); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* The code that runs during plugin deactivation. |
| 87 |
* This action is documented in includes/class-magic-post-thumbnail-deactivator.php |
| 88 |
*/ |
| 89 |
function deactivate_magic_post_thumbnail() { |
| 90 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-magic-post-thumbnail-deactivator.php'; |
| 91 |
Magic_Post_Thumbnail_Deactivator::deactivate(); |
| 92 |
} |
| 93 |
|
| 94 |
register_activation_hook( __FILE__, 'activate_magic_post_thumbnail' ); |
| 95 |
register_deactivation_hook( __FILE__, 'deactivate_magic_post_thumbnail' ); |
| 96 |
/** |
| 97 |
* The core plugin class that is used to define internationalization, |
| 98 |
* admin-specific hooks, and public-facing site hooks. |
| 99 |
*/ |
| 100 |
require plugin_dir_path( __FILE__ ) . 'includes/class-magic-post-thumbnail.php'; |
| 101 |
/** |
| 102 |
* Add capabilities |
| 103 |
*/ |
| 104 |
function MPT_add_capability() { |
| 105 |
$options = get_option( 'MPT_plugin_rights_settings' ); |
| 106 |
// Administrators always have the capability |
| 107 |
$admin_role = get_role( 'administrator' ); |
| 108 |
if ( $admin_role ) { |
| 109 |
$admin_role->add_cap( 'mpt_manage', true ); |
| 110 |
} |
| 111 |
// Manage other roles by adding or removing capabilities according to options |
| 112 |
$roles = array( |
| 113 |
'editor' => 'rights_editor', |
| 114 |
'author' => 'rights_author', |
| 115 |
'contributor' => 'rights_contributor', |
| 116 |
'subscriber' => 'rights_subscriber', |
| 117 |
); |
| 118 |
foreach ( $roles as $role_name => $option_key ) { |
| 119 |
$role = get_role( $role_name ); |
| 120 |
if ( $role ) { |
| 121 |
if ( isset( $options[$option_key] ) && $options[$option_key] === 'true' ) { |
| 122 |
// Adds capacity if the option is enabled |
| 123 |
$role->add_cap( 'mpt_manage', true ); |
| 124 |
} else { |
| 125 |
// Removes the capacity if the option is deactivated |
| 126 |
$role->remove_cap( 'mpt_manage' ); |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Check hook wp_insert_post to fire functionalities |
| 134 |
* |
| 135 |
* @since 6.0.0 |
| 136 |
*/ |
| 137 |
function MPT_check_hook() { |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Check capabilities before launching the plugin main features |
| 142 |
* |
| 143 |
* @since 5.0.0 |
| 144 |
*/ |
| 145 |
function MPT_check_capability() { |
| 146 |
$additional_check = false; |
| 147 |
// add capability for the cron |
| 148 |
if ( wp_doing_cron() || true == $additional_check ) { |
| 149 |
global $current_user; |
| 150 |
$current_user->add_cap( 'mpt_manage' ); |
| 151 |
} |
| 152 |
if ( current_user_can( 'mpt_manage' ) ) { |
| 153 |
$plugin = new Magic_Post_Thumbnail(); |
| 154 |
$plugin->run(); |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* Begins execution of the plugin. |
| 160 |
* |
| 161 |
* Since everything within the plugin is registered via hooks, |
| 162 |
* then kicking off the plugin from this point in the file does |
| 163 |
* not affect the page life cycle. |
| 164 |
* |
| 165 |
* @since 4.0.0 |
| 166 |
*/ |
| 167 |
function run_magic_post_thumbnail() { |
| 168 |
// User role & capacity |
| 169 |
add_action( 'init', 'MPT_add_capability', 1 ); |
| 170 |
add_action( 'init', 'MPT_check_capability', 2 ); |
| 171 |
// Features with hooks |
| 172 |
add_action( 'init', 'MPT_check_hook', 5 ); |
| 173 |
} |
| 174 |
|
| 175 |
run_magic_post_thumbnail(); |
| 176 |
// Fired when the plugin is uninstalled. |
| 177 |
mpt_freemius()->add_action( 'after_uninstall', 'mpt_freemius_uninstall_cleanup' ); |
| 178 |
function mpt_freemius_uninstall_cleanup() { |
| 179 |
// Remove logs |
| 180 |
define( "MPT_FREEMIUS_UNINSTALL", true ); |
| 181 |
require_once dirname( __FILE__ ) . '/admin/partials/delete_log.php'; |
| 182 |
// Delete all plugin options |
| 183 |
delete_option( 'MPT_plugin_posts_settings' ); |
| 184 |
delete_option( 'MPT_plugin_main_settings' ); |
| 185 |
delete_option( 'MPT_plugin_banks_settings' ); |
| 186 |
delete_option( 'MPT_plugin_interval_settings' ); |
| 187 |
delete_option( 'MPT_plugin_cron_settings' ); |
| 188 |
delete_option( 'MPT_plugin_rights_settings' ); |
| 189 |
delete_option( 'MPT_plugin_proxy_settings' ); |
| 190 |
delete_option( 'MPT_plugin_compatibility_settings' ); |
| 191 |
delete_option( 'MPT_plugin_logs_settings' ); |
| 192 |
} |
| 193 |
|
| 194 |
} |