-
Notifications
You must be signed in to change notification settings - Fork 48
/
sell-media.php
executable file
·392 lines (350 loc) · 12.6 KB
/
sell-media.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?php
/**
* Plugin Name: Sell Media
* Plugin URI: http://graphpaperpress.com/plugins/sell-media/
* Description: A plugin for selling photos, prints and other downloads.
* Version: 2.5.8.5
* Author: Graph Paper Press
* Author URI: http://graphpaperpress.com
* Author Email: [email protected]
* Text Domain: sell_media
* Domain Path: languages
* License: GPL2
*
* Copyright 2023 GRAPH PAPER PRESS (email: [email protected])
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License or license.txt for more details.
*
* @package SellMedia
* @category Core
* @author Thad Allender
* @version 2.5.8.5
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'SellMedia' ) ) :
/**
* Main SellMedia Class (singleton).
*
* @since 1.8.5
*/
final class SellMedia extends \stdClass {
/**
* The single instance of the class.
*
* @var SellMedia There's only one instance
* @since 1.8.5
*/
private static $instance;
/**
* Sell_Media Customer Object.
*
* @var object
* @since 1.8.5
*/
public $customer;
/**
* Sell_Media Download Object.
*
* @var object
* @since 1.8.5
*/
public $download;
/**
* Sell_Media Images Object.
*
* @var object
* @since 1.8.5
*/
public $images;
/**
* Sell_Media Payments Object.
*
* @var object
* @since 1.8.5
*/
public $payments;
/**
* Sell_Media Products Object.
*
* @var object
* @since 1.8.5
*/
public $products;
/**
* Sell_Media Search Object.
*
* @var object
* @since 1.8.5
*/
public $search;
/**
* Main SellMedia Instance.
*
* Ensures that only one instance of SellMedia exists in memory.
*
* @since 1.8.5
* @static
* @staticvar array $instance
* @uses SellMedia::constants() Setup the constants needed
* @uses SellMedia::includes() Include the required files
* @uses SellMedia::textdomain() Load textdomain for translation
* @see SellMedia()
* @return The one, the only SellMedia
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof SellMedia ) ) {
self::$instance = new SellMedia;
self::$instance->constants();
self::$instance->includes();
self::$instance->textdomain();
self::$instance->session = new SellMediaSession();
self::$instance->customer = new SellMediaCustomer();
self::$instance->download = new SellMediaDownload();
self::$instance->images = new SellMediaImages();
self::$instance->layouts = new SellMediaLayouts();
self::$instance->mail = new SellMediaMail();
self::$instance->payments = new SellMediaPayments();
self::$instance->products = new SellMediaProducts();
self::$instance->queries = new SellMediaQueries();
self::$instance->search = new SellMediaSearch();
self::$instance->tax_markup = new SellMediaTaxMarkup();
self::$instance->upgrades = new SellMediaUpgrades();
if ( self::$instance->is_request( 'admin' ) ) {
self::$instance->notices = new SellMediaAdminNotices();
self::$instance->admin_search = new SellMediaAdminSearch();
self::$instance->price_listings = new Sell_Media_Price_Listings();
self::$instance->admin_add_item = new SellMediaAdminAddItem();
}
// Set cart global variable.
if ( self::$instance->is_request( 'frontend' ) ) {
$GLOBALS['sm_cart'] = new SellMediaCart();
}
}
return self::$instance;
}
/**
* Throw error on object clone.
*
* @since 1.8.5
* @access protected
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'sell_media' ), '2.5.8.5' );
}
/**
* Disable unserializing of the class.
*
* @since 1.8.5
* @access protected
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'sell_media' ), '2.5.8.5' );
}
/**
* Constants for the plugin.
*
* @access private
* @since 1.8.5
* @return void
*/
private function constants() {
// Plugin version.
if ( ! defined( 'SELL_MEDIA_VERSION' ) ) {
define( 'SELL_MEDIA_VERSION', '2.5.8.5' );
}
// Plugin Folder Path.
if ( ! defined( 'SELL_MEDIA_PLUGIN_DIR' ) ) {
define( 'SELL_MEDIA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder URL.
if ( ! defined( 'SELL_MEDIA_PLUGIN_URL' ) ) {
define( 'SELL_MEDIA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
// Plugin Root File.
if ( ! defined( 'SELL_MEDIA_PLUGIN_FILE' ) ) {
define( 'SELL_MEDIA_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'GPP_WP_KSES_SELL_MEDIA_LIST_UPLOADS' ) ) {
define( 'GPP_WP_KSES_SELL_MEDIA_LIST_UPLOADS', [
'ul' => [ 'data-*' => true, 'class' => true, 'id' => true ],
'li' => [ 'data-*' => true, 'class' => true, 'value' => true ],
'a' => [ 'data-*' => true, 'target' => true, 'href' => true, 'class' => true ],
'span' => [ 'data-*' => true, 'class' => true ],
'img' => [
'src' => true,
'srcset' => true,
'sizes' => true,
'class' => true,
'id' => true,
'width' => true,
'height' => true,
'alt' => true,
'align' => true,
'data-*' => true,
],
]);
}
if ( ! defined( 'GPP_WP_KSES_EXTENDED_LIST' ) ) {
define( 'GPP_WP_KSES_EXTENDED_LIST', [
'ul' => [ 'data-*' => true, 'class' => true, 'id' => true ],
'li' => [ 'data-*' => true, 'class' => true, 'value' => true ],
'a' => [ 'data-*' => true, 'target' => true, 'href' => true, 'class' => true, 'id' => true ],
'div' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'span' => [ 'class' => true, 'id' => true, 'data-*' => true, 'required' => true ],
'img' => [
'src' => true,
'srcset' => true,
'sizes' => true,
'class' => true,
'id' => true,
'width' => true,
'height' => true,
'alt' => true,
'align' => true,
'data-*' => true,
],
'script' => [ 'type' => true ],
'h6' => [ 'class' => true, 'id' => true ],
'form' => [ 'class' => true, 'id' => true, 'action' => 'true', 'method' => true ],
'input' => [ 'class' => true, 'id' => true, 'type' => true, 'value' => true, 'name' => true, 'min' => true, 'step' => true ],
'fieldset' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'select' => [ 'class' => true, 'id' => true, 'data-*' => true, 'required' => true ],
'option' => [ 'class' => true, 'id' => true, 'data-*' => true, 'selected' => true, 'title' => true, 'value' => true, 'name' => true ],
'button' => [ 'class' => true, 'id' => true, 'data-*' => true, 'disabled' => true, 'enabled' => true ],
'strong' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'p' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'table' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'tr' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'td' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'th' => [ 'class' => true, 'id' => true, 'data-*' => true ],
'style' => true
] );
}
}
/**
* What type of request is this?
* string $type ajax, frontend or admin.
*
* @return bool
*/
private function is_request( $type ) {
switch ( $type ) {
case 'admin' :
return is_admin();
case 'ajax' :
return defined( 'DOING_AJAX' );
case 'cron' :
return defined( 'DOING_CRON' );
case 'frontend' :
return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' );
}
}
/**
* Include required files.
*
* @access private
* @since 1.8.5
* @return void
*/
private function includes() {
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-session.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-customer.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-downloads.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-layouts.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-mail.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-payments.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-products.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-products-images.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-products-audio-video.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-queries.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-search.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/collections.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/emails.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/deprecated.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/fields.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/helpers.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/mime-types.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/scripts.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/shortcodes.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/template-tags.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/term-meta.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/user.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/widgets.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/settings/settings.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/settings.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/lightbox.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-tax-meta-migrate.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-tax-markup.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/gateways/paypal.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/gateways/class-sm-gateway-paypal-request.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/themes/theme-support/class-sm-theme-support.php';
// Load files if is front end.
if ( self::$instance->is_request( 'frontend' ) ) {
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-cart.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/ajax.php';
}
if ( self::$instance->is_request( 'admin' ) ) {
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-helpers.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-items.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-menu.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-payments.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-scripts.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/admin-system-info.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-admin-notices.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-admin-search.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-price-listings.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-price-listings-tabs.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-admin-add-item.php';
}
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/class-upgrades.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/inc/install.php';
require_once SELL_MEDIA_PLUGIN_DIR . '/gutenberg/sell-media-items.php';
}
/**
* Loads the plugin language files.
*
* @access public
* @since 1.8.5
* @return void
*/
public function textdomain() {
// Get text domain.
$domain = 'sell_media';
// The "plugin_locale" filter is also used in load_plugin_textdomain().
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
// Create path to custom language file.
$custom_mo = WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo';
if ( file_exists( $custom_mo ) ) {
load_textdomain( $domain, $custom_mo );
} else {
load_plugin_textdomain( $domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
} // End SellMedia class.
endif; // End if class_exists check.
/**
* The main function that returns the one and only SellMedia instance.
* Use this function to access classes and methods.
* Example: <?php $sell_media = Sell_Media(); ?>
*
* @since 1.8.5
* @return object The one true SellMedia instance.
*/
function Sell_Media() {
return SellMedia::instance();
}
// Start Sell Media.
Sell_Media();