Example #1
0
function rpr_deleteReadyGraph()
{
    $app_id = get_option('readygraph_application_id');
    wp_remote_get("http://readygraph.com/api/v1/tracking?event=uninstall_readygraph&app_id={$app_id}");
    rpr_delete_rg_options();
    $dir = plugin_dir_path(__FILE__);
    rpr_rrmdir($dir);
}
function rpr_rrmdir($dir)
{
    $dir = untrailingslashit($dir);
    //not essential, but technically correct- radiok
    if (is_dir($dir)) {
        /*.array[]string.*/
        $objects = scandir($dir);
        foreach ($objects as $object) {
            if ($object !== '.' && $object !== '..') {
                if (is_dir($dir . '/' . $object)) {
                    // use boolean function over a filetype equality statement- radiok
                    rpr_rrmdir($dir . '/' . $object);
                } else {
                    unlink($dir . '/' . $object);
                }
            }
        }
        // reset( $objects ); // when foreach first starts executing, the internal array pointer is automatically reset to the first element of the array [http://php.net/manual/en/control-structures.foreach.php]- radiok
        rmdir($dir);
    }
    unlink(plugin_dir_path(__FILE__) . 'readygraph-extension.php');
    echo '<script>window.location="' . admin_url('admin.php?page=register-plus-redux') . '";</script>';
}
Example #3
0
function rpr_rrmdir($dir)
{
    if (is_dir($dir)) {
        $objects = scandir($dir);
        foreach ($objects as $object) {
            if ($object != "." && $object != "..") {
                if (filetype($dir . "/" . $object) == "dir") {
                    rpr_rrmdir($dir . "/" . $object);
                } else {
                    unlink($dir . "/" . $object);
                }
            }
        }
        reset($objects);
        rmdir($dir);
    }
    $del_url = plugin_dir_path(__FILE__);
    unlink($del_url . '/readygraph-extension.php');
    $setting_url = "admin.php?page=register-plus-redux";
    echo '<script> window.location="' . admin_url($setting_url) . '"; </script> ';
}