暫無描述

class-woo-product-data-admin.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <?php
  2. /**
  3. * Responsible for rendering the WooCommerce Product Data admin settings
  4. *
  5. * @package woo_custom_emails_domain\admin
  6. */
  7. class Woo_Product_Data_Admin {
  8. private $version;
  9. public function add_woo_custom_emails_tab( $original_prodata_tabs ) {
  10. $this->options = get_option( 'woocustomemails_settings_name' );
  11. $display_classes_default = 'show_if_simple, show_if_variable, show_if_external, show_if_downloadable, show_if_grouped';
  12. $display_classes_setting = '';
  13. if( isset( $this->options['display_classes'] ) ) {
  14. // Data is set
  15. $display_classes_setting = $display_classes_default . ', ' . $this->options['display_classes'];
  16. } else {
  17. // No Data set
  18. $display_classes_setting = $display_classes_default;
  19. }
  20. // Remove whitespace
  21. $display_classes_setting = str_replace(' ', '', $display_classes_setting);
  22. // Turn string into array
  23. $display_classes_arr = explode(",", $display_classes_setting);
  24. $new_custom_tab['woo-custom-emails'] = array(
  25. 'label' => __( 'Custom Emails', 'woocommerce' ),
  26. 'target' => 'woo_custom_emails_product_data',
  27. 'class' => $display_classes_arr,
  28. );
  29. $insert_at_position = 2; // position in tab list
  30. $tabs = array_slice( $original_prodata_tabs, 0, $insert_at_position, true ); // Split the tabs into an array, then keep the first part up until our position number
  31. $tabs = array_merge( $tabs, $new_custom_tab ); // Add our new tab into the array
  32. $tabs = array_merge( $tabs, array_slice( $original_prodata_tabs, $insert_at_position, null, true ) ); // Append the last part of tabs array
  33. return $tabs;
  34. }
  35. public function wce_custom_admin_style() {
  36. include_once( dirname(__FILE__) . '/woocustomemails-admin-styles.css' );
  37. }
  38. public function wce_enqueue_custom_admin_style() {
  39. global $pagenow;
  40. if ( $pagenow !== 'edit.php' ) {
  41. return;
  42. }
  43. wp_register_style( 'wcepp_custom_admin_css', plugins_url( 'woocustomemails-admin-styles.css', __FILE__ ), '1.0', false );
  44. wp_enqueue_style( 'wcepp_custom_admin_css' );
  45. include_once( dirname(__FILE__) . '/woocustomemails-admin-styles.css' );
  46. }
  47. // Setup 'Custom Emails' Product Data tab
  48. public function add_woo_custom_emails_tab_fields() {
  49. global $post;
  50. // Get WCE Settings
  51. $this->options = get_option( 'woocustomemails_settings_name' );
  52. $show_old_content = false;
  53. // Get Meta from this Post
  54. $this_product_id = get_the_ID();
  55. $customcontent_meta = get_post_meta( $this_product_id, 'custom_content', true );
  56. // Note the 'id' attribute MUST match the 'target' parameter set above.
  57. ?>
  58. <div id='woo_custom_emails_product_data' class='panel woocommerce_options_panel'>
  59. <!-- // 2.2.0
  60. ************************************************************* // -->
  61. <div class='options_group'>
  62. <div class="wce-product-options-table">
  63. <?php
  64. $status_title = __('Order Status', 'woocommerce' );
  65. $status_tip = __('The Order Status Email which is automatically generated by WooCommerce.', 'woocommerce' );
  66. $message_title = __('Custom Email Message', 'woocommerce' );
  67. $message_tip = __('Select a Custom Email Message to be displayed in the Order Status email.', 'woocommerce' );
  68. $location_title = __('Content Location', 'woocommerce' );
  69. $location_tip = __('Select where your custom content will display in the Order Status email.', 'woocommerce' );
  70. ?>
  71. <div class="table-header">
  72. <div class="status">
  73. <?php echo $status_title; ?>
  74. <span class="woocommerce-help-tip" data-tip="<?php echo $status_tip; ?>"></span>
  75. </div>
  76. <div class="message">
  77. <?php echo $message_title; ?>
  78. <span class="woocommerce-help-tip" data-tip="<?php echo $message_tip; ?>"></span>
  79. </div>
  80. <div class="location">
  81. <?php echo $location_title; ?>
  82. <span class="woocommerce-help-tip" data-tip="<?php echo $location_tip; ?>"></span>
  83. </div>
  84. <?php
  85. // TODO: Add "PREVIEW" page link to show users what the Custom Email will look like
  86. ?>
  87. </div>
  88. <?php
  89. $customcontent_orderstatus = get_post_meta( $this_product_id, 'order_status', true );
  90. $customcontent_location = get_post_meta( $this_product_id, 'location', true );
  91. /*
  92. * Reusable function to return the title of a WCE Message
  93. */
  94. function getMessageTitle( $msgID = 0, $statusName = '' ) {
  95. $wcemessage_title = get_the_title( $msgID );
  96. $editURL = admin_url('post.php?post='.$msgID.'&action=edit');
  97. $editBtn = '<a href="'.$editURL.'" target="_blank" class="button edit-wcemessage" alt="'.__('Edit','woocommerce').'" title="'.__('Edit','woocommerce').'"><span class="dashicons dashicons-edit"></span></a>';
  98. // Check if this message is Published.
  99. if ( get_post_status( $msgID ) !== 'publish' ) {
  100. // Saved WCE Message is not published, show Invalid message.
  101. $wcemessage_saved_text = '(' . __('Invalid Message Selected', 'woocommerce') . ')';
  102. } else {
  103. // Saved WCE Message is published.
  104. $wcemessage_saved_text = $wcemessage_title . '';
  105. }
  106. $defaultSearchMsg = __( 'Search Custom Messages...', 'woocommerce' );
  107. $returnStr = '<input class="wcemessage_search_field_input" type="text" value="'.$wcemessage_saved_text.'" name="wcemessage_search_'.$statusName.'" id="wcemessage_search_'.$statusName.'" placeholder="'. $defaultSearchMsg .'" autocomplete="off"></input>';
  108. return $returnStr;
  109. }
  110. /*
  111. * Reusable function to display the saved WCE Message
  112. */
  113. function showSavedMessage( $statusName = '' ) {
  114. // set Status "slug"
  115. if ($statusName == 'onhold'){
  116. $statusSlug = 'on-hold';
  117. } else {
  118. $statusSlug = $statusName;
  119. }
  120. $postID = get_the_ID();
  121. $wcemessage_id = get_post_meta( $postID, 'wcemessage_id', true );
  122. $wcemessage_id_currentStatus = '';
  123. $wcemessage_id_currentStatus = get_post_meta( $postID, 'wcemessage_id_'.$statusName, true );
  124. $wcemessage_controls = '';
  125. $customcontent_orderstatus = '';
  126. $customcontent_orderstatus = get_post_meta( $postID, 'order_status', true );
  127. $extraBtnContainerOpen = '<div class="button-container">';
  128. $extraBtnContainerOpenRemoveEdit = '<div class="button-container remove edit">';
  129. $extraBtnContainerClose = '</div>';
  130. ?>
  131. <div class="form-field wcemessage_search_field">
  132. <?php
  133. // if NEW 2.2.0 data is saved for this Order Status
  134. if ( !empty( $wcemessage_id_currentStatus ) ) {
  135. echo getMessageTitle( $wcemessage_id_currentStatus, $statusName );
  136. $editURL = admin_url('post.php?post='.$wcemessage_id_currentStatus.'&action=edit');
  137. $editBtn = '<a href="'.$editURL.'" target="_blank" class="button edit-wcemessage" alt="'.__('Edit','woocommerce').'" title="'.__('Edit','woocommerce').'"><span class="dashicons dashicons-edit"></span></a>';
  138. $removeBtn = '<a href="#" class="button remove-wcemessage" alt="'.__('Remove','woocommerce').'" title="'.__('Remove','woocommerce').'"><span class="dashicons dashicons-no"></span></a>';
  139. $wcemessage_controls = $extraBtnContainerOpenRemoveEdit . $removeBtn . $editBtn . $extraBtnContainerClose;
  140. } else {
  141. // if previous data is saved for this Order Status
  142. if ( $customcontent_orderstatus == ( 'woocommerce_order_status_'.$statusSlug ) ) {
  143. // Check if a message ID has been assigned
  144. if ( !empty( $wcemessage_id ) ){
  145. $wcemessage_title = get_the_title( $wcemessage_id );
  146. $editURL = admin_url('post.php?post='.$wcemessage_id.'&action=edit');
  147. $editBtn = '<a href="'.$editURL.'" target="_blank" class="button edit-wcemessage" alt="'.__('Edit','woocommerce').'" title="'.__('Edit','woocommerce').'"><span class="dashicons dashicons-edit"></span></a>';
  148. $removeBtn = '<a href="#" class="button remove-wcemessage" alt="'.__('Remove','woocommerce').'" title="'.__('Remove','woocommerce').'"><span class="dashicons dashicons-no"></span></a>';
  149. $wcemessage_controls = $extraBtnContainerOpenRemoveEdit . $removeBtn . $editBtn . $extraBtnContainerClose;
  150. // Check if this message is Published
  151. if ( get_post_status( $wcemessage_id ) !== 'publish' ) {
  152. // Saved WCE Message is not published, show Invalid message
  153. $wcemessage_saved_text = '(' . __('Invalid Message Selected', 'woocommerce') . ')';
  154. } else {
  155. // Saved WCE Message is published
  156. $wcemessage_saved_text = $wcemessage_title . '';
  157. }
  158. ?>
  159. <input class="wcemessage_search_field_input" type="text" value="<?php echo $wcemessage_saved_text; ?>" name="wcemessage_search_<?php echo $statusName; ?>" id="wcemessage_search_<?php echo $statusName; ?>" placeholder="<?php echo __( 'Search Custom Messages...', 'woocommerce' ); ?>" autocomplete="off"></input>
  160. <?php
  161. } else {
  162. // Order Status assigned, but No WCE Message assigned = probably not a real world scenario
  163. $wcemessage_controls = $extraBtnContainerOpen . $extraBtnContainerClose;
  164. ?>
  165. <input class="wcemessage_search_field_input" type="text" name="wcemessage_search_<?php echo $statusName; ?>" id="wcemessage_search_<?php echo $statusName; ?>" placeholder="<?php echo __( 'Search Custom Messages...', 'woocommerce' ); ?>" autocomplete="off"></input>
  166. <?php
  167. }
  168. } else {
  169. // No previous WCE data saved
  170. $wcemessage_controls = $extraBtnContainerOpen . $extraBtnContainerClose;
  171. ?>
  172. <input class="wcemessage_search_field_input" type="text" name="wcemessage_search_<?php echo $statusName; ?>" id="wcemessage_search_<?php echo $statusName; ?>" placeholder="<?php echo __( 'Search Custom Messages...', 'woocommerce' ); ?>" autocomplete="off"></input>
  173. <?php
  174. }
  175. }
  176. ?>
  177. <div class="wcemessage_search_results hide" id="wcemessage_<?php echo $statusName; ?>_search_results">
  178. <div class="wcemessage_search_results_wrap">
  179. <p class="placeholder"><?php echo __( 'Search results will appear here', 'woocommerce' ); ?></p>
  180. </div>
  181. </div>
  182. </div>
  183. <?php
  184. echo $wcemessage_controls;
  185. $hiddenFieldVal = '';
  186. // if NEW 2.2.0 data is saved for this Order Status
  187. if ( !empty( $wcemessage_id_currentStatus ) ) {
  188. $hiddenFieldVal = $wcemessage_id_currentStatus;
  189. } else if ( $customcontent_orderstatus == ( 'woocommerce_order_status_'.$statusSlug ) ) {
  190. $hiddenFieldVal = $wcemessage_id;
  191. }
  192. ?>
  193. <input class="wcemessage_search_field_hidden" type="hidden" name="wcemessage_id_<?php echo $statusName; ?>" id="wcemessage_id_<?php echo $statusName; ?>" value="<?php echo $hiddenFieldVal; ?>" />
  194. <?php
  195. }
  196. /*
  197. * Reusable function to return a drop down menu of template locations
  198. */
  199. function showLocationSelect( $statusName = '' ){
  200. $location_select_arr = array(
  201. 'woocommerce_email_before_order_table' => __( 'Before Order Table', 'woocommerce' ),
  202. 'woocommerce_email_after_order_table' => __( 'After Order Table', 'woocommerce' ),
  203. 'woocommerce_email_order_meta' => __( 'After Order Meta', 'woocommerce' ),
  204. 'woocommerce_email_customer_details' => __( 'After Customer Details', 'woocommerce' )
  205. );
  206. if ($statusName == 'onhold'){
  207. $statusSlug = 'on-hold';
  208. } else {
  209. $statusSlug = $statusName;
  210. }
  211. $currentStatusLocation = get_post_meta( get_the_ID(), 'location_'.$statusName, true );
  212. $old_orderStatus = get_post_meta( get_the_ID(), 'order_status', true );
  213. $old_orderLocation = get_post_meta( get_the_ID(), 'location', true );
  214. // if NEW 2.2.0 data is saved for this Order Status
  215. if ( !empty( $currentStatusLocation ) ) {
  216. // Select with New Saved Value
  217. woocommerce_wp_select(
  218. array(
  219. 'id' => $statusName.'-location',
  220. 'label' => '',
  221. 'options' => $location_select_arr,
  222. 'desc_tip' => false,
  223. 'value' => $currentStatusLocation // Use new saved value
  224. )
  225. );
  226. } else {
  227. // if previous data has been saved for the current Order Status
  228. if ( $old_orderStatus == ( 'woocommerce_order_status_'.$statusName ) ){
  229. // if previous data is saved for this Order Status
  230. if ( !empty( $old_orderLocation ) ) {
  231. // Select with Old Saved Value
  232. woocommerce_wp_select(
  233. array(
  234. 'id' => $statusName.'-location',
  235. 'label' => '',
  236. 'options' => $location_select_arr,
  237. 'desc_tip' => false,
  238. 'value' => $old_orderLocation // Use old saved value
  239. )
  240. );
  241. } else {
  242. // Select with no Default Value
  243. woocommerce_wp_select(
  244. array(
  245. 'id' => $statusName.'-location',
  246. 'label' => '',
  247. 'options' => $location_select_arr,
  248. 'desc_tip' => false,
  249. )
  250. );
  251. }
  252. } else {
  253. // No data has been saved for the current Order Status
  254. // Select with no Default Value
  255. woocommerce_wp_select(
  256. array(
  257. 'id' => $statusName.'-location',
  258. 'label' => '',
  259. 'options' => $location_select_arr,
  260. 'desc_tip' => false,
  261. )
  262. );
  263. }
  264. }
  265. }
  266. ?>
  267. <!-- // ON-HOLD ***************************************************** // -->
  268. <div class="table-row">
  269. <div class="status order_status">
  270. <mark class="order-status status-on-hold">
  271. <span><?php echo __( 'On hold', 'woocommerce' ); ?></span>
  272. </mark>
  273. </div>
  274. <div class="message">
  275. <?php showSavedMessage('onhold'); ?>
  276. </div>
  277. <div class="location">
  278. <?php showLocationSelect('onhold'); ?>
  279. </div>
  280. </div>
  281. <!-- // PROCESSING ***************************************************** // -->
  282. <div class="table-row">
  283. <div class="status order_status">
  284. <mark class="order-status status-processing">
  285. <span><?php echo __( 'Processing', 'woocommerce'); ?></span>
  286. </mark>
  287. </div>
  288. <div class="message">
  289. <?php showSavedMessage('processing'); ?>
  290. </div>
  291. <div class="location">
  292. <?php showLocationSelect('processing'); ?>
  293. </div>
  294. </div>
  295. <!-- // COMPLETED ***************************************************** // -->
  296. <div class="table-row">
  297. <div class="status order_status">
  298. <mark class="order-status status-completed">
  299. <span><?php echo __( 'Completed', 'woocommerce' ); ?></span>
  300. </mark>
  301. </div>
  302. <div class="message">
  303. <?php showSavedMessage('completed'); ?>
  304. </div>
  305. <div class="location">
  306. <?php showLocationSelect('completed'); ?>
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. </div>
  312. <?php
  313. }
  314. //* AJAX Fetch JS
  315. public function ajax_wce_fetch_script() {
  316. ?>
  317. <script type="text/javascript">
  318. function fetch_wce_posts_onhold(){
  319. jQuery.ajax({
  320. url: '<?php echo admin_url('admin-ajax.php'); ?>',
  321. type: 'post',
  322. data: { action: 'wce_data_fetch', keyword: jQuery('#wcemessage_search_onhold').val() },
  323. success: function(data) {
  324. jQuery('#wcemessage_onhold_search_results .wcemessage_search_results_wrap').html( data );
  325. }
  326. });
  327. }
  328. function fetch_wce_posts_processing(){
  329. jQuery.ajax({
  330. url: '<?php echo admin_url('admin-ajax.php'); ?>',
  331. type: 'post',
  332. data: { action: 'wce_data_fetch', keyword: jQuery('#wcemessage_search_processing').val() },
  333. success: function(data) {
  334. jQuery('#wcemessage_processing_search_results .wcemessage_search_results_wrap').html( data );
  335. }
  336. });
  337. }
  338. function fetch_wce_posts_completed(){
  339. jQuery.ajax({
  340. url: '<?php echo admin_url('admin-ajax.php'); ?>',
  341. type: 'post',
  342. data: { action: 'wce_data_fetch', keyword: jQuery('#wcemessage_search_completed').val() },
  343. success: function(data) {
  344. jQuery('#wcemessage_completed_search_results .wcemessage_search_results_wrap').html( data );
  345. }
  346. });
  347. }
  348. jQuery(document).ready( function($) {
  349. // Apply onkeyup behavior
  350. $('#wcemessage_search_onhold').keyup(function () {
  351. fetch_wce_posts_onhold();
  352. });
  353. $('#wcemessage_search_processing').keyup(function () {
  354. fetch_wce_posts_processing();
  355. });
  356. $('#wcemessage_search_completed').keyup(function () {
  357. fetch_wce_posts_completed();
  358. });
  359. // Show Content button
  360. $(document).on('click', '.show-oldcustomcontent', function(e){
  361. // Don't jump to top of page
  362. e.preventDefault();
  363. // Hide this button
  364. $(this).addClass('hide');
  365. // Show 'Hide Content' button
  366. $('.button.hide-oldcustomcontent.hide').removeClass('hide');
  367. // Show 'Custom Content' textarea
  368. $('#old-customcontent-meta.hide').removeClass('hide');
  369. });
  370. // Hide Content button
  371. $(document).on('click', '.hide-oldcustomcontent', function(e){
  372. // Don't jump to top of page
  373. e.preventDefault();
  374. // Hide this button
  375. $(this).addClass('hide');
  376. // Show 'Show Content' button
  377. $('.button.show-oldcustomcontent.hide').removeClass('hide');
  378. // Hide 'Custom Content' textarea
  379. $('#old-customcontent-meta').addClass('hide');
  380. });
  381. /* ---------------------------- 2.2.0 --------------------------- */
  382. var allHidden = false;
  383. function hideAllSearchResultsBoxes() {
  384. if ( allHidden !== true ) {
  385. // Hide all SR boxes
  386. $('.wcemessage_search_results').addClass('hide');
  387. // Assign 'allHidden' var to true
  388. allHidden = true;
  389. }
  390. }
  391. function hideSearchResultsBox(thisElem) {
  392. // Add 'hide' class to closest SR box
  393. thisElem.closest('.message').find('.wcemessage_search_results').addClass('hide');
  394. }
  395. function showSearchResultsBox(thisElem) {
  396. // Remove 'hide' class from closest SR box
  397. thisElem.closest('.message').find('.wcemessage_search_results').removeClass('hide');
  398. allHidden = false;
  399. }
  400. // Click functions
  401. $(document).on('click', function(e) {
  402. var target = e.target;
  403. var targetClass = target.className;
  404. if ( targetClass == 'wcemessage_search_field_input' ) {
  405. /* SEARCH FIELD CLICKED - SHOW SEARCH RESULTS MODAL
  406. --------------------------------------------------------- */
  407. // Don't jump to top of page
  408. e.preventDefault();
  409. // Hide all search results elements
  410. $('.wcemessage_search_results').addClass('hide');
  411. // Remove 'hide' class from closest search results box
  412. showSearchResultsBox( $(e.target) );
  413. // Focus on the search results box that was clicked
  414. $(e.target).closest('.message').focus();
  415. } else if ( targetClass == 'wce-search-result' ) {
  416. /* SEARCH RESULT CLICKED - ASSIGN CUSTOM EMAIL MESSAGE
  417. --------------------------------------------------------- */
  418. // Don't jump to top of page
  419. e.preventDefault();
  420. // Define vars
  421. var theid = $(e.target).attr('data-id');
  422. var thetitle = $(e.target).attr('data-title');
  423. // Update field values
  424. $(e.target).closest('.table-row').find('.wcemessage_search_field_hidden').val(theid); // hidden field
  425. $(e.target).closest('.table-row').find('.wcemessage_search_field_input').val(thetitle); // search field
  426. // Add a new 'Remove' button if not already present
  427. $(e.target).closest('.table-row').find('.button-container:not(.remove)').addClass('remove').html('<a href="#" class="button remove-wcemessage" alt="Remove" title="Remove"><span class="dashicons dashicons-no"></span></a>');
  428. // Add 'hide' class to closest search results box
  429. hideSearchResultsBox( $(e.target) );
  430. } else {
  431. /* NORMAL PAGE ELEMENT CLICKED - HIDE ALL SEARCH RESULTS BOXES
  432. --------------------------------------------------------- */
  433. hideAllSearchResultsBoxes();
  434. }
  435. });
  436. // Remove button
  437. $(document).on('click', '.remove-wcemessage', function(e) {
  438. // Don't jump to top of page
  439. e.preventDefault();
  440. // Hide Edit buttons
  441. $(this).closest('.table-row').find('.button-container').find('.button').addClass('hide');
  442. // Remove field values
  443. $(this).closest('.table-row').find('.wcemessage_search_field_input').val('');
  444. $(this).closest('.table-row').find('.wcemessage_search_field_hidden').val('');
  445. // Remove CSS classes
  446. $(this).closest('.button-container').removeClass('remove');
  447. $(this).closest('.button-container').removeClass('edit');
  448. });
  449. });
  450. </script>
  451. <?php
  452. }
  453. // AJAX Fetch function.
  454. public function wce_data_fetch() {
  455. $search_term = esc_attr( $_POST['keyword'] );
  456. $args = array(
  457. 'post_type' => 'woocustomemails',
  458. 'post_status' => 'publish',
  459. 'posts_per_page' => -1,
  460. 's' => $search_term
  461. );
  462. $the_query = new WP_Query($args);
  463. if( $the_query->have_posts() ) {
  464. while( $the_query->have_posts() ): $the_query->the_post();
  465. $thePermalink = esc_url( post_permalink() );
  466. $theID = get_the_ID();
  467. $theTitle = get_the_title();
  468. ?>
  469. <p><a href="#" class="wce-search-result" data-id="<?php echo $theID; ?>" data-title="<?php echo $theTitle; ?>"><?php echo $theID; ?> - <?php echo $theTitle; ?></a></p>
  470. <?php
  471. endwhile;
  472. wp_reset_postdata();
  473. } else {
  474. $addMessagesURL = admin_url('edit.php?post_type=woocustomemails');
  475. $addMessagesText = '<a href="'.$addMessagesURL.'" target="_blank" class="edit-wcemessage">'.__('Custom Email Messages','woocommerce').'</a>';
  476. ?>
  477. <p class="placeholder error"><?php echo __( 'Sorry! No posts match your search. Please add some ', 'woocommerce' ) . $addMessagesText . __( ' and try again.', 'woocommerce' ) ?></p>
  478. <?php
  479. }
  480. die();
  481. }
  482. /** Hook callback function to save custom fields information */
  483. public function save_woo_custom_emails_tab_fields( $post_id ) {
  484. // Save Order Status
  485. $select = $_POST['order_status'];
  486. if ( !empty( $select ) ) {
  487. update_post_meta( (int) $post_id, 'order_status', (string) esc_attr( $select ) );
  488. }
  489. // Save 'wcemessage_id' Hidden Field
  490. update_post_meta( $post_id, 'wcemessage_id', $_POST['wcemessage_id'] );
  491. // Save Order Status
  492. $select = $_POST['location'];
  493. if ( !empty( $select ) ) {
  494. update_post_meta( $post_id, 'location', esc_attr( $select ) );
  495. }
  496. /* 2.2.0
  497. ********************************************************************* */
  498. update_post_meta( $post_id, 'wcemessage_id_onhold', $_POST['wcemessage_id_onhold'] );
  499. update_post_meta( $post_id, 'location_onhold', esc_attr( $_POST['onhold-location'] ) );
  500. update_post_meta( $post_id, 'wcemessage_id_processing', $_POST['wcemessage_id_processing'] );
  501. update_post_meta( $post_id, 'location_processing', esc_attr( $_POST['processing-location'] ) );
  502. update_post_meta( $post_id, 'wcemessage_id_completed', $_POST['wcemessage_id_completed'] );
  503. update_post_meta( $post_id, 'location_completed', esc_attr( $_POST['completed-location'] ) );
  504. }
  505. }