function Transition_post_status($new_status, $old_status, $post) { if ($this->debug) { add_post_meta($post->ID, c_al2fb_meta_log, date('c') . ' ' . $old_status . '->' . $new_status); } self::Save_post($post->ID); $user_ID = self::Get_user_ID($post); $update = isset($_POST[c_al2fb_action_update]) && sanitize_text_field($_POST[c_al2fb_action_update]); $delete = isset($_POST[c_al2fb_action_delete]) && sanitize_text_field($_POST[c_al2fb_action_delete]); $link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true); // Security check if (self::user_can($user_ID, get_option(c_al2fb_option_min_cap))) { // Add, update or delete link if ($update || $delete || $new_status == 'trash') { if (!empty($link_id) && (self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, false))) { WPAL2Int::Delete_fb_link($post); $link_id = null; } } if (!$delete) { // Check post status if (empty($link_id) && (self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, true)) && $new_status == 'publish' && ($new_status != $old_status || $update || get_post_meta($post->ID, c_al2fb_meta_error, true))) { self::Publish_post($post); } } } }