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?
- Stop editor from removing tags and replacing them with nbsp
- Any alternate TinyMCE4 themes / subthemes?
- 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
- Add unique class or ID information to tinyMCE
- How can I stop TinyMCE from converting my HTML entities to characters?
- How to keep non-breaking spaces in the visual editor?
- Is there a way to prevent the Editor from modifying my HTML
- Remove “Are You Sure” dialogue when leaving editor
- Creating a custom MCE view for your shortcodes [closed]
- Apply custom style to single word in WordPress
- How to keep a textarea and stop tinymce?
- TinyMCE Editor Set Default Tab
- TinyMCE Autoresize
- Disable TinyMCE autoformatting
- Visual Editor freezing on text highlight since 4.3
- How to Add TinyMCE’s plugin in wordpress?
- tinyMCE.activeEditor = null WP editor loaded in ‘Text’ mode?
- Keep pasted pre formatted code as it is -with tabs- in visual editor
- How do i disable/disallow and tags in TinyMCE?
- Text cut off after the character 𪇆 in TinyMCE
- Insert text a cursor position in to TinyMCE text editor
- Using main style.css with add_editor_style
- Access tinymce from thickbox
- How can I troubleshoot why TinyMCE won’t load custom plugins in the visual editor?
- TinyMCE Editor as component in Gutenberg Block
- wp_editor on input changes content
- Set tinymce direction to rtl
- WordPress & TinyMCE: Failed to load
- How do I add a TinyMCE row that all users can see, instead of just admins?
- How to disable formatting
- Our shortcode dropdown box in Tinymce is not working in WordPress 3.9?
- How to get line breaks to translate to paragraphs?
- Localize variables with TinyMCE script
- Shift-Enter in tinyMCE (wp 3.3.1) not working
- TInyMCE object Tag stripped
- Asynchronously render shortcodes in TinyMCE visual editor
- Add a select option of shortcodes like dropdown in tinymce
- Adding a colorbutton in tinymce dialog with current api
- Adding custom styles to elements, without creating new elements
- allowing all HTML tags in tinymce editor
- tiny_mce_before_init is not trigger
- Save WYSIWYG editor plugin settings, only works after second save
- Embed iFrame in WordPress 3.0.1
- Why exactly does WordPress use p tags, not divs?
- TinyMCE: Move buttons from 2nd row to top row
- Change the background of the TinyMCE editor with available WP arguments
- When I write posts I usually have to use non breaking space element in order to keep margins in between the sentences. why?
- TinyMCE doesn’t work correctly in the Media Modal Window
- Add custom value for link_class_list for the classic editor
- How to apply padding to TinyMCE editor?
- Wordpres Tinymce custom button (Gavick guide)
- Loading a self-hosted custom @font-face into TinyMCE dropdowns (Classic Editor) via ‘tiny_mce_before_init’ filter
- WordPress, tinymce, how get the link text from dialog?
- tinymce and responsive line-breaks (short words after a period)
- How to stop TinyMce from converting image url into ?
- Client on iPad accidentally adding tag to posts while writing
- Add custom TinyMCE 4 Button: Is it mandatory to have one JS per button?
- Nested ordered list in tinymce
- Visual Editor not working properly
- wp_editor Too Tall when Content is Loaded
- TinyMCE HTML Encode Backslash
- Revealing ‘code’ hidden button in TinyMCE4 and WordPress 3.9.x
- regEx wp core file
- Adding New Row of Custom TinyMCE
- Using TinyMCE fiddle for node filter to add id attribute to anchors
- WYSIWYG with HTML source?
- How do I separate my theme’s styles from editor styles?
- Adding to he format dropdown menu tinyMCE in WordPress
- WordPress and TinyMCE Advanced: Failed to load javascript
- add button to tinymce
- Identifying first and last instance of shortcode in post