Forum Replies Created

Viewing 15 replies - 1 through 15 (of 57 total)
  • I suggest the following correction in file Mlp_Translation_Metabox.php:

    private function is_translatable_by_user( WP_Post $post, $blog_id ) {
    		$blog_id = absint( $blog_id );
    
    		$post_type = get_post_type( $post );
    		if( $post_type === FALSE )
    		{
    			return FALSE;
    		}
    
    		$remote_post = $this->data->get_remote_post( $post, $blog_id );
    		if ( isset( $remote_post->dummy ) && $remote_post->dummy === TRUE ) {
    			return current_user_can_for_blog( $blog_id, 'publish_' . $post_type . 's' );
    			//return current_user_can_for_blog( $blog_id, 'publish' );
    		}
    		//return current_user_can_for_blog( $blog_id, 'edit_post', $remote_post->ID );
    		return current_user_can_for_blog( $blog_id, 'edit_' . $post_type . 's', $remote_post->ID );
    	}

    Original lines are commented.
    That way it works perfectly. It corrects the capability “edit_post” to “edit_posts”, and also enables the translation for pages and custom post types.

    I just found that there is no documented “publish” capability.
    If I replace the line:
    return current_user_can_for_blog( $blog_id, 'publish' );
    By:
    return current_user_can_for_blog( $blog_id, 'publish_post' );

    Then suddenly the administrator can translate!

    current_user_can_for_blog( $blog_id, ‘publish’ ) works for super admins because it returns always true for them:

    wp-includes/capabilities.php

    1044	                // Multisite super admin has all caps by definition, Unless specifically denied.
    1045	                if ( is_multisite() && is_super_admin( $this->ID ) ) {
    1046	                        if ( in_array('do_not_allow', $caps) )
    1047	                                return false;
    1048	                        return true;
    1049	                }

    So I think solution for this bug is to use publish_post and publish_page capabilities.

    I just checked: it appears that all the non super-admin administrators cannot display the meta box and do not have the option to do so. As soon as I grant super admin privilege on one particular user, this user suddenly have access to multilingualpress.

    And I think current_user_can_for_blog returns an empty array, not NULL.

    The user is administrator on all the sites.

    As for my debugging code, you will find it below:

    public function register_meta_boxes( $post_type, WP_Post $post ) {
    
    		echo "Gab-MultilingualPress: enter register_meta_boxes\n";
    
    		if ( ! in_array( $post_type, $this->allowed_post_types ) ) {
    		  echo  "Gab-MultilingualPress: post is not in allowed_post_types\n";
    			return;
    		}
    
    		$current_blog_id = get_current_blog_id();
    		$site_relations = $this->plugin_data->get( 'site_relations' );
    		$related_blogs = $site_relations->get_related_sites( $current_blog_id, FALSE );
    
    		if ( empty( $related_blogs ) ) {
    		  echo "Gab-MultilingualPress: empty related_blogs\n";
    			return;
    		}
    
    		foreach ( $related_blogs as $blog_id ) {
    			// Do not allow translations if the user is lacking capabilities for the remote blog
    			if ( ! $this->is_translatable_by_user( $post, $blog_id ) ) {
    			  echo "Gab-MultilingualPress: $blog_id is not translatable\n";
    				continue;
    			}
    
    			if ( $current_blog_id !== (int) $blog_id ) {
    				$this->register_metabox_per_language( $blog_id, $post );
    				echo "Gab-MultilingualPress: register_metabox_per_language $blog_id\n";
    			}
    			else
    			{
    				echo "Gab-MultilingualPress: current_blog_id == $blog_id\n";
    			}
    		}
    
    		$assets = $this->plugin_data->get( 'assets' );
    		$assets->provide( array( 'mlp_admin_js', 'mlp_admin_css' ) );
    
    		echo "Gab-MultilingualPress: exit register_meta_boxes\n";
    	}
    
    	/**
    	 * Check if the current user has the appropriate capabilities to edit the given post.
    	 *
    	 * @param WP_Post $post
    	 * @param int     $blog_id
    	 *
    	 * @return bool
    	 */
    	private function is_translatable_by_user( WP_Post $post, $blog_id ) {
    
    		$blog_id = absint( $blog_id );
    
    		$remote_post = $this->data->get_remote_post( $post, $blog_id );
    		if ( isset( $remote_post->dummy ) && $remote_post->dummy === TRUE ) {
    		  echo "Gab-MultilingualPress: current_user_can_for_blog publish" . current_user_can_for_blog( $blog_id, 'publish' ) . "\n";
    			return current_user_can_for_blog( $blog_id, 'publish' );
    		}
    
    		echo "Gab-MultilingualPress: current_user_can_for_blog edit_post" . current_user_can_for_blog( $blog_id, 'edit_post', $remote_post->ID ) . "\n";
    		return current_user_can_for_blog( $blog_id, 'edit_post', $remote_post->ID );
    	}

    That was just simple debugging, I haven’t made it very beautiful 🙂

    I added some tracing text.

    Normal administrators get :

    Gab-MultilingualPress: enter register_meta_boxes
    Gab-MultilingualPress: current_user_can_for_blog publish true
    Gab-MultilingualPress: register_metabox_per_language 1
    Gab-MultilingualPress: exit register_meta_boxes

    But this administrator get :

    Gab-MultilingualPress: enter register_meta_boxes
    Gab-MultilingualPress: current_user_can_for_blog publish
    Gab-MultilingualPress: 1 is not translatable
    Gab-MultilingualPress: exit register_meta_boxes

    So, current_user_can_for_blog returns nothing (not false) in the following line:
    return current_user_can_for_blog( $blog_id, 'publish' );
    of file: Mlp_Translation_Metabox.php

    That’s really weird.

    I tried to network-deactivate the plugins except multilingualpress but still no luck. I tried to change the user role to something else then back to administrator, and that does not change. I’ll try to find what’s wrong.

    I have a similar problem. For a user, the translation box does not show, neither in Screen options, and below the post tinyMCE.

    I tried your plugin mlp-force-metabox-visibility but it still does not show.

    My website is multisite and all users are Administrator role with the default Administrator capabilities.
    The problematic user has been created a few days after the installation of MultilingualPress.
    Enabling the MULTILINGUALPRESS_DEBUG constant of the plugin does not show anything in the error_log file.
    I’ve tried to look into the file Mlp_Translation_Metabox in the hope I could find something obvious, but couldn’t.
    MultilingualPress is latest version, theme is hueman, wordpress is 4.3.

    Thanks for any help !

    Plugin Author GabSoftware

    (@gabsoftware)

    Thanks!

    I take good notes of your suggestions for a next release. However I cannot give any ETA as all my plugin development is mostly frozen due to lack of time. I will update, just don’t know exactly when 🙂

    Plugin Author GabSoftware

    (@gabsoftware)

    No I haven’t abandoned it yet, it’s just on hold since I came back to France for a job. I currently have less free time because of that job and my wife needs me more in France because she doesn’t speak French yet. I have big plans for Counterize, including a complete rewrite that would not use too much DB space and a more modern UI with nice looking charts. Same for most of my plugins, I hope that I can get some free time to continue their development.

    By the way, SlimStat is a very nice plugin, I already recommended it in another post to someone who was disappointed in Counterize.

    Plugin Author GabSoftware

    (@gabsoftware)

    Hi Sorina,

    Sorry for the issues. I currently do not have enough free time to solve all the problems of Counterize, so I suggest you switch to another stats plugin like for example WP SlipStat.

    Cheers,

    Gabriel

    Plugin Author GabSoftware

    (@gabsoftware)

    FNGeditor: Fixed in release 3.1.4.

    Camu: Please do not advertise your own plugin in my support forum. Thanks 🙂

    Plugin Author GabSoftware

    (@gabsoftware)

    I’m sorry but I don’t understand the problem. What are you trying to achieve?

    Plugin Author GabSoftware

    (@gabsoftware)

    Hi all,

    A fix has been released to address this particular issue.

    The development of Counterize is currently on hold because I don’t have much free time currently.

    Thank you for using Counterize and have a nice day!

    Gabriel

    Plugin Author GabSoftware

    (@gabsoftware)

    Hi,

    It’s a known problem. Still thank you for reporting this and sorry for the inconvenience.

    Gabriel

Viewing 15 replies - 1 through 15 (of 57 total)