Lines:
1 to 99 of 99
<?php /** * Theme Tools: the functions to display Content or Excerpt in a theme. * * @package automattic/jetpack */ /** * If the theme doesn't support 'jetpack-content-options', don't continue. */ if ( ! current_theme_supports( 'jetpack-content-options' ) ) { return; } /** * Get the Blog Display setting. * If theme is using both 'Content' and 'Excerpt' then this setting will be called 'Mixed'. */ $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 ); sort( $blog_display ); $blog_display = implode( ', ', $blog_display ); $blog_display = ( 'content, excerpt' === $blog_display ) ? 'mixed' : $blog_display; /** * If the theme doesn't support 'jetpack-content-options[ 'blog-display' ]', don't continue. */ if ( ! in_array( $blog_display, array( 'content', 'excerpt', 'mixed' ), true ) ) { return; } /* function jetpack_blog_display_custom_excerpt() – Apply Content filters. */ /* function jetpack_the_content_to_the_excerpt() – Display Excerpt instead of Content. */ /* function jetpack_the_excerpt_to_the_content() – Display Content instead of Excerpt. */ /* function jetpack_the_content_customizer() – Display both Content and Excerpt instead of Content in the Customizer so live preview can switch between them. */ /* function jetpack_the_excerpt_customizer() – Display both Content and Excerpt instead of Excerpt in the Customizer so live preview can switch between them. */ /* function jetpack_the_excerpt_mixed_customizer() – Display Content instead of Excerpt in the Customizer when theme uses a ‘Mixed’ display. */ /* function jetpack_the_content_customizer_class() – Returns a class value, `output-the-content` by default. */ if ( is_customize_preview() ) { /* * Display Content and Excerpt if the default Blog Display is 'Content' * and we are in the Customizer. */ if ( 'content' === $blog_display ) { add_filter( 'the_content', 'jetpack_the_content_customizer' ); } /* * Display Content and Excerpt if the default Blog Display is 'Excerpt' * and we are in the Customizer. */ if ( 'excerpt' === $blog_display ) { add_filter( 'the_excerpt', 'jetpack_the_excerpt_customizer' ); } /* * Display Content and Excerpt if the default Blog Display is 'Mixed' * and we are in the Customizer. */ if ( 'mixed' === $blog_display ) { add_filter( 'the_content', 'jetpack_the_content_customizer' ); add_filter( 'the_excerpt', 'jetpack_the_excerpt_mixed_customizer' ); } } else { $display_option = get_option( 'jetpack_content_blog_display', $blog_display ); /* * Display Excerpt if the default Blog Display is 'Content' * or default Blog Display is 'Mixed' * and the Option picked is 'Post Excerpt' * and we aren't in the Customizer. */ if ( ( 'content' === $blog_display || 'mixed' === $blog_display ) && 'excerpt' === $display_option ) { add_filter( 'the_content', 'jetpack_the_content_to_the_excerpt' ); } /* * Display Content if the default Blog Display is 'Excerpt' * or default Blog Display is 'Mixed' * and the Option picked is 'Full Post' * and we aren't in the Customizer. */ if ( ( 'excerpt' === $blog_display || 'mixed' === $blog_display ) && 'content' === $display_option ) { add_filter( 'the_excerpt', 'jetpack_the_excerpt_to_the_content' ); } }