array('subject' => '', 'message' => 'escs', 'from_name' => '', 'from_email' => ''))); update_option("__wpdm_etpl_" . wpdm_query_var('id'), $email_template); if (wpdm_is_ajax()) { die('ok'); } header("location: edit.php?post_type=wpdmpro&&page=templates&_type=$ttype"); die(); } } } /** * @usage Preview link/page template */ function Preview() { error_reporting(0); $wposts = array(); $template = sanitize_file_name(wpdm_query_var('template')); $type = wpdm_query_var("_type"); $args=array( 'post_type'=>'wpdmpro', 'posts_per_page'=>1 ); $wposts = get_posts( $args ); $html = ""; foreach( $wposts as $p ) { $package = (array)$p; $html .= wpdm_fetch_template($template, $package, $type); } if(count($wposts)==0) $html = "
".__( "No package found! Please create at least 1 package to see template preview" , "download-manager" )."
"; $html = "
".$html."
"; echo $html; die(); } public static function Dropdown($params, $activeOnly = false) { extract($params); $type = isset($type) && in_array($type, array('link', 'page', 'email')) ? esc_attr($type) : 'link'; $tplstatus = maybe_unserialize(get_option("_fm_{$type}_template_status")); $activetpls = array(); if(is_array($tplstatus)) { foreach ($tplstatus as $tpl => $active) { if ($active) $activetpls[] = $tpl; } } $ttpldir = get_stylesheet_directory() . '/download-manager/' . $type . '-templates/'; $ttpls = array(); if(file_exists($ttpldir)) { $ttpls = scandir($ttpldir); array_shift($ttpls); array_shift($ttpls); } $ltpldir = WPDM_TPL_DIR . $type . '-templates/'; $ctpls = scandir($ltpldir); array_shift($ctpls); array_shift($ctpls); foreach($ctpls as $ind => $tpl){ $ctpls[$ind] = $ltpldir.$tpl; } foreach($ttpls as $tpl){ if(!in_array($ltpldir.$tpl, $ctpls)) { $ctpls[] = $ttpldir . $tpl; } } $custom_templates = maybe_unserialize(get_option("_fm_{$type}_templates",true)); $name = isset($name)?$name:$type.'_template'; $css = isset($css)?"style='$css'":''; $id = isset($id)?$id:uniqid(); $default = $type == 'link'?'link-template-calltoaction3.php':'page-template-1col-flat.php'; $xdf = str_replace(".php", "", $default); if(is_array($activetpls) && count($activetpls) > 0) $default = in_array($xdf, $activetpls) || !isset($activetpls[0]) ? $default : $activetpls[0]; $html = ""; return isset($data_type) && $data_type == 'ARRAY'? $data : $html; } function saveEmailSetting(){ if(current_user_can(WPDM_ADMIN_CAP) && wp_verify_nonce(wpdm_query_var('__wpdm_nonce'), NONCE_KEY)) { check_ajax_referer(NONCE_KEY, '__wpdm_nonce'); update_option('__wpdm_email_template', wpdm_query_var('__wpdm_email_template')); $email_settings = wpdm_query_var('__wpdm_email_setting', array('validate' => array('logo' => 'url', 'banner' => 'url', 'youtube' => 'url', 'twitter' => 'url', 'facebook' => 'url', 'footer_text' => 'txts'))); update_option('__wpdm_email_setting', $email_settings); die("Done!"); } } function updateTemplateStatus(){ if(!current_user_can(WPDM_ADMIN_CAP)) die('error'); $type = wpdm_query_var('type'); $tpldata = maybe_unserialize(get_option("_fm_{$type}_template_status")); $tpldata[wpdm_query_var('template')] = wpdm_query_var('status'); update_option("_fm_{$type}_template_status", @serialize($tpldata)); echo "OK"; die(); } }