Skip to content

Commit

Permalink
Classic Theme Helper: Require Jetpack Testimonials from the package (…
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-karen authored and matticbot committed Dec 11, 2024
1 parent 09b0fe0 commit 3d336a1
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 98 deletions.
62 changes: 31 additions & 31 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/automattic/jetpack-classic-theme-helper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Jetpack Testimonials: Ensuring functionality runs via the Classic Theme Helper package.

## [0.7.4] - 2024-12-09
### Fixed
- Content Options: Ensure excerpt_length is cast to an int if it is not already, to prevent fatal errors. [#40389]
Expand Down Expand Up @@ -167,6 +174,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Add wordpress folder on gitignore. [#37177]

[0.8.0-alpha]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.4...v0.8.0-alpha
[0.7.4]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.3...v0.7.4
[0.7.3]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.2...v0.7.3
[0.7.2]: https://github.com/Automattic/jetpack-classic-theme-helper/compare/v0.7.1...v0.7.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"extra": {
"autotagger": true,
"branch-alias": {
"dev-trunk": "0.7.x-dev"
"dev-trunk": "0.8.x-dev"
},
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-classic-theme-helper/compare/v${old}...v${new}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Main {

const PACKAGE_VERSION = '0.7.4';
const PACKAGE_VERSION = '0.8.0-alpha';

/**
* Modules to include.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
*/
function jetpack_load_custom_post_types() {
include __DIR__ . '/custom-post-types/class-jetpack-portfolio.php';
include __DIR__ . '/custom-post-types/class-jetpack-testimonial.php';
}
add_action( 'init', array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio', 'init' ) );
register_activation_hook( __FILE__, array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio', 'activation_post_type_support' ) );
add_action( 'jetpack_activate_module_custom-content-types', array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio', 'activation_post_type_support' ) );

add_action( 'init', array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial', 'init' ) );
register_activation_hook( __FILE__, array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial', 'activation_post_type_support' ) );
add_action( 'jetpack_activate_module_custom-content-types', array( '\Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Testimonial', 'activation_post_type_support' ) );

}

if ( ! function_exists( 'jetpack_custom_post_types_loaded' ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public static function init() {
*/
public function __construct() {

// Add an option to enable the CPT. Set the priority to 11 to ensure "Portfolio Projects" appears above "Testimonials" in the UI.
add_action( 'admin_init', array( $this, 'settings_api_init' ), 11 );

// Make sure the post types are loaded for imports
add_action( 'import_start', array( $this, 'register_post_types' ) );

Expand All @@ -57,21 +60,27 @@ public function __construct() {
// Add to REST API post type allowed list.
add_filter( 'rest_api_allowed_post_types', array( $this, 'allow_cpt_rest_api_type' ) );

// If testimonial cpt is enabled (on self hosted sites), hook into init to register the CPT, otherwise run maybe_register_cpt immediately to deregister.
if ( get_option( self::OPTION_NAME, '0' ) || ( new Host() )->is_wpcom_platform() ) {
$this->maybe_register_cpt();
$this->maybe_register_cpt();

// Add a variable with the theme support status for the Jetpack Settings Testimonial toggle UI.
if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) {
wp_register_script( 'jetpack-testimonial-theme-supports', '', array(), '0.1.0', true );
wp_enqueue_script( 'jetpack-testimonial-theme-supports' );
$supports_testimonial = ( new Host() )->is_woa_site() ? 'true' : 'false';
} else {
add_action( 'init', array( $this, 'maybe_register_cpt' ) );
$supports_testimonial = 'false';
}
wp_add_inline_script(
'jetpack-testimonial-theme-supports',
'const jetpack_testimonial_theme_supports = ' . $supports_testimonial
);
}

/**
* Registers the custom post types and adds action/filter handlers, but
* only if the site supports it
*/
public function maybe_register_cpt() {
// Add an option to enable the CPT. Set the priority to 11 to ensure "Portfolio Projects" appears above "Testimonials" in the UI.
add_action( 'admin_init', array( $this, 'settings_api_init' ), 11 );

// Check on theme switch if theme supports CPT and setting is disabled
add_action( 'after_switch_theme', array( $this, 'activation_post_type_support' ) );
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"automattic/jetpack-assets": "^4.0.1",
"automattic/jetpack-blocks": "^3.0.1",
"automattic/jetpack-calypsoify": "^0.2.0",
"automattic/jetpack-classic-theme-helper": "^0.7.4",
"automattic/jetpack-classic-theme-helper": "^0.8.0-alpha",
"automattic/jetpack-connection": "^6.2.0",
"automattic/jetpack-masterbar": "^0.10.3-alpha",
"automattic/jetpack-redirect": "^3.0.1",
Expand Down
Loading

0 comments on commit 3d336a1

Please sign in to comment.