C:\xampp\htdocs\landing\wp-content\plugins\wpforms-lite\src\Tasks\Tasks.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
<?php

namespace WPForms\Tasks;

use 
WPForms\Tasks\Actions\EntryEmailsTask;

/**
 * Class Tasks manages the tasks queue and provides API to work with it.
 *
 * @since 1.5.9
 */
class Tasks {

    
/**
     * Group that will be assigned to all actions.
     *
     * @since 1.5.9
     */
    
const GROUP 'wpforms';

    
/**
     * Perform certain things on class init.
     *
     * @since 1.5.9
     */
    
public function init() {

        
// Register WPForms tasks.
        
foreach ( $this->get_tasks() as $task ) {

            if ( ! 
is_subclass_of$taskTask::class ) ) {
                continue;
            }

            new 
$task();
        }

        
add_action'admin_menu', [ $this'admin_hide_as_menu' ], PHP_INT_MAX );

        
/*
         * By default we send emails in the same process as the form submission is done.
         * That means that when many emails are set in form Notifications -
         * the form submission can take a while because of all those emails that are sending in the background.
         * Since WPForms 1.6.0 users can enable a new option in Settings > Emails,
         * called "Optimize Email Sending", to send email in async way.
         * This feature was enabled for WPForms 1.5.9, but some users were not happy.
         */
        
if ( ! (bool) wpforms_setting'email-async'false ) ) {
            
add_filter'wpforms_tasks_entry_emails_trigger_send_same_process''__return_true' );
        }

        
add_actionEntryEmailsTask::ACTION, [ EntryEmailsTask::class, 'process' ] );
    }

    
/**
     * Get the list of WPForms default scheduled tasks.
     * Tasks, that are fired under certain specific circumstances
     * (like sending form submission email notifications)
     * are not listed here.
     *
     * @since 1.5.9
     *
     * @return Task[] List of tasks classes.
     */
    
public function get_tasks() {

        if ( ! 
$this->is_usable() ) {
            return [];
        }

        
$tasks = [
            
Actions\EntryEmailsMetaCleanupTask::class,
        ];

        return 
apply_filters'wpforms_tasks_get_tasks'$tasks );
    }

    
/**
     * Hide Action Scheduler admin area when not in debug mode.
     *
     * @since 1.5.9
     */
    
public function admin_hide_as_menu() {

        
// Filter to redefine that WPForms hides Tools > Action Scheduler menu item.
        
if ( apply_filters'wpforms_tasks_admin_hide_as_menu', ! wpforms_debug() ) ) {
            
remove_submenu_page'tools.php''action-scheduler' );
        }
    }

    
/**
     * Create a new task.
     * Used for "inline" tasks, that require additional information
     * from the plugin runtime before they can be scheduled.
     *
     * Example:
     *     wpforms()->get( 'tasks' )
     *              ->create( 'i_am_the_dude' )
     *              ->async()
     *              ->params( 'The Big Lebowski', 1998 )
     *              ->register();
     *
     * This `i_am_the_dude` action will be later processed as:
     *     add_action( 'i_am_the_dude', 'thats_what_you_call_me' );
     *
     * Function `thats_what_you_call_me()` will receive `$meta_id` param,
     * and you will be able to receive all params from the action like this:
     *     $params = ( new Meta() )->get( (int) $meta_id );
     *     list( $name, $year ) = $meta->data;
     *
     * @since 1.5.9
     *
     * @param string $action Action that will be used as a hook.
     *
     * @return \WPForms\Tasks\Task
     */
    
public function create$action ) {

        return new 
Task$action );
    }

    
/**
     * Cancel all the AS actions for a group.
     *
     * @since 1.5.9
     *
     * @param string $group Group to cancel all actions for.
     */
    
public function cancel_all$group '' ) {

        if ( empty( 
$group ) ) {
            
$group self::GROUP;
        } else {
            
$group sanitize_key$group );
        }

        if ( 
class_exists'ActionScheduler_DBStore' ) ) {
            \
ActionScheduler_DBStore::instance()->cancel_actions_by_group$group );
        }
    }

    
/**
     * Whether ActionScheduler thinks that it has migrated or not.
     *
     * @since 1.5.9.3
     *
     * @return bool
     */
    
public function is_usable() {

        
// No tasks if ActionScheduler wasn't loaded.
        
if ( ! class_exists'ActionScheduler_DataController' ) ) {
            return 
false;
        }

        return \
ActionScheduler_DataController::is_migration_complete();
    }

    
/**
     * Whether task has been scheduled and is pending.
     *
     * @since 1.6.0
     *
     * @param string $hook Hook to check for.
     *
     * @return bool
     */
    
public function is_scheduled$hook ) {

        if ( ! 
function_exists'as_next_scheduled_action' ) ) {
            return 
false;
        }

        return 
as_next_scheduled_action$hook );
    }
}
x

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