| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Module Name: Custom content types | |
| 3 | + * Module Name: Custom Content Types | |
| 4 | 4 | * Module Description: Display different types of content on your site with custom content types. |
| 5 | 5 | * First Introduced: 3.1 |
| 6 | 6 | * Requires Connection: No |
| 7 | 7 | * Auto Activate: No |
| @@ -14,45 +14,113 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | use Automattic\Jetpack\Redirect; |
| 17 | 17 | |
| 18 | -/** | |
| 19 | - * Load Portfolio CPT. | |
| 20 | - */ | |
| 21 | -function jetpack_load_custom_post_types() { | |
| 22 | - include __DIR__ . '/custom-post-types/portfolios.php'; | |
| 18 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 19 | + exit( 0 ); | |
| 23 | 20 | } |
| 24 | 21 | |
| 25 | -/** | |
| 26 | - * Make module configurable. | |
| 27 | - */ | |
| 28 | -function jetpack_custom_post_types_loaded() { | |
| 29 | - Jetpack::enable_module_configurable( __FILE__ ); | |
| 22 | +if ( ! function_exists( 'jetpack_load_custom_post_types' ) ) { | |
| 23 | + if ( class_exists( 'Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio' ) ) { | |
| 24 | + // Temporarily require the file here to prevent possible deprecation notices for a short period of time. | |
| 25 | + // @todo: Can remove this if check after the subsequent release. | |
| 26 | + include __DIR__ . '/custom-post-types/portfolios.php'; | |
| 27 | + } else { | |
| 28 | + /** | |
| 29 | + * Load Portfolio CPT. | |
| 30 | + * | |
| 31 | + * @deprecated 13.9 Moved to Classic Theme Helper package. | |
| 32 | + */ | |
| 33 | + function jetpack_load_custom_post_types() { | |
| 34 | + _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); | |
| 35 | + include __DIR__ . '/custom-post-types/portfolios.php'; | |
| 36 | + } | |
| 37 | + } | |
| 30 | 38 | } |
| 31 | -add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' ); | |
| 32 | 39 | |
| 33 | -/** | |
| 34 | - * Add Settings Section for CPT | |
| 35 | - */ | |
| 36 | -function jetpack_cpt_settings_api_init() { | |
| 37 | - add_settings_section( | |
| 38 | - 'jetpack_cpt_section', | |
| 39 | - '<span id="cpt-options">' . __( 'Your Custom Content Types', 'jetpack' ) . '</span>', | |
| 40 | - 'jetpack_cpt_section_callback', | |
| 41 | - 'writing' | |
| 42 | - ); | |
| 40 | +if ( ! function_exists( 'jetpack_custom_post_types_loaded' ) ) { | |
| 41 | + | |
| 42 | + if ( class_exists( 'Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio' ) ) { | |
| 43 | + // Temporarily require the file here to prevent possible deprecation notices for a short period of time. | |
| 44 | + // @todo: Can remove this if check after the subsequent release. | |
| 45 | + add_action( | |
| 46 | + 'jetpack_modules_loaded', | |
| 47 | + function () { | |
| 48 | + Jetpack::enable_module_configurable( __FILE__ ); | |
| 49 | + } | |
| 50 | + ); | |
| 51 | + } else { | |
| 52 | + /** | |
| 53 | + * Make module configurable. | |
| 54 | + * | |
| 55 | + * @deprecated 13.9 Moved to Classic Theme Helper package. | |
| 56 | + */ | |
| 57 | + function jetpack_custom_post_types_loaded() { | |
| 58 | + _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); | |
| 59 | + Jetpack::enable_module_configurable( __FILE__ ); | |
| 60 | + } | |
| 61 | + add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' ); | |
| 62 | + } | |
| 43 | 63 | } |
| 44 | -add_action( 'admin_init', 'jetpack_cpt_settings_api_init' ); | |
| 45 | 64 | |
| 46 | -/** | |
| 47 | - * Settings Description | |
| 48 | - */ | |
| 49 | -function jetpack_cpt_section_callback() { | |
| 50 | - ?> | |
| 51 | - <p> | |
| 52 | - <?php esc_html_e( 'Use these settings to display different types of content on your site.', 'jetpack' ); ?> | |
| 53 | - <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' ); ?></a> | |
| 54 | - </p> | |
| 55 | - <?php | |
| 65 | +if ( ! function_exists( 'jetpack_cpt_settings_api_init' ) ) { | |
| 66 | + | |
| 67 | + if ( class_exists( 'Automattic\Jetpack\Classic_Theme_Helper\Jetpack_Portfolio' ) ) { | |
| 68 | + // Temporarily require the file here to prevent possible deprecation notices for a short period of time. | |
| 69 | + // @todo: Can remove this if check after the subsequent release. | |
| 70 | + add_action( | |
| 71 | + 'admin_init', | |
| 72 | + function () { | |
| 73 | + add_settings_section( | |
| 74 | + 'jetpack_cpt_section', | |
| 75 | + '<span id="cpt-options">' . __( 'Your Custom Content Types', 'jetpack' ) . '</span>', | |
| 76 | + function () { | |
| 77 | + ?> | |
| 78 | + <p> | |
| 79 | + <?php esc_html_e( 'Use these settings to display different types of content on your site.', 'jetpack' ); ?> | |
| 80 | + <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' ); ?></a> | |
| 81 | + </p> | |
| 82 | + <?php | |
| 83 | + }, | |
| 84 | + 'writing' | |
| 85 | + ); | |
| 86 | + } | |
| 87 | + ); | |
| 88 | + } else { | |
| 89 | + /** | |
| 90 | + * Add Settings Section for CPT | |
| 91 | + * | |
| 92 | + * @deprecated 13.9 Moved to Classic Theme Helper package. | |
| 93 | + */ | |
| 94 | + function jetpack_cpt_settings_api_init() { | |
| 95 | + _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); | |
| 96 | + add_settings_section( | |
| 97 | + 'jetpack_cpt_section', | |
| 98 | + '<span id="cpt-options">' . __( 'Your Custom Content Types', 'jetpack' ) . '</span>', | |
| 99 | + 'jetpack_cpt_section_callback', | |
| 100 | + 'writing' | |
| 101 | + ); | |
| 102 | + } | |
| 103 | + add_action( 'admin_init', 'jetpack_cpt_settings_api_init' ); | |
| 104 | + } | |
| 56 | 105 | } |
| 57 | 106 | |
| 58 | -jetpack_load_custom_post_types(); | |
| 107 | +if ( ! function_exists( 'jetpack_cpt_section_callback' ) ) { | |
| 108 | + /** | |
| 109 | + * Settings Description | |
| 110 | + * | |
| 111 | + * @deprecated 13.9 Moved to Classic Theme Helper package. | |
| 112 | + */ | |
| 113 | + function jetpack_cpt_section_callback() { | |
| 114 | + _deprecated_function( __FUNCTION__, 'jetpack-13.9' ); | |
| 115 | + ?> | |
| 116 | + <p> | |
| 117 | + <?php esc_html_e( 'Use these settings to display different types of content on your site.', 'jetpack' ); ?> | |
| 118 | + <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' ); ?></a> | |
| 119 | + </p> | |
| 120 | + <?php | |
| 121 | + } | |
| 122 | +} | |
| 123 | + | |
| 124 | +if ( function_exists( 'jetpack_load_custom_post_types' ) ) { | |
| 125 | + jetpack_load_custom_post_types(); | |
| 126 | +} | |