PluginProbe
Juicer.io: Effortlessly embed, curate, and aggregate social media feeds into your website / 1.12.13
Juicer.io: Effortlessly embed, curate, and aggregate social media feeds into your website v1.12.13
1.12.18 1.12.5 1.12.6 1.12.7 1.12.8 1.12.9 1.2 1.3 1.3.1 1.4 1.4.1 1.5 1.6 1.6.1 1.7 1.7.1 1.7.2 1.8 1.9 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 All 45 releases
juicer / juicer.php

juicer.php in Juicer.io: Effortlessly embed, curate, and aggregate social media feeds into your website 1.12.13, at juicer.php

271 lines 13.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Juicer
4 * Plugin URI: https://wp.juicer.io
5 * Description: Embed, curate & aggregate social media feeds from Instagram, Twitter, TikTok, Facebook, LinkedIn, YouTube, Slack, etc. and customize them as you like.
6 * Version: 1.12.13
7 * Author: saas.group Inc.
8 * Author URI: https://saas.group
9 * License: GPLv2 or later
10 */
11
12 /*
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License
15 as published by the Free Software Foundation; either version 2
16 of the License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28 define('JUICER_VERSION', '1.12.13');
29
30 class Juicer_Feed {
31 public function render($args) {
32 $defaults = array(
33 'name' => 'error',
34 );
35 $args = wp_parse_args($args, $defaults);
36
37 $map_attributes = generate_attributes($args);
38
39 $attributes = join('&', $map_attributes);
40
41 wp_enqueue_script('jquery');
42 wp_enqueue_script(
43 'juicerembed-' . $args['name'],
44 '//www.juicer.io/embed/' . $args['name'] . '/wp-plugin-1-12.js?nojquery=true&' . $attributes,
45 array('jquery'),
46 false,
47 true
48 );
49
50 return '<div class="juicer-feed" data-feed-id="' . htmlspecialchars($args['name']) . '"></div>';
51 }
52 }
53
54 function generate_attributes($array) {
55 $attrs = array();
56
57 foreach ($array as $key => $val) {
58 if ($key == 'name') {
59 continue;
60 }
61 $escaped_val = htmlspecialchars($val);
62 if (!empty($escaped_val)) {
63 if (strpos($key, "data-") !== false) {
64 $escaped_key = str_replace("data-", "", $key);
65 array_push($attrs, $escaped_key . '=' . $escaped_val);
66 } else {
67 array_push($attrs, $key . '=' . $escaped_val);
68 }
69 }
70 }
71
72 return $attrs;
73 }
74
75 function juicer_feed($args) {
76 $feed = new Juicer_Feed();
77 echo $feed->render($args);
78 }
79
80 function juicer_shortcode($args) {
81 extract(shortcode_atts(array(
82 'name' => 'error',
83 ), $args ) );
84
85 $feed = new Juicer_Feed();
86 return $feed->render($args);
87 }
88 add_shortcode('juicer', 'juicer_shortcode');
89
90
91 function juicer_activate() {
92 setcookie('juicer_welcome', 'true', time() + 3600, '/'); // Cookie expires in 1 hour
93 }
94 register_activation_hook(__FILE__, 'juicer_activate');
95
96 // Setup menu for admin section
97 function juicer_set_admin_menu() {
98 $hook_suffix = add_menu_page(
99 esc_html__('Juicer', 'juicer'),
100 esc_html__('Juicer', 'juicer'),
101 'manage_options',
102 'juicer-settings',
103 'juicer_set_settings_page',
104 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjIiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2MiA2NCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4LjYwOTUgMTMuNDI4NUM1MS4wMDMzIDEzLjQyODUgNTIuOTMzOCAxMS40OTggNTIuOTMzOCA5LjEwNDIzVjYuMzI0MzJDNTIuODU2NiAzLjkzMDUxIDUxLjAwMzMgMi4wMDAwMiA0OC42MDk1IDIuMDAwMDJDNDYuMjE1NyAyLj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IDE4LjU3MTQgMzcuNzUyN1YzMy41MDU2QzEzLjM5NzcgMzMuMjczOSAxMCAzNC41MDk1IDEwIDQxLjIyNzZDMTAgNTIuNzMzMyAxOS41NzUyIDYxLjk5OTcgMzEuNDY3MSA2MS45OTk3QzQxLjExOTUgNjEuOTk5NyA0OS4zMDQ4IDU1LjgyMjEgNTIuMDA3NSA0Ny4yNTA3QzQzLjEyNzIgNTYuMjg1NCAyOC4yMjM4IDU2Ljk4MDQgMjEuMjc0MSA0NS45MzhaIiBmaWxsPSIjOURBMkE3Ii8+Cjwvc3ZnPgo=',
105 99
106 );
107 }
108 add_action('admin_menu', 'juicer_set_admin_menu');
109
110 // Load custom admin CSS
111 function load_custom_wp_admin_style() {
112 wp_enqueue_style('juicer-admin-css', plugin_dir_url(__FILE__) . 'includes/admin/css/admin.css', array(), JUICER_VERSION);
113 }
114 add_action('admin_enqueue_scripts', 'load_custom_wp_admin_style');
115
116 // Load custom admin JavaScript and localize
117 function load_custom_wp_admin_script($hook_suffix) {
118 // Check if we're on the Juicer settings page or any admin page
119 if ($hook_suffix === 'toplevel_page_juicer-settings' || $hook_suffix === 'index.php') {
120 wp_enqueue_script('juicer-admin-js', plugin_dir_url(__FILE__) . 'includes/admin/js/admin.js', array('jquery'), JUICER_VERSION, true);
121
122 // Localize the script with your data
123 wp_localize_script('juicer-admin-js', 'juicer_admin', array(
124 'ajax_url' => admin_url('admin-ajax.php'),
125 'security' => wp_create_nonce('juicer_nonce')
126 ));
127 }
128 }
129 add_action('admin_enqueue_scripts', 'load_custom_wp_admin_script');
130
131
132 // Setup guide page
133 function juicer_set_settings_page() {
134 include('includes/admin/settings.php');
135 }
136
137 // Plugin setup guide link
138 function juicer_plugin_action_links($links) {
139 $links[] = '<a href="' . admin_url('admin.php?page=juicer-settings') . '">' . __('Setup guide') . '</a>';
140 return $links;
141 }
142 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'juicer_plugin_action_links');
143
144 // Plugin review notice
145 // Check for feed existence and set option
146 function juicer_check_feed_existence() {
147 $host_url = home_url();
148 $response = wp_remote_get('https://www.juicer.io/api/hosts?hostname=' . $host_url);
149
150 // Default to no feeds existing
151 update_option('juicer_feed_exists', false);
152
153 if (!is_wp_error($response)) {
154 $response_code = wp_remote_retrieve_response_code($response);
155
156 if ($response_code !== 404) {
157 $body = wp_remote_retrieve_body($response);
158 $data = json_decode($body, true);
159
160 foreach ($data as $item) {
161 if (isset($item['feed_id'])) {
162 // Update the option to true as feed exists
163 update_option('juicer_feed_exists', true);
164 break;
165 }
166 }
167 }
168 }
169 }
170 add_action('admin_init', 'juicer_check_feed_existence');
171
172 // Display review notice
173 function juicer_review_notice() {
174 // Get the current screen object to check the hook suffix
175 $current_screen = get_current_screen();
176 $hook_suffix = $current_screen->base;
177
178 // Check if the current page is one of the allowed pages
179 if ($hook_suffix === 'toplevel_page_juicer-settings' || $hook_suffix === 'dashboard') {
180 if (get_option('juicer_feed_exists') && juicer_should_show_review_notice()) {
181 echo '<div class="notice notice-info is-dismissible" id="juicer-review-notice">';
182 echo '<div class="juicer__notice__holder">';
183 echo '<div class="juicer__notice__col_1">';
184 echo '<img src="' . plugin_dir_url(__FILE__) . 'includes/admin/img/juicer-icon.svg" width="24" >';
185 echo '</div>';
186 echo '<div class="juicer__notice__col_2">';
187 echo '<strong class="juicer__notice__title">Thanks for using Juicer!</strong>';
188 echo '<p class="juicer__notice__text">If you enjoy our plugin, would you consider leaving us a <strong>5-star review</strong> on Wordpress.org?</p>';
189 echo '<div class="juicer__notice__buttons">';
190 echo '<a href="https://wordpress.org/plugins/juicer/#reviews" target="_blank" id="juicer-love-it" class="button button-primary">Sure, I’d love to <img src="' . plugin_dir_url(__FILE__) . 'includes/admin/img/wp-outbound-link-icon-white.svg" width="16" height="16" ></a> ';
191 echo '<button id="juicer-maybe-later" class="juicer-notice__links">Maybe later</button> ';
192 echo '<button id="juicer-never-show" class="juicer-notice__links">Never show this again</button>';
193 echo '</div>';
194 echo '</div>';
195 echo '</div>';
196 echo '</div>';
197 }
198 }
199 }
200 add_action('admin_notices', 'juicer_review_notice');
201
202
203 // AJAX handler for dismissing the review notice
204 function juicer_dismiss_review_notice() {
205 check_ajax_referer('juicer_nonce', 'security');
206 if (current_user_can('manage_options')) {
207 if (isset($_POST['dismiss_type'])) {
208 $dismiss_type = sanitize_text_field($_POST['dismiss_type']);
209 if ($dismiss_type === 'permanent') {
210 // Never show again
211 update_option('juicer_review_permanently_dismissed', 'yes');
212 wp_send_json_success('Permanently dismissed.');
213 } elseif ($dismiss_type === 'temporary') {
214 // Dismiss for 7 days
215 update_option('juicer_review_dismissed', time() + 7 * DAY_IN_SECONDS);
216 wp_send_json_success('Temporarily dismissed.');
217 } else {
218 wp_send_json_error('Invalid dismiss type.');
219 }
220 } else {
221 wp_send_json_error('Dismiss type not set.');
222 }
223 } else {
224 wp_send_json_error('Permission denied.');
225 }
226 wp_die();
227 }
228 add_action('wp_ajax_juicer_dismiss_review_notice', 'juicer_dismiss_review_notice');
229
230 // Check if the review notice should be displayed
231 function juicer_should_show_review_notice() {
232 if (get_option('juicer_review_permanently_dismissed') === 'yes') {
233 return false;
234 }
235 $dismissed_until = get_option('juicer_review_dismissed');
236 if ($dismissed_until && time() < $dismissed_until) {
237 return false;
238 }
239 return true;
240 }
241
242 // Register the Elementor widget
243 function register_juicer_elementor_widget($widgets_manager) {
244 if (defined('ELEMENTOR_VERSION') && class_exists('Elementor\Widget_Base')) {
245 require_once plugin_dir_path(__FILE__) . 'includes/elementor/elementor-widget.php';
246 $widgets_manager->register(new \Elementor_Juicer_Widget());
247 }
248 }
249 add_action('elementor/widgets/register', 'register_juicer_elementor_widget');
250
251 // Enqueue custom CSS for Elementor editor
252 function enqueue_juicer_elementor_editor_styles() {
253 wp_enqueue_style(
254 'juicer-elementor-editor',
255 plugin_dir_url(__FILE__) . 'includes/elementor/juicer-elementor.css',
256 array(),
257 JUICER_VERSION
258 );
259 }
260 add_action('elementor/frontend/after_enqueue_styles', 'enqueue_juicer_elementor_editor_styles');
261 add_action('elementor/editor/after_enqueue_styles', 'enqueue_juicer_elementor_editor_styles');
262
263 function enqueue_daterangepicker() {
264 wp_enqueue_script('moment-js', 'https://cdn.jsdelivr.net/momentjs/latest/moment.min.js', array(), '2.29.1', true);
265 wp_enqueue_script('daterangepicker', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js', array('jquery', 'moment-js'), '3.1', true);
266 wp_enqueue_style('daterangepicker-css', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css', array(), '3.1');
267 wp_enqueue_script('juicer-daterangepicker-init', plugin_dir_url(__FILE__) . 'includes/elementor/daterangepicker-init.js', array('jquery', 'daterangepicker'), '1.0', true);
268 }
269 add_action('elementor/editor/after_enqueue_scripts', 'enqueue_daterangepicker');
270 ?>
271