| Server IP : 104.21.74.147 / Your IP : 216.73.217.154 Web Server : nginx/1.24.0 System : Linux wordpress-sites 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/rebeccaone.com/wp-content/plugins/cornerstone/includes/classes/Services/ |
Upload File : |
<?php
namespace Themeco\Cornerstone\Services;
class Settings implements Service {
protected $settings;
protected $permissions;
protected $routes;
public function __construct(
Routes $routes,
Permissions $permissions
) {
$this->permissions = $permissions;
$this->routes = $routes;
}
public function setup() {
$this->routes->add_route('post', 'dashboard-clear-system-cache', [$this, 'ajaxClean']);
//$this->ajaxClean->setAction( 'dashboard_clear_system_cache' )->setHandler( [ $this, 'ajaxClean'] )->start();
// API
add_filter("cs_app_slug", [$this, 'appSlug']);
add_filter("cs_app_url", [$this, 'appUrl']);
}
public function defaults() {
return [
'custom_app_slug' => '',
'themeless' => true
];
}
public function controls() {
return [
[
'key' => 'custom_app_slug',
'type' => 'text',
'title' => __( 'Custom Path', 'cornerstone' ),
'description' => __( 'Change the path used to load the main interface.', 'cornerstone' ),
'options' => array(
'placeholder' => apply_filters( 'cornerstone_default_app_slug', 'cornerstone' )
),
]
];
}
public function getAll() {
if ( ! isset( $this->settings ) ) {
$this->settings = wp_parse_args( get_option( 'cornerstone_settings', array() ), $this->defaults() );
}
return $this->settings;
}
public function get( $name ) {
$all = $this->getAll();
return isset( $all[$name] ) ? $all[$name] : null;
}
public function update($data) {
$this->getAll();
if ( isset( $data['custom_app_slug'] ) ) {
$this->settings['custom_app_slug'] = sanitize_title_with_dashes( $data['custom_app_slug'] );
}
if ( isset( $data['themeless'] ) ) {
$this->settings['themeless'] = is_bool($data['themeless']) ? $data['themeless'] : $data['themeless'] === 'true';
}
update_option( 'cornerstone_settings', $this->settings );
}
public function appSlug() {
$customSlug = $this->get('custom_app_slug');
$slug = apply_filters( 'cornerstone_default_app_slug', 'cornerstone' );
if ( ! empty( $customSlug ) ) {
$slug = sanitize_title_with_dashes( $customSlug );
}
return $slug;
}
public function appUrl() {
$url = untrailingslashit( home_url( $this->appSlug() ) );
// See WPML::filterAppURL
// what it does there might be what we always want it to do
$url = apply_filters( 'cs_filter_app_url', $url );
return $url;
}
public function ajaxClean() {
if ( ! current_user_can( 'manage_options' ) ) {
return wp_send_json_error();
}
do_action( 'cs_purge_tmp' );
do_action( 'cs_purge_all' );
return [ 'success' => true ];
//return wp_send_json_success();
}
}