示例#1
0
        function options_page()
        {
            global $wp_version, $openid;
            WordPressOpenID_Logic::late_bind();
            if (isset($_REQUEST['action'])) {
                switch ($_REQUEST['action']) {
                    case 'rebuild_tables':
                        check_admin_referer('wp-openid-info_rebuild_tables');
                        $openid->store->destroy_tables();
                        $openid->store->create_tables();
                        echo '<div class="updated"><p><strong>' . __('OpenID tables rebuilt.', '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('wp-openid-info_update');
                $error = '';
                update_option('oid_enable_commentform', isset($_POST['enable_commentform']) ? true : false);
                update_option('oid_enable_approval', isset($_POST['enable_approval']) ? true : false);
                update_option('oid_enable_email_mapping', isset($_POST['enable_email_mapping']) ? true : false);
                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>' . __('Open ID options updated', 'openid') . '</strong></p></div>';
                }
            }
            // Display the options page form
            $siteurl = get_option('home');
            if (substr($siteurl, -1, 1) !== '/') {
                $siteurl .= '/';
            }
            ?>
			<div class="wrap">
				<h2><?php 
            _e('WP-OpenID Registration Options', 'openid');
            ?>
</h2>

				<?php 
            if ($wp_version >= '2.3') {
                WordPressOpenID_Interface::printSystemStatus();
            }
            ?>

				<form method="post">

					<?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 style="width: 33%" scope="row"><?php 
            _e('Automatic Approval:', 'openid');
            ?>
</th>
							<td>
								<p><input type="checkbox" name="enable_approval" id="enable_approval" <?php 
            echo get_option('oid_enable_approval') ? 'checked="checked"' : '';
            ?>
 />
									<label for="enable_approval"><?php 
            _e('Enable OpenID comment auto-approval', 'openid');
            ?>
</label>

								<p><?php 
            _e('For now this option will cause comments made with OpenIDs ' . 'to be automatically approved.  Since most spammers haven\'t started ' . 'using OpenID yet, this is probably pretty safe.  More importantly ' . 'however, this could be a foundation on which to build more advanced ' . 'automatic approval such as whitelists or a third-party trust service.', 'openid');
            ?>
								</p>

								<p><?php 
            _e('Note that this option will cause OpenID authenticated comments ' . 'to appear, even if you have enabled the option, "An administrator must ' . 'always approve the comment".', 'openid');
            ?>
</p>
								
							</td>
						</tr>

						<tr valign="top">
							<th style="width: 33%" scope="row"><?php 
            _e('Comment Form:', 'openid');
            ?>
</th>
							<td>
								<p><input type="checkbox" name="enable_commentform" id="enable_commentform" <?php 
            if (get_option('oid_enable_commentform')) {
                echo 'checked="checked"';
            }
            ?>
 />
									<label for="enable_commentform"><?php 
            _e('Add OpenID text to the WordPress post 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="' . get_option('siteurl') . '/' . PLUGINDIR . '/openid/readme.txt">', '</a>');
            ?>
</p>
								<br />
							</td>
						</tr>

						<?php 
            /*
            <tr valign="top">
            	<th style="width: 33%" 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('oid_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>
            */
            ?>

     				</table>

					<p><?php 
            printf(__('Occasionally, the WP-OpenID tables don\'t get setup properly, and it may help ' . 'to %srebuild the tables%s.  Don\'t worry, this won\'t cause you to lose any data... it just ' . 'rebuilds a couple of tables that hold only temporary data.', 'openid'), '<a href="' . wp_nonce_url(sprintf('?page=%s&action=rebuild_tables', $_REQUEST['page']), 'wp-openid-info_rebuild_tables') . '">', '</a>');
            ?>
</p>

					<?php 
            wp_nonce_field('wp-openid-info_update');
            ?>
     				<p class="submit"><input type="submit" name="info_update" value="<?php 
            _e('Update Options');
            ?>
 &raquo;" /></p>
     			</form>

			</div>
    			<?php 
            if ($wp_version < '2.3') {
                echo '<br />';
                WordPressOpenID_Interface::printSystemStatus();
            }
        }