download-manager
Last commit date
assets
1 day ago
languages
5 months ago
src
1 day ago
download-manager.php
1 day ago
index.php
5 years ago
readme.txt
1 day ago
download-manager.php
572 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Download Manager |
| 4 | Plugin URI: https://www.wpdownloadmanager.com/purchases/ |
| 5 | Description: Manage, Protect and Track file downloads, and sell digital products from your WordPress site. A complete digital asset management solution. |
| 6 | Author: W3 Eden, Inc. |
| 7 | Author URI: https://www.wpdownloadmanager.com/ |
| 8 | Version: 3.3.63 |
| 9 | Text Domain: download-manager |
| 10 | Domain Path: /languages |
| 11 | */ |
| 12 | |
| 13 | namespace WPDM; |
| 14 | |
| 15 | use WPDM\__\Apply; |
| 16 | use WPDM\__\CronJob; |
| 17 | use WPDM\__\Crypt; |
| 18 | use WPDM\__\DownloadStats; |
| 19 | use WPDM\__\Email; |
| 20 | use WPDM\__\FileSystem; |
| 21 | use WPDM\__\CronJobs; |
| 22 | use WPDM\__\Installer; |
| 23 | use WPDM\__\Messages; |
| 24 | use WPDM\__\Session; |
| 25 | use WPDM\__\Settings; |
| 26 | use WPDM\__\Template; |
| 27 | use WPDM\__\UI; |
| 28 | use WPDM\__\Updater; |
| 29 | use WPDM\__\UserAgent; |
| 30 | use WPDM\Admin\AdminController; |
| 31 | use WPDM\AssetManager\AssetManager; |
| 32 | use WPDM\Category\Category; |
| 33 | use WPDM\Category\CategoryController; |
| 34 | use WPDM\Admin\PackageTemplate; |
| 35 | use WPDM\MediaLibrary\MediaAccessControl; |
| 36 | use WPDM\MediaLibrary\MediaHandler; |
| 37 | use WPDM\Package\Package; |
| 38 | use WPDM\User\UserController; |
| 39 | use WPDM\Widgets\WidgetController; |
| 40 | |
| 41 | global $WPDM; |
| 42 | |
| 43 | define('WPDM_VERSION','3.3.63'); |
| 44 | |
| 45 | define('WPDM_TEXT_DOMAIN','download-manager'); |
| 46 | |
| 47 | $upload_dir = wp_upload_dir(); |
| 48 | $upload_base_url = $upload_dir['baseurl']; |
| 49 | $upload_dir = $upload_dir['basedir']; |
| 50 | |
| 51 | /** |
| 52 | * Define plugin admin access capability. |
| 53 | */ |
| 54 | if(!defined('WPDM_ADMIN_CAP')) |
| 55 | define('WPDM_ADMIN_CAP','manage_options'); |
| 56 | |
| 57 | /** |
| 58 | * Define plugin menu access capability |
| 59 | */ |
| 60 | if(!defined('WPDM_MENU_ACCESS_CAP')) |
| 61 | define('WPDM_MENU_ACCESS_CAP','manage_options'); |
| 62 | |
| 63 | /** |
| 64 | * Plugin base dir |
| 65 | */ |
| 66 | define('WPDM_BASE_DIR',dirname(__FILE__).'/'); |
| 67 | define('WPDM_SRC_DIR',dirname(__FILE__).'/src/'); |
| 68 | |
| 69 | define('WPDM_BASE_URL',plugins_url('/download-manager/')); |
| 70 | define('WPDM_ASSET_URL',plugins_url('/download-manager/assets/')); |
| 71 | define('WPDM_CSS_URL',plugins_url('/download-manager/assets/css/')); |
| 72 | define('WPDM_JS_URL',plugins_url('/download-manager/assets/js/')); |
| 73 | |
| 74 | if(!defined('UPLOAD_DIR')) |
| 75 | define('UPLOAD_DIR',$upload_dir.'/download-manager-files/'); |
| 76 | |
| 77 | |
| 78 | if(!defined('WPDM_CACHE_DIR')) { |
| 79 | define('WPDM_CACHE_DIR', $upload_dir . '/wpdm-cache/'); |
| 80 | define('WPDM_CACHE_URL', $upload_base_url . '/wpdm-cache/'); |
| 81 | } |
| 82 | |
| 83 | if(!defined('WPDM_TPL_FALLBACK')) |
| 84 | define('WPDM_TPL_FALLBACK', dirname(__FILE__) . '/tpls/'); |
| 85 | |
| 86 | if(!defined('WPDM_TPL_DIR')) { |
| 87 | define('WPDM_TPL_DIR', dirname(__FILE__) . '/tpls/'); |
| 88 | } |
| 89 | |
| 90 | if(!defined('UPLOAD_BASE')) |
| 91 | define('UPLOAD_BASE',$upload_dir); |
| 92 | |
| 93 | if(!defined('WPDM_USE_GLOBAL')) |
| 94 | define('WPDM_USE_GLOBAL', 'WPDM_USE_GLOBAL'); |
| 95 | |
| 96 | if(!defined('WPDM_TAG')) |
| 97 | define('WPDM_TAG', 'wpdmtag'); |
| 98 | |
| 99 | if(!defined('WPDM_FONTAWESOME_URL')) |
| 100 | define('WPDM_FONTAWESOME_URL', WPDM_BASE_URL.'assets/fontawesome/css/all.min.css'); |
| 101 | |
| 102 | if(!defined('NONCE_KEY')){ |
| 103 | //To avoid warning when not defined |
| 104 | define('NONCE_KEY', 'Bm|_Ek@F|HdkA7)=alSJg5_<z-j-JmhK<l&*.d<J+/71?&7pL~XBXnF4jKz>{Apx'); |
| 105 | /** |
| 106 | * Generate WordPress Security Keys and Salts from https://api.wordpress.org/secret-key/1.1/salt/ and place them in your wp-config.php |
| 107 | */ |
| 108 | } |
| 109 | |
| 110 | if(!defined('NONCE_SALT')){ |
| 111 | //To avoid warning when not defined |
| 112 | define('NONCE_SALT', 'XffybIqfklKjegGdRp7EU4kprZX00NESOE8olZ2BZ8+BQTw3bXXSbzeGssgZ'); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | if(!defined('WPDM_PUB_NONCE')) |
| 117 | define('WPDM_PUB_NONCE', 'o($Vb ^[@EH83o2gb=,lt1JtBY]%i91|xu+]jnW9{*nMK@_z-AWwsyKEVx)/|p,P'); |
| 118 | if(!defined('WPDM_PRI_NONCE')) |
| 119 | define('WPDM_PRI_NONCE', '.r&`|]S1GEAdm^hTA^XmE8vU3F^=K+)419alVN=EbDQ Z-pfl/nd-12^I&oRfDC]'); |
| 120 | |
| 121 | @ini_set('upload_tmp_dir',WPDM_CACHE_DIR); |
| 122 | |
| 123 | |
| 124 | final class WordPressDownloadManager{ |
| 125 | |
| 126 | public $session; |
| 127 | public $user; |
| 128 | public $apply; |
| 129 | public $fileSystem; |
| 130 | public $admin; |
| 131 | public $package; |
| 132 | public $category; |
| 133 | public $categories; |
| 134 | public $assetManager; |
| 135 | public $asset; |
| 136 | public $shortCode; |
| 137 | public $template; |
| 138 | public $packageTemplate; |
| 139 | public $setting; |
| 140 | public $email; |
| 141 | public $crypt; |
| 142 | public $downloadHistory; |
| 143 | public $bsversion = ''; |
| 144 | public $userAgent; |
| 145 | public $message; |
| 146 | public $updater; |
| 147 | public $ui; |
| 148 | public $cronJob; |
| 149 | public $cronJobs; |
| 150 | public $wpdm_urls; |
| 151 | |
| 152 | private static $wpdm_instance = null; |
| 153 | |
| 154 | public static function instance(){ |
| 155 | if ( is_null( self::$wpdm_instance ) ) { |
| 156 | self::$wpdm_instance = new self(); |
| 157 | } |
| 158 | return self::$wpdm_instance; |
| 159 | } |
| 160 | |
| 161 | function __construct(){ |
| 162 | |
| 163 | register_activation_hook(__FILE__, array($this, 'install')); |
| 164 | |
| 165 | add_action( 'upgrader_process_complete', array($this, 'update'), 10, 2); |
| 166 | |
| 167 | |
| 168 | $this->bsversion = get_option('__wpdm_bsversion', ''); |
| 169 | |
| 170 | add_action( 'init', array($this, 'registerPostTypeTaxonomy'), 1 ); |
| 171 | add_action( 'init', array($this, 'registerScripts'), 1 ); |
| 172 | |
| 173 | add_action( 'init', array($this, 'loadTextdomain') ); |
| 174 | add_action( 'wp_enqueue_scripts', array($this, 'enqueueScripts') ); |
| 175 | |
| 176 | add_action( 'wp_footer', array($this, 'wpFooter') ); |
| 177 | |
| 178 | $this->autoLoadClasses(); |
| 179 | |
| 180 | $this->wpdm_urls = array( |
| 181 | 'home' => esc_url_raw(home_url('/')), |
| 182 | 'site' => esc_url_raw(site_url('/')), |
| 183 | 'ajax' => esc_url_raw(admin_url('/admin-ajax.php')) |
| 184 | ); |
| 185 | |
| 186 | $this->session = new Session(); |
| 187 | |
| 188 | include_once(dirname(__FILE__) . "/src/wpdm-functions.php"); |
| 189 | include_once(dirname(__FILE__)."/src/wpdm-core.php"); |
| 190 | |
| 191 | $this->user = UserController::getInstance(); |
| 192 | $this->apply = new Apply(); |
| 193 | $this->admin = new AdminController(); |
| 194 | new MediaHandler(); |
| 195 | new MediaAccessControl(); |
| 196 | $this->package = new Package(); |
| 197 | $this->category = new Category(); |
| 198 | $this->categories = new CategoryController(); |
| 199 | $this->setting = new Settings(); |
| 200 | $this->fileSystem = new FileSystem(); |
| 201 | $this->template = new Template(); |
| 202 | $this->packageTemplate = new PackageTemplate(); |
| 203 | $this->crypt = new Crypt(); |
| 204 | $this->downloadHistory = new DownloadStats(); |
| 205 | $this->userAgent = new UserAgent(); |
| 206 | $this->message = new Messages(); |
| 207 | $this->updater = new Updater(); |
| 208 | $this->ui = new UI(); |
| 209 | $this->email = new Email(); |
| 210 | $this->cronJob = CronJob::getInstance(); |
| 211 | $this->cronJobs = CronJobs::getInstance(); |
| 212 | WidgetController::instance(); |
| 213 | |
| 214 | if (!defined('WPDM_ASSET_MANAGER') || WPDM_ASSET_MANAGER === true) { |
| 215 | AssetManager::getInstance(); |
| 216 | } |
| 217 | |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * @usage Install Plugin |
| 222 | */ |
| 223 | function install(){ |
| 224 | |
| 225 | Installer::init(); |
| 226 | |
| 227 | $this->registerPostTypeTaxonomy(); |
| 228 | |
| 229 | flush_rewrite_rules(); |
| 230 | self::createDir(); |
| 231 | |
| 232 | // Set flag to redirect to welcome page after activation |
| 233 | set_transient('wpdm_activation_redirect', 'yes', 300); |
| 234 | update_option('__wpdm_activation_redirect', 'yes', false); |
| 235 | |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Update plugin |
| 240 | * @param $upgrader_object |
| 241 | * @param $options |
| 242 | */ |
| 243 | function update( $upgrader_object, $options ) { |
| 244 | $current_plugin_path_name = plugin_basename( __FILE__ ); |
| 245 | if(!is_array($options)) return; |
| 246 | if ($options['action'] == 'update' && $options['type'] == 'plugin' ){ |
| 247 | if(isset($options['plugins']) && is_array($options['plugins'])) { |
| 248 | foreach ($options['plugins'] as $each_plugin) { |
| 249 | if ($each_plugin == $current_plugin_path_name) { |
| 250 | if (Installer::dbUpdateRequired()) { |
| 251 | Installer::updateDB(); |
| 252 | return; |
| 253 | } |
| 254 | //flush_rewrite_rules(true); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | |
| 262 | /** |
| 263 | * @usage Load Plugin Text Domain |
| 264 | */ |
| 265 | function loadTextdomain(){ |
| 266 | load_plugin_textdomain('download-manager', false, 'download-manager/languages/'); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * @usage Register WPDM Post Type and Taxonomy |
| 271 | */ |
| 272 | public function registerPostTypeTaxonomy() |
| 273 | { |
| 274 | $labels = array( |
| 275 | 'name' => __('Downloads','download-manager'), |
| 276 | 'singular_name' => __('File','download-manager'), |
| 277 | 'add_new' => __('Add New','download-manager'), |
| 278 | 'add_new_item' => __('Add New File','download-manager'), |
| 279 | 'edit_item' => __('Edit File','download-manager'), |
| 280 | 'new_item' => __('New File','download-manager'), |
| 281 | 'all_items' => __('All Files','download-manager'), |
| 282 | 'view_item' => __('View File','download-manager'), |
| 283 | 'search_items' => __('Search Files','download-manager'), |
| 284 | 'not_found' => __('No File Found','download-manager'), |
| 285 | 'not_found_in_trash' => __('No Files found in Trash','download-manager'), |
| 286 | 'parent_item_colon' => '', |
| 287 | 'menu_name' => __('Downloads','download-manager') |
| 288 | |
| 289 | ); |
| 290 | |
| 291 | $tslug = 'download'; |
| 292 | if(!strpos("_$tslug", "%")) |
| 293 | $slug = sanitize_title($tslug); |
| 294 | else |
| 295 | $slug = $tslug; |
| 296 | |
| 297 | $args = array( |
| 298 | 'labels' => $labels, |
| 299 | 'public' => true, |
| 300 | 'publicly_queryable' => get_option('__wpdm_publicly_queryable', 1), |
| 301 | 'show_ui' => true, |
| 302 | 'show_in_menu' => true, |
| 303 | 'show_in_rest' => (int)get_option('__wpdm_gutenberg_editor', 0), |
| 304 | 'show_in_nav_menus' => true, |
| 305 | 'query_var' => true, |
| 306 | 'rewrite' => array('slug' => $slug, 'with_front' => (bool)get_option('__wpdm_purl_with_front', false)), //get_option('__wpdm_purl_base','download') |
| 307 | 'capability_type' => 'post', |
| 308 | 'has_archive' => (get_option('__wpdm_has_archive', false)==false?false:sanitize_title(get_option('__wpdm_archive_page_slug', 'all-downloads'))), |
| 309 | 'hierarchical' => false, |
| 310 | //'menu_icon' => 'dashicons-download', |
| 311 | 'exclude_from_search' => (bool)get_option('__wpdm_exclude_from_search', false), |
| 312 | 'supports' => array('title', 'editor', 'publicize', 'excerpt', 'custom-fields', 'thumbnail', 'comments','author'), |
| 313 | 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 327.3 327.3"><defs><style>.cls-1{fill:#ffffff;}.cls-2,.cls-3{fill:#239cef;}.cls-3{opacity:0.58;}</style><linearGradient id="linear-gradient" x1="11.99" y1="216.58" x2="263.62" y2="129.92" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#3c80e4"/><stop offset="1" stop-color="#229df0"/></linearGradient></defs><title>wpdm logo v3</title><g id="Layer_2" data-name="Layer 2"><g id="download-manager-logo"><g id="wpdm_logo_v3" data-name="wpdm logo v3"><path id="arrow" class="cls-2" d="M149.87,180.29l-91.41-91A20,20,0,0,1,58.39,61L64,55.36a20,20,0,0,1,28.29-.07l71.52,71.18,71-71.7a20,20,0,0,1,28.29-.13l5.68,5.62a20,20,0,0,1,.14,28.29l-90.75,91.64A20,20,0,0,1,149.87,180.29Z"/><path id="circle" d="M186.66,202.9a32,32,0,0,1-45.29.16L97.58,159.48a78,78,0,1,0,132.49-.41Z" style="fill: #a7aaad;"/></g></g></g></svg>') |
| 314 | |
| 315 | ); |
| 316 | |
| 317 | $wpdm_tags = !defined('WPDM_USE_POST_TAGS') || WPDM_USE_POST_TAGS === false; |
| 318 | |
| 319 | |
| 320 | register_post_type('wpdmpro', $args); |
| 321 | |
| 322 | $labels = array( |
| 323 | 'name' => __( "Categories" , "download-manager" ), |
| 324 | 'singular_name' => __( "Category" , "download-manager" ), |
| 325 | 'search_items' => __( "Search Categories" , "download-manager" ), |
| 326 | 'all_items' => __( "All Categories" , "download-manager" ), |
| 327 | 'parent_item' => __( "Parent Category" , "download-manager" ), |
| 328 | 'parent_item_colon' => __( "Parent Category:" , "download-manager" ), |
| 329 | 'edit_item' => __( "Edit Category" , "download-manager" ), |
| 330 | 'update_item' => __( "Update Category" , "download-manager" ), |
| 331 | 'add_new_item' => __( "Add New Category" , "download-manager" ), |
| 332 | 'new_item_name' => __( "New Category Name" , "download-manager" ), |
| 333 | 'menu_name' => __( "Categories" , "download-manager" ), |
| 334 | ); |
| 335 | |
| 336 | $args = array( |
| 337 | 'hierarchical' => true, |
| 338 | 'labels' => $labels, |
| 339 | 'show_ui' => true, |
| 340 | 'show_admin_column' => true, |
| 341 | 'show_in_rest' => (bool)((int)get_option('__wpdm_gutenberg_editor', 0)), |
| 342 | 'query_var' => true, |
| 343 | 'rewrite' => array('slug' => 'download-category'), |
| 344 | ); |
| 345 | |
| 346 | register_taxonomy('wpdmcategory', array('wpdmpro'), $args); |
| 347 | |
| 348 | if($wpdm_tags && WPDM_TAG !== 'post_tag') { |
| 349 | $labels = array( |
| 350 | 'name' => __("Tags", "download-manager"), |
| 351 | 'singular_name' => __("Tag", "download-manager"), |
| 352 | 'search_items' => __("Search Document Tags", "download-manager"), |
| 353 | 'all_items' => __("All Tags", "download-manager"), |
| 354 | 'edit_item' => __("Edit Tag", "download-manager"), |
| 355 | 'update_item' => __("Update Tag", "download-manager"), |
| 356 | 'add_new_item' => __("Add New Tag", "download-manager"), |
| 357 | 'new_item_name' => __("New Tag Name", "download-manager"), |
| 358 | 'menu_name' => __("Tags", "download-manager"), |
| 359 | ); |
| 360 | |
| 361 | $args = array( |
| 362 | 'hierarchical' => false, |
| 363 | 'labels' => $labels, |
| 364 | 'show_ui' => true, |
| 365 | 'show_admin_column' => true, |
| 366 | 'query_var' => true, |
| 367 | 'rewrite' => array('slug' => sanitize_title(get_option('__wpdm_turl_base', 'document-tag'))), |
| 368 | ); |
| 369 | |
| 370 | register_taxonomy('wpdmtag', array('wpdmpro'), $args); |
| 371 | |
| 372 | //unregister_taxonomy_for_object_type('post_tag', 'wpdmpro'); |
| 373 | } else { |
| 374 | register_taxonomy_for_object_type('post_tag', 'wpdmpro'); |
| 375 | } |
| 376 | |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * @usage Create upload dir |
| 381 | */ |
| 382 | public static function createDir() |
| 383 | { |
| 384 | if (!file_exists(UPLOAD_BASE)) { |
| 385 | @mkdir(UPLOAD_BASE, 0755); |
| 386 | @chmod(UPLOAD_BASE, 0755); |
| 387 | } |
| 388 | if(!file_exists(UPLOAD_DIR)) { |
| 389 | @mkdir(UPLOAD_DIR, 0755); |
| 390 | @chmod(UPLOAD_DIR, 0755); |
| 391 | } |
| 392 | |
| 393 | if(!file_exists(WPDM_CACHE_DIR)) { |
| 394 | @mkdir(WPDM_CACHE_DIR, 0755); |
| 395 | @chmod(WPDM_CACHE_DIR, 0755); |
| 396 | } |
| 397 | |
| 398 | $_upload_dir = wp_upload_dir(); |
| 399 | $_upload_dir = $_upload_dir['basedir']; |
| 400 | $tags_dir = $_upload_dir.'/wpdm-custom-tags/'; |
| 401 | if(!file_exists($tags_dir)) { |
| 402 | @mkdir($tags_dir, 0755); |
| 403 | @chmod($tags_dir, 0755); |
| 404 | FileSystem::blockHTTPAccess($tags_dir); |
| 405 | } |
| 406 | |
| 407 | if(!file_exists($_upload_dir.'/wpdm-file-type-icons/')) { |
| 408 | @mkdir($_upload_dir.'/wpdm-file-type-icons/', 0755); |
| 409 | @chmod($_upload_dir.'/wpdm-file-type-icons/', 0755); |
| 410 | } |
| 411 | |
| 412 | self::setHtaccess(); |
| 413 | |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /** |
| 418 | * @usage Protect Download Dir using .htaccess rules |
| 419 | */ |
| 420 | public static function setHtaccess() |
| 421 | { |
| 422 | FileSystem::blockHTTPAccess(UPLOAD_DIR); |
| 423 | } |
| 424 | |
| 425 | function registerScripts(){ |
| 426 | |
| 427 | wp_register_style('wpdm-modal', plugins_url() . '/download-manager/assets/modal/wpdm-modal.min.css', [], WPDM_VERSION); |
| 428 | wp_register_script('wpdm-modal', plugins_url() . '/download-manager/assets/modal/wpdm-modal.min.js', [], WPDM_VERSION); |
| 429 | |
| 430 | if(is_admin()) return; |
| 431 | |
| 432 | wp_register_style('wpdm-front', plugins_url('/assets/css/front.min.css', __FILE__), [], WPDM_VERSION); |
| 433 | wp_register_style('wpdm-front-dark', plugins_url('/assets/css/front-dark.min.css', __FILE__), ['wpdm-front'], WPDM_VERSION); |
| 434 | wp_register_script('jquery-validate', plugins_url('/assets/js/jquery.validate.min.js', __FILE__), array('jquery')); |
| 435 | wp_register_script('wpdm-frontend-js', plugins_url('/assets/js/wpdm.min.js', __FILE__), array('jquery')); |
| 436 | |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * @usage Enqueue all styles and scripts |
| 441 | */ |
| 442 | function enqueueScripts() |
| 443 | { |
| 444 | global $post; |
| 445 | |
| 446 | if(is_admin()) return; |
| 447 | |
| 448 | wp_enqueue_script('wp-i18n'); |
| 449 | wp_enqueue_script('jquery'); |
| 450 | wp_enqueue_script('jquery-form'); |
| 451 | |
| 452 | wp_enqueue_style('wpdm-fonticon', WPDM_BASE_URL . 'assets/wpdm-iconfont/css/wpdm-icons.css'); |
| 453 | |
| 454 | wp_enqueue_style('wpdm-front' ); |
| 455 | |
| 456 | // Color scheme support |
| 457 | $color_scheme = get_option('__wpdm_color_scheme', 'system'); |
| 458 | |
| 459 | // Only load dark mode CSS when needed (dark or system mode) |
| 460 | // For light mode, skip loading front-dark.css entirely (performance + prevents flash) |
| 461 | if ($color_scheme !== 'light') { |
| 462 | wp_enqueue_style('wpdm-front-dark'); |
| 463 | } |
| 464 | |
| 465 | if ($color_scheme === 'dark' || $color_scheme === 'light') { |
| 466 | $scheme_class = $color_scheme === 'dark' ? 'dark-mode' : 'light-mode'; |
| 467 | wp_add_inline_style('wpdm-front', ".w3eden { /* color-scheme: {$color_scheme} */ }"); |
| 468 | wp_add_inline_script('jquery', "document.addEventListener('DOMContentLoaded',function(){document.querySelectorAll('.w3eden').forEach(function(el){el.classList.add('{$scheme_class}')})});", 'after'); |
| 469 | } |
| 470 | |
| 471 | wp_register_script('wpdm-frontjs', plugins_url('/assets/js/front.min.js', __FILE__), array('jquery'), WPDM_VERSION); |
| 472 | |
| 473 | wp_enqueue_script('wpdm-modal'); |
| 474 | wp_enqueue_style('wpdm-modal'); |
| 475 | |
| 476 | if((int)get_option('__wpdm_adblocked_off', 0) === 1) |
| 477 | wp_enqueue_script('wpdm-ad', plugins_url('/download-manager/assets/js/blocker.js')); |
| 478 | |
| 479 | $wpdm_js = array( |
| 480 | 'spinner' => '<i class="wpdm-icon wpdm-sun wpdm-spin"></i>', |
| 481 | 'client_id' => Session::deviceID() |
| 482 | ); |
| 483 | $wpdm_js = apply_filters("wpdm_js_vars", $wpdm_js); |
| 484 | |
| 485 | |
| 486 | wp_localize_script('wpdm-frontjs', 'wpdm_url', $this->wpdm_urls); |
| 487 | |
| 488 | wp_localize_script('wpdm-frontjs', 'wpdm_js', $wpdm_js); |
| 489 | |
| 490 | wp_localize_script('wpdm-frontjs', 'wpdm_strings', [ |
| 491 | 'pass_var' => __("Password Verified!", "download-manager"), |
| 492 | 'pass_var_q' => __("Please click following button to start download.", "download-manager"), |
| 493 | 'start_dl' => __("Start Download", "download-manager") |
| 494 | ]); |
| 495 | |
| 496 | wp_enqueue_script('wpdm-frontend-js'); |
| 497 | wp_enqueue_script('wpdm-frontjs'); |
| 498 | |
| 499 | if(is_object($post) && substr_count($post->post_content, "wpdm_all_packages")){ |
| 500 | wp_enqueue_script("datatable", plugins_url('/assets/js/jquery.dataTables.min.js', __FILE__)); |
| 501 | wp_enqueue_style("datatable-css", plugins_url('/assets/css/jquery.dataTables.min.css', __FILE__)); |
| 502 | } |
| 503 | |
| 504 | |
| 505 | } |
| 506 | |
| 507 | |
| 508 | /** |
| 509 | * @usage insert code in wp footer |
| 510 | */ |
| 511 | function wpFooter(){ |
| 512 | global $post; |
| 513 | $post_content = is_object($post) && isset($post) ? $post->post_content : ''; |
| 514 | |
| 515 | //Enable/disable view count |
| 516 | $view_count = !defined('WPDM_VIEW_COUNT') || WPDM_VIEW_COUNT === true; |
| 517 | |
| 518 | if(get_option('__wpdm_modal_login', 0) |
| 519 | && !has_shortcode($post_content, 'wpdm_user_dashboard') |
| 520 | && !has_shortcode($post_content, 'wpdm_frontend') |
| 521 | && !has_shortcode($post_content, 'wpdm_login_form') |
| 522 | && !has_shortcode($post_content, 'wpdm_reg_form') |
| 523 | ) |
| 524 | echo $this->user->login->modalForm(); |
| 525 | ?> |
| 526 | <script> |
| 527 | const abmsg = "<?php echo esc_attr(get_option('__wpdm_adblocked_msg', 'We noticed an ad blocker. Consider whitelisting us to support the site ❤️')) ?>"; |
| 528 | const abmsgd = "<?php echo esc_attr(get_option('__wpdm_adblocked_msgd', 'download')); ?>"; |
| 529 | const iswpdmpropage = <?php echo is_singular('wpdmpro') ? 1 : 0 ?>; |
| 530 | jQuery(function($){ |
| 531 | |
| 532 | <?php if(is_singular('wpdmpro') && $view_count){ ?> |
| 533 | setTimeout(function (){ |
| 534 | $.post(wpdm_url.ajax, { action: 'wpdm_view_count', __wpdm_view_count:'<?php echo wp_create_nonce(NONCE_KEY) ?>', id: '<?= get_the_ID() ?>' }); |
| 535 | }, 2000); |
| 536 | <?php } ?> |
| 537 | |
| 538 | }); |
| 539 | </script> |
| 540 | <div id="fb-root"></div> |
| 541 | <?php |
| 542 | } |
| 543 | |
| 544 | /** |
| 545 | * Class autoloader |
| 546 | */ |
| 547 | function autoLoadClasses() |
| 548 | { |
| 549 | spl_autoload_register(function ($class) { |
| 550 | |
| 551 | $prefix = 'WPDM\\'; |
| 552 | $base_dir = __DIR__ . '/src/'; |
| 553 | |
| 554 | $len = strlen($prefix); |
| 555 | if (strncmp($prefix, $class, $len) !== 0) { |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | $relative_class = substr($class, $len); |
| 560 | $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
| 561 | |
| 562 | if (file_exists($file)) { |
| 563 | require $file; |
| 564 | } |
| 565 | }); |
| 566 | } |
| 567 | |
| 568 | } |
| 569 | |
| 570 | $WPDM = WordPressDownloadManager::instance(); |
| 571 | |
| 572 |