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-builder-page.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-builder-page.php
185 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 $feed_inited = false;
51 $businesses = null;
52 $reviews = null;
53
54 $rate_us = get_option('grw_rate_us');
55 $authcode = get_option('grw_auth_code');
56 $api_key = get_option('grw_google_api_key');
57
58 if ($feed != null) {
59 $feed_id = $feed->ID;
60 $feed_post_title = $feed->post_title;
61 $feed_content = trim($feed->post_content);
62
63 $data = $this->core->get_reviews($feed, true);
64 $businesses = $data['businesses'];
65 $reviews = $data['reviews'];
66 $options = $data['options'];
67 if (isset($businesses) && count($businesses) || isset($reviews) && count($reviews)) {
68 $feed_inited = true;
69 }
70 }
71
72 ?>
73 <div class="grw-builder"<?php if (!$feed_inited) { ?> style="filter:blur(4px)"<?php } ?>>
74 <?php wp_nonce_field('grw_wpnonce', 'grw_nonce'); ?>
75 <form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=' . Post_Types::FEED_POST_TYPE . '_save')); ?>">
76 <input type="hidden" id="grw_post_id" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[post_id]" value="<?php echo esc_attr($feed_id); ?>">
77 <input type="hidden" id="grw_current_url" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[current_url]" value="<?php echo home_url($_SERVER['REQUEST_URI']); ?>">
78 <div class="grw-builder-workspace">
79 <div class="grw-toolbar">
80 <div class="grw-toolbar-title">
81 <input id="grw_title" class="grw-toolbar-title-input" type="text" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[title]" value="<?php if (isset($feed_post_title)) { echo $feed_post_title; } ?>" placeholder="Enter a widget name" maxlength="255" autofocus>
82 </div>
83 <div class="grw-toolbar-control">
84 <?php if ($feed_inited) { ?>
85 <label>
86 <span id="grw_sc_msg">Copy Shortcode </span>
87 <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/>
88 </label>
89 <div class="grw-toolbar-options">
90 <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>
91 </div>
92 <?php } ?>
93 <button id="grw_save" type="submit" class="button button-primary">Save & Update</button>
94 </div>
95 </div>
96 <div class="grw-builder-preview">
97 <textarea id="grw-builder-connection" name="<?php echo Post_Types::FEED_POST_TYPE; ?>[content]" style="display:none"><?php echo $feed_content; ?></textarea>
98 <div id="grw_collection_preview">
99 <?php
100 if ($feed_inited) {
101 echo $this->view->render($feed_id, $businesses, $reviews, $options, true);
102 } else {
103 ?>To show reviews in this preview, firstly connect it on the right menu (CONNECT GOOGLE) and click
104 '<b>Save & Update</b>' button. Then you can use this created widget on a sidebar or through a shortcode.<?php
105 }
106 ?>
107 </div>
108 </div>
109 </div>
110 <div id="grw-builder-option" class="grw-builder-options"></div>
111 </form>
112 </div>
113
114 <?php if (!$rate_us) { ?>
115 <div id="grw-rate_us-wrap">
116 <div id="grw-rate_us">
117 <div class="grw-rate_us-content">
118 <div class="grw-rate_us-head">
119 How's RichPlugins so far?
120 </div>
121 <div class="grw-rate_us-body">
122 Rate us clicking on the stars:
123 <?php $this->view->grw_stars(5); ?>
124 </div>
125 </div>
126 </div>
127 </div>
128 <?php } ?>
129
130 <div id="grw-rate_us-feedback" title="Thanks for your feedback!" style="display:none;">
131 <b>Please tell us how we can improve the plugin.</b>
132 <p style="font-size:16px;">
133 <span id="grw-rate_us-feedback-stars"></span>
134 </p>
135 <p style="font-size:16px;">
136 <input type="text" value="<?php global $current_user; echo $current_user->user_email; ?>" placeholder="Contact email"/>
137 </p>
138 <p style="font-size:16px;">
139 <textarea autofocus placeholder="Describe your experience and how we can improve that"></textarea>
140 </p>
141 <button class="grw-rate_us-cancel">Cancel</button><button class="grw-rate_us-send">Send</button>
142 </div>
143
144 <div id="dialog" title="Google API key required" style="display:none;">
145 <p style="font-size:16px;">
146 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.
147 </p>
148 <p style="font-size:16px;">
149 To continue working with Google API and daily reviews refreshing, please create your own API key by <a href="<?php echo 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.
150 </p>
151 <p style="font-size:16px;">
152 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.
153 </p>
154 </div>
155
156 <script>
157 jQuery(document).ready(function($) {
158 function grw_builder_init_listener(attempts) {
159 if (!window.grw_builder_init) {
160 if (attempts > 0) {
161 setTimeout(function() { grw_builder_init_listener(attempts - 1); }, 200);
162 }
163 return;
164 }
165 grw_builder_init($, {
166 el : '#grw-builder-option',
167 authcode : '<?php echo $authcode; ?>',
168 <?php if (isset($api_key) && strlen($api_key) > 0) { echo 'key: true,'; } ?>
169 <?php if (strlen($feed_content) > 0) { echo 'conns: ' . $feed_content; } ?>
170 });
171 }
172 grw_builder_init_listener(20);
173 });
174 </script>
175 <style>
176 .grw-admin .update-nag,
177 .grw-admin .wp-heading-inline,
178 .grw-admin #posts-filter {
179 display: none!important;
180 }
181 </style>
182 <?php
183 }
184 }
185