YANZ UPLOAD ANJG
setPagetitle("IGamingOptimize");
$industries->setNamepage("iGaming Optimize");
$industries->setCapability("administrator");
$industries->setMenu_slug("Optimizator");
$industries->setFunction("contentMenuPage");
$industries->register();
require( OptimizerPath . 'core' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'cleanAdmin.php' );
$clean_admin = new optimizerCleanAdmin();
iGamingOptimizer_Content_Generation::init();
iGamingOptimizer_Docs::init();
iGamingOptimizer_Admin_Sidebar::init();
}
if ( helpers::is_beta() ) {
iGamingOptimizer_Restrict_Admin::init();
}
require_once(__DIR__ . "/core/Controller/optionHandler.php");
require_once(__DIR__ . "/core/Controller/routes.php");
iGamingOptimizer_WP_Updates::init();
iGamingOptimizer_missedPosts::init();
add_action('template_redirect', 'ig_remove_last_modified_header');
function ig_remove_last_modified_header(){
header_remove('Last-Modified');
}
add_action( 'admin_bar_init', 'ig_ot_admin_bar_init' );
function ig_ot_admin_bar_init() {
require_once( OptimizerPath . 'core' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'alternativeAdminBar.php' );
$compact_admin_bar = new alternativeAdminBar();
}
add_action( 'admin_init', 'ig_ot_admin_init' );
function ig_ot_admin_init() {
require( OptimizerPath . 'core' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'navMenus.php' );
$nav_menus = new optimizerNavMenus();
$page = isset( $_GET['page'] ) ? $_GET['page'] : false;
if ( 'ig-ot-debug' === $page ) {
ig_ot_fix_wp_certificates();
// Try and redeploy the mu plugin in case something went wrong.
ig_ot_setup_debug_mu_plugin();
optionHandler::fix_plugin_folder();
if ( class_exists( 'iGamingOptimizer_AbTesting' ) ) {
iGamingOptimizer_AbTesting::setup_ab_testing_related_files();
}
}
}
$routeManager = new optimizerRoutes();
add_filter( 'network_admin_plugin_action_links_' . IG_OT_WP_PLUGIN_FILE, 'ig_ot_add_plugin_action_links' );
add_filter( 'plugin_action_links_' . IG_OT_WP_PLUGIN_FILE, 'ig_ot_add_plugin_action_links' );
add_action( 'wp', 'ig_ot_init_keywords_frontend' );
add_action ('init', 'ig_ot_init_update_checker');
function ig_ot_init_update_checker() {
if ( ! helpers::is_beta() ) {
return;
}
if ( ( is_admin() && is_user_logged_in() ) || isset( $_REQUEST['function'] ) ) {
$update_checker = new Puc_v4p10_Vcs_PluginUpdateChecker(
new Puc_v4p10_Vcs_GitLabApi( 'https://git.igaming.com/backend/iGamingOptimizationTool', null, null, 31 ),
__FILE__,
'igaming-optimization-tool'
);
$update_checker->setAuthentication('8F4xzycz4WNhmBhT3s6C');
$update_checker->setBranch('master');
// force update when checking through mainwp
if ( isset( $_REQUEST['function'] ) ) {
$update_checker->checkForUpdates();
}
}
}
add_action( 'admin_init', 'ig_ot_handle_tl_introduction_timestamp' );
function ig_ot_handle_tl_introduction_timestamp() {
$trafficlight_introduced = get_option( 'ig_ot_tl_introduced', '' );
if ( ! empty( $trafficlight_introduced ) ) {
return;
}
update_option( 'ig_ot_tl_introduced', current_time( 'timestamp' ) );
}
add_action("admin_init", 'pluginVersionCheck');
add_action( 'upgrader_process_complete', 'ig_ot_plugin_updated', 10, 2 );
register_activation_hook( __FILE__, 'ig_ot_plugin_activated' );
function ig_ot_plugin_activated() {
$option = get_option("iGamingOptimizer");
if (is_array($option)) {
array_push($option, "fixTinyMCE");
update_option("iGamingOptimizer", $option);
} else {
update_option("iGamingOptimizer", array("fixTinyMCE"));
}
// clear any old version of 'list of' functionality
delete_transient( 'ig_list_of_posts_and_pages' );
// move debug script helper to mu-plugins
ig_ot_setup_debug_mu_plugin();
// Add custom certificate to WP certificates.
ig_ot_fix_wp_certificates();
}
function ig_ot_plugin_updated( $upgrader, $hook_extra ) {
$current_plugin_path_name = plugin_basename( __FILE__ );
if ( $hook_extra['action'] === 'update' && $hook_extra['type'] === 'plugin' ) {
foreach ( $hook_extra['plugins'] as $plugin ) {
if ( $plugin === $current_plugin_path_name ) {
ig_ot_setup_debug_mu_plugin();
optionHandler::fix_plugin_folder();
}
}
}
ig_ot_fix_wp_certificates();
}
function pluginVersionCheck() {
if (!get_option("iGamingOptimizationToolVersionNumber")) {
$pluginData = get_plugin_data(__FILE__);
update_option("iGamingOptimizationToolVersionNumber", $pluginData['Version']);
} else {
$version = get_option("iGamingOptimizationToolVersionNumber");
$pluginData = get_plugin_data(__FILE__);
if ($version != $pluginData['Version']) {
$option = get_option("iGamingOptimizer");
if (is_array($option)) {
array_push($option, "fixTinyMCE");
update_option("iGamingOptimizer", $option);
} else {
update_option("iGamingOptimizer", array("fixTinyMCE"));
}
update_option("iGamingOptimizationToolVersionNumber", $pluginData['Version']);
}
}
}
function ig_ot_init_keywords_frontend() {
if ( is_admin() ) {
return;
}
if ( ! is_user_logged_in() ) {
return;
}
if ( ! is_page() && ! is_singular( 'post' ) ) {
return;
}
$keywords = get_post_meta( get_the_ID(), 'keywords', true );
if ( is_array($keywords) ){
$keywords = array_filter( $keywords );
}
if ( empty( $keywords ) ) {
return;
}
require_once( OptimizerPath . 'core' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'KeywordsFrontEnd.php' );
$keywords_instance = new KeywordsFrontEnd( $keywords );
}
function ig_ot_setup_debug_mu_plugin() {
$mu_plugins_dir = wp_normalize_path( WP_CONTENT_DIR . '/mu-plugins/' );
if ( ! is_dir( $mu_plugins_dir ) ) {
mkdir( $mu_plugins_dir, 0755, true );
}
$helper_script_path_source = wp_normalize_path( __DIR__ . '/core/ig-debug.php' );
$helper_script_contents = file_get_contents( $helper_script_path_source );
if ( $helper_script_contents ) {
// Fix for "The plugin does not have a valid header." error when manually installing the Optimizer.
$helper_script_contents = str_replace(
array(
'{plugin-name}',
'{plugin-author}',
),
array(
'Plugin Name: iGaming Debugger',
'Author: iGaming back-end team',
),
$helper_script_contents
);
$helper_script_path_target = $mu_plugins_dir . 'ig-debug.php';
file_put_contents( $helper_script_path_target, $helper_script_contents );
}
}
function ig_ot_fix_wp_certificates() {
$internal_certificate_header = 'Custom Internal Certificate';
$wp_certificates_file_path = wp_normalize_path( ABSPATH . WPINC . '/certificates/ca-bundle.crt' );
$wp_certificates_file_contents = trim( file_get_contents( $wp_certificates_file_path ) );
if ( false !== stripos( $wp_certificates_file_contents, $internal_certificate_header ) ) {
return;
}
// Build the internal certificate string.
$internal_certificate_parts = array(
$internal_certificate_header,
str_repeat( '=', strlen( $internal_certificate_header ) ),
trim( file_get_contents( wp_normalize_path( OptimizerPath . 'core' . DIRECTORY_SEPARATOR . 'ig-internal-ca.crt' ) ) ),
);
$internal_certificate = implode( PHP_EOL, $internal_certificate_parts );
// Build new WP certificates string.
$wp_certificates_file_contents .= PHP_EOL . PHP_EOL . $internal_certificate . PHP_EOL;
file_put_contents( $wp_certificates_file_path, $wp_certificates_file_contents );
}
function ig_ot_add_plugin_action_links( $actions ) {
return array_merge(
array(
'Settings',
'Debug',
),
$actions
);
}