Hi,
I´ve created custom fields for a post type called "Referenz". I´ve defined three additional wsywig editor fields. The last field is only for generating a shortcode out of the media section of wordpress.
There is one problem now: everytime I select the media gallery for embedding to the editor, the shortcode is inserted at the very first editor area instead of the editor area where I´ve clicked on media. I´ve produced a little screencast: versteckter Link
And a second question: is it possible to disable content editor buttons at a wsywig editor field? For example: Toolset View embed button, bold, link, paragraphs etc.? It would be great if there is a possibility to only display the media button at this wsywig field. Is there any php code snippet for such a case?
Thanks and regards,
Hi, as a quick test, can you temporarily deactivate Elementor and Elementor Pro and try again? In my local testing the issue seems to be resolved when I deactivate Elementor. If so, that would indicate a 3-way compatibility issue between Elementor, WP Media Folder Gallery, and Types. If you confirm the same behavior, I'll have what I need to escalate the issue.
Hi,
when I disable elementor I´ve got the same issue. Have you disabled more plugins? You can test this by your own on our site - it´s a development site only.
Regards,
P.S.: Have you considered my second question?
when I disable elementor I´ve got the same issue. Have you disabled more plugins?
Okay I see now, I can replicate this with elementor inactive now if there is more than one WYSIWYG custom field. I'll have to escalate this to my 2nd tier support team as a compatibility issue. For now, it looks like the Media Gallery insert feature is working if I switch to the "Text" tab instead of the "Visual Editor" tab in the WYSIWYG field.
is it possible to disable content editor buttons at a wsywig editor field? For example: Toolset View embed button, bold, link, paragraphs etc.?
You can remove the Toolset Fields and Views button by adding this custom code to functions.php:
function remove_toolset_buttons(){
// $post not available with init hook
$postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
$target_pages = array( 123, 456 ); // Edit for pages with CRED forms
if ( in_array( $postID, $target_pages ) ) {
// remove the Fields and Views button
add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
}
}
add_action( 'init', 'remove_toolset_buttons' );
If you want to hide the toolbar buttons, I think the best way is to use CSS. You can create custom CSS and enqueue it for the admin screens using admin_enqueue_scripts https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts. Something like this will hide the toolbar buttons in the Visual and Text tabs of the Galerie field in the Referenzen field group:
.post-type-portfolio #qt_wpcf-galerie_toolbar * {
display: none;
}
.post-type-portfolio #mceu_246 * {
display: none;
}
Hi,
thanks. how can I set target pages to a whole custom post type or different custom post types?
Regards,
You can apply whatever conditional logic you want based on knowing the $postID of the current URL. The code I provided is optimized for placement on individual posts by ID. If you want to apply the code to all posts in a single post type, you could check the post type slug of $postID against the desired post type slug, or against an array of desired post type slugs, or in a complex conditional of post IDs and post type slugs.
Hi,
thanks. The css code is very simple and I´ve set it successfully.
I´m not fully sure, how I can adapt your php script for defining whole post types to remove the toolsets buttom from the post editor. Can you show me an example please?
Regards,
Use WordPress get_post_type() to check the post type of the current post:
function remove_toolset_buttons(){
// $post not available with init hook
$postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
$postType = get_post_type($postID);
if ( $postType == 'some-cpt-slug' ) {
// remove the Fields and Views button
add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
}
}
add_action( 'init', 'remove_toolset_buttons' );
Sorry, I chose the wrong status for this ticket. I am updating the ticket to set the correct status.
Hi,
thanks. I´ve inserted your code for Referenzen (post slug: portfolio):
// Remove Toolset Buttons bei Referenzen
function remove_toolset_buttons(){
// $post not available with init hook
$postID = url_to_postid( $_SERVER['REQUEST_URI'] , '_wpg_def_keyword', true );
$postType = get_post_type($postID);
if ( $postType == 'portfolio' ) {
// remove the Fields and Views button
add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
}
}
add_action( 'init', 'remove_toolset_buttons' );
I´m seeing the toolset button at every editor (I´ve inserted 3 editors for this post type). Seems to be that your code isn´t working.
Regards,
Sorry, I gave you the code for removing the buttons in a Form. Here is the code for removing the buttons in wp-admin:
add_action( 'current_screen','remove_admin_toolset_buttons' ,9 );
function remove_admin_toolset_buttons(){
$screen = get_current_screen();
if( is_admin() && $screen->post_type == 'portfolio'){
add_filter( 'toolset_editor_add_form_buttons', '__return_false' );
}
}
My issue is resolved now. Thank you!