/** * Install method is called once install this plugin. * create tables, default option ... */ static function activate() { SIB_Model_Contact::create_table(); // Get the country code data SIB_Model_Country::create_table(); $file = fopen(plugin_dir_path(__FILE__) . "/model/country_code.csv", "r"); $country_code = array(); while (!feof($file)) { $code = fgetcsv($file); $country_code[$code[0]] = $code[1]; } fclose($file); SIB_Model_Country::Initialize($country_code); // redirect option update_option('ws_do_activation_redirect', true); }
/** * This method is used to fetch all users from the default customer table to list * them in the SendinBlue PS plugin. */ public static function getCustomers($phone_number = null) { $customer_data = get_users(array('role' => 'customer')); $address_mobilephone = array(); foreach ($customer_data as $customer_detail) { $iso_code = SIB_Model_Country::get_prefix($customer_detail->billing_country); if (count($customer_detail) > 0) { $address_mobilephone[$customer_detail->ID] = array('firstname' => $customer_detail->billing_first_name, 'lastname' => $customer_detail->billing_last_name, 'phone_mobile' => $customer_detail->billing_phone, 'iso_code' => $iso_code); } if ($phone_number != null) { $number = self::checkMobileNumber($customer_detail->billing_phone, $iso_code); if ($phone_number == $number) { return $address_mobilephone[$customer_detail->ID]; } } } if ($phone_number != null) { return "false"; } return $address_mobilephone; }