Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Syndication
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
Syndication
Commits
d82c7985
Commit
d82c7985
authored
11 years ago
by
Mohammad Jangda
Browse files
Options
Downloads
Plain Diff
Merge pull request #39 from andreybrokeit/featured-image-sync
Add Featured Image Data Syndication
parents
366ec854
f7bda2b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/class-syndication-wp-xmlrpc-client.php
+45
-14
45 additions, 14 deletions
includes/class-syndication-wp-xmlrpc-client.php
with
45 additions
and
14 deletions
includes/class-syndication-wp-xmlrpc-client.php
+
45
−
14
View file @
d82c7985
...
...
@@ -40,6 +40,7 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
}
function
post_push_send_thumbnail
(
$remote_post_id
,
$post_id
)
{
$thumbnail_meta_keys
=
$this
->
get_thumbnail_meta_keys
(
$post_id
);
foreach
(
$thumbnail_meta_keys
as
$thumbnail_meta
)
{
...
...
@@ -47,8 +48,9 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
$syn_local_meta_key
=
'_syn_push_thumb_'
.
$thumbnail_meta
;
$syndicated_thumbnails_by_site
=
get_post_meta
(
$post_id
,
$syn_local_meta_key
,
true
);
if
(
!
is_array
(
$syndicated_thumbnails_by_site
)
)
if
(
!
is_array
(
$syndicated_thumbnails_by_site
)
)
{
$syndicated_thumbnails_by_site
=
array
();
}
$syndicated_thumbnail_id
=
isset
(
$syndicated_thumbnails_by_site
[
$this
->
site_ID
]
)
?
$syndicated_thumbnails_by_site
[
$this
->
site_ID
]
:
false
;
...
...
@@ -70,11 +72,16 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
continue
;
}
if
(
$syndicated_thumbnail_id
==
$thumbnail_id
)
if
(
$syndicated_thumbnail_id
==
$thumbnail_id
)
{
continue
;
}
list
(
$thumbnail_url
)
=
wp_get_attachment_image_src
(
$thumbnail_id
,
'full'
);
//pass thumbnail data and meta into the addThumnail to sync caption, description and alt-text
//has to be this way since mw_newMediaObject doesn't allow to pass description and caption along
$thumbnail_post_data
=
get_post
(
$thumbnail_id
);
$thumbnail_alt_text
=
get_post_meta
(
$thumbnail_id
,
'_wp_attachment_image_alt'
,
true
);
$result
=
$this
->
query
(
'syndication.addThumbnail'
,
'1'
,
...
...
@@ -82,7 +89,9 @@ class Syndication_WP_XMLRPC_Client extends WP_HTTP_IXR_Client implements Syndica
$this
->
password
,
$remote_post_id
,
$thumbnail_url
,
$thumbnail_meta
$thumbnail_meta
,
$thumbnail_post_data
,
$thumbnail_alt_text
);
if
(
$result
)
{
...
...
@@ -424,12 +433,14 @@ class Syndication_WP_XMLRPC_Client_Extensions {
$wp_xmlrpc_server
->
escape
(
$args
);
$blog_id
=
(
int
)
$args
[
0
];
$username
=
$args
[
1
];
$password
=
$args
[
2
];
$post_ID
=
(
int
)
$args
[
3
];
$thumbnail_url
=
esc_url_raw
(
$args
[
4
]
);
$meta_key
=
!
empty
(
$args
[
5
]
)
?
sanitize_text_field
(
$args
[
5
]
)
:
'_thumbnail_id'
;
$blog_id
=
(
int
)
$args
[
0
];
$username
=
$args
[
1
];
$password
=
$args
[
2
];
$post_ID
=
(
int
)
$args
[
3
];
$thumbnail_url
=
esc_url_raw
(
$args
[
4
]
);
$meta_key
=
!
empty
(
$args
[
5
]
)
?
sanitize_text_field
(
$args
[
5
]
)
:
'_thumbnail_id'
;
$thumbnail_post_data
=
$args
[
6
];
$thumbnail_alt_text
=
$args
[
7
];
if
(
!
$post_ID
)
return
new
IXR_Error
(
500
,
__
(
'Please specify a valid post_ID.'
,
'syndication'
)
);
...
...
@@ -446,9 +457,9 @@ class Syndication_WP_XMLRPC_Client_Extensions {
$username
,
$password
,
array
(
'name'
=>
$thumbnail_filename
,
'type'
=>
$thumbnail_type
[
'type'
],
'bits'
=>
$thumbnail_raw
,
'name'
=>
$thumbnail_filename
,
'type'
=>
$thumbnail_type
[
'type'
],
'bits'
=>
$thumbnail_raw
,
'overwrite'
=>
false
,
),
);
...
...
@@ -470,6 +481,26 @@ class Syndication_WP_XMLRPC_Client_Extensions {
if
(
!
$thumbnail_set
)
return
new
IXR_Error
(
403
,
__
(
'Could not attach post thumbnail.'
)
);
$args
=
array
(
$blog_id
,
$username
,
$password
,
$thumbnail_id
,
array
(
'post_title'
=>
$thumbnail_post_data
[
'post_title'
],
'post_content'
=>
$thumbnail_post_data
[
'post_content'
],
'post_excerpt'
=>
$thumbnail_post_data
[
'post_excerpt'
],
),
);
//update caption and description of the image
$result
=
$wp_xmlrpc_server
->
wp_editPost
(
$args
);
if
(
$result
!==
true
)
{
//failed to update atatchment post details
//handle it th way you want it (log it, message it)
}
//update alt text of the image
update_post_meta
(
$thumbnail_id
,
'_wp_attachment_image_alt'
,
$thumbnail_alt_text
);
return
$thumbnail_id
;
}
...
...
@@ -482,7 +513,7 @@ class Syndication_WP_XMLRPC_Client_Extensions {
$blog_id
=
(
int
)
$args
[
0
];
$username
=
$args
[
1
];
$password
=
$args
[
2
];
$post_ID
=
(
int
)
$args
[
3
];
$post_ID
=
(
int
)
$args
[
3
];
$meta_key
=
!
empty
(
$args
[
4
]
)
?
sanitize_text_field
(
$args
[
4
]
)
:
'_thumbnail_id'
;
if
(
!
$user
=
$wp_xmlrpc_server
->
login
(
$username
,
$password
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment