Completed
Pull Request — develop (#1659)
by Naveen
01:13
created
src/wordlift/task/background/class-background-task-factory.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	 * @return Background_Task
26 26
 	 * @throws Exception in case of invalid arguments.
27 27
 	 */
28
-	public static function create( $task, $route, $page_id, $page_title ) {
29
-		self::assertions( $task, $route );
30
-		$background_task       = Background_Task::create( $task );
31
-		$background_task_route = Background_Task_Route::create( $background_task, $route );
32
-		Background_Task_Page::create( $page_title, $page_id, $background_task_route );
28
+	public static function create($task, $route, $page_id, $page_title) {
29
+		self::assertions($task, $route);
30
+		$background_task       = Background_Task::create($task);
31
+		$background_task_route = Background_Task_Route::create($background_task, $route);
32
+		Background_Task_Page::create($page_title, $page_id, $background_task_route);
33 33
 		return $background_task;
34 34
 	}
35 35
 
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	 * @return \Wordlift\Task\Action_Scheduler\Background_Task
45 45
 	 * @throws Exception in case of invalid arguments.
46 46
 	 */
47
-	public static function create_action_scheduler_task( $hook, $group, $task, $route, $page_id, $page_title, $batch_size = 5 ) {
48
-		self::assertions( $task, $route );
49
-		$background_task       = new \Wordlift\Task\Action_Scheduler\Background_Task(
47
+	public static function create_action_scheduler_task($hook, $group, $task, $route, $page_id, $page_title, $batch_size = 5) {
48
+		self::assertions($task, $route);
49
+		$background_task = new \Wordlift\Task\Action_Scheduler\Background_Task(
50 50
 			$hook,
51 51
 			$group,
52 52
 			$task,
53 53
 			"_{$hook}_",
54 54
 			$batch_size
55 55
 		);
56
-		$background_task_route = Background_Task_Route::create( $background_task, $route );
57
-		Background_Task_Page::create( $page_title, $page_id, $background_task_route );
56
+		$background_task_route = Background_Task_Route::create($background_task, $route);
57
+		Background_Task_Page::create($page_title, $page_id, $background_task_route);
58 58
 		return $background_task;
59 59
 	}
60 60
 
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 * @return void
66 66
 	 * @throws Exception in case of invalid arguments.
67 67
 	 */
68
-	private static function assertions( Task $task, $route ) {
69
-		Assertions::is_a( $task, 'Wordlift\Task\Task' );
70
-		Assertions::starts_with( $route, '/', __( 'The route must start with a slash.', 'wordlift' ) );
68
+	private static function assertions(Task $task, $route) {
69
+		Assertions::is_a($task, 'Wordlift\Task\Task');
70
+		Assertions::starts_with($route, '/', __('The route must start with a slash.', 'wordlift'));
71 71
 	}
72 72
 
73 73
 }
Please login to merge, or discard this patch.
src/modules/food-kg/load.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,104 +18,104 @@
 block discarded – undo
18 18
 use Wordlift\Task\Background\Background_Task_Factory;
19 19
 use Wordlift\Task\Single_Call_Task;
20 20
 
21
-if ( ! defined( 'ABSPATH' ) ) {
21
+if ( ! defined('ABSPATH')) {
22 22
 	exit;
23 23
 }
24 24
 
25
-define( 'WL_FOOD_KG_FILE', __FILE__ );
26
-define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) );
25
+define('WL_FOOD_KG_FILE', __FILE__);
26
+define('WL_FOOD_KG_DIR_PATH', dirname(WL_FOOD_KG_FILE));
27 27
 
28 28
 function __wl_foodkg__load() {
29 29
 
30 30
 	// Autoloader for plugin itself.
31
-	if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
32
-		require __DIR__ . '/vendor/autoload.php';
31
+	if (file_exists(__DIR__.'/vendor/autoload.php')) {
32
+		require __DIR__.'/vendor/autoload.php';
33 33
 	}
34 34
 
35 35
 	$container_builder = new ContainerBuilder();
36
-	$loader            = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) );
37
-	$loader->load( 'services.yml' );
36
+	$loader            = new YamlFileLoader($container_builder, new FileLocator(__DIR__));
37
+	$loader->load('services.yml');
38 38
 	$container_builder->compile();
39 39
 
40
-	$notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' );
40
+	$notices = $container_builder->get('Wordlift\Modules\Food_Kg\Notices');
41 41
 	$notices->register_hooks();
42 42
 
43 43
 	/**
44 44
 	 * @var Preconditions $preconditions
45 45
 	 */
46
-	$preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' );
47
-	if ( ! $preconditions->pass() ) {
46
+	$preconditions = $container_builder->get('Wordlift\Modules\Food_Kg\Preconditions');
47
+	if ( ! $preconditions->pass()) {
48 48
 		return;
49 49
 	}
50 50
 
51 51
 	// Meta Box.
52
-	$meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' );
52
+	$meta_box = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Meta_Box');
53 53
 	$meta_box->register_hooks();
54 54
 
55
-	$module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' );
55
+	$module = $container_builder->get('Wordlift\Modules\Food_Kg\Module');
56 56
 	$module->register_hooks();
57 57
 
58 58
 	/** @var Jsonld $jsonld */
59
-	$jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' );
59
+	$jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Jsonld');
60 60
 	$jsonld->register_hooks();
61 61
 
62 62
 	/**
63 63
 	 * Ingredients API.
64 64
 	 */
65
-	$ingredients_api = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_API' );
65
+	$ingredients_api = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_API');
66 66
 	$ingredients_api->register_hooks();
67 67
 
68 68
 	/** @var Main_Ingredient_Jsonld $jsonld */
69
-	$main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' );
69
+	$main_ingredient_jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld');
70 70
 	$main_ingredient_jsonld->register_hooks();
71 71
 
72 72
 	// Main Ingredient 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
 	$main_ingredient_background_task = Background_Task_Factory::create_action_scheduler_task(
75 75
 		'wl_main_ingredient_sync',
76 76
 		'wordlift',
77 77
 		new All_Posts_Task(
78
-			array( $main_ingredient_recipe_lift, 'process' ),
78
+			array($main_ingredient_recipe_lift, 'process'),
79 79
 			'wprm_recipe',
80 80
 			'sync-main-ingredient'
81 81
 		),
82 82
 		'/main-ingredient',
83 83
 		'sync-main-ingredient',
84
-		__( 'Synchronize Main Ingredient', 'wordlift' )
84
+		__('Synchronize Main Ingredient', 'wordlift')
85 85
 	);
86 86
 
87 87
 	// Ingredients Taxonomy Background Task.
88
-	$ingredients_taxonomy_recipe_lift     = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy' );
88
+	$ingredients_taxonomy_recipe_lift     = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy');
89 89
 	$ingredients_taxonomy_background_task = Background_Task_Factory::create(
90 90
 		new Single_Call_Task(
91
-			array( $ingredients_taxonomy_recipe_lift, 'run' ),
91
+			array($ingredients_taxonomy_recipe_lift, 'run'),
92 92
 			'sync-ingredients-taxonomy'
93 93
 		),
94 94
 		'/sync-ingredients-taxonomy',
95 95
 		'sync-ingredients-taxonomy',
96
-		__( 'Synchronize Ingredients Taxonomy', 'wordlift' )
96
+		__('Synchronize Ingredients Taxonomy', 'wordlift')
97 97
 	);
98 98
 
99 99
 	add_action(
100 100
 		$module::RUN_EVENT,
101
-		function () use ( $main_ingredient_background_task, $ingredients_taxonomy_background_task ) {
101
+		function() use ($main_ingredient_background_task, $ingredients_taxonomy_background_task) {
102 102
 			$main_ingredient_background_task->start();
103 103
 			$ingredients_taxonomy_background_task->start();
104 104
 		}
105 105
 	);
106 106
 
107
-	if ( is_admin() ) {
108
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' );
107
+	if (is_admin()) {
108
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Page');
109 109
 		$page->register_hooks();
110 110
 
111
-		$page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page' );
111
+		$page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page');
112 112
 		$page->register_hooks();
113 113
 
114 114
 		// Download Ingredients Data.
115
-		$download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' );
115
+		$download_ingredients_data = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data');
116 116
 		$download_ingredients_data->register_hooks();
117 117
 	}
118 118
 }
119 119
 
120
-add_action( 'plugins_loaded', '__wl_foodkg__load' );
120
+add_action('plugins_loaded', '__wl_foodkg__load');
121 121
 
Please login to merge, or discard this patch.
src/modules/food-kg/includes/Module.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,39 +22,39 @@
 block discarded – undo
22 22
 	 * @param Api_Service_Ext        $api_service
23 23
 	 * @param Recipe_Lift_Strategy[] $recipe_lift_strategies
24 24
 	 */
25
-	public function __construct( Api_Service_Ext $api_service, array $recipe_lift_strategies ) {
25
+	public function __construct(Api_Service_Ext $api_service, array $recipe_lift_strategies) {
26 26
 		$this->api_service            = $api_service;
27 27
 		$this->recipe_lift_strategies = $recipe_lift_strategies;
28 28
 	}
29 29
 
30 30
 	public function register_hooks() {
31
-		add_action( 'wl_key_updated', array( $this, '__key_updated' ) );
32
-		add_action( 'wp_ajax_wl_food_kg__run', array( $this, '__run' ) );
31
+		add_action('wl_key_updated', array($this, '__key_updated'));
32
+		add_action('wp_ajax_wl_food_kg__run', array($this, '__run'));
33 33
 	}
34 34
 
35 35
 	public function __key_updated() {
36 36
 		try {
37 37
 			$me_response    = $this->api_service->me();
38
-			$has_food_kg    = isset( $me_response->networks )
39
-							  && array_reduce( $me_response->networks, array( $this, '__has_food_kg' ), false );
40
-			$next_scheduled = wp_next_scheduled( self::RUN_EVENT );
38
+			$has_food_kg    = isset($me_response->networks)
39
+							  && array_reduce($me_response->networks, array($this, '__has_food_kg'), false);
40
+			$next_scheduled = wp_next_scheduled(self::RUN_EVENT);
41 41
 
42 42
 			// We're connected to the Food KG, but not yet scheduled.
43
-			if ( $has_food_kg && ! $next_scheduled ) {
44
-				wp_schedule_event( time(), 'daily', self::RUN_EVENT );
43
+			if ($has_food_kg && ! $next_scheduled) {
44
+				wp_schedule_event(time(), 'daily', self::RUN_EVENT);
45 45
 			}
46 46
 
47 47
 			// We're not connected to the Food KG, but we're scheduled.
48
-			if ( ! $has_food_kg && $next_scheduled ) {
49
-				wp_unschedule_event( $next_scheduled, self::RUN_EVENT );
48
+			if ( ! $has_food_kg && $next_scheduled) {
49
+				wp_unschedule_event($next_scheduled, self::RUN_EVENT);
50 50
 			}
51 51
 			// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
52
-		} catch ( \Exception $e ) {
52
+		} catch (\Exception $e) {
53 53
 			// Do nothing.
54 54
 		}
55 55
 	}
56 56
 
57
-	private function __has_food_kg( $carry, $item ) {
57
+	private function __has_food_kg($carry, $item) {
58 58
 		return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri;
59 59
 	}
60 60
 
Please login to merge, or discard this patch.