Completed
Push — develop ( 184494...d87d96 )
by David
01:17 queued 15s
created
src/wordlift/task/background/class-background-task.php 1 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 1 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 1 patch
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.
src/modules/food-kg/includes/admin/Main_Ingredient_List_Table.php 1 patch
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.
src/modules/food-kg/includes/admin/Download_Ingredients_Data.php 1 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 1 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 1 patch
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.
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 1 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.