diff --git a/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package b/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package new file mode 100644 index 0000000000000..58e968282a271 --- /dev/null +++ b/projects/packages/classic-theme-helper/changelog/add-require-content-options-in-classic-theme-helper-package @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Content Options: Ensuring feature is now required. diff --git a/projects/packages/classic-theme-helper/src/class-main.php b/projects/packages/classic-theme-helper/src/class-main.php index 8b230e3d2a7c6..27dce7a41d518 100644 --- a/projects/packages/classic-theme-helper/src/class-main.php +++ b/projects/packages/classic-theme-helper/src/class-main.php @@ -26,6 +26,7 @@ class Main { 'site-breadcrumbs.php', 'social-menu.php', 'jetpack-color.php', + 'content-options.php', ); /** Holds the singleton instance of the Loader diff --git a/projects/packages/classic-theme-helper/src/content-options/customizer.js b/projects/packages/classic-theme-helper/src/content-options/customizer.js index e853604242cdd..5170db0277d57 100644 --- a/projects/packages/classic-theme-helper/src/content-options/customizer.js +++ b/projects/packages/classic-theme-helper/src/content-options/customizer.js @@ -1,4 +1,4 @@ -/* global blogDisplay, postDetails */ +/* global blogDisplay, postDetails, wp */ /** * customizer.js @@ -6,213 +6,143 @@ * Theme Customizer enhancements for a better user experience. * * Contains handlers to make Theme Customizer preview reload changes asynchronously. - * @param $ */ -jQuery( function ( $, wp ) { - // Blog Display - wp.customize( 'jetpack_content_blog_display', function ( value ) { - if ( 'content' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { +/** + * Function to apply styles to elements based on the display type + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {object} styles - Styles to be applied to selectors. + */ +function applyStyles( selectors, styles ) { + document.querySelectorAll( selectors ).forEach( el => { + for ( const [ key, value ] of Object.entries( styles ) ) { + el.style[ key ] = value; + } + } ); +} + +// Blog Display +wp.customize( 'jetpack_content_blog_display', function ( value ) { + /** + * Updates the blog display based on the selected option. + * @param {string} to - Content display option. + */ + function updateBlogDisplay( to ) { + const contentSelectors = '.jetpack-blog-display.jetpack-the-content'; + const excerptSelectors = '.jetpack-blog-display.jetpack-the-excerpt'; + const featuredContentSelectors = '.featured-content .jetpack-blog-display'; + + if ( to === 'content' ) { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'auto', position: 'relative', } ); - } else if ( 'mixed' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } else if ( to === 'excerpt' ) { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'auto', position: 'relative', } ); - } - value.bind( function ( to ) { - if ( 'content' === to ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === to ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'mixed' === to ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { + } else if ( to === 'mixed' ) { + applyStyles( + `${ contentSelectors }.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-content`, + { clip: 'auto', position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-content, ${ contentSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-excerpt`, + { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-excerpt`, + { clip: 'auto', position: 'relative', - } ); - } - if ( blogDisplay.masonry ) { - $( blogDisplay.masonry ).masonry(); + } + ); + } + + if ( blogDisplay.masonry ) { + const masonryElement = document.querySelector( blogDisplay.masonry ); + if ( masonryElement ) { + masonryElement.masonry(); } - } ); + } + } + + updateBlogDisplay( blogDisplay.display ); + value.bind( updateBlogDisplay ); +} ); + +/** + * Function to update post details visibility + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {string} to - Content display option. + * @param {string} hiddenClass - Class to be added to the body when the post details are hidden. + */ +function updatePostDetails( selectors, to, hiddenClass ) { + document.querySelectorAll( selectors ).forEach( element => { + if ( to === false ) { + element.style.clip = 'rect(1px, 1px, 1px, 1px)'; + element.style.height = '1px'; + element.style.overflow = 'hidden'; + element.style.position = 'absolute'; + element.style.width = '1px'; + document.body.classList.add( hiddenClass ); + } else { + element.style.clip = 'auto'; + element.style.height = 'auto'; + element.style.overflow = 'auto'; + element.style.position = 'relative'; + element.style.width = 'auto'; + document.body.classList.remove( hiddenClass ); + } } ); +} - // Post Details: Date. - wp.customize( 'jetpack_content_post_details_date', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.date ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'date-hidden' ); - } else { - $( postDetails.date ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'date-hidden' ); - } - } ); +// Post Details: Date +wp.customize( 'jetpack_content_post_details_date', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.date, to, 'date-hidden' ); } ); +} ); - // Post Details: Categories. - wp.customize( 'jetpack_content_post_details_categories', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.categories ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'categories-hidden' ); - } else { - $( postDetails.categories ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'categories-hidden' ); - } - } ); +// Post Details: Categories +wp.customize( 'jetpack_content_post_details_categories', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.categories, to, 'categories-hidden' ); } ); +} ); - // Post Details: Tags. - wp.customize( 'jetpack_content_post_details_tags', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.tags ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'tags-hidden' ); - } else { - $( postDetails.tags ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'tags-hidden' ); - } - } ); +// Post Details: Tags +wp.customize( 'jetpack_content_post_details_tags', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.tags, to, 'tags-hidden' ); } ); +} ); - // Post Details: Author. - wp.customize( 'jetpack_content_post_details_author', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.author ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'author-hidden' ); - } else { - $( postDetails.author ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'author-hidden' ); - } - } ); +// Post Details: Author +wp.customize( 'jetpack_content_post_details_author', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.author, to, 'author-hidden' ); } ); +} ); - // Post Details: Comment link. - wp.customize( 'jetpack_content_post_details_comment', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.comment ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'comment-hidden' ); - } else { - $( postDetails.comment ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'comment-hidden' ); - } - } ); +// Post Details: Comment link +wp.customize( 'jetpack_content_post_details_comment', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.comment, to, 'comment-hidden' ); } ); -} )( jQuery ); +} ); diff --git a/projects/packages/classic-theme-helper/src/content-options/customizer.php b/projects/packages/classic-theme-helper/src/content-options/customizer.php index 7cbe45cac7a59..b5305c97d0baa 100644 --- a/projects/packages/classic-theme-helper/src/content-options/customizer.php +++ b/projects/packages/classic-theme-helper/src/content-options/customizer.php @@ -5,6 +5,8 @@ * @package automattic/jetpack-classic-theme-helper */ +use Automattic\Jetpack\Assets; + if ( ! function_exists( 'jetpack_content_options_customize_register' ) ) { /** @@ -493,7 +495,18 @@ function jetpack_content_options_customize_preview_js() { $author = ( ! empty( $post_details['author'] ) ) ? $post_details['author'] : null; $comment = ( ! empty( $post_details['comment'] ) ) ? $post_details['comment'] : null; - wp_enqueue_script( 'jetpack-content-options-customizer', plugins_url( 'customizer.js', __FILE__ ), array( 'jquery', 'customize-preview' ), '1.0', true ); + Assets::register_script( + 'jetpack-content-options-customizer', + '../../dist/content-options/customizer.js', + __FILE__, + array( + 'dependencies' => array( + 'customize-preview', + ), + 'in_footer' => true, + 'enqueue' => true, + ) + ); wp_localize_script( 'jetpack-content-options-customizer', diff --git a/projects/packages/classic-theme-helper/src/content-options/post-details.php b/projects/packages/classic-theme-helper/src/content-options/post-details.php index 3e4fbc3f9f526..dc21f60d3b6bb 100644 --- a/projects/packages/classic-theme-helper/src/content-options/post-details.php +++ b/projects/packages/classic-theme-helper/src/content-options/post-details.php @@ -60,8 +60,10 @@ function jetpack_post_details_enqueue_scripts() { $css = $elements . ' { clip: rect(1px, 1px, 1px, 1px); height: 1px; position: absolute; overflow: hidden; width: 1px; }'; // Add the CSS to the stylesheet. - // @phan-suppress-next-line PhanTypeArraySuspiciousNullable. - wp_add_inline_style( $post_details['stylesheet'], $css ); + + if ( is_array( $post_details ) && isset( $post_details['stylesheet'] ) ) { + wp_add_inline_style( $post_details['stylesheet'], $css ); + } } add_action( 'wp_enqueue_scripts', 'jetpack_post_details_enqueue_scripts' ); diff --git a/projects/plugins/jetpack/changelog/add-require-content-options-in-classic-theme-helper-package b/projects/plugins/jetpack/changelog/add-require-content-options-in-classic-theme-helper-package new file mode 100644 index 0000000000000..7a43d9887fd8e --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-require-content-options-in-classic-theme-helper-package @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Content Options: Ensure the feature is loaded via the Classic Theme Helper package instead of Jetpack module. diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options.php b/projects/plugins/jetpack/modules/theme-tools/content-options.php index 14ae4b03957da..ffe312f0645d8 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options.php @@ -6,165 +6,179 @@ * @package automattic/jetpack */ -/** - * Content Options. - * - * This feature will only be activated for themes that declare their support. - * This can be done by adding code similar to the following during the - * 'after_setup_theme' action: - * - add_theme_support( 'jetpack-content-options', array( - 'blog-display' => 'content', // the default setting of the theme: 'content', 'excerpt' or array( 'content', 'excerpt' ) for themes mixing both display. - 'author-bio' => true, // display or not the author bio: true or false. - 'author-bio-default' => false, // the default setting of the author bio, if it's being displayed or not: true or false (only required if false). - 'avatar-default' => true, // display or not the default avatar for the author bio: true or false. - 'masonry' => '.site-main', // a CSS selector matching the elements that triggers a masonry refresh if the theme is using a masonry layout. - 'post-details' => array( - 'stylesheet' => 'themeslug-style', // name of the theme's stylesheet. - 'date' => '.posted-on', // a CSS selector matching the elements that display the post date. - 'categories' => '.cat-links', // a CSS selector matching the elements that display the post categories. - 'tags' => '.tags-links', // a CSS selector matching the elements that display the post tags. - 'author' => '.byline', // a CSS selector matching the elements that display the post author. - 'comment' => '.comments-link', // a CSS selector matching the elements that display the comment link. - ), - 'featured-images' => array( - 'archive' => true, // enable or not the featured image check for archive pages: true or false. - 'archive-default' => false, // the default setting of the featured image on archive pages, if it's being displayed or not: true or false (only required if false). - 'post' => true, // enable or not the featured image check for single posts: true or false. - 'post-default' => false, // the default setting of the featured image on single posts, if it's being displayed or not: true or false (only required if false). - 'page' => true, // enable or not the featured image check for single pages: true or false. - 'page-default' => false, // the default setting of the featured image on single pages, if it's being displayed or not: true or false (only required if false). - 'portfolio' => true, // enable or not the featured image check for single projects: true or false. - 'portfolio-default' => false, // the default setting of the featured image on single projects, if it's being displayed or not: true or false (only required if false). - 'fallback' => true, // enable or not the featured image fallback: true or false. - 'fallback-default' => true, // the default setting for featured image fallbacks: true or false (only required if false) - ), - ) ); - */ - -if ( ! function_exists( 'jetpack_content_options_init' ) ) { +if ( ! class_exists( '\Automattic\Jetpack\Classic_Theme_Helper\Main' ) ) { /** - * Activate the Content Options plugin. + * Content Options. + * + * This feature will only be activated for themes that declare their support. + * This can be done by adding code similar to the following during the + * 'after_setup_theme' action: * - * @uses current_theme_supports() + add_theme_support( 'jetpack-content-options', array( + 'blog-display' => 'content', // the default setting of the theme: 'content', 'excerpt' or array( 'content', 'excerpt' ) for themes mixing both display. + 'author-bio' => true, // display or not the author bio: true or false. + 'author-bio-default' => false, // the default setting of the author bio, if it's being displayed or not: true or false (only required if false). + 'avatar-default' => true, // display or not the default avatar for the author bio: true or false. + 'masonry' => '.site-main', // a CSS selector matching the elements that triggers a masonry refresh if the theme is using a masonry layout. + 'post-details' => array( + 'stylesheet' => 'themeslug-style', // name of the theme's stylesheet. + 'date' => '.posted-on', // a CSS selector matching the elements that display the post date. + 'categories' => '.cat-links', // a CSS selector matching the elements that display the post categories. + 'tags' => '.tags-links', // a CSS selector matching the elements that display the post tags. + 'author' => '.byline', // a CSS selector matching the elements that display the post author. + 'comment' => '.comments-link', // a CSS selector matching the elements that display the comment link. + ), + 'featured-images' => array( + 'archive' => true, // enable or not the featured image check for archive pages: true or false. + 'archive-default' => false, // the default setting of the featured image on archive pages, if it's being displayed or not: true or false (only required if false). + 'post' => true, // enable or not the featured image check for single posts: true or false. + 'post-default' => false, // the default setting of the featured image on single posts, if it's being displayed or not: true or false (only required if false). + 'page' => true, // enable or not the featured image check for single pages: true or false. + 'page-default' => false, // the default setting of the featured image on single pages, if it's being displayed or not: true or false (only required if false). + 'portfolio' => true, // enable or not the featured image check for single projects: true or false. + 'portfolio-default' => false, // the default setting of the featured image on single projects, if it's being displayed or not: true or false (only required if false). + 'fallback' => true, // enable or not the featured image fallback: true or false. + 'fallback-default' => true, // the default setting for featured image fallbacks: true or false (only required if false) + ), + ) ); */ - function jetpack_content_options_init() { - // If the theme doesn't support 'jetpack-content-options', don't continue. - if ( ! current_theme_supports( 'jetpack-content-options' ) ) { - return; - } - // Load the Customizer options. - require __DIR__ . '/content-options/customizer.php'; - - // Load Blog Display function. - require __DIR__ . '/content-options/blog-display.php'; - - // Load Author Bio function. - require __DIR__ . '/content-options/author-bio.php'; - - // Load Post Details function. - require __DIR__ . '/content-options/post-details.php'; - - // Load Featured Images function. - if ( jetpack_featured_images_should_load() ) { - require __DIR__ . '/content-options/featured-images.php'; + if ( ! function_exists( 'jetpack_content_options_init' ) ) { + + /** + * Activate the Content Options plugin. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + * @uses current_theme_supports() + */ + function jetpack_content_options_init() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); + // If the theme doesn't support 'jetpack-content-options', don't continue. + if ( ! current_theme_supports( 'jetpack-content-options' ) ) { + return; + } + + // Load the Customizer options. + require __DIR__ . '/content-options/customizer.php'; + + // Load Blog Display function. + require __DIR__ . '/content-options/blog-display.php'; + + // Load Author Bio function. + require __DIR__ . '/content-options/author-bio.php'; + + // Load Post Details function. + require __DIR__ . '/content-options/post-details.php'; + + // Load Featured Images function. + if ( jetpack_featured_images_should_load() ) { + require __DIR__ . '/content-options/featured-images.php'; + } + + // Load Featured Images Fallback function. + if ( jetpack_featured_images_fallback_should_load() ) { + require __DIR__ . '/content-options/featured-images-fallback.php'; + } } + add_action( 'init', 'jetpack_content_options_init' ); - // Load Featured Images Fallback function. - if ( jetpack_featured_images_fallback_should_load() ) { - require __DIR__ . '/content-options/featured-images-fallback.php'; - } } - add_action( 'init', 'jetpack_content_options_init' ); - -} -if ( ! function_exists( 'jetpack_featured_images_get_settings' ) ) { + if ( ! function_exists( 'jetpack_featured_images_get_settings' ) ) { + + /** + * Get featured images settings using the jetpack-content-options theme support. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + */ + function jetpack_featured_images_get_settings() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); + $options = get_theme_support( 'jetpack-content-options' ); + + $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null; + + $settings = array( + 'archive' => ( ! empty( $featured_images['archive'] ) ) ? $featured_images['archive'] : null, + 'post' => ( ! empty( $featured_images['post'] ) ) ? $featured_images['post'] : null, + 'page' => ( ! empty( $featured_images['page'] ) ) ? $featured_images['page'] : null, + 'portfolio' => ( ! empty( $featured_images['portfolio'] ) ) ? $featured_images['portfolio'] : null, + 'archive-default' => ( isset( $featured_images['archive-default'] ) && false === $featured_images['archive-default'] ) ? '' : 1, + 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1, + 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1, + 'portfolio-default' => ( isset( $featured_images['portfolio-default'] ) && false === $featured_images['portfolio-default'] ) ? '' : 1, + 'fallback' => ( ! empty( $featured_images['fallback'] ) ) ? $featured_images['fallback'] : null, + 'fallback-default' => ( isset( $featured_images['fallback-default'] ) && false === $featured_images['fallback-default'] ) ? '' : 1, + ); + + $settings = array_merge( + $settings, + array( + 'archive-option' => get_option( 'jetpack_content_featured_images_archive', $settings['archive-default'] ), + 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ), + 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ), + 'portfolio-option' => get_option( 'jetpack_content_featured_images_portfolio', $settings['portfolio-default'] ), + 'fallback-option' => get_option( 'jetpack_content_featured_images_fallback', $settings['fallback-default'] ), + ) + ); + + return $settings; + } - /** - * Get featured images settings using the jetpack-content-options theme support. - */ - function jetpack_featured_images_get_settings() { - $options = get_theme_support( 'jetpack-content-options' ); - - $featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null; - - $settings = array( - 'archive' => ( ! empty( $featured_images['archive'] ) ) ? $featured_images['archive'] : null, - 'post' => ( ! empty( $featured_images['post'] ) ) ? $featured_images['post'] : null, - 'page' => ( ! empty( $featured_images['page'] ) ) ? $featured_images['page'] : null, - 'portfolio' => ( ! empty( $featured_images['portfolio'] ) ) ? $featured_images['portfolio'] : null, - 'archive-default' => ( isset( $featured_images['archive-default'] ) && false === $featured_images['archive-default'] ) ? '' : 1, - 'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1, - 'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1, - 'portfolio-default' => ( isset( $featured_images['portfolio-default'] ) && false === $featured_images['portfolio-default'] ) ? '' : 1, - 'fallback' => ( ! empty( $featured_images['fallback'] ) ) ? $featured_images['fallback'] : null, - 'fallback-default' => ( isset( $featured_images['fallback-default'] ) && false === $featured_images['fallback-default'] ) ? '' : 1, - ); - - $settings = array_merge( - $settings, - array( - 'archive-option' => get_option( 'jetpack_content_featured_images_archive', $settings['archive-default'] ), - 'post-option' => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ), - 'page-option' => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ), - 'portfolio-option' => get_option( 'jetpack_content_featured_images_portfolio', $settings['portfolio-default'] ), - 'fallback-option' => get_option( 'jetpack_content_featured_images_fallback', $settings['fallback-default'] ), - ) - ); - - return $settings; } -} + if ( ! function_exists( 'jetpack_featured_images_should_load' ) ) { -if ( ! function_exists( 'jetpack_featured_images_should_load' ) ) { - - /** - * Determine if the Jetpack Featured Images should be load. - */ - function jetpack_featured_images_should_load() { - // If the theme doesn't support post thumbnails, don't continue. - if ( ! current_theme_supports( 'post-thumbnails' ) ) { - return false; - } + /** + * Determine if the Jetpack Featured Images should be load. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + */ + function jetpack_featured_images_should_load() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); + // If the theme doesn't support post thumbnails, don't continue. + if ( ! current_theme_supports( 'post-thumbnails' ) ) { + return false; + } - $opts = jetpack_featured_images_get_settings(); + $opts = jetpack_featured_images_get_settings(); - // If the theme doesn't support archive, post and page or if all the options are ticked and we aren't in the customizer, don't continue. - if ( + // If the theme doesn't support archive, post and page or if all the options are ticked and we aren't in the customizer, don't continue. + if ( ( true !== $opts['archive'] && true !== $opts['post'] && true !== $opts['page'] ) || ( 1 === $opts['archive-option'] && 1 === $opts['post-option'] && 1 === $opts['page-option'] && ! is_customize_preview() ) - ) { - return false; + ) { + return false; + } + + return true; } - return true; } -} + if ( ! function_exists( 'jetpack_featured_images_fallback_should_load' ) ) { -if ( ! function_exists( 'jetpack_featured_images_fallback_should_load' ) ) { + /** + * Determine if the Jetpack Featured Images fallback should load. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + */ + function jetpack_featured_images_fallback_should_load() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); + // If the theme doesn't support post thumbnails, don't continue. + if ( ! current_theme_supports( 'post-thumbnails' ) ) { + return false; + } - /** - * Determine if the Jetpack Featured Images fallback should load. - */ - function jetpack_featured_images_fallback_should_load() { - // If the theme doesn't support post thumbnails, don't continue. - if ( ! current_theme_supports( 'post-thumbnails' ) ) { - return false; - } + $opts = jetpack_featured_images_get_settings(); - $opts = jetpack_featured_images_get_settings(); + // If the theme doesn't support fallback, don't continue. + if ( true !== $opts['fallback'] ) { + return false; + } - // If the theme doesn't support fallback, don't continue. - if ( true !== $opts['fallback'] ) { - return false; + return true; } - return true; } - } diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/author-bio.php b/projects/plugins/jetpack/modules/theme-tools/content-options/author-bio.php index 2aab1a70181aa..e146e05afe51e 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/author-bio.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/author-bio.php @@ -9,8 +9,11 @@ /** * The function to display Author Bio in a theme. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_author_bio() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); // If the theme doesn't support 'jetpack-content-options', don't continue. if ( ! current_theme_supports( 'jetpack-content-options' ) ) { return; @@ -92,11 +95,12 @@ function jetpack_author_bio() { /** * Checks to see if the specified email address has a Gravatar image. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $email The email of the address of the user to check. * @return bool Whether or not the user has a gravatar */ function jetpack_has_gravatar( $email ) { - + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $url = get_avatar_url( $email, array( 'default' => '404' ) ); $headers = get_headers( $url ); diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/blog-display.php b/projects/plugins/jetpack/modules/theme-tools/content-options/blog-display.php index 4a33aff67dfde..3e87f5816cad2 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/blog-display.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/blog-display.php @@ -35,11 +35,13 @@ /** * Apply Content filters. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @since 9.7.0 Deprecated $content parameter. * * @param string $content Post content. Deprecated. */ function jetpack_blog_display_custom_excerpt( $content = '' ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ! empty( $content ) ) { _doing_it_wrong( 'jetpack_blog_display_custom_excerpt', @@ -97,9 +99,12 @@ function jetpack_blog_display_custom_excerpt( $content = '' ) { /** * Display Excerpt instead of Content. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + * * @param string $content Post content. */ function jetpack_the_content_to_the_excerpt( $content ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) { if ( post_password_required() ) { $excerpt = sprintf( '
%s
', esc_html__( 'There is no excerpt because this is a protected post.', 'jetpack' ) ); @@ -121,9 +126,12 @@ function jetpack_the_content_to_the_excerpt( $content ) { /** * Display Content instead of Excerpt. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + * * @param string $content The post excerpt. */ function jetpack_the_excerpt_to_the_content( $content ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) { ob_start(); the_content( @@ -152,9 +160,11 @@ function jetpack_the_excerpt_to_the_content( $content ) { /** * Display both Content and Excerpt instead of Content in the Customizer so live preview can switch between them. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $content The post content. */ function jetpack_the_content_customizer( $content ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $class = jetpack_the_content_customizer_class(); if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) { if ( post_password_required() ) { @@ -177,9 +187,11 @@ function jetpack_the_content_customizer( $content ) { /** * Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $excerpt The post excerpt. */ function jetpack_the_excerpt_customizer( $excerpt ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) { ob_start(); the_content( @@ -212,9 +224,11 @@ function jetpack_the_excerpt_customizer( $excerpt ) { /** * Display Content instead of Excerpt in the Customizer when theme uses a 'Mixed' display. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $content The post excerpt. */ function jetpack_the_excerpt_mixed_customizer( $content ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ( is_home() || is_archive() ) && ! is_post_type_archive( array( 'jetpack-testimonial', 'jetpack-portfolio', 'product' ) ) ) { jetpack_the_content_customizer_class( 'output-the-excerpt' ); ob_start(); @@ -232,9 +246,11 @@ function jetpack_the_excerpt_mixed_customizer( $content ) { * Returns a class value, `output-the-content` by default. * Used for themes with a 'Mixed' Blog Display so we can tell which output is by default. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string|null $new_class CSS class added to content container. */ function jetpack_the_content_customizer_class( $new_class = null ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); static $class; if ( isset( $new_class ) ) { // Assign a new class and return. diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.js b/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.js index 5e383bc3ce327..6860ee0c21afb 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.js +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.js @@ -8,210 +8,141 @@ * Contains handlers to make Theme Customizer preview reload changes asynchronously. */ -( function ( $ ) { - // Blog Display - wp.customize( 'jetpack_content_blog_display', function ( value ) { - if ( 'content' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { +/** + * Function to apply styles to elements based on the display type + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {object} styles - Styles to be applied to selectors. + */ +function applyStyles( selectors, styles ) { + document.querySelectorAll( selectors ).forEach( el => { + for ( const [ key, value ] of Object.entries( styles ) ) { + el.style[ key ] = value; + } + } ); +} + +// Blog Display +wp.customize( 'jetpack_content_blog_display', function ( value ) { + /** + * Updates the blog display based on the selected option. + * @param {string} to - Content display option. + */ + function updateBlogDisplay( to ) { + const contentSelectors = '.jetpack-blog-display.jetpack-the-content'; + const excerptSelectors = '.jetpack-blog-display.jetpack-the-excerpt'; + const featuredContentSelectors = '.featured-content .jetpack-blog-display'; + + if ( to === 'content' ) { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'auto', position: 'relative', } ); - } else if ( 'mixed' === blogDisplay.display ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } else if ( to === 'excerpt' ) { + applyStyles( `${ contentSelectors }, ${ featuredContentSelectors }.jetpack-the-content`, { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + applyStyles( `${ excerptSelectors }, ${ featuredContentSelectors }.jetpack-the-excerpt`, { clip: 'auto', position: 'relative', } ); - } - value.bind( function ( to ) { - if ( 'content' === to ) { - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'excerpt' === to ) { - $( '.jetpack-blog-display.jetpack-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( { - clip: 'auto', - position: 'relative', - } ); - } else if ( 'mixed' === to ) { - $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( { + } else if ( to === 'mixed' ) { + applyStyles( + `${ contentSelectors }.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-content`, + { clip: 'auto', position: 'relative', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-content, ${ contentSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-content, ${ featuredContentSelectors }.jetpack-the-content.output-the-excerpt`, + { clip: 'rect(1px, 1px, 1px, 1px)', position: 'absolute', - } ); - $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( { + } + ); + applyStyles( + `${ excerptSelectors }.output-the-excerpt, ${ featuredContentSelectors }.jetpack-the-excerpt.output-the-excerpt`, + { clip: 'auto', position: 'relative', - } ); - } - if ( blogDisplay.masonry ) { - $( blogDisplay.masonry ).masonry(); + } + ); + } + + if ( blogDisplay.masonry ) { + const masonryElement = document.querySelector( blogDisplay.masonry ); + if ( masonryElement ) { + masonryElement.masonry(); } - } ); + } + } + + updateBlogDisplay( blogDisplay.display ); + value.bind( updateBlogDisplay ); +} ); + +/** + * Function to update post details visibility + * @param {object} selectors - HTML selectors which styles will apply to. + * @param {string} to - Content display option. + * @param {string} hiddenClass - Class to be added to the body when the post details are hidden. + */ +function updatePostDetails( selectors, to, hiddenClass ) { + document.querySelectorAll( selectors ).forEach( element => { + if ( to === false ) { + element.style.clip = 'rect(1px, 1px, 1px, 1px)'; + element.style.height = '1px'; + element.style.overflow = 'hidden'; + element.style.position = 'absolute'; + element.style.width = '1px'; + document.body.classList.add( hiddenClass ); + } else { + element.style.clip = 'auto'; + element.style.height = 'auto'; + element.style.overflow = 'auto'; + element.style.position = 'relative'; + element.style.width = 'auto'; + document.body.classList.remove( hiddenClass ); + } } ); +} - // Post Details: Date. - wp.customize( 'jetpack_content_post_details_date', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.date ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'date-hidden' ); - } else { - $( postDetails.date ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'date-hidden' ); - } - } ); +// Post Details: Date +wp.customize( 'jetpack_content_post_details_date', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.date, to, 'date-hidden' ); } ); +} ); - // Post Details: Categories. - wp.customize( 'jetpack_content_post_details_categories', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.categories ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'categories-hidden' ); - } else { - $( postDetails.categories ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'categories-hidden' ); - } - } ); +// Post Details: Categories +wp.customize( 'jetpack_content_post_details_categories', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.categories, to, 'categories-hidden' ); } ); +} ); - // Post Details: Tags. - wp.customize( 'jetpack_content_post_details_tags', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.tags ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'tags-hidden' ); - } else { - $( postDetails.tags ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'tags-hidden' ); - } - } ); +// Post Details: Tags +wp.customize( 'jetpack_content_post_details_tags', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.tags, to, 'tags-hidden' ); } ); +} ); - // Post Details: Author. - wp.customize( 'jetpack_content_post_details_author', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.author ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'author-hidden' ); - } else { - $( postDetails.author ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'author-hidden' ); - } - } ); +// Post Details: Author +wp.customize( 'jetpack_content_post_details_author', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.author, to, 'author-hidden' ); } ); +} ); - // Post Details: Comment link. - wp.customize( 'jetpack_content_post_details_comment', function ( value ) { - value.bind( function ( to ) { - if ( false === to ) { - $( postDetails.comment ).css( { - clip: 'rect(1px, 1px, 1px, 1px)', - height: '1px', - overflow: 'hidden', - position: 'absolute', - width: '1px', - } ); - $( 'body' ).addClass( 'comment-hidden' ); - } else { - $( postDetails.comment ).css( { - clip: 'auto', - height: 'auto', - overflow: 'auto', - position: 'relative', - width: 'auto', - } ); - $( 'body' ).removeClass( 'comment-hidden' ); - } - } ); +// Post Details: Comment link +wp.customize( 'jetpack_content_post_details_comment', function ( value ) { + value.bind( function ( to ) { + updatePostDetails( postDetails.comment, to, 'comment-hidden' ); } ); -} )( jQuery ); +} ); diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.php b/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.php index df416e518c7ec..3e278e9f426a4 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/customizer.php @@ -10,9 +10,12 @@ /** * Add Content section to the Theme Customizer. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. + * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ function jetpack_content_options_customize_register( $wp_customize ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $options = get_theme_support( 'jetpack-content-options' ); $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null; $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display ); @@ -436,8 +439,11 @@ public function render_content() { // phpcs:ignore MediaWiki.Usage.NestedFunctio /** * Return whether the theme supports Post Thumbnails. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_post_thumbnail_supports() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); return ( current_theme_supports( 'post-thumbnails' ) ); } @@ -448,10 +454,12 @@ function jetpack_post_thumbnail_supports() { /** * Sanitize the checkbox. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param int $input The unsanitized value from the setting. * @return boolean|string */ function jetpack_content_options_sanitize_checkbox( $input ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); return ( 1 === (int) $input ) ? 1 : ''; } @@ -462,10 +470,12 @@ function jetpack_content_options_sanitize_checkbox( $input ) { /** * Sanitize the Display value. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $display The unsanitized value from the setting. * @return string */ function jetpack_content_options_sanitize_blog_display( $display ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); if ( ! in_array( $display, array( 'content', 'excerpt', 'mixed' ), true ) ) { $display = 'content'; } @@ -478,8 +488,11 @@ function jetpack_content_options_sanitize_blog_display( $display ) { /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_content_options_customize_preview_js() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $options = get_theme_support( 'jetpack-content-options' ); $blog_display = ( ! empty( $options[0]['blog-display'] ) ) ? $options[0]['blog-display'] : null; $blog_display = preg_grep( '/^(content|excerpt)$/', (array) $blog_display ); diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php b/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php index 350862899186d..39bcf238ee14d 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images-fallback.php @@ -12,6 +12,7 @@ * Featured Image then first image from the_content HTML * and filter the post_thumbnail_html * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param string $html The HTML for the image markup. * @param int $post_id The post ID to check. * @param int $post_thumbnail_id The ID of the featured image. @@ -21,6 +22,7 @@ * @return string $html Thumbnail image with markup. */ function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $opts = jetpack_featured_images_get_settings(); if ( ! empty( $html ) || (bool) 1 !== (bool) $opts['fallback-option'] ) { @@ -141,6 +143,7 @@ function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thum * Get URL of one image from a specified post in the following order: * Featured Image then first image from the_content HTML * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param int $post_id The post ID to check. * @param int $post_thumbnail_id The ID of the featured image. * @param string $size The image size to return, defaults to 'post-thumbnail'. @@ -148,6 +151,7 @@ function jetpack_featured_images_fallback_get_image( $html, $post_id, $post_thum * @return string|null $image_src The URL of the thumbnail image. */ function jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbnail_id, $size ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $image_src = wp_get_attachment_image_src( $post_thumbnail_id, $size ); $image_src = ( ! empty( $image_src[0] ) ) ? $image_src[0] : null; $opts = jetpack_featured_images_get_settings(); @@ -205,11 +209,13 @@ function jetpack_featured_images_fallback_get_image_src( $post_id, $post_thumbna /** * Check if post has an image attached, including a fallback. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param int $post The post ID to check. * * @return bool */ function jetpack_has_featured_image( $post = null ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); return (bool) get_the_post_thumbnail( $post ); } @@ -220,6 +226,7 @@ function jetpack_has_featured_image( $post = null ) { /** * Adds custom class to the array of post classes. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param array $classes Classes for the post element. * @param array $class Optional. Comma separated list of additional classes. * @param array $post_id Unique The post ID to check. @@ -227,6 +234,7 @@ function jetpack_has_featured_image( $post = null ) { * @return array $classes */ function jetpack_featured_images_post_class( $classes, $class, $post_id ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $post_password_required = post_password_required( $post_id ); $opts = jetpack_featured_images_get_settings(); diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images.php b/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images.php index 95af5926aedef..e01457588edcc 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/featured-images.php @@ -10,11 +10,13 @@ /** * The function to prevent for Featured Images to be displayed in a theme. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param array $metadata Post metadata. * @param int $object_id Post ID. * @param string $meta_key Metadata key. */ function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $meta_key ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); $opts = jetpack_featured_images_get_settings(); /** @@ -93,8 +95,11 @@ function jetpack_featured_images_remove_post_thumbnail( $metadata, $object_id, $ /** * Check if we are in a WooCommerce Product in order to exclude it from the is_single check. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_is_product() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); return ( function_exists( 'is_product' ) ) ? is_product() : false; } @@ -104,8 +109,11 @@ function jetpack_is_product() { /** * Check if we are in a WooCommerce Shop in order to exclude it from the is_archive check. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_is_shop_page() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); // Check if WooCommerce is active first. if ( ! class_exists( 'WooCommerce' ) ) { return false; diff --git a/projects/plugins/jetpack/modules/theme-tools/content-options/post-details.php b/projects/plugins/jetpack/modules/theme-tools/content-options/post-details.php index 73919ab6f7d7f..ab8cfa481fa3a 100644 --- a/projects/plugins/jetpack/modules/theme-tools/content-options/post-details.php +++ b/projects/plugins/jetpack/modules/theme-tools/content-options/post-details.php @@ -9,8 +9,11 @@ /** * The function to include Post Details in a theme's stylesheet. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_post_details_enqueue_scripts() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); // Make sure we can proceed. list( $should_run, $options, $definied, $post_details ) = jetpack_post_details_should_run(); @@ -71,9 +74,11 @@ function jetpack_post_details_enqueue_scripts() { /** * Adds custom classes to the array of body classes. * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. * @param array $classes Classes for the body element. */ function jetpack_post_details_body_classes( $classes ) { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); // Make sure we can proceed. list( $should_run, $options, $definied ) = jetpack_post_details_should_run(); @@ -119,8 +124,11 @@ function jetpack_post_details_body_classes( $classes ) { /** * Determines if Post Details should run. + * + * @deprecated $$next-version$$ Moved to Classic Theme Helper package. */ function jetpack_post_details_should_run() { + _deprecated_function( __FUNCTION__, 'jetpack-$$next-version$$' ); // Empty value representing falsy return value. $void = array( false, null, null, null );