| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Taskbuilder |
| 4 |
* Plugin URI: https://wordpress.org/plugins/taskbuilder/ |
| 5 |
* Description: Wordpress Project & Task Management plugin. Easy to keep track of projects & tasks! |
| 6 |
* Version: 1.0.0 |
| 7 |
* Author: Taskbuilder Team |
| 8 |
* Author URI: https://taskbuilder.net/ |
| 9 |
* Requires at least: 4.4 |
| 10 |
* Tested up to: 5.8.1 |
| 11 |
* Text Domain: taskbuilder |
| 12 |
* Domain Path: /lang |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; // Exit if accessed directly |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! class_exists( 'WP_Taskbuilder' ) ) : |
| 20 |
|
| 21 |
final class WP_Taskbuilder { |
| 22 |
public $version = '1.0.0'; |
| 23 |
public function __construct() { |
| 24 |
// define global constants |
| 25 |
$this->define_constants(); |
| 26 |
// Include required files and classes |
| 27 |
$this->includes(); |
| 28 |
add_action( 'init', array($this,'load_textdomain') ); |
| 29 |
add_action( 'init', array( $this, 'wppm_check_download_file') ); |
| 30 |
register_deactivation_hook( __FILE__, array($this,'deactivate') ); |
| 31 |
} |
| 32 |
|
| 33 |
function define_constants() { |
| 34 |
$this->define('WPPM_STORE_URL', 'https://taskbuilder.net/'); |
| 35 |
$this->define('WPPM_PLUGIN_FILE', __FILE__); |
| 36 |
$this->define('WPPM_ABSPATH', dirname(__FILE__) . '/'); |
| 37 |
$this->define('WPPM_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 38 |
$this->define('WPPM_PLUGIN_BASENAME', plugin_basename(__FILE__)); |
| 39 |
$this->define('WPPM_VERSION', $this->version); |
| 40 |
} |
| 41 |
|
| 42 |
function load_textdomain(){ |
| 43 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'taskbuilder' ); |
| 44 |
load_textdomain( 'taskbuilder', WP_LANG_DIR . '/taskbuilder/taskbuilder-' . $locale . '.mo' ); |
| 45 |
load_plugin_textdomain( 'taskbuilder', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' ); |
| 46 |
} |
| 47 |
|
| 48 |
public function includes() { |
| 49 |
include_once( WPPM_ABSPATH . 'includes/wppm-install.php' ); |
| 50 |
include_once( WPPM_ABSPATH . 'includes/class-wppm-functions.php' ); |
| 51 |
include( WPPM_ABSPATH.'includes/wppm_cron.php' ); |
| 52 |
include_once( WPPM_ABSPATH . 'includes/wppm_actions.php' ); |
| 53 |
if ($this->is_request('admin')) { |
| 54 |
include_once( WPPM_ABSPATH . 'includes/class-wppm-admin.php' ); |
| 55 |
} |
| 56 |
if ($this->is_request('frontend')) { |
| 57 |
include_once( WPPM_ABSPATH . 'includes/class-wppm-frontend.php' ); |
| 58 |
} |
| 59 |
if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
| 60 |
include_once( WPPM_ABSPATH . 'includes/EDD_SL_Plugin_Updater.php' ); |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
public function define($name, $value) { |
| 66 |
if (!defined($name)) { |
| 67 |
define($name, $value); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
public function is_request($type) { |
| 72 |
switch ($type) { |
| 73 |
case 'admin' : |
| 74 |
return is_admin(); |
| 75 |
case 'frontend' : |
| 76 |
return (!is_admin() || defined('DOING_AJAX') ) && !defined('DOING_CRON'); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
public function wppm_check_download_file(){ |
| 81 |
global $wpdb,$wppmfunction; |
| 82 |
if( isset($_REQUEST['wppm_attachment']) && isset($_REQUEST['tid']) && isset($_REQUEST['tac'])){ |
| 83 |
$attach_id = intval(sanitize_text_field($_REQUEST['wppm_attachment'])); |
| 84 |
$auth_code = (sanitize_text_field($_REQUEST['tac'])); |
| 85 |
$task_id = intval(sanitize_text_field($_REQUEST['tid'])); |
| 86 |
$task_auth_code = $wppmfunction->get_task_fields($task_id,'task_auth_code'); |
| 87 |
$task_auth_code = sanitize_text_field($task_auth_code); |
| 88 |
if($task_auth_code == $auth_code){ |
| 89 |
$this->wppm_file_download($attach_id); |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
public function wppm_file_download($attach_id){ |
| 95 |
include WPPM_ABSPATH.'includes/admin/attachment/wppm_download_attachment.php'; |
| 96 |
} |
| 97 |
|
| 98 |
public function deactivate() { |
| 99 |
// Remove cron jobs |
| 100 |
WPPMCron::wppm_unschedule_events(); |
| 101 |
} |
| 102 |
|
| 103 |
} |
| 104 |
|
| 105 |
endif; |
| 106 |
|
| 107 |
new WP_Taskbuilder(); |
| 108 |
|