HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wptoho/wp-content/plugins/ninja-tables/app/Http/Controllers/ToolsController.php
<?php

namespace NinjaTables\App\Http\Controllers;

use NinjaTables\App\Models\Post;
use NinjaTables\Framework\Request\Request;
use NinjaTables\Framework\Support\Arr;

class ToolsController extends Controller
{
    public function getDefaultSettings(Request $request)
    {
        $settings = getDefaultNinjaTableSettings();

        return $this->sendSuccess([
            'data' => [
                'default_settings' => $settings
            ]
        ], 200);
    }

    public function saveDefaultSettings(Request $request)
    {
        $settings = ninjaTableNormalize(wp_unslash(Arr::get($request->all(), 'default_settings')));
        update_option('_ninja_table_default_appearance_settings', $settings);

        return $this->sendSuccess([
            'data' => [
                'message' => __('Settings successfully updated', 'ninja-tables')
            ]
        ], 200);
    }

    public function getAccessRoles(Request $request)
    {
        $roles = $this->get_roles();

        $formatted     = array();
        $excludedRoles = array('subscriber', 'administrator');
        foreach ($roles as $key => $role) {
            if ( ! in_array($key, $excludedRoles)) {
                $formatted[] = array(
                    'name' => $role['name'],
                    'key'  => $key
                );
            }
        }

        $capability = get_option('_ninja_tables_permission', []);

        $this->json(array(
            'capability'     => $capability,
            'roles'          => $formatted,
            'sql_permission' => get_option('_ninja_tables_sql_permission')
        ), 200);
    }

    /**
     * Filters the list of editable roles.
     * This is actually WordPress core function - get_editable_roles()
     * get_editable_roles() is not working in our framework that's why we have to copy the core code here
     *
     * @return mixed
     * @since 2.8.0
     *
     */
    public function get_roles()
    {
        $all_roles = wp_roles()->roles;

        return $this->app->applyFilters('editable_roles', $all_roles);
    }

    public function getGlobalSettings(Request $request)
    {
        $suppressError = get_option('_ninja_suppress_error');
        if ( ! $suppressError) {
            $suppressError = 'no';
        }

        return $this->sendSuccess([
            'data' => [
                'ninja_suppress_error' => $suppressError
            ]
        ], 200);
    }

    public function updateGlobalSettings(Request $request)
    {
        $errorHandling = sanitize_text_field(Arr::get($request->all(), 'suppress_error'));
        update_option('_ninja_suppress_error', $errorHandling, true);

        return $this->sendSuccess([
            'data' => [
                'message' => __('Settings successfully updated', 'ninja-tables')
            ]
        ], 200);
    }

    public function clearTableCache(Request $request)
    {
        $posts = Post::where('post_type', 'ninja-table')->get();

        ninja_table_clear_all_cache($posts);

        return $this->sendSuccess([
            'data' => [
                'posts'   => $posts,
                'message' => __('Table cache successfully cleared', 'ninja-tables')
            ]
        ], 200);
    }

    public function clearExternalTableCache(Request $request)
    {
        ninjaTablesExternalClearPageCaches();

        return $this->sendSuccess([
            'data' => [
                'message' => __('All caches successfully cleared', 'ninja-tables')
            ]
        ], 200);
    }

}