/**
 * Prints useful debug information for the plugin.
 * 
 * @author Nevma (info@nevma.gr)
 * 
 * @param bool $echo Whether to echo the result or return it as a string.
 * 
 * @return Nothing really!
 */
function adaptive_images_debug_general_info($echo = true)
{
    $options = get_option('adaptive-images');
    $icons = array('true' => '✔', 'false' => '✖', 'debug' => '❖');
    // PHP GD image library debug info.
    $gd_extenstion_installed = adaptive_images_plugin_is_gd_extension_installed();
    $message = '<p>' . ($gd_extenstion_installed ? $icons['true'] : $icons['false']) . ' PHP GD library is ' . ($gd_extenstion_installed ? '' : 'not ') . ' installed.' . '</p>';
    // Image cache directory debug info.
    $cache_path = adaptive_images_plugin_get_cahe_directory_path();
    $cache_path_exists = file_exists($cache_path);
    $message .= '<p>' . ($cache_path_exists ? $icons['true'] : $icons['false']) . ' Image cache directory has ' . ($cache_path_exists ? '' : 'not ') . 'been created.' . '</p>' . ($cache_path_exists ? '<blockquote><p>' . '<code>' . $cache_path . ' => ' . adaptive_images_plugin_file_permissions($cache_path) . '</code>' . '</p></blockquote>' : '<blockquote><p>' . (!$cache_path_exists && is_writable(dirname($cache_path)) ? 'But this is probably because the cache has not been accessed yet. <br />' . 'After accessing your website from a mobile device the directory should be automatically created.' . '<br /><br />' : 'It seems that the directory is not writeable. This is probably a filesystem permissions issue. <br />' . ' Consider adding manually the image cache directory: &quot;/wp-content/cache/adaptive-images&quot;.' . '<br /><br />') . '<code>' . dirname($cache_path) . ' => ' . adaptive_images_plugin_file_permissions(dirname($cache_path)) . '</code>' . '</p></blockquote>');
    // Check .htaccess file availability
    $htaccess = adaptive_images_plugin_get_htaccess_file_path();
    $htaccess_ok = adaptive_images_actions_is_htaccess_ok();
    $htaccess_writeable = adaptive_images_plugin_is_htaccess_writeable();
    $message .= '<p>' . ($htaccess_ok ? $icons['true'] : $icons['false']) . ' Installation .htaccess file is ' . ($htaccess_ok ? 'setup OK.' : 'not properly setup.') . '</p>' . ($htaccess_writeable ? '<blockquote><p>' . '<code>' . $htaccess . ' => ' . adaptive_images_plugin_file_permissions($htaccess) . '</code>' . '</p></blockquote>' : '<blockquote><p>' . 'The .htaccess file is not writeable so it might have not been updated.' . '<br /><br />' . '<code>' . $htaccess . ' => ' . adaptive_images_plugin_file_permissions($htaccess) . '</code>' . '</p></blockquote>');
    // Image cache settings dump.
    $message .= '<p>' . $icons['debug'] . ' Adaptive images settings dump:</p>';
    $message .= '<blockquote><pre>';
    ob_start();
    var_dump($options);
    $message .= ob_get_clean();
    $message .= '</pre></blockquote>';
    // Echo debug info or return it.
    if ($echo) {
        echo $message;
    } else {
        return $message;
    }
}
/**
 * Checks if the PHP GD image library is available in the server and informs the user in the admin.
 * 
 * @author Nevma (info@nevma.gr)
 * 
 * @return void Nothing really!
 */
function adaptive_images_actions_check_gd_available()
{
    // Do the check and inform user.
    if (!adaptive_images_plugin_is_gd_extension_installed()) {
        add_action('admin_notices', 'adaptive_images_actions_check_gd_available_message');
    }
}