PluginProbe ʕ •ᴥ•ʔ
Rich Showcase for Google Reviews / 6.4
Rich Showcase for Google Reviews v6.4
6.9.8 6.9.7 6.9.6 trunk 1.4 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.5 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.4 2.4.1 2.4.2 2.5 2.5.1 2.6 2.6.1 2.6.2 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.6.1 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.8.1 4.8.2 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.7.1 5.8 5.9 5.9.1 5.9.2 5.9.3 5.9.7 6.0 6.1 6.2 6.3 6.4 6.4.1 6.5 6.6 6.6.1 6.6.2 6.7 6.8 6.8.1 6.8.2 6.9 6.9.1 6.9.2 6.9.3 6.9.4 6.9.4.1 6.9.4.2 6.9.4.3 6.9.4.4 6.9.5
widget-google-reviews / includes / class-feed-block.php
widget-google-reviews / includes Last commit date
admin 10 months ago core 10 months ago class-activator.php 10 months ago class-assets.php 11 months ago class-builder-page.php 1 year ago class-deactivator.php 3 years ago class-debug-info.php 2 years ago class-feed-ajax.php 1 year ago class-feed-block.php 1 year ago class-feed-deserializer.php 11 months ago class-feed-old.php 4 years ago class-feed-page.php 11 months ago class-feed-serializer.php 2 years ago class-feed-shortcode.php 2 years ago class-feed-widget.php 4 years ago class-plugin-overview-ajax.php 1 year ago class-plugin-overview.php 11 months ago class-plugin-settings.php 10 months ago class-plugin-support.php 1 year ago class-plugin.php 11 months ago class-post-types.php 3 years ago class-reviews-cron.php 1 year ago class-settings-save.php 1 year ago class-view.php 10 months ago index.php 4 years ago page-setting-advance.php 1 year ago page-setting-fig.php 1 year ago page-setting-support.php 4 years ago
class-feed-block.php
76 lines
1 <?php
2
3 namespace WP_Rplg_Google_Reviews\Includes;
4
5 use WP_Rplg_Google_Reviews\Includes\Core\Core;
6
7 class Feed_Block {
8
9 static $name = 'grw-reviews-block';
10
11 private $core;
12 private $view;
13 private $assets;
14 private $feed_deserializer;
15
16 public function __construct(Feed_Deserializer $feed_deserializer, Core $core, View $view, Assets $assets) {
17 $this->core = $core;
18 $this->view = $view;
19 $this->assets = $assets;
20 $this->feed_deserializer = $feed_deserializer;
21 }
22
23 public function register() {
24 add_action('enqueue_block_editor_assets', [$this, 'enqueue_assets']);
25 add_action('init', [$this, 'register_block'], 999);
26 add_action('block_categories_all', [$this, 'register_category']);
27 }
28
29 public function enqueue_assets() {
30 $assets = require(GRW_PLUGIN_PATH . 'build/index.asset.php');
31
32 wp_register_script(
33 self::$name,
34 plugins_url('build/index.js', GRW_PLUGIN_FILE),
35 array('wp-block-editor', 'wp-blocks'),
36 $this->assets->version()
37 );
38
39 wp_localize_script(
40 self::$name,
41 'grwBlockData',
42 array(
43 'feeds' => $this->feed_deserializer->get_all_feeds_short(),
44 'builderUrl' => admin_url('admin.php?page=grw-builder')
45 )
46 );
47
48 wp_enqueue_script(self::$name);
49 }
50
51 public function register_block() {
52 register_block_type(GRW_PLUGIN_PATH, [
53 'editor_script' => self::$name,
54 'render_callback' => [$this, 'render'],
55 'attributes' => ['id' => ['type' => 'string']]
56 ]);
57 }
58
59 public function register_category($cats) {
60 return array_merge($cats, [['slug' => 'grw', 'title' => 'Google Reviews Block']]);
61 }
62
63 public function render($atts) {
64 if (isset($atts['id'])) {
65
66 $feed = $this->feed_deserializer->get_feed($atts['id']);
67 if (!$feed) {
68 return null;
69 }
70
71 $data = $this->core->get_reviews($feed);
72 return $this->view->render($feed->ID, $data['businesses'], $data['reviews'], $data['options']);
73 }
74 }
75 }
76