Skip to content

Instantly share code, notes, and snippets.

@miya0001
Created October 9, 2012 13:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miya0001/3858804 to your computer and use it in GitHub Desktop.
Save miya0001/3858804 to your computer and use it in GitHub Desktop.
WordPressでattachmentのページとかボタンを消す!
<?php
new disable_attachment_page();
class disable_attachment_page {
function __construct()
{
add_action("template_redirect", array(&$this, "template_redirect"));
add_action("admin_print_styles", array(&$this, "admin_print_styles"));
}
public function admin_print_styles()
{
echo '<style type="text/css">button.urlpost{display:none;}</style>';
}
public function template_redirect()
{
if (is_attachment() && !is_user_logged_in()) {
global $wp_query;
$wp_query->set_404();
status_header(404);
}
}
} // end class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment