/** * Get possible destination test types * * @param bool $with_labels Optional. If true, name/description returned. If false, the default only "slugs" * * @return array */ public static function destination_types($with_labels = false, $api_format = false) { $types = self::get_internal_types(); if (!ingot_is_woo_active()) { unset($types['cart_woo']); unset($types['sale_woo']); } if (!ingot_is_edd_active()) { unset($types['cart_edd']); unset($types['sale_edd']); } /** * Allowed test types * * Types are keys, labels are values * * @since 0.0.7 * * @param array $types The allowed click test types */ $types = apply_filters('ingot_allowed_click_types', $types); if ($api_format) { $_types = []; foreach ($types as $value => $type) { $_types[$value] = array_merge($type, ['value' => $value]); } return $_types; } if (false == $with_labels) { $types = array_keys($types); } return $types; }
/** * Test WOO is active * * @since 1.1.0 * * @group price * @group woo * @group functions * * @covers ingot_is_woo_active() * @covers ingot_check_ecommerce_active() */ public function testWOOActive() { if (class_exists('WooCommerce')) { $this->assertTrue(ingot_is_woo_active()); $this->assertTrue(ingot_check_ecommerce_active('woo')); } else { $this->assertFalse(ingot_is_woo_active()); $this->assertFalse(ingot_check_ecommerce_active('woo')); } }
/** * Run the price testing setup * * @since 1.1.0 * * @param array $ingot_cookies Cookies as an array * * @return array Array of setup class objects */ public static function price_testing($ingot_cookies) { $objects = []; if (ingot_is_edd_active() && isset($ingot_cookies['price']['edd']) && !empty($ingot_cookies['price']['edd'])) { $objects['edd'] = new edd($ingot_cookies['price']['edd']); } if (ingot_is_woo_active() && isset($ingot_cookies['price']['woo']) && !empty($ingot_cookies['price']['woo'])) { $object['woo'] = new woo($ingot_cookies['price']['woo']); } /** * Runs after price tests are initialized with the object for each of those classes. * * NOTE: May be empty array if no price testing is possible. * * @since 1.1.0 * * @param array $ingot_cookies Cookies as an array */ return apply_filters('ingot_price_test_objects', $objects); }
/** * Hooks to use for tracking * * @since 1.1.0 * * @return array */ public static function hooks() { $hooks = ['template_redirect' => null]; if (ingot_is_edd_active()) { $hooks['edd_post_add_to_cart'] = null; $hooks['edd_complete_purchase'] = null; } if (ingot_is_woo_active()) { $hooks['woocommerce_add_to_cart'] = null; $hooks['woocommerce_payment_complete_order_status'] = null; } if (ingot_is_give_active()) { $hooks['give_complete_purchase'] = null; } /** * Change or add hooks for destination conversion tracking * * @since 1.1.0 * * @param array $hooks hook_name => callback If callback is null, then it must exist in the `ingot\testing\tests\click\destination\hooks` class or else bad things... */ return apply_filters('ingot_destination_hooks', $hooks); }
/** * Data needed in app * * @since 0.2.0 * * @access protected * * @return array */ protected function vars() { return array('api' => esc_url_raw(util::get_url()), 'nonce' => wp_create_nonce('wp_rest'), 'partials' => esc_url_raw(INGOT_URL . 'assets/admin/partials/'), 'spinner_url' => trailingslashit(INGOT_URL) . 'assets/img/loading.gif', 'edd_active' => esc_attr(ingot_is_edd_active()), 'woo_active' => esc_attr(ingot_is_woo_active()), 'price_tests_enabled' => esc_attr(ingot_enable_price_testing()), 'click_type_options' => types::allowed_click_types(true), 'price_type_options' => types::allowed_price_types(), 'destinations' => \ingot\testing\tests\click\destination\types::destination_types(true, true), 'dev_mode' => INGOT_DEV_MODE); }