From d1919f0497f4a58d08031e5f5b4d358cf133610b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 10 Nov 2018 16:20:19 +0000 Subject: [PATCH] Added a hook to check if the hook needs to be forked at all --- blogger/blogger.php | 17 ++++++++++ buffer/buffer.php | 17 ++++++++++ diaspora/diaspora.php | 17 ++++++++++ libertree/libertree.php | 46 +++++++++++++++++-------- pumpio/pumpio.php | 38 +++++++++++++++++++++ statusnet/statusnet.php | 43 ++++++++++++++++++++++++ tumblr/tumblr.php | 17 ++++++++++ twitter/twitter.php | 43 ++++++++++++++++++++++++ wppost/wppost.php | 74 ++++++++++++++++++++++++++--------------- 9 files changed, 271 insertions(+), 41 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index 496a47c8..84594f42 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -17,6 +17,7 @@ use Friendica\Util\XML; function blogger_install() { + Addon::registerHook('hook_fork', 'addon/blogger/blogger.php', 'blogger_hook_fork'); Addon::registerHook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local'); Addon::registerHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send'); Addon::registerHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets'); @@ -26,6 +27,7 @@ function blogger_install() function blogger_uninstall() { + Addon::unregisterHook('hook_fork', 'addon/blogger/blogger.php', 'blogger_hook_fork'); Addon::unregisterHook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local'); Addon::unregisterHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send'); Addon::unregisterHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets'); @@ -130,6 +132,21 @@ function blogger_settings_post(App $a, array &$b) } } +function blogger_hook_fork(App &$a, array &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'blogger') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function blogger_post_local(App $a, array &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint diff --git a/buffer/buffer.php b/buffer/buffer.php index d9378cb1..7a62756a 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -23,6 +23,7 @@ use Friendica\Util\Strings; function buffer_install() { + Addon::registerHook('hook_fork', 'addon/buffer/buffer.php', 'buffer_hook_fork'); Addon::registerHook('post_local', 'addon/buffer/buffer.php', 'buffer_post_local'); Addon::registerHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send'); Addon::registerHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets'); @@ -32,6 +33,7 @@ function buffer_install() function buffer_uninstall() { + Addon::unregisterHook('hook_fork', 'addon/buffer/buffer.php', 'buffer_hook_fork'); Addon::unregisterHook('post_local', 'addon/buffer/buffer.php', 'buffer_post_local'); Addon::unregisterHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send'); Addon::unregisterHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets'); @@ -266,6 +268,21 @@ function buffer_post_local(App $a, array &$b) $b['postopts'] .= 'buffer'; } +function buffer_hook_fork(&$a, &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'buffer') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function buffer_send(App $a, array &$b) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { diff --git a/diaspora/diaspora.php b/diaspora/diaspora.php index 03793310..66fa1b72 100644 --- a/diaspora/diaspora.php +++ b/diaspora/diaspora.php @@ -21,6 +21,7 @@ use Friendica\Model\Queue; function diaspora_install() { + Addon::registerHook('hook_fork', 'addon/diaspora/diaspora.php', 'diaspora_hook_fork'); Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local'); Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send'); Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets'); @@ -31,6 +32,7 @@ function diaspora_install() function diaspora_uninstall() { + Addon::unregisterHook('hook_fork', 'addon/diaspora/diaspora.php', 'diaspora_hook_fork'); Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local'); Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send'); Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets'); @@ -253,6 +255,21 @@ function diaspora_settings_post(App $a, &$b) } } +function diaspora_hook_fork(&$a, &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'diaspora') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function diaspora_post_local(App $a, array &$b) { if ($b['edit']) { diff --git a/libertree/libertree.php b/libertree/libertree.php index 0804476c..a7dcce58 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -14,22 +14,25 @@ use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Util\Network; -function libertree_install() { - Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local'); - Addon::registerHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send'); - Addon::registerHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets'); - Addon::registerHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings'); - Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post'); - -} -function libertree_uninstall() { - Addon::unregisterHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local'); - Addon::unregisterHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send'); - Addon::unregisterHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets'); - Addon::unregisterHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings'); - Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post'); +function libertree_install() +{ + Addon::registerHook('hook_fork', 'addon/libertree/libertree.php', 'libertree_hook_fork'); + Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local'); + Addon::registerHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send'); + Addon::registerHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets'); + Addon::registerHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings'); + Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post'); } +function libertree_uninstall() +{ + Addon::unregisterHook('hook_fork', 'addon/libertree/libertree.php', 'libertree_hook_fork'); + Addon::unregisterHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local'); + Addon::unregisterHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send'); + Addon::unregisterHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets'); + Addon::unregisterHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings'); + Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post'); +} function libertree_jot_nets(&$a,&$b) { if(! local_user()) @@ -118,6 +121,21 @@ function libertree_settings_post(&$a,&$b) { } +function libertree_hook_fork(App &$a, array &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'libertree') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function libertree_post_local(&$a,&$b) { // This can probably be changed to allow editing by pointing to a different API endpoint diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 71b5cf15..ebef1a22 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -38,6 +38,7 @@ define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes function pumpio_install() { Addon::registerHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config'); + Addon::registerHook('hook_fork', 'addon/pumpio/pumpio.php', 'hook_fork'); Addon::registerHook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local'); Addon::registerHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send'); Addon::registerHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets'); @@ -51,6 +52,7 @@ function pumpio_install() function pumpio_uninstall() { Addon::unregisterHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config'); + Addon::unregisterHook('hook_fork', 'addon/pumpio/pumpio.php', 'pumpio_hook_fork'); Addon::unregisterHook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local'); Addon::unregisterHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send'); Addon::unregisterHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets'); @@ -381,6 +383,42 @@ function pumpio_load_config(App $a) $a->loadConfigFile(__DIR__. '/config/pumpio.ini.php'); } +function pumpio_hook_fork(App $a, array &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + // Deleting and editing is not supported by the addon (deleting could, but isn't by now) + if ($post['deleted'] || ($post['created'] !== $post['edited'])) { + $b['execute'] = false; + return; + } + + // if post comes from pump.io don't send it back + if ($post['app'] == "pump.io") { + $b['execute'] = false; + return; + } + + if (PConfig::get($post['uid'], 'pumpio', 'import')) { + // Don't fork if it isn't a reply to a pump.io post + if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) { + Logger::log('No pump.io parent found for item ' . $post['id']); + $b['execute'] = false; + return; + } + } else { + // Comments are never exported when we don't import the pumpio timeline + if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['private']) { + $b['execute'] = false; + return; + } + } +} + function pumpio_post_local(App $a, array &$b) { if (!local_user() || (local_user() != $b['uid'])) { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 473ec18c..7fc6d4d3 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -68,6 +68,7 @@ function statusnet_install() Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); Addon::registerHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); Addon::registerHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); + Addon::registerHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork'); Addon::registerHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron'); @@ -81,6 +82,7 @@ function statusnet_uninstall() Addon::unregisterHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings'); Addon::unregisterHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post'); Addon::unregisterHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook'); + Addon::unregisterHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork'); Addon::unregisterHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); Addon::unregisterHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron'); @@ -393,6 +395,47 @@ function statusnet_settings(App $a, &$s) $s .= '
'; } +function statusnet_hook_fork(App $a, array &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + // Deleting and editing is not supported by the addon + if ($post['deleted'] || ($post['created'] !== $post['edited'])) { + $b['execute'] = false; + return; + } + + // if post comes from GNU Social don't send it back + if ($post['extid'] == Protocol::STATUSNET) { + $b['execute'] = false; + return; + } + + if ($post['app'] == 'StatusNet') { + $b['execute'] = false; + return; + } + + if (PConfig::get($post['uid'], 'statusnet', 'import')) { + // Don't fork if it isn't a reply to a GNU Social post + if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::STATUSNET])) { + Logger::log('No GNU Social parent found for item ' . $post['id']); + $b['execute'] = false; + return; + } + } else { + // Comments are never exported when we don't import the GNU Social timeline + if (!strstr($post['postopts'], 'statusnet') || ($post['parent'] != $post['id']) || $post['private']) { + $b['execute'] = false; + return; + } + } +} + function statusnet_post_local(App $a, &$b) { if ($b['edit']) { diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 97ac8bf4..83bdcf6e 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -22,6 +22,7 @@ use Friendica\Util\Strings; function tumblr_install() { + Addon::registerHook('hook_fork', 'addon/tumblr/tumblr.php', 'tumblr_hook_fork'); Addon::registerHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local'); Addon::registerHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send'); Addon::registerHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets'); @@ -31,6 +32,7 @@ function tumblr_install() function tumblr_uninstall() { + Addon::unregisterHook('hook_fork', 'addon/tumblr/tumblr.php', 'tumblr_hook_fork'); Addon::unregisterHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local'); Addon::unregisterHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send'); Addon::unregisterHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets'); @@ -299,6 +301,21 @@ function tumblr_settings_post(App $a, array &$b) } } +function tumblr_hook_fork(&$a, &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'tumblr') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function tumblr_post_local(App $a, array &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint diff --git a/twitter/twitter.php b/twitter/twitter.php index 07c696ab..3e570165 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -103,6 +103,7 @@ function twitter_install() Addon::registerHook('load_config' , __FILE__, 'twitter_load_config'); Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings'); Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post'); + Addon::registerHook('hook_fork' , __FILE__, 'twitter_hook_fork'); Addon::registerHook('post_local' , __FILE__, 'twitter_post_local'); Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook'); Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets'); @@ -120,6 +121,7 @@ function twitter_uninstall() Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config'); Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings'); Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post'); + Addon::unregisterHook('hook_fork' , __FILE__, 'twitter_hook_fork'); Addon::unregisterHook('post_local' , __FILE__, 'twitter_post_local'); Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook'); Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets'); @@ -390,6 +392,47 @@ function twitter_settings(App $a, &$s) $s .= '
'; } +function twitter_hook_fork(App $a, array &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + // Deleting and editing is not supported by the addon (deleting could, but isn't by now) + if ($post['deleted'] || ($post['created'] !== $post['edited'])) { + $b['execute'] = false; + return; + } + + // if post comes from twitter don't send it back + if ($post['extid'] == Protocol::TWITTER) { + $b['execute'] = false; + return; + } + + if ($post['app'] == 'Twitter') { + $b['execute'] = false; + return; + } + + if (PConfig::get($post['uid'], 'twitter', 'import')) { + // Don't fork if it isn't a reply to a twitter post + if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::TWITTER])) { + Logger::log('No twitter parent found for item ' . $post['id']); + $b['execute'] = false; + return; + } + } else { + // Comments are never exported when we don't import the twitter timeline + if (!strstr($post['postopts'], 'twitter') || ($post['parent'] != $post['id']) || $post['private']) { + $b['execute'] = false; + return; + } + } +} + function twitter_post_local(App $a, array &$b) { if ($b['edit']) { diff --git a/wppost/wppost.php b/wppost/wppost.php index 9e226260..2f09a258 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -17,40 +17,45 @@ use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; -function wppost_install() { - Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); - Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); - Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); - Addon::registerHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); - Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); - +function wppost_install() +{ + Addon::registerHook('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork'); + Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); + Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); + Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); + Addon::registerHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); + Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); } -function wppost_uninstall() { - Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); - Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); - Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); - Addon::unregisterHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); - Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); + +function wppost_uninstall() +{ + Addon::unregisterHook('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork'); + Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local'); + Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send'); + Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets'); + Addon::unregisterHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings'); + Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); // obsolete - remove - Addon::unregisterHook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send'); - Addon::unregisterHook('addon_settings', 'addon/wppost/wppost.php', 'wppost_settings'); - Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); - + Addon::unregisterHook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send'); + Addon::unregisterHook('addon_settings', 'addon/wppost/wppost.php', 'wppost_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post'); } -function wppost_jot_nets(&$a,&$b) { - if(! local_user()) - return; +function wppost_jot_nets(&$a, &$b) +{ + if (!local_user()) { + return; + } - $wp_post = PConfig::get(local_user(),'wppost','post'); - if(intval($wp_post) == 1) { - $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default'); - $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : ''); - $b .= '
' - . L10n::t('Post to Wordpress') . '
'; - } + $wp_post = PConfig::get(local_user(), 'wppost', 'post'); + if (intval($wp_post) == 1) { + $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default'); + $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : ''); + $b .= '
' + . L10n::t('Post to Wordpress') . '
'; + } } @@ -159,6 +164,21 @@ function wppost_settings_post(&$a,&$b) { } +function wppost_hook_fork(&$a, &$b) +{ + if ($b['name'] != 'notifier_normal') { + return; + } + + $post = $b['data']; + + if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || + !strstr($post['postopts'], 'wppost') || ($post['parent'] != $post['id'])) { + $b['execute'] = false; + return; + } +} + function wppost_post_local(&$a, &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint