PluginProbe
Generate Images (AI) – Magic Post Thumbnail / 7.0.0
Generate Images (AI) – Magic Post Thumbnail v7.0.0
7.0.1 7.0.0 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.2.0 6.2.1 6.2.2 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 2.0 2.1 2.1.1 2.2 2.2.1 2.3 All 115 releases
magic-post-thumbnail / magic-post-thumbnail.php

magic-post-thumbnail.php in Generate Images (AI) – Magic Post Thumbnail 7.0.0, at magic-post-thumbnail.php

174 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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: Generate featured and in-content images from Bing, GPT Image, Unsplash and more — automatically, in bulk, or from Gutenberg.
13 * Version: 7.0.0
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', '7.0.0' );
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 * Boot automation always; admin UI only for users with mpt_manage.
134 *
135 * @since 7.0.0
136 */
137 function MPT_boot_plugin() {
138 $plugin = new Magic_Post_Thumbnail();
139 $plugin->run_automation();
140 if ( is_admin() && current_user_can( 'mpt_manage' ) ) {
141 $plugin->run();
142 }
143 }
144
145 /**
146 * Begins execution of the plugin.
147 *
148 * @since 4.0.0
149 */
150 function run_magic_post_thumbnail() {
151 add_action( 'init', 'MPT_add_capability', 1 );
152 add_action( 'init', 'MPT_boot_plugin', 2 );
153 }
154
155 run_magic_post_thumbnail();
156 // Fired when the plugin is uninstalled.
157 mpt_freemius()->add_action( 'after_uninstall', 'mpt_freemius_uninstall_cleanup' );
158 function mpt_freemius_uninstall_cleanup() {
159 define( 'MPT_FREEMIUS_UNINSTALL', true );
160 require_once dirname( __FILE__ ) . '/admin/partials/delete_log.php';
161 delete_option( 'MPT_plugin_posts_settings' );
162 delete_option( 'MPT_plugin_main_settings' );
163 delete_option( 'MPT_plugin_banks_settings' );
164 delete_option( 'MPT_plugin_interval_settings' );
165 delete_option( 'MPT_plugin_cron_settings' );
166 delete_option( 'MPT_plugin_rights_settings' );
167 delete_option( 'MPT_plugin_proxy_settings' );
168 delete_option( 'MPT_plugin_compatibility_settings' );
169 delete_option( 'MPT_plugin_logs_settings' );
170 delete_option( 'mpt_logs_dirname' );
171 delete_option( 'mpt_hook_checked' );
172 }
173
174 }