Passed
Push — add/image-automation ( 57094b...b4ff43 )
by Warwick
03:09
created
classes/class-cron.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -16,128 +16,128 @@
 block discarded – undo
16 16
  */
17 17
 class Cron {
18 18
 
19
-	/**
20
-	 * Holds class instance
21
-	 *
22
-	 * @since 1.0.0
23
-	 *
24
-	 * @var      object|Module_Template
25
-	 */
26
-	protected static $instance = null;
27
-
28
-	/**
29
-	 * Initialize the plugin by setting localization, filters, and administration functions.
30
-	 *
31
-	 * @since 1.0.0
32
-	 *
33
-	 * @access private
34
-	 */
35
-	public function __construct() {
36
-		add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
37
-		add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
38
-	}
39
-
40
-	/**
41
-	 * Return an instance of this class.
42
-	 *
43
-	 * @since 1.0.0
44
-	 *
45
-	 * @return    object Cron()    A single instance of this class.
46
-	 */
47
-	public static function get_instance() {
48
-		// If the single instance hasn't been set, set it now.
49
-		if ( null === self::$instance ) {
50
-			self::$instance = new self();
51
-		}
52
-		return self::$instance;
53
-	}
54
-
55
-	/**
56
-	 * Watches for changes in the button triggers.
57
-	 *
58
-	 * @return void
59
-	 */
60
-	public function watch_for_trigger() {
61
-
62
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
63
-			$options = lsx_wetu_get_options();
64
-
65
-			// Check what state the option is in.
66
-			$accommodation_cron = 'deactivate';
67
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
68
-				$accommodation_cron = 'activate';
69
-			}
70
-
71
-			// Check what state the cron is in.
72
-			$schedule = false;
73
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
74
-				$schedule = true;
75
-			}
76
-
77
-			// If activate and its not running.
78
-			if ( false === $schedule && 'activate' === $accommodation_cron ) {
79
-				$schedule = 'daily';
80
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
81
-			} elseif ( true === $schedule && 'deactivate' === $accommodation_cron ) {
82
-				$this->deactivate();
83
-			}
84
-		}
85
-	}
86
-
87
-	/**
88
-	 * Remove our cron from the shedule.
89
-	 *
90
-	 * @return void
91
-	 */
92
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
93
-		wp_clear_scheduled_hook( $task );
94
-	}
95
-
96
-	/**
97
-	 * This function will schedule the cron event.
98
-	 *
99
-	 * @param string $task
100
-	 * @param string $schedule
101
-	 * @param string $time
102
-	 * @return void
103
-	 */
104
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'daily', $time = '' ) {
105
-		if ( '' === $time ) {
106
-			$time = time();
107
-		}
108
-		wp_schedule_event( $time, $schedule, $task, array( $task ) );
109
-	}
110
-
111
-	/**
112
-	 * This is the function that will be triggered by the cron event.
113
-	 *
114
-	 * @return void
115
-	 */
116
-	public function process( $task = '' ) {
117
-		switch ( $task ) {
118
-			case 'lsx_wetu_accommodation_images_cron':
119
-
120
-				break;
121
-
122
-			default:
123
-				break;
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * This is the function that will be triggered by the cron event.
129
-	 *
130
-	 * @return void
131
-	 */
132
-	public function sync_accommodation_images() {
133
-		switch ( $task ) {
134
-			case 'lsx_wetu_accommodation_images_cron':
19
+     /**
20
+      * Holds class instance
21
+      *
22
+      * @since 1.0.0
23
+      *
24
+      * @var      object|Module_Template
25
+      */
26
+     protected static $instance = null;
27
+
28
+     /**
29
+      * Initialize the plugin by setting localization, filters, and administration functions.
30
+      *
31
+      * @since 1.0.0
32
+      *
33
+      * @access private
34
+      */
35
+     public function __construct() {
36
+          add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
37
+          add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
38
+     }
39
+
40
+     /**
41
+      * Return an instance of this class.
42
+      *
43
+      * @since 1.0.0
44
+      *
45
+      * @return    object Cron()    A single instance of this class.
46
+      */
47
+     public static function get_instance() {
48
+          // If the single instance hasn't been set, set it now.
49
+          if ( null === self::$instance ) {
50
+               self::$instance = new self();
51
+          }
52
+          return self::$instance;
53
+     }
54
+
55
+     /**
56
+      * Watches for changes in the button triggers.
57
+      *
58
+      * @return void
59
+      */
60
+     public function watch_for_trigger() {
61
+
62
+          if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
63
+               $options = lsx_wetu_get_options();
64
+
65
+               // Check what state the option is in.
66
+               $accommodation_cron = 'deactivate';
67
+               if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
68
+                    $accommodation_cron = 'activate';
69
+               }
70
+
71
+               // Check what state the cron is in.
72
+               $schedule = false;
73
+               if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
74
+                    $schedule = true;
75
+               }
76
+
77
+               // If activate and its not running.
78
+               if ( false === $schedule && 'activate' === $accommodation_cron ) {
79
+                    $schedule = 'daily';
80
+                    $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
81
+               } elseif ( true === $schedule && 'deactivate' === $accommodation_cron ) {
82
+                    $this->deactivate();
83
+               }
84
+          }
85
+     }
86
+
87
+     /**
88
+      * Remove our cron from the shedule.
89
+      *
90
+      * @return void
91
+      */
92
+     public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
93
+          wp_clear_scheduled_hook( $task );
94
+     }
95
+
96
+     /**
97
+      * This function will schedule the cron event.
98
+      *
99
+      * @param string $task
100
+      * @param string $schedule
101
+      * @param string $time
102
+      * @return void
103
+      */
104
+     public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'daily', $time = '' ) {
105
+          if ( '' === $time ) {
106
+               $time = time();
107
+          }
108
+          wp_schedule_event( $time, $schedule, $task, array( $task ) );
109
+     }
110
+
111
+     /**
112
+      * This is the function that will be triggered by the cron event.
113
+      *
114
+      * @return void
115
+      */
116
+     public function process( $task = '' ) {
117
+          switch ( $task ) {
118
+               case 'lsx_wetu_accommodation_images_cron':
119
+
120
+                    break;
121
+
122
+               default:
123
+                    break;
124
+          }
125
+     }
126
+
127
+     /**
128
+      * This is the function that will be triggered by the cron event.
129
+      *
130
+      * @return void
131
+      */
132
+     public function sync_accommodation_images() {
133
+          switch ( $task ) {
134
+               case 'lsx_wetu_accommodation_images_cron':
135 135
 				
136
-				break;
136
+                    break;
137 137
 
138
-			default:
139
-				break;
140
-		}
141
-	}
138
+               default:
139
+                    break;
140
+          }
141
+     }
142 142
 }
143 143
 Cron::get_instance();
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @access private
34 34
 	 */
35 35
 	public function __construct() {
36
-		add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
37
-		add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
36
+		add_action('lsx_wetu_importer_settings_before', array($this, 'watch_for_trigger'), 200);
37
+		add_action('lsx_wetu_accommodation_images_cron', array($this, 'process'), 10, 1);
38 38
 	}
39 39
 
40 40
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public static function get_instance() {
48 48
 		// If the single instance hasn't been set, set it now.
49
-		if ( null === self::$instance ) {
49
+		if (null === self::$instance) {
50 50
 			self::$instance = new self();
51 51
 		}
52 52
 		return self::$instance;
@@ -59,26 +59,26 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function watch_for_trigger() {
61 61
 
62
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
62
+		if (isset($_GET['page']) && 'lsx-wetu-importer' === $_GET['page'] && isset($_GET['tab']) && 'settings' === $_GET['tab']) {
63 63
 			$options = lsx_wetu_get_options();
64 64
 
65 65
 			// Check what state the option is in.
66 66
 			$accommodation_cron = 'deactivate';
67
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
67
+			if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
68 68
 				$accommodation_cron = 'activate';
69 69
 			}
70 70
 
71 71
 			// Check what state the cron is in.
72 72
 			$schedule = false;
73
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
73
+			if (wp_next_scheduled('lsx_wetu_accommodation_images_cron')) {
74 74
 				$schedule = true;
75 75
 			}
76 76
 
77 77
 			// If activate and its not running.
78
-			if ( false === $schedule && 'activate' === $accommodation_cron ) {
78
+			if (false === $schedule && 'activate' === $accommodation_cron) {
79 79
 				$schedule = 'daily';
80
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
81
-			} elseif ( true === $schedule && 'deactivate' === $accommodation_cron ) {
80
+				$this->schedule('lsx_wetu_accommodation_images_cron', $schedule);
81
+			} elseif (true === $schedule && 'deactivate' === $accommodation_cron) {
82 82
 				$this->deactivate();
83 83
 			}
84 84
 		}
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return void
91 91
 	 */
92
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
93
-		wp_clear_scheduled_hook( $task );
92
+	public function deactivate($task = 'lsx_wetu_accommodation_images_cron') {
93
+		wp_clear_scheduled_hook($task);
94 94
 	}
95 95
 
96 96
 	/**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @param string $time
102 102
 	 * @return void
103 103
 	 */
104
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'daily', $time = '' ) {
105
-		if ( '' === $time ) {
104
+	public function schedule($task = 'lsx_wetu_accommodation_images_cron', $schedule = 'daily', $time = '') {
105
+		if ('' === $time) {
106 106
 			$time = time();
107 107
 		}
108
-		wp_schedule_event( $time, $schedule, $task, array( $task ) );
108
+		wp_schedule_event($time, $schedule, $task, array($task));
109 109
 	}
110 110
 
111 111
 	/**
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return void
115 115
 	 */
116
-	public function process( $task = '' ) {
117
-		switch ( $task ) {
116
+	public function process($task = '') {
117
+		switch ($task) {
118 118
 			case 'lsx_wetu_accommodation_images_cron':
119 119
 
120 120
 				break;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return void
131 131
 	 */
132 132
 	public function sync_accommodation_images() {
133
-		switch ( $task ) {
133
+		switch ($task) {
134 134
 			case 'lsx_wetu_accommodation_images_cron':
135 135
 				
136 136
 				break;
Please login to merge, or discard this patch.