WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Widget
[resolved] Enable "Custom Post Widget" buttons eachtime tiny mce is used (18 posts)

  1. Nikoya
    Member
    Posted 9 months ago #

    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/

  2. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    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.

  3. Nikoya
    Member
    Posted 9 months ago #

    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

  4. Nikoya
    Member
    Posted 9 months ago #

    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 :)

  5. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    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

  6. Nikoya
    Member
    Posted 9 months ago #

    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.

  7. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    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.

  8. Nikoya
    Member
    Posted 9 months ago #

    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' );
  9. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    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?

  10. Nikoya
    Member
    Posted 9 months ago #

    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

  11. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    Ok great, I have released version 2.4.3.

  12. Nikoya
    Member
    Posted 9 months ago #

    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.

  13. Nikoya
    Member
    Posted 9 months ago #

    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.

  14. Johan van der Wijk
    Member
    Plugin Author

    Posted 9 months ago #

    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?

  15. Nikoya
    Member
    Posted 9 months ago #

    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 :(

  16. Johan van der Wijk
    Member
    Plugin Author

    Posted 7 months ago #

    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?

  17. Nikoya
    Member
    Posted 6 months ago #

    hey Johan

    Sorry for the response time ...

    Your last update seems to solved the issue with multiple tinyMce.

    Good work ;)

  18. Johan van der Wijk
    Member
    Plugin Author

    Posted 6 months ago #

    Thanks for letting me know!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.