Пример #1
0
function openid_options_page()
{
    global $wp_version, $wpdb, $wp_roles;
    if (isset($_REQUEST['action'])) {
        switch ($_REQUEST['action']) {
            case 'rebuild_tables':
                check_admin_referer('openid-rebuild_tables');
                $store = openid_getStore();
                $store->reset();
                echo '<div class="updated"><p><strong>' . __('OpenID cache refreshed.', 'openid') . '</strong></p></div>';
                break;
        }
    }
    // if we're posted back an update, let's set the values here
    if (isset($_POST['info_update'])) {
        check_admin_referer('openid-info_update');
        $error = '';
        update_option('openid_enable_commentform', isset($_POST['enable_commentform']) ? true : false);
        update_option('openid_enable_approval', isset($_POST['enable_approval']) ? true : false);
        update_option('openid_no_require_name', isset($_POST['no_require_name']) ? true : false);
        update_option('openid_enable_email_mapping', isset($_POST['enable_email_mapping']) ? true : false);
        update_option('openid_required_for_registration', isset($_POST['openid_required_for_registration']) ? true : false);
        update_option('openid_blog_owner', $_POST['openid_blog_owner']);
        // set OpenID Capability
        foreach ($wp_roles->role_names as $key => $name) {
            $role = $wp_roles->get_role($key);
            $option_set = $_POST['openid_cap_' . htmlentities($key)] == 'on' ? true : false;
            if ($role->has_cap('use_openid_provider')) {
                if (!$option_set) {
                    $role->remove_cap('use_openid_provider');
                }
            } else {
                if ($option_set) {
                    $role->add_cap('use_openid_provider');
                }
            }
        }
        if ($error !== '') {
            echo '<div class="error"><p><strong>' . __('At least one of OpenID options was NOT updated', 'openid') . '</strong>' . $error . '</p></div>';
        } else {
            echo '<div class="updated"><p><strong>' . __('OpenID options updated', 'openid') . '</strong></p></div>';
        }
    }
    // Display the options page form
    $siteurl = get_option('home');
    if (substr($siteurl, -1, 1) !== '/') {
        $siteurl .= '/';
    }
    ?>
	<div class="wrap">
		<form method="post">

			<h2><?php 
    _e('OpenID Consumer Options', 'openid');
    ?>
</h2>

			<?php 
    openid_printSystemStatus();
    ?>

			<?php 
    if ($wp_version < '2.3') {
        ?>
			<p class="submit"><input type="submit" name="info_update" value="<?php 
        _e('Update Options');
        ?>
 &raquo;" /></p>
			<?php 
    }
    ?>

			<table class="form-table optiontable editform" cellspacing="2" cellpadding="5" width="100%">
				<tr valign="top">
					<th scope="row"><?php 
    _e('Comment Approval', 'openid');
    ?>
</th>
					<td>
						<p><input type="checkbox" name="enable_approval" id="enable_approval" <?php 
    echo get_option('openid_enable_approval') ? 'checked="checked"' : '';
    ?>
 />
							<label for="enable_approval"><?php 
    _e('Automatically approve comments left with verified OpenIDs.  ' . 'These comments will bypass all comment moderation.', 'openid');
    ?>
</label>
						</p>

						<?php 
    if (get_option('require_name_email')) {
        ?>
						<p><input type="checkbox" name="no_require_name" id="no_require_name" <?php 
        echo get_option('openid_no_require_name') ? 'checked="checked"' : '';
        ?>
 />
							<label for="no_require_name"><?php 
        _e('Don\'t require name and e-mail for comments left with verified OpenIDs.', 'openid');
        ?>
</label>
						</p>
						<?php 
    }
    ?>
						
					</td>
				</tr>

				<tr valign="top">
					<th scope="row"><?php 
    _e('Comment Form', 'openid');
    ?>
</th>
					<td>
						<p><input type="checkbox" name="enable_commentform" id="enable_commentform" <?php 
    if (get_option('openid_enable_commentform')) {
        echo 'checked="checked"';
    }
    ?>
 />
							<label for="enable_commentform"><?php 
    _e('Add OpenID help text to the comment form.', 'openid');
    ?>
</label></p>

						<p><?php 
    printf(__('This will work for most themes derived from Kubrick or Sandbox.  ' . 'Template authors can tweak the comment form as described in the %sreadme%s.', 'openid'), '<a href="' . clean_url(openid_plugin_url() . '/readme.txt') . '">', '</a>');
    ?>
</p>
						<br />
					</td>
				</tr>

				<?php 
    if (get_option('users_can_register')) {
        ?>
				<tr valign="top">
					<th scope="row"><?php 
        _e('Require OpenID', 'openid');
        ?>
</th>
					<td>
						<p><input type="checkbox" name="openid_required_for_registration" id="openid_required_for_registration" <?php 
        if (get_option('openid_required_for_registration')) {
            echo 'checked="checked"';
        }
        ?>
 />
							<label for="openid_required_for_registration"><?php 
        _e('New accounts can only be created with verified OpenIDs.', 'openid');
        ?>
</label></p>
					</td>
				</tr>
				<?php 
    }
    ?>

				<?php 
    /*
    <tr valign="top">
    	<th scope="row"><?php _e('Email Mapping:', 'openid') ?></th>
    	<td>
    		<p><input type="checkbox" name="enable_email_mapping" id="enable_email_mapping" <?php
    		if( get_option('openid_enable_email_mapping') ) echo 'checked="checked"'
    		?> />
    			<label for="enable_email_mapping"><?php _e('Enable email addresses to be mapped to OpenID URLs.', 'openid') ?></label></p>
    
    		<p><?php printf(__('This feature uses the Email-To-URL mapping specification to allow OpenID authentication'
    		. ' based on an email address.  If enabled, commentors who do not supply a valid OpenID URL will have their'
    		. ' supplied email address mapped to an OpenID.  If their email provider does not currently support email to'
    		. ' url mapping, the default provider %s will be used.', 'openid'), '<a href="http://emailtoid.net/" target="_blank">Emailtoid.net</a>') ?></p>
    		<br />
    	</td>
    </tr>
    */
    ?>

				<tr valign="top">
					<th scope="row"><?php 
    _e('Troubleshooting', 'openid');
    ?>
</th>
					<td>
						<p>

						<p><?php 
    printf(__('If users are experiencing problems logging in with OpenID, it may help to %1$srefresh the cache%2$s.', 'openid'), '<a href="' . wp_nonce_url(add_query_arg('action', 'rebuild_tables'), 'openid-rebuild_tables') . '">', '</a>');
    ?>
</p>
					</td>
				</tr>

			</table>

			<br class="clear" />


			<h2><?php 
    _e('OpenID Provider Options', 'openid');
    ?>
</h2>
			<?php 
    $current_user = wp_get_current_user();
    $current_user_url = get_author_posts_url($current_user->ID);
    ?>

			<p><?php 
    _e('The OpenID Provider allows authorized ' . 'users to use their author URL as an OpenID, either using their ' . 'local WordPress username and password, or by delegating to another OpenID Provider.', 'openid');
    ?>
</p>

			<table class="form-table optiontable editform" cellspacing="2" cellpadding="5" width="100%">
				<tr valign="top">
					<th scope="row"><?php 
    _e('Enable OpenID', 'openid');
    ?>
</th>
					<td>

						<p><?php 
    _e('Enable the local OpenID Provider for these roles:', 'openid');
    ?>
</p>

						<p>
							<?php 
    foreach ($wp_roles->role_names as $key => $name) {
        $role = $wp_roles->get_role($key);
        $checked = $role->has_cap('use_openid_provider') ? ' checked="checked"' : '';
        $option_name = 'openid_cap_' . htmlentities($key);
        echo '<input type="checkbox" id="' . $option_name . '" name="' . $option_name . '"' . $checked . ' /><label for="' . $option_name . '"> ' . $name . '</label><br />' . "\n";
    }
    ?>
						</p>
					</td>
				</tr>

			<?php 
    $users = get_users_of_blog();
    $users = array_filter($users, create_function('$u', '$u = new WP_User($u->user_id); return $u->has_cap("use_openid_provider");'));
    if (!empty($users)) {
        ?>
				<tr valign="top">
					<th scope="row"><?php 
        _e('Blog Owner', 'openid');
        ?>
</th>
					<td>

						<p><?php 
        printf(__('Authorized accounts on this blog can use their author URL (i.e. <em>%1$s</em>) as an OpenID. ' . 'The Blog Owner will be able to use the blog address (%2$s) as their OpenID.  If this is a ' . 'single-user blog, you should set this to your account.', 'openid'), sprintf('<a href="%1$s">%1$s</a>', $current_user_url), sprintf('<a href="%1$s">%1$s</a>', trailingslashit(get_option('home'))));
        ?>
						</p>

			<?php 
        if (defined('OPENID_DISALLOW_OWNER') && OPENID_DISALLOW_OWNER) {
            echo '
						<p class="error">' . __('A Blog Owner cannot be set for this blog.  To set a Blog Owner, ' . 'first remove the following line from your <code>wp-config.php</code>:', 'openid') . '<br /><code style="margin:1em;">define("OPENID_DISALLOW_OWNER", 1);</code>
						</p>';
        } else {
            $blog_owner = get_option('openid_blog_owner');
            if (empty($blog_owner) || $blog_owner == $current_user->user_login) {
                echo '<select id="openid_blog_owner" name="openid_blog_owner"><option value="">(none)</option>';
                foreach ($users as $user) {
                    $selected = get_option('openid_blog_owner') == $user->user_login ? ' selected="selected"' : '';
                    echo '<option value="' . $user->user_login . '"' . $selected . '>' . $user->user_login . '</option>';
                }
                echo '</select>';
            } else {
                echo '<p class="error">' . sprintf(__('Only the current Blog Owner (%s) can change this setting.', 'openid'), $blog_owner) . '</p>';
            }
        }
        ?>
						</td>
					</tr>
			<?php 
    }
    //!empty($users)
    ?>
				</table>

			<?php 
    wp_nonce_field('openid-info_update');
    ?>
			<p class="submit"><input type="submit" name="info_update" value="<?php 
    _e('Update Options');
    ?>
 &raquo;" /></p>
		</form>
	</div>
		<?php 
}
Пример #2
0
/**
 * Include internal stylesheet.
 *
 * @action: wp_head, login_head
 **/
function openid_style()
{
    $css_file = defined('WP_DEBUG') && WP_DEBUG ? 'openid.css' : 'openid.min.css';
    $css_path = openid_plugin_url() . '/f/' . $css_file . '?ver=' . OPENID_PLUGIN_REVISION;
    echo '
		<link rel="stylesheet" type="text/css" href="' . clean_url($css_path) . '" />';
}
Пример #3
0
function openid_wp_login_head()
{
    openid_style();
    wp_enqueue_script('jquery.xpath', openid_plugin_url() . '/f/jquery.xpath.min.js', array('jquery'), OPENID_PLUGIN_REVISION);
    wp_print_scripts(array('jquery.xpath'));
}