@@ -7,6 +7,6 @@ |
||
| 7 | 7 | exit(1); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 11 | 11 | |
| 12 | 12 | return ComposerAutoloaderInitbaaf547b24d2757395578581da934187::getLoader(); |
@@ -4,41 +4,41 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Single_Call_Task implements Task { |
| 6 | 6 | |
| 7 | - private $callable; |
|
| 8 | - |
|
| 9 | - /** |
|
| 10 | - * @var string|null |
|
| 11 | - */ |
|
| 12 | - private $id; |
|
| 13 | - |
|
| 14 | - public function __construct( $callable, $id = null ) { |
|
| 15 | - $this->callable = $callable; |
|
| 16 | - $this->id = $id; |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - public function get_id() { |
|
| 20 | - return isset( $this->id ) ? $this->id : sha1( get_class( $this ) ); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function starting() { |
|
| 24 | - return 1; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param $value mixed The incoming value. |
|
| 29 | - * @param $args { |
|
| 30 | - * |
|
| 31 | - * @type int $offset The index of the current item. |
|
| 32 | - * @type int $count The total number of items as provided by the `starting` function. |
|
| 33 | - * @type int $batch_size The number of items to process within this call. |
|
| 34 | - * } |
|
| 35 | - * |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public function tick( $value, $args ) { |
|
| 39 | - |
|
| 40 | - call_user_func( $this->callable, 1 ); |
|
| 41 | - |
|
| 42 | - } |
|
| 7 | + private $callable; |
|
| 8 | + |
|
| 9 | + /** |
|
| 10 | + * @var string|null |
|
| 11 | + */ |
|
| 12 | + private $id; |
|
| 13 | + |
|
| 14 | + public function __construct( $callable, $id = null ) { |
|
| 15 | + $this->callable = $callable; |
|
| 16 | + $this->id = $id; |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + public function get_id() { |
|
| 20 | + return isset( $this->id ) ? $this->id : sha1( get_class( $this ) ); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function starting() { |
|
| 24 | + return 1; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param $value mixed The incoming value. |
|
| 29 | + * @param $args { |
|
| 30 | + * |
|
| 31 | + * @type int $offset The index of the current item. |
|
| 32 | + * @type int $count The total number of items as provided by the `starting` function. |
|
| 33 | + * @type int $batch_size The number of items to process within this call. |
|
| 34 | + * } |
|
| 35 | + * |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public function tick( $value, $args ) { |
|
| 39 | + |
|
| 40 | + call_user_func( $this->callable, 1 ); |
|
| 41 | + |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | } |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | private $id; |
| 13 | 13 | |
| 14 | - public function __construct( $callable, $id = null ) { |
|
| 14 | + public function __construct($callable, $id = null) { |
|
| 15 | 15 | $this->callable = $callable; |
| 16 | 16 | $this->id = $id; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function get_id() { |
| 20 | - return isset( $this->id ) ? $this->id : sha1( get_class( $this ) ); |
|
| 20 | + return isset($this->id) ? $this->id : sha1(get_class($this)); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function starting() { |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | - public function tick( $value, $args ) { |
|
| 38 | + public function tick($value, $args) { |
|
| 39 | 39 | |
| 40 | - call_user_func( $this->callable, 1 ); |
|
| 40 | + call_user_func($this->callable, 1); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -14,24 +14,24 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Background_Task_Factory { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Create a {@link Background_Task} given the provided task and route. |
|
| 19 | - * |
|
| 20 | - * @param Task $task The target task. |
|
| 21 | - * @param string $route The route name. |
|
| 22 | - * @param string $page_id The page id. |
|
| 23 | - * @param string $page_title The page title. |
|
| 24 | - * |
|
| 25 | - * @return void |
|
| 26 | - * @throws Exception in case of invalid arguments. |
|
| 27 | - */ |
|
| 28 | - public static function create( $task, $route, $page_id, $page_title ) { |
|
| 29 | - Assertions::is_a( $task, 'Wordlift\Task\Task' ); |
|
| 30 | - Assertions::starts_with( $route, '/', __( 'The route must start with a slash.', 'wordlift' ) ); |
|
| 17 | + /** |
|
| 18 | + * Create a {@link Background_Task} given the provided task and route. |
|
| 19 | + * |
|
| 20 | + * @param Task $task The target task. |
|
| 21 | + * @param string $route The route name. |
|
| 22 | + * @param string $page_id The page id. |
|
| 23 | + * @param string $page_title The page title. |
|
| 24 | + * |
|
| 25 | + * @return void |
|
| 26 | + * @throws Exception in case of invalid arguments. |
|
| 27 | + */ |
|
| 28 | + public static function create( $task, $route, $page_id, $page_title ) { |
|
| 29 | + Assertions::is_a( $task, 'Wordlift\Task\Task' ); |
|
| 30 | + Assertions::starts_with( $route, '/', __( 'The route must start with a slash.', 'wordlift' ) ); |
|
| 31 | 31 | |
| 32 | - $background_task = Background_Task::create( $task ); |
|
| 33 | - $background_task_route = Background_Task_Route::create( $background_task, $route ); |
|
| 34 | - Background_Task_Page::create( $page_title, $page_id, $background_task_route ); |
|
| 35 | - } |
|
| 32 | + $background_task = Background_Task::create( $task ); |
|
| 33 | + $background_task_route = Background_Task_Route::create( $background_task, $route ); |
|
| 34 | + Background_Task_Page::create( $page_title, $page_id, $background_task_route ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -25,13 +25,13 @@ |
||
| 25 | 25 | * @return void |
| 26 | 26 | * @throws Exception in case of invalid arguments. |
| 27 | 27 | */ |
| 28 | - public static function create( $task, $route, $page_id, $page_title ) { |
|
| 29 | - Assertions::is_a( $task, 'Wordlift\Task\Task' ); |
|
| 30 | - Assertions::starts_with( $route, '/', __( 'The route must start with a slash.', 'wordlift' ) ); |
|
| 28 | + public static function create($task, $route, $page_id, $page_title) { |
|
| 29 | + Assertions::is_a($task, 'Wordlift\Task\Task'); |
|
| 30 | + Assertions::starts_with($route, '/', __('The route must start with a slash.', 'wordlift')); |
|
| 31 | 31 | |
| 32 | - $background_task = Background_Task::create( $task ); |
|
| 33 | - $background_task_route = Background_Task_Route::create( $background_task, $route ); |
|
| 34 | - Background_Task_Page::create( $page_title, $page_id, $background_task_route ); |
|
| 32 | + $background_task = Background_Task::create($task); |
|
| 33 | + $background_task_route = Background_Task_Route::create($background_task, $route); |
|
| 34 | + Background_Task_Page::create($page_title, $page_id, $background_task_route); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -19,97 +19,97 @@ |
||
| 19 | 19 | use Wordlift\Task\Single_Call_Task; |
| 20 | 20 | |
| 21 | 21 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | - exit; |
|
| 22 | + exit; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | define( 'WL_FOOD_KG_FILE', __FILE__ ); |
| 26 | 26 | define( 'WL_FOOD_KG_DIR_PATH', dirname( WL_FOOD_KG_FILE ) ); |
| 27 | 27 | |
| 28 | 28 | function __wl_foodkg__load() { |
| 29 | - // Autoloader for dependencies. |
|
| 30 | - if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) { |
|
| 31 | - require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php'; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - // Autoloader for plugin itself. |
|
| 35 | - if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) { |
|
| 36 | - require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php'; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - $container_builder = new ContainerBuilder(); |
|
| 40 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | - $loader->load( 'services.yml' ); |
|
| 42 | - $container_builder->compile(); |
|
| 43 | - |
|
| 44 | - $notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' ); |
|
| 45 | - $notices->register_hooks(); |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var Preconditions $preconditions |
|
| 49 | - */ |
|
| 50 | - $preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' ); |
|
| 51 | - if ( ! $preconditions->pass() ) { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // Meta Box. |
|
| 56 | - $meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' ); |
|
| 57 | - $meta_box->register_hooks(); |
|
| 58 | - |
|
| 59 | - $module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' ); |
|
| 60 | - $module->register_hooks(); |
|
| 61 | - |
|
| 62 | - /** @var Jsonld $jsonld */ |
|
| 63 | - $jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' ); |
|
| 64 | - $jsonld->register_hooks(); |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Ingredients API. |
|
| 68 | - */ |
|
| 69 | - $ingredients_api = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_API' ); |
|
| 70 | - $ingredients_api->register_hooks(); |
|
| 71 | - |
|
| 72 | - /** @var Main_Ingredient_Jsonld $jsonld */ |
|
| 73 | - $main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' ); |
|
| 74 | - $main_ingredient_jsonld->register_hooks(); |
|
| 75 | - |
|
| 76 | - // Main Ingredient Background Task. |
|
| 77 | - $main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' ); |
|
| 78 | - Background_Task_Factory::create( |
|
| 79 | - new All_Posts_Task( |
|
| 80 | - array( $main_ingredient_recipe_lift, 'process', ), |
|
| 81 | - 'wprm_recipe', |
|
| 82 | - 'sync-main-ingredient' |
|
| 83 | - ), |
|
| 84 | - '/main-ingredient', |
|
| 85 | - 'sync-main-ingredient', |
|
| 86 | - __( 'Synchronize Main Ingredient', 'wordlift' ) |
|
| 87 | - ); |
|
| 88 | - |
|
| 89 | - // Ingredients Taxonomy Background Task. |
|
| 90 | - $ingredients_taxonomy_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy' ); |
|
| 91 | - Background_Task_Factory::create( |
|
| 92 | - new Single_Call_Task( |
|
| 93 | - array( $ingredients_taxonomy_recipe_lift, 'run', ), |
|
| 94 | - 'sync-ingredients-taxonomy' |
|
| 95 | - ), |
|
| 96 | - '/sync-ingredients-taxonomy', |
|
| 97 | - 'sync-ingredients-taxonomy', |
|
| 98 | - __( 'Synchronize Ingredients Taxonomy', 'wordlift' ) |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - if ( is_admin() ) { |
|
| 103 | - $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' ); |
|
| 104 | - $page->register_hooks(); |
|
| 105 | - |
|
| 106 | - $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page' ); |
|
| 107 | - $page->register_hooks(); |
|
| 108 | - |
|
| 109 | - // Download Ingredients Data. |
|
| 110 | - $download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' ); |
|
| 111 | - $download_ingredients_data->register_hooks(); |
|
| 112 | - } |
|
| 29 | + // Autoloader for dependencies. |
|
| 30 | + if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) { |
|
| 31 | + require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php'; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + // Autoloader for plugin itself. |
|
| 35 | + if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) { |
|
| 36 | + require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php'; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + $container_builder = new ContainerBuilder(); |
|
| 40 | + $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | + $loader->load( 'services.yml' ); |
|
| 42 | + $container_builder->compile(); |
|
| 43 | + |
|
| 44 | + $notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' ); |
|
| 45 | + $notices->register_hooks(); |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var Preconditions $preconditions |
|
| 49 | + */ |
|
| 50 | + $preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' ); |
|
| 51 | + if ( ! $preconditions->pass() ) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // Meta Box. |
|
| 56 | + $meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' ); |
|
| 57 | + $meta_box->register_hooks(); |
|
| 58 | + |
|
| 59 | + $module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' ); |
|
| 60 | + $module->register_hooks(); |
|
| 61 | + |
|
| 62 | + /** @var Jsonld $jsonld */ |
|
| 63 | + $jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' ); |
|
| 64 | + $jsonld->register_hooks(); |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Ingredients API. |
|
| 68 | + */ |
|
| 69 | + $ingredients_api = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_API' ); |
|
| 70 | + $ingredients_api->register_hooks(); |
|
| 71 | + |
|
| 72 | + /** @var Main_Ingredient_Jsonld $jsonld */ |
|
| 73 | + $main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' ); |
|
| 74 | + $main_ingredient_jsonld->register_hooks(); |
|
| 75 | + |
|
| 76 | + // Main Ingredient Background Task. |
|
| 77 | + $main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' ); |
|
| 78 | + Background_Task_Factory::create( |
|
| 79 | + new All_Posts_Task( |
|
| 80 | + array( $main_ingredient_recipe_lift, 'process', ), |
|
| 81 | + 'wprm_recipe', |
|
| 82 | + 'sync-main-ingredient' |
|
| 83 | + ), |
|
| 84 | + '/main-ingredient', |
|
| 85 | + 'sync-main-ingredient', |
|
| 86 | + __( 'Synchronize Main Ingredient', 'wordlift' ) |
|
| 87 | + ); |
|
| 88 | + |
|
| 89 | + // Ingredients Taxonomy Background Task. |
|
| 90 | + $ingredients_taxonomy_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy' ); |
|
| 91 | + Background_Task_Factory::create( |
|
| 92 | + new Single_Call_Task( |
|
| 93 | + array( $ingredients_taxonomy_recipe_lift, 'run', ), |
|
| 94 | + 'sync-ingredients-taxonomy' |
|
| 95 | + ), |
|
| 96 | + '/sync-ingredients-taxonomy', |
|
| 97 | + 'sync-ingredients-taxonomy', |
|
| 98 | + __( 'Synchronize Ingredients Taxonomy', 'wordlift' ) |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + if ( is_admin() ) { |
|
| 103 | + $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' ); |
|
| 104 | + $page->register_hooks(); |
|
| 105 | + |
|
| 106 | + $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page' ); |
|
| 107 | + $page->register_hooks(); |
|
| 108 | + |
|
| 109 | + // Download Ingredients Data. |
|
| 110 | + $download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' ); |
|
| 111 | + $download_ingredients_data->register_hooks(); |
|
| 112 | + } |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | add_action( 'plugins_loaded', '__wl_foodkg__load' ); |
@@ -18,99 +18,99 @@ |
||
| 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 | // Autoloader for dependencies. |
| 30 | - if ( file_exists( WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php' ) ) { |
|
| 31 | - require WL_FOOD_KG_DIR_PATH . '/third-party/vendor/scoper-autoload.php'; |
|
| 30 | + if (file_exists(WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php')) { |
|
| 31 | + require WL_FOOD_KG_DIR_PATH.'/third-party/vendor/scoper-autoload.php'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // Autoloader for plugin itself. |
| 35 | - if ( file_exists( WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php' ) ) { |
|
| 36 | - require WL_FOOD_KG_DIR_PATH . '/includes/vendor/autoload.php'; |
|
| 35 | + if (file_exists(WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php')) { |
|
| 36 | + require WL_FOOD_KG_DIR_PATH.'/includes/vendor/autoload.php'; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $container_builder = new ContainerBuilder(); |
| 40 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | - $loader->load( 'services.yml' ); |
|
| 40 | + $loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
| 41 | + $loader->load('services.yml'); |
|
| 42 | 42 | $container_builder->compile(); |
| 43 | 43 | |
| 44 | - $notices = $container_builder->get( 'Wordlift\Modules\Food_Kg\Notices' ); |
|
| 44 | + $notices = $container_builder->get('Wordlift\Modules\Food_Kg\Notices'); |
|
| 45 | 45 | $notices->register_hooks(); |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @var Preconditions $preconditions |
| 49 | 49 | */ |
| 50 | - $preconditions = $container_builder->get( 'Wordlift\Modules\Food_Kg\Preconditions' ); |
|
| 51 | - if ( ! $preconditions->pass() ) { |
|
| 50 | + $preconditions = $container_builder->get('Wordlift\Modules\Food_Kg\Preconditions'); |
|
| 51 | + if ( ! $preconditions->pass()) { |
|
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Meta Box. |
| 56 | - $meta_box = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Meta_Box' ); |
|
| 56 | + $meta_box = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Meta_Box'); |
|
| 57 | 57 | $meta_box->register_hooks(); |
| 58 | 58 | |
| 59 | - $module = $container_builder->get( 'Wordlift\Modules\Food_Kg\Module' ); |
|
| 59 | + $module = $container_builder->get('Wordlift\Modules\Food_Kg\Module'); |
|
| 60 | 60 | $module->register_hooks(); |
| 61 | 61 | |
| 62 | 62 | /** @var Jsonld $jsonld */ |
| 63 | - $jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Jsonld' ); |
|
| 63 | + $jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Jsonld'); |
|
| 64 | 64 | $jsonld->register_hooks(); |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Ingredients API. |
| 68 | 68 | */ |
| 69 | - $ingredients_api = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_API' ); |
|
| 69 | + $ingredients_api = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_API'); |
|
| 70 | 70 | $ingredients_api->register_hooks(); |
| 71 | 71 | |
| 72 | 72 | /** @var Main_Ingredient_Jsonld $jsonld */ |
| 73 | - $main_ingredient_jsonld = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld' ); |
|
| 73 | + $main_ingredient_jsonld = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Jsonld'); |
|
| 74 | 74 | $main_ingredient_jsonld->register_hooks(); |
| 75 | 75 | |
| 76 | 76 | // Main Ingredient Background Task. |
| 77 | - $main_ingredient_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy' ); |
|
| 77 | + $main_ingredient_recipe_lift = $container_builder->get('Wordlift\Modules\Food_Kg\Main_Ingredient_Recipe_Lift_Strategy'); |
|
| 78 | 78 | Background_Task_Factory::create( |
| 79 | 79 | new All_Posts_Task( |
| 80 | - array( $main_ingredient_recipe_lift, 'process', ), |
|
| 80 | + array($main_ingredient_recipe_lift, 'process',), |
|
| 81 | 81 | 'wprm_recipe', |
| 82 | 82 | 'sync-main-ingredient' |
| 83 | 83 | ), |
| 84 | 84 | '/main-ingredient', |
| 85 | 85 | 'sync-main-ingredient', |
| 86 | - __( 'Synchronize Main Ingredient', 'wordlift' ) |
|
| 86 | + __('Synchronize Main Ingredient', 'wordlift') |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | // Ingredients Taxonomy Background Task. |
| 90 | - $ingredients_taxonomy_recipe_lift = $container_builder->get( 'Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy' ); |
|
| 90 | + $ingredients_taxonomy_recipe_lift = $container_builder->get('Wordlift\Modules\Food_Kg\Ingredients_Taxonomy_Recipe_Lift_Strategy'); |
|
| 91 | 91 | Background_Task_Factory::create( |
| 92 | 92 | new Single_Call_Task( |
| 93 | - array( $ingredients_taxonomy_recipe_lift, 'run', ), |
|
| 93 | + array($ingredients_taxonomy_recipe_lift, 'run',), |
|
| 94 | 94 | 'sync-ingredients-taxonomy' |
| 95 | 95 | ), |
| 96 | 96 | '/sync-ingredients-taxonomy', |
| 97 | 97 | 'sync-ingredients-taxonomy', |
| 98 | - __( 'Synchronize Ingredients Taxonomy', 'wordlift' ) |
|
| 98 | + __('Synchronize Ingredients Taxonomy', 'wordlift') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - if ( is_admin() ) { |
|
| 103 | - $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Page' ); |
|
| 102 | + if (is_admin()) { |
|
| 103 | + $page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Page'); |
|
| 104 | 104 | $page->register_hooks(); |
| 105 | 105 | |
| 106 | - $page = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page' ); |
|
| 106 | + $page = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Ingredients_Taxonomy_Page'); |
|
| 107 | 107 | $page->register_hooks(); |
| 108 | 108 | |
| 109 | 109 | // Download Ingredients Data. |
| 110 | - $download_ingredients_data = $container_builder->get( 'Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data' ); |
|
| 110 | + $download_ingredients_data = $container_builder->get('Wordlift\Modules\Food_Kg\Admin\Download_Ingredients_Data'); |
|
| 111 | 111 | $download_ingredients_data->register_hooks(); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | -add_action( 'plugins_loaded', '__wl_foodkg__load' ); |
|
| 115 | +add_action('plugins_loaded', '__wl_foodkg__load'); |
|
| 116 | 116 | |
@@ -4,58 +4,58 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Ingredients_Taxonomy_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 run() { |
|
| 23 | - $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var string[] $terms |
|
| 27 | - */ |
|
| 28 | - $terms = get_terms( |
|
| 29 | - array( |
|
| 30 | - 'taxonomy' => 'wprm_ingredient', |
|
| 31 | - 'fields' => 'names', |
|
| 32 | - 'hide_empty' => false, |
|
| 33 | - ) |
|
| 34 | - ); |
|
| 35 | - $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
| 36 | - |
|
| 37 | - foreach ( $ingredients as $key => $value ) { |
|
| 38 | - $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
| 39 | - if ( ! isset( $term ) ) { |
|
| 40 | - continue; |
|
| 41 | - } |
|
| 42 | - update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @@todo update notification with progress |
|
| 46 | - */ |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - // Clean up caches. |
|
| 50 | - do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @@todo add notification that procedure is complete, with information about the number of processed items vs |
|
| 54 | - * total items |
|
| 55 | - */ |
|
| 56 | - $count_terms = count( $terms ); |
|
| 57 | - $count_lifted_terms = count( $ingredients ); |
|
| 58 | - /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
|
| 59 | - $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
| 60 | - } |
|
| 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 run() { |
|
| 23 | + $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var string[] $terms |
|
| 27 | + */ |
|
| 28 | + $terms = get_terms( |
|
| 29 | + array( |
|
| 30 | + 'taxonomy' => 'wprm_ingredient', |
|
| 31 | + 'fields' => 'names', |
|
| 32 | + 'hide_empty' => false, |
|
| 33 | + ) |
|
| 34 | + ); |
|
| 35 | + $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
| 36 | + |
|
| 37 | + foreach ( $ingredients as $key => $value ) { |
|
| 38 | + $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
| 39 | + if ( ! isset( $term ) ) { |
|
| 40 | + continue; |
|
| 41 | + } |
|
| 42 | + update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @@todo update notification with progress |
|
| 46 | + */ |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + // Clean up caches. |
|
| 50 | + do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @@todo add notification that procedure is complete, with information about the number of processed items vs |
|
| 54 | + * total items |
|
| 55 | + */ |
|
| 56 | + $count_terms = count( $terms ); |
|
| 57 | + $count_lifted_terms = count( $ingredients ); |
|
| 58 | + /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
|
| 59 | + $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -14,32 +14,32 @@ discard block |
||
| 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 | 22 | public function run() { |
| 23 | - $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
| 23 | + $this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift')); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @var string[] $terms |
| 27 | 27 | */ |
| 28 | - $terms = get_terms( |
|
| 28 | + $terms = get_terms( |
|
| 29 | 29 | array( |
| 30 | 30 | 'taxonomy' => 'wprm_ingredient', |
| 31 | 31 | 'fields' => 'names', |
| 32 | 32 | 'hide_empty' => false, |
| 33 | 33 | ) |
| 34 | 34 | ); |
| 35 | - $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
| 35 | + $ingredients = $this->ingredients_client->ingredients($terms); |
|
| 36 | 36 | |
| 37 | - foreach ( $ingredients as $key => $value ) { |
|
| 38 | - $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
| 39 | - if ( ! isset( $term ) ) { |
|
| 37 | + foreach ($ingredients as $key => $value) { |
|
| 38 | + $term = get_term_by('name', $key, 'wprm_ingredient'); |
|
| 39 | + if ( ! isset($term)) { |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | - update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
| 42 | + update_term_meta($term->term_id, '_wl_jsonld', wp_slash($value)); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @@todo update notification with progress |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Clean up caches. |
| 50 | - do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
| 50 | + do_action('wl_ttl_cache_cleaner__flush'); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @@todo add notification that procedure is complete, with information about the number of processed items vs |
| 54 | 54 | * total items |
| 55 | 55 | */ |
| 56 | - $count_terms = count( $terms ); |
|
| 57 | - $count_lifted_terms = count( $ingredients ); |
|
| 56 | + $count_terms = count($terms); |
|
| 57 | + $count_lifted_terms = count($ingredients); |
|
| 58 | 58 | /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
| 59 | - $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
| 59 | + $this->notices->queue('info', sprintf(__('WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift'), $count_lifted_terms, $count_terms)); |
|
| 60 | 60 | } |
| 61 | 61 | } |
@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Ingredients_Full_Page_Delegate implements Page_Delegate { |
| 6 | 6 | |
| 7 | - public function render() { |
|
| 8 | - include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/ingredients.php'; |
|
| 9 | - } |
|
| 7 | + public function render() { |
|
| 8 | + include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/ingredients.php'; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function admin_enqueue_scripts() { |
|
| 12 | - } |
|
| 11 | + public function admin_enqueue_scripts() { |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | 14 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | class Ingredients_Full_Page_Delegate implements Page_Delegate { |
| 6 | 6 | |
| 7 | 7 | public function render() { |
| 8 | - include WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/ingredients.php'; |
|
| 8 | + include WL_FOOD_KG_DIR_PATH.'/includes/admin/partials/ingredients.php'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public function admin_enqueue_scripts() { |
@@ -3,38 +3,38 @@ discard block |
||
| 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 Ingredients_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 | - $this->items = $wpdb->get_results( |
|
| 36 | - $wpdb->prepare( |
|
| 37 | - "SELECT t.term_id, t.name, tm.meta_value |
|
| 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 | + $this->items = $wpdb->get_results( |
|
| 36 | + $wpdb->prepare( |
|
| 37 | + "SELECT t.term_id, t.name, tm.meta_value |
|
| 38 | 38 | FROM $wpdb->term_taxonomy tt |
| 39 | 39 | INNER JOIN $wpdb->terms t |
| 40 | 40 | ON t.term_id = tt.term_id |
@@ -42,44 +42,44 @@ discard block |
||
| 42 | 42 | ON tm.term_id = t.term_id |
| 43 | 43 | AND tm.meta_key = '_wl_jsonld' |
| 44 | 44 | WHERE tt.taxonomy = %s;", |
| 45 | - 'wprm_ingredient' |
|
| 46 | - ) |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function no_items() { |
|
| 51 | - esc_html_e( 'No ingredients found.', 'wordlift' ); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function get_columns() { |
|
| 55 | - return array( |
|
| 56 | - 'id' => __( 'ID', 'wordlift' ), |
|
| 57 | - 'name' => __( 'Name', 'wordlift' ), |
|
| 58 | - 'actions' => '', |
|
| 59 | - ); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - public function column_id( $item ) { |
|
| 63 | - return $item->term_id; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function column_name( $item ) { |
|
| 67 | - return $item->name; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - public function column_actions( $item ) { |
|
| 71 | - |
|
| 72 | - $url = admin_url( |
|
| 73 | - sprintf( 'admin.php?page=wl_ingredients&modal_window=true&term_id=%d&TB_iframe=true', $item->term_id ) |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - return sprintf( |
|
| 77 | - '<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>', |
|
| 78 | - $url, |
|
| 79 | - esc_attr( $item->name ), |
|
| 80 | - esc_html__( 'JSON-LD', 'wordlift' ) |
|
| 81 | - ); |
|
| 82 | - } |
|
| 45 | + 'wprm_ingredient' |
|
| 46 | + ) |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function no_items() { |
|
| 51 | + esc_html_e( 'No ingredients found.', 'wordlift' ); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function get_columns() { |
|
| 55 | + return array( |
|
| 56 | + 'id' => __( 'ID', 'wordlift' ), |
|
| 57 | + 'name' => __( 'Name', 'wordlift' ), |
|
| 58 | + 'actions' => '', |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + public function column_id( $item ) { |
|
| 63 | + return $item->term_id; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function column_name( $item ) { |
|
| 67 | + return $item->name; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + public function column_actions( $item ) { |
|
| 71 | + |
|
| 72 | + $url = admin_url( |
|
| 73 | + sprintf( 'admin.php?page=wl_ingredients&modal_window=true&term_id=%d&TB_iframe=true', $item->term_id ) |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + return sprintf( |
|
| 77 | + '<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>', |
|
| 78 | + $url, |
|
| 79 | + esc_attr( $item->name ), |
|
| 80 | + esc_html__( 'JSON-LD', 'wordlift' ) |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
@@ -2,8 +2,8 @@ discard block |
||
| 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 |
||
| 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 | $this->items = $wpdb->get_results( |
| 36 | 36 | $wpdb->prepare( |
@@ -48,36 +48,36 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function no_items() { |
| 51 | - esc_html_e( 'No ingredients found.', 'wordlift' ); |
|
| 51 | + esc_html_e('No ingredients found.', 'wordlift'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function get_columns() { |
| 55 | 55 | return array( |
| 56 | - 'id' => __( 'ID', 'wordlift' ), |
|
| 57 | - 'name' => __( 'Name', 'wordlift' ), |
|
| 56 | + 'id' => __('ID', 'wordlift'), |
|
| 57 | + 'name' => __('Name', 'wordlift'), |
|
| 58 | 58 | 'actions' => '', |
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function column_id( $item ) { |
|
| 62 | + public function column_id($item) { |
|
| 63 | 63 | return $item->term_id; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function column_name( $item ) { |
|
| 66 | + public function column_name($item) { |
|
| 67 | 67 | return $item->name; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function column_actions( $item ) { |
|
| 70 | + public function column_actions($item) { |
|
| 71 | 71 | |
| 72 | 72 | $url = admin_url( |
| 73 | - sprintf( 'admin.php?page=wl_ingredients&modal_window=true&term_id=%d&TB_iframe=true', $item->term_id ) |
|
| 73 | + sprintf('admin.php?page=wl_ingredients&modal_window=true&term_id=%d&TB_iframe=true', $item->term_id) |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | return sprintf( |
| 77 | 77 | '<a href="%s" class="button alignright thickbox open-plugin-details-modal" data-title="%s" type="button">%s</a>', |
| 78 | 78 | $url, |
| 79 | - esc_attr( $item->name ), |
|
| 80 | - esc_html__( 'JSON-LD', 'wordlift' ) |
|
| 79 | + esc_attr($item->name), |
|
| 80 | + esc_html__('JSON-LD', 'wordlift') |
|
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -4,61 +4,61 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Page { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var Page_Delegate |
|
| 9 | - */ |
|
| 10 | - private $delegate; |
|
| 11 | - private $menu_slug; |
|
| 12 | - private $page_title; |
|
| 13 | - private $menu_title; |
|
| 7 | + /** |
|
| 8 | + * @var Page_Delegate |
|
| 9 | + */ |
|
| 10 | + private $delegate; |
|
| 11 | + private $menu_slug; |
|
| 12 | + private $page_title; |
|
| 13 | + private $menu_title; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param Page_Delegate $full_page_delegate |
|
| 17 | - * @param Page_Delegate $modal_page_delegate |
|
| 18 | - */ |
|
| 19 | - public function __construct( $full_page_delegate, $modal_page_delegate, $menu_slug, $page_title, $menu_title ) { |
|
| 20 | - $this->delegate = isset( $_GET['modal_window'] ) ? $modal_page_delegate : $full_page_delegate; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 21 | - $this->menu_slug = $menu_slug; |
|
| 22 | - $this->page_title = $page_title; |
|
| 23 | - $this->menu_title = $menu_title; |
|
| 24 | - } |
|
| 15 | + /** |
|
| 16 | + * @param Page_Delegate $full_page_delegate |
|
| 17 | + * @param Page_Delegate $modal_page_delegate |
|
| 18 | + */ |
|
| 19 | + public function __construct( $full_page_delegate, $modal_page_delegate, $menu_slug, $page_title, $menu_title ) { |
|
| 20 | + $this->delegate = isset( $_GET['modal_window'] ) ? $modal_page_delegate : $full_page_delegate; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 21 | + $this->menu_slug = $menu_slug; |
|
| 22 | + $this->page_title = $page_title; |
|
| 23 | + $this->menu_title = $menu_title; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function register_hooks() { |
|
| 27 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 28 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 29 | - if ( isset( $_GET['modal_window'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 30 | - add_action( 'in_admin_header', array( $this, 'remove_notices' ), 99 ); |
|
| 31 | - } |
|
| 32 | - } |
|
| 26 | + public function register_hooks() { |
|
| 27 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 28 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 29 | + if ( isset( $_GET['modal_window'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 30 | + add_action( 'in_admin_header', array( $this, 'remove_notices' ), 99 ); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Remove notices from ingredients modal. |
|
| 36 | - */ |
|
| 37 | - public function remove_notices() { |
|
| 38 | - remove_all_actions( 'admin_notices' ); |
|
| 39 | - remove_all_actions( 'all_admin_notices' ); |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * Remove notices from ingredients modal. |
|
| 36 | + */ |
|
| 37 | + public function remove_notices() { |
|
| 38 | + remove_all_actions( 'admin_notices' ); |
|
| 39 | + remove_all_actions( 'all_admin_notices' ); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function admin_menu() { |
|
| 43 | - add_submenu_page( |
|
| 44 | - 'wl_admin_menu', |
|
| 45 | - $this->page_title, |
|
| 46 | - $this->menu_title, |
|
| 47 | - 'manage_options', |
|
| 48 | - $this->menu_slug, |
|
| 49 | - array( $this, 'render' ) |
|
| 50 | - ); |
|
| 51 | - } |
|
| 42 | + public function admin_menu() { |
|
| 43 | + add_submenu_page( |
|
| 44 | + 'wl_admin_menu', |
|
| 45 | + $this->page_title, |
|
| 46 | + $this->menu_title, |
|
| 47 | + 'manage_options', |
|
| 48 | + $this->menu_slug, |
|
| 49 | + array( $this, 'render' ) |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function render() { |
|
| 54 | - $this->delegate->render(); |
|
| 55 | - } |
|
| 53 | + public function render() { |
|
| 54 | + $this->delegate->render(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function admin_enqueue_scripts() { |
|
| 58 | - // Check that we are on the right screen |
|
| 59 | - if ( get_current_screen()->id === 'wordlift_page_wl_ingredients' ) { |
|
| 60 | - $this->delegate->admin_enqueue_scripts(); |
|
| 61 | - } |
|
| 62 | - } |
|
| 57 | + public function admin_enqueue_scripts() { |
|
| 58 | + // Check that we are on the right screen |
|
| 59 | + if ( get_current_screen()->id === 'wordlift_page_wl_ingredients' ) { |
|
| 60 | + $this->delegate->admin_enqueue_scripts(); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | } |
@@ -16,18 +16,18 @@ discard block |
||
| 16 | 16 | * @param Page_Delegate $full_page_delegate |
| 17 | 17 | * @param Page_Delegate $modal_page_delegate |
| 18 | 18 | */ |
| 19 | - public function __construct( $full_page_delegate, $modal_page_delegate, $menu_slug, $page_title, $menu_title ) { |
|
| 20 | - $this->delegate = isset( $_GET['modal_window'] ) ? $modal_page_delegate : $full_page_delegate; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 19 | + public function __construct($full_page_delegate, $modal_page_delegate, $menu_slug, $page_title, $menu_title) { |
|
| 20 | + $this->delegate = isset($_GET['modal_window']) ? $modal_page_delegate : $full_page_delegate; //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 21 | 21 | $this->menu_slug = $menu_slug; |
| 22 | 22 | $this->page_title = $page_title; |
| 23 | 23 | $this->menu_title = $menu_title; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function register_hooks() { |
| 27 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 28 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 29 | - if ( isset( $_GET['modal_window'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 30 | - add_action( 'in_admin_header', array( $this, 'remove_notices' ), 99 ); |
|
| 27 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
| 28 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 29 | + if (isset($_GET['modal_window'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 30 | + add_action('in_admin_header', array($this, 'remove_notices'), 99); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * Remove notices from ingredients modal. |
| 36 | 36 | */ |
| 37 | 37 | public function remove_notices() { |
| 38 | - remove_all_actions( 'admin_notices' ); |
|
| 39 | - remove_all_actions( 'all_admin_notices' ); |
|
| 38 | + remove_all_actions('admin_notices'); |
|
| 39 | + remove_all_actions('all_admin_notices'); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function admin_menu() { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $this->menu_title, |
| 47 | 47 | 'manage_options', |
| 48 | 48 | $this->menu_slug, |
| 49 | - array( $this, 'render' ) |
|
| 49 | + array($this, 'render') |
|
| 50 | 50 | ); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | public function admin_enqueue_scripts() { |
| 58 | 58 | // Check that we are on the right screen |
| 59 | - if ( get_current_screen()->id === 'wordlift_page_wl_ingredients' ) { |
|
| 59 | + if (get_current_screen()->id === 'wordlift_page_wl_ingredients') { |
|
| 60 | 60 | $this->delegate->admin_enqueue_scripts(); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -6,63 +6,63 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Module { |
| 8 | 8 | |
| 9 | - const RUN_EVENT = 'wl_food_kg__run'; |
|
| 9 | + const RUN_EVENT = 'wl_food_kg__run'; |
|
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var Api_Service_Ext |
|
| 13 | - */ |
|
| 14 | - private $api_service; |
|
| 11 | + /** |
|
| 12 | + * @var Api_Service_Ext |
|
| 13 | + */ |
|
| 14 | + private $api_service; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var Recipe_Lift_Strategy |
|
| 18 | - */ |
|
| 19 | - private $recipe_lift_strategies; |
|
| 16 | + /** |
|
| 17 | + * @var Recipe_Lift_Strategy |
|
| 18 | + */ |
|
| 19 | + private $recipe_lift_strategies; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param Api_Service_Ext $api_service |
|
| 23 | - * @param Recipe_Lift_Strategy[] $recipe_lift_strategies |
|
| 24 | - */ |
|
| 25 | - public function __construct( Api_Service_Ext $api_service, array $recipe_lift_strategies ) { |
|
| 26 | - $this->api_service = $api_service; |
|
| 27 | - $this->recipe_lift_strategies = $recipe_lift_strategies; |
|
| 28 | - } |
|
| 21 | + /** |
|
| 22 | + * @param Api_Service_Ext $api_service |
|
| 23 | + * @param Recipe_Lift_Strategy[] $recipe_lift_strategies |
|
| 24 | + */ |
|
| 25 | + public function __construct( Api_Service_Ext $api_service, array $recipe_lift_strategies ) { |
|
| 26 | + $this->api_service = $api_service; |
|
| 27 | + $this->recipe_lift_strategies = $recipe_lift_strategies; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function register_hooks() { |
|
| 31 | - add_action( 'wl_key_updated', array( $this, '__key_updated' ) ); |
|
| 32 | - add_action( self::RUN_EVENT, array( $this, '__run' ) ); |
|
| 33 | - add_action( 'wp_ajax_wl_food_kg__run', array( $this, '__run' ) ); |
|
| 34 | - } |
|
| 30 | + public function register_hooks() { |
|
| 31 | + add_action( 'wl_key_updated', array( $this, '__key_updated' ) ); |
|
| 32 | + add_action( self::RUN_EVENT, array( $this, '__run' ) ); |
|
| 33 | + add_action( 'wp_ajax_wl_food_kg__run', array( $this, '__run' ) ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public function __key_updated() { |
|
| 37 | - try { |
|
| 38 | - $me_response = $this->api_service->me(); |
|
| 39 | - $has_food_kg = isset( $me_response->networks ) |
|
| 40 | - && array_reduce( $me_response->networks, array( $this, '__has_food_kg' ), false ); |
|
| 41 | - $next_scheduled = wp_next_scheduled( self::RUN_EVENT ); |
|
| 36 | + public function __key_updated() { |
|
| 37 | + try { |
|
| 38 | + $me_response = $this->api_service->me(); |
|
| 39 | + $has_food_kg = isset( $me_response->networks ) |
|
| 40 | + && array_reduce( $me_response->networks, array( $this, '__has_food_kg' ), false ); |
|
| 41 | + $next_scheduled = wp_next_scheduled( self::RUN_EVENT ); |
|
| 42 | 42 | |
| 43 | - // We're connected to the Food KG, but not yet scheduled. |
|
| 44 | - if ( $has_food_kg && ! $next_scheduled ) { |
|
| 45 | - wp_schedule_event( time(), 'daily', self::RUN_EVENT ); |
|
| 46 | - } |
|
| 43 | + // We're connected to the Food KG, but not yet scheduled. |
|
| 44 | + if ( $has_food_kg && ! $next_scheduled ) { |
|
| 45 | + wp_schedule_event( time(), 'daily', self::RUN_EVENT ); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // We're not connected to the Food KG, but we're scheduled. |
|
| 49 | - if ( ! $has_food_kg && $next_scheduled ) { |
|
| 50 | - wp_unschedule_event( $next_scheduled, self::RUN_EVENT ); |
|
| 51 | - } |
|
| 52 | - // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch |
|
| 53 | - } catch ( \Exception $e ) { |
|
| 54 | - // Do nothing. |
|
| 55 | - } |
|
| 56 | - } |
|
| 48 | + // We're not connected to the Food KG, but we're scheduled. |
|
| 49 | + if ( ! $has_food_kg && $next_scheduled ) { |
|
| 50 | + wp_unschedule_event( $next_scheduled, self::RUN_EVENT ); |
|
| 51 | + } |
|
| 52 | + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch |
|
| 53 | + } catch ( \Exception $e ) { |
|
| 54 | + // Do nothing. |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function __run() { |
|
| 59 | - foreach ( $this->recipe_lift_strategies as $recipe_lift_strategy ) { |
|
| 60 | - $recipe_lift_strategy->run(); |
|
| 61 | - } |
|
| 62 | - } |
|
| 58 | + public function __run() { |
|
| 59 | + foreach ( $this->recipe_lift_strategies as $recipe_lift_strategy ) { |
|
| 60 | + $recipe_lift_strategy->run(); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - private function __has_food_kg( $carry, $item ) { |
|
| 65 | - return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri; |
|
| 66 | - } |
|
| 64 | + private function __has_food_kg( $carry, $item ) { |
|
| 65 | + return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
@@ -22,46 +22,46 @@ |
||
| 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( self::RUN_EVENT, array( $this, '__run' ) ); |
|
| 33 | - add_action( 'wp_ajax_wl_food_kg__run', array( $this, '__run' ) ); |
|
| 31 | + add_action('wl_key_updated', array($this, '__key_updated')); |
|
| 32 | + add_action(self::RUN_EVENT, array($this, '__run')); |
|
| 33 | + add_action('wp_ajax_wl_food_kg__run', array($this, '__run')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function __key_updated() { |
| 37 | 37 | try { |
| 38 | 38 | $me_response = $this->api_service->me(); |
| 39 | - $has_food_kg = isset( $me_response->networks ) |
|
| 40 | - && array_reduce( $me_response->networks, array( $this, '__has_food_kg' ), false ); |
|
| 41 | - $next_scheduled = wp_next_scheduled( self::RUN_EVENT ); |
|
| 39 | + $has_food_kg = isset($me_response->networks) |
|
| 40 | + && array_reduce($me_response->networks, array($this, '__has_food_kg'), false); |
|
| 41 | + $next_scheduled = wp_next_scheduled(self::RUN_EVENT); |
|
| 42 | 42 | |
| 43 | 43 | // We're connected to the Food KG, but not yet scheduled. |
| 44 | - if ( $has_food_kg && ! $next_scheduled ) { |
|
| 45 | - wp_schedule_event( time(), 'daily', self::RUN_EVENT ); |
|
| 44 | + if ($has_food_kg && ! $next_scheduled) { |
|
| 45 | + wp_schedule_event(time(), 'daily', self::RUN_EVENT); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // We're not connected to the Food KG, but we're scheduled. |
| 49 | - if ( ! $has_food_kg && $next_scheduled ) { |
|
| 50 | - wp_unschedule_event( $next_scheduled, self::RUN_EVENT ); |
|
| 49 | + if ( ! $has_food_kg && $next_scheduled) { |
|
| 50 | + wp_unschedule_event($next_scheduled, self::RUN_EVENT); |
|
| 51 | 51 | } |
| 52 | 52 | // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch |
| 53 | - } catch ( \Exception $e ) { |
|
| 53 | + } catch (\Exception $e) { |
|
| 54 | 54 | // Do nothing. |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function __run() { |
| 59 | - foreach ( $this->recipe_lift_strategies as $recipe_lift_strategy ) { |
|
| 59 | + foreach ($this->recipe_lift_strategies as $recipe_lift_strategy) { |
|
| 60 | 60 | $recipe_lift_strategy->run(); |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - private function __has_food_kg( $carry, $item ) { |
|
| 64 | + private function __has_food_kg($carry, $item) { |
|
| 65 | 65 | return $carry || 'https://knowledge.cafemedia.com/food/' === $item->dataset_uri; |
| 66 | 66 | } |
| 67 | 67 | |