Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using Facebook Page Publish plugin and it adds a checkbox within the metabox submitdiv. I would like to remove that checkbox for my custom post type. Is there any way to do that using a function?

This is the function from Facebook Page Publish that is printing the checkbox:

/**
 * Renders a 'publish to facebook' checkbox. Renders the box only if 
 * the current post is a real post, not a page or something else.
 */
 function fpp_render_post_button() {
    global $post;

    $object_access_token = get_option('fpp_object_access_token');

    if (!array_pop(get_post_meta($post->ID, '_fpp_is_published'))) {
            echo '<label for="fpp_post_to_facebook"><img style="vertical-align:middle; margin:2px" src="'.FPP_BASE_URL.'publish_icon.png" alt="'.__('Publish to Facebook', FPP_TEXT_DOMAIN).'" /> '.__('Publish to Facebook', FPP_TEXT_DOMAIN).' </label><input '.(((FPP_DEFAULT_POST_TO_FACEBOOK or fpp_get_default_publishing($post)) and !empty($object_access_token)) ? 'checked="checked"' : '').' type="checkbox" value="1" id="fpp_post_to_facebook" name="fpp_post_to_facebook" '.(empty($object_access_token) ? 'disabled="disabled"' : '').' />';
    } else {
            echo '<label for="fpp_post_to_facebook"><img style="vertical-align:middle; margin:2px" src="'.FPP_BASE_URL.'publish_icon.png" alt="'.__('Publish to Facebook', FPP_TEXT_DOMAIN).'" /> '.__('Post <em>again</em> to Facebook', FPP_TEXT_DOMAIN).' </label><input type="checkbox" value="1" id="fpp_post_to_facebook" name="fpp_post_to_facebook" '.(empty($object_access_token) ? 'disabled="disabled"' : '').' />';
    }
    if (empty($object_access_token)) {
            echo '<div><em style="color:#aa6600">'.sprintf(__('Facebook Page Publish is not set up.<br />Please check your <a href="%s">plugin settings</a>.', FPP_TEXT_DOMAIN), 'options-general.php?page='.plugin_basename(__FILE__)).'</em></div>';
    }
    if ($post->post_status == "private") {
            echo '<div><em style="color:#aa6600">'.__('Private posts are not published', FPP_TEXT_DOMAIN).'</em></div>';
    }
    echo '<input type="hidden" name="fpp_send_from_admin" value="1" />';

    $error = get_option('fpp_error');
    if (!empty($error)) {
            echo '<div class="error"><strong>'.sprintf(__('Your Facebook Page Publish plugin reports an error. Please check your <a href="%s">plugin settings</a>.', FPP_TEXT_DOMAIN), 'options-general.php?page='.plugin_basename(__FILE__)).'</strong></div>';
    }

}

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

That function is used to render button and it's called inside fpp_post_submitbox_start_action(), which does some conditional check and is hooked into post_submitbox_start action.

First you need to remove plugins original action and use your own with conditional to render button. See code example below.

// Remove original action
remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );

/**
 * Renders Facebook publish button, if post type is 'post'
 * and current user has 'publish_posts' capability.
 */
function mamaduka_post_submitbox_start() {
    global $post;

    if ( 'post' == get_post_type( $post ) && current_user_can( 'publish_posts' ) )
        fpp_render_post_button();

}
add_action( 'post_submitbox_start', 'mamaduka_post_submitbox_start' );

To remove check box only from specific custom post type you can change conditional post type check, like so:

if ( 'myposttype' != get_post_type( $post ) && current_user_can( 'publish_posts' ) )
share|improve this answer
    
Do I actually need the current_user_can() check? I would like to remove it for any user. –  drtanz Sep 20 '12 at 13:32
    
Sure you can remove it, but no one can publish posts without that capability. –  Mamaduka Sep 20 '12 at 22:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.