Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

sharing_meta_box_content meta box should only get added for post types sharing is enabled for #1833

Open sc0ttkclark opened 9 years ago

sc0ttkclark commented 9 years ago

Currently, Sharedaddy does this:

function sharing_add_meta_box() {
    $post_types = get_post_types( array( 'public' => true ) );
    $title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );
    foreach( $post_types as $post_type ) {
        add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'advanced', 'high' );
    }
}

Shouldn't it be checking against the Sharing settings that enable sharing for specific post types only?

function sharing_add_meta_box() {
    $post_types = get_post_types( array( 'public' => true ) );

    $title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );

    $sharer = new Sharing_Service();
    $global_options  = $sharer->get_global_options();

    foreach( $post_types as $post_type ) {
        if ( ! in_array( $post_type, $global_options['show'] ) ) {
            continue;
        }

        add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'advanced', 'high' );
    }
}
kraftbj commented 9 years ago

There could be an odd use case for it as it is. Set to show on home/front page, not to show on Posts. On the homepage, the sharing links would display for posts, only not on single post pages.

The option is for display not enablement, per se. That said, the change makes sense to me.

sc0ttkclark commented 9 years ago

I see 'index' used elsewhere, so then this would be acceptable IMO:

function sharing_add_meta_box() {
    $post_types = get_post_types( array( 'public' => true ) );

    $title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );

    $sharer = new Sharing_Service();
    $global_options  = $sharer->get_global_options();

    foreach( $post_types as $post_type ) {
        if ( ! in_array( 'index', $global_options['show'] ) && ! in_array( $post_type, $global_options['show'] ) ) {
            continue;
        }

        add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'advanced', 'high' );
    }
}
stale[bot] commented 6 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

github-actions[bot] commented 3 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.