<?php echo '<div class="ub-plugin-wrapper>'; $is_authorized = UBConfig::is_authorized_domain($domain); $diagnostics_failed = in_array(false, UBDiagnostics::checks($domain, $domain_info)); echo UBTemplate::render('main_header', array('img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__), 'is_authorized' => $is_authorized, 'authorization' => UBUtil::get_flash('authorization'), 'diagnostics_failed' => $diagnostics_failed)); if ($is_authorized) { $proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set', array()); $proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at'); $last_refreshed = UBUtil::time_ago($proxyable_url_set_fetched_at); echo UBTemplate::render('main_authorized', array('domain' => $domain, 'proxyable_url_set' => $proxyable_url_set, 'last_refreshed' => $last_refreshed)); add_action('in_admin_footer', function () { echo UBTemplate::render('main_authorized_footer'); }); } else { if (UBConfig::has_authorized()) { // They've attempted to authorize, but this domain isn't in the list echo UBTemplate::render('main_failed_authorization', array('domain' => $domain)); } else { echo UBTemplate::render('main_unauthorized', array('domain' => $domain)); } add_action('in_admin_footer', function () { echo UBTemplate::render('main_unauthorized_footer'); }); } echo '</div>';
public static function details($domain, $domain_info) { return array('PHP Version' => phpversion(), 'WordPress Version' => UBDiagnostics::wordpress_version(), 'Unbounce Plugin Version' => "1.0.15", 'Permalink Structure' => get_option('permalink_structure', ''), 'Domain' => $domain, 'Domain Authorized' => print_r(UBConfig::is_authorized_domain($domain), true), 'Has Authorized' => print_r(UBConfig::has_authorized(), true), 'Active Plugins' => print_r(get_option('active_plugins'), true), 'Plugin Details' => print_r(get_plugins(), true), 'Curl Version' => UBDiagnostics::curl_version(), 'Configuration Options' => print_r(ini_get_all(), true), 'Extensions' => print_r(get_loaded_extensions(), true), 'Operating System' => php_uname(), 'Checks' => print_r(UBDiagnostics::checks($domain, $domain_info), true), 'Options' => print_r(UBDiagnostics::ub_options(), true)); }
wp_enqueue_script('installer-admin'); wp_enqueue_style('unbounce-pages-css', plugins_url('css/unbounce-pages.css', __FILE__)); }, 0); add_action('admin_menu', function () { // Main admin page $print_admin_panel = function () { $domain = UBConfig::domain(); $domain_info = UBConfig::read_unbounce_domain_info($domain, false); echo UBTemplate::render('main', array('domain_info' => $domain_info, 'domain' => $domain)); }; add_menu_page('Unbounce Pages', 'Unbounce Pages', 'manage_options', 'unbounce-pages', $print_admin_panel, UBIcon::base64_encoded_svg()); // Diagnostics page $print_diagnostics_panel = function () { $domain = UBConfig::domain(); $domain_info = UBConfig::read_unbounce_domain_info($domain, false); echo UBTemplate::render('diagnostics', array('img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__), 'checks' => UBDiagnostics::checks($domain, $domain_info), 'details' => UBDiagnostics::details($domain, $domain_info), 'domain' => $domain, 'permalink_url' => admin_url('options-permalink.php'), 'curl_error_message' => UBUtil::array_fetch($domain_info, 'failure_message'))); }; add_submenu_page(NULL, 'Unbounce Pages Diagnostics', 'Unbounce Pages Diagnostics', 'manage_options', 'unbounce-pages-diagnostics', $print_diagnostics_panel); }); add_action('admin_post_set_unbounce_domains', function () { $domains_list = UBUtil::array_fetch($_POST, 'domains', ''); $domains = array_filter(explode(',', $domains_list), function ($domain) { return $domain == UBConfig::domain(); }); if ($domains && is_array($domains)) { $authorization = 'success'; $has_authorized = get_option(UBConfig::UB_HAS_AUTHORIZED_KEY, false); $data = array('domain_name' => UBConfig::domain(), 'first_authorization' => !$has_authorized, 'user_id' => UBUtil::array_fetch($_POST, 'user_id', ''), 'client_id' => UBUtil::array_fetch($_POST, 'client_id', ''), 'domain_id' => UBUtil::array_fetch($_POST, 'domain_id', '')); UBConfig::update_authorization_options($domains, $data); if (UBConfig::is_authorized_domain(UBConfig::domain())) { $event = UBEvents::successful_authorization_event($data);