WP_Customize_Control::maybe_render() WordPress Method
The WP_Customize_Control::maybe_render() method is used to conditionally render a control. This method can be useful if you need to conditionally render a control based on the state of another control. For example, you might want to only render a control if a certain checkbox is checked. In order to use this method, you need to first check if the control is rendered using the WP_Customize_Control::is_renderable() method. If the control is rendered, you can then call the WP_Customize_Control::render() method to actually output the control. Here is an example of how you might use the WP_Customize_Control::maybe_render() method: if ( $wp_customize->is_renderable( 'my_control' ) ) { $wp_customize->render( 'my_control' ); }
WP_Customize_Control::maybe_render() #
Check capabilities and render the control.
Source
File: wp-includes/class-wp-customize-control.php
final public function maybe_render() { if ( ! $this->check_capabilities() ) { return; } /** * Fires just before the current Customizer control is rendered. * * @since 3.4.0 * * @param WP_Customize_Control $control WP_Customize_Control instance. */ do_action( 'customize_render_control', $this ); /** * Fires just before a specific Customizer control is rendered. * * The dynamic portion of the hook name, `$this->id`, refers to * the control ID. * * @since 3.4.0 * * @param WP_Customize_Control $control WP_Customize_Control instance. */ do_action( "customize_render_control_{$this->id}", $this ); $this->render(); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |