function save() { $_POST['post_type'] = SendPress_Data::email_post_type(); // Update post 37 (37!) $my_post = _wp_translate_postdata(true); $system_emails = SendPress_Option::base_get('system-emails'); $my_post['post_status'] = 'sp-systememail'; $my_post['post_content'] = SendPress_Data::get_sysemail_content($_POST['email_type']); // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']); update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); update_post_meta($my_post['ID'], '_sendpress_system', 'new'); update_post_meta($my_post['ID'], '_system_email_type', $_POST['email_type']); update_post_meta($my_post['ID'], '_system_default', $_POST['default']); if ($_POST['default']) { //set default system e-mail for this type SendPress_Data::set_system_email_default($my_post['ID'], $_POST['email_type']); } SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); if (!in_array($_POST['email_type'], $system_emails)) { $system_emails[] = $_POST['email_type']; } SendPress_Option::base_set('system-emails', $system_emails); SendPress_Admin::redirect('Settings_Emailedit', array('emailID' => $my_post['ID'])); //$this->save_redirect( $_POST ); }
function save() { //$this->security_check(); $_POST['post_type'] = SendPress_Data::email_post_type(); // Update post 37 (37!) $my_post = _wp_translate_postdata(true); /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ $my_post['post_status'] = 'publish'; // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']); update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); update_post_meta($my_post['ID'], '_sendpress_system', $_POST['template_system']); SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); if ($_POST['template_system'] == 'new') { SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID'])); } SendPress_Admin::redirect('Emails_Style', array('emailID' => $my_post['ID'])); //$this->save_redirect( $_POST ); }
function html() { $email_id = get_query_var('spemail'); global $post; if (is_object($this->data()) && $this->data()->id) { $email_id = $this->data()->id; } if (isset($_GET['eid'])) { $email_id = SPNL()->validate->int(base64_decode($_GET['eid'])); } // If there's a subscriber ID in the URL, we need to get the subscriber object from it to use for the str_replace below. if (isset($_GET['sid'])) { $subscriber_id = SPNL()->validate->int(base64_decode($_GET['sid'])); } else { $subscriber_id = 0; } //$post = get_post($email_id); $inline = false; if (isset($_GET['inline'])) { $inline = true; } SendPress_Email_Cache::build_cache_for_email($email_id); $message = new SendPress_Email(); $message->id($email_id); $message->subscriber_id($subscriber_id); $message->list_id(0); $body = $message->html(); //print_r( $body ); unset($message); echo $body; //echo SendPress_Template::get_instance()->render_html(false, true, $inline ); }
function save() { $_POST['post_type'] = SendPress_Data::email_post_type(); // Update post 37 (37!) $my_post = _wp_translate_postdata(true); /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ $my_post['post_status'] = 'sp-autoresponder'; // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject'])); update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template'])); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); update_post_meta($my_post['ID'], '_sendpress_system', 'new'); SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID'])); //$this->save_redirect( $_POST ); }
/** * Used to add Overwrite send info for testing. * * @return boolean true if mail sent successfully, false if an error */ static function send_test_email($email) { SendPress_Email_Cache::build_cache_for_email($email->emailID); $message = new SendPress_Email(); $message->id($email->emailID); $message->purge(true); $message->subscriber_id($email->subscriberID); $message->list_id($email->listID); $body = $message->html(); $subject = $message->subject(); $to = $email->to_email; $text = $message->text(); if (empty($text) || $text == '' || empty($body) || $body == '' || $body == " ") { SPNL()->log->add('Email Skiped', 'Email id #' . $email->emailID . ' to ' . $to . ' did not have any content. Was the email or template deleted?', 0, 'sending'); return false; } return SendPress_Manager::send($to, $subject, $body, $text, true, $email->subscriberID, $email->listID, $email->emailID); }
case 'save-email': $_POST['post_type'] = $this->_email_post_type; // Update post 37 $my_post = _wp_translate_postdata(true); /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ $my_post['post_status'] = 'publish'; // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']); update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); $this->save_redirect($_POST); break; case 'temaplte-widget-settings': $widget_options = array(); $widget_options['widget_options']['load_css'] = 0; $widget_options['widget_options']['load_ajax'] = 0; $widget_options['widget_options']['load_scripts_in_footer'] = 0; if (isset($_POST['load_css'])) { $widget_options['widget_options']['load_css'] = $_POST['load_css']; } if (isset($_POST['load_ajax'])) { $widget_options['widget_options']['load_ajax'] = $_POST['load_ajax']; }
function save() { $saveid = SPNL()->validate->int($_POST['post_ID']); $bodybg = SPNL()->validate->hex($_POST['body_bg']); $bodytext = SPNL()->validate->hex($_POST['body_text']); $bodylink = SPNL()->validate->hex($_POST['body_link']); $contentbg = SPNL()->validate->hex($_POST['content_bg']); $contenttext = SPNL()->validate->hex($_POST['content_text']); $contentlink = SPNL()->validate->hex($_POST['sp_content_link_color']); $contentborder = SPNL()->validate->hex($_POST['content_border']); $upload_image = $_POST['upload_image']; $headerbg = SPNL()->validate->hex($_POST['header_bg']); $headertextcolor = SPNL()->validate->hex($_POST['header_text_color']); $headertext = sanitize_text_field($_POST['header_text']); $headerlink = esc_url_raw($_POST['header_link']); $imageheaderurl = esc_url_raw($_POST['image_header_url']); $subheadertext = sanitize_text_field($_POST['sub_header_text']); $activeHeader = $_POST['active_header']; $_POST['post_type'] = 'sp_newsletters'; // Update post 37 $my_post = _wp_translate_postdata(true); /* $my_post['ID'] = $_POST['post_ID']; $my_post['post_content'] = $_POST['content']; $my_post['post_title'] = $_POST['post_title']; */ /* $str = $my_post['post_content']; $DOM = new DOMDocument; $DOM->loadHTML($str); //get all H1 $aTags = $DOM->getElementsByTagName('a'); foreach ($aTags as $aElement) { $style = $aElement->getAttribute('style'); if($style == ""){ $aElement->setAttribute('style', 'color: '. $contentlink); } } $body_html = $DOM->saveHtml(); $my_post['post_content'] = $body_html; */ $my_post['post_status'] = 'publish'; // Update the post into the database wp_update_post($my_post); update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject'])); update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template'])); update_post_meta($my_post['ID'], '_sendpress_status', 'private'); SendPress_Email::set_default_style($my_post['ID']); //clear the cached file. delete_transient('sendpress_email_html_' . $my_post['ID']); update_post_meta($saveid, 'body_bg', $bodybg); update_post_meta($saveid, 'body_text', $bodytext); update_post_meta($saveid, 'body_link', $bodylink); update_post_meta($saveid, 'content_bg', $contentbg); update_post_meta($saveid, 'content_text', $contenttext); update_post_meta($saveid, 'sp_content_link_color', $contentlink); update_post_meta($saveid, 'content_border', $contentborder); update_post_meta($saveid, 'upload_image', $upload_image); update_post_meta($saveid, 'header_bg', $headerbg); update_post_meta($saveid, 'header_text_color', $headertextcolor); update_post_meta($saveid, 'header_text', $headertext); update_post_meta($saveid, 'header_link', $headerlink); update_post_meta($saveid, 'image_header_url', $imageheaderurl); update_post_meta($saveid, 'sub_header_text', $subheadertext); update_post_meta($saveid, 'active_header', $activeHeader); if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') { SendPress_Admin::redirect('Emails_Send', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } else { if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') { $email = new stdClass(); $email->emailID = $my_post['ID']; $email->subscriberID = 0; $email->listID = 0; $email->to_email = $_POST['test-email']; $d = SendPress_Manager::send_test_email($email); //print_r($d); SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } else { SendPress_Admin::redirect('Emails_Style', array('emailID' => SPNL()->validate->int($_GET['emailID']))); } } }
function template_include($template) { global $post; if (get_query_var('sendpress') || isset($_POST['sendpress'])) { $action = isset($_POST['sendpress']) ? $_POST['sendpress'] : get_query_var('sendpress'); //Look for encrypted data $data = SendPress_Data::decrypt($action); $view = false; if (is_object($data)) { $view = isset($data->view) ? $data->view : false; } else { $view = $action; } $view_class = SendPress_Data::get_public_view_class($view); if (class_exists($view_class)) { $view_class = new $view_class(); $view_class->data($data); if (isset($_POST['sp']) && wp_verify_nonce($_POST['sp'], 'sendpress-form-post') && method_exists($view_class, 'save')) { $view_class->save(); } $view_class->prerender(); $view_class->render(); } //$this->load_default_screen($action); die; } if (isset($post)) { if ($post->post_type == $this->_email_post_type || $post->post_type == $this->_report_post_type) { $inline = false; if (isset($_GET['inline'])) { $inline = true; } SendPress_Email_Cache::build_cache_for_email($post->ID); $message = new SendPress_Email(); $message->id($post->ID); $message->subscriber_id(0); $message->list_id(0); $body = $message->html(); //print_r( $body ); unset($message); echo $body; die; //SendPress_Template::get_instance()->render_html(false, true, $inline ); //return SENDPRESS_PATH. '/template-loader.php'; //return dirname(__FILE__) . '/my_special_template.php'; } /** * * if($post->post_type == 'sp-standard' ){ * return 'You Bet'; * } **/ } return $template; }
function set_default_email_style($id) { SendPress_Email::set_default_style($id); }