C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\totalpoll\src\Bootstrap.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php

namespace TotalPoll;
defined'ABSPATH' ) && exit();


use 
TotalPoll\Contracts\Poll\Model;
use 
TotalPollVendors\TotalCore\Helpers\Misc;

/**
 * Bootstrap TotalPoll.
 *
 * @package TotalPoll
 */
class Bootstrap {

    public function 
__construct() {
        
// Define asynchronous loading state (enbaled | disabled)
        
define'TP_ASYNC', (bool) TotalPoll()->option'performance.async.enabled' ) );

        
// Process CPT related options (disabled archive for example).
        
if ( ! is_admin() && TotalPoll()->option'advanced.disableArchive' ) ):
            
add_action'pre_get_posts', [ $this'disableArchive' ] );
        endif;

        
// Listen to flush rewrite rules requests
        
add_action'totalpoll/actions/urls/flush''flush_rewrite_rules' );

        
// Structured Data
        
if ( TotalPoll()->option'general.structuredData.enabled' ) ):
            
TotalPoll'decorators.structuredData' );
        endif;

        
// Requests
        
if ( isset( $_REQUEST['totalpoll']['action'] ) ):
            
// Capture actions
            
add_action'wp', [ $this'route' ], 11 );
            
add_action'wp_ajax_totalpoll', [ $this'route' ] );
            
add_action'wp_ajax_nopriv_totalpoll', [ $this'route' ] );
        endif;

        
// Prepare posts and shortcodes
        
add_action'wp', [ $this'preparePoll' ] );

        
// Privacy
        
TotalPoll'admin.privacy' );

        
/**
         * Fires when TotalPoll complete the bootstrap phase.
         *
         * @since 4.0.0
         * @order 4
         */
        
do_action'totalpoll/actions/bootstrap' );
    }

    
/**
     * Process requests.
     *
     * @since 1.0.0
     */
    
public function route() {
        
TotalPoll'poll.controller' );

        
$action stripslashes( (string) $_REQUEST['totalpoll']['action'] );
        
$method strtolowerfilter_inputINPUT_SERVER'REQUEST_METHOD' ) ?: filter_var$_SERVER['REQUEST_METHOD'], FILTER_SANITIZE_STRING ) );
        
/**
         * Fires before processing a request.
         *
         * @param string $method HTTP method.
         * @param string $action Action name.
         *
         * @since 4.0.0
         */
        
do_action'totalpoll/actions/before/request'$action$method );
        
/**
         * Fires when TotalPoll receives a request.
         *
         * @param string $method HTTP method.
         * @param string $action Action name.
         *
         * @since 4.0.0
         */
        
do_action'totalpoll/actions/request'$action$method );
        
/**
         * Fires when TotalPoll receives a request (specific HTTP method and action name).
         *
         * @param string $method HTTP method.
         * @param string $action Action name.
         *
         * @since 4.0.0
         */
        
do_action"totalpoll/actions/request/{$method}/{$action}"$action$method );
        
/**
         * Fires when TotalPoll receives a request (specific action name).
         *
         * @param string $method HTTP method.
         * @param string $action Action name.
         *
         * @since 4.0.0
         */
        
do_action"totalpoll/actions/request/{$action}"$action$method );
        
/**
         * Fires after processing a request.
         *
         * @param string $method HTTP method.
         * @param string $action Action name.
         *
         * @since 4.0.0
         */
        
do_action'totalpoll/actions/after/request'$action$method );

        if ( 
Misc::isDoingAjax() ):
            
/**
             * Fires when TotalPoll receives an AJAX request.
             *
             * @param string $method HTTP method.
             * @param string $action Action name.
             *
             * @since 4.0.0
             */
            
do_action'totalpoll/actions/ajax-request'$action$method );

            
/**
             * Fires when TotalPoll receives an AJAX request (specific HTTP method and action name).
             *
             * @param string $method HTTP method.
             * @param string $action Action name.
             *
             * @since 4.0.0
             */
            
do_action"totalpoll/actions/ajax-request/{$method}/{$action}"$action$method );

            
/**
             * Fires when TotalPoll receives an AJAX request (specific action name).
             *
             * @param string $method HTTP method.
             * @param string $action Action name.
             *
             * @since 4.0.0
             */
            
do_action"totalpoll/actions/ajax-request/{$action}"$action$method );
        endif;
    }

    
/**
     * @param \WP_Query $query
     *
     * @return mixed
     */
    
public function disableArchive$query ) {
        if ( 
$query->is_main_query() && $query->is_post_type_archiveTP_POLL_CPT_NAME ) ) :
            
$query->set_404();
            
remove_action'pre_get_posts', [ $this'disableArchive' ] );
        endif;
    }

    
/**
     * Prepare poll.
     * @since 1.0.0
     */
    
public function preparePoll() {
        
// Check whether is an archive page, search or singular.
        
if ( is_single() || is_archive() || is_search() ):
            
// Get current post type.
            
$currentPostType get_post_type();

            
// Check current post type is poll
            
if ( $currentPostType === TP_POLL_CPT_NAME ):
                
$callback = [ $thisdefined'TP_ASYNC' ) && TP_ASYNC 'pollPostAsync' 'pollPost' ];
                
// Hide content when is archive, otherwise call the appropriate callback.
                
if ( ( is_archive() || is_search() ) && ! TotalPoll()->option'advanced.renderPollsInArchive' ) ):
                    
$callback = function () {
                        return 
$GLOBALS['post']->post_excerpt;
                    };
                endif;

                
// Content
                
add_filter'the_content'$callback99 );
                
// Meta tags
                
add_action'wp_head', [ $this'pollHeadSection' ], );
                
// Title
                
add_filter'wp_title', [ $this'pollTitle' ], );

                
// We need to take care of the output when It's embedded
                
if ( function_exists'is_embed' ) && is_embed() ):
                    
add_action'embed_content', function () use ( $callback ) {
                        echo 
$callback'' );
                    }, 
99 );
                    
remove_all_filters'get_the_excerpt' );
                    
add_filter'the_excerpt_embed''__return_empty_string' );
                    
add_filter'embed_site_title_html''__return_empty_string' );
                    
remove_all_actions'embed_content_meta' );
                endif;
            endif;
        endif;
    }

    
/**
     * Prepare poll post.
     *
     * @param $content Content
     *
     * @return mixed
     * @since 1.0.0
     */
    
public function pollPost$content ) {
        
$poll TotalPoll'polls.repository' )->getById$GLOBALS['post']->ID );

        return 
$poll $poll->render() : $content;
    }

    
/**
     * Prepare poll post for async loading.
     *
     * @param $content
     *
     * @return string
     */
    
public function pollPostAsync$content ) {
        return 
$this->pollPost'' );
    }

    
/**
     * Poll title.
     *
     * @param $title
     *
     * @return string
     */
    
public function pollTitle$title ) {
        
$poll TotalPoll'polls.repository' )->getById$GLOBALS['post']->ID );
        if ( 
$poll ):
            
$seo   $poll->getSeoAttributes();
            
$title $seo['title'];
        endif;

        return 
$title;
    }

    
/**
     * Poll head section.
     */
    
public function pollHeadSection() {
        
$poll TotalPoll'polls.repository' )->getById$GLOBALS['post']->ID );

        if ( 
$poll ):
            
$seo $poll->getSeoAttributes();
            
$this->printMetaTags$seo['title'], $seo['description'], $poll->getThumbnail() );
        endif;
        
/**
         * Fires after printing poll meta tags.
         *
         * @param Model $poll Poll object.
         *
         * @since 4.0.0
         */
        
do_action'totalpoll/actions/poll/after/head'$poll );
    }

    
/**
     * Print meta tags.
     *
     * @param      $title
     * @param      $description
     * @param null $image
     */
    
protected function printMetaTags$title$description$image null ) {
        if ( 
$title ):
            
printf'<meta property="og:title" content="%s" />' PHP_EOLesc_attr$title ) );
        endif;

        if ( 
$description ):
            
printf'<meta property="og:description" content="%s" />' PHP_EOLesc_attr$description ) );
            
printf'<meta property="description" content="%s" />' PHP_EOLesc_attr$description ) );
        endif;

        if ( 
$image ):
            
printf'<meta property="og:image" content="%s" />' PHP_EOLesc_attr$image ) );
        endif;
    }
}
x

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