/** * 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: "/wp-content/cache/adaptive-images".' . '<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; } }
<?php /****************************************************************************************************************** * * * * * INCLUDED AS-IS WHEN THE PLUGIN IS UNINSTALLED * * ============================================= * * * * Nevma (info@nevma.gr) * * * * * ******************************************************************************************************************/ // Exit, if file is accessed directly. if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } // Include important plugin functions. require_once 'adaptive-images-plugin.php'; require_once 'adaptive-images-actions.php'; // Attempt to cleanup the cache. $cache_path = adaptive_images_plugin_get_cahe_directory_path(); adaptive_images_actions_rmdir_recursive($cache_path); // Cleanup possible leftover options from version 0.2.08. delete_option('wprxr_include_paths'); delete_option('wprxr_ai_config'); // Cleanup current plugin options. delete_option('adaptive-images');
/** * Takes care of the plugin settings page actions. * * @author Nevma (info@nevma.gr) * * @return void Nothing really!. */ function adaptive_images_admin_settings_actions() { if (!isset($_GET['action'])) { return; } // Cleanup image cache action. if ($_GET['action'] == 'cleanup-image-cache' && wp_verify_nonce($_GET['_wpnonce'], 'adaptive-images-cleanup-image-cache')) { $cache_path = adaptive_images_plugin_get_cahe_directory_path(); $result = adaptive_images_actions_rmdir_recursive($cache_path); add_settings_error('adaptive-images-settings', 'adaptive-images-settings-error', 'Cleanup image cache <hr />' . '<p>Total files deleted from the adaptive images cache: ' . $result['files'] . '</p>' . '<p>Total directories deleted from the adaptive images cache: ' . $result['dirs'] . '</p>' . '<p>' . 'Total size deleted from the adaptive images cache: ' . adaptive_images_plugin_file_size_human($result['size']) . '</p>', 'updated'); } // Calculate image cache size action. if ($_GET['action'] == 'calculate-cache-size' && wp_verify_nonce($_GET['_wpnonce'], 'adaptive-images-calculate-cache-size')) { $cache_path = adaptive_images_plugin_get_cahe_directory_path(); $cache_size = adaptive_images_plugin_dir_size($cache_path); add_settings_error('adaptive-images-settings', 'adaptive-images-settings-error', 'Calculate cache size <hr />' . '<p>Total files in the adaptive images cache: ' . $cache_size['files'] . '</p>' . '<p>Total directories in the adaptive images cache: ' . $cache_size['dirs'] . '</p>' . '<p>' . 'Total size of the adaptive images cache: ' . adaptive_images_plugin_file_size_human($cache_size['size']) . '</p>', 'updated'); } // Print plugin info action. if ($_GET['action'] == 'print-debug-info' && wp_verify_nonce($_GET['_wpnonce'], 'adaptive-images-print-debug-info')) { add_settings_error('adaptive-images-settings', 'adaptive-images-settings-error', 'Debug info <hr />' . adaptive_images_debug_general_info(FALSE), 'updated'); } // Print system info action. if ($_GET['action'] == 'print-diagnostic-info' && wp_verify_nonce($_GET['_wpnonce'], 'adaptive-images-print-diagnostic-info')) { add_settings_error('adaptive-images-settings', 'adaptive-images-settings-error', 'System information <hr />' . adaptive_images_debug_diagnostic_info(FALSE), 'updated'); } }