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
2c715598
Commit
2c715598
authored
Apr 16, 2019
by
Andrius Mickus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add seo description to Yoast meta desc
parent
80f2e007
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
JobsImporter.php
wp-content/plugins/jobs-importer/JobsImporter.php
+47
-2
JsonDataCollector.php
wp-content/plugins/jobs-importer/JsonDataCollector.php
+19
-0
jobs-importer.php
wp-content/plugins/jobs-importer/jobs-importer.php
+1
-1
No files found.
wp-content/plugins/jobs-importer/JobsImporter.php
View file @
2c715598
...
@@ -133,9 +133,33 @@ class JobsImporter
...
@@ -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
...
@@ -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 @
2c715598
...
@@ -49,6 +49,10 @@ class JsonDataCollector
...
@@ -49,6 +49,10 @@ class JsonDataCollector
],
],
];
];
protected
$seoProperties
=
[
'metadesc'
=>
'seo_description'
];
// Custom posts data map
// Custom posts data map
protected
$posts
=
[
protected
$posts
=
[
'division'
=>
[
'division'
=>
[
...
@@ -130,6 +134,7 @@ class JsonDataCollector
...
@@ -130,6 +134,7 @@ class JsonDataCollector
$item
[
'terms'
]
=
$this
->
getTerms
(
$ad
);
$item
[
'terms'
]
=
$this
->
getTerms
(
$ad
);
$item
[
'posts'
]
=
$this
->
getPosts
(
$ad
);
$item
[
'posts'
]
=
$this
->
getPosts
(
$ad
);
$item
[
'relations'
]
=
$this
->
relationsMap
;
$item
[
'relations'
]
=
$this
->
relationsMap
;
$item
[
'seo_properties'
]
=
$this
->
getSeoProperties
(
$ad
);
$result
[]
=
$item
;
$result
[]
=
$item
;
};
};
...
@@ -151,6 +156,20 @@ class JsonDataCollector
...
@@ -151,6 +156,20 @@ class JsonDataCollector
return
$result
;
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
)
private
function
getTerms
(
$ad
)
{
{
$result
=
[];
$result
=
[];
...
...
wp-content/plugins/jobs-importer/jobs-importer.php
View file @
2c715598
...
@@ -72,7 +72,7 @@ function do_import()
...
@@ -72,7 +72,7 @@ function do_import()
// pll_the_languages( array( 'dropdown' => 1 ) );
// pll_the_languages( array( 'dropdown' => 1 ) );
// exit();
// exit();
// }
// }
print_r
(
"Data source:
$inputFile
<br><br>"
);
print_r
(
"Data source:
$inputFile
<br><br>"
);
// JSON reader
// JSON reader
...
...
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