wordpress publish hook was called before the meta storage hook so the plugin would only work on edited posts. This may be a wordpress version issue because you'd think somebody would've noticed it before.
This commit is contained in:
parent
c63a18a250
commit
2b47d36a11
@ -58,6 +58,13 @@ function post_to_red_post($post_id) {
|
|||||||
|
|
||||||
$post = get_post($post_id);
|
$post = get_post($post_id);
|
||||||
|
|
||||||
|
if (isset($_POST['post_to_red'])) {
|
||||||
|
update_post_meta($post_id, 'post_to_red', 1);
|
||||||
|
} else {
|
||||||
|
update_post_meta($post_id, 'post_to_red', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// if meta has been set
|
// if meta has been set
|
||||||
if (get_post_meta($post_id, "post_to_red", true) == 1) {
|
if (get_post_meta($post_id, "post_to_red", true) == 1) {
|
||||||
|
|
||||||
@ -80,7 +87,7 @@ function post_to_red_post($post_id) {
|
|||||||
|
|
||||||
$message_namespace = 'wordpress';
|
$message_namespace = 'wordpress';
|
||||||
|
|
||||||
$message_id = $site_url() . '/' . $post_id;
|
$message_id = site_url() . '/' . $post_id;
|
||||||
|
|
||||||
$message = $post->post_title . "<br /><br />" . $message;
|
$message = $post->post_title . "<br /><br />" . $message;
|
||||||
|
|
||||||
@ -148,6 +155,7 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function post_to_red_post_checkbox() {
|
function post_to_red_post_checkbox() {
|
||||||
|
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
'post_to_red_meta_box_id',
|
'post_to_red_meta_box_id',
|
||||||
'Cross Post to Red Matrix',
|
'Cross Post to Red Matrix',
|
||||||
@ -170,8 +178,9 @@ function post_to_red_post_field_data($post_id) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// security check
|
// security check
|
||||||
// if (!wp_verify_nonce( $_POST['post_to_red_nonce'], plugin_basename( __FILE__ )))
|
if((! array_key_exists('post_to_red_nonce', $_POST))
|
||||||
// return;
|
|| (!wp_verify_nonce( $_POST['post_to_red_nonce'], plugin_basename( __FILE__ ))))
|
||||||
|
return;
|
||||||
|
|
||||||
// now store data in custom fields based on checkboxes selected
|
// now store data in custom fields based on checkboxes selected
|
||||||
if (isset($_POST['post_to_red'])) {
|
if (isset($_POST['post_to_red'])) {
|
||||||
|
Reference in New Issue
Block a user