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

feat: add jetpack compatibility file #160

Merged
merged 1 commit into from
May 30, 2024
Merged
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
1 change: 1 addition & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@

// Include theme resources.
require_once NEWSPACK_BLOCK_THEME_FILE_PATH . '/includes/class-core.php';
require_once NEWSPACK_BLOCK_THEME_FILE_PATH . '/includes/class-jetpack.php';
5 changes: 2 additions & 3 deletions includes/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final class Core {
protected static $instance = null;

/**
* Main Newspack_Block_Theme instance.
* Ensures only one instance of Newspack_Block_Theme is loaded or can be loaded.
* Main Core instance.
* Ensures only one instance of Core is loaded or can be loaded.
*
* @return Core - Main instance.
*/
Expand Down Expand Up @@ -142,5 +142,4 @@ public static function block_pattern_categories() {
}
}


Core::instance();
60 changes: 60 additions & 0 deletions includes/class-jetpack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Jetpack compatibility file.
* See: http://jetpack.com/
*
* @package Newspack_Block_Theme
*/

namespace Newspack_Block_Theme;

defined( 'ABSPATH' ) || exit;

/**
* Main Jetpack class.
*/
final class Jetpack {
/**
* The single instance of the class.
*
* @var Jetpack
*/
protected static $instance = null;

/**
* Main Jetpack instance.
* Ensures only one instance of Jetpack is loaded or can be loaded.
*
* @return Jetpack - Main instance.
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}

/**
* Constructor.
*/
public function __construct() {
\add_action( 'after_setup_theme', [ __CLASS__, 'theme_support' ] );
\add_filter( 'sharing_show', '__return_false' );
\add_filter( 'sharing_enqueue_scripts', '__return_false' );
\add_filter( 'post_flair_disable', '__return_true' );
}

/**
* Registers support for various Jetpack features.
*
* @since Newspack Block Theme 1.0
*
* @return void
*/
public static function theme_support() {
// Add theme support for geo-location.
\add_theme_support( 'jetpack-geo-location' );
}
}

Jetpack::instance();