commit 280a6ffa1f8941b75c93e601e2a707fc28b199d1
parent 2ab7da3178e85f9d08513c63af801274077f89b8
Author: Sean Enck <sean@ttypty.com>
Date: Wed, 5 Nov 2025 09:32:19 -0500
support custom css/js loading from known sets
Diffstat:
4 files changed, 75 insertions(+), 19 deletions(-)
diff --git a/plugins/hphp/Makefile b/plugins/hphp/Makefile
@@ -18,6 +18,7 @@ TARGET := target/
ZIP := $(NAME)-$(PLUGIN_VERSION).zip
ARTIFACT := $(TARGET)$(ZIP)
WORKDIR := $(TARGET)$(NAME)
+EXT :=
all: setup check $(ARTIFACT)
@@ -28,14 +29,17 @@ clean:
@rm -rf $(TARGET)
$(ARTIFACT): *.*
- @minify -q -o $(WORKDIR)/plugin.js plugin.js
- @cp *.css $(WORKDIR)/
+ @make --no-print-directory _minify EXT=css
+ @make --no-print-directory _minify EXT=js
@sed "s/{VERSION}/$(PLUGIN_VERSION)/g" hphp.php | \
sed "s/{CSS_VERSION}/$(PLUGIN_CSS_VERSION)/g" | \
sed "s/{JS_VERSION}/$(PLUGIN_JS_VERSION)/g" > $(WORKDIR)/hphp.php
@cd $(TARGET) && zip $(ZIP) hphp/*
@echo "zip generated"
+_minify:
+ @for f in $(shell ls *.$(EXT)); do echo "minify: $$f"; minify -q -o $(WORKDIR)/$$f $$f; done
+
check:
@make --no-print-directory _check_hash HAVE_HASH="$(PLUGIN_HASH)" NEED_FILES="*" HASH_NAME=plugin
@make --no-print-directory _check_hash HAVE_HASH="$(PLUGIN_CSS_HASH)" NEED_FILES="css" HASH_NAME=css
diff --git a/plugins/hphp/data-counter-tables.css b/plugins/hphp/data-counter-tables.css
@@ -0,0 +1,39 @@
+.hphp-data-table-display {
+ border: none !important;
+ border-collapse: collapse !important;
+ border-spacing: 0 !important;
+ margin: 20px auto !important;
+ width: 80% !important;
+ font-family: Arial, sans-serif !important;
+}
+
+.hphp-data-table-display tr {
+ padding: 0 !important;
+ margin: 0 !important;
+ border: none !important;
+ vertical-align: middle !important;
+}
+
+.hphp-data-table-display td {
+ border: none !important;
+ padding: 5px !important;
+ margin: 0 !important;
+ height: 25px !important;
+ box-shadow: none !important;
+ background-color: transparent !important;
+}
+
+.hphp-icon-counter {
+ padding-right: 20px !important;
+ padding-left: 10px !important;
+}
+
+.hphp-label-cell {
+ text-align: left !important;
+ font-weight: bold !important;
+}
+
+.hphp-value-cell {
+ text-align: right !important;
+ font-weight: bold !important;
+}
diff --git a/plugins/hphp/hphp.php b/plugins/hphp/hphp.php
@@ -59,9 +59,8 @@ function hphp_sanitize_int( $value ) {
return ( $value > 0 ) ? $value : 0;
}
-function hphp_load_counters( $json ) {
+function hphp_get_counters( $objects ) {
$counters = array();
- $objects = json_decode("$json", $true);
if (property_exists($objects, "counters")) {
foreach ($objects->counters as $key => $value) {
$counters["hphp_counter_" . $key] = $value;
@@ -69,6 +68,10 @@ function hphp_load_counters( $json ) {
}
return $counters;
}
+
+function hphp_load_counters( $json ) {
+ return hphp_get_counters(json_decode("$json"));
+}
function hphp_register_settings_page() {
add_options_page(
@@ -153,19 +156,30 @@ function hphp_render_settings_page() {
}
function hphp_enqueue_assets() {
- wp_enqueue_style(
- 'hphp-style',
- plugin_dir_url( __FILE__ ) . 'style.css',
- array(),
- '{CSS_VERSION}'
- );
- wp_enqueue_script(
- 'hphp-js',
- plugin_dir_url( __FILE__ ) . 'plugin.js',
- array('jquery'),
- '{JS_VERSION}'
- );
$pages = get_option("hphp_pages_allowed", "");
+ $json_payload = get_option("hphp_json_configuration", "{}");
+ $objects = json_decode("$json_payload");
+ if (property_exists($objects, "scripts")) {
+ foreach ($objects->scripts as $key => $value) {
+ $name = "hphp-" . $value . "-" . "$key";
+ $path = plugin_dir_url(__FILE__) . "$key" . "." . $value;
+ if ($value == "js") {
+ wp_enqueue_script(
+ $name,
+ $path,
+ array("jquery"),
+ '{JS_VERSION}'
+ );
+ } elseif ($value == "css") {
+ wp_enqueue_style(
+ $name,
+ $path,
+ array(),
+ '{CSS_VERSION}'
+ );
+ }
+ }
+ }
$allowed = true;
$page_name = "";
$queried = get_queried_object();
@@ -186,8 +200,7 @@ function hphp_enqueue_assets() {
$counter_data = array();
if ($allowed) {
$sums = array();
- $json_payload = get_option("hphp_json_configuration", "{}");
- $counters = hphp_load_counters( $json_payload );
+ $counters = hphp_get_counters($objects);
foreach ($counters as $key => $value) {
if ($value == "int") {
$counter_data[$key] = get_option($key, 0);
@@ -219,6 +232,6 @@ function hphp_enqueue_assets() {
$json_output = json_encode($payload);
$script = "var hphp_data_payload = " . $json_output . ";";
- wp_add_inline_script('hphp-js', $script, 'before');
+ wp_add_inline_script('hphp-js-plugin', $script, 'before');
}
add_action( 'wp_enqueue_scripts', 'hphp_enqueue_assets' );
diff --git a/plugins/hphp/style.css b/plugins/hphp/style.css