You would need to place a globally namespaced javascript variable in your php code where you enqueue the script to be loaded for the editor pages.
So, this code will enqueue a script function to be added to the “edit post/page” screens:
add_action('admin_head','my_add_styles_admin');
function my_add_styles_admin() {
global $current_screen;
$type = $current_screen->post_type;
if (is_admin() && $type == 'post' || $type == 'page') {
?>
<script type="text/javascript">
var post_id = '<?php global $post; echo $post->ID; ?>';
</script>
<?php
}
}
Now, in your editor_plugin.js file for your tinymce button; you can access this post ID by simply calling the post_id
javascript variable.
Related Posts:
- How i can i add a split button or list box to the WordPress TinyMCE instance
- TinyMCE Anchor Button not showing
- Add Shortcode inline inside Gutenberg block
- Registering custom TinyMCE buttons, for admin area, to work with custom instances of wp_editor
- Customising the WordPress TinyMce editor and it’s buttons
- Deprecated TinyMCE API call: windowManager.createInstance(..)
- wordpress 3.5 tinymce height
- How can I control the HTML output of my post?
- TinyMCE Plugin Parameter
- TinyMce in WordPress – Getting the “fullscreen” button to stay on the right when customising button layout
- TinyMCE – Add button that changes direction of selected text
- Add a select a class dropdown in tinymce
- TinyMCE Visual Blocks plugin set Show blocks option for all users
- TinyMCE Editor change underline button behavior – u tag instead of span text-decoration underline
- TinyMCE custom plugin, how to make a word automatically selected based on current cursor position?
- More than one TinyMCE (wp_editor) with different $settings[‘drag_drop_upload’] values breaks
- Customer Support: TinyMCE stopped working (on some computers)
- Front-end image upload from TinyME [closed]
- How to disable TinyMce’s Paste plugin from turning image URLs into embedded ?
- TinyMCE Advances is removing blanks (” “)
- How to modify VisualComposer’s TinyMCE editor only for a specific shortcode
- mce_external_languages: how does it really work?
- tinymce modal and I18n strings methods
- Get the More QuickTag button back
- prevent caching during tinymce custom button development
- Add custom classes to TinyMCE generated markup
- install tinymce plugin [closed]
- How do I include a TinyMCE editor in the frontend?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Switch between Visual and HTML tab freely
- Creating a wp_editor instance with custom tinyMCE buttons
- How to add custom CSS (theme option) to TinyMCE?
- How to add “Insert/Edit link” button in custom popup tinymce window?
- Remove HTML editor and visual/HTML tabs from TinyMCE
- How to disable TinyMCE from removing span tags
- WordPress automatically adding ” “?
- Add popup window to TinyMCE buttons
- How to customize TinyMCE4 in WP 3.9 – the old way for styles and formats doesn’t work anymore
- TinyMCE editor is breaking my beautiful HTML
- How to get the input of a TinyMCE editor when using on the front-end?
- Removing buttons from the editor
- Load wp_editor via ajax [duplicate]
- Enqueue Script After TinyMCE initialized
- How to use tinyMCE for user “biographical info”?
- Why did multiple line breaks stop working in text editor?
- TinyMCE 4.x : How to customize toolbar on wp_editor()
- TinyMCE Advanced newline problem
- Stop editor from removing tags and replacing them with nbsp
- Any alternate TinyMCE4 themes / subthemes?
- Replace Taxomony Description Field with Visual/WYSIWYG Editor
- How to replace the content of tinyMCE editor in both text and visual mode using jQuery?
- Unable to add “code” button to TinyMCE toolbar
- TinyMCE format dropdown no longer showing style previews
- TinyMCE in customizer
- Possible to stop WordPress from adding p1, p2… classes to p tags in TinyMCE?
- Custom Tiny MCE button to bring up a custom php popup
- WordPress 3.2 has broken my TinyMCE code
- wp_editor disable after reaching character count limit
- When switching from html to visual editor the tag gets corrupted
- Is it possible to re-use the image details popup?
- Markup of oEmbed codes in the editor?
- Visual Tab Missing From Editor
- How to use the new Dashicons for custom TinyMCE buttons?
- Add unique class or ID information to tinyMCE
- Is it possible to create nested lists in the WYSIWYG editor?
- How can I stop TinyMCE from converting my HTML entities to characters?
- Add a button to tinyMCE editor on Custom Post Type
- How to keep non-breaking spaces in the visual editor?
- Is there a way to prevent the Editor from modifying my HTML
- Cite-Tag for blockquotes
- Wait for Gutenberg or built something in ACF?
- Replicating the_editor (Media Bar, TinyMCE, Visual/HTML Tabs) functionality without a huge rewrite
- “wp_editor” not displaying TinyMCE correctly when square brackets used in name
- HTML5, WordPress and Tiny MCE issue – wrapping anchor tag around div results in funky output
- Remove “Are You Sure” dialogue when leaving editor
- Secure Validation of wp_editor in Theme Options
- Creating a custom MCE view for your shortcodes [closed]
- Detecting when TinyMCE is “ready”
- Using a dashicon for a custom button in TinyMCE?
- Apply custom style to single word in WordPress
- How to disable TinyMCE 4 keyboard shortcuts
- How to customize the symbols that appear in the Visual Editor insert custom character
- Pasting code into pre-formatted text in Visual Editor not working in 3.3.1
- Tiny MCE not adding p tag when saving theme option
- Second toolbar in tinymce has “display:none” set?
- How to add TinyMCE keyboard shortcut
- How can the tinyMCE dom be manipulated (offical API does not seem to work)?
- How to keep a textarea and stop tinymce?
- Integrating inline tinymce editor in a component for a gutenberg block
- WordPress MultiSite Paste from Word Tool Does not work
- TinyMCE Editor Set Default Tab
- data-accordion removed in Visual Editor
- Adding TinyMCE custom buttons when using teeny_mce_before_init
- TinyMCE – Show Advanced Options (2nd Row) By Default
- Remove quicktag buttons but not Visual / Text editor and tabs
- How to make WordPress and TinyMCE accept tags wrapping block-level elements as allowed in HTML5?
- TinyMCE removes iframe attributes width and height
- TinyMCE Autoresize
- TinyMCE editor – new lines not rendered on front end
- onClick inside post_content does not appear in post tinymce editor