WordPressのfunction.phpで常用するコード⑧(プラグイン編)
2016.07.19
プラグイン「All in One SEO」:管理者以外非表示
function.php
function remove_aiosp_meta_box() {
if ( ! current_user_can( 'administrator' ) ) {
remove_meta_box( 'aiosp', 'post', 'advanced' );
}
}
add_action( 'admin_menu' , 'remove_aiosp_meta_box', 1000 );
プラグイン「Jetpack」:OGP非表示
function.php
add_filter( 'jetpack_enable_open_graph', '__return_false' );
プラグイン「Jetpack」:SNSボタンを任意の場所に表示
function.php
function jptweak_remove_share() {
remove_filter( 'the_content', 'sharing_display',19 );
remove_filter( 'the_excerpt', 'sharing_display',19 );
if ( class_exists( 'Jetpack_Likes' ) ) {
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
}
}
add_action( 'loop_start', 'jptweak_remove_share' );
表示用
if ( function_exists( 'sharing_display' ) ) {
sharing_display( '', true );
}
プラグイン「Public Post Preview」:有効期限期間を指定
function.php
add_filter( 'ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
return 60 * 60 * 24 * 14; // 14 日間(秒×分×時間×日)
}