• Resolved Nikoya

    (@nicolas-andre)


    Hello,

    This plugin is very helpful.

    You choose to add the popin only in ‘post.php’, ‘page.php’, ‘page-new.php’ and ‘post-new.php’.

    Why not enable the pop everywhere tinymce is enabled ?

    In this way your plugin will work on our custom admin page too.
    (like admin.php or settings.php too if needed)

    I propose to edit post-widget.php:
    Comment your last line and just add 1 line.

    // Only add content block popup action on page and post edit
    /*
     if( !defined( 'CUSTOM_POST_WIDGET_CURRENT_PAGE' ) )
    	define( 'CUSTOM_POST_WIDGET_CURRENT_PAGE', basename( $_SERVER['PHP_SELF'] ) );
    if( in_array( CUSTOM_POST_WIDGET_CURRENT_PAGE, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) {
    	add_action( 'admin_footer', 'add_content_block_popup' );
    }
    */
    
    add_filter('mce_external_plugins', 'add_content_block_popup');

    That seems to work. (all page with tinymce have your plugin working on it too)

    Thank you to share your work.

    http://wordpress.org/plugins/custom-post-widget/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Johan van der Wijk

    (@vanderwijk)

    Hi Nikoya, I have added this code to prevent the button from showing up when editing a content block (a content block inside a content block does not make much sense :)).

    If there is a specific page on which you would like the button to appear, can you send me the page name? I can then add it to the list.

    Thread Starter Nikoya

    (@nicolas-andre)

    Hey,

    thx to reply 🙂

    I understand your logic.

    Would be better to detect if we are in content_block post type ?

    than detect all other page ….

    If i’m wrong, (it’s afton the case ^^) this is the list of page that would be great to see your plugin working on it.

    admin.php and themes.php

    THx

    Thread Starter Nikoya

    (@nicolas-andre)

    i propose to add in file popup.php

    line 4

    global $current_screen;
    if( 'content_block' != $current_screen -> post_type ) {

    and close this at line 50 with :

    }

    with this, that will be load with tinymce but not in content_block post type.

    Just what we need i think 🙂

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Ok, I have changed post-widget.php to make this work (and removed 5 lines of code in the process, yay!).

    Please download this beta version and let me know if it works for you: http://downloads.wordpress.org/plugin/custom-post-widget.2.4.2.zip

    Thread Starter Nikoya

    (@nicolas-andre)

    Work great,

    but seems to load “add_content_block_popup” (admin_footer hook) function on each admin page not only on page who use tinymce.

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Yes, that is a shortcut I had to make because I don’t know if there is a specific hook for the tinymce that I can use instead. I don’t know if adding this to every admin page will cause any issues.

    Also, a lot of users disable the WYSIWYG editor and they still need to be able to insert shortcodes.

    Thread Starter Nikoya

    (@nicolas-andre)

    why not simply use media_buttons hook, like you do just before for add_content_block_icon ?

    I’ve tryed it.

    That works great, and that seems to be logic (at least in my head ^^) to call the button and the div in the same time.

    add_filter( 'media_buttons', 'add_content_block_icon' );		add_action( 'media_buttons', 'add_content_block_popup' );
    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Silly me, I never thought of doing it like that… I have updated the plugin: http://downloads.wordpress.org/plugin/custom-post-widget.2.4.3.zip

    Could you please check if it works for you?

    Thread Starter Nikoya

    (@nicolas-andre)

    I’ve check it ( v 2.4.3)

    All seems to work perfectly.

    page / post / custom post / custom settings page with tinyMce

    And don’t load div when not requiered.

    So i think it’s sooooo good 🙂

    Ty to take time to read my poor english hahahaa

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Ok great, I have released version 2.4.3.

    Thread Starter Nikoya

    (@nicolas-andre)

    ohhh found another issue now.

    If we have a custom post type with 2 tinymce or more, we have multi div with same id then we can’t use your button cause there is always the message : “choose a block”.

    I suppose we need be sure that the div is write only 1 time.

    Thread Starter Nikoya

    (@nicolas-andre)

    I suggest edit file popup.php

    start it with :

    <?php
    // Displays the lightbox popup to insert a content block shortcode to a post/page
    function add_content_block_popup() {
    	global $add_content_block_popup;
    
    	if($add_content_block_popup != true){
    
    		$add_content_block_popup = true;
    		?>

    close it with

    <?php
    	}
    };

    With this we have only 1 div and all seems to be ok.

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Mmm, that code seems a bit like a hack. I wonder if there is a more elegant way to achieve this. By the way, I have never seen an edit screen in WordPress which contains more than one instance of tinymce, is this really an issue?

    Thread Starter Nikoya

    (@nicolas-andre)

    Hi

    Custom post type or template are often used to create complexe page with multi tinyMce.

    So in my opinion it’s an issue.

    I’m totally agree with you when you say “seems a bit like a hack”.

    I think the best solution would be to create, then call this div using ajax (thickbox) and destroying this when closing it.

    But i don’t really understand how works ajax in backoffice 🙁

    Plugin Author Johan van der Wijk

    (@vanderwijk)

    Hi Nikoya,

    Today I have released V2.4.5 of the plugin in which I changed the jQuery code for insering the content block.

    Does this new version solve the issue with multiple tinyMce instances?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Enable "Custom Post Widget" buttons eachtime tiny mce is used’ is closed to new replies.