• I have custom API calls set up by adding controllers from a different directory using the following code:

    // loop through each file and include it
    	foreach ( glob( dirname( __FILE__ ) . '/api-controllers/*.php' ) as $filename ) {
    
    		// include file
    		require_once( $filename );
    
    		// make controller name lowercase
    		$filename = strtolower( $filename );
    		$filename = str_replace( '.php', '', $filename );
    		$filename = basename( $filename );
    
    		if ( $filename != 'index' ) {
    
    			// Register the source file for JSON_API_<controller name>_Controller
    			add_filter( 'json_api_' . $filename . '_controller_path', 'APS_controller_path' );
    		}
    	}
    
    	// modify the controller location so we don't have to put controllers in plugin directory
    	function APS_controller_path( $default_path ) {
    
    		// get what controller this is
    		$controller = basename( $default_path );
    
    		// set new path to controller directory
    		return dirname( __FILE__ ) . '/api-controllers/' . $controller;
    	}
    
    	// register new controlelrs to use
    	function APS_controllers( $controllers ) {
    
    		// loop through each file and setup a controller for it
    		foreach ( glob( dirname( __FILE__ ) . '/api-controllers/*.php' ) as $filename ) {
    
    			// make controller name lowercase
    			$filename = strtolower( $filename );
    			$filename = str_replace( '.php', '', $filename );
    			$filename = basename( $filename );
    
    			if ( $filename != 'index' ) {
    
    				// add our controllers to existing controllers
    				$controllers[] = $filename;
    			}
    		}
    
    		// return controllers
    		return $controllers;
    	}

    It seems after the update, none of them work. I simply get a blank white screen.

    http://wordpress.org/extend/plugins/json-api/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Maxaud

    (@maxaud)

    I reverted to 1.0.7 and I get my API calls back.

    Thread Starter Maxaud

    (@maxaud)

    My custom controllers and their methods show in the admin panel too.

    I don’t manage to get it working with version 1.1.1. The plugin documentation mentions that you can keep the controller in the theme folder – but also need to modify your theme’s function.php, which actually re-introduces the initial problem: The next update of the theme would erase it again.
    It would definitely be better if the he plugin could automatically check for a custom folder.

    Thread Starter Maxaud

    (@maxaud)

    I’ve placed my code in a plugin in the /wp-content/mu-plugins/ directory so it doesn’t get overwritten and loads just like the functions.php file from a theme.

    It’s weird because the plugin recognizes the controller in the backend but the API calls are blank and I don’t see any error codes either.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Blank pages for all custom API calls after update’ is closed to new replies.