options_discussion_add_js() WordPress Function

This function is used to add JavaScript to the discussion settings page in the WordPress admin area. It allows users to select the default option for new discussions, as well as specify whether they want to display the "Allow comments" and "Allow trackbacks and pingbacks" options.

options_discussion_add_js() #

Output JavaScript to toggle display of additional settings if avatars are disabled.


Source

File: wp-admin/includes/options.php

function options_discussion_add_js() {
	?>
	<script>
	(function($){
		var parent = $( '#show_avatars' ),
			children = $( '.avatar-settings' );
		parent.on( 'change', function(){
			children.toggleClass( 'hide-if-js', ! this.checked );
		});
	})(jQuery);
	</script>
	<?php
}

Top ↑

Changelog

Changelog
VersionDescription
4.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.