PluginProbe ʕ •ᴥ•ʔ
Rich Showcase for Google Reviews / 6.9.10
Rich Showcase for Google Reviews v6.9.10
6.9.10 6.9.9 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-builder-page.php
widget-google-reviews / includes Last commit date
admin 2 weeks ago core 6 days ago class-activator.php 2 weeks ago class-assets.php 2 months ago class-builder-page.php 5 months ago class-deactivator.php 3 years ago class-debug-info.php 6 months ago class-feed-ajax.php 1 year ago class-feed-block.php 2 weeks 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 9 months ago class-feed-shortcode.php 2 years ago class-feed-widget.php 8 months ago class-plugin-overview-ajax.php 1 year ago class-plugin-overview.php 6 months ago class-plugin-settings.php 3 days ago class-plugin-support.php 1 year ago class-plugin.php 2 months ago class-post-types.php 3 years ago class-reviews-cron.php 1 year ago class-settings-save.php 2 months ago class-view.php 3 days ago index.php 4 years ago page-setting-advance.php 2 weeks ago page-setting-fig.php 1 year ago page-setting-support.php 4 years ago
class-builder-page.php
193 lines
1 <?php
2
3 namespace WP_Rplg_Google_Reviews\Includes;
4
5 use WP_Rplg_Google_Reviews\Includes\Core\Core;
6 use WP_Rplg_Google_Reviews\Includes\Core\Database;
7
8 class Builder_Page {
9
10 private $view;
11 private $core;
12 private $feed_deserializer;
13
14 public function __construct(Feed_Deserializer $feed_deserializer, Core $core, View $view) {
15 $this->feed_deserializer = $feed_deserializer;
16 $this->core = $core;
17 $this->view = $view;
18 }
19
20 public function register() {
21 add_action('grw_admin_page_grw-builder', array($this, 'init'));
22 }
23
24 public function init() {
25 if (isset($_GET['grw_notice'])) {
26 $this->add_admin_notice();
27 }
28
29 $feed = null;
30 if (isset($_GET[Post_Types::FEED_POST_TYPE . '_id'])) {
31 $feed = $this->feed_deserializer->get_feed(sanitize_text_field(wp_unslash($_GET[Post_Types::FEED_POST_TYPE . '_id'])));
32 }
33
34 $this->render($feed);
35 }
36
37 public function add_admin_notice($notice_code = 0) {
38
39 }
40
41 public function render($feed) {
42 global $wp_version;
43 if (version_compare($wp_version, '3.5', '>=')) {
44 wp_enqueue_media();
45 }
46
47 $feed_id = '';
48 $feed_post_title = '';
49 $feed_content = '';
50 $decoded_content = array();
51 $feed_inited = false;
52 $businesses = null;
53 $reviews = null;
54
55 $rate_us = get_option('grw_rate_us');
56 $authcode = get_option('grw_auth_code');
57 $api_key = get_option('grw_google_api_key');
58
59 if ($feed != null) {
60 $feed_id = $feed->ID;
61 $feed_post_title = $feed->post_title;
62 $feed_content = trim($feed->post_content);
63
64 if (!empty($feed_content)) {
65 $tmp = json_decode($feed_content, true);
66 if (is_array($tmp)) {
67 $decoded_content = $tmp;
68 }
69 }
70
71 $data = $this->core->get_reviews($feed, true);
72 $businesses = $data['businesses'];
73 $reviews = $data['reviews'];
74 $options = $data['options'];
75 if (isset($businesses) && count($businesses) || isset($reviews) && count($reviews)) {
76 $feed_inited = true;
77 }
78 }
79
80 ?>
81 <div class="grw-builder">
82 <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=' . Post_Types::FEED_POST_TYPE . '_save')); ?>">
83 <?php wp_nonce_field('grw_wpnonce', 'grw_nonce'); ?>
84 <input type="hidden" id="grw_post_id" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[post_id]" value="<?php echo esc_attr($feed_id); ?>">
85 <input type="hidden" id="grw_current_url" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[current_url]" value="<?php echo home_url(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI']))); ?>">
86 <div class="grw-builder-workspace">
87 <div class="grw-toolbar">
88 <div class="grw-toolbar-title">
89 <input id="grw_title" class="grw-toolbar-title-input" type="text" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[title]" value="<?php if (!empty($feed_post_title)) echo esc_attr($feed_post_title); ?>" placeholder="Enter a widget name" maxlength="255" autofocus>
90 </div>
91 <div class="grw-toolbar-control">
92 <?php if ($feed_inited) { ?>
93 <label>
94 <span id="grw_sc_msg">Copy Shortcode </span>
95 <input id="grw_sc" type="text" value="[grw id=<?php echo esc_attr($feed_id); ?>]" data-grw-shortcode="[grw id=<?php echo esc_attr($feed_id); ?>]" onclick="this.select(); document.execCommand('copy'); window.grw_sc_msg.innerHTML = 'Shortcode Copied! Paste on page. ';" readonly/>
96 </label>
97 <div class="grw-toolbar-options">
98 <label title="Sometimes, you need to use this shortcode in PHP, for instance in header.php or footer.php files, in this case use this option"><input type="checkbox" onclick="var el = window.grw_sc; if (this.checked) { el.value = '&lt;?php echo do_shortcode( \'' + el.getAttribute('data-grw-shortcode') + '\' ); ?&gt;'; } else { el.value = el.getAttribute('data-grw-shortcode'); } el.select();document.execCommand('copy'); window.grw_sc_msg.innerHTML = 'Shortcode Copied! ';"/>Use in PHP</label>
99 </div>
100 <?php } ?>
101 <button id="grw_save" type="submit" class="button button-primary">Save & Update</button>
102 </div>
103 </div>
104 <div class="grw-builder-preview">
105 <textarea id="grw-builder-connection" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[content]" style="display:none"><?php echo esc_textarea($feed_content); ?></textarea>
106 <div id="grw_collection_preview">
107 <?php
108 if ($feed_inited) {
109 echo $this->view->render($feed_id, $businesses, $reviews, $options, true);
110 } else {
111 ?>To show reviews in this preview, firstly connect it on the right menu (CONNECT GOOGLE) and click
112 '<b>Save & Update</b>' button. Then you can use this created widget on a sidebar or through a shortcode.<?php
113 }
114 ?>
115 </div>
116 </div>
117 </div>
118 <div id="grw-builder-option" class="grw-builder-options"></div>
119 </form>
120 </div>
121
122 <?php if (!$rate_us) { ?>
123 <div id="grw-rate_us-wrap">
124 <div id="grw-rate_us">
125 <div class="grw-rate_us-content">
126 <div class="grw-rate_us-head">
127 How's RichPlugins so far?
128 </div>
129 <div class="grw-rate_us-body">
130 Rate us clicking on the stars:
131 <span class="rpi-star" data-rating="5" style="--rpi-star-size:26px;--gap:0"><i></i><i></i><i></i><i></i><i></i></span>
132 </div>
133 </div>
134 </div>
135 </div>
136 <?php } ?>
137
138 <div id="grw-rate_us-feedback" title="Thanks for your feedback!" style="display:none;">
139 <b>Please tell us how we can improve the plugin.</b>
140 <p>
141 <span class="rpi-star" data-rating="5" style="--rpi-star-size:26px;--gap:0"><i></i><i></i><i></i><i></i><i></i></span>
142 </p>
143 <p style="font-size:16px;">
144 <input type="text" value="<?php global $current_user; echo esc_attr($current_user->user_email); ?>" placeholder="Contact email"/>
145 </p>
146 <p style="font-size:16px;">
147 <textarea autofocus placeholder="Describe your experience and how we can improve that"></textarea>
148 </p>
149 <button class="grw-rate_us-cancel">Cancel</button><button class="grw-rate_us-send">Send</button>
150 </div>
151
152 <div id="dialog" title="Google API key required" style="display:none;">
153 <p style="font-size:16px;">
154 This plugin uses our default <b>Google Places API key which is mandatory for retrieving Google reviews</b> through official way approved by Google (without crawling). Our API key can make 5 requests to Google API for each WordPress server and it's exceeded at the moment.
155 </p>
156 <p style="font-size:16px;">
157 To continue working with Google API and daily reviews refreshing, please create your own API key by <a href="<?php echo esc_url(admin_url('admin.php?page=grw-support&grw_tab=fig#fig_api_key')); ?>" target="_blank">this instruction</a> and save it on the settings page of the plugin.
158 </p>
159 <p style="font-size:16px;">
160 Don’t worry, it will be free because Google is currently giving free credit a month and it should be enough to use the plugin for connecting several Google places and daily refresh of reviews.
161 </p>
162 </div>
163
164 <script>
165 jQuery(document).ready(function($) {
166 function grw_builder_init_listener(attempts) {
167 if (!window.grw_builder_init) {
168 if (attempts > 0) {
169 setTimeout(function() { grw_builder_init_listener(attempts - 1); }, 200);
170 }
171 return;
172 }
173 grw_builder_init($, {
174 el : '#grw-builder-option',
175 authcode : <?php echo wp_json_encode((string) $authcode); ?>,
176 <?php if (!empty($api_key)) echo 'key: true,'; ?>
177 <?php if (!empty($feed_content)) echo 'conns: ' . wp_json_encode($decoded_content); ?>
178 });
179 }
180 grw_builder_init_listener(20);
181 });
182 </script>
183 <style>
184 .grw-admin .update-nag,
185 .grw-admin .wp-heading-inline,
186 .grw-admin #posts-filter {
187 display: none!important;
188 }
189 </style>
190 <?php
191 }
192 }
193