Ejemplo n.º 1
0
 * Delightful Downloads Uninstall
 *
 * @package     Delightful Downloads
 * @subpackage  Uninstall
 * @since       1.3
*/
// Exit if accessed directly
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
// Include Delightful Downloads
include_once 'delightful-downloads.php';
// Globals
global $wpdb, $dedo_options, $dedo_statistics;
// Clear transients
dedo_delete_all_transients();
// Check for complete uninstall
if ($dedo_options['uninstall']) {
    // Disable max_execution_time, can take a while with legacy logs
    set_time_limit(0);
    // Delete post types
    $post_types = array('dedo_download', 'dedo_log');
    foreach ($post_types as $post_type) {
        $posts = get_posts(array('post_type' => $post_type, 'post_status' => 'any', 'posts_per_page' => -1, 'fields' => 'ids'));
        if (!empty($posts)) {
            foreach ($posts as $post) {
                wp_delete_post($post, true);
            }
        }
    }
    /**
 /**
  * Deactivate plugin
  *
  * @since  1.3.2
  */
 public function deactivate()
 {
     // Clear dedo transients
     dedo_delete_all_transients();
 }
Ejemplo n.º 3
0
/**
 * Validate settings callback
 *
 * @since  1.3
 */
function dedo_validate_settings($input)
{
    global $dedo_options, $dedo_default_options;
    // Registered options
    $options = dedo_get_options();
    // Ensure text fields are not blank
    foreach ($options as $key => $value) {
        if ('text' === $options[$key]['type'] && '' === trim($input[$key])) {
            $input[$key] = $dedo_default_options[$key];
        }
    }
    // Ensure download URL does not contain illegal characters
    $input['download_url'] = strtolower(preg_replace('/[^A-Za-z0-9_-]/', '', $input['download_url']));
    // Run folder protection if option changed
    if ($input['folder_protection'] != $dedo_options['folder_protection']) {
        dedo_folder_protection($input['folder_protection']);
    }
    // Clear transients
    dedo_delete_all_transients();
    return $input;
}