/** * */ public static function transition_post_status($new, $old, $post) { if ($new != 'publish') { return false; } $bridgy = static::save_post($post->ID, $post); $options = get_option('bridgy_options'); if ($options['shortlinks'] == 1) { $url = wp_get_shortlink($post->ID); } else { $url = get_permalink($post->ID); } if (!empty($bridgy)) { foreach ($bridgy as $key => $value) { $response = send_webmention($url, "https://brid.gy/publish/{$key}", $post->ID); $response_code = wp_remote_retrieve_response_code($response); $json = json_decode($response['body']); if ($response_code == 200) { static::debug('Bridgy did the magic and responded: ' . $json->url, 5); static::add_syndication($post->ID, $json->url); } else { static::debug('Bridgy said something is wrong: ' . $json->error, 4); } } } }
public static function publish($ID, $post = null) { $cites = get_post_meta($ID, 'mf2_cite', true); if (empty($cites)) { return; } if (isset($cites['url'])) { send_webmention(get_permalink($ID), $cites['url']); if (WP_DEBUG) { error_log('WEBMENTION CALLED' . get_permalink($ID) . ' : ' . $cites['url']); } } else { foreach ($cites as $cite) { if (!empty($cite) && isset($cite['url'])) { send_webmention(get_permalink($ID), $cite['url']); if (WP_DEBUG) { error_log('WEBMENTIONS CALLED' . get_permalink($ID) . ' : ' . $cite['url']); } } } } }