Changeset 771715
- Timestamp:
- 09/13/2013 03:49:54 PM (13 years ago)
- Location:
- omt-on-air/trunk
- Files:
-
- 1 added
- 3 edited
-
readme.txt (modified) (4 diffs)
-
screenshot-1.jpg (modified) (previous)
-
screenshot-4.jpg (added)
-
wp.widget_lrhomtonair.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
omt-on-air/trunk/readme.txt
r561890 r771715 4 4 Tags: lrh omt onair imediatouch 5 5 Requires at least: 3.0.0 6 Tested up to: 3. 46 Tested up to: 3.6.1 7 7 Stable tag: 1.2.0 8 8 License: GPLv2 or later … … 26 26 27 27 The output can be generated as an unnumbered list or plain. 28 29 Additionally, you may specify an optional footer to output below the on air data. 30 Commonly used to include a request line phone number. 28 31 29 32 == Installation == … … 56 59 2. Widget in 8-some theme sidebar. 57 60 3. Widget in Easel theme sidebar. 61 4. Widget in custom theme sidebar, with footer line. 58 62 59 63 == Changelog == 64 65 = 1.2.3 = 66 67 * Maintenance. 68 * Addition of footer line. 60 69 61 70 = 1.2.0 = … … 74 83 == Upgrade Notice == 75 84 76 = 1.2.0 = 77 * Maintenance update. 85 = 1.2.3 = 86 * Maintenance. 87 * Addition of footer line. 78 88 -
omt-on-air/trunk/wp.widget_lrhomtonair.php
r561890 r771715 2 2 /* 3 3 Plugin Name: LRH/OMT OnAir 4 Plugin URI: http://lrh.net/wp _blog_lrh4 Plugin URI: http://lrh.net/wpblog_lrh 5 5 Description: Retrieves the OMT/iMediaTouch OnAir xml file and displays the active cut. 6 6 Author: Larry Houbre, Jr. 7 Version: 1.2. 07 Version: 1.2.3 8 8 */ 9 9 … … 26 26 define('cwidgetoption_lrhomtonair_ajaxload','lrhomtonair_al'); 27 27 define('cwidgetoption_lrhomtonair_ajaxload_value',__('Loading...',cwidgetbaseid_lrhomtonair)); 28 define('cwidgetoption_lrhomtonair_foot','lrhomtonair_ft'); 28 29 29 30 define('cwidgetajax_lrhomtonair_request','lrhomtonair_ar'); … … 61 62 ,__('Output as non-list:',cwidgetbaseid_lrhomtonair) 62 63 ,'0','yesnoselect'); 64 $this->RegisterOptionField(cwidgetoption_lrhomtonair_foot 65 ,__('Footer text:',cwidgetbaseid_lrhomtonair) 66 ,'','text'); 63 67 64 68 $this->RegisterFieldHelp(cwidgetoption_lrhomtonair_defaultprogram … … 93 97 $useajax=('1'==$instance[cwidgetoption_lrhomtonair_useajax]); 94 98 $defpgm=$instance[cwidgetoption_lrhomtonair_defaultprogram]; 99 $footer=$instance[cwidgetoption_lrhomtonair_foot]; 95 100 $usediv=('1'==$instance[cwidgetoption_lrhomtonair_usediv]); 96 101 if ($useajax) { 97 $jurl=admin_url('admin-ajax.php');102 $jurl=admin_url('admin-ajax.php'); 98 103 $nonce=wp_create_nonce(cwidgetbaseid_lrhomtonair); 99 104 $show=(empty($instance[cwidgetoption_lrhomtonair_ajaxload]))?cwidgetoption_lrhomtonair_ajaxload_value:$instance[cwidgetoption_lrhomtonair_ajaxload]; … … 131 136 132 137 } else { 133 $show=lrh _GetDisplayText($URL,$defpgm);138 $show=lrhomtonair_GetDisplayText($URL,$defpgm); 134 139 $script=''; 135 140 } … … 142 147 else echo '<ul><li'; 143 148 echo " id='{$widget_id}_onair'>$show</"; 144 if ($usediv) echo 'div>';149 if ($usediv) echo 'div>'; 145 150 else echo 'li></ul>'; 151 if ($footer) { 152 echo (($usediv)?"<div":"<p") 153 ." class='".cwidgetbaseid_lrhomtonair."_footer'>" 154 .$footer.(($usediv)?'</div>':'</p>'); 155 } 146 156 echo $after_widget; 147 157 print $script; … … 161 171 162 172 // To support the AJAX calls, these need to be OUTSIDE of the widget class 163 function lrh _GetOnAirData($aUrl) {173 function lrhomtonair_GetOnAirData($aUrl) { 164 174 if ('file://'==substr($aUrl,0,7)) { 165 175 $aUrl=substr($aUrl,7); 166 176 if (file_exists($aUrl)) { 167 177 $content=file_get_contents($aUrl); 168 if ($content=='') return lrh _DataError('File:no content'); //nothing178 if ($content=='') return lrhomtonair_DataError('File:no content'); //nothing 169 179 } else { 170 return lrh _DataError('File:not found'); //nothing180 return lrhomtonair_DataError('File:not found'); //nothing 171 181 } 172 182 } else { … … 174 184 if ('http://'!=substr($aUrl,0,7)) $aUrl='http://'.$aUrl; 175 185 $content=wp_remote_retrieve_body(wp_remote_get($aUrl)); 176 if ($content=='') return lrh _DataError('Http:no content'); //nothing186 if ($content=='') return lrhomtonair_DataError('Http:no content'); //nothing 177 187 } 178 188 //convert xml to data array … … 180 190 @$x=new SimpleXMLElement($content); 181 191 } catch (Exception $e) { 182 return lrh _DataError('XML error:'.$e->getMessage(),$content); //trouble192 return lrhomtonair_DataError('XML error:'.$e->getMessage(),$content); //trouble 183 193 } 184 194 … … 203 213 } 204 214 205 function lrh _DataError($aMsg,$aMsg2='') {215 function lrhomtonair_DataError($aMsg,$aMsg2='') { 206 216 //for debugging 207 217 // return array('now'=>array('Title'=>$aMsg,'Artist'=>$aMsg2)); … … 209 219 } 210 220 211 function lrh _GetDisplayText($aUrl,$aDefaultProgram) {212 $ONAIR=lrh _GetOnAirData($aUrl);221 function lrhomtonair_GetDisplayText($aUrl,$aDefaultProgram) { 222 $ONAIR=lrhomtonair_GetOnAirData($aUrl); 213 223 $data=$ONAIR['now']; 214 224 if (null==$data) { … … 221 231 } 222 232 223 function lrh _ajaxhandler_omtonair() {233 function lrhomtonair_ajaxhandler() { 224 234 if (!empty($_POST[cwidgetajax_lrhomtonair_request])) { 225 235 //check_ajax_referer does not return if check fails … … 229 239 $URL=strip_tags($_POST[cwidgetajax_lrhomtonair_url]); 230 240 $DEFPGM=strip_tags($_POST[cwidgetajax_lrhomtonair_defpgm]); 231 echo lrh _GetDisplayText($URL,$DEFPGM);241 echo lrhomtonair_GetDisplayText($URL,$DEFPGM); 232 242 die(); 233 243 } … … 236 246 } 237 247 238 239 248 add_action('widgets_init' 240 ,create_function('','return register_widget("lrh_widget_omtonair");')241 );242 add_action('wp_ajax_'.cwidgetajax_lrhomtonair_request,'lrh _ajaxhandler_omtonair');243 add_action('wp_ajax_nopriv_'.cwidgetajax_lrhomtonair_request,'lrh _ajaxhandler_omtonair');249 ,create_function('','return register_widget("lrh_widget_omtonair");') 250 ); 251 add_action('wp_ajax_'.cwidgetajax_lrhomtonair_request,'lrhomtonair_ajaxhandler'); 252 add_action('wp_ajax_nopriv_'.cwidgetajax_lrhomtonair_request,'lrhomtonair_ajaxhandler'); 244 253 245 254 ?>
Note: See TracChangeset
for help on using the changeset viewer.