• Resolved smoke86

    (@smoke86)


    Hi,
    I can’t correctly load your plugin and i’m getting the “The Rest API is disabled or broken” error.

    After spending some time debugging I found out that the problem may be due to the fact that in my functions.php I change the rest prefix using the following filter:

    add_filter( 'rest_url_prefix', 'my_api_slug');
    function my_api_slug( $slug ) {
        return 'api';
    }

    It seams that the rest prefix is changed after the execution of the MeowCommon_Helpers::is_rest(); therefore when you try to get the $rest_url['path'] it returns “wp-json” instead of “api”.

    As temporary fix I disabled the rest_url_prefix filter, but i need to find a way to make your plugin work with the custom rest prefix.

    Can you help me, please ?

    Best,
    A.

    • This topic was modified 4 years, 10 months ago by smoke86.
    • This topic was modified 4 years, 10 months ago by smoke86.
Viewing 1 replies (of 1 total)
  • Plugin Author Jordy Meow

    (@tigroumeow)

    Hi,

    Sorry, I am a bit busy with the plugins right now, but since you seem to know well what you are doing, maybe I can help you trying to find the right fix?

    In the core.php file of the plugin, you’ll fine those two lines:

    add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
    add_action( 'init', array( $this, 'init' ) );

    What happens if you change the first one to init instead of plugins_loaded?

    So something like that:

    add_action( 'init', array( $this, 'plugins_loaded' ) );
    add_action( 'init', array( $this, 'init' ) );

    The plugins_loaded run earlier than init. I think it might work, but I am not sure how the plugin will behave. Please give it a try 🙂

Viewing 1 replies (of 1 total)

The topic ‘REST Api init errow when changing rest URL’ is closed to new replies.