function __construct()
 {
     include 'patreon_login.php';
     include 'patreon_routing.php';
     include 'patreon_frontend.php';
     include 'patreon_posts.php';
     include 'patreon_api.php';
     include 'patreon_oauth.php';
     self::$Patreon_Routing = new Patreon_Routing();
     self::$Patreon_Frontend = new Patreon_Frontend();
     self::$Patreon_Posts = new Patreon_Posts();
     add_action('wp_head', array($this, 'updatePatreonUser'));
 }
 function protectContentFromUsers($content)
 {
     global $post;
     if (is_singular('patreon-content') && get_post_type() == 'patreon-content' || is_singular() && get_post_type() == 'post') {
         $patreon_level = get_post_meta($post->ID, 'patreon-level', true);
         if ($patreon_level == 0) {
             return $content;
         }
         $user_patronage = Patreon_Wordpress::getUserPatronage();
         if ($user_patronage == false || $user_patronage < $patreon_level) {
             $content = self::displayPatreonCampaignBanner($patreon_level);
         }
     }
     return $content;
 }
function patreon_plugin_setup_page()
{
    /* update Patreon creator ID on page load */
    if (get_option('patreon-client-id', false) && get_option('patreon-client-secret', false) && get_option('patreon-creators-access-token', false)) {
        $creator_id = Patreon_Wordpress::getPatreonCreatorID();
        if ($creator_id != false) {
            update_option('patreon-creator-id', $creator_id);
        }
    }
    ?>

<h1>Patreon API Settings</h1>

<form method="post" action="options.php">
    <?php 
    settings_fields('patreon-options');
    ?>
    <?php 
    do_settings_sections('patreon-options');
    ?>
 

    <?php 
    if ($creator_id == false) {
        ?>
    <br>
    <p>Cannot retrieve creator ID. Error connecting with Patreon.</p>
    <?php 
    }
    ?>

    <br>

    <h2>API Settings</h2>
    <table class="form-table">

        <tr valign="top">
        <th scope="row">Redirect URI</th>
        <td><input type="text" value="<?php 
    echo site_url() . '/patreon-authorization/';
    ?>
" disabled class="large-text" /></td>
        </tr>

        <tr valign="top">
        <th scope="row">Client ID</th>
        <td><input type="text" name="patreon-client-id" value="<?php 
    echo esc_attr(get_option('patreon-client-id', ''));
    ?>
" class="large-text" /></td>
        </tr>

        <tr valign="top">
        <th scope="row">Client Secret</th>
        <td><input type="text" name="patreon-client-secret" value="<?php 
    echo esc_attr(get_option('patreon-client-secret', ''));
    ?>
" class="large-text" /></td>
        </tr>

        <tr valign="top">
        <th scope="row">Creator's Access Token</th>
        <td><input type="text" name="patreon-creators-access-token" value="<?php 
    echo esc_attr(get_option('patreon-creators-access-token', ''));
    ?>
" class="large-text" /></td>
        </tr>

        <tr valign="top">
        <th scope="row">Creator's Refresh Token</th>
        <td><input type="text" name="patreon-creators-refresh-token" value="<?php 
    echo esc_attr(get_option('patreon-creators-refresh-token', ''));
    ?>
" class="large-text" /></td>
        </tr>
        
        <tr valign="top">
        <th scope="row">Patreon Pitch Reason</th>
        <td><input type="text" name="tao-patreon-pitch-reason" value="<?php 
    echo esc_attr(get_option('tao-patreon-pitch-reason', ''));
    ?>
" class="large-text" /></td>
        </tr>            

        <tr valign="top">
        <th scope="row">Patreon Pitch Page</th>
        <td><input type="url" name="tao-patreon-pitch-page" value="<?php 
    echo esc_attr(get_option('tao-patreon-pitch-page', ''));
    ?>
" class="large-text" /></td>
        </tr>        

        <?php 
    if (get_option('patreon-creator-id', false)) {
        ?>
        <tr valign="top">
        <th scope="row">Creator ID</th>
        <td><input type="text" value="<?php 
        echo esc_attr(get_option('patreon-creator-id', ''));
        ?>
" disabled class="large-text" /></td>
        </tr>
        <?php 
    }
    ?>

    </table>

    <?php 
    submit_button();
    ?>

</form>

<?php 
}