Example #1
0
/**
 * Returns default settings for the plugin
 */
function amcharts_get_defaults()
{
    $settings = array('location' => 'remote', 'own' => '0', 'paths' => '', 'wrap' => '1', 'resources' => amcharts_get_available_resources(), 'custom_resources' => '', 'chart_types' => array());
    $chart_libs = amcharts_get_chart_type_libs();
    foreach ($chart_libs as $chart_type => $libs) {
        $settings['chart_types'][$chart_type] = array('default_resources' => amcharts_get_resources($libs, $settings['resources']), 'custom_resources' => 0, 'default_html' => amcharts_get_default($chart_type, 'html'), 'default_javascript' => amcharts_get_default($chart_type, 'javascript'));
    }
    return $settings;
}
Example #2
0
function amcharts_check_version()
{
    $version = get_option('amcharts_version', '1.0.0');
    if ($version != AMCHARTS_VERSION) {
        // get numeric representation
        $version = str_replace('.', '', $version);
        // the version does not match
        // run necessary checks
        $settings = get_option('amcharts_options', array());
        $chart_libs = amcharts_get_chart_type_libs();
        $resources = amcharts_get_available_resources();
        // 1.0.8 and down
        if ($version <= 108) {
            // populate gantt chart type defaults
            $settings['chart_types']['gantt'] = array('default_resources' => amcharts_get_resources($chart_libs['gantt'], $resources), 'custom_resources' => 0, 'default_html' => amcharts_get_default('gantt', 'html'), 'default_javascript' => amcharts_get_default('gantt', 'javascript'));
        }
        // 1.0.9 and down
        if ($version <= 109) {
            // refresh resource list (to include CSS files)
            $settings['resources'] = amcharts_get_available_resources($settings['location'], $settings['paths']);
        }
        update_option('amcharts_options', $settings);
        // update the version
        update_option('amcharts_version', AMCHARTS_VERSION);
    }
}