Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Danny Froberg
steempress_amn
Commits
ab5ed170
Commit
ab5ed170
authored
Nov 04, 2018
by
Martin Lees
Browse files
Added the Update to steem checkbox
parent
6f1f6813
Changes
2
Hide whitespace changes
Inline
Side-by-side
admin/class-steempress_sp-admin.php
View file @
ab5ed170
...
...
@@ -389,15 +389,17 @@ class Steempress_sp_Admin {
{
// New post
if
(
$new_status
==
'publish'
&&
$old_status
!=
'publish'
&&
$post
->
post_type
==
'post'
)
{
if
(
!
isset
(
$_POST
[
'Steempress_sp_steem_publish'
])
&&
isset
(
$_POST
[
'Steempress_sp_steem_do_not_publish'
])
)
{
if
(
!
isset
(
$_POST
[
'Steempress_sp_steem_publish'
])
&&
isset
(
$_POST
[
'Steempress_sp_steem_do_not_publish'
])
)
return
;
}
else
{
$value
=
get_post_meta
(
$post
->
ID
,
'Steempress_sp_steem_publish'
,
true
);
if
(
$value
!=
"0"
)
$this
->
Steempress_sp_publish
(
$post
->
ID
);
}
$value
=
get_post_meta
(
$post
->
ID
,
'Steempress_sp_steem_publish'
,
true
);
if
(
$value
!=
"0"
)
$this
->
Steempress_sp_publish
(
$post
->
ID
);
// Edited post
}
else
if
(
$new_status
==
'publish'
&&
$old_status
==
'publish'
&&
$post
->
post_type
==
'post'
)
{
if
(
!
isset
(
$_POST
[
'Steempress_sp_steem_update'
])
&&
isset
(
$_POST
[
'Steempress_sp_steem_do_not_update'
])
)
return
;
$this
->
steempress_sp_update
(
$post
->
ID
);
}
return
;
...
...
@@ -432,26 +434,55 @@ class Steempress_sp_Admin {
<?php
}
function
saveSteemPublishField
(
$post_id
)
function
create_update_checkbox
(
)
{
if
(
defined
(
'DOING_AUTOSAVE'
)
&&
DOING_AUTOSAVE
)
{
$post_id
=
get_the_ID
();
if
(
get_post_type
(
$post_id
)
!=
'post'
)
{
return
;
}
if
(
!
isset
(
$_POST
[
'Steempress_sp_custom_nonce'
])
||
!
wp_verify_nonce
(
$_POST
[
'Steempress_sp_custom_nonce'
],
'Steempress_sp_custom_nonce_'
.
$post_id
)
)
{
if
(
get_post_status
(
$post_id
)
!=
'publish'
)
return
;
}
if
(
!
current_user_can
(
'edit_post'
,
$post_id
))
{
wp_nonce_field
(
'Steempress_sp_custom_update_nonce_'
.
$post_id
,
'Steempress_sp_custom_update_nonce'
);
$value
=
get_post_meta
(
$post_id
,
'Steempress_sp_steem_update'
,
true
);
if
(
$value
==
"0"
)
$checked
=
""
;
else
$checked
=
"checked"
;
?>
<div
class=
"misc-pub-section misc-pub-section-last"
>
<label><input
type=
"checkbox"
value=
"1"
<?php
echo
$checked
;
?>
name=
"Steempress_sp_steem_update"
/>
<input
type=
"hidden"
name=
"Steempress_sp_steem_do_not_update"
value=
"0"
/>
Update to steem
</label>
</div>
<?php
}
function
saveSteemPublishField
(
$post_id
)
{
if
(
defined
(
'DOING_AUTOSAVE'
)
&&
DOING_AUTOSAVE
)
return
;
}
if
(
isset
(
$_POST
[
'Steempress_sp_steem_publish'
]))
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_publish'
,
$_POST
[
'Steempress_sp_steem_publish'
]);
if
((
!
isset
(
$_POST
[
'Steempress_sp_custom_nonce'
])
||
!
wp_verify_nonce
(
$_POST
[
'Steempress_sp_custom_nonce'
],
'Steempress_sp_custom_nonce_'
.
$post_id
))
&&
(
!
isset
(
$_POST
[
'Steempress_sp_custom_update_nonce'
])
||
!
wp_verify_nonce
(
$_POST
[
'Steempress_sp_custom_update_nonce'
],
'Steempress_sp_custom_update_nonce_'
.
$post_id
)))
return
;
if
(
!
current_user_can
(
'edit_post'
,
$post_id
))
return
;
if
(
get_post_status
(
$post_id
)
!=
'publish'
)
{
if
(
isset
(
$_POST
[
'Steempress_sp_steem_publish'
]))
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_publish'
,
$_POST
[
'Steempress_sp_steem_publish'
]);
}
else
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_publish'
,
'0'
);
}
}
else
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_publish'
,
'0'
);
if
(
isset
(
$_POST
[
'Steempress_sp_steem_update'
]))
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_update'
,
$_POST
[
'Steempress_sp_steem_update'
]);
}
else
{
update_post_meta
(
$post_id
,
'Steempress_sp_steem_update'
,
'0'
);
}
}
}
...
...
includes/class-steempress_sp.php
View file @
ab5ed170
...
...
@@ -176,6 +176,7 @@ class Steempress_sp {
$this
->
loader
->
add_action
(
'post_submitbox_misc_actions'
,
$plugin_admin
,
'createSteemPublishField'
);
$this
->
loader
->
add_action
(
'post_submitbox_misc_actions'
,
$plugin_admin
,
'create_update_checkbox'
);
$this
->
loader
->
add_action
(
'save_post'
,
$plugin_admin
,
'saveSteemPublishField'
,
8
);
$this
->
loader
->
add_action
(
'add_meta_boxes'
,
$plugin_admin
,
'steempress_sp_add_custom_box'
);
$this
->
loader
->
add_action
(
'save_post'
,
$plugin_admin
,
'steempress_sp_save_post_data'
);
...
...
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