]> git.mxchange.org Git - friendica-addons.git/blobdiff - wppost/wppost.php
Merge pull request #531 from tobiasd/20180210-blockem
[friendica-addons.git] / wppost / wppost.php
index 88ae5a4f2e1b176c0178bf7753242fa28f6959a3..e3127e8e6e2c1d51e41350e6ee730e024f5f3328 100644 (file)
@@ -5,9 +5,11 @@
  * Version: 1.1
  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
  */
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Util\Network;
 
 function wppost_install() {
     Addon::registerHook('post_local',           'addon/wppost/wppost.php', 'wppost_post_local');
@@ -218,18 +220,16 @@ function wppost_send(&$a,&$b) {
                $wp_backlink_text = L10n::t('Read the orig­i­nal post and com­ment stream on Friendica');
        }
 
-       if($wp_username && $wp_password && $wp_blog) {
-
-               require_once('include/bbcode.php');
-               require_once('include/html2plain.php');
-               require_once('include/plaintext.php');
+       if ($wp_username && $wp_password && $wp_blog) {
+               require_once 'include/bbcode.php';
+               require_once 'include/html2plain.php';
 
                $wptitle = trim($b['title']);
 
-               if (intval(PConfig::get($b['uid'],'wppost','shortcheck'))) {
+               if (intval(PConfig::get($b['uid'], 'wppost', 'shortcheck'))) {
                        // Checking, if its a post that is worth a blog post
                        $postentry = false;
-                       $siteinfo = get_attached_data($b["body"]);
+                       $siteinfo = BBCode::getAttachedData($b["body"]);
 
                        // Is it a link to an aricle, a video or a photo?
                        if (isset($siteinfo["type"])) {
@@ -256,7 +256,7 @@ function wppost_send(&$a,&$b) {
                // If the title is empty then try to guess
                if ($wptitle == '') {
                        // Fetch information about the post
-                       $siteinfo = get_attached_data($b["body"]);
+                       $siteinfo = BBCode::getAttachedData($b["body"]);
                        if (isset($siteinfo["title"])) {
                                $wptitle = $siteinfo["title"];
                        }
@@ -314,10 +314,9 @@ EOT;
 
                logger('wppost: data: ' . $xml, LOGGER_DATA);
 
-               if($wp_blog !== 'test') {
-                       $x = post_url($wp_blog,$xml);
+               if ($wp_blog !== 'test') {
+                       $x = Network::post($wp_blog, $xml);
                }
                logger('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG);
-
        }
 }