@@ -4,11 +4,11 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Ingredients_Full_Page_Delegate implements Page_Delegate { |
| 6 | 6 | |
| 7 | - public function render() { |
|
| 8 | - include_once WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/ingredients.php'; |
|
| 9 | - } |
|
| 7 | + public function render() { |
|
| 8 | + include_once 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_once WL_FOOD_KG_DIR_PATH . '/includes/admin/partials/ingredients.php'; |
|
| 8 | + include_once WL_FOOD_KG_DIR_PATH.'/includes/admin/partials/ingredients.php'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public function admin_enqueue_scripts() { |
@@ -11,99 +11,99 @@ |
||
| 11 | 11 | |
| 12 | 12 | class All_Posts_Task implements Task { |
| 13 | 13 | |
| 14 | - private $callable; |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @var string|null |
|
| 18 | - */ |
|
| 19 | - private $post_type; |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @var string|null |
|
| 23 | - */ |
|
| 24 | - private $id; |
|
| 25 | - |
|
| 26 | - public function __construct( $callable, $post_type = null, $id = null ) { |
|
| 27 | - $this->callable = $callable; |
|
| 28 | - $this->post_type = $post_type; |
|
| 29 | - $this->id = $id; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public function get_id() { |
|
| 33 | - return isset( $this->id ) ? $this->id : hash( 'sha256', get_class( $this ) ); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function starting() { |
|
| 37 | - global $wpdb; |
|
| 38 | - |
|
| 39 | - // Try to get the count from transient, or load it from database. |
|
| 40 | - $key = $this->get_transient_key(); |
|
| 41 | - $count = get_transient( $key ); |
|
| 42 | - if ( false === $count ) { |
|
| 43 | - $count = $wpdb->get_var( |
|
| 44 | - "SELECT COUNT( 1 ) |
|
| 14 | + private $callable; |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @var string|null |
|
| 18 | + */ |
|
| 19 | + private $post_type; |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @var string|null |
|
| 23 | + */ |
|
| 24 | + private $id; |
|
| 25 | + |
|
| 26 | + public function __construct( $callable, $post_type = null, $id = null ) { |
|
| 27 | + $this->callable = $callable; |
|
| 28 | + $this->post_type = $post_type; |
|
| 29 | + $this->id = $id; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public function get_id() { |
|
| 33 | + return isset( $this->id ) ? $this->id : hash( 'sha256', get_class( $this ) ); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function starting() { |
|
| 37 | + global $wpdb; |
|
| 38 | + |
|
| 39 | + // Try to get the count from transient, or load it from database. |
|
| 40 | + $key = $this->get_transient_key(); |
|
| 41 | + $count = get_transient( $key ); |
|
| 42 | + if ( false === $count ) { |
|
| 43 | + $count = $wpdb->get_var( |
|
| 44 | + "SELECT COUNT( 1 ) |
|
| 45 | 45 | FROM $wpdb->posts " |
| 46 | - // Prepare is called with the `add_post_type_filter` function. |
|
| 47 | - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 48 | - . $this->where( $this->add_post_type_filter() ) |
|
| 49 | - ); |
|
| 50 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - return $count; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @param $value mixed The incoming value. |
|
| 58 | - * @param $args { |
|
| 59 | - * |
|
| 60 | - * @type int $offset The index of the current item. |
|
| 61 | - * @type int $count The total number of items as provided by the `starting` function. |
|
| 62 | - * @type int $batch_size The number of items to process within this call. |
|
| 63 | - * } |
|
| 64 | - * |
|
| 65 | - * @return void |
|
| 66 | - */ |
|
| 67 | - public function tick( $value, $args ) { |
|
| 68 | - global $wpdb; |
|
| 69 | - |
|
| 70 | - $ids = $wpdb->get_col( |
|
| 71 | - $wpdb->prepare( |
|
| 72 | - "SELECT ID FROM $wpdb->posts " |
|
| 73 | - // Prepare is called with the `add_post_type_filter` function. |
|
| 74 | - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 75 | - . $this->where( $this->add_post_type_filter() ) |
|
| 76 | - . ' ORDER BY ID LIMIT %d,%d', |
|
| 77 | - $args['offset'], |
|
| 78 | - $args['batch_size'] |
|
| 79 | - ) |
|
| 80 | - ); |
|
| 81 | - |
|
| 82 | - foreach ( $ids as $id ) { |
|
| 83 | - call_user_func( $this->callable, $id ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - private function add_post_type_filter() { |
|
| 89 | - global $wpdb; |
|
| 90 | - if ( isset( $this->post_type ) ) { |
|
| 91 | - return $wpdb->prepare( ' post_type = %s ', $this->post_type ); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return ''; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - private function where( $filter ) { |
|
| 98 | - if ( ! empty( $filter ) ) { |
|
| 99 | - return " WHERE $filter"; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - return ''; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - private function get_transient_key() { |
|
| 106 | - return '_wl_task__all_posts_task__count' . ( isset( $this->post_type ) ? '__' . $this->post_type : '' ); |
|
| 107 | - } |
|
| 46 | + // Prepare is called with the `add_post_type_filter` function. |
|
| 47 | + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 48 | + . $this->where( $this->add_post_type_filter() ) |
|
| 49 | + ); |
|
| 50 | + set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + return $count; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @param $value mixed The incoming value. |
|
| 58 | + * @param $args { |
|
| 59 | + * |
|
| 60 | + * @type int $offset The index of the current item. |
|
| 61 | + * @type int $count The total number of items as provided by the `starting` function. |
|
| 62 | + * @type int $batch_size The number of items to process within this call. |
|
| 63 | + * } |
|
| 64 | + * |
|
| 65 | + * @return void |
|
| 66 | + */ |
|
| 67 | + public function tick( $value, $args ) { |
|
| 68 | + global $wpdb; |
|
| 69 | + |
|
| 70 | + $ids = $wpdb->get_col( |
|
| 71 | + $wpdb->prepare( |
|
| 72 | + "SELECT ID FROM $wpdb->posts " |
|
| 73 | + // Prepare is called with the `add_post_type_filter` function. |
|
| 74 | + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 75 | + . $this->where( $this->add_post_type_filter() ) |
|
| 76 | + . ' ORDER BY ID LIMIT %d,%d', |
|
| 77 | + $args['offset'], |
|
| 78 | + $args['batch_size'] |
|
| 79 | + ) |
|
| 80 | + ); |
|
| 81 | + |
|
| 82 | + foreach ( $ids as $id ) { |
|
| 83 | + call_user_func( $this->callable, $id ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + private function add_post_type_filter() { |
|
| 89 | + global $wpdb; |
|
| 90 | + if ( isset( $this->post_type ) ) { |
|
| 91 | + return $wpdb->prepare( ' post_type = %s ', $this->post_type ); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return ''; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + private function where( $filter ) { |
|
| 98 | + if ( ! empty( $filter ) ) { |
|
| 99 | + return " WHERE $filter"; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + return ''; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + private function get_transient_key() { |
|
| 106 | + return '_wl_task__all_posts_task__count' . ( isset( $this->post_type ) ? '__' . $this->post_type : '' ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | } |
@@ -23,14 +23,14 @@ discard block |
||
| 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 : hash( 'sha256', get_class( $this ) ); |
|
| 33 | + return isset($this->id) ? $this->id : hash('sha256', get_class($this)); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function starting() { |
@@ -38,16 +38,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -4,42 +4,42 @@ |
||
| 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 : hash( 'sha256', 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 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 39 | - public function tick( $value, $args ) { |
|
| 40 | - |
|
| 41 | - call_user_func( $this->callable, 1 ); |
|
| 42 | - |
|
| 43 | - } |
|
| 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 : hash( 'sha256', 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 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 39 | + public function tick( $value, $args ) { |
|
| 40 | + |
|
| 41 | + call_user_func( $this->callable, 1 ); |
|
| 42 | + |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -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 : hash( 'sha256', get_class( $this ) ); |
|
| 20 | + return isset($this->id) ? $this->id : hash('sha256', get_class($this)); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function starting() { |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * @return void |
| 37 | 37 | */ |
| 38 | 38 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 39 | - public function tick( $value, $args ) { |
|
| 39 | + public function tick($value, $args) { |
|
| 40 | 40 | |
| 41 | - call_user_func( $this->callable, 1 ); |
|
| 41 | + call_user_func($this->callable, 1); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |