Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classic Theme Helper: Load relevant theme compat functionality from package #41598

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Theme tools: Load theme compat functionality relevant to features in Classic Theme Helper package, from this package.
18 changes: 8 additions & 10 deletions projects/packages/classic-theme-helper/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ public static function init() {
if ( ! self::$instance ) {
self::$instance = new Main();
self::$instance->load_modules();
// TODO Commenting below since we still load them from theme-tools module
add_action( 'init', array( __CLASS__, 'jetpack_load_theme_tools' ), 30 );
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
// add_action( 'after_setup_theme', array( __CLASS__, 'jetpack_load_theme_compat' ), -1 );
add_action( 'after_setup_theme', array( __CLASS__, 'classic_theme_helper_load_theme_compat' ), -1 );
}

return self::$instance;
Expand Down Expand Up @@ -78,15 +76,15 @@ public static function jetpack_load_theme_tools() {
/**
* Load theme compat file if it exists.
*/
public static function jetpack_load_theme_compat() {
public static function classic_theme_helper_load_theme_compat() {

/**
* Filter theme compat files.
*
* Themes can add their own compat files here if they like. For example:
*
* add_filter( 'jetpack_theme_compat_files', 'mytheme_jetpack_compat_file' );
* function mytheme_jetpack_compat_file( $files ) {
* add_filter( 'classic_theme_helper_theme_compat_files', 'mytheme_classic_theme_helper_theme_compat_file' );
* function mytheme_classic_theme_helper_theme_compat_file( $files ) {
* $files['mytheme'] = locate_template( 'jetpack-compat.php' );
* return $files;
* }
Expand All @@ -96,7 +94,7 @@ public static function jetpack_load_theme_compat() {
* @param array Associative array of theme compat files to load.
*/
$compat_files = apply_filters(
'jetpack_theme_compat_files',
'classic_theme_helper_theme_compat_files',
array(
'twentyfourteen' => __DIR__ . '/compat/twentyfourteen.php',
'twentyfifteen' => __DIR__ . '/compat/twentyfifteen.php',
Expand All @@ -107,10 +105,10 @@ public static function jetpack_load_theme_compat() {
)
);

self::jetpack_require_compat_file( get_stylesheet(), $compat_files );
self::classic_theme_helper_require_compat_file( get_stylesheet(), $compat_files );

if ( is_child_theme() ) {
self::jetpack_require_compat_file( get_template(), $compat_files );
self::classic_theme_helper_require_compat_file( get_template(), $compat_files );
}
}

Expand All @@ -121,7 +119,7 @@ public static function jetpack_load_theme_compat() {
* @param array $files Array of files to check in.
* @return void|WP_Error
*/
private static function jetpack_require_compat_file( $key, $files ) {
private static function classic_theme_helper_require_compat_file( $key, $files ) {
if ( ! is_string( $key ) ) {
return new WP_Error( 'key_not_string', 'The specified key is not actually a string.', compact( 'key' ) );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Theme tools: Load theme compat functionality relevant to features in Classic Theme Helper package, from this package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Theme tools: Load theme compat functionality relevant to features in Classic Theme Helper package, from this package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Theme tools: Load theme compat functionality relevant to features in Classic Theme Helper package, from this package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Theme tools: Load theme compat functionality relevant to features in Classic Theme Helper package, from this package.
Loading