' . $config['message'] . '
'; } // Alias for getting i18n strings for this plugin function hello_world_i18n($key) { return i18n_r(HELLO_WORLD . '/' . $key); } // Administration panel function hello_world_admin() { // Initialize the configuration file $init = hello_world_config_exists() || hello_world_init(); // Check if we need to save the configuration $save_changes = isset($_POST['save-configuration']); if ($save_changes) { // Validate and save the config $data = hello_world_validate_config($_POST); $save_success = hello_world_save_config($data); // Display a success/error status message for the admin hello_world_display_status_message($save_success); } // Show the admin panel page $config = hello_world_get_config(); include(HELLO_WORLD_PLUGINPATH . '/admin.php'); } // Load plugin configuration into an array function hello_world_get_config() { $file = HELLO_WORLD_CONFIGFILE; $contents = file_get_contents($file); $json = json_decode($contents); $config = (array) $json; return $config; } // Save array data to the configuration function hello_world_save_config($config = array()) { $file = HELLO_WORLD_CONFIGFILE; $contents = json_encode($config); return file_put_contents($file, $contents); } // Validate an array for saving it as a configuration object function hello_world_validate_config($data) { // Clean up the configuration array... $config = array( 'message' => $data['message'], ); return $config; } // Check that the configuration file exists function hello_world_config_exists() { return file_exists(HELLO_WORLD_CONFIGFILE); } // Create a default configuration file function hello_world_init() { $config = array('message' => hello_world_i18n('HELLO_WORLD')); return hello_world_save_config($config); } // Display the success/error status of a coonfiguration's saving function hello_world_display_status_message($status) { if ($status) { $class = 'success'; $message = hello_world_i18n('CONFIG_SAVE_SUCCESS'); } else { $class = 'error'; $message = hello_world_i18n('CONFIG_SAVE_ERROR'); } echo '