Changeset 3490347
- Timestamp:
- 03/24/2026 08:21:40 PM (8 days ago)
- Location:
- praison-file-content-git
- Files:
-
- 8 edited
- 1 copied
-
tags/1.3.0 (copied) (copied from praison-file-content-git/trunk)
-
tags/1.3.0/praisonpressgit.php (modified) (2 diffs)
-
tags/1.3.0/scripts/export-to-markdown.php (modified) (3 diffs)
-
tags/1.3.0/src/Core/Bootstrap.php (modified) (5 diffs)
-
tags/1.3.0/src/Export/ExportConfig.php (modified) (1 diff)
-
trunk/praisonpressgit.php (modified) (2 diffs)
-
trunk/scripts/export-to-markdown.php (modified) (3 diffs)
-
trunk/src/Core/Bootstrap.php (modified) (5 diffs)
-
trunk/src/Export/ExportConfig.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
praison-file-content-git/tags/1.3.0/praisonpressgit.php
r3490022 r3490347 3 3 * Plugin Name: PraisonAI Git Posts 4 4 * Description: Load WordPress content from files (Markdown, JSON, YAML) without database writes, with Git-based version control 5 * Version: 1. 2.05 * Version: 1.3.0 6 6 * Author: MervinPraison 7 7 * Author URI: https://mer.vin … … 13 13 14 14 // Define constants 15 define('PRAISON_VERSION', '1. 1.0');15 define('PRAISON_VERSION', '1.3.0'); 16 16 define('PRAISON_PLUGIN_DIR', __DIR__); 17 17 define('PRAISON_PLUGIN_URL', trailingslashit(plugins_url('', __FILE__))); -
praison-file-content-git/tags/1.3.0/scripts/export-to-markdown.php
r3426687 r3490347 127 127 $custom_fields = []; 128 128 129 // Load exclude list from ExportConfig if available 130 $exclude_meta = []; 131 if (class_exists('PraisonPress\\Export\\ExportConfig')) { 132 $exportConfig = new PraisonPress\Export\ExportConfig(); 133 $exclude_meta = $exportConfig->getExcludeMeta($post->post_type); 134 } 135 136 // Allow filtering via WordPress hook (generic for all users) 137 $exclude_meta = apply_filters('praison_export_exclude_meta', $exclude_meta, $post->post_type, $post->ID); 138 129 139 // Check if ACF is active 130 140 $has_acf = function_exists('get_fields'); … … 135 145 if ($acf_fields) { 136 146 foreach ($acf_fields as $key => $value) { 137 $custom_fields[$key] = $value; 147 if (!in_array($key, $exclude_meta, true)) { 148 $custom_fields[$key] = $value; 149 } 138 150 } 139 151 } … … 143 155 $all_meta = get_post_meta($post->ID); 144 156 foreach ($all_meta as $key => $value) { 145 // Skip WordPress internal fields and ACF internalfields146 if (strpos($key, '_') !== 0 && !isset($custom_fields[$key]) ) {157 // Skip WordPress internal fields, ACF internal fields, and excluded fields 158 if (strpos($key, '_') !== 0 && !isset($custom_fields[$key]) && !in_array($key, $exclude_meta, true)) { 147 159 $custom_fields[$key] = is_array($value) && count($value) === 1 ? $value[0] : $value; 148 160 } -
praison-file-content-git/tags/1.3.0/src/Core/Bootstrap.php
r3490022 r3490347 318 318 // If no file-based posts, return database posts as-is 319 319 if (empty($file_posts)) { 320 if ( function_exists('do_action')) {320 if (get_option('praisonpress_qm_logging')) { 321 321 do_action('qm/debug', sprintf( 322 322 '[PraisonPress] DB fallback for "%s" (post_type=%s)', … … 331 331 // This happens when WordPress hasn't queried the database yet 332 332 if ($posts === null) { 333 if ( function_exists('do_action')) {333 if (get_option('praisonpress_qm_logging')) { 334 334 do_action('qm/info', sprintf( 335 335 '[PraisonPress] ✅ HEADLESS: Serving %d post(s) from Git files (post_type=%s, slug=%s)', … … 344 344 // MERGE: Combine database posts with file-based posts 345 345 // File-based posts take precedence for duplicate slugs 346 if ( function_exists('do_action')) {346 if (get_option('praisonpress_qm_logging')) { 347 347 do_action('qm/info', sprintf( 348 348 '[PraisonPress] ✅ HEADLESS+MERGE: %d file post(s) + %d DB post(s) (post_type=%s)', … … 588 588 */ 589 589 public function renderSettingsPage() { 590 // Handle settings save 591 if (isset($_POST['praisonpress_save_settings']) && check_admin_referer('praisonpress_settings_nonce')) { 592 $qm_logging = isset($_POST['praisonpress_qm_logging']) ? 1 : 0; 593 update_option('praisonpress_qm_logging', $qm_logging); 594 echo '<div class="notice notice-success"><p>✅ Settings saved.</p></div>'; 595 } 596 597 $qm_enabled = get_option('praisonpress_qm_logging', 0); 590 598 ?> 591 599 <div class="wrap"> … … 593 601 594 602 <div class="card" style="max-width: 800px;"> 603 <h2>🔍 Diagnostics</h2> 604 <form method="post"> 605 <?php wp_nonce_field('praisonpress_settings_nonce'); ?> 606 <table class="form-table"> 607 <tr> 608 <th scope="row">Query Monitor Logging</th> 609 <td> 610 <label> 611 <input type="checkbox" name="praisonpress_qm_logging" value="1" <?php checked($qm_enabled, 1); ?> /> 612 Enable headless content source logging in Query Monitor 613 </label> 614 <p class="description">When enabled, each page load logs whether content was served from Git files or the database. Visible in Query Monitor's "Logs" panel. No performance impact when disabled.</p> 615 </td> 616 </tr> 617 </table> 618 <p class="submit"> 619 <input type="submit" name="praisonpress_save_settings" class="button button-primary" value="Save Settings" /> 620 </p> 621 </form> 622 </div> 623 624 <div class="card" style="max-width: 800px; margin-top: 20px;"> 595 625 <h2>⚙️ Configuration</h2> 596 626 <p>Edit your configuration file at:</p> -
praison-file-content-git/tags/1.3.0/src/Export/ExportConfig.php
r3426687 r3490347 175 175 176 176 /** 177 * Get meta fields to exclude from export. 178 * Merges global [exclude_meta] keys with per-post-type exclude_meta. 179 * 180 * @param string $postType Post type name 181 * @return array Array of meta field names to exclude 182 */ 183 public function getExcludeMeta($postType) { 184 // Global excludes from [exclude_meta] section 185 $globalExcludes = []; 186 if (isset($this->config['exclude_meta'])) { 187 $globalExcludes = array_keys(array_filter($this->config['exclude_meta'])); 188 } 189 190 // Per-post-type excludes 191 $config = $this->getPostTypeConfig($postType); 192 $typeExcludes = []; 193 if (isset($config['exclude_meta'])) { 194 if (is_string($config['exclude_meta'])) { 195 $typeExcludes = array_map('trim', explode(',', $config['exclude_meta'])); 196 } elseif (is_array($config['exclude_meta'])) { 197 $typeExcludes = $config['exclude_meta']; 198 } 199 } 200 201 return array_unique(array_merge($globalExcludes, $typeExcludes)); 202 } 203 204 /** 177 205 * Generate file path for a post based on configuration 178 206 * -
praison-file-content-git/trunk/praisonpressgit.php
r3490022 r3490347 3 3 * Plugin Name: PraisonAI Git Posts 4 4 * Description: Load WordPress content from files (Markdown, JSON, YAML) without database writes, with Git-based version control 5 * Version: 1. 2.05 * Version: 1.3.0 6 6 * Author: MervinPraison 7 7 * Author URI: https://mer.vin … … 13 13 14 14 // Define constants 15 define('PRAISON_VERSION', '1. 1.0');15 define('PRAISON_VERSION', '1.3.0'); 16 16 define('PRAISON_PLUGIN_DIR', __DIR__); 17 17 define('PRAISON_PLUGIN_URL', trailingslashit(plugins_url('', __FILE__))); -
praison-file-content-git/trunk/scripts/export-to-markdown.php
r3426687 r3490347 127 127 $custom_fields = []; 128 128 129 // Load exclude list from ExportConfig if available 130 $exclude_meta = []; 131 if (class_exists('PraisonPress\\Export\\ExportConfig')) { 132 $exportConfig = new PraisonPress\Export\ExportConfig(); 133 $exclude_meta = $exportConfig->getExcludeMeta($post->post_type); 134 } 135 136 // Allow filtering via WordPress hook (generic for all users) 137 $exclude_meta = apply_filters('praison_export_exclude_meta', $exclude_meta, $post->post_type, $post->ID); 138 129 139 // Check if ACF is active 130 140 $has_acf = function_exists('get_fields'); … … 135 145 if ($acf_fields) { 136 146 foreach ($acf_fields as $key => $value) { 137 $custom_fields[$key] = $value; 147 if (!in_array($key, $exclude_meta, true)) { 148 $custom_fields[$key] = $value; 149 } 138 150 } 139 151 } … … 143 155 $all_meta = get_post_meta($post->ID); 144 156 foreach ($all_meta as $key => $value) { 145 // Skip WordPress internal fields and ACF internalfields146 if (strpos($key, '_') !== 0 && !isset($custom_fields[$key]) ) {157 // Skip WordPress internal fields, ACF internal fields, and excluded fields 158 if (strpos($key, '_') !== 0 && !isset($custom_fields[$key]) && !in_array($key, $exclude_meta, true)) { 147 159 $custom_fields[$key] = is_array($value) && count($value) === 1 ? $value[0] : $value; 148 160 } -
praison-file-content-git/trunk/src/Core/Bootstrap.php
r3490022 r3490347 318 318 // If no file-based posts, return database posts as-is 319 319 if (empty($file_posts)) { 320 if ( function_exists('do_action')) {320 if (get_option('praisonpress_qm_logging')) { 321 321 do_action('qm/debug', sprintf( 322 322 '[PraisonPress] DB fallback for "%s" (post_type=%s)', … … 331 331 // This happens when WordPress hasn't queried the database yet 332 332 if ($posts === null) { 333 if ( function_exists('do_action')) {333 if (get_option('praisonpress_qm_logging')) { 334 334 do_action('qm/info', sprintf( 335 335 '[PraisonPress] ✅ HEADLESS: Serving %d post(s) from Git files (post_type=%s, slug=%s)', … … 344 344 // MERGE: Combine database posts with file-based posts 345 345 // File-based posts take precedence for duplicate slugs 346 if ( function_exists('do_action')) {346 if (get_option('praisonpress_qm_logging')) { 347 347 do_action('qm/info', sprintf( 348 348 '[PraisonPress] ✅ HEADLESS+MERGE: %d file post(s) + %d DB post(s) (post_type=%s)', … … 588 588 */ 589 589 public function renderSettingsPage() { 590 // Handle settings save 591 if (isset($_POST['praisonpress_save_settings']) && check_admin_referer('praisonpress_settings_nonce')) { 592 $qm_logging = isset($_POST['praisonpress_qm_logging']) ? 1 : 0; 593 update_option('praisonpress_qm_logging', $qm_logging); 594 echo '<div class="notice notice-success"><p>✅ Settings saved.</p></div>'; 595 } 596 597 $qm_enabled = get_option('praisonpress_qm_logging', 0); 590 598 ?> 591 599 <div class="wrap"> … … 593 601 594 602 <div class="card" style="max-width: 800px;"> 603 <h2>🔍 Diagnostics</h2> 604 <form method="post"> 605 <?php wp_nonce_field('praisonpress_settings_nonce'); ?> 606 <table class="form-table"> 607 <tr> 608 <th scope="row">Query Monitor Logging</th> 609 <td> 610 <label> 611 <input type="checkbox" name="praisonpress_qm_logging" value="1" <?php checked($qm_enabled, 1); ?> /> 612 Enable headless content source logging in Query Monitor 613 </label> 614 <p class="description">When enabled, each page load logs whether content was served from Git files or the database. Visible in Query Monitor's "Logs" panel. No performance impact when disabled.</p> 615 </td> 616 </tr> 617 </table> 618 <p class="submit"> 619 <input type="submit" name="praisonpress_save_settings" class="button button-primary" value="Save Settings" /> 620 </p> 621 </form> 622 </div> 623 624 <div class="card" style="max-width: 800px; margin-top: 20px;"> 595 625 <h2>⚙️ Configuration</h2> 596 626 <p>Edit your configuration file at:</p> -
praison-file-content-git/trunk/src/Export/ExportConfig.php
r3426687 r3490347 175 175 176 176 /** 177 * Get meta fields to exclude from export. 178 * Merges global [exclude_meta] keys with per-post-type exclude_meta. 179 * 180 * @param string $postType Post type name 181 * @return array Array of meta field names to exclude 182 */ 183 public function getExcludeMeta($postType) { 184 // Global excludes from [exclude_meta] section 185 $globalExcludes = []; 186 if (isset($this->config['exclude_meta'])) { 187 $globalExcludes = array_keys(array_filter($this->config['exclude_meta'])); 188 } 189 190 // Per-post-type excludes 191 $config = $this->getPostTypeConfig($postType); 192 $typeExcludes = []; 193 if (isset($config['exclude_meta'])) { 194 if (is_string($config['exclude_meta'])) { 195 $typeExcludes = array_map('trim', explode(',', $config['exclude_meta'])); 196 } elseif (is_array($config['exclude_meta'])) { 197 $typeExcludes = $config['exclude_meta']; 198 } 199 } 200 201 return array_unique(array_merge($globalExcludes, $typeExcludes)); 202 } 203 204 /** 177 205 * Generate file path for a post based on configuration 178 206 *
Note: See TracChangeset
for help on using the changeset viewer.