<commit_before><?php
/**
 * Plugin Name: Jumpstarter
 * Plugin URI: https://github.com/jumpstarter-io/
 * Description: Wordpress Jumpstarter integration.
 * Author: Jumpstarter
 * Author URI: https://jumpstarter.io/
 * License: Public Domain
 */

// Don't load directly.
if (!defined("ABSPATH"))
    die("-1");

require_once(dirname(__FILE__) . "/jswp-env.php");
require_once(dirname(__FILE__) . "/jswp-util.php");

// Only allow full access to plugin activation/deactivation from cli.
if (php_sapi_name() !== "cli") {
    // Allow all plugin activation/deactivation except for Jumpstarter core plugins.
    foreach (array("activate_plugin" => "activate", "deactivate_plugin" => "deactivate") as $action => $action_name) {
        add_action($action, function($plugin_key) use ($action_name) {
            if (in_array($plugin_key, jswp_env_core_plugins())) {
                wp_die(__("You are not allowed to $action_name this plugin."));
            }
        }, 1, 1);
    }
    // Filter out the Jumpstarter core plugins from listing as we don't want the
    // user to think these can be activated/deactivated.
    add_filter("all_plugins", function($plugins) {
        foreach (jswp_env_core_plugins() as $core_plugin) {
            unset($plugins[$core_plugin]);
        }
        return $plugins;
    }, 100, 1);
}

// Add a filter for outgoing requests that prevents WordPress from checking for
// updates for our core plugins.
add_filter("http_request_args", function($r, $url) {
    if (strpos($url, "api.wordpress.org/plugins/update-check") !== false) {
        $update_plugins = json_decode($r["body"]["plugins"], true);
        foreach (jswp_env_core_plugins() as $plugin) {
            unset($update_plugins["plugins"][$plugin]);
        }
        $r["body"]["plugins"] = json_encode($update_plugins);
    }
    return $r;
}, 100, 2);

// Sandboxed Jumpstarter WordPress user.
class JS_WP_User extends WP_User {
    public function __construct(WP_User $raw_wp_user) {
        foreach (get_object_vars($raw_wp_user) as $key => $var)
            $this->$key = $var;
    }

    public function has_cap($in) {
        $cap = (is_numeric($in)? $this->translate_level_to_cap($in): $in);
        return (in_array($cap, jswp_env_get_disabled_capabilities()))? false:
                call_user_func_array(array($this, "parent::" . __FUNCTION__), func_get_args());
    }
}
<commit_msg>jumpstarter: remove the last plugin restrictions. it's up to the user to choose if it want's the blog to work or not<commit_after><?php
/**
 * Plugin Name: Jumpstarter
 * Plugin URI: https://github.com/jumpstarter-io/
 * Description: Wordpress Jumpstarter integration.
 * Author: Jumpstarter
 * Author URI: https://jumpstarter.io/
 * License: Public Domain
 */

// Don't load directly.
if (!defined("ABSPATH"))
    die("-1");

require_once(dirname(__FILE__) . "/jswp-env.php");
require_once(dirname(__FILE__) . "/jswp-util.php");

// Sandboxed Jumpstarter WordPress user.
class JS_WP_User extends WP_User {
    public function __construct(WP_User $raw_wp_user) {
        foreach (get_object_vars($raw_wp_user) as $key => $var)
            $this->$key = $var;
    }

    public function has_cap($in) {
        $cap = (is_numeric($in)? $this->translate_level_to_cap($in): $in);
        return (in_array($cap, jswp_env_get_disabled_capabilities()))? false:
                call_user_func_array(array($this, "parent::" . __FUNCTION__), func_get_args());
    }
}

{'fraction_non_alphanumeric': 0.1441415313225058, 'fraction_numerical': 0.0034802784222737818, 'mean_word_length': 3.479220779220779, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3776132', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1069, 'n_words': 262}