C:\xampp\htdocs\landing\wp-content\plugins\totalpoll\src\Admin\Ajax\Options.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

namespace TotalPoll\Admin\Ajax;
defined'ABSPATH' ) && exit();


defined'ABSPATH' ) && exit();


use 
TotalPoll\Contracts\Migrations\Poll\Migrator;
use 
TotalPollVendors\TotalCore\Contracts\Http\Request;

/**
 * Class Options
 * @package TotalPoll\Admin\Ajax
 */
class Options {
    
/**
     * @var Migrator[] $migrators
     */
    
protected $migrators;
    
/**
     * @var Request $request
     */
    
protected $request;

    
/**
     * Page constructor.
     *
     * @param Request    $request
     * @param Migrator[] $migrators
     */
    
public function __constructRequest $request$migrators ) {
        
$this->request   $request;
        
$this->migrators $migrators;
    }

    
/**
     * Save options.
     */
    
public function saveOptions() {
        
$options json_decode$this->request->post'options''{}' ), true );
        if ( ! empty( 
$options ) ):
            
TotalPoll'options' )->setOptions$optionstrue );
            
wp_schedule_single_eventtime(), 'totalpoll/actions/urls/flush' );
        endif;
        
wp_send_json_success__'Saved.''totalpoll' ) );
    }

    
/**
     * Purge.
     */
    
public function purge() {
        
$type $this->request->request'type''cache' );
        if ( 
$type === 'cache' ):
            
TotalPoll'utils.purge.cache' );
            
TotalPoll'utils.purge.store' );
        endif;
        
wp_send_json_success__'Purged.''totalpoll' ) );
    }

    
/**
     * Migrate polls AJAX endpoint.
     * @action-callback wp_ajax_totalpoll_options_migrate_polls
     */
    
public function migratePolls() {
        
$plugin $this->request->post'plugin' );

        if ( ! isset( 
$this->migrators$plugin ] ) ):
            
wp_send_json_error__'Plugin is not supported.''totalpoll' ) );
        endif;

        
$migrator   $this->migrators$plugin ];
        
$pollsCount $migrator->getCount();

        
$migrator->migrate();

        
wp_send_json_success( [ 'done' => $migrator->getMigratedCount(), 'of' => $pollsCount ] );
    }

}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586