Skip to content

Commit

Permalink
Create helpfulbot module
Browse files Browse the repository at this point in the history
Move of the glitch code to the plugin, with the same set of commands and periodics
  • Loading branch information
Randall-Scharpf authored Jul 20, 2020
2 parents b4ea7d5 + 5848046 commit a282655
Show file tree
Hide file tree
Showing 20 changed files with 2,517 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
**/.data
sekrit.php
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# whsso-wesite-plugin
Code for the custom plugin on whsscioly.org, which is used to directly code the UI. The plugin also creates a potential endpoint for other online code.
This software is licensed under the GNU General Public License, version 3.
85 changes: 85 additions & 0 deletions backend-home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!--
WHSSO Website Plugin: for custom frontend interface modification and
educational/competitive projects requiring a home on the website
Copyright (C) 2020 WHSSO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

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, see <http://www.gnu.org/licenses/>.
-->

<h1>WHSSO Custom Website Plugin</h1>
<p>
This plugin is a set of modules used to make custom code edits to both the public website and the wordpress admin section.
<br>
In addition, it provides an endpoint for deployment of WHSSO projects and utilities that require web hosting.
</p>
<p>
Our code is on GitHub! Go to <a href="https://github.com/West-High-Science-Olympiad/whsso-wesite-plugin">
https://github.com/West-High-Science-Olympiad/whsso-wesite-plugin
</a>
to view our code.
</p>
<p>
The plugin uses the GNU General Public License, version 3.
</p>
<h2>List of Modules</h2>
<p><b>Tabs</b><br>
Tabs is a module designed initially for backend operation that creates a php function for extremely simple
creation of a tabbed interface. It may be restyled universally using a small set of CSS classes. In addition
to a simple and effective interface, the plugin saves the currently selected tab in the URL to sponsor generation
of links to specific tabs and to improve the action of redirects.<br>
The function exported by the tabs module takes three inputs. The first should be a unique identifier for the tab group that
represents its name. The second is an array of title texts for the tab headers. The final input is an array of equal length
containing the body of each tab. The first two inputs must contain raw string data. Elements of the body information data array
may be either names of functions that return strings, names of functions that echo the tab body, or raw string data.<br>
<i>Since version 1.0</i>
</p>
<p><b>Sticky Elements</b><br>
Sticky Elements is a module that prevents elements on the frontend interface from disappering when the user
scrolls down past it. Menus on the frontend are the primary target elements of this plugin. More info may be found
in the plugin settings page, at <a href="<?php
echo add_query_arg(
array(
'page' => 'whsso-plugin',
"tab-Main" => "Sticky Element Settings",
"tab-stickysettingspage" => "Information"
),
admin_url('options-general.php')
);
?>">this link</a>.<br>
<i>Since version 1.0</i>
</p>
<p><b>PHP Button</b><br>
PHP Button is a module exclusively for backend operation that calls a php function, instead of a javascript function as
is typical, when a button is clicked. The plugin includes security wrapping (a unique nonce field for each button and a
permissions check subsequent to form submission) to ensure that a button is actually pressed by a real user before
running server-side php code. It makes button creation simple while still allowing versatility in button fashion and function.<br>
The function exported by the module takes two inputs. The first is the html code to display the button itself (this must be a single
&lt;button&gt;&lt;/button&gt; element). The second is the name of the php function that is to be called on the button click.
A unique identifier for the button is created internally for the button form submission and ajax code, so the html button supplied
should not specify the id attribute. The "manage_options" permissions are required to click a php button and cannot be changed
by function parameter.<br>
<i>Since version 2.0</i>
</p>
<p><b>Helpful Bot</b><br>
Helpful Bot is a custom discord.js bot for the team communication server. By hosting it on the team website, we can receive reliable
and free custom labor of menial discord management. The module requires node and npm to be installed and in the command line path on
the server system, and installs the necessary dependencies on each boot. The authentication key and databases are not released on the
GitHub page, so to acquire these, ask a current developer, or pull the files from the website itself. The module settings page has
options to start and stop the bot and will, in the future, have options to customize how the bot runs. Note that if the server crashes,
the bot must be manually restarted as of this version. In the event that a fatal error occurs during boot or shutdown, the error should
be addressed and the status reset directly using the wordpress database. The bot may also display as running even when it is stopped
if an internal server error was responsible for the crash - in this case shutting down and restarting the bot will result in a clean
boot. Be aware that a full boot takes a relatively long duration due to dependencies. For more information about functionality, use
h?commands or h?periodics on the team Discord server.
</p>
49 changes: 45 additions & 4 deletions custom-so-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@
* Author URI: https://whsscioly.org/
**/

/*
WHSSO Website Plugin: for custom frontend interface modification and
educational/competitive projects requiring a home on the website
Copyright (C) 2020 WHSSO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
*/

if (!defined('ABSPATH')) exit;

if (!function_exists('whsso_plugin_add_to_plugin_list')) {
Expand All @@ -28,16 +47,22 @@ function whsso_plugin_settings_link($links) {
function whsso_plugin_settings() {
echo "<br>";
whsso_tabs_create("Main",
array('Home Page', 'Sticky Element Settings', "Blank Page"),
array('Home Page', 'Sticky Element Settings', "Helpful Bot Configuration"),
array(
"<h3>Home Page</h3>\n<p>Im supposed to like put info here or something right?</p>",
"backend_landing_page",
"sticky_anything_config_page",
"<h3>Blank Page</h3>\n<p>This page intentionally left blank.</p>"
"helpful_bot_config_page"
)
);
}
}

if (!function_exists("backend_landing_page")) {
function backend_landing_page() {
include "backend-home.php";
}
}

$plugin = plugin_basename(__FILE__);

add_action('admin_menu', 'whsso_plugin_add_to_plugin_list');
Expand All @@ -57,11 +82,13 @@ function empty_string($default) {
}

// REGISTER AND RUN EACH MODULE
require_once dirname( __FILE__ ).'/sekrit.php';
if (!function_exists('whsso_plugin_styles')) {
function whsso_plugin_styles($hook) {
if ($hook == 'settings_page_whsso-plugin') {
whsso_register_module_jscss_tabs();
whsso_register_module_jscss_stickyelements();
whsso_register_module_jscss_helpfulbot();
}
}
}
Expand All @@ -75,11 +102,25 @@ function whsso_register_module_jscss_tabs() {
wp_enqueue_style('whssoPluginMainTabViewerStyle');
}

// phpbutton
require_once dirname( __FILE__ ).'/modules/phpbutton/button.php';

// stickyelements
require_once dirname( __FILE__ ).'/modules/stickyelements/sticky-interface.php';
add_action('wp_enqueue_scripts', 'load_sticky_anything');
add_action('admin_init', 'sticky_anything_admin_init');
function whsso_register_module_jscss_stickyelements() {
wp_register_style('whssoPluginStickyHoverHintStyle', plugins_url('/modules/stickyelements/hoverhint.css', __FILE__));
wp_enqueue_style('whssoPluginStickyHoverHintStyle');
}
}

// helpfulbot
require_once dirname( __FILE__ ).'/modules/helpfulbot/helpful.php';
function whsso_register_module_jscss_helpfulbot() {
wp_register_script('whssoPlgnHlpflBtSttngsPagScrpt', plugins_url('/modules/helpfulbot/settings.js', __FILE__), array( 'jquery' ));
wp_enqueue_script('whssoPlgnHlpflBtSttngsPagScrpt');
wp_register_style('whssoPlgnHlpflBtSttngsPagStyle', plugins_url('/modules/helpfulbot/settings.css', __FILE__));
wp_enqueue_style('whssoPlgnHlpflBtSttngsPagStyle');
}
register_activation_hook(__FILE__, 'launch_helpful_bot');
register_deactivation_hook(__FILE__, 'kill_helpful_bot');
Loading

0 comments on commit a282655

Please sign in to comment.