Skip to content

Commit

Permalink
Classic Theme Helper: Copy Portfolios Custom Post Type code to Classi…
Browse files Browse the repository at this point in the history
…c Theme Helper package (#39134)
  • Loading branch information
coder-karen authored and gogdzl committed Oct 25, 2024
1 parent 62799d6 commit e059266
Show file tree
Hide file tree
Showing 8 changed files with 1,407 additions and 47 deletions.
7 changes: 5 additions & 2 deletions projects/packages/classic-theme-helper/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
return [
// # Issue statistics:
// PhanTypeMismatchArgumentInternal : 10+ occurrences
// PhanUndeclaredClassMethod : 9 occurrences
// PhanTypePossiblyInvalidDimOffset : 8 occurrences
// PhanUndeclaredClassMethod : 7 occurrences
// PhanUndeclaredClassReference : 4 occurrences
// PhanTypeMismatchArgumentProbablyReal : 3 occurrences
// PhanTypeSuspiciousNonTraversableForeach : 3 occurrences
// PhanTypeInvalidDimOffset : 2 occurrences
// PhanTypeMismatchArgument : 2 occurrences
// PhanTypeComparisonToArray : 1 occurrence
// PhanTypeMismatchArgumentProbablyReal : 1 occurrence
// PhanTypeMismatchProperty : 1 occurrence
// PhanUndeclaredTypeProperty : 1 occurrence

Expand All @@ -26,6 +27,8 @@
'src/class-featured-content.php' => ['PhanTypeComparisonToArray', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset'],
'src/class-social-links.php' => ['PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredTypeProperty'],
'src/content-options/featured-images-fallback.php' => ['PhanTypePossiblyInvalidDimOffset'],
'src/custom-content-types.php' => ['PhanUndeclaredClassMethod'],
'src/custom-post-types/class-jetpack-portfolio.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Classic Theme Helper: Adding Portfolio custom post type content
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Module Name: Custom content types
* Module Description: Display different types of content on your site with custom content types.
* First Introduced: 3.1
* Requires Connection: No
* Auto Activate: No
* Module Tags: Writing
* Sort Order: 34
* Feature: Writing
* Additional Search Queries: cpt, custom post types, portfolio, portfolios, testimonial, testimonials
*
* @package automattic/jetpack-classic-theme-helper
*/

use Automattic\Jetpack\Redirect;

if ( ! function_exists( 'jetpack_load_custom_post_types' ) ) {
/**
* Load Portfolio CPT.
*/
function jetpack_load_custom_post_types() {
include __DIR__ . '/custom-post-types/class-jetpack-portfolio.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' ) );

}

if ( ! function_exists( 'jetpack_custom_post_types_loaded' ) ) {
/**
* Make module configurable.
*/
function jetpack_custom_post_types_loaded() {
if ( class_exists( 'Jetpack' ) ) {
Jetpack::enable_module_configurable( __FILE__ );
}
}
add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' );
}

if ( ! function_exists( 'jetpack_cpt_settings_api_init' ) ) {
/**
* Add Settings Section for CPT
*/
function jetpack_cpt_settings_api_init() {
add_settings_section(
'jetpack_cpt_section',
'<span id="cpt-options">' . __( 'Your Custom Content Types', 'jetpack-classic-theme-helper' ) . '</span>',
'jetpack_cpt_section_callback',
'writing'
);
}
add_action( 'admin_init', 'jetpack_cpt_settings_api_init' );
}

if ( ! function_exists( 'jetpack_cpt_section_callback' ) ) {
/**
* Settings Description
*/
function jetpack_cpt_section_callback() {
if ( class_exists( 'Redirect' ) ) {
?>
<p>
<?php esc_html_e( 'Use these settings to display different types of content on your site.', 'jetpack-classic-theme-helper' ); ?>
<a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url( Redirect::get_url( 'jetpack-support-custom-content-types' ) ); ?>"><?php esc_html_e( 'Learn More', 'jetpack-classic-theme-helper' ); ?></a>
</p>
<?php
}
}
}

if ( function_exists( 'jetpack_load_custom_post_types' ) ) {

jetpack_load_custom_post_types();

}
Loading

0 comments on commit e059266

Please sign in to comment.