@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * |
| 21 | 21 | * @return mixed |
| 22 | 22 | */ |
| 23 | - function task( $item ); |
|
| 23 | + function task($item); |
|
| 24 | 24 | |
| 25 | 25 | function get_info(); |
| 26 | 26 | |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface Sync_Background_Process_State { |
| 6 | 6 | |
| 7 | - function enter(); |
|
| 8 | - |
|
| 9 | - function leave(); |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * Task |
|
| 13 | - * |
|
| 14 | - * Override this method to perform any actions required on each |
|
| 15 | - * queue item. Return the modified item for further processing |
|
| 16 | - * in the next pass through. Or, return false to remove the |
|
| 17 | - * item from the queue. |
|
| 18 | - * |
|
| 19 | - * @param mixed $item Queue item to iterate over. |
|
| 20 | - * |
|
| 21 | - * @return mixed |
|
| 22 | - */ |
|
| 23 | - function task( $item ); |
|
| 24 | - |
|
| 25 | - function get_info(); |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * Try to resume an interrupted task. |
|
| 29 | - */ |
|
| 30 | - function resume(); |
|
| 7 | + function enter(); |
|
| 8 | + |
|
| 9 | + function leave(); |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * Task |
|
| 13 | + * |
|
| 14 | + * Override this method to perform any actions required on each |
|
| 15 | + * queue item. Return the modified item for further processing |
|
| 16 | + * in the next pass through. Or, return false to remove the |
|
| 17 | + * item from the queue. |
|
| 18 | + * |
|
| 19 | + * @param mixed $item Queue item to iterate over. |
|
| 20 | + * |
|
| 21 | + * @return mixed |
|
| 22 | + */ |
|
| 23 | + function task( $item ); |
|
| 24 | + |
|
| 25 | + function get_info(); |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * Try to resume an interrupted task. |
|
| 29 | + */ |
|
| 30 | + function resume(); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -4,27 +4,27 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Sync_Background_Process_Info { |
| 6 | 6 | |
| 7 | - public $started; |
|
| 8 | - public $index; |
|
| 9 | - public $count; |
|
| 10 | - public $last_update; |
|
| 11 | - public $state; |
|
| 7 | + public $started; |
|
| 8 | + public $index; |
|
| 9 | + public $count; |
|
| 10 | + public $last_update; |
|
| 11 | + public $state; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * Sync_Model constructor. |
|
| 15 | - * |
|
| 16 | - * @param $started |
|
| 17 | - * @param $index |
|
| 18 | - * @param $count |
|
| 19 | - * @param $last_update |
|
| 20 | - * @param $state |
|
| 21 | - */ |
|
| 22 | - public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
| 23 | - $this->started = $started; |
|
| 24 | - $this->index = $index; |
|
| 25 | - $this->count = (int) $count; |
|
| 26 | - $this->last_update = $last_update; |
|
| 27 | - $this->state = $state; |
|
| 28 | - } |
|
| 13 | + /** |
|
| 14 | + * Sync_Model constructor. |
|
| 15 | + * |
|
| 16 | + * @param $started |
|
| 17 | + * @param $index |
|
| 18 | + * @param $count |
|
| 19 | + * @param $last_update |
|
| 20 | + * @param $state |
|
| 21 | + */ |
|
| 22 | + public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
| 23 | + $this->started = $started; |
|
| 24 | + $this->index = $index; |
|
| 25 | + $this->count = (int) $count; |
|
| 26 | + $this->last_update = $last_update; |
|
| 27 | + $this->state = $state; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * @param $last_update |
| 20 | 20 | * @param $state |
| 21 | 21 | */ |
| 22 | - public function __construct( $state, $started = null, $index = null, $count = null, $last_update = null ) { |
|
| 22 | + public function __construct($state, $started = null, $index = null, $count = null, $last_update = null) { |
|
| 23 | 23 | $this->started = $started; |
| 24 | 24 | $this->index = $index; |
| 25 | 25 | $this->count = (int) $count; |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface Sync_Background_Process_Stage { |
| 6 | 6 | |
| 7 | - function count(); |
|
| 7 | + function count(); |
|
| 8 | 8 | |
| 9 | - function get_sync_object_adapters( $offset, $batch_size ); |
|
| 9 | + function get_sync_object_adapters( $offset, $batch_size ); |
|
| 10 | 10 | |
| 11 | 11 | } |
@@ -6,6 +6,6 @@ |
||
| 6 | 6 | |
| 7 | 7 | function count(); |
| 8 | 8 | |
| 9 | - function get_sync_object_adapters( $offset, $batch_size ); |
|
| 9 | + function get_sync_object_adapters($offset, $batch_size); |
|
| 10 | 10 | |
| 11 | 11 | } |
@@ -7,42 +7,42 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class Sync_Background_Process_Terms_Stage { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @var Sync_Object_Adapter_Factory |
|
| 12 | - */ |
|
| 13 | - private $sync_object_adapter_factory; |
|
| 14 | - |
|
| 15 | - /** |
|
| 16 | - * Sync_Background_Process_Posts_Stage constructor. |
|
| 17 | - * |
|
| 18 | - * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 19 | - */ |
|
| 20 | - function __construct( $sync_object_adapter_factory ) { |
|
| 21 | - $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - function count() { |
|
| 25 | - |
|
| 26 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 27 | - $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 28 | - |
|
| 29 | - global $wpdb; |
|
| 30 | - $sql = " |
|
| 10 | + /** |
|
| 11 | + * @var Sync_Object_Adapter_Factory |
|
| 12 | + */ |
|
| 13 | + private $sync_object_adapter_factory; |
|
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * Sync_Background_Process_Posts_Stage constructor. |
|
| 17 | + * |
|
| 18 | + * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 19 | + */ |
|
| 20 | + function __construct( $sync_object_adapter_factory ) { |
|
| 21 | + $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + function count() { |
|
| 25 | + |
|
| 26 | + $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 27 | + $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 28 | + |
|
| 29 | + global $wpdb; |
|
| 30 | + $sql = " |
|
| 31 | 31 | SELECT COUNT( 1 ) |
| 32 | 32 | FROM $wpdb->term_taxonomy |
| 33 | 33 | WHERE taxonomy IN ('$in_taxonomies') |
| 34 | 34 | "; |
| 35 | 35 | |
| 36 | - return $wpdb->get_var( $sql ); |
|
| 37 | - } |
|
| 36 | + return $wpdb->get_var( $sql ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - function get_sync_object_adapters( $offset, $limit ) { |
|
| 39 | + function get_sync_object_adapters( $offset, $limit ) { |
|
| 40 | 40 | |
| 41 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 42 | - $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 41 | + $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 42 | + $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 43 | 43 | |
| 44 | - global $wpdb; |
|
| 45 | - $sql = " |
|
| 44 | + global $wpdb; |
|
| 45 | + $sql = " |
|
| 46 | 46 | SELECT term_id |
| 47 | 47 | FROM $wpdb->term_taxonomy |
| 48 | 48 | WHERE taxonomy IN ('$in_taxonomies') |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | LIMIT %d, %d |
| 51 | 51 | "; |
| 52 | 52 | |
| 53 | - $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 53 | + $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 54 | 54 | |
| 55 | - return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids ); |
|
| 56 | - } |
|
| 55 | + return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | } |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
| 19 | 19 | */ |
| 20 | - function __construct( $sync_object_adapter_factory ) { |
|
| 20 | + function __construct($sync_object_adapter_factory) { |
|
| 21 | 21 | $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function count() { |
| 25 | 25 | |
| 26 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 27 | - $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 26 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
| 27 | + $in_taxonomies = implode("','", array_map('esc_sql', $taxonomies)); |
|
| 28 | 28 | |
| 29 | 29 | global $wpdb; |
| 30 | 30 | $sql = " |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | WHERE taxonomy IN ('$in_taxonomies') |
| 34 | 34 | "; |
| 35 | 35 | |
| 36 | - return $wpdb->get_var( $sql ); |
|
| 36 | + return $wpdb->get_var($sql); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - function get_sync_object_adapters( $offset, $limit ) { |
|
| 39 | + function get_sync_object_adapters($offset, $limit) { |
|
| 40 | 40 | |
| 41 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
| 42 | - $in_taxonomies = implode( "','", array_map( 'esc_sql', $taxonomies ) ); |
|
| 41 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
| 42 | + $in_taxonomies = implode("','", array_map('esc_sql', $taxonomies)); |
|
| 43 | 43 | |
| 44 | 44 | global $wpdb; |
| 45 | 45 | $sql = " |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | LIMIT %d, %d |
| 51 | 51 | "; |
| 52 | 52 | |
| 53 | - $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 53 | + $ids = $wpdb->get_col($wpdb->prepare($sql, $offset, $limit)); |
|
| 54 | 54 | |
| 55 | - return $this->sync_object_adapter_factory->create_many( Object_Type_Enum::TERM, $ids ); |
|
| 55 | + return $this->sync_object_adapter_factory->create_many(Object_Type_Enum::TERM, $ids); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | } |
@@ -8,49 +8,49 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class Sync_Background_Process_Posts_Stage { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var Sync_Object_Adapter_Factory |
|
| 13 | - */ |
|
| 14 | - private $sync_object_adapter_factory; |
|
| 11 | + /** |
|
| 12 | + * @var Sync_Object_Adapter_Factory |
|
| 13 | + */ |
|
| 14 | + private $sync_object_adapter_factory; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Sync_Background_Process_Posts_Stage constructor. |
|
| 18 | - * |
|
| 19 | - * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 20 | - */ |
|
| 21 | - function __construct( $sync_object_adapter_factory ) { |
|
| 22 | - $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 23 | - } |
|
| 16 | + /** |
|
| 17 | + * Sync_Background_Process_Posts_Stage constructor. |
|
| 18 | + * |
|
| 19 | + * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 20 | + */ |
|
| 21 | + function __construct( $sync_object_adapter_factory ) { |
|
| 22 | + $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - function count() { |
|
| 25 | + function count() { |
|
| 26 | 26 | |
| 27 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
| 27 | + $post_types = get_post_types( array( 'public' => true ) ); |
|
| 28 | 28 | |
| 29 | - global $wpdb; |
|
| 30 | - $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 31 | - $sql = " |
|
| 29 | + global $wpdb; |
|
| 30 | + $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 31 | + $sql = " |
|
| 32 | 32 | SELECT COUNT( 1 ) |
| 33 | 33 | FROM $wpdb->posts |
| 34 | 34 | WHERE post_type IN ('$in_post_type') |
| 35 | 35 | AND post_status IN ( 'publish', 'future', 'draft', 'pending', 'private' ) |
| 36 | 36 | "; |
| 37 | 37 | |
| 38 | - return $wpdb->get_var( $sql ); |
|
| 39 | - } |
|
| 38 | + return $wpdb->get_var( $sql ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param int $offset |
|
| 43 | - * @param int $limit |
|
| 44 | - * |
|
| 45 | - * @return Sync_Object_Adapter[] |
|
| 46 | - */ |
|
| 47 | - function get_sync_object_adapters( $offset, $limit ) { |
|
| 41 | + /** |
|
| 42 | + * @param int $offset |
|
| 43 | + * @param int $limit |
|
| 44 | + * |
|
| 45 | + * @return Sync_Object_Adapter[] |
|
| 46 | + */ |
|
| 47 | + function get_sync_object_adapters( $offset, $limit ) { |
|
| 48 | 48 | |
| 49 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
| 49 | + $post_types = get_post_types( array( 'public' => true ) ); |
|
| 50 | 50 | |
| 51 | - global $wpdb; |
|
| 52 | - $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 53 | - $sql = " |
|
| 51 | + global $wpdb; |
|
| 52 | + $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 53 | + $sql = " |
|
| 54 | 54 | SELECT ID |
| 55 | 55 | FROM $wpdb->posts |
| 56 | 56 | WHERE post_type IN ('$in_post_type') |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | LIMIT %d, %d |
| 60 | 60 | "; |
| 61 | 61 | |
| 62 | - $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 62 | + $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 63 | 63 | |
| 64 | - return $this->sync_object_adapter_factory |
|
| 65 | - ->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) ); |
|
| 66 | - } |
|
| 64 | + return $this->sync_object_adapter_factory |
|
| 65 | + ->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
| 20 | 20 | */ |
| 21 | - function __construct( $sync_object_adapter_factory ) { |
|
| 21 | + function __construct($sync_object_adapter_factory) { |
|
| 22 | 22 | $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function count() { |
| 26 | 26 | |
| 27 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
| 27 | + $post_types = get_post_types(array('public' => true)); |
|
| 28 | 28 | |
| 29 | 29 | global $wpdb; |
| 30 | - $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 30 | + $in_post_type = implode("','", array_map('esc_sql', $post_types)); |
|
| 31 | 31 | $sql = " |
| 32 | 32 | SELECT COUNT( 1 ) |
| 33 | 33 | FROM $wpdb->posts |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | AND post_status IN ( 'publish', 'future', 'draft', 'pending', 'private' ) |
| 36 | 36 | "; |
| 37 | 37 | |
| 38 | - return $wpdb->get_var( $sql ); |
|
| 38 | + return $wpdb->get_var($sql); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return Sync_Object_Adapter[] |
| 46 | 46 | */ |
| 47 | - function get_sync_object_adapters( $offset, $limit ) { |
|
| 47 | + function get_sync_object_adapters($offset, $limit) { |
|
| 48 | 48 | |
| 49 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
| 49 | + $post_types = get_post_types(array('public' => true)); |
|
| 50 | 50 | |
| 51 | 51 | global $wpdb; |
| 52 | - $in_post_type = implode( "','", array_map( 'esc_sql', $post_types ) ); |
|
| 52 | + $in_post_type = implode("','", array_map('esc_sql', $post_types)); |
|
| 53 | 53 | $sql = " |
| 54 | 54 | SELECT ID |
| 55 | 55 | FROM $wpdb->posts |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | LIMIT %d, %d |
| 60 | 60 | "; |
| 61 | 61 | |
| 62 | - $ids = $wpdb->get_col( $wpdb->prepare( $sql, $offset, $limit ) ); |
|
| 62 | + $ids = $wpdb->get_col($wpdb->prepare($sql, $offset, $limit)); |
|
| 63 | 63 | |
| 64 | 64 | return $this->sync_object_adapter_factory |
| 65 | - ->create_many( Object_Type_Enum::POST, array_map( 'intval', $ids ) ); |
|
| 65 | + ->create_many(Object_Type_Enum::POST, array_map('intval', $ids)); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | } |
@@ -4,30 +4,30 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Sync_Background_Process_Stopped_State extends Abstract_Sync_Background_Process_State { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var Sync_Background_Process |
|
| 9 | - */ |
|
| 10 | - private $context; |
|
| 7 | + /** |
|
| 8 | + * @var Sync_Background_Process |
|
| 9 | + */ |
|
| 10 | + private $context; |
|
| 11 | 11 | |
| 12 | - function __construct( $context ) { |
|
| 13 | - parent::__construct( Sync_Background_Process::STATE_STOPPED ); |
|
| 12 | + function __construct( $context ) { |
|
| 13 | + parent::__construct( Sync_Background_Process::STATE_STOPPED ); |
|
| 14 | 14 | |
| 15 | - $this->context = $context; |
|
| 16 | - } |
|
| 15 | + $this->context = $context; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - function enter() { |
|
| 19 | - $this->context->set_state( Sync_Background_Process::STATE_STOPPED ); |
|
| 20 | - } |
|
| 18 | + function enter() { |
|
| 19 | + $this->context->set_state( Sync_Background_Process::STATE_STOPPED ); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - function leave() { |
|
| 23 | - $this->context->set_state( null ); |
|
| 24 | - } |
|
| 22 | + function leave() { |
|
| 23 | + $this->context->set_state( null ); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - function task( $item ) { |
|
| 26 | + function task( $item ) { |
|
| 27 | 27 | |
| 28 | - $this->context->cancel_process(); |
|
| 28 | + $this->context->cancel_process(); |
|
| 29 | 29 | |
| 30 | - return false; |
|
| 31 | - } |
|
| 30 | + return false; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | } |
@@ -9,21 +9,21 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | private $context; |
| 11 | 11 | |
| 12 | - function __construct( $context ) { |
|
| 13 | - parent::__construct( Sync_Background_Process::STATE_STOPPED ); |
|
| 12 | + function __construct($context) { |
|
| 13 | + parent::__construct(Sync_Background_Process::STATE_STOPPED); |
|
| 14 | 14 | |
| 15 | 15 | $this->context = $context; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | function enter() { |
| 19 | - $this->context->set_state( Sync_Background_Process::STATE_STOPPED ); |
|
| 19 | + $this->context->set_state(Sync_Background_Process::STATE_STOPPED); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | function leave() { |
| 23 | - $this->context->set_state( null ); |
|
| 23 | + $this->context->set_state(null); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - function task( $item ) { |
|
| 26 | + function task($item) { |
|
| 27 | 27 | |
| 28 | 28 | $this->context->cancel_process(); |
| 29 | 29 | |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | * @param Sync_Service $sync_service A {@link Sync_Service} instance providing the supporting functions to this background process. |
| 50 | 50 | * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
| 51 | 51 | */ |
| 52 | - public function __construct( $sync_service, $sync_object_adapter_factory ) { |
|
| 52 | + public function __construct($sync_service, $sync_object_adapter_factory) { |
|
| 53 | 53 | parent::__construct(); |
| 54 | 54 | |
| 55 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 55 | + $this->log = \Wordlift_Log_Service::get_logger(get_class()); |
|
| 56 | 56 | |
| 57 | 57 | $this->sync_service = $sync_service; |
| 58 | 58 | $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
| 59 | 59 | |
| 60 | 60 | // Set the current state. |
| 61 | - if ( self::STATE_STARTED === $this->get_state() ) { |
|
| 62 | - $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 61 | + if (self::STATE_STARTED === $this->get_state()) { |
|
| 62 | + $this->state = new Sync_Background_Process_Started_State($this, $this->sync_service, $this->sync_object_adapter_factory); |
|
| 63 | 63 | } else { |
| 64 | - $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 64 | + $this->state = new Sync_Background_Process_Stopped_State($this); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return int[]|false The next post IDs or false if there are no more. |
| 79 | 79 | */ |
| 80 | - protected function task( $item ) { |
|
| 80 | + protected function task($item) { |
|
| 81 | 81 | |
| 82 | - return $this->state->task( $item ); |
|
| 82 | + return $this->state->task($item); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function start() { |
| 89 | 89 | $this->state->leave(); |
| 90 | - $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 90 | + $this->state = new Sync_Background_Process_Started_State($this, $this->sync_service, $this->sync_object_adapter_factory); |
|
| 91 | 91 | $this->state->enter(); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function stop() { |
| 98 | 98 | $this->state->leave(); |
| 99 | - $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 99 | + $this->state = new Sync_Background_Process_Stopped_State($this); |
|
| 100 | 100 | $this->state->enter(); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default). |
| 107 | 107 | */ |
| 108 | 108 | public function get_state() { |
| 109 | - return get_option( '_wl_sync_background_process_state', self::STATE_STOPPED ); |
|
| 109 | + return get_option('_wl_sync_background_process_state', self::STATE_STOPPED); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return bool |
| 118 | 118 | */ |
| 119 | - public function set_state( $value ) { |
|
| 119 | + public function set_state($value) { |
|
| 120 | 120 | return null === $value |
| 121 | - ? delete_option( '_wl_sync_background_process_state' ) |
|
| 122 | - : update_option( '_wl_sync_background_process_state', $value, true ); |
|
| 121 | + ? delete_option('_wl_sync_background_process_state') |
|
| 122 | + : update_option('_wl_sync_background_process_state', $value, true); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public function get_info() { |
@@ -18,116 +18,116 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Sync_Background_Process extends \Wordlift_Plugin_WP_Background_Process { |
| 20 | 20 | |
| 21 | - const STATE_STARTED = 'started'; |
|
| 22 | - const STATE_STOPPED = 'stopped'; |
|
| 23 | - |
|
| 24 | - protected $action = 'wl_dataset__sync'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var Sync_Service |
|
| 28 | - */ |
|
| 29 | - private $sync_service; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var Sync_Object_Adapter_Factory |
|
| 33 | - */ |
|
| 34 | - private $sync_object_adapter_factory; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var \Wordlift_Log_Service |
|
| 38 | - */ |
|
| 39 | - private $log; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var Sync_Background_Process_State |
|
| 43 | - */ |
|
| 44 | - private $state; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Sync_Background_Process constructor. |
|
| 48 | - * |
|
| 49 | - * @param Sync_Service $sync_service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 50 | - * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 51 | - */ |
|
| 52 | - public function __construct( $sync_service, $sync_object_adapter_factory ) { |
|
| 53 | - parent::__construct(); |
|
| 54 | - |
|
| 55 | - $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 56 | - |
|
| 57 | - $this->sync_service = $sync_service; |
|
| 58 | - $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 59 | - |
|
| 60 | - // Set the current state. |
|
| 61 | - if ( self::STATE_STARTED === $this->get_state() ) { |
|
| 62 | - $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 63 | - } else { |
|
| 64 | - $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * This function is called: |
|
| 71 | - * - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance. |
|
| 72 | - * - To synchronize a post, by passing a numeric ID. |
|
| 73 | - * |
|
| 74 | - * This function returns the parameter for the next call or NULL if there are no more posts to process. |
|
| 75 | - * |
|
| 76 | - * @param mixed $item Queue item to iterate over. |
|
| 77 | - * |
|
| 78 | - * @return int[]|false The next post IDs or false if there are no more. |
|
| 79 | - */ |
|
| 80 | - protected function task( $item ) { |
|
| 81 | - |
|
| 82 | - return $this->state->task( $item ); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Transition to the started state. |
|
| 87 | - */ |
|
| 88 | - public function start() { |
|
| 89 | - $this->state->leave(); |
|
| 90 | - $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 91 | - $this->state->enter(); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Transition to the stopped state. |
|
| 96 | - */ |
|
| 97 | - public function stop() { |
|
| 98 | - $this->state->leave(); |
|
| 99 | - $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 100 | - $this->state->enter(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function resume() { |
|
| 104 | - $this->state->resume(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Get the current state. |
|
| 109 | - * |
|
| 110 | - * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default). |
|
| 111 | - */ |
|
| 112 | - public function get_state() { |
|
| 113 | - return get_option( '_wl_sync_background_process_state', self::STATE_STOPPED ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Persist the current state. |
|
| 118 | - * |
|
| 119 | - * @param string $value |
|
| 120 | - * |
|
| 121 | - * @return bool |
|
| 122 | - */ |
|
| 123 | - public function set_state( $value ) { |
|
| 124 | - return null === $value |
|
| 125 | - ? delete_option( '_wl_sync_background_process_state' ) |
|
| 126 | - : update_option( '_wl_sync_background_process_state', $value, true ); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - public function get_info() { |
|
| 130 | - return $this->state->get_info(); |
|
| 131 | - } |
|
| 21 | + const STATE_STARTED = 'started'; |
|
| 22 | + const STATE_STOPPED = 'stopped'; |
|
| 23 | + |
|
| 24 | + protected $action = 'wl_dataset__sync'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var Sync_Service |
|
| 28 | + */ |
|
| 29 | + private $sync_service; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var Sync_Object_Adapter_Factory |
|
| 33 | + */ |
|
| 34 | + private $sync_object_adapter_factory; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var \Wordlift_Log_Service |
|
| 38 | + */ |
|
| 39 | + private $log; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var Sync_Background_Process_State |
|
| 43 | + */ |
|
| 44 | + private $state; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Sync_Background_Process constructor. |
|
| 48 | + * |
|
| 49 | + * @param Sync_Service $sync_service A {@link Sync_Service} instance providing the supporting functions to this background process. |
|
| 50 | + * @param Sync_Object_Adapter_Factory $sync_object_adapter_factory |
|
| 51 | + */ |
|
| 52 | + public function __construct( $sync_service, $sync_object_adapter_factory ) { |
|
| 53 | + parent::__construct(); |
|
| 54 | + |
|
| 55 | + $this->log = \Wordlift_Log_Service::get_logger( get_class() ); |
|
| 56 | + |
|
| 57 | + $this->sync_service = $sync_service; |
|
| 58 | + $this->sync_object_adapter_factory = $sync_object_adapter_factory; |
|
| 59 | + |
|
| 60 | + // Set the current state. |
|
| 61 | + if ( self::STATE_STARTED === $this->get_state() ) { |
|
| 62 | + $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 63 | + } else { |
|
| 64 | + $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * This function is called: |
|
| 71 | + * - To start a new Synchronization, by passing a {@link Sync_Start_Message} instance. |
|
| 72 | + * - To synchronize a post, by passing a numeric ID. |
|
| 73 | + * |
|
| 74 | + * This function returns the parameter for the next call or NULL if there are no more posts to process. |
|
| 75 | + * |
|
| 76 | + * @param mixed $item Queue item to iterate over. |
|
| 77 | + * |
|
| 78 | + * @return int[]|false The next post IDs or false if there are no more. |
|
| 79 | + */ |
|
| 80 | + protected function task( $item ) { |
|
| 81 | + |
|
| 82 | + return $this->state->task( $item ); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Transition to the started state. |
|
| 87 | + */ |
|
| 88 | + public function start() { |
|
| 89 | + $this->state->leave(); |
|
| 90 | + $this->state = new Sync_Background_Process_Started_State( $this, $this->sync_service, $this->sync_object_adapter_factory ); |
|
| 91 | + $this->state->enter(); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Transition to the stopped state. |
|
| 96 | + */ |
|
| 97 | + public function stop() { |
|
| 98 | + $this->state->leave(); |
|
| 99 | + $this->state = new Sync_Background_Process_Stopped_State( $this ); |
|
| 100 | + $this->state->enter(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function resume() { |
|
| 104 | + $this->state->resume(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Get the current state. |
|
| 109 | + * |
|
| 110 | + * @return string Either self::STARTED_STATE or self::STOPPED_STATE (default). |
|
| 111 | + */ |
|
| 112 | + public function get_state() { |
|
| 113 | + return get_option( '_wl_sync_background_process_state', self::STATE_STOPPED ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Persist the current state. |
|
| 118 | + * |
|
| 119 | + * @param string $value |
|
| 120 | + * |
|
| 121 | + * @return bool |
|
| 122 | + */ |
|
| 123 | + public function set_state( $value ) { |
|
| 124 | + return null === $value |
|
| 125 | + ? delete_option( '_wl_sync_background_process_state' ) |
|
| 126 | + : update_option( '_wl_sync_background_process_state', $value, true ); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + public function get_info() { |
|
| 130 | + return $this->state->get_info(); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | |
| 33 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 33 | + add_filter('wl_mappings_rule_validators', array($this, 'wl_mappings_rule_validators')); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return array An array with validators plus ours. |
| 43 | 43 | */ |
| 44 | - public function wl_mappings_rule_validators( $value ) { |
|
| 44 | + public function wl_mappings_rule_validators($value) { |
|
| 45 | 45 | |
| 46 | - $value[ self::POST_TAXONOMY ] = $this; |
|
| 46 | + $value[self::POST_TAXONOMY] = $this; |
|
| 47 | 47 | |
| 48 | 48 | return $value; |
| 49 | 49 | } |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * {@inheritdoc} |
| 53 | 53 | */ |
| 54 | 54 | public function get_label() { |
| 55 | - return __( 'Post Taxonomy', 'wordlift' ); |
|
| 55 | + return __('Post Taxonomy', 'wordlift'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * {@inheritdoc} |
| 60 | 60 | */ |
| 61 | - public function is_valid ( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 61 | + public function is_valid($identifier, $operator, $operand_1, $operand_2, $type) { |
|
| 62 | 62 | $taxonomy = $operand_1; |
| 63 | 63 | $term_slug = $operand_2; |
| 64 | 64 | |
| 65 | 65 | if (get_post_type($identifier) !== 'post') { |
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | - $is_object_in_term = is_object_in_term( $identifier, $taxonomy, $term_slug ); |
|
| 69 | - if ( is_wp_error( $is_object_in_term ) ) { |
|
| 68 | + $is_object_in_term = is_object_in_term($identifier, $taxonomy, $term_slug); |
|
| 69 | + if (is_wp_error($is_object_in_term)) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | - return ( $is_object_in_term && self::IS_EQUAL_TO === $operator ) |
|
| 73 | - || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator ); |
|
| 72 | + return ($is_object_in_term && self::IS_EQUAL_TO === $operator) |
|
| 73 | + || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator); |
|
| 74 | 74 | } |
| 75 | 75 | } |
@@ -17,48 +17,48 @@ discard block |
||
| 17 | 17 | * @package Wordlift\Mappings\Validators |
| 18 | 18 | */ |
| 19 | 19 | class Post_Taxonomy_Term_Rule_Validator implements Rule_Validator { |
| 20 | - /** |
|
| 21 | - * @since 3.25.0 |
|
| 22 | - * Enum for the post taxonomy type rule validator. |
|
| 23 | - */ |
|
| 24 | - const POST_TAXONOMY = 'post_taxonomy'; |
|
| 20 | + /** |
|
| 21 | + * @since 3.25.0 |
|
| 22 | + * Enum for the post taxonomy type rule validator. |
|
| 23 | + */ |
|
| 24 | + const POST_TAXONOMY = 'post_taxonomy'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Post_Taxonomy_Term_Rule_Validator constructor. |
|
| 28 | - * |
|
| 29 | - * When initializing the class hooks to `wl_mappings_rule_validators`. |
|
| 30 | - */ |
|
| 31 | - public function __construct() { |
|
| 26 | + /** |
|
| 27 | + * Post_Taxonomy_Term_Rule_Validator constructor. |
|
| 28 | + * |
|
| 29 | + * When initializing the class hooks to `wl_mappings_rule_validators`. |
|
| 30 | + */ |
|
| 31 | + public function __construct() { |
|
| 32 | 32 | |
| 33 | - add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 33 | + add_filter( 'wl_mappings_rule_validators', array( $this, 'wl_mappings_rule_validators' ) ); |
|
| 34 | 34 | |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 39 | - * |
|
| 40 | - * @param array $value An array with validators. |
|
| 41 | - * |
|
| 42 | - * @return array An array with validators plus ours. |
|
| 43 | - */ |
|
| 44 | - public function wl_mappings_rule_validators( $value ) { |
|
| 37 | + /** |
|
| 38 | + * Hook to `wl_mappings_rule_validators` to register ourselves. |
|
| 39 | + * |
|
| 40 | + * @param array $value An array with validators. |
|
| 41 | + * |
|
| 42 | + * @return array An array with validators plus ours. |
|
| 43 | + */ |
|
| 44 | + public function wl_mappings_rule_validators( $value ) { |
|
| 45 | 45 | |
| 46 | - $value[ self::POST_TAXONOMY ] = $this; |
|
| 46 | + $value[ self::POST_TAXONOMY ] = $this; |
|
| 47 | 47 | |
| 48 | - return $value; |
|
| 49 | - } |
|
| 48 | + return $value; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - public function get_label() { |
|
| 55 | - return __( 'Post Taxonomy', 'wordlift' ); |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + public function get_label() { |
|
| 55 | + return __( 'Post Taxonomy', 'wordlift' ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * {@inheritdoc} |
|
| 60 | - */ |
|
| 61 | - public function is_valid ( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 58 | + /** |
|
| 59 | + * {@inheritdoc} |
|
| 60 | + */ |
|
| 61 | + public function is_valid ( $identifier, $operator, $operand_1, $operand_2, $type ) { |
|
| 62 | 62 | $taxonomy = $operand_1; |
| 63 | 63 | $term_slug = $operand_2; |
| 64 | 64 | if (get_post_type($identifier) !== 'post') { |
@@ -70,5 +70,5 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | return ( $is_object_in_term && self::IS_EQUAL_TO === $operator ) |
| 72 | 72 | || ( ! $is_object_in_term && self::IS_NOT_EQUAL_TO === $operator ); |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -10,157 +10,157 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Filler_Posts_Util { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @var array<Filler_Posts> |
|
| 15 | - */ |
|
| 16 | - private $sources = array(); |
|
| 17 | - |
|
| 18 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
| 19 | - |
|
| 20 | - $post_type = $alternate_post_type ?: get_post_type( $post_id ); |
|
| 21 | - |
|
| 22 | - if ( $post_type === 'post' || ( is_array( $post_type ) && in_array( 'post', $post_type ) ) ) { |
|
| 23 | - $this->sources = array( |
|
| 24 | - new Same_Category_Filler_Posts( $post_id ), |
|
| 25 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 26 | - ); |
|
| 27 | - } else if ( $post_type === 'product' || ( is_array( $post_type ) && in_array( 'product', $post_type ) ) ) { |
|
| 28 | - $this->sources = array( |
|
| 29 | - new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
| 30 | - new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
| 31 | - ); |
|
| 32 | - } else { |
|
| 33 | - $this->sources = array( |
|
| 34 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 35 | - ); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param $posts array<\WP_Post> |
|
| 42 | - * |
|
| 43 | - * @return array<int> |
|
| 44 | - */ |
|
| 45 | - private function extract_post_ids( $posts ) { |
|
| 46 | - return array_map( function ( $post ) { |
|
| 47 | - /** |
|
| 48 | - * @var $post \WP_Post |
|
| 49 | - */ |
|
| 50 | - return $post->ID; |
|
| 51 | - }, $posts ); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
| 55 | - |
|
| 56 | - $filler_posts = array(); |
|
| 57 | - |
|
| 58 | - foreach ( $this->sources as $source ) { |
|
| 59 | - |
|
| 60 | - if ( $filler_count <= 0 ) { |
|
| 61 | - break; |
|
| 62 | - } |
|
| 63 | - /** |
|
| 64 | - * @var Filler_Posts $source |
|
| 65 | - */ |
|
| 66 | - $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
|
| 67 | - $source->filler_count = $filler_count; |
|
| 68 | - |
|
| 69 | - $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 70 | - $post_ids = $this->extract_post_ids( $posts ); |
|
| 71 | - |
|
| 72 | - // Update the post ids, filler posts and filler count |
|
| 73 | - $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
| 74 | - $filler_count = $filler_count - count( $posts ); |
|
| 75 | - $filler_posts = array_merge( $filler_posts, $posts ); |
|
| 76 | - } |
|
| 77 | - $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
| 78 | - |
|
| 79 | - return $filler_posts; |
|
| 80 | - |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param $posts array<\WP_Post> |
|
| 85 | - * |
|
| 86 | - * @return array $posts array<\WP_Post> |
|
| 87 | - */ |
|
| 88 | - private function add_additional_properties_to_filler_posts( $posts ) { |
|
| 89 | - return array_map( function ( $post ) { |
|
| 90 | - $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
| 91 | - $post->permalink = get_permalink( $post->ID ); |
|
| 92 | - $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
| 93 | - |
|
| 94 | - return $post; |
|
| 95 | - }, $posts ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Called by wordlift navigator, converts all the posts to response format. |
|
| 100 | - * |
|
| 101 | - * @param $filler_count |
|
| 102 | - * @param $post_ids_to_be_excluded |
|
| 103 | - * |
|
| 104 | - * @return array |
|
| 105 | - */ |
|
| 106 | - public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 107 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 108 | - // Add thumbnail and permalink to filler posts |
|
| 109 | - $filler_response = array(); |
|
| 110 | - foreach ( $filler_posts as $post_obj ) { |
|
| 111 | - $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
| 112 | - $filler_response[] = array( |
|
| 113 | - 'post' => array( |
|
| 114 | - 'id' => $post_obj->ID, |
|
| 115 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
| 116 | - 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
| 117 | - 'title' => $post_obj->post_title, |
|
| 118 | - 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ) |
|
| 119 | - ), |
|
| 120 | - 'entity' => array( |
|
| 121 | - 'id' => 0 |
|
| 122 | - ) |
|
| 123 | - ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - return $filler_response; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Called by wordlift navigator, converts all the posts to response format. |
|
| 132 | - * |
|
| 133 | - * @param $filler_count |
|
| 134 | - * @param $post_ids_to_be_excluded |
|
| 135 | - * |
|
| 136 | - * @return array |
|
| 137 | - */ |
|
| 138 | - public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 139 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 140 | - // Add thumbnail and permalink to filler posts |
|
| 141 | - $filler_response = array(); |
|
| 142 | - foreach ( $filler_posts as $post_obj ) { |
|
| 143 | - $product = wc_get_product( $post_obj->ID ); |
|
| 144 | - $filler_response[] = array( |
|
| 145 | - 'product' => array( |
|
| 146 | - 'id' => $post_obj->ID, |
|
| 147 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
| 148 | - 'title' => $post_obj->post_title, |
|
| 149 | - 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
| 150 | - 'regular_price' => $product->get_regular_price(), |
|
| 151 | - 'sale_price' => $product->get_sale_price(), |
|
| 152 | - 'price' => $product->get_price(), |
|
| 153 | - 'currency_symbol' => get_woocommerce_currency_symbol(), |
|
| 154 | - 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
| 155 | - 'average_rating' => $product->get_average_rating(), |
|
| 156 | - 'rating_count' => $product->get_rating_count(), |
|
| 157 | - 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) |
|
| 158 | - ), |
|
| 159 | - 'entity' => array(), |
|
| 160 | - ); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return $filler_response; |
|
| 164 | - } |
|
| 13 | + /** |
|
| 14 | + * @var array<Filler_Posts> |
|
| 15 | + */ |
|
| 16 | + private $sources = array(); |
|
| 17 | + |
|
| 18 | + public function __construct( $post_id, $alternate_post_type = null ) { |
|
| 19 | + |
|
| 20 | + $post_type = $alternate_post_type ?: get_post_type( $post_id ); |
|
| 21 | + |
|
| 22 | + if ( $post_type === 'post' || ( is_array( $post_type ) && in_array( 'post', $post_type ) ) ) { |
|
| 23 | + $this->sources = array( |
|
| 24 | + new Same_Category_Filler_Posts( $post_id ), |
|
| 25 | + new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 26 | + ); |
|
| 27 | + } else if ( $post_type === 'product' || ( is_array( $post_type ) && in_array( 'product', $post_type ) ) ) { |
|
| 28 | + $this->sources = array( |
|
| 29 | + new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
| 30 | + new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
| 31 | + ); |
|
| 32 | + } else { |
|
| 33 | + $this->sources = array( |
|
| 34 | + new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param $posts array<\WP_Post> |
|
| 42 | + * |
|
| 43 | + * @return array<int> |
|
| 44 | + */ |
|
| 45 | + private function extract_post_ids( $posts ) { |
|
| 46 | + return array_map( function ( $post ) { |
|
| 47 | + /** |
|
| 48 | + * @var $post \WP_Post |
|
| 49 | + */ |
|
| 50 | + return $post->ID; |
|
| 51 | + }, $posts ); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
| 55 | + |
|
| 56 | + $filler_posts = array(); |
|
| 57 | + |
|
| 58 | + foreach ( $this->sources as $source ) { |
|
| 59 | + |
|
| 60 | + if ( $filler_count <= 0 ) { |
|
| 61 | + break; |
|
| 62 | + } |
|
| 63 | + /** |
|
| 64 | + * @var Filler_Posts $source |
|
| 65 | + */ |
|
| 66 | + $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
|
| 67 | + $source->filler_count = $filler_count; |
|
| 68 | + |
|
| 69 | + $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 70 | + $post_ids = $this->extract_post_ids( $posts ); |
|
| 71 | + |
|
| 72 | + // Update the post ids, filler posts and filler count |
|
| 73 | + $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
| 74 | + $filler_count = $filler_count - count( $posts ); |
|
| 75 | + $filler_posts = array_merge( $filler_posts, $posts ); |
|
| 76 | + } |
|
| 77 | + $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
| 78 | + |
|
| 79 | + return $filler_posts; |
|
| 80 | + |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param $posts array<\WP_Post> |
|
| 85 | + * |
|
| 86 | + * @return array $posts array<\WP_Post> |
|
| 87 | + */ |
|
| 88 | + private function add_additional_properties_to_filler_posts( $posts ) { |
|
| 89 | + return array_map( function ( $post ) { |
|
| 90 | + $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
| 91 | + $post->permalink = get_permalink( $post->ID ); |
|
| 92 | + $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
| 93 | + |
|
| 94 | + return $post; |
|
| 95 | + }, $posts ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Called by wordlift navigator, converts all the posts to response format. |
|
| 100 | + * |
|
| 101 | + * @param $filler_count |
|
| 102 | + * @param $post_ids_to_be_excluded |
|
| 103 | + * |
|
| 104 | + * @return array |
|
| 105 | + */ |
|
| 106 | + public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 107 | + $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 108 | + // Add thumbnail and permalink to filler posts |
|
| 109 | + $filler_response = array(); |
|
| 110 | + foreach ( $filler_posts as $post_obj ) { |
|
| 111 | + $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
| 112 | + $filler_response[] = array( |
|
| 113 | + 'post' => array( |
|
| 114 | + 'id' => $post_obj->ID, |
|
| 115 | + 'permalink' => get_permalink( $post_obj->ID ), |
|
| 116 | + 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
| 117 | + 'title' => $post_obj->post_title, |
|
| 118 | + 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ) |
|
| 119 | + ), |
|
| 120 | + 'entity' => array( |
|
| 121 | + 'id' => 0 |
|
| 122 | + ) |
|
| 123 | + ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + return $filler_response; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Called by wordlift navigator, converts all the posts to response format. |
|
| 132 | + * |
|
| 133 | + * @param $filler_count |
|
| 134 | + * @param $post_ids_to_be_excluded |
|
| 135 | + * |
|
| 136 | + * @return array |
|
| 137 | + */ |
|
| 138 | + public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 139 | + $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 140 | + // Add thumbnail and permalink to filler posts |
|
| 141 | + $filler_response = array(); |
|
| 142 | + foreach ( $filler_posts as $post_obj ) { |
|
| 143 | + $product = wc_get_product( $post_obj->ID ); |
|
| 144 | + $filler_response[] = array( |
|
| 145 | + 'product' => array( |
|
| 146 | + 'id' => $post_obj->ID, |
|
| 147 | + 'permalink' => get_permalink( $post_obj->ID ), |
|
| 148 | + 'title' => $post_obj->post_title, |
|
| 149 | + 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
| 150 | + 'regular_price' => $product->get_regular_price(), |
|
| 151 | + 'sale_price' => $product->get_sale_price(), |
|
| 152 | + 'price' => $product->get_price(), |
|
| 153 | + 'currency_symbol' => get_woocommerce_currency_symbol(), |
|
| 154 | + 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
| 155 | + 'average_rating' => $product->get_average_rating(), |
|
| 156 | + 'rating_count' => $product->get_rating_count(), |
|
| 157 | + 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) |
|
| 158 | + ), |
|
| 159 | + 'entity' => array(), |
|
| 160 | + ); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return $filler_response; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | } |
@@ -15,23 +15,23 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | private $sources = array(); |
| 17 | 17 | |
| 18 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
| 18 | + public function __construct($post_id, $alternate_post_type = null) { |
|
| 19 | 19 | |
| 20 | - $post_type = $alternate_post_type ?: get_post_type( $post_id ); |
|
| 20 | + $post_type = $alternate_post_type ?: get_post_type($post_id); |
|
| 21 | 21 | |
| 22 | - if ( $post_type === 'post' || ( is_array( $post_type ) && in_array( 'post', $post_type ) ) ) { |
|
| 22 | + if ($post_type === 'post' || (is_array($post_type) && in_array('post', $post_type))) { |
|
| 23 | 23 | $this->sources = array( |
| 24 | - new Same_Category_Filler_Posts( $post_id ), |
|
| 25 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 24 | + new Same_Category_Filler_Posts($post_id), |
|
| 25 | + new Same_Post_Type_Filler_Posts($post_id), |
|
| 26 | 26 | ); |
| 27 | - } else if ( $post_type === 'product' || ( is_array( $post_type ) && in_array( 'product', $post_type ) ) ) { |
|
| 27 | + } else if ($post_type === 'product' || (is_array($post_type) && in_array('product', $post_type))) { |
|
| 28 | 28 | $this->sources = array( |
| 29 | - new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
| 30 | - new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
| 29 | + new Same_Post_Type_Same_Category_Posts($post_id, 'product'), |
|
| 30 | + new Same_Post_Type_Filler_Posts($post_id, 'product'), |
|
| 31 | 31 | ); |
| 32 | 32 | } else { |
| 33 | 33 | $this->sources = array( |
| 34 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
| 34 | + new Same_Post_Type_Filler_Posts($post_id), |
|
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -42,22 +42,22 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return array<int> |
| 44 | 44 | */ |
| 45 | - private function extract_post_ids( $posts ) { |
|
| 46 | - return array_map( function ( $post ) { |
|
| 45 | + private function extract_post_ids($posts) { |
|
| 46 | + return array_map(function($post) { |
|
| 47 | 47 | /** |
| 48 | 48 | * @var $post \WP_Post |
| 49 | 49 | */ |
| 50 | 50 | return $post->ID; |
| 51 | - }, $posts ); |
|
| 51 | + }, $posts); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
| 54 | + public function get_filler_posts($filler_count, $post_ids_to_be_excluded) { |
|
| 55 | 55 | |
| 56 | 56 | $filler_posts = array(); |
| 57 | 57 | |
| 58 | - foreach ( $this->sources as $source ) { |
|
| 58 | + foreach ($this->sources as $source) { |
|
| 59 | 59 | |
| 60 | - if ( $filler_count <= 0 ) { |
|
| 60 | + if ($filler_count <= 0) { |
|
| 61 | 61 | break; |
| 62 | 62 | } |
| 63 | 63 | /** |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
| 67 | 67 | $source->filler_count = $filler_count; |
| 68 | 68 | |
| 69 | - $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 70 | - $post_ids = $this->extract_post_ids( $posts ); |
|
| 69 | + $posts = $source->get_posts($filler_count, $post_ids_to_be_excluded); |
|
| 70 | + $post_ids = $this->extract_post_ids($posts); |
|
| 71 | 71 | |
| 72 | 72 | // Update the post ids, filler posts and filler count |
| 73 | - $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
| 74 | - $filler_count = $filler_count - count( $posts ); |
|
| 75 | - $filler_posts = array_merge( $filler_posts, $posts ); |
|
| 73 | + $post_ids_to_be_excluded = array_merge($post_ids_to_be_excluded, $post_ids); |
|
| 74 | + $filler_count = $filler_count - count($posts); |
|
| 75 | + $filler_posts = array_merge($filler_posts, $posts); |
|
| 76 | 76 | } |
| 77 | - $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
| 77 | + $filler_posts = $this->add_additional_properties_to_filler_posts($filler_posts); |
|
| 78 | 78 | |
| 79 | 79 | return $filler_posts; |
| 80 | 80 | |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return array $posts array<\WP_Post> |
| 87 | 87 | */ |
| 88 | - private function add_additional_properties_to_filler_posts( $posts ) { |
|
| 89 | - return array_map( function ( $post ) { |
|
| 90 | - $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
| 91 | - $post->permalink = get_permalink( $post->ID ); |
|
| 92 | - $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
| 88 | + private function add_additional_properties_to_filler_posts($posts) { |
|
| 89 | + return array_map(function($post) { |
|
| 90 | + $post->thumbnail = get_the_post_thumbnail_url($post->ID, 'medium'); |
|
| 91 | + $post->permalink = get_permalink($post->ID); |
|
| 92 | + $post->post_title = html_entity_decode($post->post_title, ENT_QUOTES, 'UTF-8'); |
|
| 93 | 93 | |
| 94 | 94 | return $post; |
| 95 | - }, $posts ); |
|
| 95 | + }, $posts); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -103,19 +103,19 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return array |
| 105 | 105 | */ |
| 106 | - public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 107 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 106 | + public function get_filler_response($filler_count, $post_ids_to_be_excluded) { |
|
| 107 | + $filler_posts = $this->get_filler_posts($filler_count, $post_ids_to_be_excluded); |
|
| 108 | 108 | // Add thumbnail and permalink to filler posts |
| 109 | 109 | $filler_response = array(); |
| 110 | - foreach ( $filler_posts as $post_obj ) { |
|
| 111 | - $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
| 110 | + foreach ($filler_posts as $post_obj) { |
|
| 111 | + $thumbnail = get_the_post_thumbnail_url($post_obj, 'medium'); |
|
| 112 | 112 | $filler_response[] = array( |
| 113 | 113 | 'post' => array( |
| 114 | 114 | 'id' => $post_obj->ID, |
| 115 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
| 116 | - 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
| 115 | + 'permalink' => get_permalink($post_obj->ID), |
|
| 116 | + 'thumbnail' => ($thumbnail) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
| 117 | 117 | 'title' => $post_obj->post_title, |
| 118 | - 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ) |
|
| 118 | + 'srcset' => Srcset_Util::get_srcset($post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET) |
|
| 119 | 119 | ), |
| 120 | 120 | 'entity' => array( |
| 121 | 121 | 'id' => 0 |
@@ -135,26 +135,26 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return array |
| 137 | 137 | */ |
| 138 | - public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
| 139 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
| 138 | + public function get_product_navigator_response($filler_count, $post_ids_to_be_excluded) { |
|
| 139 | + $filler_posts = $this->get_filler_posts($filler_count, $post_ids_to_be_excluded); |
|
| 140 | 140 | // Add thumbnail and permalink to filler posts |
| 141 | 141 | $filler_response = array(); |
| 142 | - foreach ( $filler_posts as $post_obj ) { |
|
| 143 | - $product = wc_get_product( $post_obj->ID ); |
|
| 142 | + foreach ($filler_posts as $post_obj) { |
|
| 143 | + $product = wc_get_product($post_obj->ID); |
|
| 144 | 144 | $filler_response[] = array( |
| 145 | 145 | 'product' => array( |
| 146 | 146 | 'id' => $post_obj->ID, |
| 147 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
| 147 | + 'permalink' => get_permalink($post_obj->ID), |
|
| 148 | 148 | 'title' => $post_obj->post_title, |
| 149 | - 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
| 149 | + 'thumbnail' => get_the_post_thumbnail_url($post_obj->ID, 'medium'), |
|
| 150 | 150 | 'regular_price' => $product->get_regular_price(), |
| 151 | 151 | 'sale_price' => $product->get_sale_price(), |
| 152 | 152 | 'price' => $product->get_price(), |
| 153 | 153 | 'currency_symbol' => get_woocommerce_currency_symbol(), |
| 154 | - 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
| 154 | + 'discount_pc' => ($product->get_sale_price() && ($product->get_regular_price() > 0)) ? round(1 - ($product->get_sale_price() / $product->get_regular_price()), 2) * 100 : 0, |
|
| 155 | 155 | 'average_rating' => $product->get_average_rating(), |
| 156 | 156 | 'rating_count' => $product->get_rating_count(), |
| 157 | - 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ) |
|
| 157 | + 'rating_html' => wc_get_rating_html($product->get_average_rating(), $product->get_rating_count()) |
|
| 158 | 158 | ), |
| 159 | 159 | 'entity' => array(), |
| 160 | 160 | ); |