/** * Create a page for embedding the forum, give it a default name, url, and template. */ function vf_configure_embed_container() { $post_id = vf_get_option('embed-post-id'); $post = get_post($post_id); // PostID not set or not related to an existing page? Generate the page now and apply template. if (!is_numeric($post_id) || $post_id <= 0 || !$post) { // Copy the vanilla template to the current theme $template_to_use = 'embed_template.php'; try { copy(__DIR__ . '/templates/embed_template.php', get_template_directory() . '/embed_template.php'); } catch (Exception $e) { $template_to_use = false; } $post_id = wp_insert_post(array('post_name' => 'discussions', 'post_title' => 'Discussions', 'post_type' => 'page', 'post_status' => 'publish', 'comment_status' => 'closed')); if ($template_to_use) { update_post_meta($post_id, '_wp_page_template', $template_to_use); } vf_update_option('embed-post-id', $post_id); } return $post_id; }
/** * 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 }