fix WSP-65
This commit is contained in:
@@ -157,8 +157,17 @@ if ($obj['type'] == 'text') {
|
||||
|
||||
/* save featured media */
|
||||
if ($obj['associations']['featuremedia'] && $obj['associations']['featuremedia']['type'] == 'picture') {
|
||||
$filenameQ = explode("/", $obj['associations']['featuremedia']['renditions']['original']['media']);
|
||||
$filename = $filenameQ[count($filenameQ) - 1];
|
||||
|
||||
$fileExist = $wpdb->get_row("SELECT meta_id, post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_wp_attached_file' AND meta_value LIKE '%" . wp_strip_all_tags($filename) . "'");
|
||||
|
||||
if ($fileExist) {
|
||||
set_post_thumbnail($post_ID, $fileExist->post_id);
|
||||
} else {
|
||||
saveAttachment($obj['associations']['featuremedia'], $post_ID);
|
||||
}
|
||||
}
|
||||
} elseif ($obj['pubstatus'] == 'canceled') {
|
||||
/* remove article */
|
||||
$guid = wp_strip_all_tags($obj['guid']);
|
||||
|
||||
3
mvp.php
3
mvp.php
@@ -84,7 +84,8 @@ function generatePassword() {
|
||||
|
||||
function saveAttachment($picture, $post_ID) {
|
||||
$filenameQ = explode("/", $picture['renditions']['original']['media']);
|
||||
$filename = $filenameQ[1];
|
||||
$filename = $filenameQ[count($filenameQ) - 1];
|
||||
|
||||
saveFile($picture['renditions']['original']['href'], wp_upload_dir()['path'] . "/" . $filename);
|
||||
|
||||
$attachment = array(
|
||||
|
||||
Reference in New Issue
Block a user