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 131 to 186

Definition

 
function get_plugin_yaml($path$validate=true)
    {
    
#We're not using a full YAML structure, so this parsing function will do
    #If validate is false, this function will return an array of blank values if a yaml isn't available
    
$yaml_file_ptr = @fopen($path'r');
    
$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 (
$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;
        }
    if (!isset(
$plugin_yaml['name']))
        {
        
$plugin_yaml['name'] = basename($path,'.yaml');
        }
    if (!isset(
$plugin_yaml['version']))
        {
        
$plugin_yaml['version'] = '0';
        }
        
    return 
$plugin_yaml;
    }

This article was last updated 26th November 2020 04:35 Europe/London time based on the source file dated 9th October 2020 10:20 Europe/London time.