esc' => 'Package Name' ),
"{{author}}" => array( 'value' => '', 'desc' => 'Package author profile' ),
"{{package_url}}" => array( 'value' => '', 'desc' => 'Package URL' ),
"{{edit_url}}" => array( 'value' => '', 'desc' => 'Package Edit URL' )
);
$tags["{{client_ip}}"] = ['value' => wpdm_get_client_ip(), 'desc' => 'User IP'];
if(is_user_logged_in()) {
global $current_user;
$tags["{{user_login}}"] = ['value' => $current_user->user_login, 'desc' => 'User login'];
$tags["{{user_email}}"] = ['value' => $current_user->user_email, 'desc' => 'User email'];
$tags["{{user_first_name}}"] = ['value' => $current_user->user_firstname, 'desc' => 'User first name'];
$tags["{{user_last_name}}"] = ['value' => $current_user->user_lastname, 'desc' => 'User last name'];
$tags["{{user_display_name}}"] = ['value' => $current_user->display_name, 'desc' => 'User display name'];
$tags["{{user_description}}"] = ['value' => get_user_meta($current_user->ID, 'description', true), 'desc' => 'User display name'];
$tags["{{um_...metakey...}}"] = ['value' => '', 'desc' => 'User meta data, replace ...metakey...
with user meta key'];
}
return apply_filters( "wpdm_email_template_tags", $tags );
}
public static function defaultTemplate( $id ) {
$templates = self::templates();
return isset($templates[ $id ], $templates[ $id ]['default']) ? $templates[ $id ]['default'] : null;
}
public static function getTemplate( $id ) {
$template = maybe_unserialize( get_option( "__wpdm_etpl_" . $id, false ) );
//print_r($template);die();
$default = self::defaultTemplate( $id );
if ( ! $template ) {
$template = $default;
}
$template['message'] = ! isset( $template['message'] ) || trim( strip_tags( $template['message'] ) ) == '' ? $default['message'] : $template['message'];
return $template;
}
public static function prepare( $id, $params ) {
$template = self::getTemplate( $id );
$params = apply_filters( "wpdm_email_params_" . $id, $params );
$template = apply_filters( "wpdm_email_template_" . $id, $template );
if(!is_array($params)) $params = [];
$__wpdm_email_setting = maybe_unserialize( get_option( '__wpdm_email_setting', array() ) );
if(!is_array($__wpdm_email_setting)) $__wpdm_email_setting = [];
$params = $params + $__wpdm_email_setting;
$logo = isset($params['logo']) ? esc_url($params['logo']) : '';
$banner = isset($params['banner']) ? esc_url($params['banner']) : '';
$logo_wh = isset( $params['logo_w'] ) ? "width:{$params['logo_w']};" : "";
$logo_wh .= isset($params['logo_h']) ? "height:{$params['logo_h']};" : "";
$params['img_logo'] = isset( $params['logo'] ) && $params['logo'] != '' ? "
" : get_bloginfo('name');
$params['banner'] = isset( $params['banner'] ) && $params['banner'] != '' ? esc_url($params['banner']) : "";
$params['banner_img'] = isset( $params['banner'] ) && $params['banner'] != '' ? "
" : "";
$params['images_dir'] = WPDM_BASE_URL.'src/__/views/email-templates/images/';
$template_file = get_option( "__wpdm_email_template", "default.html" );
$emltpl = null;
if ( isset( $params['template_file'] ) ) {
$template_file = $params['template_file'];
$emltpl = Template::locate( "email-templates/".sanitize_file_name($template_file), __DIR__ . '/views' );
}
if(!$emltpl)
$emltpl = Template::locate( "email-templates/".sanitize_file_name($template_file), __DIR__ . '/views' );
if($emltpl)
$emltpl = realpath($emltpl);
if($template_file === '' || !$emltpl)
$emltpl = Template::locate( "email-templates/default.html", __DIR__ . '/views' );
if(file_exists($emltpl))
$template_data = file_get_contents( $emltpl );
$template['message'] = str_replace( "{{message}}", stripslashes( wpautop( $template['message'] ) ), $template_data );
$tags = self::tags();
$new_pasrams = array();
foreach ( $params as $key => $val ) {
$new_pasrams["{{{$key}}}"] = stripslashes($val);
$new_pasrams["[#{$key}#]"] = stripslashes($val);
}
$params = $new_pasrams;
foreach ( $tags as $key => $info ) {
if ( ! isset( $params[$key] )) {
$params[$key] = $info['value'];
}
}
$template['subject'] = isset($params['subject']) ? $params['subject'] : str_replace( array_keys( $params ), array_values( $params ), $template['subject'] );
if(isset($template['to_email']))
$template['to_email'] = str_replace( array_keys( $params ), array_values( $params ), $template['to_email'] );
$template['message'] = str_replace( array_keys( $params ), array_values( $params ), $template['message'] );
$template['message'] = self::compile($template['message']);
$template['message'] = self::compile($template['message'], "/\{\{([^\}]+)\}\}/");
return $template;
}
public static function send( $id, $params ) {
if(!$id || !WPDM()->email->getStatus($id)) return false;
$email = self::info( $id );
$template = self::prepare( $id, $params );
$headers[] = "From: " . $template['from_name'] . " <" . $template['from_email'] . ">";
$headers[] = "Content-type: text/html";
if(!isset($template['to_email'])) {
$template['to_email'] = get_option('admin_email');
}
//$to = $email['for'] !== 'admin' && !isset($params['to_seller']) && isset($params['to_email']) ? $params['to_email'] : $template['to_email'];
if(!isset($template['to_email'])) $template['to_email'] = get_option('admin_email');
$to = isset($params['to_email']) ? $params['to_email'] : $template['to_email'];
$headers = apply_filters( "wpdm_email_headers_" . str_replace("-", "_", $id), $headers );
if(isset($params['cc'])){
$headers[] = "CC: {$params['cc']}";
unset($params['cc']);
}
if(isset($params['bcc'])){
$headers[] = "Bcc: {$params['bcc']}";
unset($params['bcc']);
}
$attachments = apply_filters( "wpdm_email_attachments_" . str_replace("-", "_", $id), array(), $params );
return wp_mail( $to, esc_attr($template['subject']), $template['message'], $headers, $attachments );
}
function sendMail()
{
$params = $this->_params;
$email = self::info( $this->_template );
$template = self::prepare( $this->_template, $this->_params );
$headers[] = "From: " . $template['from_name'] . " <" . $template['from_email'] . ">";
$headers[] = "Content-type: text/html";
if(!isset($template['to_email'])) {
$template['to_email'] = get_option('admin_email');
}
//$to = $email['for'] !== 'admin' && !isset($params['to_seller']) && isset($params['to_email']) ? $params['to_email'] : $template['to_email'];
if(!isset($template['to_email'])) $template['to_email'] = get_option('admin_email');
$to = isset($params['to_email']) ? $params['to_email'] : $template['to_email'];
$headers = apply_filters( "wpdm_email_headers_" . str_replace("-", "_", $this->_template), $headers );
if(isset($params['cc'])){
$headers[] = "CC: {$params['cc']}";
unset($params['cc']);
}
if(isset($params['bcc'])){
$headers[] = "Bcc: {$params['bcc']}";
unset($params['bcc']);
}
$attachments = apply_filters( "wpdm_email_attachments_" . str_replace("-", "_", $this->_template), array(), $params );
return wp_mail( $to, esc_attr($template['subject']), $template['message'], $headers, $attachments );
}
public function preview() {
global $current_user;
if ( ! isset( $_REQUEST['action'] ) || $_REQUEST['action'] != 'email_template_preview' ) {
return;
}
__::isAuthentic("__empnonce", WPDM_PRI_NONCE, WPDM_MENU_ACCESS_CAP, false);
$id = wpdm_query_var('id');
$email = self::info( $id );
$params = array(
"name" => $current_user->display_name,
"username" => $current_user->user_login,
"password" => "**************",
"package_name" => __( "Sample Package Name" , "download-manager" ),
"author" => $current_user->display_name,
"package_url" => "#",
"edit_url" => "#"
);
if ( isset( $_REQUEST['etmpl'] ) ) {
$params['template_file'] = wpdm_query_var('etmpl');
}
$template = self::prepare( $id, $params );
echo $template['message'];
die();
}
static public function fetch($template, $message) {
global $current_user;
if ( ! current_user_can( WPDM_MENU_ACCESS_CAP ) ) {
die( 'Error' );
}
$params['template_file'] = $template;
$template = self::prepare( 'default', $params );
return $template['message'];
}
static function compile($template, $rule = "/\[\#([^\#]+)\#\]/")
{
$compiled = preg_replace_callback($rule, [new self, '_var'], $template);
return $compiled;
}
static function _var($matched)
{
if(substr_count($matched[1], "acfx_user_meta_") && file_exists('get_field')){
$meta_name = str_replace("acfx_user_meta_", "", $matched[1]);
$meta_value = get_field($meta_name, 'user_'.get_current_user_id());
return $meta_value;
}
if(substr_count($matched[1], "acf_user_meta_")){
$meta_name = str_replace("acf_user_meta_", "", $matched[1]);
$data = maybe_unserialize(get_user_meta(get_current_user_id(), 'wpdm_cregf', true));
$value = wpdm_valueof($data, $meta_name);
if(is_array($value)) $value = implode(", ", $value);
return $value;
}
if(substr_count($matched[1], "user_meta_")){
$meta_name = str_replace("user_meta_", "", $matched[1]);
if(substr_count($meta_name, '/')){
$meta_name = explode("/", $meta_name);
$meta_value = get_user_meta(get_current_user_id(), $meta_name[0], true);
array_shift($meta_name);
$meta_value = wpdm_valueof($meta_value, implode("/", $meta_name));
return $meta_value;
}
return get_user_meta(get_current_user_id(), $meta_name, true);
}
if(substr_count($matched[1], "um_")){
$meta_name = str_replace("um_", "", $matched[1]);
if(substr_count($meta_name, '/')){
$meta_name = explode("/", $meta_name);
$meta_value = get_user_meta(get_current_user_id(), $meta_name[0], true);
array_shift($meta_name);
$meta_value = wpdm_valueof($meta_value, implode("/", $meta_name));
return $meta_value;
}
return get_user_meta(get_current_user_id(), $meta_name, true);
}
if(substr_count($matched[1], "SERVER_")){
$meta_name = str_replace("SERVER_", "", $matched[1]);
$meta_value = wpdm_valueof($_SERVER, $meta_name);
return $meta_value;
}
if(substr_count($matched[1], "REQUEST_")){
$meta_name = str_replace("REQUEST_", "", $matched[1]);
$meta_value = wpdm_valueof($_REQUEST, $meta_name);
if(is_array($meta_value)) $meta_value = implode(", ", $meta_value);
return $meta_value;
}
return $matched[1];
}
}
Fatal error: Uncaught Error: Class 'WPDM\__\Email' not found in /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/src/Admin/AdminController.php:35
Stack trace:
#0 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/src/Admin/AdminController.php(27): WPDM\Admin\AdminController->actions()
#1 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/download-manager.php(188): WPDM\Admin\AdminController->__construct()
#2 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/download-manager.php(151): WPDM\WordPressDownloadManager->__construct()
#3 /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/download-manager.php(533): WPDM\WordPressDownloadManager::instance()
#4 /home/kordian1/domains/ostrabrama.pl/public_html/wp-settings.php(545): include_once('/home/kordian1/...')
#5 /home/kordian1/domains/ostrabrama.pl/public_html/wp-config.php(81): require_once('/home/kordian in /home/kordian1/domains/ostrabrama.pl/public_html/wp-content/plugins/download-manager/src/Admin/AdminController.php on line 35