Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Gioggiolo

    (@gioggiolo)

    Thank you, i have updated to version 2.7 and it looks right.

    Thread Starter Gioggiolo

    (@gioggiolo)

    Yes, all linked children, thank you!
    I already created a plugin a bit tricky but without hacking your code.
    I think you can do better ??

    public function __construct() {
    	add_action( 'init', array($this,'action_init') );
    }
    function action_init() {
    	global $threewp_broadcast;
    	if (!$threewp_broadcast) return;
    	add_action( 'post_row_actions', array($this,'action_post_row_actions'), 9, 2 );
    	add_action( 'page_row_actions', array($this,'action_post_row_actions'), 9, 2 );
    	add_filter( 'wp_die_handler', array($this,'filter_wp_die_handler'), 100 );
    }
    private $function_wp_die_handler = null;
    function filter_wp_die_handler($func) {
    	$this->function_wp_die_handler = $func;
    	return array($this,'_default_wp_die_handler');
    }
    function action_post_row_actions($actions, $post) {
    	global $threewp_broadcast;
    	$threewp_broadcast->broadcast_data_cache()->expect_from_wp_query();
    
    	global $blog_id;
    	$broadcast_data = $threewp_broadcast->get_post_broadcast_data( $blog_id, $post->ID );
    	if ( $broadcast_data->has_linked_children() )
    		$actions = array_merge( $actions, array(
    			'broadcast_delete' => '<a href="'.wp_nonce_url("admin.php?page=threewp_broadcast&action=user_delete&post=".$post->ID."&child=".$blog_id."", 'broadcast_delete_' . $blog_id . '_' . $post->ID).'" title="'.$threewp_broadcast->_( 'Unlink and delete all the broadcasted children' ).'">'.$threewp_broadcast->_( 'Unlink&Delete' ).'</a>',
    		) );
    	return $actions;
    }
    private $in_default_wp_die_handler = false;
    function _default_wp_die_handler( $message, $title = '', $args = array() ) {
    	if ($this->in_default_wp_die_handler) {
    		call_user_func( $this->function_wp_die_handler, $message, $title, $args );
    		return;
    	}
    	$this->in_default_wp_die_handler = true;
    	if ($message=='No broadcasted child post found on this blog!') {
    		global $blog_id;
    		global $threewp_broadcast;
    		$post_id = $_GET[ 'post' ];
    		$broadcast_data = $threewp_broadcast->get_post_broadcast_data( $blog_id, $post_id );
    		$linked_children = $broadcast_data->get_linked_children();
    		foreach( $linked_children as $child_blog_id => $broadcasted_post_id)
    		{
    			switch_to_blog( $child_blog_id );
    			$broadcasted_post_id = $broadcast_data->get_linked_child_on_this_blog();
    			if ( $broadcasted_post_id === null )
    				wp_die( 'No broadcasted child post found on this blog!' );
    			wp_delete_post( $broadcasted_post_id, true );
    			restore_current_blog();
    		}
    		return;
    	}
    	call_user_func( $this->function_wp_die_handler, $message, $title, $args );
    	$this->in_default_wp_die_handler = false;
    }

    Thread Starter Gioggiolo

    (@gioggiolo)

    Hello, i have just installed last version and i re-wrote my plugin using “threewp_broadcast_get_user_writable_blogs” filter.

    I noticed you added delete command and it works very well but it deletes a child. I’d want also a global command (under post_row_actions) that deletes all children.

    Thread Starter Gioggiolo

    (@gioggiolo)

    About delete, I solved adding a hook:

    public function delete_post_broadcast_data( $blog_id, $post_id)
    {
    	$this->sql_delete_broadcast_data( $blog_id, $post_id );
    	do_action( 'threewp_after_delete_post_broadcast_data', $blog_id, $post_id);
    }

    And so I created a custom plugin:

    public function __construct() {
    	add_action('threewp_after_delete_post_broadcast_data', array($this,'action_threewp_after_delete_post_broadcast_data'), 100, 2 );
    }
    function action_threewp_after_delete_post_broadcast_data($blog_id, $post_id) {
    	global $threewp_broadcast;
    	remove_action('delete_post',array($threewp_broadcast,'delete_post'));
    	remove_action('delete_page',array($threewp_broadcast,'delete_post'));
    	switch_to_blog($blog_id);
    	wp_delete_post( $post_id, true );
    	restore_current_blog();
    	add_action('delete_post',array($threewp_broadcast,'delete_post'));
    	add_action('delete_page',array($threewp_broadcast,'delete_post'));
    }

    Thread Starter Gioggiolo

    (@gioggiolo)

    Thank you for your quick answer ??

    I think the delete command is really useful when a post has to be deleted from many blog.

    About the blogs hook, it’s necessary another one:

    public function get_blog_list()
    {
    	$blogs = apply_filters( 'threewp_before_get_blog_list', false, get_current_user_id());
    	if ($blogs !== false) return $blogs;
    ....

    Besides I noticed that I can’t unlink a blog from the meta_box. If I uncheck a blog, it’s still checked(and linked) after saved the post. Instead it’s all right if I unlink a blog from the posts list.

    No, i have a wpzoom theme.
    I have no problems using Admin user, while it happens using Editors and Contributors… maybe Authors.
    I have set:
    Editors can: manage users and all posts.
    Contributors can: manage all posts.
    Authors can: manage all their posts.

    I have restricted just a category (called Staff) with following settings:
    Post Reader Restricted for category
    Private Post Reader Restricted for category
    Post Contributor (Unrestricted by default)
    Post Author Restricted for category
    Post Editor (Unrestricted by default)
    Category Manager Restricted for category
    Category Assigner Restricted for category

    Anyway i temporally solved disabling the autosave.

    Same problem here. I will try to find the cause

Viewing 7 replies - 1 through 7 (of 7 total)