| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Juicer |
| 4 | - * Plugin URI: http://www.juicer.io | |
| 5 | - * Description: Add and embed a social media feed to your site with a shortcode. | |
| 6 | - * Version: 1.4 | |
| 7 | - * Author: Ryan MacInnes | |
| 8 | - * Author URI: http://www.goddamnyouryan.com | |
| 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.11 | |
| 7 | + * Author: saas.group LLC | |
| 8 | + * Author URI: https://saas.group | |
| 9 | 9 | * License: GPLv2 or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | /* |
| @@ -24,8 +24,9 @@ | ||
| 24 | 24 | along with this program; if not, write to the Free Software |
| 25 | 25 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | + | |
| 28 | 29 | add_action( 'wp_enqueue_scripts', 'juicer_scripts', 0 ); |
| 29 | 30 | function juicer_scripts() { |
| 30 | 31 | |
| 31 | 32 | wp_enqueue_script('jquery'); |
| @@ -49,21 +50,47 @@ | ||
| 49 | 50 | public function render( $args ) { |
| 50 | 51 | |
| 51 | 52 | $defaults = array( |
| 52 | 53 | 'name' => 'error', |
| 53 | - 'columns' => '3', | |
| 54 | - 'per' => '100', | |
| 55 | - 'pages' => '1000' | |
| 56 | 54 | ); |
| 57 | 55 | |
| 58 | 56 | $args = wp_parse_args( $args, $defaults); |
| 59 | 57 | |
| 60 | - $output = '<ul class="juicer-feed" data-feed-id="' . $args['name'] .'" data-per="' .$args['per'] . '" data-pages="' . $args['pages'] . '"><h1 class="referral"><a href="http://www.juicer.io">Powered by Juicer</a></h1></ul>'; | |
| 58 | + $map_attributes = generate_attributes($args); | |
| 61 | 59 | |
| 60 | + $attributes = join(' ', $map_attributes); | |
| 61 | + | |
| 62 | + $output = '<ul class="juicer-feed" data-origin="wp-plugin-1-11" data-feed-id="' . htmlspecialchars($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 | + | |
| 62 | 68 | return $output; |
| 63 | 69 | } |
| 70 | + | |
| 64 | 71 | } |
| 65 | 72 | |
| 73 | +function generate_attributes( $array ) { | |
| 74 | + $attrs = array(); | |
| 75 | + | |
| 76 | + foreach ( $array as $key => $val ) { | |
| 77 | + if ( $key == 'name' ) { | |
| 78 | + continue; | |
| 79 | + } | |
| 80 | + $escaped_val = htmlspecialchars($val); | |
| 81 | + if ( !empty($escaped_val) ) { | |
| 82 | + if (strpos($escaped_val, 'data-') !== false) { | |
| 83 | + array_push($attrs, $escaped_val); | |
| 84 | + } else { | |
| 85 | + array_push($attrs, 'data-' . $key . '="' . $escaped_val . '"'); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + return $attrs; | |
| 91 | +} | |
| 92 | + | |
| 66 | 93 | function juicer_feed( $args ) { |
| 67 | 94 | $feed = new Juicer_Feed(); |
| 68 | 95 | echo $feed->render( $args ); |
| 69 | 96 | } |
| @@ -70,11 +97,8 @@ | ||
| 70 | 97 | |
| 71 | 98 | function juicer_shortcode( $args ) { |
| 72 | 99 | extract( shortcode_atts( array( |
| 73 | 100 | 'name' => 'error', |
| 74 | - 'columns' => '3', | |
| 75 | - 'per' => '100', | |
| 76 | - 'pages' => '1000' | |
| 77 | 101 | ), $args ) ); |
| 78 | 102 | |
| 79 | 103 | $feed = new Juicer_Feed(); |
| 80 | 104 | |