Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
  1 <?php
  2 
  3 /**
  4  * POS Support
  5  *
  6  * @class    WC_POS_API_Support
  7  * @package  WooCommerce POS
  8  * @author   Paul Kilmurray <paul@kilbot.com.au>
  9  * @link     http://www.woopos.com.au
 10  */
 11 
 12 namespace WC_POS\API;
 13 
 14 use WC_API_Resource;
 15 use WC_API_Server;
 16 
 17 class Support extends WC_API_Resource {
 18 
 19   protected $base = '/pos/support';
 20 
 21   public $support_email = 'support@woopos.com.au';
 22 
 23 
 24   /**
 25    * Register routes for POS Params
 26    *
 27    * GET /pos
 28    *
 29    * @param array $routes
 30    * @return array
 31    */
 32   public function register_routes( array $routes ) {
 33 
 34     # POST /pos/support
 35     $routes[ $this->base ] = array(
 36       array( array( $this, 'send_support_email' ), WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA )
 37     );
 38 
 39     return $routes;
 40 
 41   }
 42 
 43 
 44   /**
 45    * @param $data
 46    * @return array|WP_Error
 47    */
 48   public function send_support_email( $data ) {
 49     $name = isset( $data['name'] ) ? $data['name'] : '' ;
 50     $email = isset( $data['email'] ) ? $data['email'] : '' ;
 51     $message = isset( $data['message'] ) ? $data['message'] : '' ;
 52     $append_report = isset( $data['append_report'] ) ? $data['append_report'] : false ;
 53     $report = isset( $data['report'] ) ? $data['report'] : '' ;
 54 
 55     $headers[]  = 'From: '. $name .' <'. $email .'>';
 56     $headers[]  = 'Reply-To: '. $name .' <'. $email .'>';
 57     $message    = $message . "\n\n";
 58 
 59     if( $append_report ){
 60       $message .= $report;
 61       $message .= $this->get_active_plugins();
 62     }
 63 
 64     $support_email = apply_filters( 'woocommerce_pos_support_email', $this->support_email );
 65 
 66     if( wp_mail( $support_email, 'WooCommerce POS Support', $message, $headers ) ) {
 67       return array(
 68         'result' => 'success',
 69         'message' => __( 'Email sent', 'woocommerce-pos')
 70       );
 71     }
 72 
 73     return new \WP_Error(
 74       'woocommerce_pos_email_error',
 75       __( 'There was an error sending the email', 'woocommerce-pos' ),
 76       array( 'status' => 400 )
 77     );
 78   }
 79 
 80   /**
 81    *
 82    */
 83   public function get_active_plugins(){
 84     $plugins = '*** Active Plugins ***' . "\n\n";
 85 
 86     $active_plugins = (array) get_option( 'active_plugins', array() );
 87 
 88     if ( is_multisite() ) {
 89       $network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
 90       $active_plugins            = array_merge( $active_plugins, $network_activated_plugins );
 91     }
 92 
 93     foreach ( $active_plugins as $plugin ) {
 94       $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
 95       if( ! empty( $plugin_data['Name'] ) ){
 96         $plugins .= $plugin_data['Name'] . ': by ' .  $plugin_data['Author'] . ' - ' . $plugin_data['Version'] . "\n";
 97       }
 98     }
 99 
100     return $plugins;
101 
102   }
103 
104 }
API documentation generated by ApiGen