PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
plugins
/
vxcash
/
public
<?php /** * Created by PhpStorm. * User: te * Date: 20.06.2016 * Time: 13:43 */ class Vxcash_Bas { /** * @var Vxcash_Bas_Dataprovider */ private $dataprovider; /** * @var Vxcash_Loader */ private $loader; /** * @var Vxcash_Config */ private $config; /** * Vxcash_Bas constructor. * * @param Vxcash_Bas_Dataprovider $dataprovider * @param Vxcash_Loader $loader * @param Vxcash_Config $config */ public function __construct(Vxcash_Bas_Dataprovider $dataprovider, Vxcash_Loader $loader, Vxcash_Config $config) { $this->dataprovider = $dataprovider; $loader->add_action('init', $this, 'setup'); $loader->add_action('wp_ajax_get_bas_hosts', $this, 'getHostList'); $loader->add_action('wp_ajax_nopriv_get_bas_hosts', $this, 'getHostList'); $loader->add_action('wp_ajax_get_single_bas_host', $this, 'getSingleHost'); $loader->add_action('wp_ajax_nopriv_get_single_bas_host', $this, 'getSingleHost'); $loader->add_action('wp_ajax_get_connection', $this, 'getChatUrl'); $loader->add_action('wp_ajax_nopriv_get_connection', $this, 'getChatUrl'); $this->config = $config; } /** * Start setup */ public function setup() { $this->updateDataFromRemote(); } public function getHostList() { if ($this->config->getBasApiKey() === '') { echo json_encode([]); wp_die(); } echo json_encode($this->dataprovider->getHostList()); wp_die(); } public function getSingleHost( ) { if ($this->config->getBasApiKey() === '') { echo json_encode([]); wp_die(); } $id = $_REQUEST['id']; echo json_encode($this->dataprovider->getSingleHostFromRemote($id)); wp_die(); } /** * @param array $args */ public function showBasList($args = array()) { if ($this->config->getBasApiKey() === '') { return; } $minAge = isset($args['minAge']) ? (int) $args['minAge'] : 18; $maxAge = isset($args['maxAge']) ? (int) $args['maxAge'] : 100; $arguments = array( 'limit' => isset($args['limit']) ? $args['limit'] : 0, 'pagination' => isset($args['pagination']) ? $args['pagination'] : 0, 'languages' => isset($args['languages']) ? $args['languages'] : 'de,at,ch', 'minAge' => $minAge, 'maxAge' => $maxAge, 'attributes' => isset($args['attributes']) ? $args['attributes'] : '' ); printf("<div class=\"list-holder-bas\" data-arguments='%s'></div>", json_encode($arguments)); } /** * Shows the "Call now" button if there is a valid bas Host for this id * * @param $hostId */ public function showBasButton($hostId) { if (!$this->dataprovider->hasNumbers()) { return; } if ($this->config->getBasApiKey() === '') { return; } $theme = wp_get_theme(); $host = $this->dataprovider->getInfoForHost($hostId); if ($host instanceof Vxcash_Bas_Host && $host->getState() !== 'offline') { $this->getBasCallButtonScript(); $url = plugins_url('/vxcash/public/img/telefon.png'); $image = "<img src='$url' alt=''>"; if ($theme->get_stylesheet() === 'vxcash2') { $image = '<i class="fa fa-phone-vx fa-lg fa-fw"></i>'; } echo "<a class=\"basCallBtn\" data-hostid='$hostId' id='$hostId' data-host='" . json_encode($host) . "' href='#basTarget$hostId'>{$image} Jetzt anrufen</a>"; } } /** * */ private function updateDataFromRemote() { if ($this->config->getBasApiKey() === '') { return; } $now = new DateTime(); $lastNumberUpdate = get_option('vxBasNumberUpdateInterval', new DateTime('1980-01-01')); $diffNumbers = $now->diff($lastNumberUpdate); if ($diffNumbers->days > 0 || !$this->dataprovider->hasNumbers()) { // Every day update if ($this->dataprovider->updateNumbersFromRemote()) { update_option('vxBasNumberUpdateInterval', $now); } } } public function getChatUrl() { $code = $_POST['code']; $url = $_POST['url']; $chatInfo = $this->dataprovider->getChatInfo($code, $url); echo json_encode($chatInfo); wp_die(); } private function getBasCallButtonScript() { wp_register_script('sockjs', plugins_url('/js/sockjs.js', __FILE__)); wp_register_script('bas_button_checker', plugins_url('/../dist/callbutton.js', __FILE__), array('sockjs')); wp_enqueue_script('bas_button_checker'); } }
[+]
img
[-] class-vxcash-bas-dataprovider.php
[edit]
[-] class-vxcash-bas-country.php
[edit]
[-] class-vxcash-public.php
[edit]
[-] index.php
[edit]
[+]
js
[+]
partials
[-] class-vxcash-bas-host.php
[edit]
[-] class-vxcash-bas.php
[edit]
[+]
..
[+]
css
[-] class-vxcash-crosselling.php
[edit]