| 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.9.4 |
| 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 |
|
| 29 |
add_action( 'wp_enqueue_scripts', 'juicer_scripts', 0 ); |
| 30 |
function juicer_scripts() { |
| 31 |
|
| 32 |
wp_enqueue_script('jquery'); |
| 33 |
|
| 34 |
wp_enqueue_script( |
| 35 |
'juicerembed', |
| 36 |
'//assets.juicer.io/embed-no-jquery.js', |
| 37 |
array('jquery'), |
| 38 |
false, |
| 39 |
false |
| 40 |
); |
| 41 |
|
| 42 |
wp_enqueue_style( |
| 43 |
'juicerstyle', |
| 44 |
'//assets.juicer.io/embed.css' |
| 45 |
); |
| 46 |
} |
| 47 |
|
| 48 |
class Juicer_Feed { |
| 49 |
|
| 50 |
public function render( $args ) { |
| 51 |
|
| 52 |
$defaults = array( |
| 53 |
'name' => 'error', |
| 54 |
); |
| 55 |
|
| 56 |
$args = wp_parse_args( $args, $defaults); |
| 57 |
|
| 58 |
$map_attributes = generate_attributes($args); |
| 59 |
|
| 60 |
$attributes = join(' ', $map_attributes); |
| 61 |
|
| 62 |
$output = '<ul class="juicer-feed" data-feed-id="' . $args['name'] . '" ' . $attributes . '>'; |
| 63 |
|
| 64 |
$closing = (array_key_exists('paid', $args)) ? '</ul>' : '<h1 class="referral"><a href="http://www.juicer.io">Powered by Juicer</a></h1></ul>'; |
| 65 |
|
| 66 |
$output = $output . $closing; |
| 67 |
|
| 68 |
return $output; |
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
function generate_attributes( $array ) { |
| 74 |
$attrs = array(); |
| 75 |
|
| 76 |
foreach ( $array as $key => $val ) { |
| 77 |
if ( !empty($val) ) { |
| 78 |
if (strpos($val, 'data-') !== false) { |
| 79 |
array_push($attrs, $val); |
| 80 |
} else { |
| 81 |
array_push($attrs, 'data-' . $key . '="' . $val . '"'); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
return $attrs; |
| 87 |
} |
| 88 |
|
| 89 |
function juicer_feed( $args ) { |
| 90 |
$feed = new Juicer_Feed(); |
| 91 |
echo $feed->render( $args ); |
| 92 |
} |
| 93 |
|
| 94 |
function juicer_shortcode( $args ) { |
| 95 |
extract( shortcode_atts( array( |
| 96 |
'name' => 'error', |
| 97 |
), $args ) ); |
| 98 |
|
| 99 |
$feed = new Juicer_Feed(); |
| 100 |
|
| 101 |
return $feed->render( $args ); |
| 102 |
} |
| 103 |
|
| 104 |
add_shortcode( 'juicer', 'juicer_shortcode' ); |
| 105 |
?> |
| 106 |
|