posts)) {
foreach ($json->posts as $post_id => $row) {
if (isset($row->error_message) && $row->error_message <> '') {
$response[$post_id] = '' . $row->error_message . '';
continue;
}
if (isset($row->optimized) && (int)$row->optimized > 0) {
$html = '';
$html .= '
' . $row->keyword . '
';
} else {
$html = '' . __('Optimize it with Squirrly Live Assistant', _SQ_PLUGIN_NAME_) . '';
}
$response[$post_id] = $html;
}
}
return $response;
}
/**
* Show SEO Button
*
* @param int $post_id
* @param string $post_type
* @return string
*/
public function getPostButton($post_id = 0, $post_type = 'post') {
$button = '';
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet($post_id, 0, '', $post_type)) {
$post = SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->parsePage($post)->getPage();
$post->tasks_completed = ($post->tasks_completed ? $post->tasks_completed : 1);
$completed = number_format(($post->tasks_completed * 100) / $post->tasks, 0);
$title = __('Snippet optimized:', _SQ_PLUGIN_NAME_) . ' ' . $completed . '%. ' . ($post->tasks - $post->tasks_completed) . ' ' . __('task(s) remained.', _SQ_PLUGIN_NAME_);
$button .= '';
} else {
$button .= '';
}
$button .= '' . __('Edit Snippet', _SQ_PLUGIN_NAME_) . '';
return $button;
}
/**
* Show SEO Button
*
* @param int $term_id
* @param string $taxonomy
* @return string
*/
public function getTaxButton($term_id = 0, $taxonomy = 'post') {
$button = '';
if ($post = SQ_Classes_ObjController::getClass('SQ_Models_Snippet')->getCurrentSnippet(0, $term_id, str_replace('tax-', '', $taxonomy), '')) {
$post = SQ_Classes_ObjController::getClass('SQ_Models_BulkSeo')->parsePage($post)->getPage();
$post->tasks_completed = ($post->tasks_completed ? $post->tasks_completed : 1);
$completed = number_format(($post->tasks_completed * 100) / $post->tasks, 0);
$title = __('Snippet optimized:', _SQ_PLUGIN_NAME_) . ' ' . $completed . '%. ' . ($post->tasks - $post->tasks_completed) . ' ' . __('task(s) remained.', _SQ_PLUGIN_NAME_);
$button .= '';
} else {
$button .= '';
}
$button .= '' . __('Edit Snippet', _SQ_PLUGIN_NAME_) . '';
return $button;
}
public function hookUpdateStatus($post_id) {
if ($post_id > 0) {
$status = get_post_status($post_id);
$args = array();
$args['status'] = ($status ? $status : 'deleted');
$args['post_id'] = $post_id;
SQ_Classes_RemoteController::updatePost($args);
}
}
}