wp-papi/papi

How to get started?

romanwuensche opened this issue · 4 comments

Sorry for this issue here, but I'm unable to get started with Papi. I've read your docs on the project page, installed papi as a vendor module with composer. What now? I haven't found a simple guide how to get this thing running.

I want to use papi inside a plugin. I've made a dummy "Page.php" inside my source folder which extends from \Papi_Page_Type.

<?php
namespace My\Plugin\Page;

class TestPage extends \Papi_Page_Type {
    public function meta() {
        return [
            'name'        => 'Video page',
            'description' => 'A page where you can embed videos',
            'template'    => 'pages/video-page.php'
        ];
    }
}

How do I get papi to register these classes? I've found a filter in the docs. Is this the one?

add_filter( 'papi/settings/directories', function () {
     return '/fqdn/to/plugin/src/Page';
});

Unfortunately nothing happens. I've searched in the source but a little hint would be great!

Did you install papi in vendor dir and not as a mu-plugin or a plugin? It's still a WordPress plugin even if you install it with composer so it needs to be activated. See https://roots.io/wordpress-plugins-with-composer/

The code you provided looks like it should work if the plugin is activated and if /fqdn/to/plugin/src/Page is where your page types lives.

Thanks for your reply. I had installed the plugin as a dependency inside my own plugin and called the papi-loader directly on the plugins_loaded hook. I've now moved everything out and activated the plugin manually inside wp-admin. Same result.

After some digging I've checked, if another plugin could be the problem. I had an additional plugin active for multilingual content (WPML). It seems wp-papi and WPML doesn't work together. Do you know if this isn't supported?

Papi will never have any compatibility build in with other plugins and it don't have any support for wpml or other language plugins. Papi will work with WordPress, what other plugins does isn't our problem.

You could try https://github.com/log-oscon/papi-compatibility-for-wpml if it's a wpml problem, I have no idea what that plugin does or do. I have never used wpml and will never use it.

Unfortunately this plugin doesn't seem to work with the newest version of papi. Anyway, thank for your time and your help!