/var/www/html_it/wp-content/plugins/loco-translate/src/admin/config/PrefsController.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
 *  User-level plugin preferences
 */
class Loco_admin_config_PrefsController extends Loco_admin_config_BaseController {


    
/**
     * {@inheritdoc}
     */
    
public function init(){
        
parent::init();
        
$this->set'title'__('User options','loco-translate') );
        
        
// user preference options
        
$opts Loco_data_Preferences::get();
        
$this->set'opts'$opts );
        
        
// handle save action 
        
$nonce $this->setNonce('save-prefs');
        try {
            if( 
$this->checkNonce($nonce->action) ){
                
$post Loco_mvc_PostParams::get();
                if( 
$post->has('opts') ){
                    
$opts->populate$post->opts )->persist();
                    
Loco_error_AdminNotices::success__('Settings saved','loco-translate') );
                }
            }
        }
        catch( 
Loco_error_Exception $e ){
            
Loco_error_AdminNotices::add($e);
        }
    }



    
/**
     * {@inheritdoc}
     */
    
public function render(){
        
        
$title __('Plugin settings','loco-translate');
        
$breadcrumb = new Loco_admin_Navigation;
        
$breadcrumb->add$title );
        
        return 
$this->view('admin/config/prefs'compact('breadcrumb') ); 
    }

}