<?php
/**
 * Plugin Name: IRIS WebPortal Plugin
 * Description: Admin Dashboard, Developer Console, IRIS WebPortal Content
 * Text Domain: ow-plugin
 *
 * Plugin URI: //iriswebportal.co.uk/
 * 
 * Author: IRIS WebPortal
 * Author URI: //iriswebportal.co.uk/
 * 
 * Version: 1.5.6.1
 *
 */
// PLUGIN DETAILS
const OW_VERSION = '1.5.6.1';

$global_option = $wpdb->get_results( 'SELECT gc_option, gc_value FROM ow_global_configuration' );
$globalArray = [];

foreach ( $global_option as $row ) {
	
	$globalArray[$row->gc_option] = $row->gc_value;
}
$ow_global_variables = $globalArray;

const SERVER_1 = '185.41.10.150';
const SERVER_2 = '62.182.18.252';
const DEV_SERVER = '62.182.18.70';

// CDN PATHS
const SERVER1_CDN = 'https://cdn.irisopenwebsite.co.uk/';
const SERVER2_CDN = 'https://cdn.iriswebportallive.co.uk/';

if (array_key_exists('hosted_in', $ow_global_variables)) {
    if ($ow_global_variables['hosted_in'] == SERVER_1) {
        $cdn_link = SERVER1_CDN;
    }else if ($ow_global_variables['hosted_in'] == SERVER_2) {
        $cdn_link = SERVER2_CDN;
    }else{
        $cdn_link = SERVER2_CDN;
    }
}


// RUNS PLUGIN AUTO UPDATE CHECKER
require 'update-checker/plugin-update-checker.php';
$myUpdateChecker = PucFactory::buildUpdateChecker(
    $cdn_link.'v4/plugins/ow-plugin-meta.json',
    __FILE__,
    'ow-plugin',
	24
);
add_filter( 'auto_update_plugin', '__return_true' );


// START THE PLUGIN
include plugin_dir_path( __FILE__ ) . 'ow-config.php';