/** * Loads ingot if not already loaded. * * @since 0.0.5 */ public static function maybe_load() { if (did_action('ingot_loaded')) { return; } if (!defined('INGOT_DEV_MODE')) { /** * Puts Ingot into dev mode * * Don't use on a live site -- makes API totally open * * @since 0.0.5 */ define('INGOT_DEV_MODE', false); } $load = true; if (!version_compare(PHP_VERSION, '5.5.0', '>=')) { $load = false; } $autoloader = dirname(__FILE__) . '/vendor/autoload.php'; if (!file_exists($autoloader)) { $load = false; } if ($load) { add_filter('ingot_force_update_table', '__return_true'); if (!did_action('ingot_loaded')) { include_once $autoloader; self::maybe_upgrade(); self::add_tables(); if (self::check_if_tables_exist()) { ingot\testing\ingot::instance(); //make admin go in admin if (is_admin()) { new \ingot\ui\admin\app\load(); } add_action('init', array(__CLASS__, 'init_cookies'), 25); add_action('ingot_cookies_set', array(__CLASS__, 'init_price_tests')); /** * Runs when Ingot has loaded. * * @since 0.0.5 * */ do_action('ingot_loaded'); } else { if (is_admin()) { printf('<div class="error"><p>%s</p></div>', __('Ingot Not Loaded', 'ingot')); } /** * Runs if Ingot failed to load * * @since 0.3.0 * */ do_action('ingot_loaded_failed'); return; } } } }
public function setUp() { parent::setUp(); /** @var WP_REST_Server $wp_rest_server */ global $wp_rest_server; $this->server = $wp_rest_server = new \WP_REST_Server(); do_action('rest_api_init'); $ingot = ingot\testing\ingot::instance(); $ingot->boot_rest_api(); $this->setNamespacedRoute(); }
/** * Loads ingot if not already loaded. * * @since 0.0.5 */ public static function maybe_load() { if (did_action('ingot_loaded')) { return; } if (!defined('INGOT_DEV_MODE')) { /** * Puts Ingot into dev mode * * Don't use on a live site -- makes API totally open * * @since 0.0.5 */ define('INGOT_DEV_MODE', false); } $load = true; if (!version_compare(PHP_VERSION, '5.5.0', '>=')) { $load = false; } $autoloader = dirname(__FILE__) . '/vendor/autoload.php'; if (!file_exists($autoloader)) { $load = false; } if ($load) { include_once $autoloader; self::maybe_add_tables(); self::maybe_upgrade(); self::maybe_load_trial(); if (\ingot\testing\db\delta::check_if_tables_exist()) { ingot\testing\ingot::instance(); //make admin go in admin if (is_admin()) { new ingot\ui\make(); } if (ingot_is_front_end() || ingot_is_admin_ajax()) { //setup destination tests $destination_tests = \ingot\testing\tests\click\destination\init::set_tracking(); //run cookies add_action('ingot_loaded', function () { /** * Disable running cookies * * @since 1.1.0 * * @param bool $run */ if (true == (bool) apply_filters('ingot_run_cookies', true) && !did_action('ingot_cookies_set')) { if (!empty($destination_tests)) { \ingot\testing\tests\click\destination\init::setup_cookies($destination_tests); } \ingot\testing\cookies\set::run(); } }); } /** * Runs when Ingot has loaded. * * @since 0.0.5 */ do_action('ingot_loaded'); } else { if (is_admin()) { printf('<div class="error"><p>%s</p></div>', __('Ingot Not Loaded', 'ingot')); } /** * Runs if Ingot failed to load * * @since 0.3.0 * */ do_action('ingot_loaded_failed'); return; } } }