ttings&tab=wpdm-crons', 'title' => __('Cron Jobs', 'download-manager'), 'callback' => array($this, 'cronJobs'));
$stabs['privacy'] = array('id' => 'privacy','icon'=>'fas fa-user-shield', 'link' => 'edit.php?post_type=wpdmpro&page=wpdm-settings&tab=privacy', 'title' => 'Privacy', 'callback' => array($this, 'privacy'));
}
/**
* @usage Admin Settings Tab Helper
* @param string $sel
*/
public static function renderMenu($sel = '')
{
global $stabs;
foreach ($stabs as $tab) {
$isactive = ($sel == $tab['id']) ? 'class="active"' : '';
echo "
{$tab['title']}";
}
}
function basic(){
if (isset($_POST['task']) && $_POST['task'] == 'wdm_save_settings') {
if(!current_user_can('manage_options')) die(__( "You are not allowed to change settings!", "download-manager" ));
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach ($_POST as $optn => $optv) {
if(strpos("__".$optn, '_wpdm_')) {
$optv = wpdm_sanitize_array($optv);
if($optn === '_wpdm_file_browser_root') {
$optv = realpath( get_home_path() . '/' . $optv );
$optv = str_replace("\\", "/", $optv);
if ( $optv ) {
$optv = trailingslashit( $optv );
}
}
update_option($optn, $optv, false);
}
}
WPDM()->apply->sfbAccess();
if (!isset($_POST['__wpdm_skip_locks'])) delete_option('__wpdm_skip_locks');
if (!isset($_POST['__wpdm_login_form'])) delete_option('__wpdm_login_form');
if (!isset($_POST['__wpdm_cat_desc'])) delete_option('__wpdm_cat_desc');
if (!isset($_POST['__wpdm_cat_img'])) delete_option('__wpdm_cat_img');
if (!isset($_POST['__wpdm_cat_tb'])) delete_option('__wpdm_cat_tb');
flush_rewrite_rules();
global $wp_rewrite, $WPDM;
$WPDM->registerPostTypeTaxonomy();
$wp_rewrite->flush_rules();
die('Settings Saved Successfully');
}
$show_db_update_notice = 0;
if(Installer::dbUpdateRequired()){
$show_db_update_notice = 1;
Installer::updateDB();
}
include wpdm_admin_tpl_path("settings/basic.php");
}
function userInterface(){
if (isset($_POST['task']) && $_POST['task'] == 'wdm_save_settings' && current_user_can(WPDM_ADMIN_CAP)) {
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach ($_POST as $optn => $optv) {
if(strpos("__".$optn, '_wpdm_')) {
//$optv = wpdm_sanitize_array($optv);
$optv = wpdm_sanitize_array($optv, "/([^\#a-zA-Z0-9_\-\s:\.\;\@])/");
//echo $optn."=".$optv."
";
update_option($optn, $optv, false);
}
}
die(__( "Settings Saved Successfully", "download-manager" ));
}
include wpdm_admin_tpl_path("settings/user-interface.php");
}
function frontEnd(){
if(isset($_POST['section']) && $_POST['section']=='frontend' && isset($_POST['task']) && $_POST['task']=='wdm_save_settings' && current_user_can(WPDM_ADMIN_CAP)){
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach($_POST as $k => $v){
if(strpos("__".$k, '_wpdm_')){
$v = wpdm_sanitize_array($v);
update_option($k, $v, false);
}
}
global $wp_roles;
$roleids = array_keys($wp_roles->roles);
$roles = maybe_unserialize(get_option('__wpdm_front_end_access',array()));
$naroles = array_diff($roleids, $roles);
foreach($roles as $role) {
$role = get_role($role);
if(is_object($role))
$role->add_cap('upload_files');
}
foreach($naroles as $role) {
$role = get_role($role);
if(!isset($role->capabilities['edit_posts']) || $role->capabilities['edit_posts']!=1)
$role->remove_cap('upload_files');
}
$refresh = 0;
$page_id = wpdm_query_var('__wpdm_user_dashboard', 'int');
if($page_id != '') {
$page_name = get_post_field("post_name", $page_id);
add_rewrite_rule('^' . $page_name . '/(.+)/?', 'index.php?page_id=' . $page_id . '&udb_page=$matches[1]', 'top');
$refresh = 1;
}
$page_id = wpdm_query_var('__wpdm_author_profile', 'int');
if((int)$page_id > 0) {
$page_name = get_post_field("post_name", $page_id);
add_rewrite_rule('^' . $page_name . '/(.+)/?$', 'index.php?pagename=' . $page_name . '&profile=$matches[1]', 'top');
$refresh = 1;
}
if($refresh == 1){
global $wp_rewrite;
$wp_rewrite->flush_rules(true);
}
die('Settings Saved Successfully!');
}
include wpdm_admin_tpl_path("settings/frontend.php");
}
function socialConnects(){
if(isset($_POST['section']) && $_POST['section']=='social-connects' && isset($_POST['task']) && $_POST['task']=='wdm_save_settings' && current_user_can(WPDM_ADMIN_CAP)){
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach($_POST as $k => $v){
if(strpos("__".$k, '_wpdm_')){
update_option($k, wpdm_sanitize_array($v), false);
}
}
die('Settings Saved Successfully!');
}
include wpdm_admin_tpl_path("settings/social-connects.php");
}
function Buddypress(){
if(isset($_POST['section']) && $_POST['section']=='buddypress' && isset($_POST['task']) && $_POST['task']=='wdm_save_settings' && current_user_can(WPDM_ADMIN_CAP)){
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach($_POST as $k => $v){
if(strpos("__".$k, '_wpdm_')){
update_option($k, wpdm_sanitize_array($v), false);
}
}
die('Settings Saved Successfully!');
}
include wpdm_admin_tpl_path("settings/buddypress.php");
}
function cloudStorage(){
if(isset($_POST['section']) && $_POST['section']=='cloud-storage' && isset($_POST['task']) && $_POST['task']=='wdm_save_settings' && current_user_can(WPDM_ADMIN_CAP)){
if(!wp_verify_nonce($_POST['__wpdms_nonce'], WPDMSET_NONCE_KEY)) die(__('Security token is expired! Refresh the page and try again.', 'download-manager'));
foreach($_POST as $k => $v){
if(strpos("__".$k, '_wpdm_')){
update_option($k, wpdm_sanitize_array($v), false);
}
}
die('Settings Saved Successfully!');
}
include wpdm_admin_tpl_path("settings/cloud-storage.php");
}
function Privacy(){
if (wpdm_query_var('task') == 'wdm_save_settings' && wpdm_query_var('section') == 'privacy') {
update_option('__wpdm_noip', wpdm_query_var('__wpdm_noip', 'int', 0));
update_option('__wpdm_delstats_on_udel', wpdm_query_var('__wpdm_delstats_on_udel', 'int', 0));
update_option('__wpdm_checkout_privacy', wpdm_query_var('__wpdm_checkout_privacy', 'int', 0));
update_option('__wpdm_checkout_privacy_label', wpdm_query_var('__wpdm_checkout_privacy_label', 'txt'));
update_option('__wpdm_tmp_storage', wpdm_query_var('__wpdm_tmp_storage', 'txt', 'db'));
update_option('__wpdm_auto_clean_cache', wpdm_query_var('__wpdm_auto_clean_cache', 'int', 0));
update_option('__wpdm_cron_key', wpdm_query_var('__wpdm_cron_key', 'alphanum', ''));
_e("Privacy Settings Saved Successfully", "download-manager");
die();
}
include wpdm_admin_tpl_path("settings/privacy.php");
}
function cronJobs() {
if (wpdm_query_var('task') == 'wdm_save_settings' && wpdm_query_var('section') == 'wpdm-crons') {
_e("Nothing to update!", "download-manager");
die();
}
include wpdm_admin_tpl_path("settings/crons.php");
}
function deleteCron() {
__::isAuthentic('wpdmdcx', WPDM_PRI_NONCE, WPDM_ADMIN_CAP);
CronJob::delete(wpdm_query_var('cronid', 'int'));
wp_send_json(['success' => true]);
}
}