diff --git a/css/widrick_style.css b/css/widrick_style.css
new file mode 100644
index 0000000..a7ef5e9
--- /dev/null
+++ b/css/widrick_style.css
@@ -0,0 +1,5 @@
+
+span .widrick_minecraft_motd
+{
+ background-color: #333;
+}
diff --git a/libs/minecraft_query/MinecraftQuery.php b/libs/minecraft_query/MinecraftQuery.php
index 311cf1e..213dfb2 100644
--- a/libs/minecraft_query/MinecraftQuery.php
+++ b/libs/minecraft_query/MinecraftQuery.php
@@ -132,7 +132,8 @@ private function GetStatus( $Challenge )
}
else if( $Last != false )
{
- $Info[ $Last ] = mb_convert_encoding( $Value, 'UTF-8' );
+ //$Info[ $Last ] = mb_convert_encoding( $Value, 'UTF-8' );
+ $Info[$Last] = $Value;
}
}
diff --git a/shortcode.php b/shortcode.php
new file mode 100644
index 0000000..fe8efd9
--- /dev/null
+++ b/shortcode.php
@@ -0,0 +1,30 @@
+queryCall();
+ $pingServer = $client->pingCall();
+
+ require dirname(__FILE__) . '/templates/widget.php';
+}
+add_shortcode('widrick_serverStats','widrick_minecraft_serverStats_shortcode');
diff --git a/templates/partials/online.php b/templates/partials/online.php
index e069fbc..9f79d06 100644
--- a/templates/partials/online.php
+++ b/templates/partials/online.php
@@ -6,7 +6,9 @@
diff --git a/widget.php b/widget.php
index 3d2488a..71b908f 100644
--- a/widget.php
+++ b/widget.php
@@ -14,6 +14,8 @@
*/
require dirname(__FILE__) . '/libs/Widgetize.php';
require dirname(__FILE__) . '/libs/ApiClient.php';
+require dirname(__FILE__) . '/shortcode.php';
+require dirname(__FILE__) . '/widrick_motd_correction.php';
class MCServerStatus_Widget extends Widgetize {
/**
@@ -64,7 +66,6 @@ public function widget(array $args, array $instance) {
if (in_array($instance['host'], array('127.0.0.1', 'localhost'))) {
$instance['host'] = $_SERVER['SERVER_ADDR'];
}
-
$client = new GoneTone\ApiClient($instance['host'], $instance['server_port'], $instance['query_port']);
$queryServer = $client->queryCall();
$pingServer = $client->pingCall();
diff --git a/widrick_motd_correction.php b/widrick_motd_correction.php
new file mode 100644
index 0000000..82bbdd2
--- /dev/null
+++ b/widrick_motd_correction.php
@@ -0,0 +1,149 @@
+";
+ $formatState = Array();
+
+
+ foreach($stringArr as $key => $char)
+ {
+ if($skipChar === true)
+ {
+ $skipChar = false;
+ continue;
+ }
+ if(ord($char) === 167)
+ {
+ $nextChar = $stringArr[$key+1];
+ if(ord($nextChar) <= ord('f'))
+ {
+ $colorCode = widrick_format_colorCode($nextChar);
+ if($colorCode !== null)
+ {
+ //--New color = end all formats per spec
+ $formattedHostName .= widrick_format_reset($formatState);
+ if($inSpan === true)
+ {
+ $formattedHostName .= "";
+ $inSpan = false;
+ }
+ $formattedHostName .= "";
+ $inSpan = true;
+ }
+ $skipChar = true;
+ continue;
+ }
+ elseif(ord($nextChar) >= ord('k') && ord($nextChar) <= ord('r'))
+ {
+ $formatCode = widrick_format_formatCode($nextChar);
+ if($formatCode !== null && $formatCode != "RESET")
+ {
+ $formattedHostName .= $formatCode;
+ $formatState[$formatCode] = substr($formatCode,0,1) . '/' . substr($formatCode,1);
+ }
+ elseif($formatCode == "RESET")
+ {
+ $formattedHostName .= widrick_format_reset($formatState);
+ }
+ $skipChar = true;
+ continue;
+ }
+ elseif(ord($nextChar) == 167)
+ continue; //STAHP!
+ }
+ //Throw out unicode decorations
+ $formattedHostName .= $char;
+ }
+
+ //clean up
+ $formattedHostName .= widrick_format_reset($formatState);
+ if($inSpan === true)
+ $formattedHostName .= '';
+ return $formattedHostName . '';
+
+}
+function widrick_format_reset(&$formatState)
+{
+ $retStr = "";
+ foreach(array_reverse($formatState) as $key => $state)
+ {
+ $retStr .= $state;
+ unset($formatState[$key]);
+ }
+ return $retStr;
+}
+function widrick_format_formatCode($code)
+{
+ $code = strtolower($code);
+ switch($code)
+ {
+ case "k":
+ return null;// Unimplemented
+ case "l":
+ return "";
+ case "m":
+ return null;//Not implemented
+ case "n":
+ return "";
+ case "r":
+ return "RESET";
+ default:
+ return null;
+ }
+}
+
+
+function widrick_format_colorCode($code)
+{
+
+ $code = strtolower($code);
+ switch($code)
+ {
+ case "0":
+ return "#000";
+ case "1":
+ return "#0000AA";
+ case "2":
+ return "#00AA00";
+ case "3":
+ return "#00AAAA";
+ case "4":
+ return "#AA0000";
+ case "5":
+ return "#AA00AA";
+ case "6":
+ return "#FFAA00";
+ case "7":
+ return "#AAAAAA";
+ case "8":
+ return "#555555";
+ case "9":
+ return "#5555FF";
+ case "a":
+ return "#55ff55";
+ case "b":
+ return "#55ffff";
+ case "c":
+ return "#ff5555";
+ case "d":
+ return "#ff55ff";
+ case "e":
+ return "#ffff55";
+
+ case "f":
+ return "#ffffff";
+ default:
+ return null;
+ }
+}
+
+wp_register_style('widrick_format_HostName',plugin_dir_url(__FILE__).'css/widrick_style.css');