Forum Replies Created

Viewing 1 replies (of 1 total)
  • I did a similiar thing in a plugin prior to 3.0 i.e. not with custom post types but as your tag suggests used ajax

    I used jQuery with a ajax request like this
    $.post(url, { action:"uon_post","cookie": encodeURIComponent(document.cookie),postId: $('#post_ID').val() ,"storytype":storytype,"ImgPath":imgPath },

    and the recieving plugin function /action like this

    add_action('wp_ajax_uon_post', 'postManagementajaxCall');
    function postManagementajaxCall()
    	{
    
    		$return="";
    
    		if(isset($_POST))
    		{
    			$filters = array
    		  (
    		  "postId" => FILTER_VALIDATE_INT,
    		  "storytype" => FILTER_SANITIZE_STRING,
    		  "ImgPath"=> FILTER_SANITIZE_STRING
    		  );
    
    			$args=filter_var_array($_POST, $filters);
    
    			global $wpdb; 
    
    			$postManagement= new PostManagement($wpdb);
    
    			echo $postManagement->processPost($args["postId"],$args["storytype"],$args["ImgPath"]); 
    
    			exit();
    		}
    	}

    The key things to note are the action name in both the jquery/javascript and php

    Hope that helps along the way a bit – feel free to ask for clarification (happy to help if I can) @sdh100shaun

Viewing 1 replies (of 1 total)