WP_Customize_Widgets::get_widget_control_parts() WordPress Method

The WP_Customize_Widgets::get_widget_control_parts() method is used to get an array of the various parts that make up a widget control. This includes the title, form fields, and the update button.

WP_Customize_Widgets::get_widget_control_parts( array $args ) #

Retrieves the widget control markup parts.


Parameters

$args

(array)(Required)Widget control arguments.


Top ↑

Return

(array)

  • 'control'
    (string) Markup for widget control wrapping form.
  • 'content'
    (string) The contents of the widget form itself.


Top ↑

Source

File: wp-includes/class-wp-customize-widgets.php

	public function get_widget_control_parts( $args ) {
		$args[0]['before_widget_content'] = '<div class="widget-content">';
		$args[0]['after_widget_content']  = '</div><!-- .widget-content -->';
		$control_markup                   = $this->get_widget_control( $args );

		$content_start_pos = strpos( $control_markup, $args[0]['before_widget_content'] );
		$content_end_pos   = strrpos( $control_markup, $args[0]['after_widget_content'] );

		$control  = substr( $control_markup, 0, $content_start_pos + strlen( $args[0]['before_widget_content'] ) );
		$control .= substr( $control_markup, $content_end_pos );
		$content  = trim(
			substr(
				$control_markup,
				$content_start_pos + strlen( $args[0]['before_widget_content'] ),
				$content_end_pos - $content_start_pos - strlen( $args[0]['before_widget_content'] )
			)
		);

		return compact( 'control', 'content' );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.4.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.

Show More