C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\totalpoll\src\Migrations\Polls\Load.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
82
83
84
85
86
<?php

namespace TotalPoll\Migrations\Polls;
defined'ABSPATH' ) && exit();


use 
TotalPoll\Contracts\Log\Model as LogModel;
use 
TotalPoll\Contracts\Migrations\Poll\Template\LogEntry;
use 
TotalPoll\Contracts\Migrations\Poll\Template\Options;
use 
TotalPoll\Contracts\Migrations\Poll\Template\Poll;
use 
TotalPoll\Contracts\Migrations\Poll\Template\Submission;
use 
TotalPoll\Contracts\Migrations\Poll\Template\Submission as SubmissionModel;

/**
 * Load Polls.
 * @package TotalPoll\Migrations\Polls
 */
class Load implements \TotalPoll\Contracts\Migrations\Poll\Load {

    
/**
     * @param Poll $poll
     *
     * @return Poll
     */
    
public function loadPollPoll $poll ) {
        
$poll['presetUid'] = md5$poll->getId() );

        
$defaults TotalPoll'polls.defaults', [] );
        
$model    wp_parse_args$poll->toArray(), $defaults );

        
$id wp_insert_post(
            [
                
'ID'           => $poll->getNewId(),
                
'post_title'   => $poll->getTitle(),
                
'post_content' => wp_slashjson_encode$model ) ),
                
'post_type'    => TP_POLL_CPT_NAME,
            ]
        );

        if ( 
is_int$id ) ):
            
$poll->setNewId$id );
        endif;

        
$choicesVotes = [];
        foreach ( 
$poll['questions'] as $question ):
            foreach ( 
$question['choices'] as $choice ):
                
$choicesVotes$choice['uid'] ] = $choice['votes'];
            endforeach;
        endforeach;

        
TotalPoll'polls.repository' )->setVotes$poll->getNewId(), $choicesVotes );

        
update_post_meta$poll->getNewId(), '_migrated''migrated' );

        return 
$poll;
    }

    
/**
     * @param Options $options
     *
     * @return array
     */
    
public function loadOptionsOptions $options ) {
        return 
TotalPoll'options' )->setOptions$options->toArray() );
    }

    
/**
     * @param Poll     $poll
     * @param LogEntry $logEntry
     *
     * @return LogModel
     */
    
public function loadLogEntryPoll $pollLogEntry $logEntry ) {
        return 
TotalPoll'log.repository' )->create$logEntry->toArray() );
    }

    
/**
     * @param Poll       $poll
     * @param Submission $submission
     *
     * @return SubmissionModel
     */
    
public function loadSubmissionPoll $pollSubmission $submission ) {
        return 
TotalPoll'entries.repository' )->create$submission->toArray() );
    }
}
x

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