WP_Customize_Control::get_link() WordPress Method

The WP_Customize_Control::get_link() method is used to get the link for a given control. This is useful for creating links to specific controls in the Customizer.

WP_Customize_Control::get_link( string $setting_key = 'default' ) #

Get the data link attribute for a setting.


Parameters

$setting_key

(string)(Optional)

Default value: 'default'


Top ↑

Return

(string) Data link parameter, a data-customize-setting-link attribute if the $setting_key refers to a pre-registered setting, and a data-customize-setting-key-link attribute if the setting is not yet registered.


Top ↑

Source

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

	public function get_link( $setting_key = 'default' ) {
		if ( isset( $this->settings[ $setting_key ] ) && $this->settings[ $setting_key ] instanceof WP_Customize_Setting ) {
			return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"';
		} else {
			return 'data-customize-setting-key-link="' . esc_attr( $setting_key ) . '"';
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.9.0Return a data-customize-setting-key-link attribute if a setting is not registered for the supplied setting key.
3.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.