예제 #1
0
 /**
  * Initialize the plugin
  * 
  * @see		http://codex.wordpress.org/Plugin_API/Action_Reference
  * @see		http://adambrown.info/p/wp_hooks/hook/init
  */
 function init()
 {
     global $wpdb, $wp_rewrite, $current_user, $blog_id, $wp_roles;
     $this->install();
     //we run this here because activation hooks aren't triggered when updating - see http://wp.mu/8kv
     if (is_admin()) {
         $this->init_admin_pages();
     }
     $this->settings = get_option('wiki_settings');
     if (preg_match('/mu\\-plugin/', $this->plugin_dir) > 0) {
         load_muplugin_textdomain('wiki', dirname(plugin_basename(__FILE__)) . '/languages');
     } else {
         load_plugin_textdomain('wiki', false, dirname(plugin_basename(__FILE__)) . '/languages');
     }
     if (class_exists('Wiki_Premium')) {
         // taxonomies MUST be registered before custom post types
         Wiki_Premium::get_instance()->register_taxonomies();
     }
     $this->register_post_types();
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'editpost':
                 // editing an existing wiki using the frontend editor
                 if (wp_verify_nonce($_POST['_wpnonce'], "wiki-editpost_{$_POST['post_ID']}")) {
                     $post_id = $this->edit_post($_POST);
                     wp_redirect(get_permalink($post_id));
                     exit;
                 }
                 break;
         }
     }
     if (isset($_REQUEST['subscribe']) && wp_verify_nonce($_REQUEST['_wpnonce'], "wiki-subscribe-wiki_{$_REQUEST['post_id']}")) {
         if (isset($_REQUEST['email'])) {
             if ($wpdb->insert("{$this->db_prefix}wiki_subscriptions", array('blog_id' => $blog_id, 'wiki_id' => $_REQUEST['post_id'], 'email' => $_REQUEST['email']))) {
                 setcookie('incsub_wiki_email', $_REQUEST['email'], time() + 3600 * 24 * 365, '/');
                 wp_redirect(get_permalink($_REQUEST['post_id']));
                 exit;
             }
         } elseif (is_user_logged_in()) {
             $result = $wpdb->insert("{$this->db_prefix}wiki_subscriptions", array('blog_id' => $blog_id, 'wiki_id' => $_REQUEST['post_id'], 'user_id' => $current_user->ID));
             if (false !== $result) {
                 wp_redirect(get_permalink($_REQUEST['post_id']));
                 exit;
             }
         }
     }
     if (isset($_GET['action']) && $_GET['action'] == 'cancel-wiki-subscription') {
         if ($wpdb->query("DELETE FROM {$this->db_prefix}wiki_subscriptions WHERE ID = " . intval($_GET['sid']) . ";")) {
             wp_redirect(get_option('siteurl'));
             exit;
         }
     }
 }
예제 #2
0
    function display_settings()
    {
        global $wiki;
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have permission to access this page', 'wiki'));
        }
        //If accessed properly, this message doesn't appear.
        if (isset($_GET['incsub_wiki_settings_saved']) && $_GET['incsub_wiki_settings_saved'] == 1) {
            echo '<div class="updated fade"><p>' . __('Settings saved.', 'wiki') . '</p></div>';
        }
        ?>
		<div class="wrap">
			<h2><?php 
        _e('Wiki Settings', 'wiki');
        ?>
</h2>
			<form method="post" action="edit.php?post_type=incsub_wiki&amp;page=incsub_wiki">
			<?php 
        wp_nonce_field('wiki_save_settings', 'wiki_settings_nonce');
        ?>
			<table class="form-table">
				<tr valign="top">
					<th><label for="incsub_wiki-slug"><?php 
        _e('Wiki Slug', 'wiki');
        ?>
</label> </th>
					<td> /<input type="text" size="20" id="incsub_wiki-slug" name="wiki[slug]" value="<?php 
        echo $wiki->get_setting('slug');
        ?>
" /></td>
				</tr>
				
				<?php 
        if (class_exists('Wiki_Premium')) {
            Wiki_Premium::get_instance()->admin_page_settings();
        }
        ?>
			</table>
			
			<h3><?php 
        _e('<a target="_blank" href="http://premium.wpmudev.org/project/wordpress-wiki">Upgrade now</a> to access additional features!', 'wiki');
        ?>
</h3>
			<ul>
				<li><?php 
        _e('Specify the number of breadcrumbs to add to title', 'wiki');
        ?>
</li>
				<li><?php 
        _e('Specify a custom name for Wikis', 'wiki');
        ?>
</li>
				<li><?php 
        _e('Add sub wikis', 'wiki');
        ?>
</li>
				<li><?php 
        _e('Specify how sub wikis should be ordered', 'wiki');
        ?>
</li>
				<li><?php 
        _e('Allow users other than administrator to edit wikis', 'wiki');
        ?>
</li>
			</ul>

			<p class="submit">
			<input type="submit" class="button-primary" name="submit_settings" value="<?php 
        _e('Save Changes', 'wiki');
        ?>
" />
			</p>
		</form>
		<?php 
    }