-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMS Integration #70
Projects
Comments
Hello. I have thoughts about it, thanks. Dunno how to write wp plugins but I'll take a look |
Hello, anything change about a Wordpress Plugin ? |
Hey @wahke <?php
/**
* @package LGSL
* @version 0.0.1
*/
/*
Plugin Name: LGSL Plugin (Live Game Server List)
Plugin URI: https://github.com/tltneon/lgsl/
Description: This is just a plugin to parsing data from LGSL
Author: tltneon
Version: 0.0.1
Author URI: https://github.com/tltneon
*/
function getLgslPath() {
return "http://lgsl7.test";
}
function getLgslServers() {
$response = wp_remote_retrieve_body(wp_remote_get(getLgslPath() . "/src/lgsl_feed.php")) ?? "[]";
return json_decode($response, true);
}
function lgsl() {
$servers = getLgslServers();
$out = "<div class='card-wrapper w-full' id='lgsl'><article class='card card-list'><div class='card-content flex-grow'><h2 class='entry-title'>Live Game Server List</h2><table class='wp-list-table widefat striped table-view-list posts'>";
$out .= "
<tr>
<th>Name</th>
<th>IP</th>
<th>Port</th>
<th>Game</th>
<th>Map</th>
<th>Players</th>
<th>Status</th>
</tr>";
foreach ($servers as $server) {
$isOnline = $server['online'] ? 'online' : 'offline';
$out .= "
<tr>
<td><a href='" . getLgslPath() . "/?ip={$server['ip']}&port={$server['port']}' target='_blank' class='link'>{$server['name']}</a></td>
<td>{$server['ip']}</td>
<td>{$server['port']}</td>
<td>{$server['game']}</td>
<td>{$server['map']}</td>
<td>{$server['players']}/{$server['maxplayers']}</td>
<td>{$isOnline}</td>
</tr>";
}
$out .= "</table></div></article></div>";
print($out);
}
add_action( 'get_footer', 'lgsl');
function lgslCss() {
echo "
<style type='text/css'>
#lgsl div.card-content {
margin: auto;
}
</style>
";
}
add_action( 'get_footer', 'lgslCss' );
function wporg_options_page() {
add_menu_page(
'LGSL Page',
'LGSL Page',
'manage_options',
'lgsl',
'lgsl_page_html'
);
}
add_action( 'admin_menu', 'wporg_options_page' );
function lgsl_page_html() {
lgsl();
} It able to show table with servers in the footer of page. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, maybe you could think about an integration with Wordpress?
The text was updated successfully, but these errors were encountered: