diff --git a/projects/packages/classic-theme-helper/.phan/baseline.php b/projects/packages/classic-theme-helper/.phan/baseline.php index aede0f74752cc..47e19ffe57e80 100644 --- a/projects/packages/classic-theme-helper/.phan/baseline.php +++ b/projects/packages/classic-theme-helper/.phan/baseline.php @@ -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 @@ -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) diff --git a/projects/packages/classic-theme-helper/changelog/add-portfolios-cpt-to-classic-theme-helper-package b/projects/packages/classic-theme-helper/changelog/add-portfolios-cpt-to-classic-theme-helper-package new file mode 100644 index 0000000000000..ea4ff08e57db7 --- /dev/null +++ b/projects/packages/classic-theme-helper/changelog/add-portfolios-cpt-to-classic-theme-helper-package @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Classic Theme Helper: Adding Portfolio custom post type content diff --git a/projects/packages/classic-theme-helper/src/custom-content-types.php b/projects/packages/classic-theme-helper/src/custom-content-types.php new file mode 100644 index 0000000000000..704fb7f082be3 --- /dev/null +++ b/projects/packages/classic-theme-helper/src/custom-content-types.php @@ -0,0 +1,78 @@ +' . __( 'Your Custom Content Types', 'jetpack-classic-theme-helper' ) . '', + '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' ) ) { + ?> +

+ + +

+ maybe_register_cpt(); + } + + /** + * Registers the custom post types and adds action/filter handlers, but + * only if the site supports it + */ + public function maybe_register_cpt() { + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + $setting = get_option( self::OPTION_NAME, '0' ); + } else { + $setting = class_exists( 'Jetpack_Options' ) ? Jetpack_Options::get_option_and_ensure_autoload( self::OPTION_NAME, '0' ) : '0'; // @phan-suppress-current-line PhanUndeclaredClassMethod -- We check if the class exists first. + } + + // Bail early if Portfolio option is not set and the theme doesn't declare support. + if ( empty( $setting ) && ! $this->site_supports_custom_post_type() ) { + return; + } + + // CPT magic. + $this->register_post_types(); + add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 ); + add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'flush_rules_on_enable' ), 10 ); + add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'flush_rules_on_first_project' ) ); + add_action( 'after_switch_theme', array( $this, 'flush_rules_on_switch' ) ); + + // Admin Customization. + add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); + add_filter( sprintf( 'manage_%s_posts_columns', self::CUSTOM_POST_TYPE ), array( $this, 'edit_admin_columns' ) ); + add_filter( sprintf( 'manage_%s_posts_custom_column', self::CUSTOM_POST_TYPE ), array( $this, 'image_column' ), 10, 2 ); + if ( ! wp_is_block_theme() ) { + add_action( 'customize_register', array( $this, 'customize_register' ) ); + } + + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + + // Track all the things. + add_action( sprintf( 'add_option_%s', self::OPTION_NAME ), array( $this, 'new_activation_stat_bump' ) ); + add_action( sprintf( 'update_option_%s', self::OPTION_NAME ), array( $this, 'update_option_stat_bump' ), 11, 2 ); + add_action( sprintf( 'publish_%s', self::CUSTOM_POST_TYPE ), array( $this, 'new_project_stat_bump' ) ); + } + + add_image_size( 'jetpack-portfolio-admin-thumb', 50, 50, true ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); + + // register jetpack_portfolio shortcode and portfolio shortcode (legacy). + add_shortcode( 'portfolio', array( $this, 'portfolio_shortcode' ) ); + add_shortcode( 'jetpack_portfolio', array( $this, 'portfolio_shortcode' ) ); + + // Adjust CPT archive and custom taxonomies to obey CPT reading setting. + add_filter( 'infinite_scroll_settings', array( $this, 'infinite_scroll_click_posts_per_page' ) ); + add_filter( 'infinite_scroll_results', array( $this, 'infinite_scroll_results' ), 10, 3 ); + + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + // Add to Dotcom XML sitemaps. + add_filter( 'wpcom_sitemap_post_types', array( $this, 'add_to_sitemap' ) ); + } else { + // Add to Jetpack XML sitemap. + add_filter( 'jetpack_sitemap_post_types', array( $this, 'add_to_sitemap' ) ); + } + + // Adjust CPT archive and custom taxonomies to obey CPT reading setting. + add_filter( 'pre_get_posts', array( $this, 'query_reading_setting' ) ); + + // If CPT was enabled programatically and no CPT items exist when user switches away, disable. + if ( $setting && $this->site_supports_custom_post_type() ) { + add_action( 'switch_theme', array( $this, 'deactivation_post_type_support' ) ); + } + } + + /** + * Add a checkbox field in 'Settings' > 'Writing' + * for enabling CPT functionality. + * + * @return void + */ + public function settings_api_init() { + add_settings_field( + self::OPTION_NAME, + '' . __( 'Portfolio Projects', 'jetpack-classic-theme-helper' ) . '', + array( $this, 'setting_html' ), + 'writing', + 'jetpack_cpt_section' + ); + register_setting( + 'writing', + self::OPTION_NAME, + 'intval' + ); + + // Check if CPT is enabled first so that intval doesn't get set to NULL on re-registering. + if ( get_option( self::OPTION_NAME, '0' ) || current_theme_supports( self::CUSTOM_POST_TYPE ) ) { + register_setting( + 'writing', + self::OPTION_READING_SETTING, + 'intval' + ); + } + } + + /** + * HTML code to display a checkbox true/false option + * for the Portfolio CPT setting. + * + * @return void + */ + public function setting_html() { + if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) : ?> +

+ %s', 'jetpack-classic-theme-helper' ), + esc_attr( self::CUSTOM_POST_TYPE ) + ), + array( + 'strong' => array(), + ) + ); + ?> +

+ + +

', + esc_attr( self::OPTION_READING_SETTING ), + sprintf( + /* translators: %1$s is replaced with an input field for numbers */ + __( 'Portfolio pages display at most %1$s projects', 'jetpack-classic-theme-helper' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- the placeholder contains HTML. + sprintf( + '', + esc_attr( self::OPTION_READING_SETTING ), + esc_attr( get_option( self::OPTION_READING_SETTING, '10' ) ) + ) + ) + ); + endif; + } + + /** + * Bump Portfolio > New Activation stat. + */ + public function new_activation_stat_bump() { + if ( function_exists( 'bump_stats_extras' ) ) { + bump_stats_extras( 'portfolios', 'new-activation' ); // @phan-suppress-current-line PhanUndeclaredFunction -- only calling if it exists. + } + } + + /** + * Bump Portfolio > Option On/Off stats to get total active. + * + * @param mixed $old The old option value. + * @param mixed $new The new option value. + */ + public function update_option_stat_bump( $old, $new ) { + if ( empty( $old ) && ! empty( $new ) ) { + if ( function_exists( 'bump_stats_extras' ) ) { + + bump_stats_extras( 'portfolios', 'option-on' ); // @phan-suppress-current-line PhanUndeclaredFunction -- only calling if it exists. + } + } + + if ( ! empty( $old ) && empty( $new ) ) { + if ( function_exists( 'bump_stats_extras' ) ) { + + bump_stats_extras( 'portfolios', 'option-off' ); // @phan-suppress-current-line PhanUndeclaredFunction -- only calling if it exists. + } + } + } + + /** + * Bump Portfolio > Published Projects stat when projects are published. + */ + public function new_project_stat_bump() { + if ( function_exists( 'bump_stats_extras' ) ) { + + bump_stats_extras( 'portfolios', 'published-projects' ); // @phan-suppress-current-line PhanUndeclaredFunction -- only calling if it exists. + } + } + + /** + * Should this Custom Post Type be made available? + */ + private function site_supports_custom_post_type() { + // If the current theme requests it. + if ( current_theme_supports( self::CUSTOM_POST_TYPE ) || get_option( self::OPTION_NAME, '0' ) ) { + return true; + } + + // Otherwise, say no unless something wants to filter us to say yes. + /** This action is documented in modules/custom-post-types/nova.php */ + return (bool) apply_filters( 'jetpack_enable_cpt', false, self::CUSTOM_POST_TYPE ); + } + + /** + * Flush permalinks when CPT option is turned on/off + */ + public function flush_rules_on_enable() { + flush_rewrite_rules(); + } + + /** + * Count published projects and flush permalinks when first projects is published + */ + public function flush_rules_on_first_project() { + $projects = get_transient( 'jetpack-portfolio-count-cache' ); + + if ( false === $projects ) { + flush_rewrite_rules(); + $projects = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish; + + if ( ! empty( $projects ) ) { + set_transient( 'jetpack-portfolio-count-cache', $projects, HOUR_IN_SECONDS * 12 ); + } + } + } + + /** + * Flush permalinks when CPT supported theme is activated + */ + public function flush_rules_on_switch() { + if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) { + flush_rewrite_rules(); + } + } + + /** + * On plugin/theme activation, check if current theme supports CPT + */ + public static function activation_post_type_support() { + if ( current_theme_supports( self::CUSTOM_POST_TYPE ) ) { + update_option( self::OPTION_NAME, '1' ); + } + } + + /** + * On theme switch, check if CPT item exists and disable if not + */ + public function deactivation_post_type_support() { + $portfolios = get_posts( + array( + 'fields' => 'ids', + 'posts_per_page' => 1, + 'post_type' => self::CUSTOM_POST_TYPE, + 'suppress_filters' => false, + ) + ); + + if ( empty( $portfolios ) ) { + update_option( self::OPTION_NAME, '0' ); + } + } + + /** + * Register Post Type + */ + public function register_post_types() { + if ( post_type_exists( self::CUSTOM_POST_TYPE ) ) { + return; + } + + register_post_type( + self::CUSTOM_POST_TYPE, + array( + 'labels' => array( + 'name' => esc_html__( 'Projects', 'jetpack-classic-theme-helper' ), + 'singular_name' => esc_html__( 'Project', 'jetpack-classic-theme-helper' ), + 'menu_name' => esc_html__( 'Portfolio', 'jetpack-classic-theme-helper' ), + 'all_items' => esc_html__( 'All Projects', 'jetpack-classic-theme-helper' ), + 'add_new' => esc_html__( 'Add New', 'jetpack-classic-theme-helper' ), + 'add_new_item' => esc_html__( 'Add New Project', 'jetpack-classic-theme-helper' ), + 'edit_item' => esc_html__( 'Edit Project', 'jetpack-classic-theme-helper' ), + 'new_item' => esc_html__( 'New Project', 'jetpack-classic-theme-helper' ), + 'view_item' => esc_html__( 'View Project', 'jetpack-classic-theme-helper' ), + 'search_items' => esc_html__( 'Search Projects', 'jetpack-classic-theme-helper' ), + 'not_found' => esc_html__( 'No Projects found', 'jetpack-classic-theme-helper' ), + 'not_found_in_trash' => esc_html__( 'No Projects found in Trash', 'jetpack-classic-theme-helper' ), + 'filter_items_list' => esc_html__( 'Filter projects list', 'jetpack-classic-theme-helper' ), + 'items_list_navigation' => esc_html__( 'Project list navigation', 'jetpack-classic-theme-helper' ), + 'items_list' => esc_html__( 'Projects list', 'jetpack-classic-theme-helper' ), + ), + 'supports' => array( + 'title', + 'editor', + 'thumbnail', + 'author', + 'post-formats', + 'comments', + 'publicize', + 'wpcom-markdown', + 'revisions', + 'excerpt', + 'custom-fields', + 'newspack_blocks', + ), + 'rewrite' => array( + 'slug' => 'portfolio', + 'with_front' => false, + 'feeds' => true, + 'pages' => true, + ), + 'public' => true, + 'show_ui' => true, + 'menu_position' => 20, // below Pages. + 'menu_icon' => 'dashicons-portfolio', // 3.8+ dashicon option. + 'capability_type' => 'page', + 'map_meta_cap' => true, + 'taxonomies' => array( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_TAXONOMY_TAG ), + 'has_archive' => true, + 'query_var' => 'portfolio', + 'show_in_rest' => true, + ) + ); + + register_taxonomy( + self::CUSTOM_TAXONOMY_TYPE, + self::CUSTOM_POST_TYPE, + array( + 'hierarchical' => true, + 'labels' => array( + 'name' => esc_html__( 'Project Types', 'jetpack-classic-theme-helper' ), + 'singular_name' => esc_html__( 'Project Type', 'jetpack-classic-theme-helper' ), + 'menu_name' => esc_html__( 'Project Types', 'jetpack-classic-theme-helper' ), + 'all_items' => esc_html__( 'All Project Types', 'jetpack-classic-theme-helper' ), + 'edit_item' => esc_html__( 'Edit Project Type', 'jetpack-classic-theme-helper' ), + 'view_item' => esc_html__( 'View Project Type', 'jetpack-classic-theme-helper' ), + 'update_item' => esc_html__( 'Update Project Type', 'jetpack-classic-theme-helper' ), + 'add_new_item' => esc_html__( 'Add New Project Type', 'jetpack-classic-theme-helper' ), + 'new_item_name' => esc_html__( 'New Project Type Name', 'jetpack-classic-theme-helper' ), + 'parent_item' => esc_html__( 'Parent Project Type', 'jetpack-classic-theme-helper' ), + 'parent_item_colon' => esc_html__( 'Parent Project Type:', 'jetpack-classic-theme-helper' ), + 'search_items' => esc_html__( 'Search Project Types', 'jetpack-classic-theme-helper' ), + 'items_list_navigation' => esc_html__( 'Project type list navigation', 'jetpack-classic-theme-helper' ), + 'items_list' => esc_html__( 'Project type list', 'jetpack-classic-theme-helper' ), + ), + 'public' => true, + 'show_ui' => true, + 'show_in_nav_menus' => true, + 'show_in_rest' => true, + 'show_admin_column' => true, + 'query_var' => true, + 'rewrite' => array( 'slug' => 'project-type' ), + ) + ); + + register_taxonomy( + self::CUSTOM_TAXONOMY_TAG, + self::CUSTOM_POST_TYPE, + array( + 'hierarchical' => false, + 'labels' => array( + 'name' => esc_html__( 'Project Tags', 'jetpack-classic-theme-helper' ), + 'singular_name' => esc_html__( 'Project Tag', 'jetpack-classic-theme-helper' ), + 'menu_name' => esc_html__( 'Project Tags', 'jetpack-classic-theme-helper' ), + 'all_items' => esc_html__( 'All Project Tags', 'jetpack-classic-theme-helper' ), + 'edit_item' => esc_html__( 'Edit Project Tag', 'jetpack-classic-theme-helper' ), + 'view_item' => esc_html__( 'View Project Tag', 'jetpack-classic-theme-helper' ), + 'update_item' => esc_html__( 'Update Project Tag', 'jetpack-classic-theme-helper' ), + 'add_new_item' => esc_html__( 'Add New Project Tag', 'jetpack-classic-theme-helper' ), + 'new_item_name' => esc_html__( 'New Project Tag Name', 'jetpack-classic-theme-helper' ), + 'search_items' => esc_html__( 'Search Project Tags', 'jetpack-classic-theme-helper' ), + 'popular_items' => esc_html__( 'Popular Project Tags', 'jetpack-classic-theme-helper' ), + 'separate_items_with_commas' => esc_html__( 'Separate tags with commas', 'jetpack-classic-theme-helper' ), + 'add_or_remove_items' => esc_html__( 'Add or remove tags', 'jetpack-classic-theme-helper' ), + 'choose_from_most_used' => esc_html__( 'Choose from the most used tags', 'jetpack-classic-theme-helper' ), + 'not_found' => esc_html__( 'No tags found.', 'jetpack-classic-theme-helper' ), + 'items_list_navigation' => esc_html__( 'Project tag list navigation', 'jetpack-classic-theme-helper' ), + 'items_list' => esc_html__( 'Project tag list', 'jetpack-classic-theme-helper' ), + ), + 'public' => true, + 'show_ui' => true, + 'show_in_nav_menus' => true, + 'show_in_rest' => true, + 'show_admin_column' => true, + 'query_var' => true, + 'rewrite' => array( 'slug' => 'project-tag' ), + ) + ); + + register_taxonomy_for_object_type( 'post_format', self::CUSTOM_POST_TYPE ); + } + + /** + * Update messages for the Portfolio admin. + * + * @param array $messages Existing post update messages. + */ + public function updated_messages( $messages ) { + global $post; + + $messages[ self::CUSTOM_POST_TYPE ] = array( + 0 => '', // Unused. Messages start at index 1. + 1 => sprintf( + /* Translators: link to portfolio item's page. */ + __( 'Project updated. View item', 'jetpack-classic-theme-helper' ), + esc_url( get_permalink( $post->ID ) ) + ), + 2 => esc_html__( 'Custom field updated.', 'jetpack-classic-theme-helper' ), + 3 => esc_html__( 'Custom field deleted.', 'jetpack-classic-theme-helper' ), + 4 => esc_html__( 'Project updated.', 'jetpack-classic-theme-helper' ), + 5 => isset( $_GET['revision'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling. + ? sprintf( + /* translators: %s: date and time of the revision */ + esc_html__( 'Project restored to revision from %s', 'jetpack-classic-theme-helper' ), + wp_post_revision_title( (int) $_GET['revision'], false ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Copying core message handling. + ) + : false, + 6 => sprintf( + /* Translators: link to portfolio item's page. */ + __( 'Project published. View project', 'jetpack-classic-theme-helper' ), + esc_url( get_permalink( $post->ID ) ) + ), + 7 => esc_html__( 'Project saved.', 'jetpack-classic-theme-helper' ), + 8 => sprintf( + /* Translators: link to portfolio item's page. */ + __( 'Project submitted. Preview project', 'jetpack-classic-theme-helper' ), + esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) + ), + 9 => sprintf( + /* Translators: 1: Publishing date and time. 2. Link to portfolio's item page. */ + __( 'Project scheduled for: %1$s. Preview project', 'jetpack-classic-theme-helper' ), + /* translators: Publish box date format, see https://php.net/date */ + date_i18n( __( 'M j, Y @ G:i', 'jetpack-classic-theme-helper' ), strtotime( $post->post_date ) ), + esc_url( get_permalink( $post->ID ) ) + ), + 10 => sprintf( + /* Translators: link to portfolio item's page. */ + __( 'Project item draft updated. Preview project', 'jetpack-classic-theme-helper' ), + esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) + ), + ); + + return $messages; + } + + /** + * Change ‘Title’ column label + * Add Featured Image column + * + * @param array $columns An array of column names. + */ + public function edit_admin_columns( $columns ) { + // change 'Title' to 'Project'. + $columns['title'] = __( 'Project', 'jetpack-classic-theme-helper' ); + if ( current_theme_supports( 'post-thumbnails' ) ) { + // add featured image before 'Project'. + $columns = array_slice( $columns, 0, 1, true ) + array( 'thumbnail' => '' ) + array_slice( $columns, 1, null, true ); + } + + return $columns; + } + + /** + * Add featured image to column + * + * @param string $column The name of the column to display. + * @param int $post_id The current post ID. + */ + public function image_column( $column, $post_id ) { + if ( 'thumbnail' !== $column ) { + return; + } + + echo get_the_post_thumbnail( $post_id, 'jetpack-portfolio-admin-thumb' ); + } + + /** + * Adjust image column width + * + * @param string $hook Page hook. + */ + public function enqueue_admin_styles( $hook ) { + $screen = get_current_screen(); + + if ( + 'edit.php' === $hook + && self::CUSTOM_POST_TYPE === $screen->post_type + && current_theme_supports( 'post-thumbnails' ) + ) { + wp_add_inline_style( 'wp-admin', '.manage-column.column-thumbnail { width: 50px; } @media screen and (max-width: 360px) { .column-thumbnail{ display:none; } }' ); + } + } + + /** + * Adds portfolio section to the Customizer. + * + * @param WP_Customize_Manager $wp_customize Customizer instance. + */ + public function customize_register( $wp_customize ) { + $options = get_theme_support( self::CUSTOM_POST_TYPE ); + + if ( ( ! isset( $options[0]['title'] ) || true !== $options[0]['title'] ) && ( ! isset( $options[0]['content'] ) || true !== $options[0]['content'] ) && ( ! isset( $options[0]['featured-image'] ) || true !== $options[0]['featured-image'] ) ) { + return; + } + + $wp_customize->add_section( + 'jetpack_portfolio', + array( + 'title' => esc_html__( 'Portfolio', 'jetpack-classic-theme-helper' ), + 'theme_supports' => self::CUSTOM_POST_TYPE, + 'priority' => 130, + ) + ); + + if ( isset( $options[0]['title'] ) && true === $options[0]['title'] ) { + $wp_customize->add_setting( + 'jetpack_portfolio_title', + array( + 'default' => esc_html__( 'Projects', 'jetpack-classic-theme-helper' ), + 'type' => 'option', + 'sanitize_callback' => 'sanitize_text_field', + 'sanitize_js_callback' => 'sanitize_text_field', + ) + ); + + $wp_customize->add_control( + 'jetpack_portfolio_title', + array( + 'section' => 'jetpack_portfolio', + 'label' => esc_html__( 'Portfolio Archive Title', 'jetpack-classic-theme-helper' ), + 'type' => 'text', + ) + ); + } + + if ( isset( $options[0]['content'] ) && true === $options[0]['content'] ) { + $wp_customize->add_setting( + 'jetpack_portfolio_content', + array( + 'default' => '', + 'type' => 'option', + 'sanitize_callback' => 'wp_kses_post', + 'sanitize_js_callback' => 'wp_kses_post', + ) + ); + + $wp_customize->add_control( + 'jetpack_portfolio_content', + array( + 'section' => 'jetpack_portfolio', + 'label' => esc_html__( 'Portfolio Archive Content', 'jetpack-classic-theme-helper' ), + 'type' => 'textarea', + ) + ); + } + + if ( isset( $options[0]['featured-image'] ) && true === $options[0]['featured-image'] ) { + $wp_customize->add_setting( + 'jetpack_portfolio_featured_image', + array( + 'default' => '', + 'type' => 'option', + 'sanitize_callback' => 'attachment_url_to_postid', + 'sanitize_js_callback' => 'attachment_url_to_postid', + 'theme_supports' => 'post-thumbnails', + ) + ); + + $wp_customize->add_control( + new WP_Customize_Image_Control( + $wp_customize, + 'jetpack_portfolio_featured_image', + array( + 'section' => 'jetpack_portfolio', + 'label' => esc_html__( 'Portfolio Archive Featured Image', 'jetpack-classic-theme-helper' ), + ) + ) + ); + } + } + + /** + * Follow CPT reading setting on CPT archive and taxonomy pages + * + * @param WP_Query $query A WP_Query instance. + */ + public function query_reading_setting( $query ) { + if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) + && $query->is_main_query() + && ( $query->is_post_type_archive( self::CUSTOM_POST_TYPE ) + || $query->is_tax( self::CUSTOM_TAXONOMY_TYPE ) + || $query->is_tax( self::CUSTOM_TAXONOMY_TAG ) ) + ) { + $query->set( 'posts_per_page', get_option( self::OPTION_READING_SETTING, '10' ) ); + } + } + + /** + * If Infinite Scroll is set to 'click', use our custom reading setting instead of core's `posts_per_page`. + * + * @param array $settings Array of Infinite Scroll settings. + */ + public function infinite_scroll_click_posts_per_page( $settings ) { + global $wp_query; + + if ( ( ! is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) + && true === $settings['click_handle'] + && ( $wp_query->is_post_type_archive( self::CUSTOM_POST_TYPE ) + || $wp_query->is_tax( self::CUSTOM_TAXONOMY_TYPE ) + || $wp_query->is_tax( self::CUSTOM_TAXONOMY_TAG ) ) + ) { + $settings['posts_per_page'] = get_option( self::OPTION_READING_SETTING, $settings['posts_per_page'] ); // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page + } + + return $settings; + } + + /** + * Filter the results of infinite scroll to make sure we get `lastbatch` right. + * + * @param array $results Array of Infinite Scroll results. + * @param array $query_args Array of main query arguments. + * @param WP_Query $query WP Query. + */ + public function infinite_scroll_results( $results, $query_args, $query ) { + $results['lastbatch'] = $query_args['paged'] >= $query->max_num_pages; + return $results; + } + + /** + * Add CPT to Dotcom sitemap + * + * @param array $post_types Array of post types included in sitemap. + */ + public function add_to_sitemap( $post_types ) { + $post_types[] = self::CUSTOM_POST_TYPE; + + return $post_types; + } + + /** + * Add to REST API post type allowed list. + * + * @param array $post_types Array of post types to add to the allowed list. Default to `array( 'post', 'page', 'revision' )`. + */ + public function allow_portfolio_rest_api_type( $post_types ) { + $post_types[] = self::CUSTOM_POST_TYPE; + + return $post_types; + } + + /** + * Our [portfolio] shortcode. + * Prints Portfolio data styled to look good on *any* theme. + * + * @param array $atts Shortcode attributes. + * + * @return string html + */ + public static function portfolio_shortcode( $atts ) { + // Default attributes. + $atts = shortcode_atts( + array( + 'display_types' => true, + 'display_tags' => true, + 'display_content' => true, // Can be false, true, or full. + 'display_author' => false, + 'show_filter' => false, + 'include_type' => false, + 'include_tag' => false, + 'columns' => 2, + 'showposts' => -1, + 'order' => 'asc', + 'orderby' => 'date', + ), + $atts, + 'portfolio' + ); + + /* + * A little sanitization for our shortcode attributes aiming to use booleans. + * Attributes can be booleans (from the default values) or strings. + */ + foreach ( $atts as $attribute_name => $attribute_value ) { + if ( preg_match( '#^(?:display_|show_)#i', $attribute_name ) ) { + // display_content is a special case. + if ( 'display_content' === $attribute_name && 'full' === $attribute_value ) { + $atts['display_content'] = 'full'; + continue; + } + + $atts[ $attribute_name ] = self::sanitize_boolean_attribute( $attribute_value ); + } + } + + if ( $atts['include_type'] ) { + $atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) ); + } + + if ( $atts['include_tag'] ) { + $atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) ); + } + + $atts['columns'] = absint( $atts['columns'] ); + + $atts['showposts'] = (int) $atts['showposts']; + + if ( $atts['order'] ) { + $atts['order'] = urldecode( $atts['order'] ); + $atts['order'] = strtoupper( $atts['order'] ); + if ( 'DESC' !== $atts['order'] ) { + $atts['order'] = 'ASC'; + } + } + + if ( $atts['orderby'] ) { + $atts['orderby'] = urldecode( $atts['orderby'] ); + $atts['orderby'] = strtolower( $atts['orderby'] ); + $allowed_keys = array( 'author', 'date', 'title', 'rand' ); + + $parsed = array(); + foreach ( explode( ',', $atts['orderby'] ) as $orderby ) { + if ( ! in_array( $orderby, $allowed_keys, true ) ) { + continue; + } + $parsed[] = $orderby; + } + + if ( empty( $parsed ) ) { + unset( $atts['orderby'] ); + } else { + $atts['orderby'] = implode( ' ', $parsed ); + } + } + + // enqueue shortcode styles when shortcode is used. + if ( ! wp_style_is( 'jetpack-portfolio-style', 'enqueued' ) ) { + wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' ); + } + + return self::portfolio_shortcode_html( $atts ); + } + + /** + * Sanitizes an attribute value. + * Attributes can be booleans (from the default values) or strings. + * + * @since 11.0 + * + * @param bool|string $attr Shortcode attribute value. + * + * @return bool + */ + private static function sanitize_boolean_attribute( $attr ) { + if ( $attr && 'true' == $attr ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual + return true; + } + + return false; + } + + /** + * Query to retrieve entries from the Portfolio post_type. + * + * @param array $atts Shortcode attributes. + * + * @return object + */ + private static function portfolio_query( $atts ) { + // Default query arguments. + $default = array( + 'order' => $atts['order'], + 'orderby' => $atts['orderby'], + 'posts_per_page' => $atts['showposts'], + ); + + $args = wp_parse_args( $atts, $default ); + $args['post_type'] = self::CUSTOM_POST_TYPE; // Force this post type. + + if ( $atts['include_type'] || $atts['include_tag'] ) { + $args['tax_query'] = array(); + } + + // If 'include_type' has been set use it on the main query. + if ( $atts['include_type'] ) { + array_push( + $args['tax_query'], + array( + 'taxonomy' => self::CUSTOM_TAXONOMY_TYPE, + 'field' => 'slug', + 'terms' => $atts['include_type'], + ) + ); + } + + // If 'include_tag' has been set use it on the main query. + if ( $atts['include_tag'] ) { + array_push( + $args['tax_query'], + array( + 'taxonomy' => self::CUSTOM_TAXONOMY_TAG, + 'field' => 'slug', + 'terms' => $atts['include_tag'], + ) + ); + } + + if ( $atts['include_type'] && $atts['include_tag'] ) { + $args['tax_query']['relation'] = 'AND'; + } + + // Run the query and return. + $query = new WP_Query( $args ); + return $query; + } + + /** + * The Portfolio shortcode loop. + * + * @todo add theme color styles + * + * @param array $atts Shortcode attributes. + * + * @return string html + */ + private static function portfolio_shortcode_html( $atts ) { + $query = self::portfolio_query( $atts ); + $portfolio_index_number = 0; + + ob_start(); + + /* + * If we have posts, create the html + * with portfolio markup + */ + if ( $query->have_posts() ) { + /* + * Render styles + * See self::themecolor_styles(); + */ + ?> +
+ have_posts() ) { + $query->the_post(); + $post_id = get_the_ID(); + ?> +
+
+ + +

+ + + +
+ + +
+ +
+ +
+ +
+ +

+ 'slugs' ) ); + $class = array(); + + $class[] = 'portfolio-entry-column-' . $columns; + // add a type- class for each project type. + foreach ( $project_types as $project_type ) { + $class[] = 'type-' . esc_html( $project_type ); + } + if ( $columns > 1 ) { + if ( ( $portfolio_index_number % 2 ) === 0 ) { + $class[] = 'portfolio-entry-mobile-first-item-row'; + } else { + $class[] = 'portfolio-entry-mobile-last-item-row'; + } + } + + // add first and last classes to first and last items in a row. + if ( ( $portfolio_index_number % $columns ) === 0 ) { + $class[] = 'portfolio-entry-first-item-row'; + } elseif ( ( $portfolio_index_number % $columns ) === ( $columns - 1 ) ) { + $class[] = 'portfolio-entry-last-item-row'; + } + + /** + * Filter the class applied to project div in the portfolio + * + * @module custom-content-types + * + * @since 3.1.0 + * + * @param string $class class name of the div. + * @param int $portfolio_index_number iterator count the number of columns up starting from 0. + * @param int $columns number of columns to display the content in. + */ + return apply_filters( + 'portfolio-project-post-class', // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + implode( ' ', $class ), + $portfolio_index_number, + $columns + ); + } + + /** + * Displays the project type that a project belongs to. + * + * @param int $post_id Post ID. + * + * @return string html + */ + private static function get_project_type( $post_id ) { + $project_types = get_the_terms( $post_id, self::CUSTOM_TAXONOMY_TYPE ); + + // If no types, return empty string. + if ( empty( $project_types ) || is_wp_error( $project_types ) ) { + return ''; + } + + $html = '
' . __( 'Types:', 'jetpack-classic-theme-helper' ) . ''; + $types = array(); + // Loop through all the types. + foreach ( $project_types as $project_type ) { + $project_type_link = get_term_link( $project_type, self::CUSTOM_TAXONOMY_TYPE ); + + if ( is_wp_error( $project_type_link ) ) { + return $project_type_link; + } + + $types[] = ''; + } + $html .= ' ' . implode( ', ', $types ); + $html .= '
'; + + return $html; + } + + /** + * Displays the project tags that a project belongs to. + * + * @param int $post_id Post ID. + * + * @return string html + */ + private static function get_project_tags( $post_id ) { + $project_tags = get_the_terms( $post_id, self::CUSTOM_TAXONOMY_TAG ); + + // If no tags, return empty string. + if ( empty( $project_tags ) || is_wp_error( $project_tags ) ) { + return ''; + } + + $html = '
' . __( 'Tags:', 'jetpack-classic-theme-helper' ) . ''; + $tags = array(); + // Loop through all the tags. + foreach ( $project_tags as $project_tag ) { + $project_tag_link = get_term_link( $project_tag, self::CUSTOM_TAXONOMY_TYPE ); + + if ( is_wp_error( $project_tag_link ) ) { + return $project_tag_link; + } + + $tags[] = ''; + } + $html .= ' ' . implode( ', ', $tags ); + $html .= '
'; + + return $html; + } + + /** + * Displays the author of the current portfolio project. + * + * @return string html + */ + private static function get_project_author() { + $html = '
'; + $html .= sprintf( + /* translators: %1$s is link to author posts, %2$s is author display name */ + __( 'Author: %2$s', 'jetpack-classic-theme-helper' ), + esc_url( get_author_posts_url( (int) get_the_author_meta( 'ID' ) ) ), + esc_html( get_the_author() ) + ); + $html .= '
'; + + return $html; + } + + /** + * Display the featured image if it's available + * + * @param int $post_id Post ID. + * + * @return string html + */ + private static function get_portfolio_thumbnail_link( $post_id ) { + if ( has_post_thumbnail( $post_id ) ) { + /** + * Change the Portfolio thumbnail size. + * + * @module custom-content-types + * + * @since 3.4.0 + * + * @param string|array $var Either a registered size keyword or size array. + */ + return '' . get_the_post_thumbnail( $post_id, apply_filters( 'jetpack_portfolio_thumbnail_size', 'large' ) ) . ''; + } + } + } +} diff --git a/projects/packages/classic-theme-helper/src/custom-post-types/css/portfolio-shortcode.css b/projects/packages/classic-theme-helper/src/custom-post-types/css/portfolio-shortcode.css new file mode 100644 index 0000000000000..b3c2c1e37d971 --- /dev/null +++ b/projects/packages/classic-theme-helper/src/custom-post-types/css/portfolio-shortcode.css @@ -0,0 +1,131 @@ +.jetpack-portfolio-shortcode { + clear: both; + margin: 0; + overflow: hidden; + padding: 0; +} + +.portfolio-entry { + float: left; + margin: 0 0 3em; + padding: 0; + width: 100%; +} + +/* Column setting */ +.portfolio-entry-column-1 { + width: 100%; +} + +.portfolio-entry-column-2 { + margin-right: 4%; + width: 48%; +} + +.portfolio-entry-column-3 { + margin-right: 3.5%; + width: 31%; +} + +.portfolio-entry-column-4 { + margin-right: 3%; + width: 22%; +} + +.portfolio-entry-column-5 { + margin-right: 2.5%; + width: 18%; +} + +.portfolio-entry-column-6 { + margin-right: 2%; + width: 15%; +} +.portfolio-entry-first-item-row { + clear: both; +} +.portfolio-entry-last-item-row { + margin-right: 0; +} + +@media screen and (max-width:768px) { + .portfolio-entry-mobile-first-item-row{ + margin-right: 4%; + width: 48%; + clear:both; + } + .portfolio-entry-first-item-row { + clear:none; + } + .portfolio-entry-mobile-last-item-row{ + width: 48%; + margin-right: 0; + } +} +/* Entry Header */ +.portfolio-entry-header { + border: 0; + margin: 0; + padding: 0; +} + +.portfolio-featured-image { + margin: 0; + padding: 0; +} + +.portfolio-featured-image img { + border: 0; + height: auto; + max-width: 100%; + vertical-align: middle; +} + +.portfolio-entry-title { + font-weight: 700; + margin: 0; + padding: 0; +} + +.portfolio-featured-image + .portfolio-entry-title { + margin-top: 1.0em; +} + +.portfolio-entry-title a { + border: 0; + text-decoration: none; +} + +/* Entry Meta */ +.portfolio-entry-meta { + margin: 0; + padding: 0; +} + +.portfolio-entry-title + .portfolio-entry-meta { + margin-top: 0.75em; +} + +.portfolio-entry-title + .portfolio-entry-meta:empty { + margin: 0; +} + +.portfolio-entry-meta span, +.portfolio-entry-meta a { + font-size: 0.9em; + padding: 0; +} + +.portfolio-entry-meta a { + border: 0; + text-decoration: none; +} +/* Entry Content */ +.portfolio-entry-content { + margin: 0.75em 0 0; + padding: 0; +} + +.portfolio-entry-content > :last-child { + margin: 0; +} \ No newline at end of file diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index 63c5c04ab2a06..30a47dd3b9b97 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -20,32 +20,32 @@ // PhanRedundantCondition : 70+ occurrences // PhanPossiblyUndeclaredVariable : 60+ occurrences // PhanTypeArraySuspiciousNullable : 60+ occurrences - // PhanRedefineFunction : 50+ occurrences + // PhanRedefineFunction : 55+ occurrences // PhanTypeMismatchArgumentNullable : 50+ occurrences - // PhanTypeExpectedObjectPropAccess : 45+ occurrences // PhanParamTooMany : 40+ occurrences // PhanPluginDuplicateAdjacentStatement : 40+ occurrences + // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeMismatchArgumentInternal : 40+ occurrences // PhanUndeclaredProperty : 35+ occurrences // PhanParamSignatureMismatch : 25+ occurrences - // PhanPluginSimplifyExpressionBool : 25+ occurrences // PhanTypeMismatchDefault : 25+ occurrences // PhanTypeMismatchPropertyProbablyReal : 25+ occurrences // PhanTypeMissingReturn : 25+ occurrences // PhanTypeSuspiciousNonTraversableForeach : 25+ occurrences // PhanDeprecatedProperty : 20+ occurrences + // PhanPluginSimplifyExpressionBool : 20+ occurrences // PhanTypeArraySuspicious : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanPluginMixedKeyNoKey : 15+ occurrences // PhanSuspiciousMagicConstant : 15+ occurrences // PhanTypeExpectedObjectPropAccessButGotNull : 15+ occurrences - // PhanTypeMismatchArgumentNullableInternal : 15+ occurrences // PhanTypeMismatchPropertyDefault : 15+ occurrences // PhanUndeclaredMethod : 15+ occurrences // PhanPluginDuplicateExpressionAssignmentOperation : 10+ occurrences // PhanRedefineClass : 10+ occurrences // PhanRedundantConditionInLoop : 10+ occurrences // PhanTypeInvalidDimOffset : 10+ occurrences + // PhanTypeMismatchArgumentNullableInternal : 10+ occurrences // PhanTypeMismatchProperty : 10+ occurrences // PhanTypeMismatchReturnNullable : 10+ occurrences // PhanUndeclaredFunction : 10+ occurrences @@ -56,12 +56,12 @@ // PhanTypeMismatchArgumentInternalReal : 7 occurrences // PhanCommentAbstractOnInheritedMethod : 6 occurrences // PhanDeprecatedClass : 5 occurrences - // PhanImpossibleCondition : 5 occurrences // PhanNonClassMethodCall : 5 occurrences // PhanTypeArraySuspiciousNull : 5 occurrences // PhanTypeMismatchDimAssignment : 5 occurrences // PhanTypeSuspiciousStringExpression : 5 occurrences // PhanAccessMethodInternal : 4 occurrences + // PhanImpossibleCondition : 4 occurrences // PhanTypeInvalidLeftOperandOfAdd : 4 occurrences // PhanTypeInvalidLeftOperandOfBitwiseOp : 4 occurrences // PhanTypeInvalidRightOperandOfBitwiseOp : 4 occurrences @@ -71,15 +71,12 @@ // PhanImpossibleTypeComparison : 3 occurrences // PhanPluginUnreachableCode : 3 occurrences // PhanStaticPropIsStaticType : 3 occurrences - // PhanTypeConversionFromArray : 3 occurrences // PhanTypeMismatchArgumentReal : 3 occurrences // PhanTypeObjectUnsetDeclaredProperty : 3 occurrences // PhanUndeclaredMethodInCallable : 3 occurrences - // PhanCompatibleNegativeStringOffset : 2 occurrences // PhanImpossibleConditionInLoop : 2 occurrences // PhanParamTooManyCallable : 2 occurrences // PhanPluginDuplicateSwitchCaseLooseEquality : 2 occurrences - // PhanRedefineFunctionInternal : 2 occurrences // PhanStaticCallToNonStatic : 2 occurrences // PhanTypeMismatchArgumentInternalProbablyReal : 2 occurrences // PhanUndeclaredClassInCallable : 2 occurrences @@ -87,13 +84,10 @@ // PhanDeprecatedPartiallySupportedCallable : 1 occurrence // PhanEmptyFQSENInCallable : 1 occurrence // PhanEmptyForeach : 1 occurrence - // PhanInfiniteRecursion : 1 occurrence // PhanPluginDuplicateSwitchCase : 1 occurrence // PhanPluginInvalidPregRegex : 1 occurrence - // PhanPluginRedundantAssignmentInLoop : 1 occurrence // PhanPluginUseReturnValueInternalKnown : 1 occurrence - // PhanTypeComparisonFromArray : 1 occurrence - // PhanTypeInvalidRightOperandOfNumericOp : 1 occurrence + // PhanTypeConversionFromArray : 1 occurrence // PhanTypeVoidArgument : 1 occurrence // PhanUndeclaredConstant : 1 occurrence // PhanUndeclaredExtendedClass : 1 occurrence @@ -329,6 +323,7 @@ 'modules/comments/comments.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanRedundantCondition', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanUndeclaredFunction'], 'modules/comments/subscription-modal-on-comment/class-jetpack-subscription-modal-on-comment.php' => ['PhanTypeMismatchReturnNullable'], 'modules/copy-post.php' => ['PhanNoopNew'], + 'modules/custom-content-types.php' => ['PhanRedefineFunction'], 'modules/custom-post-types/nova.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach'], 'modules/custom-post-types/portfolios.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach'], 'modules/custom-post-types/testimonial.php' => ['PhanTypeMismatchArgumentProbablyReal'], diff --git a/projects/plugins/jetpack/changelog/add-portfolios-cpt-to-classic-theme-helper-package b/projects/plugins/jetpack/changelog/add-portfolios-cpt-to-classic-theme-helper-package new file mode 100644 index 0000000000000..d62e78c8bc49c --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-portfolios-cpt-to-classic-theme-helper-package @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Classic Theme Helper: Adding Portfolio custom post type content diff --git a/projects/plugins/jetpack/modules/custom-content-types.php b/projects/plugins/jetpack/modules/custom-content-types.php index 6c3d62cabd0be..933c235806b8a 100644 --- a/projects/plugins/jetpack/modules/custom-content-types.php +++ b/projects/plugins/jetpack/modules/custom-content-types.php @@ -15,44 +15,54 @@ use Automattic\Jetpack\Redirect; -/** - * Load Portfolio CPT. - */ -function jetpack_load_custom_post_types() { - include __DIR__ . '/custom-post-types/portfolios.php'; +if ( ! function_exists( 'jetpack_load_custom_post_types' ) ) { + /** + * Load Portfolio CPT. + */ + function jetpack_load_custom_post_types() { + include __DIR__ . '/custom-post-types/portfolios.php'; + } } -/** - * Make module configurable. - */ -function jetpack_custom_post_types_loaded() { - Jetpack::enable_module_configurable( __FILE__ ); +if ( ! function_exists( 'jetpack_custom_post_types_loaded' ) ) { + /** + * Make module configurable. + */ + function jetpack_custom_post_types_loaded() { + Jetpack::enable_module_configurable( __FILE__ ); + } + add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' ); } -add_action( 'jetpack_modules_loaded', 'jetpack_custom_post_types_loaded' ); -/** - * Add Settings Section for CPT - */ -function jetpack_cpt_settings_api_init() { - add_settings_section( - 'jetpack_cpt_section', - '' . __( 'Your Custom Content Types', 'jetpack' ) . '', - 'jetpack_cpt_section_callback', - 'writing' - ); +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', + '' . __( 'Your Custom Content Types', 'jetpack' ) . '', + 'jetpack_cpt_section_callback', + 'writing' + ); + } + add_action( 'admin_init', 'jetpack_cpt_settings_api_init' ); } -add_action( 'admin_init', 'jetpack_cpt_settings_api_init' ); -/** - * Settings Description - */ -function jetpack_cpt_section_callback() { - ?> -

- - -

- +

+ + +

+