Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,38 +11,45 @@
|
||||
namespace IPS\core\Facebook;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Patterns\Singleton;
|
||||
use IPS\Settings;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Facebook Pixel class
|
||||
*/
|
||||
class _Pixel extends \IPS\Patterns\Singleton
|
||||
class Pixel extends Singleton
|
||||
{
|
||||
/**
|
||||
* @brief Singleton Instances
|
||||
*/
|
||||
protected static $instance = NULL;
|
||||
protected static ?Singleton $instance = NULL;
|
||||
|
||||
/**
|
||||
* @brief Data Store
|
||||
*/
|
||||
protected $data = NULL;
|
||||
protected ?array $data = NULL;
|
||||
|
||||
/**
|
||||
* @brief Events
|
||||
*/
|
||||
protected static $events = NULL;
|
||||
protected static ?array $events = NULL;
|
||||
|
||||
/**
|
||||
* Output for JS inclusion
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function output()
|
||||
public function output() : ?string
|
||||
{
|
||||
if ( $this->data === NULL )
|
||||
{
|
||||
@@ -60,7 +67,7 @@ class _Pixel extends \IPS\Patterns\Singleton
|
||||
{
|
||||
$inlineParams = '';
|
||||
|
||||
if ( \is_array( $params ) and \count( $params ) )
|
||||
if ( is_array( $params ) and count( $params ) )
|
||||
{
|
||||
$inlineParams = json_encode( $params );
|
||||
}
|
||||
@@ -75,7 +82,7 @@ class _Pixel extends \IPS\Patterns\Singleton
|
||||
}
|
||||
}
|
||||
|
||||
return \count( $return ) ? implode( "\n", $return ) : null;
|
||||
return count( $return ) ? implode( "\n", $return ) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,11 +90,11 @@ class _Pixel extends \IPS\Patterns\Singleton
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function noscript()
|
||||
public function noscript() : ?string
|
||||
{
|
||||
if ( $this->data === NULL )
|
||||
{
|
||||
return '<img alt="" height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=' . \IPS\Settings::i()->fb_pixel_id . '&ev=PageView&noscript=1"/>';
|
||||
return '<img alt="" height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=' . Settings::i()->fb_pixel_id . '&ev=PageView&noscript=1"/>';
|
||||
}
|
||||
|
||||
$return = array();
|
||||
@@ -99,9 +106,9 @@ class _Pixel extends \IPS\Patterns\Singleton
|
||||
|
||||
foreach( $this->data as $name => $params )
|
||||
{
|
||||
$url = 'https://www.facebook.com/tr?id=' . \IPS\Settings::i()->fb_pixel_id . '&ev=' . $name;
|
||||
$url = 'https://www.facebook.com/tr?id=' . Settings::i()->fb_pixel_id . '&ev=' . $name;
|
||||
|
||||
if ( \is_array( $params ) and \count( $params ) )
|
||||
if ( is_array( $params ) and count( $params ) )
|
||||
{
|
||||
$url .= '&' . http_build_query( array( 'cd' => $params ), '', '&' );
|
||||
}
|
||||
@@ -110,6 +117,6 @@ class _Pixel extends \IPS\Patterns\Singleton
|
||||
|
||||
}
|
||||
|
||||
return \count( $return ) ? implode( "\n", $return ) : null;
|
||||
return count( $return ) ? implode( "\n", $return ) : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user