Plugin Directory

Changeset 3489910


Ignore:
Timestamp:
03/24/2026 11:17:45 AM (9 days ago)
Author:
mervinpraison
Message:

Update to version 1.1.1 from GitHub

Location:
praison-file-content-git
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • praison-file-content-git/tags/1.1.1/praisonpressgit.php

    r3489866 r3489910  
    33 * Plugin Name: PraisonAI Git Posts
    44 * Description: Load WordPress content from files (Markdown, JSON, YAML) without database writes, with Git-based version control
    5  * Version: 1.1.0
     5 * Version: 1.1.1
    66 * Author: MervinPraison
    77 * Author URI: https://mer.vin
  • praison-file-content-git/tags/1.1.1/src/Core/Bootstrap.php

    r3488026 r3489910  
    1717    private $postLoaders = [];
    1818    private $postTypes = [];
     19    private $allowedPostTypes = null;
    1920   
    2021    /**
     
    104105   
    105106    /**
     107     * Get the allowed post types from site-config.ini
     108     *
     109     * @return array|null Array of allowed types, or null if setting doesn't exist (allow all)
     110     */
     111    private function getAllowedPostTypes() {
     112        if ($this->allowedPostTypes !== null) {
     113            return $this->allowedPostTypes;
     114        }
     115       
     116        $config_file = PRAISON_PLUGIN_DIR . '/site-config.ini';
     117        if (file_exists($config_file)) {
     118            $config = parse_ini_file($config_file, true);
     119            if (isset($config['content']['post_types']) && is_array($config['content']['post_types'])) {
     120                $this->allowedPostTypes = $config['content']['post_types'];
     121                return $this->allowedPostTypes;
     122            }
     123        }
     124       
     125        $this->allowedPostTypes = false; // Use false internally to denote "checked but not found"
     126        return null; // Return null to mean "allow all"
     127    }
     128
     129    /**
    106130     * Dynamically discover post types from content directory
    107131     * Scans folders and auto-registers them as post types
     
    120144        $items = scandir(PRAISON_CONTENT_DIR);
    121145       
     146        $allowed = $this->getAllowedPostTypes();
     147       
    122148        foreach ($items as $item) {
    123149            // Skip hidden files, current/parent directory references
     
    130156            // Only process directories
    131157            if (is_dir($path)) {
     158                // If allowed list is defined in config, skip post types not in the list
     159                // Note: The directory name for 'post' is 'posts', so check both
     160                if ($allowed !== null) {
     161                    $check_name = ($item === 'posts') ? 'post' : $item;
     162                    if (!in_array($check_name, $allowed, true)) {
     163                        continue;
     164                    }
     165                }
     166               
    132167                $types[] = $item;
    133168            }
     
    215250        if (empty($post_type)) {
    216251            if ($query->is_main_query() && (is_home() || is_archive())) {
    217                 // Check if posts loader exists before calling
    218                 if (isset($this->postLoaders['posts'])) {
    219                     return $this->postLoaders['posts']->loadPosts($query);
     252                $allowed = $this->getAllowedPostTypes();
     253                // Check if 'post' is allowed to be file-based
     254                if ($allowed === null || in_array('post', $allowed, true)) {
     255                    // Check if posts loader exists before calling
     256                    if (isset($this->postLoaders['posts'])) {
     257                        return $this->postLoaders['posts']->loadPosts($query);
     258                    }
    220259                }
    221260            }
    222261            return $posts;
     262        }
     263       
     264        // Skip injection if this post type is explicitly excluded from site-config.ini
     265        $allowed = $this->getAllowedPostTypes();
     266        if ($allowed !== null) {
     267            // Handle array of post types or single string
     268            $types_to_check = is_array($post_type) ? $post_type : [$post_type];
     269            $has_allowed = false;
     270           
     271            foreach ($types_to_check as $type) {
     272                // Translate internal post type back to standard if needed
     273                $check_type = ($type === 'praison_post') ? 'post' : $type;
     274                if (in_array($check_type, $allowed, true)) {
     275                    $has_allowed = true;
     276                    break;
     277                }
     278            }
     279           
     280            if (!$has_allowed) {
     281                return $posts;
     282            }
    223283        }
    224284       
  • praison-file-content-git/trunk/praisonpressgit.php

    r3489866 r3489910  
    33 * Plugin Name: PraisonAI Git Posts
    44 * Description: Load WordPress content from files (Markdown, JSON, YAML) without database writes, with Git-based version control
    5  * Version: 1.1.0
     5 * Version: 1.1.1
    66 * Author: MervinPraison
    77 * Author URI: https://mer.vin
  • praison-file-content-git/trunk/src/Core/Bootstrap.php

    r3488026 r3489910  
    1717    private $postLoaders = [];
    1818    private $postTypes = [];
     19    private $allowedPostTypes = null;
    1920   
    2021    /**
     
    104105   
    105106    /**
     107     * Get the allowed post types from site-config.ini
     108     *
     109     * @return array|null Array of allowed types, or null if setting doesn't exist (allow all)
     110     */
     111    private function getAllowedPostTypes() {
     112        if ($this->allowedPostTypes !== null) {
     113            return $this->allowedPostTypes;
     114        }
     115       
     116        $config_file = PRAISON_PLUGIN_DIR . '/site-config.ini';
     117        if (file_exists($config_file)) {
     118            $config = parse_ini_file($config_file, true);
     119            if (isset($config['content']['post_types']) && is_array($config['content']['post_types'])) {
     120                $this->allowedPostTypes = $config['content']['post_types'];
     121                return $this->allowedPostTypes;
     122            }
     123        }
     124       
     125        $this->allowedPostTypes = false; // Use false internally to denote "checked but not found"
     126        return null; // Return null to mean "allow all"
     127    }
     128
     129    /**
    106130     * Dynamically discover post types from content directory
    107131     * Scans folders and auto-registers them as post types
     
    120144        $items = scandir(PRAISON_CONTENT_DIR);
    121145       
     146        $allowed = $this->getAllowedPostTypes();
     147       
    122148        foreach ($items as $item) {
    123149            // Skip hidden files, current/parent directory references
     
    130156            // Only process directories
    131157            if (is_dir($path)) {
     158                // If allowed list is defined in config, skip post types not in the list
     159                // Note: The directory name for 'post' is 'posts', so check both
     160                if ($allowed !== null) {
     161                    $check_name = ($item === 'posts') ? 'post' : $item;
     162                    if (!in_array($check_name, $allowed, true)) {
     163                        continue;
     164                    }
     165                }
     166               
    132167                $types[] = $item;
    133168            }
     
    215250        if (empty($post_type)) {
    216251            if ($query->is_main_query() && (is_home() || is_archive())) {
    217                 // Check if posts loader exists before calling
    218                 if (isset($this->postLoaders['posts'])) {
    219                     return $this->postLoaders['posts']->loadPosts($query);
     252                $allowed = $this->getAllowedPostTypes();
     253                // Check if 'post' is allowed to be file-based
     254                if ($allowed === null || in_array('post', $allowed, true)) {
     255                    // Check if posts loader exists before calling
     256                    if (isset($this->postLoaders['posts'])) {
     257                        return $this->postLoaders['posts']->loadPosts($query);
     258                    }
    220259                }
    221260            }
    222261            return $posts;
     262        }
     263       
     264        // Skip injection if this post type is explicitly excluded from site-config.ini
     265        $allowed = $this->getAllowedPostTypes();
     266        if ($allowed !== null) {
     267            // Handle array of post types or single string
     268            $types_to_check = is_array($post_type) ? $post_type : [$post_type];
     269            $has_allowed = false;
     270           
     271            foreach ($types_to_check as $type) {
     272                // Translate internal post type back to standard if needed
     273                $check_type = ($type === 'praison_post') ? 'post' : $type;
     274                if (in_array($check_type, $allowed, true)) {
     275                    $has_allowed = true;
     276                    break;
     277                }
     278            }
     279           
     280            if (!$has_allowed) {
     281                return $posts;
     282            }
    223283        }
    224284       
Note: See TracChangeset for help on using the changeset viewer.