PHP code example of publishpress / wordpress-reviews
1. Go to this page and download the library: Download publishpress/wordpress-reviews 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/ */
publishpress / wordpress-reviews example snippets
is_admin() && current_user_can('edit_posts')
use PublishPress\WordPressReviews\ReviewsController;
class MyPlugin
{
/**
* @var ReviewsController
*/
private $reviewController;
public function __construct()
{
$this->reviewController = new ReviewsController(
'my-plugin',
'My Plugin',
MY_PLUGIN_URL . '/assets/img/logo.png'
);
}
public function init()
{
// .......
add_filter('my-plugin_wp_reviews_allow_display_notice', [$this, 'shouldDisplayBanner']);
$this->reviewController->init();
}
public function shouldDisplayBanner($shouldDisplay)
{
global $pagenow;
if (! is_admin() || ! current_user_can('edit_posts')) {
return false;
}
if ($pagenow === 'admin.php' && isset($_GET['page'])) {
if ($_GET['page'] === 'pp-page1') {
return true;
}
if ($_GET['page'] === 'pp-page2') {
return true;
}
}
if ($pagenow === 'edit.php' && isset($_GET['post_type'])) {
if ($_GET['post_type'] === 'pp_custom_post_type') {
return true;
}
}
return false;
}
// .......
}