Skip to content

Commit

Permalink
bugfix commenst
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome committed Dec 22, 2018
1 parent db4edf4 commit e9b8be7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Controller/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function redirect()
public function preGetPosts( $query )
{
if( !$query->is_main_query() || is_admin() )
return;
return $query;

global $wp_query;

Expand Down
24 changes: 16 additions & 8 deletions src/Traits/ContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function addSite()
'language' => $blog_language,
'languages' => $languages,
'is_admin' => current_user_can('manage_options'),
'home_url' => home_url(),
'home_url' => home_url('/'),
'search_url' => get_search_link(),
'privacy_policy_url' => get_privacy_policy_url(),
'maintenance_mode' => wp_maintenance_mode()
Expand Down Expand Up @@ -484,7 +484,7 @@ public function addBreadcrumb($data=[], $add_current=true, $add_home=true)
$breadcrumb = [];

if( $add_home )
$breadcrumb[] = ['title' => __('Home'), 'link' => get_home_url()];
$breadcrumb[] = ['title' => __('Home'), 'link' => home_url('/')];

$breadcrumb = array_merge($breadcrumb, $data);

Expand Down Expand Up @@ -521,8 +521,8 @@ public function addComments($args=[], $key='comments')
{
$args['fields'] = 'ids';

if( !isset($args['include_unapproved']))
$args['include_unapproved'] = false;
if( !isset($args['status']))
$args['status'] = 'approve';

if( !isset($args['number']))
$args['number'] = 5;
Expand All @@ -545,17 +545,25 @@ public function addComments($args=[], $key='comments')
}
}

$comments_count = wp_count_comments(isset($args['post_id'])?$args['post_id']:0 );

if( isset($this->data['post']))
{
if( is_array($this->data['post']) )
if( is_array($this->data['post']) ){
$this->data['post'][$key] = $comments;
else
$this->data['post']['comments_count'] = $comments_count;
}
else{
$this->data['post']->$key = $comments;
$this->data['post']->comments_count = $comments_count;
}
}
else{

else
$this->data[$key] = $comments;

$this->data['comments_count'] = $comments_count;
}

return $comments;
}
}

0 comments on commit e9b8be7

Please sign in to comment.