PluginProbe ʕ •ᴥ•ʔ
Export/Import Media – CSV Media Library Import & Export / 1.6.15
Export/Import Media – CSV Media Library Import & Export v1.6.15
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 REPO_PREP_NOTES.txt 2 months ago export-import-media.php 2 months ago readme.txt 2 months ago
export-import-media.php
229 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.6.15
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.6.15' );
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
60 if ( ! function_exists( 'eim_get_setting' ) ) {
61 /**
62 * Get a plugin setting using dot notation.
63 *
64 * @param string $path Dot notation path.
65 * @param mixed $default Default value when setting does not exist.
66 * @return mixed
67 */
68 function eim_get_setting( $path, $default = null ) {
69 return EIM_Config::get( $path, $default );
70 }
71 }
72
73 if ( ! function_exists( 'eim_get_public_slug' ) ) {
74 /**
75 * Get the canonical public plugin slug.
76 *
77 * @return string
78 */
79 function eim_get_public_slug() {
80 return (string) apply_filters( 'eim_public_slug', EIM_PUBLIC_SLUG );
81 }
82 }
83
84 if ( ! function_exists( 'eim_get_required_capability' ) ) {
85 /**
86 * Capability required to access plugin features.
87 *
88 * Filterable so future extensions can align permissions without forking core.
89 *
90 * @return string
91 */
92 function eim_get_required_capability() {
93 $default = eim_get_setting( 'required_capability', 'manage_options' );
94 $capability = apply_filters( 'eim_required_capability', $default );
95
96 if ( ! is_string( $capability ) || '' === trim( $capability ) ) {
97 return 'manage_options';
98 }
99
100 return trim( $capability );
101 }
102 }
103
104 if ( ! function_exists( 'eim_current_user_can_manage' ) ) {
105 /**
106 * Check whether the current user can access the plugin.
107 *
108 * @return bool
109 */
110 function eim_current_user_can_manage() {
111 return current_user_can( eim_get_required_capability() );
112 }
113 }
114
115 if ( ! function_exists( 'eim_is_pro_active' ) ) {
116 /**
117 * Whether a Pro add-on is active.
118 *
119 * The add-on can define a constant or use the filter to report itself.
120 *
121 * @return bool
122 */
123 function eim_is_pro_active() {
124 $is_active = (
125 defined( 'EIM_PRO_VERSION' ) ||
126 defined( 'EXPORT_IMPORT_MEDIA_PRO_VERSION' ) ||
127 class_exists( 'EIM_Pro_Plugin', false ) ||
128 class_exists( 'EIM_Pro_Bootstrap', false )
129 );
130
131 return (bool) apply_filters( 'eim_is_pro_active', $is_active );
132 }
133 }
134
135 if ( ! function_exists( 'eim_is_feature_enabled' ) ) {
136 /**
137 * Check whether a feature flag is enabled.
138 *
139 * @param string $feature Feature slug.
140 * @return bool
141 */
142 function eim_is_feature_enabled( $feature ) {
143 $feature = sanitize_key( (string) $feature );
144 if ( '' === $feature ) {
145 return false;
146 }
147
148 $flags = EIM_Config::get_feature_flags();
149 $enabled = ! empty( $flags[ $feature ] );
150
151 return (bool) apply_filters( 'eim_is_feature_enabled', $enabled, $feature, $flags );
152 }
153 }
154
155 if ( ! function_exists( 'eim_get_service' ) ) {
156 /**
157 * Fetch a bootstrapped plugin service.
158 *
159 * @param string|null $service Service key. Pass null to retrieve the full map.
160 * @return mixed|null
161 */
162 function eim_get_service( $service = null ) {
163 $services = isset( $GLOBALS['eim_services'] ) && is_array( $GLOBALS['eim_services'] )
164 ? $GLOBALS['eim_services']
165 : [];
166
167 if ( null === $service || '' === $service ) {
168 return $services;
169 }
170
171 $service = sanitize_key( (string) $service );
172
173 return isset( $services[ $service ] ) ? $services[ $service ] : null;
174 }
175 }
176
177 if ( ! class_exists( 'EIM_Importer', false ) ) {
178 require_once EIM_PATH . 'includes/class-importer.php';
179 }
180
181 if ( ! class_exists( 'EIM_Admin', false ) ) {
182 require_once EIM_PATH . 'admin/class-admin.php';
183 }
184
185 if ( ! class_exists( 'EIM_Exporter', false ) ) {
186 require_once EIM_PATH . 'includes/class-exporter.php';
187 }
188
189
190 if ( ! function_exists( 'eim_init_plugin' ) ) {
191 /**
192 * Bootstrap plugin services.
193 */
194 function eim_init_plugin() {
195 static $booted = false;
196
197 if ( $booted ) {
198 return;
199 }
200
201 $booted = true;
202
203 $services = [];
204
205 if ( class_exists( 'EIM_Admin' ) ) {
206 $services['admin'] = new EIM_Admin();
207 }
208
209 if ( class_exists( 'EIM_Importer' ) ) {
210 $services['importer'] = new EIM_Importer();
211 }
212
213 if ( class_exists( 'EIM_Exporter' ) ) {
214 $services['exporter'] = new EIM_Exporter();
215 }
216
217 $GLOBALS['eim_services'] = $services;
218
219 do_action( 'eim_plugin_ready', $services );
220 }
221 }
222
223 add_action( 'plugins_loaded', 'eim_init_plugin' );
224
225 if ( class_exists( 'EIM_Importer' ) ) {
226 register_activation_hook( EIM_FILE, [ 'EIM_Importer', 'activate_plugin' ] );
227 register_deactivation_hook( EIM_FILE, [ 'EIM_Importer', 'deactivate_plugin' ] );
228 }
229