| 1894 | * Updates the new theme with the theme mods of the old theme. |
| 1895 | * |
| 1896 | * @param string $template Old theme name. |
| 1897 | * @param WP_Theme $theme WP_Theme instance of the old theme. |
| 1898 | */ |
| 1899 | function _maybe_inherit_theme_mods( $template, $theme = null ) { |
| 1900 | // If the old theme exists, $template is the theme name. |
| 1901 | if ( $template_exists = is_a( $theme, 'WP_Theme' ) ) { |
| 1902 | $template = $theme->get_stylesheet(); |
| 1903 | } |
| 1904 | |
| 1905 | // If the old theme is the new themes parent... |
| 1906 | if ( wp_get_theme()->get_template() === $template ) { |
| 1907 | |
| 1908 | // Check legacy theme mods if the old theme exists. |
| 1909 | if ( false === ( $mods = get_option( "theme_mods_$template" ) ) && $template_exists ) { |
| 1910 | $theme_name = $theme->get( 'Name' ); |
| 1911 | $mods = get_option( "mods_$theme_name" ); // Deprecated location. |
| 1912 | } |
| 1913 | |
| 1914 | // ...and it has theme mods, pass them on. |
| 1915 | if ( false !== $mods ) { |
| 1916 | foreach ( (array) $mods as $name => $value ) { |
| 1917 | if ( 'sidebars_widgets' == $name ) { |
| 1918 | continue; |
| 1919 | } |
| 1920 | set_theme_mod( $name, $value ); |
| 1921 | } |
| 1922 | } |
| 1923 | } |
| 1924 | } |
| 1925 | |
| 1926 | /** |