PluginProbe ʕ •ᴥ•ʔ
Export/Import Media – CSV Media Library Import & Export / 1.7
Export/Import Media – CSV Media Library Import & Export v1.7
1.7.28 1.7.27 1.7.20 1.7.26 1.7.10 1.7.9 1.7.1 1.7 trunk 1.0 1.0.3 1.2.1 1.2.2 1.2.3 1.6.15 1.6.4
calliope-media-import-export / export-import-media.php
calliope-media-import-export Last commit date
admin 2 months ago assets 2 months ago includes 2 months ago languages 2 months ago export-import-media.php 2 months ago readme.txt 2 months ago
export-import-media.php
226 lines
1 <?php
2 /*
3 Plugin Name: Export/Import Media
4 Description: CSV export/import for your media library with preview, batch processing, duplicate prevention, and core metadata columns.
5 Version: 1.7
6 Requires at least: 5.6
7 Requires PHP: 7.4
8 Author: CalliopeWP
9 Author URI: https://pluginswordpress.calliope.com.ar/
10 License: GPLv2 or later
11 Text Domain: calliope-media-import-export
12 Domain Path: /languages
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 // Prevent fatal errors when two copies of the plugin are loaded at the same time.
20 if ( defined( 'EIM_BOOTSTRAPPED_FILE' ) ) {
21 return;
22 }
23
24 define( 'EIM_BOOTSTRAPPED_FILE', __FILE__ );
25
26 if ( ! defined( 'EIM_FILE' ) ) {
27 define( 'EIM_FILE', __FILE__ );
28 }
29
30 if ( ! defined( 'EIM_VERSION' ) ) {
31 define( 'EIM_VERSION', '1.7' );
32 }
33
34 if ( ! defined( 'EIM_PUBLIC_SLUG' ) ) {
35 define( 'EIM_PUBLIC_SLUG', 'calliope-media-import-export' );
36 }
37
38 if ( ! defined( 'EIM_TEXT_DOMAIN' ) ) {
39 define( 'EIM_TEXT_DOMAIN', 'calliope-media-import-export' );
40 }
41
42 if ( ! defined( 'EIM_ADMIN_PAGE_SLUG' ) ) {
43 define( 'EIM_ADMIN_PAGE_SLUG', 'export-import-media' );
44 }
45
46 if ( ! defined( 'EIM_PATH' ) ) {
47 define( 'EIM_PATH', plugin_dir_path( EIM_FILE ) );
48 }
49
50 if ( ! defined( 'EIM_URL' ) ) {
51 define( 'EIM_URL', plugin_dir_url( EIM_FILE ) );
52 }
53
54 if ( ! defined( 'EIM_BASENAME' ) ) {
55 define( 'EIM_BASENAME', plugin_basename( EIM_FILE ) );
56 }
57
58 require_once EIM_PATH . 'includes/class-config.php';
59 require_once EIM_PATH . 'includes/class-eim-service-registry.php';
60
61 if ( ! function_exists( 'eim_get_setting' ) ) {
62 /**
63 * Get a plugin setting using dot notation.
64 *
65 * @param string $path Dot notation path.
66 * @param mixed $default Default value when setting does not exist.
67 * @return mixed
68 */
69 function eim_get_setting( $path, $default = null ) {
70 return EIM_Config::get( $path, $default );
71 }
72 }
73
74 if ( ! function_exists( 'eim_get_public_slug' ) ) {
75 /**
76 * Get the canonical public plugin slug.
77 *
78 * @return string
79 */
80 function eim_get_public_slug() {
81 return (string) apply_filters( 'eim_public_slug', EIM_PUBLIC_SLUG );
82 }
83 }
84
85 if ( ! function_exists( 'eim_get_required_capability' ) ) {
86 /**
87 * Capability required to access plugin features.
88 *
89 * Filterable so future extensions can align permissions without forking core.
90 *
91 * @return string
92 */
93 function eim_get_required_capability() {
94 $default = eim_get_setting( 'required_capability', 'manage_options' );
95 $capability = apply_filters( 'eim_required_capability', $default );
96
97 if ( ! is_string( $capability ) || '' === trim( $capability ) ) {
98 return 'manage_options';
99 }
100
101 return trim( $capability );
102 }
103 }
104
105 if ( ! function_exists( 'eim_current_user_can_manage' ) ) {
106 /**
107 * Check whether the current user can access the plugin.
108 *
109 * @return bool
110 */
111 function eim_current_user_can_manage() {
112 return current_user_can( eim_get_required_capability() );
113 }
114 }
115
116 if ( ! function_exists( 'eim_is_pro_active' ) ) {
117 /**
118 * Whether a Pro add-on is active.
119 *
120 * The add-on can define a constant or use the filter to report itself.
121 *
122 * @return bool
123 */
124 function eim_is_pro_active() {
125 $is_active = (
126 defined( 'EIM_PRO_VERSION' ) ||
127 defined( 'EXPORT_IMPORT_MEDIA_PRO_VERSION' ) ||
128 class_exists( 'EIM_Pro_Plugin', false ) ||
129 class_exists( 'EIM_Pro_Bootstrap', false )
130 );
131
132 return (bool) apply_filters( 'eim_is_pro_active', $is_active );
133 }
134 }
135
136 if ( ! function_exists( 'eim_is_feature_enabled' ) ) {
137 /**
138 * Check whether a feature flag is enabled.
139 *
140 * @param string $feature Feature slug.
141 * @return bool
142 */
143 function eim_is_feature_enabled( $feature ) {
144 $feature = sanitize_key( (string) $feature );
145 if ( '' === $feature ) {
146 return false;
147 }
148
149 $flags = EIM_Config::get_feature_flags();
150 $enabled = ! empty( $flags[ $feature ] );
151
152 return (bool) apply_filters( 'eim_is_feature_enabled', $enabled, $feature, $flags );
153 }
154 }
155
156 if ( ! function_exists( 'eim_get_service' ) ) {
157 /**
158 * Fetch a bootstrapped plugin service.
159 *
160 * @param string|null $service Service key. Pass null to retrieve the full map.
161 * @return mixed|null
162 */
163 function eim_get_service( $service = null ) {
164 $services = EIM_Service_Registry::all();
165
166 if ( null === $service || '' === $service ) {
167 return $services;
168 }
169
170 return EIM_Service_Registry::get( $service );
171 }
172 }
173
174 if ( ! class_exists( 'EIM_Importer', false ) ) {
175 require_once EIM_PATH . 'includes/class-importer.php';
176 }
177
178 if ( ! class_exists( 'EIM_Admin', false ) ) {
179 require_once EIM_PATH . 'admin/class-admin.php';
180 }
181
182 if ( ! class_exists( 'EIM_Exporter', false ) ) {
183 require_once EIM_PATH . 'includes/class-exporter.php';
184 }
185
186
187 if ( ! function_exists( 'eim_init_plugin' ) ) {
188 /**
189 * Bootstrap plugin services.
190 */
191 function eim_init_plugin() {
192 static $booted = false;
193
194 if ( $booted ) {
195 return;
196 }
197
198 $booted = true;
199
200 $services = [];
201
202 if ( class_exists( 'EIM_Admin' ) ) {
203 $services['admin'] = new EIM_Admin();
204 }
205
206 if ( class_exists( 'EIM_Importer' ) ) {
207 $services['importer'] = new EIM_Importer();
208 }
209
210 if ( class_exists( 'EIM_Exporter' ) ) {
211 $services['exporter'] = new EIM_Exporter();
212 }
213
214 EIM_Service_Registry::set_services( $services );
215
216 do_action( 'eim_plugin_ready', $services );
217 }
218 }
219
220 add_action( 'plugins_loaded', 'eim_init_plugin' );
221
222 if ( class_exists( 'EIM_Importer' ) ) {
223 register_activation_hook( EIM_FILE, [ 'EIM_Importer', 'activate_plugin' ] );
224 register_deactivation_hook( EIM_FILE, [ 'EIM_Importer', 'deactivate_plugin' ] );
225 }
226