| 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.2 |
| 7 |
* Author: saas.group LLC |
| 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 |
class Juicer_Feed { |
| 29 |
|
| 30 |
public function render( $args ) { |
| 31 |
|
| 32 |
$defaults = array( |
| 33 |
'name' => 'error', |
| 34 |
); |
| 35 |
|
| 36 |
$args = wp_parse_args( $args, $defaults); |
| 37 |
|
| 38 |
$map_attributes = generate_attributes($args); |
| 39 |
|
| 40 |
$attributes = join('&', $map_attributes); |
| 41 |
|
| 42 |
wp_enqueue_script('jquery'); |
| 43 |
wp_enqueue_script( |
| 44 |
'juicerembed-' . $args['name'], |
| 45 |
'//www.juicer.io/embed/' . $args['name'] .'/wp-plugin-1-12.js?nojquery=true&' . $attributes, |
| 46 |
array('jquery'), |
| 47 |
false, |
| 48 |
# This will load the script in the footer, when the juicer-feed div is already in the DOM |
| 49 |
true |
| 50 |
); |
| 51 |
|
| 52 |
$output = '<div class="juicer-feed" data-feed-id="' . htmlspecialchars($args['name']) . '">'; |
| 53 |
|
| 54 |
$closing = (array_key_exists('paid', $args)) ? '</div>' : '<h1 class="referral"><a href="http://www.juicer.io">Powered by Juicer</a></h1></div>'; |
| 55 |
|
| 56 |
$output = $output . $closing; |
| 57 |
|
| 58 |
return $output; |
| 59 |
} |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
function generate_attributes( $array ) { |
| 64 |
$attrs = array(); |
| 65 |
|
| 66 |
foreach ( $array as $key => $val ) { |
| 67 |
if ( $key == 'name' ) { |
| 68 |
continue; |
| 69 |
} |
| 70 |
$escaped_val = htmlspecialchars($val); |
| 71 |
if (!empty($escaped_val)) { |
| 72 |
if (strpos($key, "data-") !== false) { |
| 73 |
$escaped_key = str_replace("data-", "", $key); |
| 74 |
array_push($attrs, $escaped_key . '=' . $escaped_val); |
| 75 |
} else { |
| 76 |
array_push($attrs, $key . '=' . $escaped_val); |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
return $attrs; |
| 82 |
} |
| 83 |
|
| 84 |
function juicer_feed( $args ) { |
| 85 |
$feed = new Juicer_Feed(); |
| 86 |
echo $feed->render( $args ); |
| 87 |
} |
| 88 |
|
| 89 |
function juicer_shortcode( $args ) { |
| 90 |
extract( shortcode_atts( array( |
| 91 |
'name' => 'error', |
| 92 |
), $args ) ); |
| 93 |
|
| 94 |
$feed = new Juicer_Feed(); |
| 95 |
|
| 96 |
return $feed->render( $args ); |
| 97 |
} |
| 98 |
|
| 99 |
add_shortcode( 'juicer', 'juicer_shortcode' ); |
| 100 |
|
| 101 |
|
| 102 |
////////////////////////////////// |
| 103 |
// Setup menu for admin section |
| 104 |
////////////////////////////////// |
| 105 |
function juicer_set_admin_menu() { |
| 106 |
add_options_page( |
| 107 |
esc_html__( 'Juicer', 'juicer' ), |
| 108 |
esc_html__( 'Juicer', 'juicer' ), |
| 109 |
'manage_options', |
| 110 |
'juicer-settings', |
| 111 |
'juicer_set_settings_page' |
| 112 |
); |
| 113 |
} |
| 114 |
|
| 115 |
add_action( 'admin_menu', 'juicer_set_admin_menu' ); |
| 116 |
|
| 117 |
|
| 118 |
function load_custom_wp_admin_style() { |
| 119 |
wp_enqueue_style( 'juicer-admin-css', plugin_dir_url(__FILE__) . 'includes/admin/css/' . 'admin.css', '' ); |
| 120 |
} |
| 121 |
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' ); |
| 122 |
|
| 123 |
////////////////////////////////// |
| 124 |
// Setup guide page |
| 125 |
////////////////////////////////// |
| 126 |
function juicer_set_settings_page() { |
| 127 |
include( 'includes/admin/settings.php' ); |
| 128 |
} |
| 129 |
|
| 130 |
////////////////////////////////// |
| 131 |
// Plugin setup guide link |
| 132 |
////////////////////////////////// |
| 133 |
function juicer_plugin_action_links( $links ) { |
| 134 |
$links[] = '<a href="' . admin_url( 'admin.php?page=juicer-settings' ) . '">' . __('Setup guide') . '</a>'; |
| 135 |
return $links; |
| 136 |
} |
| 137 |
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'juicer_plugin_action_links' ); |
| 138 |
|
| 139 |
?> |
| 140 |
|