Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Indeed I was using a very old "plugin template" before wordpress had the $instance call. so people used to make their own instances, wich is what I was doing. I've cleaned up my code and got it working. The only problem I encountered is that my css won't work in the plugin once jQuery takes over. But that is a different question. here is my fix</p> <pre><code> &lt;?php /* Plugin Name: Yelp Reviews Ticker Plugin URI: http://wordpress.org/extend/plugins/ Description: This reviews ticker allows you to show your yelp reviews and also customize its display to your taste in a easy manner Version: 0.5 Author: Flavio Domeneck Jr Author URI: http://www.flaviotreeservice.com/ License: GPL2 Copyright 2013 FDJ (email : contactflavio@gmail.com ) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class yrtWidget extends WP_Widget { function yrtWidget() { parent::__construct( false, 'Yelp Reviews Ticker', array( 'description' =&gt; "Yelp Reviews Ticker shows your yelp reviews cleanly and pain free" ) ); } function widget( $args, $instance ) { extract($args); echo $before_widget; echo $before_title.$instance['title'].$after_title; // // Partially from // http://non-diligent.com/articles/yelp-apiv2-php-example/ // https://github.com/Yelp/yelp-api/blob/master/v2/php/example.php // // Enter the path that the oauth library is in relation to the php file require_once ('lib/OAuth.php'); // Set instance values $speed = $instance['speed']; $pause = $instance['pause']; $showitems = $instance['showitems']; $animation = $instance['animation']; $mousepause = $instance['mousepause']; $direction = $instance['direction']; $yelp_url = $instance['yelp_url']; $unsigned_url = $instance['unsigned_url']; $consumer_key = $instance['consumer_key']; $consumer_secret = $instance['consumer_secret']; $token = $instance['token']; $token_secret = $instance['token_secret']; // Token object built using the OAuth library $token = new OAuthToken($token, $token_secret); // Consumer object built using the OAuth library $consumer = new OAuthConsumer($consumer_key, $consumer_secret); // Yelp uses HMAC SHA1 encoding $signature_method = new OAuthSignatureMethod_HMAC_SHA1(); // Build OAuth Request using the OAuth PHP library. Uses the consumer and token object created above. $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url); // Sign the request $oauthrequest-&gt;sign_request($signature_method, $consumer, $token); // Get the signed URL $signed_url = $oauthrequest-&gt;to_url(); // Send Yelp API Call $ch = curl_init($signed_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); // Yelp response curl_close($ch); // Handle Yelp response data $response = json_decode($data); $arr = (array) $response; if(is_array($arr['reviews'])){ ?&gt; &lt;!-- Start Yelp Reviews Ticker --&gt; &lt;script type="text/javascript"&gt; $(function(){ $('#yelp-review-ticker').vTicker({ &lt;? echo " speed: " . $instance['speed'] . ",\n"; echo " pause: " . $instance['pause'] . ",\n"; echo " animation: '" . $instance['animation'] . "',\n"; echo " mousePause: " . $instance['mousepause'] . ",\n"; echo " direction: '" . $instance['direction'] . "',\n"; echo " showItems: " . $instance['showitems'] . "\n"; ?&gt; }); }); &lt;/script&gt; &lt;!-- End Yelp Reviews Ticker --&gt; &lt;div id="yelp-review-ticker"&gt;&lt;ul&gt; &lt;? foreach($arr['reviews'] as $review){ ?&gt; &lt;li&gt; &lt;table&gt; &lt;tr&gt; &lt;td style="text-align:center; padding:5px; font-size:90%"&gt; &lt;? echo " &lt;img src=\"" . $review-&gt;user-&gt;image_url . "\" width=\"60px\"/&gt;\n"; echo " &lt;br /&gt;" . $review-&gt;user-&gt;name . "\n"; echo " &lt;br /&gt;&lt;img src=\"" . $review-&gt;rating_image_small_url . "\" /&gt;\n"; ?&gt; &lt;/td&gt; &lt;td&gt; &lt;? echo " &lt;p&gt;" . $review-&gt;excerpt . "&lt;/p&gt;\n"; echo " &lt;div style=\"text-align:right; font-size:80%;\"&gt;&lt;a href=\"" . $instance['yelp_url'] . "\" target=\"_blank\"&gt; " . gmdate("m/d/Y", $review-&gt;time_created) . " more at \n"; echo " &lt;img src=\"http://s3-media1.ak.yelpcdn.com/assets/2/www/img/14f29ad24935/map/miniMapLogo.png\"/&gt;&lt;/a&gt;\n"; ?&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/li&gt; &lt;? } ?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;? } echo $after_widget; } // End function widget. function yrtWidget_header(){ // jQuery vTicker from // http://www.jugbit.com/jquery-vticker-vertical-news-ticker/ echo ' &lt;script type="text/javascript" src="' . plugins_url( 'lib/jquery-1.8.3.min.js' , __FILE__ ) . '"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="' . plugins_url( 'lib/jquery.vticker-min.js' , __FILE__ ) . '"&gt;&lt;/script&gt; &lt;style type="text/css" media="all" src="' . plugins_url( 'css/yelprt.css' , __FILE__ ) . '"&gt;&lt;/style&gt; '; } // Updates the settings. function update( $new_instance, $old_instance ) { return $new_instance; } function form( $instance ) { //&lt;- set default parameters of widget if($instance){ $title = $instance['title']; $speed = $instance['speed']; $pause = $instance['pause']; $showitems = $instance['showitems']; $animation = $instance['animation']; $mousepause = $instance['mousepause']; $direction = $instance['direction']; $yelp_url = $instance['yelp_url']; $unsigned_url = $instance['unsigned_url']; $consumer_key = $instance['consumer_key']; $consumer_secret = $instance['consumer_secret']; $token = $instance['token']; $token_secret = $instance['token_secret']; } else{ $title = 'Reviews'; $speed = '2500'; $pause = '6000'; $showitems = '2'; $animation = 'fade'; $mousepause = 'true'; $direction = 'up'; $yelp_url = 'http://www.yelp.com/biz/'; $unsigned_url = 'http://api.yelp.com/v2/business/'; $consumer_key = ''; $consumer_secret = ''; $token = ''; $token_secret = ''; } ?&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('title');?&gt;"&gt;Widget Title&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('title');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('title');?&gt;" type="text" value="&lt;?php echo $title; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('speed');?&gt;"&gt;Speed&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('speed');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('speed');?&gt;" type="text" value="&lt;?php echo $speed; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('pause');?&gt;"&gt;Pause&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('pause');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('pause');?&gt;" type="text" value="&lt;?php echo $pause; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('showitems');?&gt;"&gt;# of reviews&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('showitems');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('showitems');?&gt;" type="text" value="&lt;?php echo $showitems; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('animation');?&gt;"&gt;Fade&lt;/label&gt;&lt;br /&gt; Yes &lt;input id="&lt;?php echo $this-&gt;get_field_id('animation');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('animation');?&gt;" type="radio" &lt;?php if($animation == 'fade') echo 'checked="checked"'; ?&gt; value="fade"/&gt; No &lt;input id="&lt;?php echo $this-&gt;get_field_id('animation');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('animation');?&gt;" type="radio" &lt;?php if($animation == '') echo 'checked="checked"'; ?&gt; value=""/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('mousepause');?&gt;"&gt;Mouse Pause&lt;/label&gt;&lt;br /&gt; Yes &lt;input id="&lt;?php echo $this-&gt;get_field_id('mousepause');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('mousepause');?&gt;" type="radio" &lt;?php if($mousepause == 'true') echo 'checked="checked"'; ?&gt; value="true"/&gt; No &lt;input id="&lt;?php echo $this-&gt;get_field_id('mousepause');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('mousepause');?&gt;" type="radio" &lt;?php if($mousepause == 'false') echo 'checked="checked"'; ?&gt; value="false"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('direction');?&gt;"&gt;Direction&lt;/label&gt;&lt;br /&gt; Up &lt;input id="&lt;?php echo $this-&gt;get_field_id('direction');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('direction');?&gt;" type="radio" &lt;?php if($direction == 'up') echo 'checked="checked"'; ?&gt; value="up"/&gt; Down &lt;input id="&lt;?php echo $this-&gt;get_field_id('direction');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('direction');?&gt;" type="radio" &lt;?php if($direction == 'down') echo 'checked="checked"'; ?&gt; value="down"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('yelp_url');?&gt;"&gt;Yelp Business URL&lt;/label&gt;&lt;br /&gt; http://www.yelp.com/biz/...&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('yelp_url');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('yelp_url');?&gt;" type="text" value="&lt;?php echo $yelp_url; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('unsigned_url');?&gt;"&gt;API Business URL&lt;/label&gt;&lt;br /&gt; http://api.yelp.com/v2/business/...&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('unsigned_url');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('unsigned_url');?&gt;" type="text" value="&lt;?php echo $unsigned_url; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('consumer_key');?&gt;"&gt;Consumer Key&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('consumer_key');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('consumer_key');?&gt;" type="text" value="&lt;?php echo $consumer_key; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('consumer_secret');?&gt;"&gt;Consumer Secret&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('consumer_secret');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('consumer_secret');?&gt;" type="text" value="&lt;?php echo $consumer_secret; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('token');?&gt;"&gt;Token&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('token');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('token');?&gt;" type="text" value="&lt;?php echo $token; ?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('token_secret');?&gt;"&gt;Token Secret&lt;/label&gt;&lt;br /&gt; &lt;input id="&lt;?php echo $this-&gt;get_field_id('token_secret');?&gt;" name="&lt;?php echo $this-&gt;get_field_name('token_secret');?&gt;" type="text" value="&lt;?php echo $token_secret; ?&gt;"/&gt; &lt;/p&gt; &lt;?php } // end function form } // end class // Register the widget. function yrtw_register() { register_widget( 'yrtWidget' ); } add_action('wp_head', 'add_yrt_header'); function add_yrt_header(){ echo ' &lt;script type="text/javascript" src="' . plugins_url( 'lib/jquery-1.8.3.min.js' , __FILE__ ) . '"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="' . plugins_url( 'lib/jquery.vticker-min.js' , __FILE__ ) . '"&gt;&lt;/script&gt; &lt;style type="text/css" media="all" src="' . plugins_url( 'css/yelprt.css' , __FILE__ ) . '"&gt;&lt;/style&gt; '; } add_action( 'widgets_init', 'yrtw_register' ); ?&gt; </code></pre> <p>I hope it helps someone else</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload