My Plugin is not working
-
I built a plugin and it is not working, i really dont know what is wrong with my code, please help
<?php
/*
Plugin Name: WordPress Windspeed Converter by Solution Oriented
Plugin URI: http://www.Solution Oriented.at/
Description: This Plugin gives you the possibility to insert a converter via widget or shortcode into your site. The user has to write one of five values and the plugin calculates the others.
Author: Solution Oriented
Version: 1.0.1
Author URI: http:soriented.comCopyright 2014 Solution Oriented (email : (email visible only to moderators and staff))
global $wp_version;
$exit_msg=’Wordpress Windspeed Converter by Solution Oriented requires WordPress 3.0 or newer.
Please update!‘;if(version_compare($wp_version, “3.0”,”<“)) {
exit($exit_msg);
}/* Select the URL of the plugin */
$plugin_url_wind = trailingslashit( WP_PLUGIN_URL.’/’. dirname( plugin_basename(__FILE__) ));/* Localization */
load_plugin_textdomain( ‘windspeed’, false, dirname( plugin_basename(__FILE__) ).’/languages/’ );/* Register Widget */
function wind_init() {
global $plugin_url_wind;
register_sidebar_widget(‘Windspeed Converter’, ‘wind_widget’);
register_widget_control(‘Windspeed Converter’, ‘wind_widget_control’);
}
add_action(‘init’,’wind_init’);/* Load CSS */
function wind_css() {
global $plugin_url_wind;
wp_register_style( ‘wind-css’, $plugin_url_wind . ‘windspeed-converter.css’ );
wp_enqueue_style( ‘wind-css’ );
}
add_action( ‘wp_enqueue_scripts’, ‘wind_css’ );/* Load Scripts */
function wind_scripts() {
global $plugin_url_wind;
wp_enqueue_script(‘windspeed-converter’, $plugin_url_wind . ‘windspeed-converter.js’, array(‘jquery’));
wp_enqueue_script(‘windspeed-converter_beaufort_scala’, $plugin_url_wind . ‘windspeed-converter-beaufort-scala.js’, array(‘jquery’));
wp_localize_script(
‘windspeed-converter’,
‘messages’,
array(
‘usecomma’ => “* Use . (dot) as comma.”,
‘numberbetween’ => “* Number between 1 and 12”,
‘mustinteger’ => “* Number must be a integer.”
)
);
}
add_action(‘wp_enqueue_scripts’,’wind_scripts’,10);/* Generate Shortcode [windspeed_converter] */
function wind_shortcode($atts) {
ob_start();
display_shortcode($atts);
$output_string = ob_get_contents();
ob_end_clean();return $output_string;
}
add_shortcode(‘windspeed_converter’,’wind_shortcode’);function display_shortcode($atts) {
extract(shortcode_atts( array(
‘kmh’ => ‘kmh’,
‘mph’ => ‘mph’,
‘beaufort’ => ‘beaufort’,
‘ms’ => ‘ms’,
‘knots’ => ‘knots’,
‘cm’ => ‘cm’,
‘link’ => ‘link’
), $atts ));echo ‘<div id=”wind_converter” class=”wind_converter”>’;
echo ‘<form name=”form_wind_converter”>’;
if($kmh != ‘false’) {
echo ‘<div id=”kmh” class=”field”>
<label>’;_e( “Km/h”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”kmh” class=”input_field” />
</div>’;
}
if($mph != ‘false’) {
echo ‘<div id=”mph” class=”field”>
<label>’;_e( “mph”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”mph” class=”input_field” />
</div>’;
}
if($beaufort != ‘false’) {
echo ‘<div id=”beaufort” class=”field”>
<label>’;_e( “Beaufort”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”beaufort” class=”input_field” />
</div>’;
}
if($ms != ‘false’) {
echo ‘<div id=”ms” class=”field”>
<label>’;_e( “m/s”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”ms” class=”input_field” />
</div>’;
}
if($knots != ‘false’) {
echo ‘<div id=”knots” class=”field”>
<label>’;_e( “Knots”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”knots” class=”input_field” />
</div>’;
}
if($cm != ‘false’) {
echo ‘<div id=”cm” class=”field”>
<label>’;_e( “cm”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”cm” class=”input_field” />
</div>’;
}
echo ‘<div class=”field message”></div>’;
echo ‘<div class=”clear”></div>’;
if($link != ‘false’) {
echo ‘<div id=”link” class=”field”>
by APRG, OAU
</div>’;
}
echo ‘</form>’;
echo ‘</div>’;
}/* Create Windspeed Converter Widget */
function wind_widget() {
// Get saved options
$options = get_option(‘wp_wind’);
$title = $options[‘title’];// Display the Widget on the Website
echo ‘<div id=”wind_converter” class=”wind_converter”>’;
echo ‘<h3 class=”widget-title”>’.$title.'</h3>’;
echo ‘<form name=”form_wind_converter”>’;
if($options[‘kmh’] == 1) {
echo ‘<div id=”kmh” class=”field”>
<label>’;_e( “Km/h”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”kmh” class=”input_field” />
</div>’;
}
if($options[‘mph’] == 1) {
echo ‘<div id=”mph” class=”field”>
<label>’;_e( “mph”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”mph” class=”input_field” />
</div>’;
}
if($options[‘beaufort’] == 1) {
echo ‘<div id=”beaufort” class=”field”>
<label>’;_e( “Beaufort”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”beaufort” class=”input_field” />
</div>’;
}
if($options[‘ms’] == 1) {
echo ‘<div id=”ms” class=”field”>
<label>’;_e( “m/s”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”ms” class=”input_field” />
</div>’;
}
if($options[‘knots’] == 1) {
echo ‘<div id=”knots” class=”field”>
<label>’;_e( “Knots”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”knots” class=”input_field” />
</div>’;
}
if($options[‘cm’] == 1) {
echo ‘<div id=”cm” class=”field”>
<label>’;_e( “cm”, ‘windspeed’ ); echo ‘</label>
<input type=”text” name=”cm” class=”input_field” />
</div>’;
}
echo ‘<div class=”field message”></div>’;
echo ‘<div class=”clear”></div>’;
if($options[‘link’] != 1 || empty($options[‘link’])) {
echo ‘<div id=”link”>
by Solution Oriented.at
</div>’;
}echo ‘</form>’;
echo ‘</div>’;
}/* Create Windspeed Converter Widget Control */
function wind_widget_control() {// Get saved options
$options = get_option(‘wp_wind’);// Handle user input
if ($_POST[“wind_submit”]) {
// Define variables from the request
$options[‘title’] = strip_tags(stripslashes($_POST[“title”]));
$options[‘kmh’] = strip_tags(stripslashes($_POST[“kmh”]));
$options[‘mph’] = strip_tags(stripslashes($_POST[“mph”]));
$options[‘beaufort’] = strip_tags(stripslashes($_POST[“beaufort”]));
$options[‘ms’] = strip_tags(stripslashes($_POST[“ms”]));
$options[‘knots’] = strip_tags(stripslashes($_POST[“knots”]));
$options[‘cm’] = strip_tags(stripslashes($_POST[“cm”]));
$options[‘link’] = strip_tags(stripslashes($_POST[“link”]));// Update the options to database
update_option(‘wp_wind’, $options);
}// Save options to variables
$title = $options[‘title’];
$kmh = $options[‘kmh’];
$mph = $options[‘mph’];
$beaufort = $options[‘beaufort’];
$ms = $options[‘ms’];
$knots = $options[‘knots’];
$cm = $options[‘cm’];
$link = $options[‘link’];// Display the Widget-Control
echo ‘<div class=”widget-content”>’;
echo ‘<p><label for=”title”>’;_e( “Title”, ‘windspeed’ ); echo ‘ <input name=”title” type=”text” value=”‘.$title.'” /></label></p>’;
if($kmh == 1) {
echo ‘<p><input type=”checkbox” name=”kmh” value=”1″ checked=”checked” /><label> ‘;_e( “Km/h”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”kmh” value=”1″ /><label> ‘;_e( “Km/h”, ‘windspeed’ ); echo ‘</label></p>’;
}
if($mph == 1) {
echo ‘<p><input type=”checkbox” name=”mph” value=”1″ checked=”checked” /><label> ‘;_e( “mph”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”mph” value=”1″ /><label> ‘;_e( “mph”, ‘windspeed’ ); echo ‘</label></p>’;
}
if($beaufort == 1) {
echo ‘<p><input type=”checkbox” name=”beaufort” value=”1″ checked=”checked” /><label> ‘;_e( “Beaufort”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”beaufort” value=”1″ /><label> ‘;_e( “Beaufort”, ‘windspeed’ ); echo ‘</label></p>’;
}
if($ms == 1) {
echo ‘<p><input type=”checkbox” name=”ms” value=”1″ checked=”checked” /><label> ‘;_e( “m/s”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”ms” value=”1″ /><label> ‘;_e( “m/s”, ‘windspeed’ ); echo ‘</label></p>’;
}
if($knots == 1) {
echo ‘<p><input type=”checkbox” name=”knots” value=”1″ checked=”checked” /><label> ‘;_e( “Knots”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”knots” value=”1″ /><label> ‘;_e( “Knots”, ‘windspeed’ ); echo ‘</label></p>’;
}
if($cm == 1) {
echo ‘<p><input type=”checkbox” name=”cm” value=”1″ checked=”checked” /><label> ‘;_e( “cm”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”cm” value=”1″ /><label> ‘;_e( “cm”, ‘windspeed’ ); echo ‘</label></p>’;
}
echo ‘
‘;
if($link == 1) {
echo ‘<p><input type=”checkbox” name=”link” value=”1″ checked=”checked” /><label> ‘;_e( “Hide Link?”, ‘windspeed’ ); echo ‘</label></p>’;
} else {
echo ‘<p><input type=”checkbox” name=”link” value=”1″ /><label> ‘;_e( “Hide Link?”, ‘windspeed’ ); echo ‘</label></p>’;
}
echo ‘<input type=”hidden” id=”wind_submit” name=”wind_submit” value=”1″ />’;
echo ‘</div>’;
}i used the shortcode [winddirection_conveter] to call it in one of my sub pages and it i not working
-
Plugin installation possible only if you hire a web host http://wordpress.org/hosting/ and set up a WordPress.ORG install. http://wordpress.org
There is no FTP access to WordPress.COM blogs and we bloggers cannot install any plugins or third party themes.
http://en.support.wordpress.com/ftp-access/
http://en.support.wordpress.com/plugins/
http://en.support.wordpress.com/themes/adding-new-themes/There is no other upgrade you can purchase here that changes that reality.
WordPress.org offers free software that you can install on a web server. You can upload and install themes and plugins, run ads, conduct ecommerce and edit the database. Learn about the differences here. http://support.wordpress.com/com-vs-org/
That site is NOT hosted by wordpress.COM and our support docs do not apply to it so be clear on that. We cannot help you as we do not provide support for any blogs that are not hosted by WordPress.COM.
WordPress.COM and WordPress.ORG are completely separate and have different logins, features, run different versions of some themes with the same names, and have separate support forums. http://en.support.wordpress.com/com-vs-org/
If you don’t have a username account at WordPress.ORG click http://wordpress.org/support/ and register one on the top right hand corner of the page that opens, so you can post to the support forums there.
Resetting your WordPress.ORG password http://codex.wordpress.org/Resetting_Your_Password
WordPress.org support docs are at https://codex.wordpress.org/Main_Page -
Thank you. The site i want to use the plugin for is meteorology.oauife.edu.ng which is a wordpress site. All i need is for the plugin i built to work because i have not seen any plugin on wordpress site with the same functionality as the one we need on the site. Please help me
-
meteorology.oauife.edu.ng is hosted by MAINONE
IP Address: 197.253.6.200
It is not hosted by WordPress.COM and we cannot help you. -
This is the code, it worked actually, but i want to call it from a sub page with a shortcode
<?php
/*
Plugin Name: WordPress Winddirection Converter by Solution Oriented
Plugin URI: http://www.Soriented,com
Description: This Plugin gives you the possibility to insert a converter via widget or shortcode into your site. The user has to write one of five values and the plugin calculates the others.
Author: Solution Oriented
Version: 1.0.1
Author URI: http:soriented.comCopyright 2014 Solution Oriented (email : (email visible only to moderators and staff))
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
*///function
function convert($a,$b){
if ($a<90 && $a>0){
$b=”N”.$a.”<sup>o</sup>E”;
return $b;
}
if ($a<180 && $a>90){
$b=”S”.(180-$a).”<sup>o</sup>E”;
return $b;
}
if ($a<270 && $a>180){
$b=”S”.($a-180).”<sup>o</sup>W”;
return $b;
}if ($a<360 && $a>270){
$b=”N”.(360-$a).”<sup>o</sup>W”;
return $b;
}
if ($a==0){
$b=”0<sup>o</sup>N”;
return $b;
}if ($a==90){
$b=”N90<sup>o</sup>E”;
return $b;
}
if ($a==180){
$b=”0<sup>o</sup>S”;
return $b;
}
if ($a==270){
$b=”S90<sup>o</sup>W”;
return $b;
}
}
//end of function.if (isset($_POST[‘submit’])){
$deg=$_POST[‘deg’];
$mi=$deg;
$deg=$deg%360;
$m=0;//call the function
$m=convert($deg,$m);function converts( $atts ) {
// Attributes
extract( shortcode_atts(
array(
), $atts )
);
}
add_shortcode( ‘winddirection_converter’, ‘converts’ );
}
?><form action=”” method=post>
give a degree value: <input type=text name=deg value=”<?php if (isset($_POST[‘submit’])){ print $mi;} ?>”><p>
Equivalent value: <?php if (isset($_POST[‘submit’])){ print $m;} ?><p>
<input type=submit name=submit value=convert></form>
-
-
Stop posting code here please and understand me clearly that we cannot assist you here. You are posting to the wrong support forum.
If you don’t have a username account at WordPress.ORG click http://wordpress.org/support/ and register one on the top right hand corner of the page that opens, so you can post to the support forums there like this one https://wordpress.org/support/forum/plugins-and-hacks
-
But i can use the same plugin on my blog, oniosuntemidayo.wordpress.com
No you absolutely cannot use that plugin on any WordPress.COM hosted blog. There is no FTP access to WordPress.COM blogs and we bloggers cannot install any plugins.
http://en.support.wordpress.com/ftp-access/ -
-
- The topic ‘My Plugin is not working’ is closed to new replies.