WordPress.org

Ready to get started?Download WordPress

Forums

Removing Options (2 posts)

  1. sephers2
    Member
    Posted 3 years ago #

    Hi all,
    I'm developing a plugin that deals with comments and as such it has an admin page that controls all the settings. However a lot of these settings are similar/the same as the ones defined in the discussion panel. I was wondering if there is a way to remove options from the discussion panel. I have been looking at ./wp-admin/options-discussion.php and I can see exactly what I want to hide but obviously as it's a plugin I can't just delete stuff off that page.
    I noticed each option has a <label> around the whole option so is there a way of hiding this??
    Below is the code I am talking about:

    <label for="default_comment_status">
    <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
    <?php _e('Allow people to post comments on new articles') ?></label>
    <br />

    Thanks for any help,
    Sephers2.

  2. fparamaru
    Member
    Posted 3 years ago #

    To hide stuff in that menu, do something like this in your plugin
    (But... if there are items that are there by default, why are u not using them?):

    function hide_them() {
    	?>
    	<script type="text/javascript"><!--
    	/* <![CDATA[ */
    	jQuery('#commentstatusdiv label[for="default_comment_status"]').hide();
    	/* ]]> */
    	--></script>
    	<?php
    }
    add_action('admin_footer', 'hide_them');

    Or... Maybe the better way for you would be to create another admin page and not using the options-discussion.php :)

    you can remove the default discussion options page from the menu and add your own, doing this:

    function mydisq_remove_old() {
    	// remove discussion page
    	remove_submenu_page('options-general.php','options-discussion.php');
    }
    add_action('admin_init', 'mydisq_remove_old');
    
    function mydisq_add_new() {
    	// add own discussion page
    	add_options_page(__('My Discussion Options'), __('My Discussion'), 'manage_options', 'my_discussion_unique_id', 'mydisq_admin_panel');
    }
    add_action('admin_menu', 'mydisq_add_new');
    
    function mydisq_admin_panel() {
    	?>
    	<div class="wrap">
    		<div id="icon-options-general" class="icon32"><br /></div>
    		<h2><?php _e('Discussion Settings'); ?></h2>
    		<!-- output your options panel -->
    	</div>
    	<?php
    }

Topic Closed

This topic has been closed to new replies.

About this Topic