options = get_option( 'woocustomemails_settings_name' ); $display_classes_default = 'show_if_simple, show_if_variable, show_if_external, show_if_downloadable, show_if_grouped'; $display_classes_setting = ''; if( isset( $this->options['display_classes'] ) ) { // Data is set $display_classes_setting = $display_classes_default . ', ' . $this->options['display_classes']; } else { // No Data set $display_classes_setting = $display_classes_default; } // Remove whitespace $display_classes_setting = str_replace(' ', '', $display_classes_setting); // Turn string into array $display_classes_arr = explode(",", $display_classes_setting); $new_custom_tab['woo-custom-emails'] = array( 'label' => __( 'Custom Emails', 'woocommerce' ), 'target' => 'woo_custom_emails_product_data', 'class' => $display_classes_arr, ); $insert_at_position = 2; // position in tab list $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 $tabs = array_merge( $tabs, $new_custom_tab ); // Add our new tab into the array $tabs = array_merge( $tabs, array_slice( $original_prodata_tabs, $insert_at_position, null, true ) ); // Append the last part of tabs array return $tabs; } public function wce_custom_admin_style() { include_once( dirname(__FILE__) . '/woocustomemails-admin-styles.css' ); } public function wce_enqueue_custom_admin_style() { global $pagenow; if ( $pagenow !== 'edit.php' ) { return; } wp_register_style( 'wcepp_custom_admin_css', plugins_url( 'woocustomemails-admin-styles.css', __FILE__ ), '1.0', false ); wp_enqueue_style( 'wcepp_custom_admin_css' ); include_once( dirname(__FILE__) . '/woocustomemails-admin-styles.css' ); } // Setup 'Custom Emails' Product Data tab public function add_woo_custom_emails_tab_fields() { global $post; // Get WCE Settings $this->options = get_option( 'woocustomemails_settings_name' ); $show_old_content = false; // Get Meta from this Post $this_product_id = get_the_ID(); $customcontent_meta = get_post_meta( $this_product_id, 'custom_content', true ); // Note the 'id' attribute MUST match the 'target' parameter set above. ?>
'; // Check if this message is Published. if ( get_post_status( $msgID ) !== 'publish' ) { // Saved WCE Message is not published, show Invalid message. $wcemessage_saved_text = '(' . __('Invalid Message Selected', 'woocommerce') . ')'; } else { // Saved WCE Message is published. $wcemessage_saved_text = $wcemessage_title . ''; } $defaultSearchMsg = __( 'Search Custom Messages...', 'woocommerce' ); $returnStr = ''; return $returnStr; } /* * Reusable function to display the saved WCE Message */ function showSavedMessage( $statusName = '' ) { // set Status "slug" if ($statusName == 'onhold'){ $statusSlug = 'on-hold'; } else { $statusSlug = $statusName; } $postID = get_the_ID(); $wcemessage_id = get_post_meta( $postID, 'wcemessage_id', true ); $wcemessage_id_currentStatus = ''; $wcemessage_id_currentStatus = get_post_meta( $postID, 'wcemessage_id_'.$statusName, true ); $wcemessage_controls = ''; $customcontent_orderstatus = ''; $customcontent_orderstatus = get_post_meta( $postID, 'order_status', true ); $extraBtnContainerOpen = '
'; $extraBtnContainerOpenRemoveEdit = '
'; $extraBtnContainerClose = '
'; ?>
'; $removeBtn = ''; $wcemessage_controls = $extraBtnContainerOpenRemoveEdit . $removeBtn . $editBtn . $extraBtnContainerClose; } else { // if previous data is saved for this Order Status if ( $customcontent_orderstatus == ( 'woocommerce_order_status_'.$statusSlug ) ) { // Check if a message ID has been assigned if ( !empty( $wcemessage_id ) ){ $wcemessage_title = get_the_title( $wcemessage_id ); $editURL = admin_url('post.php?post='.$wcemessage_id.'&action=edit'); $editBtn = ''; $removeBtn = ''; $wcemessage_controls = $extraBtnContainerOpenRemoveEdit . $removeBtn . $editBtn . $extraBtnContainerClose; // Check if this message is Published if ( get_post_status( $wcemessage_id ) !== 'publish' ) { // Saved WCE Message is not published, show Invalid message $wcemessage_saved_text = '(' . __('Invalid Message Selected', 'woocommerce') . ')'; } else { // Saved WCE Message is published $wcemessage_saved_text = $wcemessage_title . ''; } ?>

__( 'Before Order Table', 'woocommerce' ), 'woocommerce_email_after_order_table' => __( 'After Order Table', 'woocommerce' ), 'woocommerce_email_order_meta' => __( 'After Order Meta', 'woocommerce' ), 'woocommerce_email_customer_details' => __( 'After Customer Details', 'woocommerce' ) ); if ($statusName == 'onhold'){ $statusSlug = 'on-hold'; } else { $statusSlug = $statusName; } $currentStatusLocation = get_post_meta( get_the_ID(), 'location_'.$statusName, true ); $old_orderStatus = get_post_meta( get_the_ID(), 'order_status', true ); $old_orderLocation = get_post_meta( get_the_ID(), 'location', true ); // if NEW 2.2.0 data is saved for this Order Status if ( !empty( $currentStatusLocation ) ) { // Select with New Saved Value woocommerce_wp_select( array( 'id' => $statusName.'-location', 'label' => '', 'options' => $location_select_arr, 'desc_tip' => false, 'value' => $currentStatusLocation // Use new saved value ) ); } else { // if previous data has been saved for the current Order Status if ( $old_orderStatus == ( 'woocommerce_order_status_'.$statusName ) ){ // if previous data is saved for this Order Status if ( !empty( $old_orderLocation ) ) { // Select with Old Saved Value woocommerce_wp_select( array( 'id' => $statusName.'-location', 'label' => '', 'options' => $location_select_arr, 'desc_tip' => false, 'value' => $old_orderLocation // Use old saved value ) ); } else { // Select with no Default Value woocommerce_wp_select( array( 'id' => $statusName.'-location', 'label' => '', 'options' => $location_select_arr, 'desc_tip' => false, ) ); } } else { // No data has been saved for the current Order Status // Select with no Default Value woocommerce_wp_select( array( 'id' => $statusName.'-location', 'label' => '', 'options' => $location_select_arr, 'desc_tip' => false, ) ); } } } ?>
'woocustomemails', 'post_status' => 'publish', 'posts_per_page' => -1, 's' => $search_term ); $the_query = new WP_Query($args); if( $the_query->have_posts() ) { while( $the_query->have_posts() ): $the_query->the_post(); $thePermalink = esc_url( post_permalink() ); $theID = get_the_ID(); $theTitle = get_the_title(); ?>

-

'.__('Custom Email Messages','woocommerce').''; ?>