/** * install for first time */ public function install() { // create tables // nothing yet, decided to use WP's revisions instead of using new data tables // Set options // plugin $options['pacowiki_version'] = '1.0.0'; // post types $options['pacowiki_post_slug'] = 'pacowiki'; $options['pacowiki_hierarchical'] = true; $options['pacowiki_exclude_from_search'] = false; // include posts in WP's default search $options['pacowiki_category_enable'] = true; $options['pacowiki_category_slug'] = 'pacowikicategories'; $options['pacowiki_tag_enable'] = true; $options['pacowiki_tag_slug'] = 'pacowikitags'; $options['pacowiki_tag_tagcloud'] = true; // post $options['pacowiki_show_table_of_contents'] = true; $options['pacowiki_enable_excerpt'] = true; // template $options['pacowiki_template'] = 'default'; $options['pacowiki_load_styles'] = true; // we don't have any custom css or js codes here so there is no need to load them // content of custom css and js codes are saved in a separate option fields(pacowiki_custom_css & pacowiki_custom_js) for size control $options['pacowiki_custom_css_enabled'] = false; $options['pacowiki_custom_js_enabled'] = false; // set up two default wiki roles remove_role('wiki_editor'); $result = add_role('wiki_editor', __('Wiki Editor'), array('publish_posts' => true, 'edit_others_posts' => true, 'delete_others_posts' => true, 'edit_published_posts' => true, 'delete_published_posts' => true, 'edit_posts' => true, 'delete_posts' => true, 'read' => true)); remove_role('wiki_author'); $result = add_role('wiki_author', __('Wiki Author'), array('publish_posts' => true, 'edit_others_posts' => false, 'delete_others_posts' => false, 'edit_published_posts' => true, 'delete_published_posts' => true, 'edit_posts' => true, 'delete_posts' => true, 'read' => true)); remove_role('wiki_contributor'); $result = add_role('wiki_contributor', __('Wiki Contributor'), array('publish_posts' => true, 'edit_others_posts' => false, 'delete_others_posts' => false, 'edit_published_posts' => false, 'delete_published_posts' => false, 'edit_posts' => true, 'delete_posts' => true, 'read' => true)); // set up user role capabilities $roles = pacowiki_get_all_roles(); foreach ($roles as $key => $role) { $capabilities['publish_posts'] = @$role["capabilities"]["publish_posts"]; $capabilities['edit_others_posts'] = @$role["capabilities"]["edit_others_posts"]; $capabilities['delete_others_posts'] = @$role["capabilities"]["delete_others_posts"]; $capabilities['edit_published_posts'] = @$role["capabilities"]["edit_published_posts"]; $capabilities['delete_published_posts'] = @$role["capabilities"]["delete_published_posts"]; $capabilities['edit_posts'] = @$role["capabilities"]["edit_posts"]; $capabilities['delete_posts'] = @$role["capabilities"]["delete_posts"]; $capabilities['read'] = @$role["capabilities"]["read"]; update_option('pacowiki_cap_' . $key, $capabilities, false); } // update option update_option('pacowiki_custom_css', ''); update_option('pacowiki_custom_js', ''); update_option('pacowiki_options', $options, false); PacoWiki()->load_options(); }
/** * get_editable_roles * get list of editable roles */ function pacowiki_get_editable_roles() { $all_roles = pacowiki_get_all_roles(); $editable_roles = apply_filters('editable_roles', $all_roles); return $editable_roles; }
<table class="dtable-table"> <tr> <th></th> <th>Create Wiki</th> <th>Edit Other's</th> <th>Delete Other's</th> <th>Edit Own Post</th> <th>Delete Own Post</th> <th>Edit</th> <th>Delete</th> <th>Read</th> </tr> <?php $roles = pacowiki_get_all_roles(); foreach ($roles as $key => $role) { if ($key == 'administrator') { $is_admin = true; } else { $is_admin = false; } $capabilities = PacoWiki()->get_capabilities($key); ?> <tr> <td><?php echo $role["name"]; ?> </td> <td data-th="Create Wiki"> <input type="checkbox" name="pacowiki_options[pacowiki_cap_<?php echo $key; ?> ][publish_posts]" <?php