add_filter( 'bulk_actions-upload', function( $actions ){
$actions['make_gallery'] = 'ギャラリーコードを作成';
return $actions;
}, 20 );
add_filter( 'handle_bulk_actions-upload', function( $redirect_to, $action, $ids ){
if( $action !== 'make_gallery' ){
return $redirect_to;
}
$id_str = implode( ',', $ids );
$code = '[gallery ids="' . $id_str . '" columns="1" size="full"]';
set_transient(
'kb_gallery_code_' . get_current_user_id(),
$code,
60
);
return add_query_arg( 'kb_gallery_code', '1', $redirect_to );
}, 10, 3 );
add_action( 'admin_notices', function(){
$screen = get_current_screen();
if( !$screen || $screen->id !== 'upload' ){
return;
}
if( empty( $_GET['kb_gallery_code'] ) ){
return;
}
$code = get_transient(
'kb_gallery_code_' . get_current_user_id()
);
if( !$code ){
return;
}
delete_transient(
'kb_gallery_code_' . get_current_user_id()
);
echo '
';
echo '下のコードを記事本文にそのまま貼り付けてください';
echo '
';
echo '
';
});
XML SitemapXML Sitemap Index