Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dev.biuro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Biuro
dev.biuro
Commits
6a63f218
Commit
6a63f218
authored
Apr 17, 2019
by
Simonas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'liv2802_meta_description' into 'dev'
Liv2802 meta description See merge request
!2
parents
80f2e007
2d58587b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
JobsImporter.php
wp-content/plugins/jobs-importer/JobsImporter.php
+47
-2
JsonDataCollector.php
wp-content/plugins/jobs-importer/JsonDataCollector.php
+19
-0
No files found.
wp-content/plugins/jobs-importer/JobsImporter.php
View file @
6a63f218
...
...
@@ -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
;
}
}
wp-content/plugins/jobs-importer/JsonDataCollector.php
View file @
6a63f218
...
...
@@ -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
=
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment