PHP code example of wiryonolau / zend-wordpress

1. Go to this page and download the library: Download wiryonolau/zend-wordpress library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wiryonolau / zend-wordpress example snippets



dWordpress = new ZendWordpress\Application();
$zendWordpress->setPluginDirectory(plugin_dir_path(__FILE__))
            ->setPluginFile(__FILE__)
            ->setRoutePrefix("my_plugin_prefix")
            ->setTablePrefix("my_db_prefix")
            ->enableSession()
            ->run();



return [
    "modules" => [
        "ZendWordpress"
    ]
];




return [
    "router" => [
        "routes" => [
            "plugin_admin_page" => [
                "type" => "WpAdminRoute",
                "options" => [
                    "route" => "/plugin_admin_page_without_route_prefix"
                    "defaults" => [
                        "controller" => "Your controller"
                        "action" => "action"
                    ]
                ]
            ]
        ]
    ]
]



# Do this
$this->url(
    "your page without namespace",
    array(
        "param1" => "your parameter"
        "param1" => "your parameter and so on"
    )
);

# Instead of this
$this->url(
    "your page without namespace",
    array(),
    array(
        "query" => array(
            "param1" => "your parameter"
            "param1" => "your parameter and so on"
        )
    )
);