Commit 6a63f218 authored by Simonas's avatar Simonas

Merge branch 'liv2802_meta_description' into 'dev'

Liv2802 meta description

See merge request !2
parents 80f2e007 2d58587b
......@@ -133,9 +133,33 @@ class JobsImporter
}
}
foreach ($this->primaryTerms as $term => $termKey) {
// Set primary properties
if (is_plugin_active('wordpress-seo/wp-seo.php')) {
update_post_meta($podId, "_yoast_wpseo_primary_{$term}", $termKey);
foreach ($this->primaryTerms as $term => $termKey) {
update_post_meta($podId, "_yoast_wpseo_primary_{$term}", $termKey);
}
}
$this->addSeoProperties($ad, $podId);
}
}
/**
* Add SEO properties for ad
* @uses Yoast SEO plugin
*
* @param $ad
* @param $postId
*/
private function addSeoProperties($ad, $postId)
{
if (is_plugin_active('wordpress-seo/wp-seo.php')) {
foreach ($ad['seo_properties'] as $key => $item) {
update_post_meta($postId, '_yoast_wpseo_' . $key, $item);
}
}
}
......@@ -390,4 +414,25 @@ class JobsImporter
}
private function add_to_yoast_seo($post_id, $metatitle, $metadesc, $metakeywords){
$ret = false;
// Include plugin library to check if Yoast Seo is presently active
include_once( ABSPATH.'panel/includes/plugin.php' );
if(is_plugin_active('wordpress-seo/wp-seo.php')) {
//plugin is activated
$updated_title = update_post_meta($post_id, '_yoast_wpseo_title', $metatitle);
$updated_desc = update_post_meta($post_id, '_yoast_wpseo_metadesc', $metadesc);
$updated_kw = update_post_meta($post_id, '_yoast_wpseo_metakeywords', $metakeywords);
if($updated_title && $updated_desc && $updated_kw){
$ret = true;
}
}
return $ret;
}
}
......@@ -49,6 +49,10 @@ class JsonDataCollector
],
];
protected $seoProperties = [
'metadesc' => 'seo_description'
];
// Custom posts data map
protected $posts = [
'division' => [
......@@ -130,6 +134,7 @@ class JsonDataCollector
$item['terms'] = $this->getTerms($ad);
$item['posts'] = $this->getPosts($ad);
$item['relations'] = $this->relationsMap;
$item['seo_properties'] = $this->getSeoProperties($ad);
$result[] = $item;
};
......@@ -151,6 +156,20 @@ class JsonDataCollector
return $result;
}
private function getSeoProperties($ad)
{
$result = [];
foreach ($this->seoProperties as $propertyKey => $propertyValue) {
if (isset($ad->{$propertyValue})) {
$dataValue = $ad->{$propertyValue};
}
$result[$propertyKey] = $this->getValue($dataValue);
}
return $result;
}
private function getTerms($ad)
{
$result = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment