function save_email()
 {
     //print_r($_POST['content-1']);
     //content-area-one-edit
     //$template = get_post();
     //$_POST['post_type'] = 'sp_newsletters';
     //$my_post = _wp_translate_postdata(true);
     //print_r($my_post);
     //$template['post_content'] = $my_post->content_area_one_edit;
     $post_update = array('ID' => $_POST['post_ID'], 'post_content' => $_POST['content_area_one_edit']);
     update_post_meta($_POST['post_ID'], '_sendpress_template', $_POST['template']);
     update_post_meta($_POST['post_ID'], '_sendpress_subject', $_POST['post_subject']);
     update_post_meta($_POST['post_ID'], '_header_content', $_POST['header_content_edit']);
     update_post_meta($_POST['post_ID'], '_footer_content', $_POST['footer_content_edit']);
     //	print_r($template);
     wp_update_post($post_update);
     if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') {
         SendPress_Admin::redirect('Emails_Send', array('emailID' => $_GET['emailID']));
     } else {
         if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') {
             $email = new stdClass();
             $email->emailID = $_POST['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_Edit', array('emailID' => $_GET['emailID']));
         } else {
             SendPress_Admin::redirect('Emails_Edit', array('emailID' => $_GET['emailID']));
         }
     }
 }
 function save_email()
 {
     //$this->security_check();
     $clean_post_id = SPNL()->validate->int($_POST['post_ID']);
     if ($clean_post_id > 0) {
         $post_update = array('ID' => $clean_post_id, 'post_content' => $_POST['content_area_one_edit']);
         update_post_meta($clean_post_id, '_sendpress_template', SPNL()->validate->int($_POST['template']));
         update_post_meta($clean_post_id, '_sendpress_subject', sanitize_text_field($_POST['post_subject']));
         update_post_meta($clean_post_id, '_header_content', sanitize_text_field($_POST['header_content_edit']));
         update_post_meta($clean_post_id, '_footer_content', sanitize_text_field($_POST['footer_content_edit']));
         //	print_r($template);
         wp_update_post($post_update);
         if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') {
             SendPress_Admin::redirect('Emails_Systememail', array('emailID' => SPNL()->validate->_int('emailID')));
         } else {
             if (isset($_POST['submit']) && $_POST['submit'] == 'send-test') {
                 $email = new stdClass();
                 $email->emailID = $clean_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_Systememail', array('emailID' => SPNL()->validate->_int('emailID')));
             } else {
                 SendPress_Admin::redirect('Emails_Systememail', array('emailID' => SPNL()->validate->_int('emailID')));
             }
         }
     }
 }
 function save_email()
 {
     //$this->security_check();
     $post_id = SPNL()->validate->_int('post_ID');
     if ($post_id > 0) {
         $html = SPNL()->validate->_html('content_area_one_edit');
         //SendPress_Error::Log($html);
         $post_update = array('ID' => $post_id, 'post_content' => $html);
         update_post_meta($post_id, '_sendpress_template', SPNL()->validate->_int('template'));
         update_post_meta($post_id, '_sendpress_subject', sanitize_text_field(SPNL()->validate->_string('post_subject')));
         if (SPNL()->validate->_isset('header_content_edit')) {
             update_post_meta($post_id, '_header_content', SPNL()->validate->_html('header_content_edit'));
         }
         if (SPNL()->validate->_isset('footer_content_edit')) {
             update_post_meta($post_id, '_footer_content', SPNL()->validate->_html('footer_content_edit'));
         }
         //	print_r($template);
         remove_filter('content_save_pre', 'wp_filter_post_kses');
         remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
         wp_update_post($post_update);
         add_filter('content_save_pre', 'wp_filter_post_kses');
         add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     }
     if (SPNL()->validate->_string('submit') == 'save-next') {
         SendPress_Admin::redirect('Emails_Send', array('emailID' => SPNL()->validate->_int('emailID')));
     } else {
         if (SPNL()->validate->_string('submit') == 'send-test') {
             $email = new stdClass();
             $email->emailID = SPNL()->validate->_int('post_ID');
             $email->subscriberID = 0;
             $email->listID = 0;
             $email->to_email = SPNL()->validate->_email('test-email');
             $d = SendPress_Manager::send_test_email($email);
             //print_r($d);
             SendPress_Admin::redirect('Emails_Edit', array('emailID' => SPNL()->validate->_int('emailID')));
         } else {
             SendPress_Admin::redirect('Emails_Edit', array('emailID' => SPNL()->validate->_int('emailID')));
         }
     }
 }
 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'])));
         }
     }
 }