_title_maxlength = (int)$metas->og_title_maxlength;
$this->_description_maxlength = (int)$metas->og_description_maxlength;
//Get all the patterns
$this->_patterns = SQ_Classes_Helpers_Tools::getOption('patterns');
//For post types who are not in automation, add the custom patterns
if (!isset($this->_patterns[$this->_post->post_type])) {
$this->_patterns[$this->_post->post_type] = $this->_patterns['custom'];
}
if (!SQ_Classes_Helpers_Tools::getOption('sq_auto_pattern') ||
isset($patterns[$this->_post->post_type]['do_pattern']) && !$this->_patterns[$this->_post->post_type]['do_pattern']) {
$this->_loadpatterns = false;
}
if ($this->_loadpatterns && ($this->_post->sq_adm->og_title == '' || $this->_post->sq_adm->og_description == '')) {
$this->_pattern = true;
}
$this->_og_title = ($this->_post->sq->og_title <> '' ? $this->_post->sq->og_title : SQ_Classes_Helpers_Sanitize::truncate($this->_post->sq->title, self::TITLE_MINLENGTH, $this->_post->sq->og_title_maxlength));
$this->_og_description = ($this->_post->sq->og_description <> '' ? $this->_post->sq->og_description : SQ_Classes_Helpers_Sanitize::truncate($this->_post->sq->description, self::DESCRIPTION_MINLENGTH, $this->_post->sq->og_description_maxlength));
$this->_og_media = $this->_post->sq->og_media;
if ($this->_og_media == '') {
$images = SQ_Classes_ObjController::getNewClass('SQ_Models_Services_OpenGraph')->getPostImages();
if (!empty($images)) {
$image = current($images);
if (isset($image['src'])) {
$this->_og_media = $image['src'];
}
}
}
}
public function setTasks($tasks) {
parent::setTasks($tasks);
$this->_tasks[$this->_category] = array(
'title_empty' => array(
'title' => __("OG title not empty", _SQ_PLUGIN_NAME_),
'value' => $this->_og_title,
'description' => sprintf(__('You need to have an Open Graph title for this post. %s It will help you control the way your post looks when people share this URL to Facebook, LinkedIN and other social networks. %s It\'s also important for SEO purposes.', _SQ_PLUGIN_NAME_), '
', '
'),
),
'title_length' => array(
'title' => sprintf(__("OG title up to %s chars", _SQ_PLUGIN_NAME_), $this->_title_maxlength),
'value' => strlen($this->_og_title) . ' ' . __('chars', _SQ_PLUGIN_NAME_),
'description' => sprintf(__("Title has to be longer than %s chars and up to %s chars. %s You can change the title max length from %sSEO Settings > Automation%s.", _SQ_PLUGIN_NAME_), self::TITLE_MINLENGTH, $this->_title_maxlength, '
', '', ''),
),
'description_empty' => array(
'title' => __("OG description not empty", _SQ_PLUGIN_NAME_),
'value' => $this->_og_description,
'description' => sprintf(__('You need to have an Open Graph description for this post. %s It will help you control the way your post looks when people share this URL to Facebook, LinkedIN and other social networks. %s It\'s also important for SEO purposes.', _SQ_PLUGIN_NAME_), '
', '
'),
),
'description_length' => array(
'title' => sprintf(__("OG description up to %s chars", _SQ_PLUGIN_NAME_), $this->_description_maxlength),
'value' => strlen($this->_og_description) . ' ' . __('chars', _SQ_PLUGIN_NAME_),
'description' => sprintf(__("Description has to be longer than %s chars and up to %s chars. %s You can change the description max length from %sSEO Settings > Automation%s.", _SQ_PLUGIN_NAME_), self::DESCRIPTION_MINLENGTH, $this->_description_maxlength, '
', '', ''),
),
'image' => array(
'title' => __("OG Image", _SQ_PLUGIN_NAME_),
'value' => ($this->_post->sq->og_media <> '' ? $this->_post->sq->og_media : ($this->_post->post_attachment <> '' ? __('(featured image)', _SQ_PLUGIN_NAME_) . ' ' . $this->_post->post_attachment : '')),
'description' => sprintf(__("Set a good looking image for your URL. It needs to look good in Facebook and LinkedIN feeds when people will share this URL. %s A great image will attract more clicks to your site.", _SQ_PLUGIN_NAME_), '
'),
),
);
}
/**
* Return the Category Tile
* @param $title
* @return string
*/
public function getTitle($title) {
if ($this->_error) {
return __("Open Graph is deactivated.", _SQ_PLUGIN_NAME_);
}
foreach ($this->_tasks[$this->_category] as $task) {
if ($task['completed'] === false) {
return __("Open Graph is not set correctly.", _SQ_PLUGIN_NAME_);
}
}
if ($this->_pattern) {
return __("Open Graph is generated automatically.", _SQ_PLUGIN_NAME_);
}
return __("Open Graph is customized and set correctly.", _SQ_PLUGIN_NAME_);
}
/**
* Show Current Post
* @return string
*/
public function getHeader() {
$header = '