Skip Navigation

[Resolved] Media embed at wrong text area

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 12 replies, has 2 voices.

Last updated by rainerS 5 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1069121

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: hidden 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,

#1069424

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.

#1070010

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,

#1070051

P.S.: Have you considered my second question?

#1070227

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;
}
#1070256

Hi,

thanks. how can I set target pages to a whole custom post type or different custom post types?

Regards,

#1071463

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.

#1074847

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,

#1075060

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' );
#1075061

Sorry, I chose the wrong status for this ticket. I am updating the ticket to set the correct status.

#1076110

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,

#1076386

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' );
  }
}
#1143761

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.