前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >WordPress 中禁止编辑“已发布”的文章

WordPress 中禁止编辑“已发布”的文章

作者头像
Jeff
发布2018-01-19 16:24:57
9990
发布2018-01-19 16:24:57
举报
文章被收录于专栏:DeveWorkDeveWork

出于某些目的(如多人博客要保护自己已经发表的文章不受篡改),我们可能需要对WordPress 中“已发布”的文章进行“编辑”的限制。下面由Jeff 分享个来自prevent-publish-edit-plugin 插件的代码,可以实现WordPress 中禁止编辑“已发布”的文章。

<?php /* * Removes the edit action from the post row actions if the post is published */ function pep_post_row_actions( $actions , $post ) {   if ( $post->post_status == 'publish' ) unset( $actions['edit'] );   return $actions; }   /* * Blanks the Edit link shown in the public interface if the post is published */ function pep_edit_post_link( $link ) {   global $post;   if ( $post->post_status == 'publish' ) $link = '';   return $link;   }   /* * Removes the Edit Post option from the admin bar if a single post is being shown and * the post is published */ function pep_before_admin_bar_render() {   global $wp_admin_bar, $post;   if ( is_single() && $post->post_status == 'publish' ) $wp_admin_bar->remove_menu('edit');   }   // set up the filters add_filter( 'post_row_actions' , 'pep_post_row_actions' , 1 , 2 ); add_filter( 'edit_post_link' , 'pep_edit_post_link' , 1 );   // set up the action add_action( 'wp_before_admin_bar_render' , 'pep_before_admin_bar_render' ); ?>

你可以自行添加到主题的functions.php 文件下或者做成一个插件激活使用。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013/10/26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档