1. Go to this page and download the library: Download pammel/simple-wordpress-cms 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/ */
pammel / simple-wordpress-cms example snippets
use pammel\SimpleWordpressCms\Config;
use pammel\SimpleWordpressCms\Client;
$config = (new Config())
->setWordpressUrl('https://my-wordpress.com')
->setProjectUrl('https://my-php-project.com/wp')
->setCssFolderLocal('/var/www/my-php-project/public/css')
->setCssFolderPublicUrl('/css')
;
$page = (new Client($config))->getPage('my-first-page');
use Illuminate\Support\Facades\Cache;
use pammel\SimpleWordpressCms\Client;
use pammel\SimpleWordpressCms\Config;
$slug = 'my-first-page';
$cacheKey = md5('wordpress:' . $slug);
$page = Cache::remember($cacheKey, 3600, function() use($slug){
$config = (new Config())
->setWordpressUrl('https://my-wordpress.com')
->setProjectUrl('https://my-php-project.com/wp')
->setCssFolderLocal('/var/www/my-php-project/public/css')
->setCssFolderPublicUrl('/css')
;
return (new Client($config))->getPage($slug)->preprocess();
});
# wp-content\themes\<your-theme>\function.php
...
/**
* Modify REST API content for pages to force
* shortcodes to render since Visual Composer does not
* do this
*/
add_action( 'rest_api_init', function ()
{
register_rest_field(
'page',
'content',
array(
'get_callback' => 'compasshb_do_shortcodes',
'update_callback' => null,
'schema' => null,
)
);
});
function compasshb_do_shortcodes( $object, $field_name, $request )
{
WPBMap::addAllMappedShortcodes(); // This does all the work
global $post;
$post = get_post ($object['id']);
$output['rendered'] = apply_filters( 'the_content', $post->post_content );
// EDIT: add custom CSS to $output:
$output[ 'yb_wpb_post_custom_css' ] = get_post_meta( $object[ 'id' ], '_wpb_post_custom_css', true);
return $output;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.