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
-
Duplicate https://en.forums.wordpress.com/topic/my-plugin-is-not-working?replies=2#post-2184395
Already answered!
- The topic ‘My Plugin is not working’ is closed to new replies.