<commit_before><?php

/**
 * Woocommerce CiviCRM Orders Contact Tab class.
 *
 * @since 2.0
 */
class Woocommerce_CiviCRM_Orders_Contact_Tab {

	/**
	 * Initialises this object.
	 *
	 * @since 2.0
	 */
	public function __construct() {
		$this->register_hooks();
	}

	/**
	 * Register hooks
	 *
	 * @since 0.2
	 */
	public function register_hooks() {
		// register custom php directory
		add_action( 'civicrm_config', array( $this, 'register_custom_php_directory' ), 10, 1 );
		// register custom template directory
		add_action( 'civicrm_config', array( $this, 'register_custom_template_directory' ), 10, 1 );
    // register menu callback
		add_filter( 'civicrm_xmlMenu', array( $this, 'register_callback' ), 10, 1 );
		// Add Civicrm settings tab
		add_filter( 'civicrm_tabset', array( $this, 'add_orders_contact_tab' ), 10, 3 );
	}

	/**
	 * Register php directory.
	 *
	 * @since 2.0
	 * @param object $config The CiviCRM config object
	 */
	public function register_custom_php_directory( &$config ){

		$custom_path = WOOCOMMERCE_CIVICRM_PATH . 'custom_php';
		$include_path = $custom_path . PATH_SEPARATOR . get_include_path();
		set_include_path( $include_path );

	}

	/**
	 * Register template directory.
	 *
	 * @since 2.0
	 * @param object $config The CiviCRM config object
	 */
	public function register_custom_template_directory( &$config ){

		$custom_path = WOOCOMMERCE_CIVICRM_PATH . 'custom_tpl';
		$template = CRM_Core_Smarty::singleton()->addTemplateDir( $custom_path );
		$include_template_path = $custom_path . PATH_SEPARATOR . get_include_path();
		set_include_path( $include_template_path );

	}

  /**
	 * Register XML file.
	 *
	 * @since 2.0
	 * @param array $files The array for files used to build the menu
	 */
  public function register_callback( &$files ){
		$files[] = dirname(__FILE__) . '/xml/menu.xml';
	}

	/**
	 * Add CiviCRM tab to the settings page.
	 *
	 * @since 2.0
	 * @uses 'woocommerce_settings_tabs_array' filter
	 * @param array $setting_tabs The setting tabs array
	 * @return array $setting_tabs The setting tabs array
	 */
	public function add_orders_contact_tab( $tabsetName, &$tabs, $context ) {
		$uid = CRM_Core_BAO_UFMatch::getUFId( $context['contact_id'] );
		if (empty($uid)) {
			return;
		}

		$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
	    'numberposts' => -1,
	    'meta_key'    => '_customer_user',
	    'meta_value'  => $uid,
	    'post_type'   => 'shop_order',
	    'post_status' => array_keys( wc_get_order_statuses() )
	  ) ) );

	  $site_url = get_site_url();
	  $orders = array();
	  foreach ( $customer_orders as $customer_order ) {
	    $order = new WC_Order();<commit_msg>fix xml path<commit_after><?php

/**
 * Woocommerce CiviCRM Orders Contact Tab class.
 *
 * @since 2.0
 */
class Woocommerce_CiviCRM_Orders_Contact_Tab {

	/**
	 * Initialises this object.
	 *
	 * @since 2.0
	 */
	public function __construct() {
		$this->register_hooks();
	}

	/**
	 * Register hooks
	 *
	 * @since 0.2
	 */
	public function register_hooks() {
		// register custom php directory
		add_action( 'civicrm_config', array( $this, 'register_custom_php_directory' ), 10, 1 );
		// register custom template directory
		add_action( 'civicrm_config', array( $this, 'register_custom_template_directory' ), 10, 1 );
    // register menu callback
		add_filter( 'civicrm_xmlMenu', array( $this, 'register_callback' ), 10, 1 );
		// Add Civicrm settings tab
		add_filter( 'civicrm_tabset', array( $this, 'add_orders_contact_tab' ), 10, 3 );
	}

	/**
	 * Register php directory.
	 *
	 * @since 2.0
	 * @param object $config The CiviCRM config object
	 */
	public function register_custom_php_directory( &$config ){

		$custom_path = WOOCOMMERCE_CIVICRM_PATH . 'custom_php';
		$include_path = $custom_path . PATH_SEPARATOR . get_include_path();
		set_include_path( $include_path );

	}

	/**
	 * Register template directory.
	 *
	 * @since 2.0
	 * @param object $config The CiviCRM config object
	 */
	public function register_custom_template_directory( &$config ){

		$custom_path = WOOCOMMERCE_CIVICRM_PATH . 'custom_tpl';
		$template = CRM_Core_Smarty::singleton()->addTemplateDir( $custom_path );
		$include_template_path = $custom_path . PATH_SEPARATOR . get_include_path();
		set_include_path( $include_template_path );

	}

  /**
	 * Register XML file.
	 *
	 * @since 2.0
	 * @param array $files The array for files used to build the menu
	 */
  public function register_callback( &$files ){
		$files[] = WOOCOMMERCE_CIVICRM_PATH . 'xml/menu.xml';
	}

	/**
	 * Add CiviCRM tab to the settings page.
	 *
	 * @since 2.0
	 * @uses 'woocommerce_settings_tabs_array' filter
	 * @param array $setting_tabs The setting tabs array
	 * @return array $setting_tabs The setting tabs array
	 */
	public function add_orders_contact_tab( $tabsetName, &$tabs, $context ) {
		$uid = CRM_Core_BAO_UFMatch::getUFId( $context['contact_id'] );
		if (empty($uid)) {
			return;
		}

		$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
	    'numberposts' => -1,
	    'meta_key'    => '_customer_user',
	    'meta_value'  => $uid,
	    'post_type'   => 'shop_order',
	    'post_status' => array_keys( wc_get_order_statuses() )
	  ) ) );

	  $site_url = get_site_url();
	  $orders = array();
	  foreach ( $customer_orders as $customer_order ) {
	    $order = new WC_Order();
{'fraction_non_alphanumeric': 0.1303058387395737, 'fraction_numerical': 0.010009267840593142, 'mean_word_length': 3.878842676311031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 7}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3312143', 'n_tokens_mistral': 2032, 'n_tokens_neox': 1828, 'n_words': 425}