PluginProbe
Juicer.io: Effortlessly embed, curate, and aggregate social media feeds into your website / 1.12.10
Juicer.io: Effortlessly embed, curate, and aggregate social media feeds into your website v1.12.10
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.10, at juicer.php

303 lines 14.4 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.10
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.10');
29
30 function get_default_juicer_atts() {
31 return array(
32 'name' => 'error'
33 );
34 }
35
36 class Juicer_Feed {
37 public function render($args) {
38 $defaults = get_default_juicer_atts();
39 $args = wp_parse_args($args, $defaults);
40
41 if ($args['name'] === 'error') {
42 return '<div class="juicer-feed" data-feed-id="error"></div>';
43 }
44
45 $map_attributes = generate_attributes($args);
46
47 $attributes = join('&', $map_attributes);
48
49 wp_enqueue_script('jquery');
50 wp_enqueue_script(
51 'juicerembed-' . $args['name'],
52 '//www.juicer.io/embed/' . $args['name'] . '/wp-plugin-1-12.js?' . $attributes,
53 array('jquery'),
54 false,
55 true
56 );
57
58 return '<div class="juicer-feed" data-feed-id="' . htmlspecialchars($args['name']) . '"></div>';
59 }
60 }
61
62 function generate_attributes($array) {
63 $attrs = array();
64
65 foreach ($array as $key => $val) {
66 if ($key == 'name') {
67 continue;
68 }
69 $escaped_val = htmlspecialchars($val);
70 if (!empty($escaped_val)) {
71 if (strpos($key, "data-") !== false) {
72 $escaped_key = str_replace("data-", "", $key);
73 array_push($attrs, $escaped_key . '=' . $escaped_val);
74 } else {
75 array_push($attrs, $key . '=' . $escaped_val);
76 }
77 }
78 }
79
80 return $attrs;
81 }
82
83 function juicer_feed($args) {
84 $feed = new Juicer_Feed();
85 echo $feed->render($args);
86 }
87
88 function juicer_shortcode($atts) {
89 $args = array(
90 'name' => sanitize_text_field($atts['name'])
91 );
92 if ($atts['per'])
93 $args['per'] = intval($atts['per']);
94 if ($atts['pages'])
95 $args['pages'] = intval($atts['pages']);
96 if ($atts['truncate'])
97 $args['truncate'] = intval($atts['truncate']);
98 if ($atts['style'])
99 $args['style'] = sanitize_text_field($atts['style']);
100 if ($atts['filter'])
101 $args['filter'] = sanitize_text_field($atts['filter']);
102 if ($atts['spacing'])
103 $args['spacing'] = sanitize_text_field($atts['spacing']);
104 if ($atts['daterange'])
105 $args['daterange'] = sanitize_text_field($atts['daterange']);
106 if ($atts['overlay'])
107 $args['overlay'] = sanitize_text_field($atts['overlay']);
108 if ($atts['after'])
109 $args['after'] = sanitize_text_field($atts['after']);
110 if ($atts['columns'])
111 $args['columns'] = intval($atts['columns']);
112
113 $defaults = get_default_juicer_atts();
114 $atts = shortcode_atts($defaults, $atts, 'juicer');
115
116 $feed = new Juicer_Feed();
117 return $feed->render($args);
118 }
119 add_shortcode('juicer', 'juicer_shortcode');
120
121 function juicer_activate() {
122 setcookie('juicer_welcome', 'true', time() + 3600, '/'); // Cookie expires in 1 hour
123 }
124 register_activation_hook(__FILE__, 'juicer_activate');
125
126 // Setup menu for admin section
127 function juicer_set_admin_menu() {
128 $hook_suffix = add_menu_page(
129 esc_html__('Juicer', 'juicer'),
130 esc_html__('Juicer', 'juicer'),
131 'manage_options',
132 'juicer-settings',
133 'juicer_set_settings_page',
134 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjIiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2MiA2NCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4LjYwOTUgMTMuNDI4NUM1MS4wMDMzIDEzLjQyODUgNTIuOTMzOCAxMS40OTggNTIuOTMzOCA5LjEwNDIzVjYuMzI0MzJDNTIuODU2NiAzLjkzMDUxIDUxLjAwMzMgMi4wMDAwMiA0OC42MDk1IDIuMDAwMDJDNDYuMjE1NyAyLjAwMDAyIDQ0LjI4NTIgMy45MzA1MSA0NC4yODUyIDYuMzI0MzJWOS4xODE0NUM0NC4yODUyIDExLjQ5OCA0Ni4yMTU3IDEzLjQyODUgNDguNjA5NSAxMy40Mjg1WiIgZmlsbD0iIzlEQTJBNyIvPgo8cGF0aCBkPSJNNTIuODU2OSA0MS4yMjc1VjIzLjAwMzdDNTIuODU2OSAyMC44NDE1IDUwLjkyNjQgMTkuMTQyNyA0OC41MzI2IDE5LjE0MjdDNDYuMTM4OCAxOS4xNDI3IDQ0LjIwODMgMjAuOTE4OCA0NC4yMDgzIDIzLjAwMzdWMzMuNDI4M1YzNS41OTA1QzQ0LjIwODMgMzcuOTg0MyA0Mi4yNzc4IDM5LjkxNDggMzkuODg0IDM5LjkxNDhDMzcuNDkwMiAzOS45MTQ4IDM1LjYzNjkgMzcuOTg0MyAzNS41NTk3IDM1LjY2NzdWMzQuODk1NVYzNC4yMDA1SDM1LjQ4MjVDMzUuMzI4IDMyLjExNTYgMzMuNTU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zLjM1MTMgMTQuMTY5NSAzMy41ODMgMTIuNzAyNCAzNC40MzI0QzEyLjM5MzUgMzUuNDM2MyAxMi4yMzkgMzYuNTk0NiAxMi4yMzkgMzguMDYxN0MxMi4yMzkgNDkuNTY3NSAyMS44MTQzIDU4LjgzMzggMzMuNzA2MSA1OC44MzM4QzM5LjM0MzEgNTguODMzOCA0NC41OTQxIDU3LjA1NzggNDguNDU1MSA1My44MTQ1QzQ5Ljk5OTUgNTEuODg0IDUxLjIzNSA0OS42NDQ3IDUyLjAwNzIgNDcuMTczNkM0My4wNDk3IDUzLjk2OSAyOS44NDUxIDUyLjg4NzkgMjMuNTEzMSA0Mi44NDkzWiIgZmlsbD0iIzlEQTJBNyIvPgo8cGF0aCBkPSJNMjEuMjc0MSA0NS45MzhDMTkuNDIwOCA0My4wMDM2IDE4Ljg4MDMgNDAuNjg3IDE4LjcyNTggMzguNzU2NUMxOC42NDg2IDM4LjQ0NzcgMTguNTcxNCAzOC4wNjE2IDE4LjU3MTQgMzcuNzUyN1YzMy41MDU2QzEzLjM5NzcgMzMuMjczOSAxMCAzNC41MDk1IDEwIDQxLjIyNzZDMTAgNTIuNzMzMyAxOS41NzUyIDYxLjk5OTcgMzEuNDY3MSA2MS45OTk3QzQxLjExOTUgNjEuOTk5NyA0OS4zMDQ4IDU1LjgyMjEgNTIuMDA3NSA0Ny4yNTA3QzQzLjEyNzIgNTYuMjg1NCAyOC4yMjM4IDU2Ljk4MDQgMjEuMjc0MSA0NS45MzhaIiBmaWxsPSIjOURBMkE3Ii8+Cjwvc3ZnPgo=',
135 99
136 );
137 }
138 add_action('admin_menu', 'juicer_set_admin_menu');
139
140 // Load custom admin CSS
141 function load_custom_wp_admin_style() {
142 wp_enqueue_style('juicer-admin-css', plugin_dir_url(__FILE__) . 'includes/admin/css/admin.css', array(), JUICER_VERSION);
143 }
144 add_action('admin_enqueue_scripts', 'load_custom_wp_admin_style');
145
146 // Load custom admin JavaScript and localize
147 function load_custom_wp_admin_script($hook_suffix) {
148 // Check if we're on the Juicer settings page or any admin page
149 if ($hook_suffix === 'toplevel_page_juicer-settings' || $hook_suffix === 'index.php') {
150 wp_enqueue_script('juicer-admin-js', plugin_dir_url(__FILE__) . 'includes/admin/js/admin.js', array('jquery'), JUICER_VERSION, true);
151
152 // Localize the script with your data
153 wp_localize_script('juicer-admin-js', 'juicer_admin', array(
154 'ajax_url' => admin_url('admin-ajax.php'),
155 'security' => wp_create_nonce('juicer_nonce')
156 ));
157 }
158 }
159 add_action('admin_enqueue_scripts', 'load_custom_wp_admin_script');
160
161 // Enqueue admin scripts and localize
162 function juicer_enqueue_admin_scripts($hook_suffix) {
163 wp_enqueue_script('juicer-admin-js', plugin_dir_url(__FILE__) . 'includes/admin/js/admin.js', array('jquery'), JUICER_VERSION, true);
164 wp_localize_script('juicer-admin-js', 'juicer', array(
165 'ajaxurl' => admin_url('admin-ajax.php'),
166 'security' => wp_create_nonce('juicer_nonce'),
167 ));
168 }
169 add_action('admin_enqueue_scripts', 'juicer_enqueue_admin_scripts');
170
171 // Setup guide page
172 function juicer_set_settings_page() {
173 include('includes/admin/settings.php');
174 }
175
176 // Plugin setup guide link
177 function juicer_plugin_action_links($links) {
178 $links[] = '<a href="' . admin_url('admin.php?page=juicer-settings') . '">' . __('Setup guide') . '</a>';
179 return $links;
180 }
181 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'juicer_plugin_action_links');
182
183 // Plugin review notice
184 // Check for feed existence and set option
185 function juicer_check_feed_existence() {
186 $host_url = home_url();
187 $response = wp_remote_get('https://www.juicer.io/api/hosts?hostname=' . $host_url);
188
189 // Default to no feeds existing
190 update_option('juicer_feed_exists', false);
191
192 if (!is_wp_error($response)) {
193 $response_code = wp_remote_retrieve_response_code($response);
194
195 if ($response_code !== 404) {
196 $body = wp_remote_retrieve_body($response);
197 $data = json_decode($body, true);
198
199 foreach ($data as $item) {
200 if (isset($item['feed_id'])) {
201 // Update the option to true as feed exists
202 update_option('juicer_feed_exists', true);
203 break;
204 }
205 }
206 }
207 }
208 }
209 add_action('admin_init', 'juicer_check_feed_existence');
210
211 // Display review notice
212 function juicer_review_notice() {
213 if (get_option('juicer_feed_exists') && juicer_should_show_review_notice()) {
214 echo '<div class="notice notice-info is-dismissible" id="juicer-review-notice">';
215 echo '<div class="juicer__notice__holder">';
216 echo '<div class="juicer__notice__col_1">';
217 echo '<img src="' . plugin_dir_url(__FILE__) . 'includes/admin/img/juicer-icon.svg" width="24" >';
218 echo '</div>';
219 echo '<div class="juicer__notice__col_2">';
220 echo '<strong class="juicer__notice__title">Thanks for using Juicer!</strong>';
221 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>';
222 echo '<div class="juicer__notice__buttons">';
223 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> ';
224 echo '<button id="juicer-maybe-later" class="juicer-notice__links">Maybe later</button> ';
225 echo '<button id="juicer-never-show" class="juicer-notice__links">Never show this again</button>';
226 echo '</div>';
227 echo '</div>';
228 echo '</div>';
229 echo '</div>';
230 }
231 }
232 add_action('admin_notices', 'juicer_review_notice');
233
234 // AJAX handler for dismissing the review notice
235 function juicer_dismiss_review_notice() {
236 check_ajax_referer('juicer_nonce', 'security');
237 if (current_user_can('manage_options')) {
238 if (isset($_POST['dismiss_type'])) {
239 $dismiss_type = sanitize_text_field($_POST['dismiss_type']);
240 if ($dismiss_type === 'permanent') {
241 // Never show again
242 update_option('juicer_review_permanently_dismissed', 'yes');
243 wp_send_json_success('Permanently dismissed.');
244 } elseif ($dismiss_type === 'temporary') {
245 // Dismiss for 7 days
246 update_option('juicer_review_dismissed', time() + 7 * DAY_IN_SECONDS);
247 wp_send_json_success('Temporarily dismissed.');
248 } else {
249 wp_send_json_error('Invalid dismiss type.');
250 }
251 } else {
252 wp_send_json_error('Dismiss type not set.');
253 }
254 } else {
255 wp_send_json_error('Permission denied.');
256 }
257 wp_die();
258 }
259 add_action('wp_ajax_juicer_dismiss_review_notice', 'juicer_dismiss_review_notice');
260
261 // Check if the review notice should be displayed
262 function juicer_should_show_review_notice() {
263 if (get_option('juicer_review_permanently_dismissed') === 'yes') {
264 return false;
265 }
266 $dismissed_until = get_option('juicer_review_dismissed');
267 if ($dismissed_until && time() < $dismissed_until) {
268 return false;
269 }
270 return true;
271 }
272
273 // Register the Elementor widget
274 function register_juicer_elementor_widget($widgets_manager) {
275 if (defined('ELEMENTOR_VERSION') && class_exists('Elementor\Widget_Base')) {
276 require_once plugin_dir_path(__FILE__) . 'includes/elementor/elementor-widget.php';
277 $widgets_manager->register(new \Elementor_Juicer_Widget());
278 }
279 }
280 add_action('elementor/widgets/register', 'register_juicer_elementor_widget');
281
282 // Enqueue custom CSS for Elementor editor
283 function enqueue_juicer_elementor_editor_styles() {
284 wp_enqueue_style(
285 'juicer-elementor-editor',
286 plugin_dir_url(__FILE__) . 'includes/elementor/juicer-elementor.css',
287 array(),
288 JUICER_VERSION
289 );
290 }
291 add_action('elementor/frontend/after_enqueue_styles', 'enqueue_juicer_elementor_editor_styles');
292 add_action('elementor/editor/after_enqueue_styles', 'enqueue_juicer_elementor_editor_styles');
293
294 function enqueue_daterangepicker() {
295 wp_enqueue_script('moment-js', 'https://cdn.jsdelivr.net/momentjs/latest/moment.min.js', array(), '2.29.1', true);
296 wp_enqueue_script('daterangepicker', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js', array('jquery', 'moment-js'), '3.1', true);
297 wp_enqueue_style('daterangepicker-css', 'https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css', array(), '3.1');
298 wp_enqueue_script('juicer-daterangepicker-init', plugin_dir_url(__FILE__) . 'includes/elementor/daterangepicker-init.js', array('jquery', 'daterangepicker'), '1.0', true);
299 }
300 add_action('elementor/editor/after_enqueue_scripts', 'enqueue_daterangepicker');
301 add_action('elementor/frontend/after_enqueue_scripts', 'enqueue_daterangepicker');
302 ?>
303