3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Plugin Name: Weather Plugin Plugin URI: http://www.yourpluginurlhere.com/ Version: Current Version Author: Name please Description: What does your plugin do and what features does it offer... */ /** * Weather Plugin For Wordpress */ /** * Proper way to enqueue scripts and styles */ define('APFSURL', WP_PLUGIN_URL . "/" . dirname(plugin_basename(__FILE__))); function theme_name_scripts() { //define('weather-plugin', WP_PLUGIN_URL . "/" . dirname(plugin_basename(__FILE__))); wp_enqueue_style( 'weather-plugin', get_stylesheet_uri() ); wp_enqueue_script( 'weather-plugin',APFSURL.'/js/weather-plugin.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); add_shortcode('weather-plugin','weather_function'); function weather_function(){ $ip = '203.135.41.33';//$_SERVER['REMOTE_ADDR']; $xml = new SimpleXMLElement(file_get_contents("http://www.geoplugin.net/xml.gp?={$ip}")); $city = (array)$xml->geoplugin_city; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22%27'.$city[0].'%27%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $weather_rss = curl_exec($ch); echo curl_error($ch); curl_close($ch); $return = json_decode($weather_rss); var_dump($weather_rss); $temp = $return->query->results->channel->item->condition->temp; echo "<div> Weather &nbsp; : &nbsp;"; echo "<div class = 'farenheit'> ".$temp." </div>"; $centi = 5/9*($temp-32); $centi1 = number_format((float)$centi, 0, '.', ''); echo "<div class = 'centigrade' style='display:none'> ".$centi1." </div>"; echo "<a hredf='#' id='btn1'>&nbsp;F</a> / <a href='#' id='btn2'> C</a>"; echo "</div>"; } ?>
based on CGouK
Output for 7.2.0
Warning: Use of undefined constant WP_PLUGIN_URL - assumed 'WP_PLUGIN_URL' (this will throw an Error in a future version of PHP) in /in/0NcJL on line 15 Fatal error: Uncaught Error: Call to undefined function plugin_basename() in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant WP_PLUGIN_URL - assumed 'WP_PLUGIN_URL' in /in/0NcJL on line 15 Fatal error: Uncaught Error: Call to undefined function plugin_basename() in /in/0NcJL:15 Stack trace: #0 {main} thrown in /in/0NcJL on line 15
Process exited with code 255.
Output for 5.3.18 - 5.6.28
Notice: Use of undefined constant WP_PLUGIN_URL - assumed 'WP_PLUGIN_URL' in /in/0NcJL on line 15 Fatal error: Call to undefined function plugin_basename() in /in/0NcJL on line 15
Process exited with code 255.