public static function log_var($level, $var, $val) { if (UBConfig::debug_loggging_enabled()) { UBLogger::log($level, '$' . $var . ': ' . $val); UBLogger::log_wp_log_var($var, $val); } }
private static function ub_options() { $option_values = array_map(function ($key) { return get_option($key); }, UBConfig::ub_option_keys()); # Return an array where the key is the option key and the value # the option value: # array('ub-option-key' => 'option value') return array_combine(UBConfig::ub_option_keys(), $option_values); }
<form method="post" action="<?php echo admin_url('admin-post.php?action=set_unbounce_domains'); ?> "> <input type="hidden" name="domains" /> <input type="hidden" name="user_id" /> <input type="hidden" name="domain_id" /> <input type="hidden" name="client_id" /> <?php if (isset($outer_text)) { ?> <?php echo $outer_text; ?> <?php } ?> <?php $style = isset($outer_text) ? 'vertical-align: baseline' : ''; ?> <?php echo get_submit_button($text, $is_primary ? 'primary' : 'secondary', 'set-unbounce-domains', $wrap_in_p, array('data-set-domains-url' => admin_url('admin-post.php?action=set_unbounce_domains'), 'data-redirect-uri' => admin_url('admin.php?page=unbounce-pages'), 'data-api-url' => UBConfig::api_url(), 'data-api-client-id' => UBConfig::api_client_id(), 'data-wordpress-domain-name' => $domain, 'style' => $style)); ?> </form>
if ($authorization === 'success' && $is_authorized) { ?> <div class="updated"><p>Authorized with Unbounce and WordPress domain successfully enabled.</p></div> <?php } elseif ($authorization === 'success') { ?> <div class="updated"><p>Successfully authorized with Unbounce.</p></div> <?php } elseif ($authorization === 'failure') { ?> <div class="error"><p>Sorry, there was an error authorizing with Unbounce. Please try again.</p></div> <?php } ?> <?php // Only show error if they've never authorized, otherwise it will be shown right away if (UBConfig::has_authorized() && $diagnostics_failed) { ?> <div class="error"> <p> We have identified a configuration issue with this Unbounce Pages Plugin and your WordPress configuration, please <a href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?> ">click here</a> for more details. </p> </div> <?php }
<?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 is_authorized_domain($domain0) { $pieces = explode(':', $domain0); $domain = $pieces[0]; return in_array($domain, UBConfig::authorized_domains()); }
}); 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); } else { $event = UBEvents::failed_authorization_event($data); } UBHTTP::send_event_to_events_gateway(UBConfig::remote_events_url(), $event); } else { $authorization = 'failure'; } UBUtil::set_flash('authorization', $authorization); status_header(301); $location = admin_url('admin.php?page=unbounce-pages'); header("Location: {$location}"); }); add_action('admin_post_flush_unbounce_pages', function () { $domain = UBConfig::domain(); // Expire cache and redirect $_domain_info = UBConfig::read_unbounce_domain_info($domain, true); status_header(301); $location = admin_url('admin.php?page=unbounce-pages'); header("Location: {$location}"); }); add_action('shutdown', function () { UBLogger::upload_logs_to_unbounce(UBConfig::remote_log_url()); });