public static function template_path($template)
 {
     return UBTemplate::join_paths(dirname(__FILE__), 'templates', $template . '.php');
 }
<h2 class="ub-published-pages-heading">Published Pages</h2>

<form method="get" action="https://app.unbounce.com" target="_blank">
  <?php 
echo get_submit_button('Manage Pages In Unbounce', 'primary', 'flush-unbounce-pages', false, array('style' => 'margin-top: 10px'));
?>
</form>

<div class="ub-page-list">
  <?php 
$table = new UBPageTable($proxyable_url_set);
?>
  <?php 
echo $table->display();
?>

  <p>Last refreshed  <?php 
echo $last_refreshed;
?>
.</p>

  <?php 
echo UBTemplate::render('authorize_button', array('text' => 'Update WordPress Enabled Domains', 'domain' => $domain, 'wrap_in_p' => false, 'is_primary' => false));
?>
</div>
Example #3
0
<?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>';
<div class="error">
  <p>It looks like <strong><?php 
echo $domain;
?>
</strong> has not been added as a WordPress domain in your Unbounce account.</p>
</div>

<form method="get" action="https://app.unbounce.com/add_wordpress_domain" target="_blank">
  <input type="hidden" name="domain_name" value="<?php 
echo $domain;
?>
" />
  <?php 
get_submit_Button('Add My Domain in Unbounce', 'primary', null, true, array('id' => 'add-domain', 'onclick' => 'swap_primary_buttons("add-domain", "set-unbounce-domains");'));
?>
</form>

<?php 
echo UBTemplate::render('authorize_button', array('text' => 'Update WordPress Enabled Domains', 'domain' => $domain, 'wrap_in_p' => false, 'is_primary' => false, 'outer_text' => 'After adding your domain in Unbounce, come back here and '));
<div class="ub-authorize-message">Before you can publish your pages to WordPress you will have to authorize your Unbounce account.</div>

<?php 
echo UBTemplate::render('authorize_button', array('text' => 'Authorize With Unbounce', 'domain' => $domain, 'wrap_in_p' => true, 'is_primary' => true));
?>

<form method="get" action="http://unbounce.com/landing-pages-for-wordpress/" target='_blank'>
  <input type="hidden" name="utm_medium" value="product" />
  <input type="hidden" name="utm_source" value="wordpress-plugin" />
  <input type="hidden" name="utm_campaign" value="product-launch-wordpress" />
  <p>
    Not an Unbounce customer?
    <?php 
echo get_submit_Button('Try Unbounce For Free', 'secondary', null, false);
?>
  </p>
</form>
    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);