Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@
if (!titleInput) return;

// Meta keys (with leading underscore) map to DOM ids by stripping the
// leading "_ot_" and re-prefixing with "ot_".
// leading underscore: `_opentrust_cert_type` → `opentrust_cert_type`.
var metaKeyToDomId = function (metaKey) {
return metaKey.replace(/^_ot_/, 'ot_');
return metaKey.replace(/^_opentrust_/, 'opentrust_');
};

var normalize = function (value) {
Expand Down Expand Up @@ -801,7 +801,7 @@
* Certification type toggle.
*
* Shows or hides the "certified only" fields (issuing body, status, dates)
* based on the `_ot_cert_type` select. A compliant certification has no
* based on the `_opentrust_cert_type` select. A compliant certification has no
* audit and therefore no auditor, no issue date, no expiry, and no status
* state machine, so those fields are hidden from the form entirely.
* Hidden inputs still submit their values, which matches the "keep data
Expand Down Expand Up @@ -836,7 +836,7 @@
(function () {
'use strict';

var toggle = document.getElementById('ot_publish_new_version');
var toggle = document.getElementById('opentrust_publish_new_version');
if (!toggle) return;

toggle.addEventListener('change', function () {
Expand All @@ -845,7 +845,7 @@
wrap.style.display = this.checked ? 'block' : 'none';
}
if (this.checked) {
var summary = document.getElementById('ot_version_summary');
var summary = document.getElementById('opentrust_version_summary');
if (summary) summary.focus();
}
});
Expand Down
3 changes: 1 addition & 2 deletions includes/class-opentrust-admin-ai.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,7 @@ public static function cron_refresh_all_providers(): void {
$self = self::instance();
$settings = OpenTrust::get_settings();
$active = (string) ($settings['ai_provider'] ?? '');
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- diagnostic for cron refresh failures
$log = static fn(string $slug, string $why) => error_log("[OpenTrust] AI model refresh failed for {$slug}: {$why}");
$log = static fn(string $slug, string $why) => OpenTrust::debug_log("AI model refresh failed for {$slug}: {$why}");
$dirty = false;

foreach ($stored_keys as $slug => $api_key) {
Expand Down
40 changes: 20 additions & 20 deletions includes/class-opentrust-admin-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ private function render_export_panel(array $exportable): void {
<fieldset class="ot-tools-fieldset">
<legend><?php esc_html_e('What to export', 'opentrust'); ?></legend>
<label class="ot-tools-radio">
<input type="radio" name="ot_export_kind" value="content" checked>
<input type="radio" name="opentrust_export_kind" value="content" checked>
<?php esc_html_e('Content (CPTs + bundled media)', 'opentrust'); ?>
</label>
<label class="ot-tools-radio">
<input type="radio" name="ot_export_kind" value="settings">
<input type="radio" name="opentrust_export_kind" value="settings">
<?php esc_html_e('Settings only', 'opentrust'); ?>
</label>
</fieldset>
Expand All @@ -199,15 +199,15 @@ private function render_export_panel(array $exportable): void {
?>
<details class="ot-tools-cpt-group">
<summary>
<input type="checkbox" name="ot_export_cpt[<?php echo esc_attr($cpt); ?>]" value="all" checked>
<input type="checkbox" name="opentrust_export_cpt[<?php echo esc_attr($cpt); ?>]" value="all" checked>
<?php echo esc_html($label); ?>
<span class="ot-tools-count">(<?php echo (int) $count; ?>)</span>
</summary>
<ul>
<?php foreach ($items as $item): ?>
<li>
<label>
<input type="checkbox" name="ot_export_ids[<?php echo esc_attr($cpt); ?>][]" value="<?php echo (int) $item['id']; ?>" checked>
<input type="checkbox" name="opentrust_export_ids[<?php echo esc_attr($cpt); ?>][]" value="<?php echo (int) $item['id']; ?>" checked>
<?php echo esc_html($item['title']); ?>
<?php if ($item['status'] !== 'publish'): ?>
<em class="ot-tools-status">(<?php echo esc_html($item['status']); ?>)</em>
Expand All @@ -221,7 +221,7 @@ private function render_export_panel(array $exportable): void {
</fieldset>

<label class="ot-tools-radio">
<input type="checkbox" name="ot_include_media" value="1" checked>
<input type="checkbox" name="opentrust_include_media" value="1" checked>
<?php esc_html_e('Bundle attached PDFs and images', 'opentrust'); ?>
</label>

Expand All @@ -245,8 +245,8 @@ private function render_import_panel(): void {
</div>

<p>
<label for="ot_import_file"><strong><?php esc_html_e('Upload export file', 'opentrust'); ?></strong></label><br>
<input type="file" id="ot_import_file" name="ot_import_file" accept=".zip" required>
<label for="opentrust_import_file"><strong><?php esc_html_e('Upload export file', 'opentrust'); ?></strong></label><br>
<input type="file" id="opentrust_import_file" name="opentrust_import_file" accept=".zip" required>
<span class="ot-tools-hint">
<?php
/* translators: %d: max upload size in MB */
Expand All @@ -258,15 +258,15 @@ private function render_import_panel(): void {
<fieldset class="ot-tools-fieldset">
<legend><?php esc_html_e('On conflict', 'opentrust'); ?></legend>
<label class="ot-tools-radio">
<input type="radio" name="ot_strategy" value="skip" checked>
<input type="radio" name="opentrust_strategy" value="skip" checked>
<?php esc_html_e('Skip — keep existing records untouched', 'opentrust'); ?>
</label>
<label class="ot-tools-radio">
<input type="radio" name="ot_strategy" value="overwrite">
<input type="radio" name="opentrust_strategy" value="overwrite">
<?php esc_html_e('Overwrite — replace existing records', 'opentrust'); ?>
</label>
<label class="ot-tools-radio">
<input type="radio" name="ot_strategy" value="create_new">
<input type="radio" name="opentrust_strategy" value="create_new">
<?php esc_html_e('Create new — duplicate with a -import suffix', 'opentrust'); ?>
</label>
</fieldset>
Expand Down Expand Up @@ -360,7 +360,7 @@ private function render_preview_screen(array $preview): void {
<?php if (empty($preview['errors'])): ?>
<button type="submit" class="button button-primary"><?php esc_html_e('Confirm and import', 'opentrust'); ?></button>
<?php endif; ?>
<button type="submit" name="ot_cancel" value="1" class="button"><?php esc_html_e('Cancel', 'opentrust'); ?></button>
<button type="submit" name="opentrust_cancel" value="1" class="button"><?php esc_html_e('Cancel', 'opentrust'); ?></button>
</form>
<?php
}
Expand All @@ -372,8 +372,8 @@ private function render_preview_screen(array $preview): void {
public function handle_export(): void {
$this->guard('opentrust_export');

$kind = isset($_POST['ot_export_kind']) ? sanitize_key((string) wp_unslash($_POST['ot_export_kind'])) : 'content';
$include_media = !empty($_POST['ot_include_media']);
$kind = isset($_POST['opentrust_export_kind']) ? sanitize_key((string) wp_unslash($_POST['opentrust_export_kind'])) : 'content';
$include_media = !empty($_POST['opentrust_include_media']);

try {
if ($kind === 'settings') {
Expand Down Expand Up @@ -411,12 +411,12 @@ public function handle_export(): void {
public function handle_import_preview(): void {
$this->guard('opentrust_import_preview');

if (empty($_FILES['ot_import_file']['tmp_name']) || !is_uploaded_file((string) $_FILES['ot_import_file']['tmp_name'])) {
if (empty($_FILES['opentrust_import_file']['tmp_name']) || !is_uploaded_file((string) $_FILES['opentrust_import_file']['tmp_name'])) {
$this->bounce_error(__('No file uploaded.', 'opentrust'));
return;
}

$size = (int) ($_FILES['ot_import_file']['size'] ?? 0);
$size = (int) ($_FILES['opentrust_import_file']['size'] ?? 0);
if ($size > self::UPLOAD_MAX_MB * 1024 * 1024) {
$this->bounce_error(__('Upload exceeds size limit.', 'opentrust'));
return;
Expand All @@ -438,7 +438,7 @@ public function handle_import_preview(): void {
// application/x-zip-compressed to application/zip, so one entry covers all
// browsers without tripping the get_allowed_mime_types() global allowlist.
$upload = wp_handle_upload(
$_FILES['ot_import_file'],
$_FILES['opentrust_import_file'],
[
'test_form' => false,
'mimes' => ['zip' => 'application/zip'],
Expand All @@ -461,7 +461,7 @@ public function handle_import_preview(): void {
$manifest = $read['manifest'];
$check = OpenTrust_IO::validate_manifest($manifest);

$strategy = isset($_POST['ot_strategy']) ? sanitize_key((string) wp_unslash($_POST['ot_strategy'])) : OpenTrust_IO::STRATEGY_SKIP;
$strategy = isset($_POST['opentrust_strategy']) ? sanitize_key((string) wp_unslash($_POST['opentrust_strategy'])) : OpenTrust_IO::STRATEGY_SKIP;

$preview = [
'manifest' => $manifest,
Expand Down Expand Up @@ -506,7 +506,7 @@ public function handle_import_apply(): void {
$stash_key = 'opentrust_io_preview_' . get_current_user_id();
$preview = get_transient($stash_key);

if (!empty($_POST['ot_cancel']) || !is_array($preview)) {
if (!empty($_POST['opentrust_cancel']) || !is_array($preview)) {
if (is_array($preview) && !empty($preview['zip_path'])) {
wp_delete_file((string) $preview['zip_path']);
}
Expand Down Expand Up @@ -568,8 +568,8 @@ private function guard(string $nonce_action): void {
}

private function parse_selection(array $post): array {
$cpts = isset($post['ot_export_cpt']) && is_array($post['ot_export_cpt']) ? $post['ot_export_cpt'] : [];
$ids = isset($post['ot_export_ids']) && is_array($post['ot_export_ids']) ? $post['ot_export_ids'] : [];
$cpts = isset($post['opentrust_export_cpt']) && is_array($post['opentrust_export_cpt']) ? $post['opentrust_export_cpt'] : [];
$ids = isset($post['opentrust_export_ids']) && is_array($post['opentrust_export_ids']) ? $post['opentrust_export_ids'] : [];

$out = [];
foreach ($cpts as $cpt => $_) {
Expand Down
6 changes: 3 additions & 3 deletions includes/class-opentrust-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public function enqueue_assets(string $hook): void {
return;
}

$is_ot_screen = str_starts_with($screen->id, 'toplevel_page_opentrust')
$is_opentrust_screen = str_starts_with($screen->id, 'toplevel_page_opentrust')
|| str_starts_with($screen->id, 'opentrust_page_')
|| in_array($screen->post_type, OpenTrust_CPT::CORPUS, true);

if (!$is_ot_screen) {
if (!$is_opentrust_screen) {
return;
}

Expand Down Expand Up @@ -247,7 +247,7 @@ public function render_plain_permalinks_notice(): void {
</p>
<ul style="margin:0 0 0 18px;list-style:disc">
<li><code><?php echo esc_html($home_url); ?>?opentrust=main</code></li>
<li><code><?php echo esc_html($home_url); ?>?opentrust=policy&amp;ot_policy_slug=YOUR-POLICY-SLUG</code></li>
<li><code><?php echo esc_html($home_url); ?>?opentrust=policy&amp;opentrust_policy_slug=YOUR-POLICY-SLUG</code></li>
<li><code><?php echo esc_html($home_url); ?>?opentrust=ask</code></li>
</ul>
<p style="margin:6px 0 0">
Expand Down
8 changes: 4 additions & 4 deletions includes/class-opentrust-catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ public static function faqs(): array {
*
* Gated by the `opentrust_faqs_seeded` option so deletions stick: once a
* site has been seeded, re-activating the plugin will not recreate the
* FAQs. Each seeded post is tagged with `_ot_seeded=1` and a stable
* `_ot_seed_slug` meta for later bulk operations.
* FAQs. Each seeded post is tagged with `_opentrust_seeded=1` and a stable
* `_opentrust_seed_slug` meta for later bulk operations.
*/
public static function seed_default_faqs(): void {
if ( get_option( 'opentrust_faqs_seeded' ) ) {
Expand All @@ -164,8 +164,8 @@ public static function seed_default_faqs(): void {
);

if ( is_int( $post_id ) && $post_id > 0 ) {
update_post_meta( $post_id, '_ot_seeded', 1 );
update_post_meta( $post_id, '_ot_seed_slug', $slug );
update_post_meta( $post_id, '_opentrust_seeded', 1 );
update_post_meta( $post_id, '_opentrust_seed_slug', $slug );
}
}

Expand Down
10 changes: 5 additions & 5 deletions includes/class-opentrust-chat-corpus.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class OpenTrust_Chat_Corpus {
* Read here; written by OpenTrust_Chat_Summarizer. Defined in the corpus
* class so this file works whether the summarizer class is loaded or not.
*/
public const POLICY_SUMMARY_META = '_ot_policy_chat_summary';
public const POLICY_SUMMARY_META = '_opentrust_policy_chat_summary';

// ──────────────────────────────────────────────
// Cache
Expand Down Expand Up @@ -455,7 +455,7 @@ private static function maybe_truncate_content(string $content, string $url): ar

/**
* Resolve the index summary for a policy. Fallback ladder:
* 1. _ot_policy_chat_summary postmeta if non-empty.
* 1. _opentrust_policy_chat_summary postmeta if non-empty.
* 2. post_excerpt (stripped + collapsed) if non-empty.
* 3. First 240 chars of the stripped post_content with ellipsis.
*/
Expand Down Expand Up @@ -497,10 +497,10 @@ private static function format_policy(\WP_Post $post, array $settings): array {
$url = home_url('/' . $endpoint . '/policy/' . $post->post_name . '/');

$category_labels = OpenTrust_Render::policy_category_labels();
$category = (string) (get_post_meta($post->ID, '_ot_policy_category', true) ?: 'other');
$category = (string) (get_post_meta($post->ID, '_opentrust_policy_category', true) ?: 'other');
$category_label = $category_labels[$category] ?? $category;
$effective = (string) get_post_meta($post->ID, '_ot_policy_effective_date', true);
$version = (int) (get_post_meta($post->ID, '_ot_version', true) ?: 1);
$effective = (string) get_post_meta($post->ID, '_opentrust_policy_effective_date', true);
$version = (int) (get_post_meta($post->ID, '_opentrust_version', true) ?: 1);

// Strip block-editor markup down to plain text.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- core filter.
Expand Down
9 changes: 4 additions & 5 deletions includes/class-opentrust-chat-summarizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ final class OpenTrust_Chat_Summarizer {
* Postmeta key. Mirror of OpenTrust_Chat_Corpus::POLICY_SUMMARY_META —
* declared in both classes so neither file requires the other to load.
*/
public const META_KEY = '_ot_policy_chat_summary';
public const META_KEY_UPDATED_AT = '_ot_policy_chat_summary_updated_at';
public const META_KEY_ORIGIN = '_ot_policy_chat_summary_origin'; // 'auto' | 'manual'
public const META_KEY = '_opentrust_policy_chat_summary';
public const META_KEY_UPDATED_AT = '_opentrust_policy_chat_summary_updated_at';
public const META_KEY_ORIGIN = '_opentrust_policy_chat_summary_origin'; // 'auto' | 'manual'

public const CRON_HOOK = 'opentrust_generate_policy_summary';
public const SUMMARY_MAX_CHARS = 320;
Expand Down Expand Up @@ -317,7 +317,6 @@ private static function clean_summary(string $raw): string {
}

private static function log_failure(int $post_id, string $reason): void {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- diagnostic for upstream provider failures
error_log(sprintf('[OpenTrust] policy summary generation failed for post %d: %s', $post_id, $reason));
OpenTrust::debug_log(sprintf('policy summary generation failed for post %d: %s', $post_id, $reason));
}
}
Loading
Loading