Απαντήσεις συζητήσεων που έγιναν

Επισκόπηση 1 απαντήσεων (από 1 συνολικά)
  • Χαίρετε,

    το συγκεκριμένο θέμα είναι κάπως πολύπλοκο να επιλυθεί καθώς απαιτεί τη προσθήκη κώδικα στο αρχείο functions.php του child του θέματός που χρησιμοποιείς.

    
    //φτιάχνουμε το function cc_gutenberg_panels
    function cc_gutenberg_panels() {
    	global $current_user; //φορτώνουμε τον τρέχοντα χρήστη
    	if ($current_user->roles == "subscriber") { //ελέγχουμε αν ο χρήστης έχει ρόλο συνδρομητή ή ότι άλλο θέλουμε. επίσης μπορούμε να ελέγξουμε και με το username $current_user->user_login;
       ?><script> //για την απενεργοποίηση των διαφόρων πάνελ πρέπει να χρησιμοποιήσουμε javasript
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'taxonomy-panel-category' ) ; //για το πάνελ category
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'taxonomy-panel-post_tag' ); //για το πάνελ tags
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'featured-image' ); //για το πάνελ featured image
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-link' ); //για το πάνελ permalink
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'page-attributes' ); //για το πάνελ page attributes
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-excerpt' ); //για το πάνελ Excerpt
    	wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'discussion-panel' ); //για το πάνελ Discussion
    </script><?php
    	}
    }
    add_action( 'init', 'cc_gutenberg_panels' ); //λέμε στο wordpress να φορτώσει τον κώδικα που γράψαμε
    

    Η απάντηση έχει βασιστεί στο post https://wordpress.stackexchange.com/questions/339436/removing-panels-meta-boxes-in-the-block-editor .

Επισκόπηση 1 απαντήσεων (από 1 συνολικά)