Changeset 36842
- Timestamp:
- 03/04/2016 02:01:15 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-widgets.php
r36841 r36842 113 113 114 114 /** 115 * Getthe widget setting type given a setting ID.115 * Retrieves the widget setting type given a setting ID. 116 116 * 117 117 * @since 4.2.0 … … 137 137 138 138 /** 139 * Inspect the incoming customized data for any widget settings, and dynamically add them up-front so widgets will be initialized properly. 139 * Inspects the incoming customized data for any widget settings, and dynamically adds 140 * them up-front so widgets will be initialized properly. 140 141 * 141 142 * @since 4.2.0 … … 169 170 170 171 /** 171 * Determine the arguments for a dynamically-created setting.172 * Determines the arguments for a dynamically-created setting. 172 173 * 173 174 * @since 4.2.0 … … 186 187 187 188 /** 188 * Get an unslashed post value or return a default. 189 * 190 * @since 3.9.0 191 * 189 * Retrieves an unslashed post value or return a default. 190 * 191 * @since 3.9.0 192 192 * @access protected 193 193 * … … 238 238 239 239 /** 240 * Filter old_sidebars_widgets_data Customizer setting. 241 * 242 * When switching themes, filter the Customizer setting 243 * old_sidebars_widgets_data to supply initial $sidebars_widgets before they 244 * were overridden by retrieve_widgets(). The value for 245 * old_sidebars_widgets_data gets set in the old theme's sidebars_widgets 240 * Filters old_sidebars_widgets_data Customizer setting. 241 * 242 * When switching themes, filter the Customizer setting old_sidebars_widgets_data 243 * to supply initial $sidebars_widgets before they were overridden by retrieve_widgets(). 244 * The value for old_sidebars_widgets_data gets set in the old theme's sidebars_widgets 246 245 * theme_mod. 247 246 * 247 * @since 3.9.0 248 * @access public 249 * 248 250 * @see WP_Customize_Widgets::handle_theme_switch() 249 * @since 3.9.0250 * @access public251 251 * 252 252 * @param array $old_sidebars_widgets … … 258 258 259 259 /** 260 * Filter sidebars_widgets option for theme switch. 261 * 262 * When switching themes, the retrieve_widgets() function is run when the 263 * Customizer initializes, and then the new sidebars_widgets here get 264 * supplied as the default value for the sidebars_widgets option. 260 * Filters sidebars_widgets option for theme switch. 261 * 262 * When switching themes, the retrieve_widgets() function is run when the Customizer initializes, 263 * and then the new sidebars_widgets here get supplied as the default value for the sidebars_widgets 264 * option. 265 * 266 * @since 3.9.0 267 * @access public 265 268 * 266 269 * @see WP_Customize_Widgets::handle_theme_switch() 267 * @since 3.9.0268 * @access public269 *270 270 * @global array $sidebars_widgets 271 271 * … … 280 280 281 281 /** 282 * Make sureall widgets get loaded into the Customizer.282 * Ensures all widgets get loaded into the Customizer. 283 283 * 284 284 * Note: these actions are also fired in wp_ajax_update_widget(). … … 299 299 300 300 /** 301 * Ensure widgets are available for all types of previews. 302 * 303 * When in preview, hook to 'customize_register' for settings 304 * after WordPress is loaded so that all filters have been 305 * initialized (e.g. Widget Visibility). 301 * Ensures widgets are available for all types of previews. 302 * 303 * When in preview, hook to 'customize_register' for settings after WordPress is loaded 304 * so that all filters have been initialized (e.g. Widget Visibility). 306 305 * 307 306 * @since 3.9.0 … … 317 316 318 317 /** 319 * Register Customizer settings and controls for all sidebars and widgets.318 * Registers Customizer settings and controls for all sidebars and widgets. 320 319 * 321 320 * @since 3.9.0 … … 467 466 468 467 /** 469 * Returnwhether the widgets panel is active, based on whether there are sidebars registered.468 * Determines whether the widgets panel is active, based on whether there are sidebars registered. 470 469 * 471 470 * @since 4.4.0 … … 483 482 484 483 /** 485 * Co verta widget_id into its corresponding Customizer setting ID (option name).484 * Converts a widget_id into its corresponding Customizer setting ID (option name). 486 485 * 487 486 * @since 3.9.0 … … 502 501 503 502 /** 504 * Determine whether the widget is considered "wide".505 * 506 * Core widgets which may have controls wider than 250, but can 507 * still be shown in the narrow Customizer panel. The RSS and Text508 * widgets in Core, for example, have widths of 400 and yet they509 * still render fine in the Customizer panel. This method will510 * return all Core widgets as being not wide, but this can be503 * Determines whether the widget is considered "wide". 504 * 505 * Core widgets which may have controls wider than 250, but can still be shown 506 * in the narrow Customizer panel. The RSS and Text widgets in Core, for example, 507 * have widths of 400 and yet they still render fine in the Customizer panel. 508 * 509 * This method will return all Core widgets as being not wide, but this can be 511 510 * overridden with the is_wide_widget_in_customizer filter. 512 511 * … … 539 538 540 539 /** 541 * Co verta widget ID into its id_base and number components.540 * Converts a widget ID into its id_base and number components. 542 541 * 543 542 * @since 3.9.0 … … 564 563 565 564 /** 566 * Convert a widget setting ID (option path) to its id_base and number components.565 * Converts a widget setting ID (option path) to its id_base and number components. 567 566 * 568 567 * @since 3.9.0 … … 585 584 586 585 /** 587 * Call admin_print_styles-widgets.php and admin_print_styles hooks to586 * Calls admin_print_styles-widgets.php and admin_print_styles hooks to 588 587 * allow custom styles from plugins. 589 588 * … … 600 599 601 600 /** 602 * Call admin_print_scripts-widgets.php and admin_print_scripts hooks to601 * Calls admin_print_scripts-widgets.php and admin_print_scripts hooks to 603 602 * allow custom scripts from plugins. 604 603 * … … 615 614 616 615 /** 617 * Enqueue scripts and styles for Customizer panel and export data to JavaScript.616 * Enqueues scripts and styles for Customizer panel and export data to JavaScript. 618 617 * 619 618 * @since 3.9.0 … … 707 706 708 707 /** 709 * Render the widget form control templates into the DOM.708 * Renders the widget form control templates into the DOM. 710 709 * 711 710 * @since 3.9.0 … … 745 744 746 745 /** 747 * Call admin_print_footer_scripts and admin_print_scripts hooks to746 * Calls admin_print_footer_scripts and admin_print_scripts hooks to 748 747 * allow custom scripts from plugins. 749 748 * … … 760 759 761 760 /** 762 * Getcommon arguments to supply when constructing a Customizer setting.761 * Retrieves common arguments to supply when constructing a Customizer setting. 763 762 * 764 763 * @since 3.9.0 … … 801 800 802 801 /** 803 * Make sure thatsidebar widget arrays only ever contain widget IDS.802 * Ensures sidebar widget arrays only ever contain widget IDS. 804 803 * 805 804 * Used as the 'sanitize_callback' for each $sidebars_widgets setting. … … 821 820 822 821 /** 823 * Build up an index of all available widgets for use in Backbone models.822 * Builds up an index of all available widgets for use in Backbone models. 824 823 * 825 824 * @since 3.9.0 … … 908 907 909 908 /** 910 * Naturally order available widgets by name.909 * Naturally orders available widgets by name. 911 910 * 912 911 * @since 3.9.0 … … 922 921 923 922 /** 924 * Getthe widget control markup.923 * Retrieves the widget control markup. 925 924 * 926 925 * @since 3.9.0 … … 942 941 943 942 /** 944 * Getthe widget control markup parts.943 * Retrieves the widget control markup parts. 945 944 * 946 945 * @since 4.4.0 … … 949 948 * @param array $args Widget control arguments. 950 949 * @return array { 951 * @type string $control 952 * @type string $content 950 * @type string $control Markup for widget control wrapping form. 951 * @type string $content The contents of the widget form itself. 953 952 * } 954 953 */ … … 973 972 974 973 /** 975 * Add hooks for the Customizer preview.974 * Adds hooks for the Customizer preview. 976 975 * 977 976 * @since 3.9.0 … … 985 984 986 985 /** 987 * Refresh nonce for widget updates.986 * Refreshes the nonce for widget updates. 988 987 * 989 988 * @since 4.2.0 … … 999 998 1000 999 /** 1001 * When previewing, make sure the proper previewing widgets are used. 1002 * 1003 * Because wp_get_sidebars_widgets() gets called early at init 1004 * (via wp_convert_widget_settings()) and can set global variable 1005 * $_wp_sidebars_widgets to the value of get_option( 'sidebars_widgets' ) 1006 * before the Customizer preview filter is added, we have to reset 1007 * it after the filter has been added. 1000 * When previewing, ensures the proper previewing widgets are used. 1001 * 1002 * Because wp_get_sidebars_widgets() gets called early at {@see 'init' } (via 1003 * wp_convert_widget_settings()) and can set global variable `$_wp_sidebars_widgets` 1004 * to the value of `get_option( 'sidebars_widgets' )` before the Customizer preview 1005 * filter is added, it has to be reset after the filter has been added. 1008 1006 * 1009 1007 * @since 3.9.0 … … 1021 1019 1022 1020 /** 1023 * Enqueue scripts for the Customizer preview.1021 * Enqueues scripts for the Customizer preview. 1024 1022 * 1025 1023 * @since 3.9.0 … … 1031 1029 1032 1030 /** 1033 * Insert default style for highlighted widget at early point so theme1031 * Inserts default style for highlighted widget at early point so theme 1034 1032 * stylesheet can override. 1035 1033 * 1036 1034 * @since 3.9.0 1037 1035 * @access public 1038 *1039 * @action wp_print_styles1040 1036 */ 1041 1037 public function print_preview_css() { … … 1054 1050 1055 1051 /** 1056 * At the very end of the page, at the very end of the wp_footer,1057 * communicate the sidebars that appeared on the page.1052 * Communicates the sidebars that appeared on the page at the very end of the page, 1053 * and at the very end of the wp_footer, 1058 1054 * 1059 1055 * @since 3.9.0 … … 1088 1084 1089 1085 /** 1090 * Keep track ofthe widgets that were rendered.1086 * Tracks the widgets that were rendered. 1091 1087 * 1092 1088 * @since 3.9.0 … … 1113 1109 1114 1110 /** 1115 * Determine if a sidebar is rendered on the page.1111 * Determines if a sidebar is rendered on the page. 1116 1112 * 1117 1113 * @since 4.0.0 … … 1126 1122 1127 1123 /** 1128 * Tally the sidebars rendered via is_active_sidebar(). 1129 * 1130 * Keep track of the times that is_active_sidebar() is called 1131 * in the template, and assume that this means that the sidebar 1132 * would be rendered on the template if there were widgets 1133 * populating it. 1124 * Tallies the sidebars rendered via is_active_sidebar(). 1125 * 1126 * Keep track of the times that is_active_sidebar() is called in the template, 1127 * and assume that this means that the sidebar would be rendered on the template 1128 * if there were widgets populating it. 1134 1129 * 1135 1130 * @since 3.9.0 … … 1138 1133 * @param bool $is_active Whether the sidebar is active. 1139 1134 * @param string $sidebar_id Sidebar ID. 1140 * @return bool 1135 * @return bool Whether the sidebar is active. 1141 1136 */ 1142 1137 public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) { … … 1153 1148 1154 1149 /** 1155 * Tall ythe sidebars rendered via dynamic_sidebar().1150 * Tallies the sidebars rendered via dynamic_sidebar(). 1156 1151 * 1157 1152 * Keep track of the times that dynamic_sidebar() is called in the template, … … 1164 1159 * @param bool $has_widgets Whether the current sidebar has widgets. 1165 1160 * @param string $sidebar_id Sidebar ID. 1166 * @return bool 1161 * @return bool Whether the current sidebar has widgets. 1167 1162 */ 1168 1163 public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) { … … 1180 1175 1181 1176 /** 1182 * GetMAC for a serialized widget instance string.1177 * Retrieves MAC for a serialized widget instance string. 1183 1178 * 1184 1179 * Allows values posted back from JS to be rejected if any tampering of the … … 1196 1191 1197 1192 /** 1198 * Sanitize a widget instance.1199 * 1200 * Unserialize the JS-instance for storing in the options. It's important 1201 * that this filter only get applied to an instance once.1193 * Sanitizes a widget instance. 1194 * 1195 * Unserialize the JS-instance for storing in the options. It's important that this filter 1196 * only get applied to an instance *once*. 1202 1197 * 1203 1198 * @since 3.9.0 … … 1237 1232 1238 1233 /** 1239 * Convert widget instance into JSON-representable format.1234 * Converts a widget instance into JSON-representable format. 1240 1235 * 1241 1236 * @since 3.9.0 … … 1260 1255 1261 1256 /** 1262 * Strip out widget IDs for widgets which are no longer registered.1257 * Strips out widget IDs for widgets which are no longer registered. 1263 1258 * 1264 1259 * One example where this might happen is when a plugin orphans a widget … … 1280 1275 1281 1276 /** 1282 * Find and invokethe widget update and control callbacks.1283 * 1284 * Requires that $_POSTbe populated with the instance data.1277 * Finds and invokes the widget update and control callbacks. 1278 * 1279 * Requires that `$_POST` be populated with the instance data. 1285 1280 * 1286 1281 * @since 3.9.0 … … 1407 1402 1408 1403 /** 1409 * Update widget settings asynchronously.1404 * Updates widget settings asynchronously. 1410 1405 * 1411 1406 * Allows the Customizer to update a widget using its form, but return the new 1412 1407 * instance info via Ajax instead of saving it to the options table. 1413 1408 * 1414 * Most code here copied from wp_ajax_save_widget() 1409 * Most code here copied from wp_ajax_save_widget(). 1415 1410 * 1416 1411 * @since 3.9.0 … … 1418 1413 * 1419 1414 * @see wp_ajax_save_widget() 1420 *1421 1415 */ 1422 1416 public function wp_ajax_update_widget() { … … 1507 1501 1508 1502 /** 1509 * Add hooks for selective refresh.1503 * Adds hooks for selective refresh. 1510 1504 * 1511 1505 * @since 4.5.0 … … 1525 1519 1526 1520 /** 1527 * Enqueue scripts for the Customizer preview.1521 * Enqueues scripts for the Customizer preview. 1528 1522 * 1529 1523 * @since 4.5.0 … … 1600 1594 * List of the tag names seen for before_widget strings. 1601 1595 * 1602 * This is used in the filter_wp_kses_allowed_htmlfilter to ensure that the1596 * This is used in the {@see 'filter_wp_kses_allowed_html'} filter to ensure that the 1603 1597 * data-* attributes can be whitelisted. 1604 1598 * 1605 1599 * @since 4.5.0 1606 * @access pr ivate1600 * @access protected 1607 1601 * @var array 1608 1602 */ … … 1610 1604 1611 1605 /** 1612 * Ensure thatthe HTML data-* attributes for selective refresh are allowed by kses.1613 * 1614 * This is needed in case the $before_widgetis run through wp_kses() when printed.1606 * Ensures the HTML data-* attributes for selective refresh are allowed by kses. 1607 * 1608 * This is needed in case the `$before_widget` is run through wp_kses() when printed. 1615 1609 * 1616 1610 * @since 4.5.0 … … 1618 1612 * 1619 1613 * @param array $allowed_html Allowed HTML. 1620 * @return array Allowed HTML.1614 * @return array (Maybe) modified allowed HTML. 1621 1615 */ 1622 1616 public function filter_wp_kses_allowed_data_attributes( $allowed_html ) { … … 1645 1639 * 1646 1640 * @since 4.5.0 1647 * @access pr ivate1641 * @access protected 1648 1642 * @var array 1649 1643 */ … … 1654 1648 * 1655 1649 * @since 4.5.0 1656 * @access pr ivate1650 * @access protected 1657 1651 * @var int 1658 1652 */ … … 1663 1657 * 1664 1658 * @since 4.5.0 1665 * @access pr ivate1659 * @access protected 1666 1660 * @var array 1667 1661 */ … … 1669 1663 1670 1664 /** 1671 * Startkeeping track of the current sidebar being rendered.1665 * Begins keeping track of the current sidebar being rendered. 1672 1666 * 1673 1667 * Insert marker before widgets are rendered in a dynamic sidebar. 1674 1668 * 1675 1669 * @since 4.5.0 1670 * @access public 1676 1671 * 1677 1672 * @param int|string $index Index, name, or ID of the dynamic sidebar. … … 1689 1684 1690 1685 /** 1691 * Finish keeping track of the current sidebar being rendered.1692 * 1693 * Insert marker after widgets are rendered in a dynamic sidebar.1686 * Finishes keeping track of the current sidebar being rendered. 1687 * 1688 * Inserts a marker after widgets are rendered in a dynamic sidebar. 1694 1689 * 1695 1690 * @since 4.5.0 1691 * @access public 1696 1692 * 1697 1693 * @param int|string $index Index, name, or ID of the dynamic sidebar. … … 1708 1704 * 1709 1705 * @since 4.5.0 1710 * @access pr ivate1706 * @access protected 1711 1707 * @var string 1712 1708 */ … … 1717 1713 * 1718 1714 * @since 4.5.0 1719 * @access pr ivate1715 * @access protected 1720 1716 * @var string 1721 1717 */ … … 1723 1719 1724 1720 /** 1725 * Filter sidebars_widgets to ensure the currently-rendered widget is the only widget in the current sidebar.1721 * Filters sidebars_widgets to ensure the currently-rendered widget is the only widget in the current sidebar. 1726 1722 * 1727 1723 * @since 4.5.0 1728 * @access pr ivate1724 * @access protected 1729 1725 * 1730 1726 * @param array $sidebars_widgets Sidebars widgets. 1731 * @return array Sidebars widgets.1727 * @return array Filtered sidebars widgets. 1732 1728 */ 1733 1729 public function filter_sidebars_widgets_for_rendering_widget( $sidebars_widgets ) { … … 1737 1733 1738 1734 /** 1739 * Render a specific widget using the supplied sidebar arguments.1735 * Renders a specific widget using the supplied sidebar arguments. 1740 1736 * 1741 1737 * @since 4.5.0 … … 1744 1740 * @see dynamic_sidebar() 1745 1741 * 1746 * @param WP_Customize_Partial $partial 1742 * @param WP_Customize_Partial $partial Partial. 1747 1743 * @param array $context { 1748 1744 * Sidebar args supplied as container context. 1749 1745 * 1750 * @type string $sidebar_id 1751 * @type int [$sidebar_instance_number]Disambiguating instance number.1746 * @type string $sidebar_id ID for sidebar for widget to render into. 1747 * @type int $sidebar_instance_number Disambiguating instance number. 1752 1748 * } 1753 1749 * @return string|false … … 1814 1810 1815 1811 /** 1816 * Determine whether the captured option update should be ignored.1812 * Determines whether the captured option update should be ignored. 1817 1813 * 1818 1814 * @since 3.9.0 … … 1827 1823 1828 1824 /** 1829 * Retrieve captured widget option updates.1825 * Retrieves captured widget option updates. 1830 1826 * 1831 1827 * @since 3.9.0 … … 1839 1835 1840 1836 /** 1841 * Getthe option that was captured from being saved.1837 * Retrieves the option that was captured from being saved. 1842 1838 * 1843 1839 * @since 4.2.0 … … 1845 1841 * 1846 1842 * @param string $option_name Option name. 1847 * @param mixed $default Optional. Default value to return if the option does not exist. 1843 * @param mixed $default Optional. Default value to return if the option does not exist. Default false. 1848 1844 * @return mixed Value set for the option. 1849 1845 */ … … 1858 1854 1859 1855 /** 1860 * Getthe number of captured widget option updates.1856 * Retrieves the number of captured widget option updates. 1861 1857 * 1862 1858 * @since 3.9.0 … … 1870 1866 1871 1867 /** 1872 * Startkeeping track of changes to widget options, caching new values.1868 * Begins keeping track of changes to widget options, caching new values. 1873 1869 * 1874 1870 * @since 3.9.0 … … 1886 1882 1887 1883 /** 1888 * Pre-filter captured option values before updating.1884 * Pre-filters captured option values before updating. 1889 1885 * 1890 1886 * @since 3.9.0 … … 1911 1907 1912 1908 /** 1913 * Pre-filter captured option values before retrieving.1909 * Pre-filters captured option values before retrieving. 1914 1910 * 1915 1911 * @since 3.9.0 … … 1933 1929 1934 1930 /** 1935 * Undo any changes to the options since options capture began.1931 * Undoes any changes to the options since options capture began. 1936 1932 * 1937 1933 * @since 3.9.0
Note: See TracChangeset
for help on using the changeset viewer.