Created
October 9, 2012 13:26
-
-
Save miya0001/3858804 to your computer and use it in GitHub Desktop.
WordPressでattachmentのページとかボタンを消す!
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 | |
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