Example #1
0
/**
 * Embed Vanilla administration page.
 */
function vf_embed_admin_page()
{
    // Check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $post_id = vf_configure_embed_container();
    $options = get_option(VF_OPTIONS_NAME);
    $embed_code = vf_get_value('embed-code', $options);
    $vanilla_post = get_post($PostID);
    ?>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('&lt;Embed&gt; Vanilla');
    ?>
</h2>
   <p>Use this page to embed your Vanilla Forum into WordPress.</p>
	<?php 
    vf_open_form('embed-form');
    ?>
		<strong>Forum Location in WordPress</strong>
		<em>Define where to access your Vanilla Forum within WordPress.</em>
		<div id="edit-slug-box"><?php 
    echo get_sample_permalink_html($post_id);
    ?>
</div>
		<?php 
    wp_nonce_field('samplepermalink', 'samplepermalinknonce', false);
    ?>
		<em>You can further customize the page that contains your forum <a href="./post.php?post=<?php 
    echo $post_id;
    ?>
&action=edit">here</a>.</em>

		<strong>Forum &lt;Embed&gt; Code</strong>
		<textarea id="EmbedCode" name="<?php 
    echo vf_get_option_name('embed-code');
    ?>
"><?php 
    echo $embed_code;
    ?>
</textarea>
		<em>You can make changes to your forum embed code here (optional).</em>
      <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
		</div>
   </form>
</div>
<?php 
}
Example #2
0
function vf_admin_page()
{
    // Check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $url = vf_get_value('url', $options);
    ?>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('Vanilla Forum Administration');
    ?>
</h2>
   <p>Use this page to configure your Vanilla Forum to work with WordPress.</p>
	<?php 
    if ($url == '') {
        ?>
	 <div class="GetVanilla">
		<h2>Don't have a Vanilla Forum yet?</h2>
		<a href="http://vanillaforums.com" target="_blank"><span>Get one in under 60 seconds!</span></a>
	 </div>
	<?php 
    }
    vf_open_form('url-form');
    ?>
		<strong>Tell WordPress where your Vanilla Forum is located</strong>
		<input name="<?php 
    echo vf_get_option_name('url');
    ?>
" value="<?php 
    echo $url;
    ?>
" class="InputBox" />
		<em>Paste the url to your Vanilla forum here (eg. http://yourdomain.com/forum)</em>
      <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Validate &amp; Save');
    ?>
" /></p>
   </form>
</div>
<?php 
}
Example #3
0
/**
 * Single Sign-on administration page.
 */
function vf_sso_admin_page()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $sso_enabled = vf_get_value('sso-enabled', $options, '');
    $sso_create_users_on_register = vf_get_value('sso-create-users-on-register', $options, '');
    $sso_clientid = vf_get_value('sso-clientid', $options, vf_format_url(get_option('blogname')));
    $sso_secret = vf_get_value('sso-secret', $options, '');
    $vanilla_url = vf_get_value('url', $options);
    ?>
<style type="text/css">
.wrap strong {
	display: block;
	font-size: 14px;
}
.TextBox {
	width: 300px;
}
.form-container {
	background: #f0f0f0;
	display: block;
	max-width: 800px;
	padding: 10px;
	margin: 0 0 20px;
}
.form-container label {
	display: block;
	padding: 0 0 16px;
}
.form-container label:last-child {
	padding: 0;
}
.form-container span {
	display: block;
}
.info-container {
	background: #f0f0f0;
	display: block;
	max-width: 800px;
	padding: 10px;
}
.form-container label,
.info-container label {
	cursor: auto;
}
.CopyBox {
	font-size: 12px;
	border: 1px solid #ddd;
	background: #fff;
	padding: 3px 6px;
	font-family: monospace;
	margin-bottom: 10px;
	border-radius: 2px;
	-moz-border-radius: 2px;
	-webkit-border-radius: 2px;
}
.important {
	font-weight: bold;
	font-style: italic;
}
</style>
<script type="text/javascript">
jQuery(document).ready(function($) {
	$('.generate-secret').click(function() {
		$.ajax({
			url: $(this).attr('href'),
			success: function(data) {
				$('input.sso-secret').val(data);
			}
			
		});
		return false;
	});
});
</script>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('Vanilla Single Sign-on Integration');
    ?>
</h2>
	<?php 
    vf_open_form('sso-form');
    ?>
	<br />
	<strong>Security Settings for Single Sign-on</strong>
	<div class="form-container">
		<label>
			<strong>Enable</strong>
			<input type="checkbox" name="<?php 
    echo vf_get_option_name('sso-enabled');
    ?>
" value="1" <?php 
    echo $sso_enabled == '1' ? ' checked="checked"' : '';
    ?>
 />
			Allow users to sign into Vanilla through WordPress.
		</label>
		<label>
			<strong>Enable creating user in vanilla on Wordpress user creation</strong>
			<input type="checkbox" name="<?php 
    echo vf_get_option_name('sso-create-users-on-register');
    ?>
" <?php 
    echo $sso_create_users_on_register == 'on' ? ' checked="checked"' : '';
    ?>
 />
			Create vanilla forum user immediatelly after wordpress user registration
		</label>

		<label>
			<strong>Client ID</strong>
			<span>The client id is a url-friendly value that identifies your WordPress site to Vanilla.</span>
			<input class="TextBox" type="text" name="<?php 
    echo vf_get_option_name('sso-clientid');
    ?>
" value="<?php 
    echo $sso_clientid;
    ?>
" />
		</label>

		<label>
			<strong>Secret</strong>
			<span>This is a "secret" value that Vanilla uses to ensure that your WordPress site is a trusted source.</span>
			<input class="TextBox sso-secret" type="text" name="<?php 
    echo vf_get_option_name('sso-secret');
    ?>
" value="<?php 
    echo $sso_secret;
    ?>
" />
			<a class="generate-secret" href="<?php 
    echo site_url('?VFRequest=generate-secret');
    ?>
">Generate</a>
		</label>
	</div>
	<strong>Other information for Vanilla</strong>
	<div class="info-container">
		<label>
			<strong>Authenticate Url</strong>
			<div class="CopyBox"><?php 
    echo site_url('?VFRequest=connect');
    ?>
</div>
		</label>
		<label>
			<strong>Sign In Url</strong>
			<div class="CopyBox"><?php 
    echo wp_login_url();
    ?>
?redirect_to={Target}</div>
		</label>
		<label>
			<strong>Register Url</strong>
			<div class="CopyBox"><?php 
    echo site_url('wp-login.php?action=register', 'login');
    ?>
</div>
		</label>
		<label>
			<strong>SignOut Url</strong>
			<div class="CopyBox"><?php 
    echo add_query_arg(array('action' => 'logout', '_wpnonce' => '{Nonce}', 'redirect_to' => '{Redirect}'), site_url('wp-login.php', 'login'));
    ?>
</div>
		</label>
	</div>

	<p class="important">Make sure that <u>all</u> of the values above are copied into <a href="<?php 
    echo vf_combine_paths(array($vanilla_url, 'dashboard/settings/jsconnect'));
    ?>
">your Vanilla jsConnect settings page</a>.</p>

   <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
	</form>
</div>

<?php 
}
Example #4
0
/**
 * SSO administration page.
 */
function vf_sso_admin_page()
{
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $cookie_domain = vf_get_value('vanilla_cookie_domain', $options, '');
    $Key = vf_get_value('vanilla_sso_key', $options, '');
    if ($Key == '') {
        $Characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
        $Key = '';
        for ($i = 0; $i < 16; ++$i) {
            $Offset = rand() % 35;
            $Key .= substr($Characters, $Offset, 1);
        }
        vf_update_option('vanilla_sso_key', $Key);
    }
    ?>
<div class="wrap">
	<div id="icon-options-general" class="icon32"><br /></div>
	<h2><?php 
    _e('Vanilla Single Sign-on Configuration');
    ?>
</h2>
	<h3><?php 
    _e('Vanilla Settings for WordPress');
    ?>
</h3>
	<p>Grab this value from the single sign-on configuration screen in your Vanilla installation:</p>
	<?php 
    vf_open_form('sso-form');
    ?>
		<table class="form-table">
			<tr>
				<th>Vanilla's Cookie Domain</th>
				<td><input name="<?php 
    echo vf_get_option_name('vanilla_cookie_domain');
    ?>
" value="<?php 
    echo $cookie_domain;
    ?>
" class="InputBox" /></td>
			</tr>
		</table>
		<p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save');
    ?>
" /></p>
	</form>
	<h3><?php 
    _e('WordPress Settings for Vanilla');
    ?>
</h3>
	<p>Copy & paste the following information into the single sign-on configuration screen in your Vanilla installation:</p>
	<table class="form-table">
		<tr>
			<th>Authenticate Url</th>
			<td><span class="description"><?php 
    echo site_url('?VanillaChallengeKey=' . $Key, 'vanilla-sso-info');
    ?>
</span></td>
		</tr>
		<tr>
			<th>Registration Url</th>
			<td><span class="description"><?php 
    echo site_url('wp-login.php?action=register', 'login');
    ?>
</span></td>
		</tr>
		<tr>
			<th>Sign-in Url</th>
			<td><span class="description"><?php 
    echo wp_login_url();
    ?>
?redirect_to={Redirect}</span></td>
		</tr>
		<tr>
			<th>Sign-out Url</th>
			<td><span class="description"><?php 
    echo add_query_arg(array('action' => 'logout', '_wpnonce' => '{Nonce}', 'redirect_to' => '{Redirect}'), site_url('wp-login.php', 'login'));
    ?>
</span></td>
		</tr>
	</table>
</div>
<?php 
}
Example #5
0
/**
 * Vanilla Comments administration page.
 */
function vf_comment_admin_page()
{
    // Check that the user has the required capability
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    $options = get_option(VF_OPTIONS_NAME);
    $embed_comments = vf_get_value('embed-comments', $options);
    $resturl = vf_get_value('url', $options, '');
    $resturl = vf_combine_paths(array($resturl, '?p=categories/all.json'), '/');
    $categoryid = vf_get_value('embed-categoryid', $options, '0');
    $matchCategories = vf_get_value('embed-matchcategories', $options, '0');
    $category_data = json_decode(vf_rest($resturl));
    $select_options = vf_get_select_option('No Category', '0', $categoryid);
    if (is_object($category_data)) {
        foreach ($category_data->Categories as $Category) {
            $select_options .= vf_get_select_option($Category->Name, $Category->CategoryID, $categoryid);
        }
    }
    ?>
<div class="wrap">
   <div id="icon-options-general" class="icon32"><br /></div>
   <h2><?php 
    _e('Vanilla Comment Integration');
    ?>
</h2>
	<?php 
    vf_open_form('embed-comments-form');
    ?>
	 <p>
		<label>
		  <input type="checkbox" name="<?php 
    echo vf_get_option_name('embed-comments');
    ?>
" value="1"<?php 
    echo $embed_comments == '1' ? ' checked="checked"' : '';
    ?>
 />
		  Replace your blog's native commenting system with Vanilla comments.
		</label>
	 </p>
	 <p>
		<label>
		  <select name="<?php 
    echo vf_get_option_name('embed-categoryid');
    ?>
"><?php 
    echo $select_options;
    ?>
</select>
		  <?php 
    echo __('Place embedded comments into the selected category.');
    ?>
		</label>
	 </p>
    <p>
       <label>
          <input type="checkbox" name="<?php 
    echo vf_get_option_name('embed-matchcategories');
    ?>
" value="1"<?php 
    echo $matchCategories == '1' ? ' checked="checked"' : '';
    ?>
 />
          <?php 
    echo __('Try and match your Wordpress category.');
    ?>
       </label>
    </p>
    <p class="submit"><input type="submit" name="save" value="<?php 
    _e('Save Changes');
    ?>
" /></p>
  </form>
</div>
<?php 
}