| 1 |
<?php |
| 2 |
/** |
| 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.1 |
| 7 |
* Author: Ryan MacInnes |
| 8 |
* Author URI: http://www.goddamnyouryan.com |
| 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 |
add_action( 'wp_enqueue_scripts', 'juicer_scripts', 0 ); |
| 29 |
function juicer_scripts() { |
| 30 |
|
| 31 |
wp_enqueue_script('jquery'); |
| 32 |
|
| 33 |
wp_enqueue_script( |
| 34 |
'juicerembed', |
| 35 |
'//assets.juicer.io/embed-no-jquery.js', |
| 36 |
array('jquery'), |
| 37 |
false, |
| 38 |
false |
| 39 |
); |
| 40 |
|
| 41 |
wp_enqueue_style( |
| 42 |
'juicerstyle', |
| 43 |
'//assets.juicer.io/embed.css' |
| 44 |
); |
| 45 |
} |
| 46 |
|
| 47 |
class Juicer_Feed { |
| 48 |
|
| 49 |
public function render( $args ) { |
| 50 |
|
| 51 |
$defaults = array( |
| 52 |
'name' => 'error', |
| 53 |
'columns' => '3', |
| 54 |
'per' => '100', |
| 55 |
'pages' => NULL |
| 56 |
); |
| 57 |
|
| 58 |
$args = wp_parse_args( $args, $defaults); |
| 59 |
|
| 60 |
if ( is_null($args['pages']) ) { |
| 61 |
$output = '<ul class="juicer-feed" data-feed-id="' . $args['name'] .'" data-per="' .$args['per'] . '"><h1 class="referral"><a href="http://www.juicer.io">Powered by Juicer</a></h1></ul>'; |
| 62 |
} else { |
| 63 |
$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>'; |
| 64 |
}; |
| 65 |
|
| 66 |
return $output; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
function juicer_feed( $args ) { |
| 71 |
$feed = new Juicer_Feed(); |
| 72 |
echo $feed->render( $args ); |
| 73 |
} |
| 74 |
|
| 75 |
function juicer_shortcode( $args ) { |
| 76 |
extract( shortcode_atts( array( |
| 77 |
'name' => 'error', |
| 78 |
'columns' => '3', |
| 79 |
'per' => '100', |
| 80 |
'pages' => '1000' |
| 81 |
), $args ) ); |
| 82 |
|
| 83 |
$feed = new Juicer_Feed(); |
| 84 |
|
| 85 |
return $feed->render( $args ); |
| 86 |
} |
| 87 |
|
| 88 |
add_shortcode( 'juicer', 'juicer_shortcode' ); |
| 89 |
?> |
| 90 |
|