Completed
Push — develop ( 184494...d87d96 )
by David
01:17 queued 15s
created
src/wordlift/task/background/class-background-task.php 2 patches
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -7,119 +7,119 @@
 block discarded – undo
7 7
 
8 8
 class Background_Task extends Wordlift_Plugin_WP_Background_Process {
9 9
 
10
-	const STATE_STARTED = 'started';
11
-	const STATE_STOPPED = 'stopped';
12
-
13
-	/**
14
-	 * The current state of the task, started or stopped.
15
-	 *
16
-	 * @var Background_Task_State $state
17
-	 */
18
-	private $state;
19
-
20
-	/**
21
-	 * The actual task.
22
-	 *
23
-	 * @var Task $task
24
-	 */
25
-	private $task;
26
-
27
-	/**
28
-	 * The prefix to store the state and other information in WP's options table, determined at instantiation.
29
-	 *
30
-	 * @var string $option_prefix
31
-	 */
32
-	private $option_prefix;
33
-
34
-	/**
35
-	 * @param Task $task
36
-	 */
37
-	public function __construct( $task ) {
38
-		$this->action        = $task->get_id();
39
-		$this->option_prefix = "_{$this->action}_";
40
-
41
-		parent::__construct();
42
-
43
-		// Set the current state.
44
-		if ( self::STATE_STARTED === $this->get_state() ) {
45
-			$this->state = new Background_Task_Started_State( $this, $task );
46
-		} else {
47
-			$this->state = new Background_Task_Stopped_State( $this );
48
-		}
49
-
50
-		$this->task = $task;
51
-	}
52
-
53
-	public static function create( $task ) {
54
-		return new self( $task );
55
-	}
56
-
57
-	public function get_option_prefix() {
58
-		return $this->option_prefix;
59
-	}
60
-
61
-	/**
62
-	 * This function is called:
63
-	 *  - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance.
64
-	 *  - To synchronize a post, by passing a numeric ID.
65
-	 *
66
-	 * This function returns the parameter for the next call or NULL if there are no more posts to process.
67
-	 *
68
-	 * @param mixed $item Queue item to iterate over.
69
-	 *
70
-	 * @return int[]|false The next post IDs or false if there are no more.
71
-	 */
72
-	protected function task( $item ) {
73
-
74
-		return $this->state->task( $item );
75
-	}
76
-
77
-	/**
78
-	 * Transition to the started state.
79
-	 */
80
-	public function start() {
81
-		$this->state->leave();
82
-		$this->state = new Background_Task_Started_State( $this, $this->task );
83
-		$this->state->enter();
84
-	}
85
-
86
-	/**
87
-	 * Transition to the stopped state.
88
-	 */
89
-	public function stop() {
90
-		$this->state->leave();
91
-		$this->state = new Background_Task_Stopped_State( $this );
92
-		$this->state->enter();
93
-	}
94
-
95
-	public function resume() {
96
-		$this->state->resume();
97
-	}
98
-
99
-	/**
100
-	 * Get the current state.
101
-	 *
102
-	 * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default).
103
-	 */
104
-	public function get_state() {
105
-		return get_option( $this->option_prefix . 'state', self::STATE_STOPPED );
106
-	}
107
-
108
-	/**
109
-	 * Persist the current state.
110
-	 *
111
-	 * @param string $value
112
-	 *
113
-	 * @return bool
114
-	 */
115
-	public function set_state( $value ) {
116
-		return null === $value
117
-			? delete_option( $this->option_prefix . 'state' )
118
-			: update_option( $this->option_prefix . 'state', $value, true );
119
-	}
120
-
121
-	public function get_info() {
122
-		return $this->state->get_info();
123
-	}
10
+    const STATE_STARTED = 'started';
11
+    const STATE_STOPPED = 'stopped';
12
+
13
+    /**
14
+     * The current state of the task, started or stopped.
15
+     *
16
+     * @var Background_Task_State $state
17
+     */
18
+    private $state;
19
+
20
+    /**
21
+     * The actual task.
22
+     *
23
+     * @var Task $task
24
+     */
25
+    private $task;
26
+
27
+    /**
28
+     * The prefix to store the state and other information in WP's options table, determined at instantiation.
29
+     *
30
+     * @var string $option_prefix
31
+     */
32
+    private $option_prefix;
33
+
34
+    /**
35
+     * @param Task $task
36
+     */
37
+    public function __construct( $task ) {
38
+        $this->action        = $task->get_id();
39
+        $this->option_prefix = "_{$this->action}_";
40
+
41
+        parent::__construct();
42
+
43
+        // Set the current state.
44
+        if ( self::STATE_STARTED === $this->get_state() ) {
45
+            $this->state = new Background_Task_Started_State( $this, $task );
46
+        } else {
47
+            $this->state = new Background_Task_Stopped_State( $this );
48
+        }
49
+
50
+        $this->task = $task;
51
+    }
52
+
53
+    public static function create( $task ) {
54
+        return new self( $task );
55
+    }
56
+
57
+    public function get_option_prefix() {
58
+        return $this->option_prefix;
59
+    }
60
+
61
+    /**
62
+     * This function is called:
63
+     *  - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance.
64
+     *  - To synchronize a post, by passing a numeric ID.
65
+     *
66
+     * This function returns the parameter for the next call or NULL if there are no more posts to process.
67
+     *
68
+     * @param mixed $item Queue item to iterate over.
69
+     *
70
+     * @return int[]|false The next post IDs or false if there are no more.
71
+     */
72
+    protected function task( $item ) {
73
+
74
+        return $this->state->task( $item );
75
+    }
76
+
77
+    /**
78
+     * Transition to the started state.
79
+     */
80
+    public function start() {
81
+        $this->state->leave();
82
+        $this->state = new Background_Task_Started_State( $this, $this->task );
83
+        $this->state->enter();
84
+    }
85
+
86
+    /**
87
+     * Transition to the stopped state.
88
+     */
89
+    public function stop() {
90
+        $this->state->leave();
91
+        $this->state = new Background_Task_Stopped_State( $this );
92
+        $this->state->enter();
93
+    }
94
+
95
+    public function resume() {
96
+        $this->state->resume();
97
+    }
98
+
99
+    /**
100
+     * Get the current state.
101
+     *
102
+     * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default).
103
+     */
104
+    public function get_state() {
105
+        return get_option( $this->option_prefix . 'state', self::STATE_STOPPED );
106
+    }
107
+
108
+    /**
109
+     * Persist the current state.
110
+     *
111
+     * @param string $value
112
+     *
113
+     * @return bool
114
+     */
115
+    public function set_state( $value ) {
116
+        return null === $value
117
+            ? delete_option( $this->option_prefix . 'state' )
118
+            : update_option( $this->option_prefix . 'state', $value, true );
119
+    }
120
+
121
+    public function get_info() {
122
+        return $this->state->get_info();
123
+    }
124 124
 
125 125
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @param Task $task
36 36
 	 */
37
-	public function __construct( $task ) {
37
+	public function __construct($task) {
38 38
 		$this->action        = $task->get_id();
39 39
 		$this->option_prefix = "_{$this->action}_";
40 40
 
41 41
 		parent::__construct();
42 42
 
43 43
 		// Set the current state.
44
-		if ( self::STATE_STARTED === $this->get_state() ) {
45
-			$this->state = new Background_Task_Started_State( $this, $task );
44
+		if (self::STATE_STARTED === $this->get_state()) {
45
+			$this->state = new Background_Task_Started_State($this, $task);
46 46
 		} else {
47
-			$this->state = new Background_Task_Stopped_State( $this );
47
+			$this->state = new Background_Task_Stopped_State($this);
48 48
 		}
49 49
 
50 50
 		$this->task = $task;
51 51
 	}
52 52
 
53
-	public static function create( $task ) {
54
-		return new self( $task );
53
+	public static function create($task) {
54
+		return new self($task);
55 55
 	}
56 56
 
57 57
 	public function get_option_prefix() {
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return int[]|false The next post IDs or false if there are no more.
71 71
 	 */
72
-	protected function task( $item ) {
72
+	protected function task($item) {
73 73
 
74
-		return $this->state->task( $item );
74
+		return $this->state->task($item);
75 75
 	}
76 76
 
77 77
 	/**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function start() {
81 81
 		$this->state->leave();
82
-		$this->state = new Background_Task_Started_State( $this, $this->task );
82
+		$this->state = new Background_Task_Started_State($this, $this->task);
83 83
 		$this->state->enter();
84 84
 	}
85 85
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function stop() {
90 90
 		$this->state->leave();
91
-		$this->state = new Background_Task_Stopped_State( $this );
91
+		$this->state = new Background_Task_Stopped_State($this);
92 92
 		$this->state->enter();
93 93
 	}
94 94
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default).
103 103
 	 */
104 104
 	public function get_state() {
105
-		return get_option( $this->option_prefix . 'state', self::STATE_STOPPED );
105
+		return get_option($this->option_prefix.'state', self::STATE_STOPPED);
106 106
 	}
107 107
 
108 108
 	/**
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return bool
114 114
 	 */
115
-	public function set_state( $value ) {
115
+	public function set_state($value) {
116 116
 		return null === $value
117
-			? delete_option( $this->option_prefix . 'state' )
118
-			: update_option( $this->option_prefix . 'state', $value, true );
117
+			? delete_option($this->option_prefix.'state')
118
+			: update_option($this->option_prefix.'state', $value, true);
119 119
 	}
120 120
 
121 121
 	public function get_info() {
Please login to merge, or discard this patch.
src/install/class-wordlift-install-service.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -18,172 +18,172 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Install_Service {
20 20
 
21
-	/**
22
-	 * A {@link Wordlift_Log_Service} instance.
23
-	 *
24
-	 * @since  3.18.0
25
-	 * @access private
26
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
-	 */
28
-	private $log;
29
-
30
-	/**
31
-	 * The singleton instance.
32
-	 *
33
-	 * @since  3.18.0
34
-	 * @access private
35
-	 * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
-	 */
37
-	private static $instance;
38
-
39
-	/**
40
-	 * @var array
41
-	 */
42
-	private $installs;
43
-
44
-	/**
45
-	 * Wordlift_Install_Service constructor.
46
-	 *
47
-	 * @since 3.18.0
48
-	 */
49
-	public function __construct() {
50
-
51
-		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
-		// Get the install services.
75
-		$this->installs = array(
76
-			new Wordlift_Install_1_0_0(),
77
-			new Wordlift_Install_3_10_0(),
78
-			new Wordlift_Install_3_12_0(),
79
-			new Wordlift_Install_3_14_0(),
80
-			new Wordlift_Install_3_15_0(),
81
-			new Wordlift_Install_3_18_0(),
82
-			new Wordlift_Install_3_18_3(),
83
-			new Wordlift_Install_3_19_5(),
84
-			new Wordlift_Install_3_20_0(),
85
-
86
-			/*
21
+    /**
22
+     * A {@link Wordlift_Log_Service} instance.
23
+     *
24
+     * @since  3.18.0
25
+     * @access private
26
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
27
+     */
28
+    private $log;
29
+
30
+    /**
31
+     * The singleton instance.
32
+     *
33
+     * @since  3.18.0
34
+     * @access private
35
+     * @var \Wordlift_Install_Service $instance A {@link Wordlift_Install_Service} instance.
36
+     */
37
+    private static $instance;
38
+
39
+    /**
40
+     * @var array
41
+     */
42
+    private $installs;
43
+
44
+    /**
45
+     * Wordlift_Install_Service constructor.
46
+     *
47
+     * @since 3.18.0
48
+     */
49
+    public function __construct() {
50
+
51
+        /** Installs. */
52
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
+        require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
74
+        // Get the install services.
75
+        $this->installs = array(
76
+            new Wordlift_Install_1_0_0(),
77
+            new Wordlift_Install_3_10_0(),
78
+            new Wordlift_Install_3_12_0(),
79
+            new Wordlift_Install_3_14_0(),
80
+            new Wordlift_Install_3_15_0(),
81
+            new Wordlift_Install_3_18_0(),
82
+            new Wordlift_Install_3_18_3(),
83
+            new Wordlift_Install_3_19_5(),
84
+            new Wordlift_Install_3_20_0(),
85
+
86
+            /*
87 87
 			 * This should be enabled with #852.
88 88
 			 */
89
-			new Wordlift_Install_Package_Type(),
90
-			new Wordlift_Install_3_23_4(),
91
-			new Wordlift_Install_3_24_2(),
92
-			new Wordlift_Install_3_25_0(),
93
-			new Wordlift_Install_3_27_0(),
94
-			new Wordlift_Install_3_27_1(),
95
-			new Wordlift_Install_3_28_0(),
96
-			// Add column to represent term
97
-			new Wordlift_Install_3_32_0(),
98
-			// Add the entities table.
99
-			new Wordlift_Install_3_33_9(),
100
-			// When woocommerce extension installed, acf4so should be installed automatically.
101
-			new Wordlift_Install_3_36_0(),
102
-
103
-			new Wordlift_Install_3_38_5(),
104
-		);
105
-		self::$instance = $this;
106
-
107
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
108
-
109
-		add_action( 'init', array( $this, 'install' ) );
110
-
111
-	}
112
-
113
-	/**
114
-	 * Get the singleton instance.
115
-	 *
116
-	 * @since 3.18.0
117
-	 */
118
-	public static function get_instance() {
119
-
120
-		return self::$instance;
121
-	}
122
-
123
-	/**
124
-	 * Loop thought all versions and install the updates.
125
-	 *
126
-	 * @return void
127
-	 * @since 3.18.0
128
-	 *
129
-	 * @since 3.20.0 use a transient to avoid concurrent installation calls.
130
-	 */
131
-	public function install() {
132
-
133
-		$version = null;
134
-
135
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
136
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
137
-			/** @var Wordlift_Install $install */
138
-			foreach ( $this->installs as $install ) {
139
-				// Get the install version.
140
-				$version = $install->get_version();
141
-
142
-				if ( version_compare( $version, $this->get_current_version(), '>' )
143
-					 || $install->must_install() ) {
144
-					$class_name = get_class( $install );
145
-
146
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
147
-					// Install version.
148
-					$install->install();
149
-
150
-					$this->log->info( "$class_name installed." );
151
-
152
-					// Bump the version.
153
-					update_option( 'wl_db_version', $version );
154
-				}
155
-			}
156
-
157
-			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
158
-			@delete_transient( '_wl_installing' );
159
-
160
-		}
161
-
162
-	}
163
-
164
-	private function install_required() {
165
-
166
-		/** @var Wordlift_Install $install */
167
-		foreach ( $this->installs as $install ) {
168
-			// Get the install version.
169
-			$version = $install->get_version();
170
-
171
-			if ( version_compare( $version, $this->get_current_version(), '>' )
172
-				 || $install->must_install() ) {
173
-				return true;
174
-			}
175
-		}
176
-
177
-		return false;
178
-	}
179
-
180
-	/**
181
-	 * Retrieve the current db version.
182
-	 *
183
-	 * @return type
184
-	 */
185
-	private function get_current_version() {
186
-		return get_option( 'wl_db_version', '0.0.0' );
187
-	}
89
+            new Wordlift_Install_Package_Type(),
90
+            new Wordlift_Install_3_23_4(),
91
+            new Wordlift_Install_3_24_2(),
92
+            new Wordlift_Install_3_25_0(),
93
+            new Wordlift_Install_3_27_0(),
94
+            new Wordlift_Install_3_27_1(),
95
+            new Wordlift_Install_3_28_0(),
96
+            // Add column to represent term
97
+            new Wordlift_Install_3_32_0(),
98
+            // Add the entities table.
99
+            new Wordlift_Install_3_33_9(),
100
+            // When woocommerce extension installed, acf4so should be installed automatically.
101
+            new Wordlift_Install_3_36_0(),
102
+
103
+            new Wordlift_Install_3_38_5(),
104
+        );
105
+        self::$instance = $this;
106
+
107
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
108
+
109
+        add_action( 'init', array( $this, 'install' ) );
110
+
111
+    }
112
+
113
+    /**
114
+     * Get the singleton instance.
115
+     *
116
+     * @since 3.18.0
117
+     */
118
+    public static function get_instance() {
119
+
120
+        return self::$instance;
121
+    }
122
+
123
+    /**
124
+     * Loop thought all versions and install the updates.
125
+     *
126
+     * @return void
127
+     * @since 3.18.0
128
+     *
129
+     * @since 3.20.0 use a transient to avoid concurrent installation calls.
130
+     */
131
+    public function install() {
132
+
133
+        $version = null;
134
+
135
+        if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
136
+            set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
137
+            /** @var Wordlift_Install $install */
138
+            foreach ( $this->installs as $install ) {
139
+                // Get the install version.
140
+                $version = $install->get_version();
141
+
142
+                if ( version_compare( $version, $this->get_current_version(), '>' )
143
+                     || $install->must_install() ) {
144
+                    $class_name = get_class( $install );
145
+
146
+                    $this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
147
+                    // Install version.
148
+                    $install->install();
149
+
150
+                    $this->log->info( "$class_name installed." );
151
+
152
+                    // Bump the version.
153
+                    update_option( 'wl_db_version', $version );
154
+                }
155
+            }
156
+
157
+            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
158
+            @delete_transient( '_wl_installing' );
159
+
160
+        }
161
+
162
+    }
163
+
164
+    private function install_required() {
165
+
166
+        /** @var Wordlift_Install $install */
167
+        foreach ( $this->installs as $install ) {
168
+            // Get the install version.
169
+            $version = $install->get_version();
170
+
171
+            if ( version_compare( $version, $this->get_current_version(), '>' )
172
+                 || $install->must_install() ) {
173
+                return true;
174
+            }
175
+        }
176
+
177
+        return false;
178
+    }
179
+
180
+    /**
181
+     * Retrieve the current db version.
182
+     *
183
+     * @return type
184
+     */
185
+    private function get_current_version() {
186
+        return get_option( 'wl_db_version', '0.0.0' );
187
+    }
188 188
 
189 189
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -49,28 +49,28 @@  discard block
 block discarded – undo
49 49
 	public function __construct() {
50 50
 
51 51
 		/** Installs. */
52
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install.php';
53
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-1-0-0.php';
54
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-10-0.php';
55
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-12-0.php';
56
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-14-0.php';
57
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-15-0.php';
58
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-0.php';
59
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-18-3.php';
60
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-19-5.php';
61
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-20-0.php';
62
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-23-4.php';
63
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-24-2.php';
64
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-all-entity-types.php';
65
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-package-type.php';
66
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-25-0.php';
67
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-0.php';
68
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-27-1.php';
69
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-28-0.php';
70
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-32-0.php';
71
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-33-9.php';
72
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-36-0.php';
73
-		require_once plugin_dir_path( __DIR__ ) . 'install/class-wordlift-install-3-38-5.php';
52
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install.php';
53
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-1-0-0.php';
54
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-10-0.php';
55
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-12-0.php';
56
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-14-0.php';
57
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-15-0.php';
58
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-0.php';
59
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-18-3.php';
60
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-19-5.php';
61
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-20-0.php';
62
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-23-4.php';
63
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-24-2.php';
64
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-all-entity-types.php';
65
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-package-type.php';
66
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-25-0.php';
67
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-0.php';
68
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-27-1.php';
69
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-28-0.php';
70
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-32-0.php';
71
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-33-9.php';
72
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-36-0.php';
73
+		require_once plugin_dir_path(__DIR__).'install/class-wordlift-install-3-38-5.php';
74 74
 		// Get the install services.
75 75
 		$this->installs = array(
76 76
 			new Wordlift_Install_1_0_0(),
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 		);
105 105
 		self::$instance = $this;
106 106
 
107
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
107
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
108 108
 
109
-		add_action( 'init', array( $this, 'install' ) );
109
+		add_action('init', array($this, 'install'));
110 110
 
111 111
 	}
112 112
 
@@ -132,30 +132,30 @@  discard block
 block discarded – undo
132 132
 
133 133
 		$version = null;
134 134
 
135
-		if ( $this->install_required() && false === get_transient( '_wl_installing' ) ) {
136
-			set_transient( '_wl_installing', true, 5 * MINUTE_IN_SECONDS );
135
+		if ($this->install_required() && false === get_transient('_wl_installing')) {
136
+			set_transient('_wl_installing', true, 5 * MINUTE_IN_SECONDS);
137 137
 			/** @var Wordlift_Install $install */
138
-			foreach ( $this->installs as $install ) {
138
+			foreach ($this->installs as $install) {
139 139
 				// Get the install version.
140 140
 				$version = $install->get_version();
141 141
 
142
-				if ( version_compare( $version, $this->get_current_version(), '>' )
143
-					 || $install->must_install() ) {
144
-					$class_name = get_class( $install );
142
+				if (version_compare($version, $this->get_current_version(), '>')
143
+					 || $install->must_install()) {
144
+					$class_name = get_class($install);
145 145
 
146
-					$this->log->info( "Current version is {$this->get_current_version()}, installing $class_name..." );
146
+					$this->log->info("Current version is {$this->get_current_version()}, installing $class_name...");
147 147
 					// Install version.
148 148
 					$install->install();
149 149
 
150
-					$this->log->info( "$class_name installed." );
150
+					$this->log->info("$class_name installed.");
151 151
 
152 152
 					// Bump the version.
153
-					update_option( 'wl_db_version', $version );
153
+					update_option('wl_db_version', $version);
154 154
 				}
155 155
 			}
156 156
 
157 157
 			// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
158
-			@delete_transient( '_wl_installing' );
158
+			@delete_transient('_wl_installing');
159 159
 
160 160
 		}
161 161
 
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
 	private function install_required() {
165 165
 
166 166
 		/** @var Wordlift_Install $install */
167
-		foreach ( $this->installs as $install ) {
167
+		foreach ($this->installs as $install) {
168 168
 			// Get the install version.
169 169
 			$version = $install->get_version();
170 170
 
171
-			if ( version_compare( $version, $this->get_current_version(), '>' )
172
-				 || $install->must_install() ) {
171
+			if (version_compare($version, $this->get_current_version(), '>')
172
+				 || $install->must_install()) {
173 173
 				return true;
174 174
 			}
175 175
 		}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @return type
184 184
 	 */
185 185
 	private function get_current_version() {
186
-		return get_option( 'wl_db_version', '0.0.0' );
186
+		return get_option('wl_db_version', '0.0.0');
187 187
 	}
188 188
 
189 189
 }
Please login to merge, or discard this patch.
src/modules/food-kg/load.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -19,58 +19,58 @@  discard block
 block discarded – undo
19 19
 use Wordlift\Task\Background\Background_Task_Page;
20 20
 use Wordlift\Task\Background\Background_Task_Route;
21 21
 
22
-if ( ! defined( 'ABSPATH' ) ) {
22
+if ( ! defined('ABSPATH')) {
23 23
 	exit;
24 24
 }
25 25
 
26
-define( 'WL_FOOD_KG_FILE', __FILE__ );
27
-define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
26
+define('WL_FOOD_KG_FILE', __FILE__);
27
+define('WL_FOOD_KG_DIR_PATH', dirname(WL_FOOD_KG_FILE));
28 28
 
29 29
 function __wl_foodkg__load() {
30 30
 	// Autoloader for dependencies.
31
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
32
-		require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
31
+	if (file_exists(WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php')) {
32
+		require WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php';
33 33
 	}
34 34
 
35 35
 	// Autoloader for plugin itself.
36
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
37
-		require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
36
+	if (file_exists(WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php')) {
37
+		require WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php';
38 38
 	}
39 39
 
40 40
 	$container_builder = new ContainerBuilder();
41
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
42
-	$loader->load( 'services.yml' );
41
+	$loader            = new YamlFileLoader($container_builder, new FileLocator(__DIR__));
42
+	$loader->load('services.yml');
43 43
 	$container_builder->compile();
44 44
 
45
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
45
+	$notices = $container_builder->get('Wordlift\Modules\Food_Kg\Notices');
46 46
 	$notices->register_hooks();
47 47
 
48 48
 	/**
49 49
 	 * @var Preconditions $preconditions
50 50
 	 */
51
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
52
-	if ( ! $preconditions->pass() ) {
51
+	$preconditions = $container_builder->get('Wordlift\Modules\Food_Kg\Preconditions');
52
+	if ( ! $preconditions->pass()) {
53 53
 		return;
54 54
 	}
55 55
 
56 56
 	// Meta Box.
57
-	$meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' );
57
+	$meta_box = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Meta_Box');
58 58
 	$meta_box->register_hooks();
59 59
 
60
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
60
+	$module = $container_builder->get('Wordlift\Modules\Food_Kg\Module');
61 61
 	$module->register_hooks();
62 62
 
63 63
 	/** @var Jsonld $jsonld */
64
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
64
+	$jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Jsonld');
65 65
 	$jsonld->register_hooks();
66 66
 
67 67
 	/** @var Main_Ingredient_Jsonld $jsonld */
68
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
68
+	$main_ingredient_jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld');
69 69
 	$main_ingredient_jsonld->register_hooks();
70 70
 
71 71
 
72 72
 	/** Prepare the background task. */
73
-	$main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' );
73
+	$main_ingredient_recipe_lift = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy');
74 74
 	$task                        = new All_Posts_Task(
75 75
 		array(
76 76
 			$main_ingredient_recipe_lift,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 		'wprm_recipe',
80 80
 		'sync-main-ingredient'
81 81
 	);
82
-	$background_task             = Background_Task::create( $task );
83
-	$background_task_route       = Background_Task_Route::create( $background_task, '/main-ingredient' );
84
-	Background_Task_Page::create( __( 'Synchronize Main Ingredient', 'wordlift' ), 'sync-main-ingredient', $background_task_route );
82
+	$background_task             = Background_Task::create($task);
83
+	$background_task_route       = Background_Task_Route::create($background_task, '/main-ingredient');
84
+	Background_Task_Page::create(__('Synchronize Main Ingredient', 'wordlift'), 'sync-main-ingredient', $background_task_route);
85 85
 
86 86
 
87
-	if ( is_admin() ) {
88
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
87
+	if (is_admin()) {
88
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Page');
89 89
 		$page->register_hooks();
90 90
 
91 91
 		// Download Ingredients Data.
92
-		$download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' );
92
+		$download_ingredients_data = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data');
93 93
 		$download_ingredients_data->register_hooks();
94 94
 
95 95
 	}
96 96
 }
97 97
 
98
-add_action( 'plugins_loaded', '__wl_foodkg__load' );
98
+add_action('plugins_loaded', '__wl_foodkg__load');
99 99
 
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -20,77 +20,77 @@
 block discarded – undo
20 20
 use Wordlift\Task\Background\Background_Task_Route;
21 21
 
22 22
 if ( ! defined( 'ABSPATH' ) ) {
23
-	exit;
23
+    exit;
24 24
 }
25 25
 
26 26
 define( 'WL_FOOD_KG_FILE', __FILE__ );
27 27
 define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
28 28
 
29 29
 function __wl_foodkg__load() {
30
-	// Autoloader for dependencies.
31
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
32
-		require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
33
-	}
34
-
35
-	// Autoloader for plugin itself.
36
-	if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
37
-		require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
38
-	}
39
-
40
-	$container_builder = new ContainerBuilder();
41
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
42
-	$loader->load( 'services.yml' );
43
-	$container_builder->compile();
44
-
45
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
46
-	$notices->register_hooks();
47
-
48
-	/**
49
-	 * @var Preconditions $preconditions
50
-	 */
51
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
52
-	if ( ! $preconditions->pass() ) {
53
-		return;
54
-	}
55
-
56
-	// Meta Box.
57
-	$meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' );
58
-	$meta_box->register_hooks();
59
-
60
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
61
-	$module->register_hooks();
62
-
63
-	/** @var Jsonld $jsonld */
64
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
65
-	$jsonld->register_hooks();
66
-
67
-	/** @var Main_Ingredient_Jsonld $jsonld */
68
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
69
-	$main_ingredient_jsonld->register_hooks();
70
-
71
-	/** Prepare the background task. */
72
-	$main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' );
73
-	$task                        = new All_Posts_Task(
74
-		array(
75
-			$main_ingredient_recipe_lift,
76
-			'process',
77
-		),
78
-		'wprm_recipe',
79
-		'sync-main-ingredient'
80
-	);
81
-	$background_task             = Background_Task::create( $task );
82
-	$background_task_route       = Background_Task_Route::create( $background_task, '/main-ingredient' );
83
-	Background_Task_Page::create( __( 'Synchronize Main Ingredient', 'wordlift' ), 'sync-main-ingredient', $background_task_route );
84
-
85
-	if ( is_admin() ) {
86
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
87
-		$page->register_hooks();
88
-
89
-		// Download Ingredients Data.
90
-		$download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' );
91
-		$download_ingredients_data->register_hooks();
92
-
93
-	}
30
+    // Autoloader for dependencies.
31
+    if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) {
32
+        require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php';
33
+    }
34
+
35
+    // Autoloader for plugin itself.
36
+    if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) {
37
+        require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php';
38
+    }
39
+
40
+    $container_builder = new ContainerBuilder();
41
+    $loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
42
+    $loader->load( 'services.yml' );
43
+    $container_builder->compile();
44
+
45
+    $notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
46
+    $notices->register_hooks();
47
+
48
+    /**
49
+     * @var Preconditions $preconditions
50
+     */
51
+    $preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
52
+    if ( ! $preconditions->pass() ) {
53
+        return;
54
+    }
55
+
56
+    // Meta Box.
57
+    $meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' );
58
+    $meta_box->register_hooks();
59
+
60
+    $module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
61
+    $module->register_hooks();
62
+
63
+    /** @var Jsonld $jsonld */
64
+    $jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
65
+    $jsonld->register_hooks();
66
+
67
+    /** @var Main_Ingredient_Jsonld $jsonld */
68
+    $main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
69
+    $main_ingredient_jsonld->register_hooks();
70
+
71
+    /** Prepare the background task. */
72
+    $main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' );
73
+    $task                        = new All_Posts_Task(
74
+        array(
75
+            $main_ingredient_recipe_lift,
76
+            'process',
77
+        ),
78
+        'wprm_recipe',
79
+        'sync-main-ingredient'
80
+    );
81
+    $background_task             = Background_Task::create( $task );
82
+    $background_task_route       = Background_Task_Route::create( $background_task, '/main-ingredient' );
83
+    Background_Task_Page::create( __( 'Synchronize Main Ingredient', 'wordlift' ), 'sync-main-ingredient', $background_task_route );
84
+
85
+    if ( is_admin() ) {
86
+        $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
87
+        $page->register_hooks();
88
+
89
+        // Download Ingredients Data.
90
+        $download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' );
91
+        $download_ingredients_data->register_hooks();
92
+
93
+    }
94 94
 }
95 95
 
96 96
 add_action( 'plugins_loaded', '__wl_foodkg__load' );
Please login to merge, or discard this patch.
src/modules/food-kg/includes/admin/Main_Ingredient_List_Table.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Wordlift\Modules\Food_Kg\Admin;
4 4
 
5
-if ( ! class_exists( 'WP_List_Table' ) ) {
6
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+if ( ! class_exists('WP_List_Table')) {
6
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 use WP_List_Table;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		 * 3 other arrays. One for all columns, one for hidden columns, and one
31 31
 		 * for sortable columns.
32 32
 		 */
33
-		$this->_column_headers = array( $columns, $hidden, $sortable );
33
+		$this->_column_headers = array($columns, $hidden, $sortable);
34 34
 
35 35
 		// Pagination.
36 36
 		$per_page     = 20;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 					LIMIT %d
55 55
 					OFFSET %d",
56 56
 				$per_page,
57
-				( $current_page - 1 ) * $per_page
57
+				($current_page - 1) * $per_page
58 58
 			)
59 59
 		);
60 60
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			array(
63 63
 				'total_items' => $total_items,
64 64
 				'per_page'    => $per_page,
65
-				'total_pages' => ceil( $total_items / $per_page ),
65
+				'total_pages' => ceil($total_items / $per_page),
66 66
 			)
67 67
 		);
68 68
 	}
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	private function count() {
71 71
 		global $wpdb;
72 72
 
73
-		$count = get_transient( '_wl_main_ingredient_list_table__count' );
73
+		$count = get_transient('_wl_main_ingredient_list_table__count');
74 74
 
75
-		if ( ! $count ) {
75
+		if ( ! $count) {
76 76
 
77 77
 			$count = $wpdb->get_var(
78 78
 				"SELECT COUNT( 1 ) 
@@ -85,56 +85,56 @@  discard block
 block discarded – undo
85 85
 					WHERE p1.post_type = 'wprm_recipe'"
86 86
 			);
87 87
 
88
-			set_transient( '_wl_main_ingredient_list_table__count', $count, 60 );
88
+			set_transient('_wl_main_ingredient_list_table__count', $count, 60);
89 89
 		}
90 90
 
91 91
 		return $count;
92 92
 	}
93 93
 
94 94
 	public function no_items() {
95
-		esc_html_e( 'No main ingredients found.', 'wordlift' );
95
+		esc_html_e('No main ingredients found.', 'wordlift');
96 96
 	}
97 97
 
98 98
 	public function get_columns() {
99 99
 		return array(
100
-			'ingredient_name' => __( 'Ingredient Name', 'wordlift' ),
101
-			'recipe_name'     => __( 'Recipe Name', 'wordlift' ),
102
-			'post_title'      => __( 'Post Title', 'wordlift' ),
103
-			'url'             => __( 'Post URL', 'wordlift' ),
100
+			'ingredient_name' => __('Ingredient Name', 'wordlift'),
101
+			'recipe_name'     => __('Recipe Name', 'wordlift'),
102
+			'post_title'      => __('Post Title', 'wordlift'),
103
+			'url'             => __('Post URL', 'wordlift'),
104 104
 			'actions'         => '',
105 105
 		);
106 106
 	}
107 107
 
108
-	public function column_ingredient_name( $item ) {
109
-		$recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
110
-		$recipe         = json_decode( $recipe_json_ld, true );
108
+	public function column_ingredient_name($item) {
109
+		$recipe_json_ld = get_post_meta($item->recipe_ID, '_wl_main_ingredient_jsonld', true); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
110
+		$recipe         = json_decode($recipe_json_ld, true);
111 111
 
112 112
 		return $recipe ? $recipe['name'] : 'null';
113 113
 	}
114 114
 
115
-	public function column_recipe_name( $item ) {
115
+	public function column_recipe_name($item) {
116 116
 		return $item->recipe_name;
117 117
 	}
118 118
 
119
-	public function column_post_title( $item ) {
120
-		return sprintf( '<a href="%s">%s</a>', get_edit_post_link( $item->post_ID ), $item->post_title );
119
+	public function column_post_title($item) {
120
+		return sprintf('<a href="%s">%s</a>', get_edit_post_link($item->post_ID), $item->post_title);
121 121
 	}
122 122
 
123
-	public function column_url( $item ) {
124
-		return get_permalink( $item->post_ID );
123
+	public function column_url($item) {
124
+		return get_permalink($item->post_ID);
125 125
 	}
126 126
 
127
-	public function column_actions( $item ) {
127
+	public function column_actions($item) {
128 128
 
129 129
 		$url = admin_url(
130
-			sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->recipe_ID )  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
130
+			sprintf('admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->recipe_ID)  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
131 131
 		);
132 132
 
133 133
 		return sprintf(
134 134
 			'<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
135 135
 			$url,
136
-			esc_attr( $item->post_title ),
137
-			esc_html__( 'JSON-LD', 'wordlift' )
136
+			esc_attr($item->post_title),
137
+			esc_html__('JSON-LD', 'wordlift')
138 138
 		);
139 139
 	}
140 140
 
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -3,43 +3,43 @@  discard block
 block discarded – undo
3 3
 namespace Wordlift\Modules\Food_Kg\Admin;
4 4
 
5 5
 if ( ! class_exists( 'WP_List_Table' ) ) {
6
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 use WP_List_Table;
10 10
 
11 11
 class Main_Ingredient_List_Table extends WP_List_Table {
12 12
 
13
-	public function prepare_items() {
14
-		global $wpdb; // This is used only if making any database queries
15
-
16
-		/**
17
-		 * REQUIRED. Now we need to define our column headers. This includes a complete
18
-		 * array of columns to be displayed (slugs & titles), a list of columns
19
-		 * to keep hidden, and a list of columns that are sortable. Each of these
20
-		 * can be defined in another method (as we've done here) before being
21
-		 * used to build the value for our _column_headers property.
22
-		 */
23
-		$columns  = $this->get_columns();
24
-		$hidden   = array();
25
-		$sortable = $this->get_sortable_columns();
26
-
27
-		/**
28
-		 * REQUIRED. Finally, we build an array to be used by the class for column
29
-		 * headers. The $this->_column_headers property takes an array which contains
30
-		 * 3 other arrays. One for all columns, one for hidden columns, and one
31
-		 * for sortable columns.
32
-		 */
33
-		$this->_column_headers = array( $columns, $hidden, $sortable );
34
-
35
-		// Pagination.
36
-		$per_page     = 20;
37
-		$current_page = $this->get_pagenum();
38
-		$total_items  = $this->count();
39
-
40
-		$this->items = $wpdb->get_results(
41
-			$wpdb->prepare(
42
-				"SELECT p1.ID AS recipe_ID,
13
+    public function prepare_items() {
14
+        global $wpdb; // This is used only if making any database queries
15
+
16
+        /**
17
+         * REQUIRED. Now we need to define our column headers. This includes a complete
18
+         * array of columns to be displayed (slugs & titles), a list of columns
19
+         * to keep hidden, and a list of columns that are sortable. Each of these
20
+         * can be defined in another method (as we've done here) before being
21
+         * used to build the value for our _column_headers property.
22
+         */
23
+        $columns  = $this->get_columns();
24
+        $hidden   = array();
25
+        $sortable = $this->get_sortable_columns();
26
+
27
+        /**
28
+         * REQUIRED. Finally, we build an array to be used by the class for column
29
+         * headers. The $this->_column_headers property takes an array which contains
30
+         * 3 other arrays. One for all columns, one for hidden columns, and one
31
+         * for sortable columns.
32
+         */
33
+        $this->_column_headers = array( $columns, $hidden, $sortable );
34
+
35
+        // Pagination.
36
+        $per_page     = 20;
37
+        $current_page = $this->get_pagenum();
38
+        $total_items  = $this->count();
39
+
40
+        $this->items = $wpdb->get_results(
41
+            $wpdb->prepare(
42
+                "SELECT p1.ID AS recipe_ID,
43 43
 					    p1.post_title AS recipe_name,
44 44
 					    p2.ID AS post_ID,
45 45
 					    p2.post_title,
@@ -48,36 +48,36 @@  discard block
 block discarded – undo
48 48
 					    INNER JOIN {$wpdb->postmeta} pm1 ON pm1.post_ID = p1.ID
49 49
 					        AND pm1.meta_key = '_wl_main_ingredient_jsonld'
50 50
 					    INNER JOIN {$wpdb->posts} p2"
51
-				// The following ignore rule is used against the `LIKE CONCAT`. We only have const values.
52
-				// phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery
53
-				. " ON p2.post_content LIKE CONCAT( '%<!--WPRM Recipe ', p1.ID,'-->%' )
51
+                // The following ignore rule is used against the `LIKE CONCAT`. We only have const values.
52
+                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery
53
+                . " ON p2.post_content LIKE CONCAT( '%<!--WPRM Recipe ', p1.ID,'-->%' )
54 54
 					            AND p2.post_status = 'publish'
55 55
 					WHERE p1.post_type = 'wprm_recipe'
56 56
 					LIMIT %d
57 57
 					OFFSET %d",
58
-				$per_page,
59
-				( $current_page - 1 ) * $per_page
60
-			)
61
-		);
58
+                $per_page,
59
+                ( $current_page - 1 ) * $per_page
60
+            )
61
+        );
62 62
 
63
-		$this->set_pagination_args(
64
-			array(
65
-				'total_items' => $total_items,
66
-				'per_page'    => $per_page,
67
-				'total_pages' => ceil( $total_items / $per_page ),
68
-			)
69
-		);
70
-	}
63
+        $this->set_pagination_args(
64
+            array(
65
+                'total_items' => $total_items,
66
+                'per_page'    => $per_page,
67
+                'total_pages' => ceil( $total_items / $per_page ),
68
+            )
69
+        );
70
+    }
71 71
 
72
-	private function count() {
73
-		global $wpdb;
72
+    private function count() {
73
+        global $wpdb;
74 74
 
75
-		$count = get_transient( '_wl_main_ingredient_list_table__count' );
75
+        $count = get_transient( '_wl_main_ingredient_list_table__count' );
76 76
 
77
-		if ( ! $count ) {
77
+        if ( ! $count ) {
78 78
 
79
-			$count = $wpdb->get_var(
80
-				"SELECT COUNT( 1 ) 
79
+            $count = $wpdb->get_var(
80
+                "SELECT COUNT( 1 ) 
81 81
 					FROM {$wpdb->posts} p1
82 82
 					    INNER JOIN {$wpdb->postmeta} pm1 ON pm1.post_ID = p1.ID
83 83
 					        AND pm1.meta_key = '_wl_main_ingredient_jsonld'
@@ -85,60 +85,60 @@  discard block
 block discarded – undo
85 85
 					        ON p2.post_content LIKE CONCAT( '%<!--WPRM Recipe ', p1.ID,'-->%' )
86 86
 					            AND p2.post_status = 'publish'
87 87
 					WHERE p1.post_type = 'wprm_recipe'"
88
-			);
89
-
90
-			set_transient( '_wl_main_ingredient_list_table__count', $count, 60 );
91
-		}
92
-
93
-		return $count;
94
-	}
95
-
96
-	public function no_items() {
97
-		esc_html_e( 'No main ingredients found.', 'wordlift' );
98
-	}
99
-
100
-	public function get_columns() {
101
-		return array(
102
-			'ingredient_name' => __( 'Ingredient Name', 'wordlift' ),
103
-			'recipe_name'     => __( 'Recipe Name', 'wordlift' ),
104
-			'post_title'      => __( 'Post Title', 'wordlift' ),
105
-			'url'             => __( 'Post URL', 'wordlift' ),
106
-			'actions'         => '',
107
-		);
108
-	}
109
-
110
-	public function column_ingredient_name( $item ) {
111
-		$recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
112
-		$recipe         = json_decode( $recipe_json_ld, true );
113
-
114
-		return $recipe ? $recipe['name'] : 'null';
115
-	}
116
-
117
-	public function column_recipe_name( $item ) {
118
-		return $item->recipe_name;
119
-	}
120
-
121
-	public function column_post_title( $item ) {
122
-		return sprintf( '<a href="%s">%s</a>', get_edit_post_link( $item->post_ID ), $item->post_title );
123
-	}
124
-
125
-	public function column_url( $item ) {
126
-		return get_permalink( $item->post_ID );
127
-	}
128
-
129
-	public function column_actions( $item ) {
130
-
131
-		$url = admin_url(
132
-			sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->recipe_ID )  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
133
-		);
134
-
135
-		return sprintf(
136
-			'<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
137
-			$url,
138
-			esc_attr( $item->post_title ),
139
-			esc_html__( 'JSON-LD', 'wordlift' )
140
-		);
141
-	}
88
+            );
89
+
90
+            set_transient( '_wl_main_ingredient_list_table__count', $count, 60 );
91
+        }
92
+
93
+        return $count;
94
+    }
95
+
96
+    public function no_items() {
97
+        esc_html_e( 'No main ingredients found.', 'wordlift' );
98
+    }
99
+
100
+    public function get_columns() {
101
+        return array(
102
+            'ingredient_name' => __( 'Ingredient Name', 'wordlift' ),
103
+            'recipe_name'     => __( 'Recipe Name', 'wordlift' ),
104
+            'post_title'      => __( 'Post Title', 'wordlift' ),
105
+            'url'             => __( 'Post URL', 'wordlift' ),
106
+            'actions'         => '',
107
+        );
108
+    }
109
+
110
+    public function column_ingredient_name( $item ) {
111
+        $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
112
+        $recipe         = json_decode( $recipe_json_ld, true );
113
+
114
+        return $recipe ? $recipe['name'] : 'null';
115
+    }
116
+
117
+    public function column_recipe_name( $item ) {
118
+        return $item->recipe_name;
119
+    }
120
+
121
+    public function column_post_title( $item ) {
122
+        return sprintf( '<a href="%s">%s</a>', get_edit_post_link( $item->post_ID ), $item->post_title );
123
+    }
124
+
125
+    public function column_url( $item ) {
126
+        return get_permalink( $item->post_ID );
127
+    }
128
+
129
+    public function column_actions( $item ) {
130
+
131
+        $url = admin_url(
132
+            sprintf( 'admin.php?page=wl_ingredients&modal_window=true&id=%d&TB_iframe=true', $item->recipe_ID )  // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
133
+        );
134
+
135
+        return sprintf(
136
+            '<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>',
137
+            $url,
138
+            esc_attr( $item->post_title ),
139
+            esc_html__( 'JSON-LD', 'wordlift' )
140
+        );
141
+    }
142 142
 
143 143
 }
144 144
 
Please login to merge, or discard this patch.
src/modules/food-kg/includes/admin/Download_Ingredients_Data.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -4,22 +4,22 @@  discard block
 block discarded – undo
4 4
 
5 5
 class Download_Ingredients_Data {
6 6
 
7
-	public function register_hooks() {
8
-		add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) );
9
-	}
7
+    public function register_hooks() {
8
+        add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) );
9
+    }
10 10
 
11
-	public function wl_download_ingredients_data() {
11
+    public function wl_download_ingredients_data() {
12 12
 
13
-		check_ajax_referer( 'wl-dl-ingredients-data-nonce' );
13
+        check_ajax_referer( 'wl-dl-ingredients-data-nonce' );
14 14
 
15
-		if ( ! current_user_can( 'manage_options' ) ) {
16
-			wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) );
17
-		}
15
+        if ( ! current_user_can( 'manage_options' ) ) {
16
+            wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) );
17
+        }
18 18
 
19
-		global $wpdb;
19
+        global $wpdb;
20 20
 
21
-		$items = $wpdb->get_results(
22
-			"SELECT p1.ID AS recipe_ID,
21
+        $items = $wpdb->get_results(
22
+            "SELECT p1.ID AS recipe_ID,
23 23
 					    p1.post_title AS recipe_name,
24 24
 					    p2.ID AS post_ID,
25 25
 					    p2.post_title,
@@ -31,56 +31,56 @@  discard block
 block discarded – undo
31 31
 					        ON p2.post_content LIKE CONCAT( '%<!--WPRM Recipe ', p1.ID,'-->%' )
32 32
 					            AND p2.post_status = 'publish'
33 33
 					WHERE p1.post_type = 'wprm_recipe'"
34
-		);
35
-
36
-		if ( ! $items ) {
37
-			wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) );
38
-		}
39
-
40
-		// Generate unique filename using current timestamp.
41
-		$filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv';
42
-
43
-		header( 'Content-Disposition: attachment; filename=' . $filename );
44
-		header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) );
45
-
46
-		// Do not cache the file.
47
-		header( 'Pragma: no-cache' );
48
-		header( 'Expires: 0' );
49
-
50
-		$output = fopen( 'php://output', 'w' );
51
-
52
-		// Insert Header.
53
-		fputcsv(
54
-			$output,
55
-			array(
56
-				__( 'Ingredient Name', 'wordlift' ),
57
-				__( 'Recipe Name', 'wordlift' ),
58
-				__( 'Recipe ID', 'wordlift' ),
59
-				__( 'Post Name', 'wordlift' ),
60
-				__( 'Post ID', 'wordlift' ),
61
-				__( 'Post URL', 'wordlift' ),
62
-			),
63
-			"\t"
64
-		);
65
-
66
-		// Insert Data.
67
-		foreach ( $items as $item ) {
68
-			$recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
69
-			$recipe         = json_decode( $recipe_json_ld, true );
70
-			fputcsv(
71
-				$output,
72
-				array(
73
-					$recipe ? $recipe['name'] : 'null',
74
-					$item->recipe_name,
75
-					$item->recipe_ID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
76
-					$item->post_title,
77
-					$item->post_ID,
78
-					esc_url( get_the_permalink( $item->post_ID ) ),
79
-				),
80
-				"\t"
81
-			);
82
-		}
83
-
84
-		wp_die();
85
-	}
34
+        );
35
+
36
+        if ( ! $items ) {
37
+            wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) );
38
+        }
39
+
40
+        // Generate unique filename using current timestamp.
41
+        $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv';
42
+
43
+        header( 'Content-Disposition: attachment; filename=' . $filename );
44
+        header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) );
45
+
46
+        // Do not cache the file.
47
+        header( 'Pragma: no-cache' );
48
+        header( 'Expires: 0' );
49
+
50
+        $output = fopen( 'php://output', 'w' );
51
+
52
+        // Insert Header.
53
+        fputcsv(
54
+            $output,
55
+            array(
56
+                __( 'Ingredient Name', 'wordlift' ),
57
+                __( 'Recipe Name', 'wordlift' ),
58
+                __( 'Recipe ID', 'wordlift' ),
59
+                __( 'Post Name', 'wordlift' ),
60
+                __( 'Post ID', 'wordlift' ),
61
+                __( 'Post URL', 'wordlift' ),
62
+            ),
63
+            "\t"
64
+        );
65
+
66
+        // Insert Data.
67
+        foreach ( $items as $item ) {
68
+            $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
69
+            $recipe         = json_decode( $recipe_json_ld, true );
70
+            fputcsv(
71
+                $output,
72
+                array(
73
+                    $recipe ? $recipe['name'] : 'null',
74
+                    $item->recipe_name,
75
+                    $item->recipe_ID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
76
+                    $item->post_title,
77
+                    $item->post_ID,
78
+                    esc_url( get_the_permalink( $item->post_ID ) ),
79
+                ),
80
+                "\t"
81
+            );
82
+        }
83
+
84
+        wp_die();
85
+    }
86 86
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,15 +5,15 @@  discard block
 block discarded – undo
5 5
 class Download_Ingredients_Data {
6 6
 
7 7
 	public function register_hooks() {
8
-		add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) );
8
+		add_action('wp_ajax_wl_download_ingredients_data', array($this, 'wl_download_ingredients_data'));
9 9
 	}
10 10
 
11 11
 	public function wl_download_ingredients_data() {
12 12
 
13
-		check_ajax_referer( 'wl-dl-ingredients-data-nonce' );
13
+		check_ajax_referer('wl-dl-ingredients-data-nonce');
14 14
 
15
-		if ( ! current_user_can( 'manage_options' ) ) {
16
-			wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) );
15
+		if ( ! current_user_can('manage_options')) {
16
+			wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'wordlift'));
17 17
 		}
18 18
 
19 19
 		global $wpdb;
@@ -33,40 +33,40 @@  discard block
 block discarded – undo
33 33
 					WHERE p1.post_type = 'wprm_recipe'"
34 34
 		);
35 35
 
36
-		if ( ! $items ) {
37
-			wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) );
36
+		if ( ! $items) {
37
+			wp_send_json_error(__('No main ingredients found.', 'wordlift'));
38 38
 		}
39 39
 
40 40
 		// Generate unique filename using current timestamp.
41
-		$filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv';
41
+		$filename = 'wl-main-ingredients-data-'.gmdate('Y-m-d-H-i-s').'.tsv';
42 42
 
43
-		header( 'Content-Disposition: attachment; filename=' . $filename );
44
-		header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) );
43
+		header('Content-Disposition: attachment; filename='.$filename);
44
+		header('Content-Type: text/text/tab-separated-values; charset='.get_bloginfo('charset'));
45 45
 
46 46
 		// Do not cache the file.
47
-		header( 'Pragma: no-cache' );
48
-		header( 'Expires: 0' );
47
+		header('Pragma: no-cache');
48
+		header('Expires: 0');
49 49
 
50
-		$output = fopen( 'php://output', 'w' );
50
+		$output = fopen('php://output', 'w');
51 51
 
52 52
 		// Insert Header.
53 53
 		fputcsv(
54 54
 			$output,
55 55
 			array(
56
-				__( 'Ingredient Name', 'wordlift' ),
57
-				__( 'Recipe Name', 'wordlift' ),
58
-				__( 'Recipe ID', 'wordlift' ),
59
-				__( 'Post Name', 'wordlift' ),
60
-				__( 'Post ID', 'wordlift' ),
61
-				__( 'Post URL', 'wordlift' ),
56
+				__('Ingredient Name', 'wordlift'),
57
+				__('Recipe Name', 'wordlift'),
58
+				__('Recipe ID', 'wordlift'),
59
+				__('Post Name', 'wordlift'),
60
+				__('Post ID', 'wordlift'),
61
+				__('Post URL', 'wordlift'),
62 62
 			),
63 63
 			"\t"
64 64
 		);
65 65
 
66 66
 		// Insert Data.
67
-		foreach ( $items as $item ) {
68
-			$recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
69
-			$recipe         = json_decode( $recipe_json_ld, true );
67
+		foreach ($items as $item) {
68
+			$recipe_json_ld = get_post_meta($item->recipe_ID, '_wl_main_ingredient_jsonld', true); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
69
+			$recipe         = json_decode($recipe_json_ld, true);
70 70
 			fputcsv(
71 71
 				$output,
72 72
 				array(
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 					$item->recipe_ID, // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
76 76
 					$item->post_title,
77 77
 					$item->post_ID,
78
-					esc_url( get_the_permalink( $item->post_ID ) ),
78
+					esc_url(get_the_permalink($item->post_ID)),
79 79
 				),
80 80
 				"\t"
81 81
 			);
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Main_Ingredient_Recipe_Lift_Strategy.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -4,94 +4,94 @@
 block discarded – undo
4 4
 
5 5
 class Main_Ingredient_Recipe_Lift_Strategy implements Recipe_Lift_Strategy {
6 6
 
7
-	/**
8
-	 * @var Ingredients_Client
9
-	 */
10
-	private $ingredients_client;
11
-
12
-	/**
13
-	 * @var Notices
14
-	 */
15
-	private $notices;
16
-
17
-	public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
-		$this->ingredients_client = $ingredients_client;
19
-		$this->notices            = $notices;
20
-	}
21
-
22
-	public function get_json_ld_data( $ingredient ) {
23
-		// Get JSON LD Data.
24
-		return $this->ingredients_client->main_ingredient( $ingredient );
25
-	}
26
-
27
-	public function run() {
28
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
29
-
30
-		$recipes = get_posts(
31
-			array(
32
-				'post_type'   => 'wprm_recipe',
33
-				'numberposts' => - 1,
34
-			)
35
-		);
36
-		$count   = count( $recipes );
37
-
38
-		$count_lifted = 0;
39
-		foreach ( $recipes as $recipe ) {
40
-			/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
-			$this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
42
-
43
-			// Emit something to keep the connection alive.
44
-			echo esc_html( "$count_lifted\n" );
45
-
46
-			if ( $this->process( $recipe->ID ) ) {
47
-				$count_lifted ++;
48
-			}
49
-		}
50
-
51
-		/**
52
-		 * @@todo add notification that procedure is complete, with information about the number of processed items vs
53
-		 *   total items
54
-		 */
55
-		/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
56
-		$this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
57
-	}
58
-
59
-	public function process( $post_id ) {
60
-
61
-		// Skip posts with existing data.
62
-		$existing = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
63
-		if ( ! empty( $existing ) ) {
64
-			return true;
65
-		}
66
-
67
-		$post = get_post( $post_id );
68
-
69
-		$jsonld = $this->ingredients_client->main_ingredient( $post->post_title );
70
-		if ( $this->validate( $jsonld ) ) {
71
-			add_post_meta( $post_id, '_wl_main_ingredient_jsonld', $jsonld );
72
-
73
-			return true;
74
-		} else {
75
-			// No ingredient found.
76
-			delete_post_meta( $post_id, '_wl_main_ingredient_jsonld' );
77
-
78
-			return false;
79
-		}
80
-
81
-	}
82
-
83
-	private function validate( $jsonld_string ) {
84
-
85
-		try {
86
-			$json = json_decode( $jsonld_string );
87
-			if ( ! isset( $json->{'@type'} ) || ! isset( $json->name ) ) {
88
-				return false;
89
-			}
90
-		} catch ( \Exception $e ) {
91
-			return false;
92
-		}
93
-
94
-		return true;
95
-	}
7
+    /**
8
+     * @var Ingredients_Client
9
+     */
10
+    private $ingredients_client;
11
+
12
+    /**
13
+     * @var Notices
14
+     */
15
+    private $notices;
16
+
17
+    public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
18
+        $this->ingredients_client = $ingredients_client;
19
+        $this->notices            = $notices;
20
+    }
21
+
22
+    public function get_json_ld_data( $ingredient ) {
23
+        // Get JSON LD Data.
24
+        return $this->ingredients_client->main_ingredient( $ingredient );
25
+    }
26
+
27
+    public function run() {
28
+        $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
29
+
30
+        $recipes = get_posts(
31
+            array(
32
+                'post_type'   => 'wprm_recipe',
33
+                'numberposts' => - 1,
34
+            )
35
+        );
36
+        $count   = count( $recipes );
37
+
38
+        $count_lifted = 0;
39
+        foreach ( $recipes as $recipe ) {
40
+            /* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
+            $this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
42
+
43
+            // Emit something to keep the connection alive.
44
+            echo esc_html( "$count_lifted\n" );
45
+
46
+            if ( $this->process( $recipe->ID ) ) {
47
+                $count_lifted ++;
48
+            }
49
+        }
50
+
51
+        /**
52
+         * @@todo add notification that procedure is complete, with information about the number of processed items vs
53
+         *   total items
54
+         */
55
+        /* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
56
+        $this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
57
+    }
58
+
59
+    public function process( $post_id ) {
60
+
61
+        // Skip posts with existing data.
62
+        $existing = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
63
+        if ( ! empty( $existing ) ) {
64
+            return true;
65
+        }
66
+
67
+        $post = get_post( $post_id );
68
+
69
+        $jsonld = $this->ingredients_client->main_ingredient( $post->post_title );
70
+        if ( $this->validate( $jsonld ) ) {
71
+            add_post_meta( $post_id, '_wl_main_ingredient_jsonld', $jsonld );
72
+
73
+            return true;
74
+        } else {
75
+            // No ingredient found.
76
+            delete_post_meta( $post_id, '_wl_main_ingredient_jsonld' );
77
+
78
+            return false;
79
+        }
80
+
81
+    }
82
+
83
+    private function validate( $jsonld_string ) {
84
+
85
+        try {
86
+            $json = json_decode( $jsonld_string );
87
+            if ( ! isset( $json->{'@type'} ) || ! isset( $json->name ) ) {
88
+                return false;
89
+            }
90
+        } catch ( \Exception $e ) {
91
+            return false;
92
+        }
93
+
94
+        return true;
95
+    }
96 96
 }
97 97
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,37 +14,37 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	private $notices;
16 16
 
17
-	public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) {
17
+	public function __construct(Ingredients_Client $ingredients_client, Notices $notices) {
18 18
 		$this->ingredients_client = $ingredients_client;
19 19
 		$this->notices            = $notices;
20 20
 	}
21 21
 
22
-	public function get_json_ld_data( $ingredient ) {
22
+	public function get_json_ld_data($ingredient) {
23 23
 		// Get JSON LD Data.
24
-		return $this->ingredients_client->main_ingredient( $ingredient );
24
+		return $this->ingredients_client->main_ingredient($ingredient);
25 25
 	}
26 26
 
27 27
 	public function run() {
28
-		$this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) );
28
+		$this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift'));
29 29
 
30 30
 		$recipes = get_posts(
31 31
 			array(
32 32
 				'post_type'   => 'wprm_recipe',
33
-				'numberposts' => - 1,
33
+				'numberposts' => -1,
34 34
 			)
35 35
 		);
36
-		$count   = count( $recipes );
36
+		$count = count($recipes);
37 37
 
38 38
 		$count_lifted = 0;
39
-		foreach ( $recipes as $recipe ) {
39
+		foreach ($recipes as $recipe) {
40 40
 			/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
41
-			$this->notices->queue( 'info', sprintf( __( 'WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
41
+			$this->notices->queue('info', sprintf(__('WordLift is adding the main ingredient to recipes. So far it lifted %1$d of %2$d recipe(s).', 'wordlift'), $count_lifted, $count));
42 42
 
43 43
 			// Emit something to keep the connection alive.
44
-			echo esc_html( "$count_lifted\n" );
44
+			echo esc_html("$count_lifted\n");
45 45
 
46
-			if ( $this->process( $recipe->ID ) ) {
47
-				$count_lifted ++;
46
+			if ($this->process($recipe->ID)) {
47
+				$count_lifted++;
48 48
 			}
49 49
 		}
50 50
 
@@ -53,41 +53,41 @@  discard block
 block discarded – undo
53 53
 		 *   total items
54 54
 		 */
55 55
 		/* translators: 1: The number of lifted recipes, 2: The total number of recipes. */
56
-		$this->notices->queue( 'info', sprintf( __( 'WordLift lifted %1$d of %2$d recipe(s).', 'wordlift' ), $count_lifted, $count ) );
56
+		$this->notices->queue('info', sprintf(__('WordLift lifted %1$d of %2$d recipe(s).', 'wordlift'), $count_lifted, $count));
57 57
 	}
58 58
 
59
-	public function process( $post_id ) {
59
+	public function process($post_id) {
60 60
 
61 61
 		// Skip posts with existing data.
62
-		$existing = get_post_meta( $post_id, '_wl_main_ingredient_jsonld', true );
63
-		if ( ! empty( $existing ) ) {
62
+		$existing = get_post_meta($post_id, '_wl_main_ingredient_jsonld', true);
63
+		if ( ! empty($existing)) {
64 64
 			return true;
65 65
 		}
66 66
 
67
-		$post = get_post( $post_id );
67
+		$post = get_post($post_id);
68 68
 
69
-		$jsonld = $this->ingredients_client->main_ingredient( $post->post_title );
70
-		if ( $this->validate( $jsonld ) ) {
71
-			add_post_meta( $post_id, '_wl_main_ingredient_jsonld', $jsonld );
69
+		$jsonld = $this->ingredients_client->main_ingredient($post->post_title);
70
+		if ($this->validate($jsonld)) {
71
+			add_post_meta($post_id, '_wl_main_ingredient_jsonld', $jsonld);
72 72
 
73 73
 			return true;
74 74
 		} else {
75 75
 			// No ingredient found.
76
-			delete_post_meta( $post_id, '_wl_main_ingredient_jsonld' );
76
+			delete_post_meta($post_id, '_wl_main_ingredient_jsonld');
77 77
 
78 78
 			return false;
79 79
 		}
80 80
 
81 81
 	}
82 82
 
83
-	private function validate( $jsonld_string ) {
83
+	private function validate($jsonld_string) {
84 84
 
85 85
 		try {
86
-			$json = json_decode( $jsonld_string );
87
-			if ( ! isset( $json->{'@type'} ) || ! isset( $json->name ) ) {
86
+			$json = json_decode($jsonld_string);
87
+			if ( ! isset($json->{'@type'} ) || ! isset($json->name)) {
88 88
 				return false;
89 89
 			}
90
-		} catch ( \Exception $e ) {
90
+		} catch (\Exception $e) {
91 91
 			return false;
92 92
 		}
93 93
 
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-38-5.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 					AND meta_value NOT LIKE %s
23 23
 				",
24 24
 				'_wl_main_ingredient_jsonld',
25
-				'%' . $wpdb->esc_like( '"@id":' ) . '%'
25
+				'%'.$wpdb->esc_like('"@id":').'%'
26 26
 			)
27 27
 		);
28 28
 
29 29
 		// Flush the JSON-LD caches.
30
-		do_action( 'wl_ttl_cache_cleaner__flush' );
30
+		do_action('wl_ttl_cache_cleaner__flush');
31 31
 
32 32
 	}
33 33
 
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Install_3_38_5 extends Wordlift_Install {
9 9
 
10
-	/**
11
-	 * {@inheritdoc}
12
-	 */
13
-	protected static $version = '3.39.0-dev';
10
+    /**
11
+     * {@inheritdoc}
12
+     */
13
+    protected static $version = '3.39.0-dev';
14 14
 
15
-	public function install() {
16
-		global $wpdb;
15
+    public function install() {
16
+        global $wpdb;
17 17
 
18
-		$wpdb->query(
19
-			$wpdb->prepare(
20
-				"DELETE FROM $wpdb->postmeta
18
+        $wpdb->query(
19
+            $wpdb->prepare(
20
+                "DELETE FROM $wpdb->postmeta
21 21
 				WHERE meta_key = %s
22 22
 					AND meta_value NOT LIKE %s
23 23
 				",
24
-				'_wl_main_ingredient_jsonld',
25
-				'%' . $wpdb->esc_like( '"@id":' ) . '%'
26
-			)
27
-		);
24
+                '_wl_main_ingredient_jsonld',
25
+                '%' . $wpdb->esc_like( '"@id":' ) . '%'
26
+            )
27
+        );
28 28
 
29
-		// Flush the JSON-LD caches.
30
-		do_action( 'wl_ttl_cache_cleaner__flush' );
29
+        // Flush the JSON-LD caches.
30
+        do_action( 'wl_ttl_cache_cleaner__flush' );
31 31
 
32
-	}
32
+    }
33 33
 
34 34
 }
Please login to merge, or discard this patch.
src/modules/food-kg/includes/admin/partials/main_ingredient.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
 
8 8
 <div class="wrap">
9 9
 	<div class="wl-ingredients">
10
-		<h1><?php esc_html_e( 'Main Ingredients', 'wordlift' ); ?></h1>
11
-		<a href="<?php echo esc_url( admin_url( 'admin-ajax.php?action=wl_download_ingredients_data&_wpnonce=' . wp_create_nonce( 'wl-dl-ingredients-data-nonce' ) ) ); ?>"
12
-		   class="wl-ingredients__btn-copy-table"><?php esc_html_e( 'Download Ingredients Data', 'wordlift' ); ?></a>
10
+		<h1><?php esc_html_e('Main Ingredients', 'wordlift'); ?></h1>
11
+		<a href="<?php echo esc_url(admin_url('admin-ajax.php?action=wl_download_ingredients_data&_wpnonce='.wp_create_nonce('wl-dl-ingredients-data-nonce'))); ?>"
12
+		   class="wl-ingredients__btn-copy-table"><?php esc_html_e('Download Ingredients Data', 'wordlift'); ?></a>
13 13
 	</div>
14 14
 	<?php
15 15
 
Please login to merge, or discard this patch.
src/wordlift/task/class-all-posts-task.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -11,99 +11,99 @@
 block discarded – undo
11 11
 
12 12
 class All_Posts_Task implements Task {
13 13
 
14
-	private $callable;
15
-
16
-	/**
17
-	 * @var string|null
18
-	 */
19
-	private $post_type;
20
-
21
-	/**
22
-	 * @var string|null
23
-	 */
24
-	private $id;
25
-
26
-	public function __construct( $callable, $post_type = null, $id = null ) {
27
-		$this->callable  = $callable;
28
-		$this->post_type = $post_type;
29
-		$this->id        = $id;
30
-	}
31
-
32
-	public function get_id() {
33
-		return isset( $this->id ) ? $this->id : sha1( get_class( $this ) );
34
-	}
35
-
36
-	public function starting() {
37
-		global $wpdb;
38
-
39
-		// Try to get the count from transient, or load it from database.
40
-		$key   = $this->get_transient_key();
41
-		$count = get_transient( $key );
42
-		if ( false === $count ) {
43
-			$count = $wpdb->get_var(
44
-				"SELECT COUNT( 1 ) 
14
+    private $callable;
15
+
16
+    /**
17
+     * @var string|null
18
+     */
19
+    private $post_type;
20
+
21
+    /**
22
+     * @var string|null
23
+     */
24
+    private $id;
25
+
26
+    public function __construct( $callable, $post_type = null, $id = null ) {
27
+        $this->callable  = $callable;
28
+        $this->post_type = $post_type;
29
+        $this->id        = $id;
30
+    }
31
+
32
+    public function get_id() {
33
+        return isset( $this->id ) ? $this->id : sha1( get_class( $this ) );
34
+    }
35
+
36
+    public function starting() {
37
+        global $wpdb;
38
+
39
+        // Try to get the count from transient, or load it from database.
40
+        $key   = $this->get_transient_key();
41
+        $count = get_transient( $key );
42
+        if ( false === $count ) {
43
+            $count = $wpdb->get_var(
44
+                "SELECT COUNT( 1 ) 
45 45
 				FROM $wpdb->posts "
46
-				// Prepare is called with the `add_post_type_filter` function.
47
-				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
48
-				. $this->where( $this->add_post_type_filter() )
49
-			);
50
-			set_transient( $key, $count, HOUR_IN_SECONDS );
51
-		}
52
-
53
-		return $count;
54
-	}
55
-
56
-	/**
57
-	 * @param $value mixed The incoming value.
58
-	 * @param $args {
59
-	 *
60
-	 * @type int $offset The index of the current item.
61
-	 * @type int $count The total number of items as provided by the `starting` function.
62
-	 * @type int $batch_size The number of items to process within this call.
63
-	 * }
64
-	 *
65
-	 * @return void
66
-	 */
67
-	public function tick( $value, $args ) {
68
-		global $wpdb;
69
-
70
-		$ids = $wpdb->get_col(
71
-			$wpdb->prepare(
72
-				"SELECT ID FROM $wpdb->posts "
73
-				// Prepare is called with the `add_post_type_filter` function.
74
-				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
75
-				. $this->where( $this->add_post_type_filter() )
76
-				. ' ORDER BY ID LIMIT %d,%d',
77
-				$args['offset'],
78
-				$args['batch_size']
79
-			)
80
-		);
81
-
82
-		foreach ( $ids as $id ) {
83
-			call_user_func( $this->callable, $id );
84
-		}
85
-
86
-	}
87
-
88
-	private function add_post_type_filter() {
89
-		global $wpdb;
90
-		if ( isset( $this->post_type ) ) {
91
-			return $wpdb->prepare( ' post_type = %s ', $this->post_type );
92
-		}
93
-
94
-		return '';
95
-	}
96
-
97
-	private function where( $filter ) {
98
-		if ( ! empty( $filter ) ) {
99
-			return " WHERE $filter";
100
-		}
101
-
102
-		return '';
103
-	}
104
-
105
-	private function get_transient_key() {
106
-		return '_wl_task__all_posts_task__count' . ( isset( $this->post_type ) ? '__' . $this->post_type : '' );
107
-	}
46
+                // Prepare is called with the `add_post_type_filter` function.
47
+                // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
48
+                . $this->where( $this->add_post_type_filter() )
49
+            );
50
+            set_transient( $key, $count, HOUR_IN_SECONDS );
51
+        }
52
+
53
+        return $count;
54
+    }
55
+
56
+    /**
57
+     * @param $value mixed The incoming value.
58
+     * @param $args {
59
+     *
60
+     * @type int $offset The index of the current item.
61
+     * @type int $count The total number of items as provided by the `starting` function.
62
+     * @type int $batch_size The number of items to process within this call.
63
+     * }
64
+     *
65
+     * @return void
66
+     */
67
+    public function tick( $value, $args ) {
68
+        global $wpdb;
69
+
70
+        $ids = $wpdb->get_col(
71
+            $wpdb->prepare(
72
+                "SELECT ID FROM $wpdb->posts "
73
+                // Prepare is called with the `add_post_type_filter` function.
74
+                // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
75
+                . $this->where( $this->add_post_type_filter() )
76
+                . ' ORDER BY ID LIMIT %d,%d',
77
+                $args['offset'],
78
+                $args['batch_size']
79
+            )
80
+        );
81
+
82
+        foreach ( $ids as $id ) {
83
+            call_user_func( $this->callable, $id );
84
+        }
85
+
86
+    }
87
+
88
+    private function add_post_type_filter() {
89
+        global $wpdb;
90
+        if ( isset( $this->post_type ) ) {
91
+            return $wpdb->prepare( ' post_type = %s ', $this->post_type );
92
+        }
93
+
94
+        return '';
95
+    }
96
+
97
+    private function where( $filter ) {
98
+        if ( ! empty( $filter ) ) {
99
+            return " WHERE $filter";
100
+        }
101
+
102
+        return '';
103
+    }
104
+
105
+    private function get_transient_key() {
106
+        return '_wl_task__all_posts_task__count' . ( isset( $this->post_type ) ? '__' . $this->post_type : '' );
107
+    }
108 108
 
109 109
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	private $id;
25 25
 
26
-	public function __construct( $callable, $post_type = null, $id = null ) {
26
+	public function __construct($callable, $post_type = null, $id = null) {
27 27
 		$this->callable  = $callable;
28 28
 		$this->post_type = $post_type;
29 29
 		$this->id        = $id;
30 30
 	}
31 31
 
32 32
 	public function get_id() {
33
-		return isset( $this->id ) ? $this->id : sha1( get_class( $this ) );
33
+		return isset($this->id) ? $this->id : sha1(get_class($this));
34 34
 	}
35 35
 
36 36
 	public function starting() {
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 
39 39
 		// Try to get the count from transient, or load it from database.
40 40
 		$key   = $this->get_transient_key();
41
-		$count = get_transient( $key );
42
-		if ( false === $count ) {
41
+		$count = get_transient($key);
42
+		if (false === $count) {
43 43
 			$count = $wpdb->get_var(
44 44
 				"SELECT COUNT( 1 ) 
45 45
 				FROM $wpdb->posts "
46 46
 				// Prepare is called with the `add_post_type_filter` function.
47 47
 				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
48
-				. $this->where( $this->add_post_type_filter() )
48
+				. $this->where($this->add_post_type_filter())
49 49
 			);
50
-			set_transient( $key, $count, HOUR_IN_SECONDS );
50
+			set_transient($key, $count, HOUR_IN_SECONDS);
51 51
 		}
52 52
 
53 53
 		return $count;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return void
66 66
 	 */
67
-	public function tick( $value, $args ) {
67
+	public function tick($value, $args) {
68 68
 		global $wpdb;
69 69
 
70 70
 		$ids = $wpdb->get_col(
@@ -72,30 +72,30 @@  discard block
 block discarded – undo
72 72
 				"SELECT ID FROM $wpdb->posts "
73 73
 				// Prepare is called with the `add_post_type_filter` function.
74 74
 				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
75
-				. $this->where( $this->add_post_type_filter() )
75
+				. $this->where($this->add_post_type_filter())
76 76
 				. ' ORDER BY ID LIMIT %d,%d',
77 77
 				$args['offset'],
78 78
 				$args['batch_size']
79 79
 			)
80 80
 		);
81 81
 
82
-		foreach ( $ids as $id ) {
83
-			call_user_func( $this->callable, $id );
82
+		foreach ($ids as $id) {
83
+			call_user_func($this->callable, $id);
84 84
 		}
85 85
 
86 86
 	}
87 87
 
88 88
 	private function add_post_type_filter() {
89 89
 		global $wpdb;
90
-		if ( isset( $this->post_type ) ) {
91
-			return $wpdb->prepare( ' post_type = %s ', $this->post_type );
90
+		if (isset($this->post_type)) {
91
+			return $wpdb->prepare(' post_type = %s ', $this->post_type);
92 92
 		}
93 93
 
94 94
 		return '';
95 95
 	}
96 96
 
97
-	private function where( $filter ) {
98
-		if ( ! empty( $filter ) ) {
97
+	private function where($filter) {
98
+		if ( ! empty($filter)) {
99 99
 			return " WHERE $filter";
100 100
 		}
101 101
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 
105 105
 	private function get_transient_key() {
106
-		return '_wl_task__all_posts_task__count' . ( isset( $this->post_type ) ? '__' . $this->post_type : '' );
106
+		return '_wl_task__all_posts_task__count'.(isset($this->post_type) ? '__'.$this->post_type : '');
107 107
 	}
108 108
 
109 109
 }
Please login to merge, or discard this patch.