Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_plugin_yaml()

Parameters

ColumnTypeDefaultDescription
$path
$validate true

Location

include/plugin_functions.php lines 132 to 186

Definition

 
function get_plugin_yaml($path$validate=true)
    {
    
#We're not using a full YAML structure, so this parsing function will do
    
$plugin_yaml['name'] = basename($path'.yaml');
    
$plugin_yaml['version'] = '0';
    
$plugin_yaml['author'] = '';
    
$plugin_yaml['info_url'] = '';
    
$plugin_yaml['update_url'] = '';
    
$plugin_yaml['config_url'] = '';
    
$plugin_yaml['desc'] = '';
    
$plugin_yaml['default_priority'] = '999';
    
$plugin_yaml['disable_group_select'] = '0';
    
$plugin_yaml['title'] = '';
    
$plugin_yaml['icon'] = '';

    if(!(
file_exists($path) && is_readable($path)))
        {
        return (
$validate false $plugin_yaml);
        }
    
$yaml_file_ptr fopen($path'r');

    if (
$yaml_file_ptr!=false)
        {
        while ((
$line fgets($yaml_file_ptr))!='')
            {
            if(
$line[0]!='#'#Exclude comments from parsing
                
{
                if ((
$pos=strpos($line,':'))!=false)
                    {
                    
$plugin_yaml[trim(substr($line,0,$pos))] = trim(substr($line$pos+1));
                    }
                }
            }
            
        if (
$plugin_yaml['config_url']!='' && $plugin_yaml['config_url'][0]=='/'# Strip leading spaces from the config url.
            
{
            
trim($plugin_yaml['config_url'], '/');
            }
        
fclose($yaml_file_ptr);
        if (
$validate)
            {
            if (isset(
$plugin_yaml['name']) && $plugin_yaml['name']==basename($path,'.yaml') && isset($plugin_yaml['version']))
                {
                return 
$plugin_yaml;
                }
            else return 
false;
            }
        }
    elseif (
$validate)
        {
        return 
false;
        }

    return 
$plugin_yaml;
    }

This article was last updated 9th March 2021 05:05 Europe/London time based on the source file dated 4th March 2021 12:05 Europe/London time.