PATH:
home
/
bkunreyz
/
managedmedia.org
/
wp-content
/
plugins
/
optinmonster
/
OMAPI
<?php /** * Revenue attribution class. * * @since 2.6.13 * * @package OMAPI * @author Thomas Griffin */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * The Revenue Attribution class. * * @since 2.6.13 */ class OMAPI_RevenueAttribution { /** * Holds the class object. * * @since 2.6.13 * * @var object */ public static $instance; /** * Path to the file. * * @since 2.6.13 * * @var string */ public $file = __FILE__; /** * Holds the base class object. * * @since 2.6.13 * * @var object */ public $base; /** * Primary class constructor. * * @since 2.6.13 */ public function __construct() { // Set our object. $this->set(); } /** * Sets our object instance and base class instance. * * @since 2.6.13 */ public function set() { self::$instance = $this; $this->base = OMAPI::get_instance(); } /** * Maybe stores revenue attribution data when a purchase is successful. * * @since 2.6.13 * * @param array $data An array of revenue attribution data to store. * * @return bool|WP_Error True if successful, WP_Error or false otherwise. */ public function store( $data = array() ) { // If revenue attribution is not turned on, return early. $ra = $this->base->get_revenue_attribution(); if ( empty( $ra['enabled'] ) || empty( $ra['currency'] ) ) { return false; } // If we can't find the account ID, return early. $accountId = $this->base->get_option( 'accountId' ); if ( empty( $accountId ) ) { return false; } // Build and send the request. $api = OMAPI_Api::build( 'v2', 'revenue/' . $accountId, 'POST' ); return $api->request( $data ); } /** * Returns revenue attribution data. * * @since 2.6.13 * * @return array An array of revenue attribution data. */ public function get_revenue_data() { // If we don't have any cookies set for OM campaigns, return early. if ( empty( $_COOKIE['_omra'] ) ) { return array(); } // If revenue attribution is not turned on, return early. $ra = $this->base->get_revenue_attribution(); if ( empty( $ra['enabled'] ) || empty( $ra['currency'] ) ) { return array(); } // Loop through and prepare the campaign data. If it is empty, return early. $campaign_data = json_decode( stripslashes( rawurldecode( $_COOKIE['_omra'] ) ), true ); if ( empty( $campaign_data ) ) { return array(); } // Sanitize the campaign data before sending it back. $sanitized_campaigns = array(); foreach ( $campaign_data as $campaign_id => $action ) { $sanitized_campaigns[ esc_html( $campaign_id ) ] = esc_html( $action ); } // Return the default revenue attribution data. Additional revenue // data should be returned from the integration itself (such as // the total, transaction ID, etc.). return array( 'campaigns' => $sanitized_campaigns, 'currency' => esc_html( $ra['currency'] ), 'device' => wp_is_mobile() ? 'mobile' : 'desktop', 'type' => 'sale', ); } }
[-] Refresh.php
[edit]
[-] InstallSkin.php
[edit]
[-] Inserter.php
[edit]
[-] Promos.php
[edit]
[-] Review.php
[edit]
[+]
Shortcodes
[-] ApiKey.php
[edit]
[-] ConstantContact.php
[edit]
[+]
Rules
[-] Actions.php
[edit]
[-] Pages.php
[edit]
[-] Widget.php
[edit]
[-] MailPoet.php
[edit]
[-] MemberPress.php
[edit]
[-] Menu.php
[edit]
[-] Ajax.php
[edit]
[-] Save.php
[edit]
[-] Shortcode.php
[edit]
[-] Debug.php
[edit]
[-] ClassicEditor.php
[edit]
[-] Sites.php
[edit]
[-] RevenueAttribution.php
[edit]
[-] Partners.php
[edit]
[-] Blocks.php
[edit]
[-] Api.php
[edit]
[+]
WPForms
[+]
Elementor
[-] Support.php
[edit]
[-] InstallSkinCompat.php
[edit]
[-] Validate.php
[edit]
[+]
..
[-] Output.php
[edit]
[-] OmuApi.php
[edit]
[+]
Integrations
[-] WpErrorException.php
[edit]
[-] Welcome.php
[edit]
[-] RestApi.php
[edit]
[-] EasyDigitalDownloads.php
[edit]
[-] WooCommerce.php
[edit]
[+]
EasyDigitalDownloads
[-] Rules.php
[edit]
[-] Urls.php
[edit]
[+]
WooCommerce
[-] Elementor.php
[edit]
[-] Notifications.php
[edit]
[-] Utils.php
[edit]
[+]
MemberPress
[+]
Plugins
[-] WPForms.php
[edit]
[-] ApiAuth.php
[edit]
[-] Type.php
[edit]
[-] Plugins.php
[edit]
[-] BaseRestApi.php
[edit]
[+]
Promos
[-] AssetLoader.php
[edit]