Created
July 12, 2016 00:20
-
-
Save s-hiroshi/e79d18449fd995af89a8b058094ce4ff to your computer and use it in GitHub Desktop.
WordPressセットアップ(InfoTown_Admin、InfoTown_Post)のサンプルです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 管理画面設定 | |
* | |
* @package InfoTown | |
* @author Hiroshi Sawai <info@info-town.jp> | |
* @copyright Hiroshi Sawai | |
*/ | |
class InfoTown_Admin { | |
// 管理者以外アップデート非表示 | |
public function hide_core_update() { | |
if ( ! current_user_can( 'administrator' ) ) { | |
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) ); | |
} | |
} | |
public function hide_plugins_update() { | |
// 管理者以外プラグインアップデート非表示 | |
if ( ! current_user_can( 'administrator' ) ) { | |
add_action( 'admin_menu', 'remove_counts' ); | |
function remove_counts() { | |
global $menu, $submenu; | |
$menu[65][0] = 'プラグイン'; | |
$submenu['index.php'][10][0] = 'Updates'; | |
} | |
} | |
} | |
/* | |
* ダッシュボード不要項目非表示 | |
*/ | |
public $meta_boxes; | |
public function remove_meta_boxes( $args ) { | |
remove_all_actions( 'wp_dashboard_setup' ); | |
$this->meta_boxes = $args; | |
add_action( 'wp_dashboard_setup', array($this, '_remove_meta_boxes') ); | |
} | |
public function _remove_meta_boxes() { | |
global $wp_meta_boxes; | |
foreach ( $this->meta_boxes['normal'] as $arg ) { | |
unset( $wp_meta_boxes['dashboard']['normal']['core'][ $arg ] ); | |
} | |
foreach ( $this->meta_boxes['side'] as $arg ) { | |
unset( $wp_meta_boxes['dashboard']['side']['core'][ $arg ] ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 管理画面設定 | |
* | |
* @package InfoTown | |
* @author Hiroshi Sawai <info@info-town.jp> | |
* @copyright Hiroshi Sawai | |
*/ | |
class InfoTown_Post { | |
// 投稿画面のカスタマイズ | |
private $meta_boxes; | |
public function remove_default_meta_boxes( $args ) { | |
$this->meta_boxes = $args; | |
add_action( 'admin_menu', array( $this, '_remove_default_meta_boxes' ) ); | |
} | |
public function _remove_default_meta_boxes() { | |
foreach ( $this->meta_boxes as $arg ) { | |
remove_meta_box( $arg, 'post', 'normal' ); | |
} | |
} | |
// 投稿一覧画面からタグ列削除 | |
private $columns_name; | |
public function remove_list_columns( $args ) { | |
$this->columns_name = $args; | |
add_filter( 'manage_posts_columns', array( $this, '_remove_list_columns' ) ); | |
} | |
public function _remove_list_columns( $columns ) { | |
foreach ( $this->columns_name as $arg ) { | |
unset( $columns[ $arg ] ); | |
} | |
return $columns; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment