File "BeaconGetShouldShowStrategy.php"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/flexible-shipping-pro/vendor_prefixed/wpdesk/wp-helpscout-beacon/src/Beacon/BeaconGetShouldShowStrategy.php
File size: 1.08 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace FSProVendor\WPDesk\Beacon;

/**
 * When and if show Beacon.
 */
class BeaconGetShouldShowStrategy implements \FSProVendor\WPDesk\Beacon\BeaconShouldShowStrategy
{
    /**
     * Whether to show beacon on the page or not. Array of arrays with condition for _GET.
     * Inner arrays mean AND, outer arrays mean OR conditions.
     *
     * ie. [ [ .. and .. and ..] or [ .. and .. and ..] or .. ]
     *
     * @var array
     */
    private $conditions;
    public function __construct(array $conditions)
    {
        $this->conditions = $conditions;
    }
    /**
     * Should Beacon be visible?
     *
     * @return bool
     */
    public function shouldDisplay()
    {
        foreach ($this->conditions as $or_conditions) {
            $display = \true;
            foreach ($or_conditions as $parameter => $value) {
                if (!isset($_GET[$parameter]) || $_GET[$parameter] !== $value) {
                    $display = \false;
                }
            }
            if ($display) {
                return $display;
            }
        }
        return \false;
    }
}