Exemplo n.º 1
0
/**
 * Save the value of `pmp_subscribe_to_updates` post meta.
 *
 * @since 0.1
 */
function pmp_subscribe_to_update_save($post_id)
{
    $pmp_guid = get_post_meta($post_id, 'pmp_guid', true);
    if (!empty($pmp_guid) && !pmp_post_is_mine($post_id)) {
        if (!isset($_POST['pmp_subscribe_to_updates'])) {
            $pmp_subscribe_to_updates = 'off';
        } else {
            $pmp_subscribe_to_updates = $_POST['pmp_subscribe_to_updates'];
        }
        update_post_meta($post_id, 'pmp_subscribe_to_updates', $pmp_subscribe_to_updates);
    }
}
Exemplo n.º 2
0
 function test_pmp_post_is_mine()
 {
     $is_mine = pmp_post_is_mine($this->post);
     $this->assertTrue($is_mine);
     $pmp_posts = pmp_get_pmp_posts();
     $pmp_post = $pmp_posts[0];
     $is_mine = pmp_post_is_mine($pmp_post->ID);
     $this->assertTrue(!$is_mine);
 }
Exemplo n.º 3
0
/**
 * Add distribution meta box if our user is a distributor
 *
 * @since 0.0.1
 */
function pmp_dist_meta_box()
{
    $screen = get_current_screen();
    if ($screen->id == 'post') {
        global $post;
        $pmp_guid = get_post_meta($post->ID, 'pmp_guid', true);
        if (!empty($pmp_guid)) {
            if (pmp_user_is_distributor_of_post($post->ID)) {
                $callback = 'pmp_distributor_options_meta_box_for_distributor';
            } else {
                if (pmp_post_is_mine($post->ID)) {
                    $callback = 'pmp_distributor_options_meta_box_for_owner';
                } else {
                    return;
                    // Do nothing if not an owner or distributor
                }
            }
            add_meta_box('pmp_distributor_options_meta', 'PMP: Distribution options', $callback, 'post', 'side');
        }
    }
}
Exemplo n.º 4
0
/**
 * Add a "Publish and push to PMP" button the post publish actions meta box.
 *
 * @param $post object the WP_Post object to use for rendering the PMP 'Push to PMP' button.
 * @since 0.2
 */
function pmp_publish_and_push_to_pmp_button($post)
{
    // Check if post is in the PMP, and if it's mine
    $pmp_guid = get_post_meta($post->ID, 'pmp_guid', true);
    $pmp_mine = pmp_post_is_mine($post->ID);
    if ($pmp_guid && !$pmp_mine) {
        return;
    }
    // Base display/disabled on post status
    $is_disabled = $post->post_status != 'publish';
    if ($is_disabled) {
        $helper_text = 'You must publish first!';
    } else {
        if (!$pmp_guid) {
            $helper_text = 'Not in PMP';
        } else {
            $helper_text = 'Post will be updated';
        }
    }
    ?>
	<div id="pmp-publish-actions">
		<p class="helper-text"><?php 
    echo $helper_text;
    ?>
</p>
<?php 
    $attrs = array('id' => 'pmp-update-push');
    if ($is_disabled) {
        $attrs['disabled'] = 'disabled';
    }
    submit_button('Push to PMP', 'large', 'pmp_update_push', false, $attrs);
    ?>
	</div>
<?php 
}