calling filters via ajax
-
I’ve created my WP ajax following the codex: http://codex.wordpress.org/AJAX_in_Plugins. I am trying to call specific filters based on user’s interaction with my admin section. Unfortunately, I haven’t been able to turn up anything on here or google about using ajax like this. Basically, when a user clicks a button, I need to set some filters to restrict upload types, among other things for the Media Upload box (Thickbox, ie tb_show()). What I have done so far is:
click function:
jQuery.post( ajaxurl, {action:'handlePDFUpload', ajaxNonce:hsciAjax.ajaxNonce}, success: function() { tb_show('Please Select Your Completed Work Plan PDF', 'media-upload.php?type=file&TB_iframe=true&file=xxx&page=xxx'); } );
(return false to stop form submission)
And the action handlePDF
add_action( 'wp_ajax_handlePDFUpload', 'handlePDFUpload' ); function handlePDFUpload() { add_filter('media_upload_tabs', 'remove_media_library_tab'); $response = json_encode(array('success' => true)); header("Content-Type: application/json"); echo $response; exit; }
Removed nonce stuff so I don’t exceed the code guidelines.
Once this is handled, I would use the tb_close or tb_remove function to remove the filters at hand. The reason for this is I have 3 different upload button in which I need the users to upload very specific files. However, the filters are completely ignored when clicked. Any help would be greatly appreciated.
- The topic ‘calling filters via ajax’ is closed to new replies.