├── .gitmodules ├── lock-posts-files └── languages │ ├── lock-posts.mo │ ├── lock-posts.pot │ └── lock-posts.po ├── changelog.txt ├── README.md └── lock-posts.php /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dash-notice"] 2 | path = dash-notice 3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git 4 | -------------------------------------------------------------------------------- /lock-posts-files/languages/lock-posts.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/lock-posts/master/lock-posts-files/languages/lock-posts.mo -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Plugin Name: Lock Posts 2 | Author: WPMUDEV 3 | Lead developer: Maniu 4 | Contributors: Andrew Billits, Ulrich Sossou 5 | 6 | Change Log: 7 | ---------------------------------------------------------------------- 8 | 1.1.7 - 12/16/2016 9 | ---------------------------------------------------------------------- 10 | 11 | - Updated WPMU DEV Dashboard Notification 12 | 13 | 1.1.6 - 11/13/2015 14 | ---------------------------------------------------------------------- 15 | - Update dash notice 16 | 17 | 18 | 1.1.5 - 11/13/2013 19 | ---------------------------------------------------------------------- 20 | - Added support for all public custom post types. 21 | 22 | 1.1 - 08/10/2012 23 | ---------------------------------------------------------------------- 24 | - Locking based on user capability querying interception. 25 | - Filterable, post type based scope locking. 26 | - Filterable set of locking capabilities. 27 | 28 | 1.0.3 - 01/10/2012 29 | ---------------------------------------------------------------------- 30 | - Fix for submenu checks. 31 | 32 | 1.0.2 - 01/04/2011 33 | ---------------------------------------------------------------------- 34 | - 3.1+ compatibility. 35 | - Internationalization. 36 | 37 | 1.0.1 - 08/31/2009 38 | ---------------------------------------------------------------------- 39 | - Fixed bug that resulted in posts getting locked regardless of setting. 40 | 41 | 1.0.0 - 06/19/2009 42 | ---------------------------------------------------------------------- 43 | - Initial Release. -------------------------------------------------------------------------------- /lock-posts-files/languages/lock-posts.pot: -------------------------------------------------------------------------------- 1 | # Translation of the WordPress plugin Lock Posts 1.0.2 by Andrew Billits, Ulrich Sossou. 2 | # Copyright (C) 2011 Andrew Billits, Ulrich Sossou 3 | # This file is distributed under the same license as the Lock Posts package. 4 | # FIRST AUTHOR , 2011. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: Lock Posts 1.0.2\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2012-03-10 16:28+0100\n" 11 | "PO-Revision-Date: 2012-03-10 16:28+0100\n" 12 | "Last-Translator: \n" 13 | "Language-Team: Incsub \n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | "Language: \n" 18 | "X-Poedit-KeywordsList: __;_e\n" 19 | "X-Poedit-Basepath: d:\\Tmp\\Incsub\\lock-posts\\\n" 20 | "X-Poedit-SearchPath-0: .\n" 21 | 22 | #: lock-posts.php:67 23 | msgid "Lock Status" 24 | msgstr "" 25 | 26 | #: lock-posts.php:83 27 | #: lock-posts.php:118 28 | msgid "Locked" 29 | msgstr "" 30 | 31 | #: lock-posts.php:85 32 | #: lock-posts.php:119 33 | msgid "Unlocked" 34 | msgstr "" 35 | 36 | #: lock-posts.php:95 37 | #: lock-posts.php:96 38 | msgid "Post Status" 39 | msgstr "" 40 | 41 | #: lock-posts.php:121 42 | msgid "Locked posts cannot be edited by anyone other than Super admins." 43 | msgstr "" 44 | 45 | #: lock-posts.php:158 46 | msgid "Post Locked" 47 | msgstr "" 48 | 49 | #: lock-posts.php:159 50 | #, php-format 51 | msgid "The post \"%s\" has been locked by a Super admin and you aren't able to edit it." 52 | msgstr "" 53 | 54 | #: lock-posts.php:160 55 | msgid "Back to Posts List" 56 | msgstr "" 57 | 58 | #: lock-posts.php:193 59 | msgid "Please install the latest version of our free Update Notifications plugin which helps you stay up-to-date with the most stable, secure versions of WPMU DEV themes and plugins. More information »" 60 | msgstr "" 61 | 62 | -------------------------------------------------------------------------------- /lock-posts-files/languages/lock-posts.po: -------------------------------------------------------------------------------- 1 | # Translation of the WordPress plugin Lock Posts 1.0.2 by Andrew Billits, Ulrich Sossou. 2 | # Copyright (C) 2011 Andrew Billits, Ulrich Sossou 3 | # This file is distributed under the same license as the Lock Posts package. 4 | # FIRST AUTHOR , 2011. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: Lock Posts 1.0.2\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2012-03-10 16:28+0100\n" 11 | "PO-Revision-Date: 2013-10-11 14:01+0100\n" 12 | "Last-Translator: \n" 13 | "Language-Team: Incsub \n" 14 | "MIME-Version: 1.0\n" 15 | "Content-Type: text/plain; charset=UTF-8\n" 16 | "Content-Transfer-Encoding: 8bit\n" 17 | "X-Poedit-KeywordsList: __;_e\n" 18 | "X-Poedit-Basepath: d:\\Tmp\\Incsub\\lock-posts\\\n" 19 | "X-Generator: Poedit 1.5.5\n" 20 | "X-Poedit-SearchPath-0: .\n" 21 | 22 | #: lock-posts.php:67 23 | msgid "Lock Status" 24 | msgstr "" 25 | 26 | #: lock-posts.php:83 lock-posts.php:118 27 | msgid "Locked" 28 | msgstr "" 29 | 30 | #: lock-posts.php:85 lock-posts.php:119 31 | msgid "Unlocked" 32 | msgstr "" 33 | 34 | #: lock-posts.php:95 lock-posts.php:96 35 | msgid "Post Status" 36 | msgstr "" 37 | 38 | #: lock-posts.php:121 39 | msgid "Locked posts cannot be edited by anyone other than Super admins." 40 | msgstr "" 41 | 42 | #: lock-posts.php:158 43 | msgid "Post Locked" 44 | msgstr "" 45 | 46 | #: lock-posts.php:159 47 | #, php-format 48 | msgid "" 49 | "The post \"%s\" has been locked by a Super admin and you aren't able to edit " 50 | "it." 51 | msgstr "" 52 | 53 | #: lock-posts.php:160 54 | msgid "Back to Posts List" 55 | msgstr "" 56 | 57 | #: lock-posts.php:193 58 | msgid "" 59 | "Please install the latest version of our free " 61 | "Update Notifications plugin which helps you stay up-to-date with the " 62 | "most stable, secure versions of WPMU DEV themes and plugins. More information »" 65 | msgstr "" 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lock Posts 2 | 3 | 4 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.** 5 | 6 | ## Translations 7 | 8 | Translation files can be found at https://github.com/wpmudev/translations 9 | 10 | ## About 11 | 12 | Lock Posts lets a network super admin 'lock' or 'fix' posts so they can't be edited by the users of that site – even administrators. 13 | 14 | ### Block post editing 15 | 16 | Perfect for stopping school assignments from being edited after submission or adding a post to a network that you don't want removed. Lock Posts adds a post status module that's only available to post or page admins. Easily toggle the status between locked and unlocked. 17 | 18 | ![Lock Posts Editor](http://premium.wpmudev.org/wp-content/uploads/2009/06/lock-posts-1150-editor.png) 19 | 20 | Quickly toggle between lock status 21 | 22 | Quickly see what posts have been locked by the super admin from 'All Posts'. 23 | 24 | ![Lock Posts Locked](http://premium.wpmudev.org/wp-content/uploads/2009/06/lock-posts-1150-locked.png) 25 | 26 | Status information conveniently shown in 'All Posts' 27 | 28 | Take control of what posts can be edited across an entire Multisite network with Lock Posts. 29 | 30 | ## Usage 31 | 32 | ### To Get Started: 33 | 34 | Start by reading the [Installing Plugins](https://premium.wpmudev.org/wpmu-manual/installing-regular-plugins-on-wpmu/) section in our comprehensive [WordPress and WordPress Multisite Manual](https://premium.wpmudev.org/wpmu-manual/) if you are new to WordPress. _Important notes:_ 35 | 36 | * If you have an older version of the plugin installed in /mu-plugins/ please delete it. 37 | * When this plugin is activated on a single site, only admins have the capability to lock/unlock posts. 38 | * When activated on any site in a multisite install, it is activated on all sites, but only the network admin can lock/unlock posts. 39 | 40 | ### To Use: 41 | 42 | Log into your site as an admin (or network-admin) user. Then go to any post, page or custom post type you want to lock. Click the "Edit" link and scroll to the bottom of the edit screen. 43 | 44 | ![Lock Posts Editor](https://premium.wpmudev.org/wp-content/uploads/2009/06/lock-posts-1150-editor.png) 45 | 46 | Once a post has been locked, you'll see that indicated in a new column on the All Posts screen. 47 | 48 | ![Lock Posts Locked](https://premium.wpmudev.org/wp-content/uploads/2009/06/lock-posts-1150-locked.png) 49 | 50 | Any other user who tries to edit a locked post will get a friendly message informing them that it has been locked. 51 | 52 | ![Lock Posts Locked Message](https://premium.wpmudev.org/wp-content/uploads/2009/06/lock-posts-1150-locked-message.png) 53 | 54 | Please note the following: 55 | 56 | * On a network install, only super-admin can lock/unlock posts. Individual site admins and other roles cannot. 57 | * On a single site install, site admin can lock/unlock, other roles cannot. 58 | -------------------------------------------------------------------------------- /lock-posts.php: -------------------------------------------------------------------------------- 1 | lock_capabilities = array( 42 | 'edit_post', 43 | 'delete_post', 44 | ); 45 | 46 | add_action( 'add_meta_boxes', array( &$this, 'meta_box' ) ); 47 | add_action( 'admin_menu', array( &$this, 'admin_page' ) ); 48 | add_action( 'save_post', array( &$this, 'update' ) ); 49 | add_action( 'init', array( &$this, 'check' ) ); 50 | 51 | add_filter('user_has_cap', array($this, 'kill_edit_cap'), 10, 3); 52 | 53 | add_action( 'init', array( &$this, 'add_columns' ), 99 ); 54 | 55 | add_action( 'plugins_loaded', array( &$this, 'load_languages' ) ); 56 | } 57 | 58 | function load_languages() { 59 | // load text domain 60 | if ( defined( 'WPMU_PLUGIN_DIR' ) && file_exists( WPMU_PLUGIN_DIR . '/lock-posts.php' ) ) { 61 | load_muplugin_textdomain( 'lock_posts', 'lock-posts-files/languages' ); 62 | } else { 63 | load_plugin_textdomain( 'lock_posts', false, dirname( plugin_basename( __FILE__ ) ) . '/lock-posts-files/languages' ); 64 | } 65 | } 66 | 67 | /** 68 | * Properly filtering out forbidden capabilities for non-super admin users. 69 | */ 70 | function kill_edit_cap ($all, $caps, $args) { 71 | global $post; 72 | if (!is_object($post) || !isset($post->post_type)) return $all; // Only proceed for pages with known post types 73 | if (!in_array($post->post_type, $this->lock_capabilities)) return $all; // Only proceed for allowed types 74 | 75 | if (!$args) return $all; // Something is wrong here. 76 | if (count($args) < 3) return $all; // Only proceed for individual items. 77 | if (!isset($args[0])) return $all; // Something is still wrong here. 78 | 79 | //if ('edit_post' != $args[0]) return $all; // So, not the one we're looking for. 80 | if (!in_array($args[0], $this->lock_capabilities)) return $all; // Not one of the forbidden capabilities 81 | $post_id = isset($args[2]) ? $args[2] : false; 82 | if (!$post_id) return $all; // Can't obtain post ID 83 | 84 | $post_lock_status = ('locked' == get_post_meta($post_id, '_post_lock_status', true)); 85 | 86 | return $post_lock_status ? (is_super_admin() ? $all : false) : $all; 87 | } 88 | 89 | /** 90 | * Properly manage columns 91 | * 92 | */ 93 | function add_columns() { 94 | $this->post_types = get_post_types(array('show_ui' => true, 'public' => true)); 95 | unset($this->post_types['attachment']); 96 | 97 | foreach ($this->post_types as $post_type) { 98 | add_filter( 'manage_edit-'.$post_type.'_columns', array( &$this, 'status_column' ), 999 ); 99 | add_action( 'manage_'.$post_type.'_posts_custom_column', array( &$this, 'status_output' ), 99, 2 ); 100 | } 101 | } 102 | 103 | /** 104 | * Add column to posts management panel 105 | * 106 | */ 107 | function status_column( $columns ) { 108 | $columns['lock_status'] = __( 'Lock Status', 'lock_posts' ); 109 | return $columns; 110 | } 111 | 112 | /** 113 | * Display columns content on posts management panel 114 | * 115 | */ 116 | function status_output( $column, $id ) { 117 | if( $column == 'lock_status' ) { 118 | $post_lock_status = get_post_meta( $id, '_post_lock_status' ); 119 | 120 | if( is_array( $post_lock_status ) && isset( $post_lock_status[0] ) ) 121 | $post_lock_status = $post_lock_status[0]; 122 | 123 | if( 'locked' == $post_lock_status ) 124 | echo __( 'Locked', 'lock_posts' ); 125 | else 126 | echo __( 'Unlocked', 'lock_posts' ); 127 | } 128 | } 129 | 130 | /** 131 | * Add metabox to posts edition panel 132 | * 133 | */ 134 | function meta_box() { 135 | if (!is_super_admin()) return; 136 | 137 | foreach ($this->post_types as $key => $post_type) { 138 | add_meta_box( 'postlock', __( 'Post Status', 'lock_posts' ), array( &$this, 'meta_box_output' ), $post_type, 'advanced', 'high' ); 139 | } 140 | } 141 | 142 | /** 143 | * Post status metabox 144 | * 145 | */ 146 | function meta_box_output( $post ) { 147 | if ( !is_super_admin() ) 148 | return; 149 | 150 | $post_lock_status = get_post_meta( $post->ID, '_post_lock_status' ); 151 | if( is_array( $post_lock_status ) && isset( $post_lock_status[0] ) ) 152 | $post_lock_status = $post_lock_status[0]; 153 | 154 | if( empty( $post_lock_status ) ) 155 | $post_lock_status = 'unlocked'; 156 | ?> 157 |
158 | 159 | 163 |

164 |
165 | '; 200 | echo '

' . __( 'Post Locked', 'lock_posts' ) . '

'; 201 | echo '

' . sprintf( __( 'The post "%s" has been locked by a Super admin and you aren\'t able to edit it.', 'lock_posts' ), $post->post_title ) . '

'; 202 | echo '

« ' . __( 'Back to Posts List', 'lock_posts' ) . '

'; 203 | echo ''; 204 | } 205 | 206 | /** 207 | * Add admin page 208 | * 209 | */ 210 | function admin_page() { 211 | global $submenu; 212 | 213 | add_submenu_page( 'edit.php', 'Post Locked', 'Post Locked', 'edit_posts', 'post-locked', array( &$this, 'locked' ) ); 214 | 215 | if (isset($submenu['edit.php']) && is_array($submenu['edit.php'])) foreach( $submenu['edit.php'] as $key => $menu_item ) { 216 | if( isset( $menu_item[2] ) && $menu_item[2] == 'post-locked' ) 217 | unset( $submenu['edit.php'][$key] ); 218 | } 219 | } 220 | 221 | } 222 | 223 | $lock_posts = new Lock_Posts(); 224 | 225 | global $wpmudev_notices; 226 | $wpmudev_notices[] = array( 'id'=> 83, 'name'=> 'Lock Posts', 'screens' => array( 'post' ) ); 227 | include_once(plugin_dir_path( __FILE__ ).'dash-notice/wpmudev-dash-notification.php'); 228 | 229 | --------------------------------------------------------------------------------