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