Instead of requireing admin.php you just can use WP built-in ajax functionality, even if it’s not ajax in this case.
Add a hook
add_action('wp_ajax_my_plugin_function', 'my_plugin_function_callback');
Create your output function (callback)
function my_plugin_function_callback() {
// do stuff
}
Call it this way
instead of:
file : url + '/box.php',
you should be able to use the global ajaxurl:
file: ajaxurl + '?action=my_plugin_function&optional=data ...
Maybe add a nonce for security reasons, but that’s up to you 🙂
Related Posts:
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- Get page content using slug
- Where to store PHP files created by plugin / themes
- Add self-closing shortcode button to TinyMCE in WP 4.6
- What is the correct way to build a widget using OOP
- How to provide translations for a WordPress TinyMCE plugin?
- API to trigger prompt on leaving page
- Hook the Keydown Event in the TinyMCE Post Editor
- Detect a focus on wp_editor
- Has anyone managed to integrate the wp_editor inside a widget?
- How can the tinyMCE dom be manipulated (offical API does not seem to work)?
- Utilize TinyMCE hyperlink chooser outside of TinyMCE
- Two-step login process – Is it possible?
- $wp_filesystem returns NULL. What are the dependencies?
- How to store accumulate multiple option values in a single array using Options_API
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- Bridge WordPress Media API with custom tinyMCE plugin [closed]
- Admin-ajax.php appending a status code to ajax response
- WYSIWYG editor in WP 3.2 plugin
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Applying OO patterns and principles to plugin development
- the_editor() function
- TinyMCE 4.7.11 custom styles using styleselect – what does the ‘attributes’ argument do?
- Rich text editor settings persist throughout all rich text editors
- Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin
- Asynchronously render shortcodes in TinyMCE visual editor
- Add a select option of shortcodes like dropdown in tinymce
- Open modal when user clicks on span in visual editor
- tinymce.get() returns error after ajax request
- Widget HTML Display Problem
- wordpress JSONAPI introspector always limits number at 10?
- TinyMCE editor turns white on Biographical info [closed]
- Inserting code to HTML view from a pop up initiated from visual view
- Translate MCE button text/tooltip in custom plugin
- WordPress Specified file failed upload test
- Make Database query only when option is updated
- Getting a WordPress Debug Strategy
- Moving/dragging a metabox removes TinyMCE’s content
- Working of foreach loop with array
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- How can I allow the user to press enter without creating a new element in the editor?
- How to close tinymce inline popup
- Adding Permalink to Slides with ‘Simple Nivo Slider’ plugin?
- Setting a post’s category
- Why doesn’t update_post_meta work for certain strings?
- How to display TinyMCE HTML view?
- post content and shortcode content displaying out of order
- “Rendering of admin template [path to template] failed”
- How to determine which capability to use?
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- TinyMCE 4.7.11 – Enable hidden WordPress core plugins? (referencing a wp-includes from plugin.php)
- How to get values from Tinymce visual editor popup?
- foreach argument to get specific file types getting too many returns
- get_option() is undefined in TinymceWindowManager
- Add Button to TinyMCE Custom Menu
- Issue with iframe in TinyMCE
- Why if i enqueue the tinymce script i get undefined error
- Trouble using wordpress functions in a pop-up modal form
- How to show phpinfo() only in a new tab?
- External Authentication, session_tokens not destroyed on logout
- Add code inside specific wordpress standard function
- Verify if user is wordpress logged in from another app since wordpress 4.0
- plugin settings – uploading multiple files with a single button
- How to find error in my code when the error message is pointing to WP core file?
- How to select the contents in the text view textrea in wp_editor?
- SMS registration and login [closed]
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- Where to add hooks in a class
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Adding custom fields to WordPress nav menus
- Enqueueing stylesheets on particular plugin admin pages using WordPress Plugin Boilerplate
- How to customize a permalink (URL) structure?
- Adding a brand column to WooCommerce Products
- Trying to understand order and frequency of action hooks firing
- Limit role to one plugin [duplicate]
- How to fix Uninitialized string offset: error on a checkbox in WP Settings API
- Short code not working in boostrap modal dont no why?
- How To Change Post Author Default?
- What is the proper way to include Bootstrap when executing a shortcode
- WP Post Template – Templates in own folder
- Where can i find wordpress auto update code flows?
- Custom Taxonomy to dropdown box on adminside wordpress
- Upgrade private plugin without deleting files?
- Example Dashboard Widget, Cancel not working
- How to use output buffering in WordPress hooked functions?
- Woocommerce checkout update totals with datepicker
- Create a free scripts and styles template within a plugin
- Issue regarding $wpdb->prepare()
- Is there a way to list all actions registered by a plugin or theme?
- Checkbox Undefined index error in Plugin
- WordPress Plugin with a shortcode that dynamically generates javascript. Can I use add_action without wrapping the javascript in a function?
- Call wp_generate_password() from within a Class
- wp_scheduled_event being removed mysteriously
- WP_Editor – Saving Value into Plugin Option – Stripping HTML
- Getting timestamp of activation plugin time
- Howto: Use Custom Post Types as Submenu Items in Admin
- How To Prevent Certain Folder To Be Overwritten During Plugin Update?
- Sub Menu content is being duplicated
- get_query_var not works