&tag(WordPress/SNSCountCache);
if ( $posts_query->have_posts() ) {
while ( $posts_query->have_posts() ) {
$posts_query->the_post();
$post_id = get_the_ID();
foreach ( $this->target_sns as $sns => $active ) {
$meta_key = $this->get_cache_key( $sns );
if ( $active ) {
update_post_meta( $post_id, $meta_key, (int) -1 );
}
}
}
}
update_option( self::DB_SETTINGS, $settings );
$this->reactivate_plugin();
$url = self::DEF_BASE_URL . '?id='. rawurlencode($this->query_parameters['id']) . '&fields=og_object{engagement},engagement&access_token=' . $this->query_parameters['access_token']; if ( isset( $content['data'] ) && empty( $content['error'] ) ) {
$json = json_decode( $content['data'], true );
// if ( isset( $json['share']['share_count'] ) && is_numeric( $json['share']['share_count'] ) ) {
// $count = (int) $json['share']['share_count'];
// } elseif ( isset( $json['id'] ) && ! isset( $json['share']['share_count'] ) ) {
// $count = (int) 0;
// } else {
// $count = (int) -1;
// }
$reaction = (int) $json['engagement']['reaction_count'];
$comment_count = (int) $json['engagement']['comment_count'];
$share_count = (int) $json['engagement']['share_count'];
$count = $reaction + $comment_count + $share_count;
} else {
$count = (int) -1;
}
/**
* Get cache expiration based on current number of total post and page
*
* @since 0.1.1
*/
protected function get_cache_expiration() {
SCC_Common_Util::log( '[' . __METHOD__ . '] (line='. __LINE__ . ')' );
$posts_total = $this->get_posts_total();
SCC_Common_Util::log( '[' . __METHOD__ . '] posts_total: ' . $posts_total );
return ceil( $posts_total / $this->posts_per_check ) * $this->check_interval * 3;
}