"getAttachedData" has been removed

This commit is contained in:
Michael 2023-03-05 21:17:14 +00:00
parent 2dd57a2f40
commit 9183371062
2 changed files with 104 additions and 127 deletions

View file

@ -9,13 +9,12 @@
require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'tumblroauth.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'tumblroauth.php';
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag; use Friendica\Model\Tag;
@ -34,7 +33,9 @@ function tumblr_install()
* existence of this method is checked to figure out if the addon offers a * existence of this method is checked to figure out if the addon offers a
* module. * module.
*/ */
function tumblr_module() {} function tumblr_module()
{
}
function tumblr_content() function tumblr_content()
{ {
@ -45,11 +46,11 @@ function tumblr_content()
if (isset(DI::args()->getArgv()[1])) { if (isset(DI::args()->getArgv()[1])) {
switch (DI::args()->getArgv()[1]) { switch (DI::args()->getArgv()[1]) {
case "connect": case 'connect':
$o = tumblr_connect(); $o = tumblr_connect();
break; break;
case "callback": case 'callback':
$o = tumblr_callback(); $o = tumblr_callback();
break; break;
@ -66,13 +67,13 @@ function tumblr_content()
function tumblr_addon_admin(string &$o) function tumblr_addon_admin(string &$o)
{ {
$t = Renderer::getMarkupTemplate( "admin.tpl", "addon/tumblr/" ); $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/tumblr/');
$o = Renderer::replaceMacros($t, [ $o = Renderer::replaceMacros($t, [
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
// name, label, value, help, [extra values] // name, label, value, help, [extra values]
'$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key' ), ''], '$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key'), ''],
'$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret' ), ''], '$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret'), ''],
]); ]);
} }
@ -87,9 +88,6 @@ function tumblr_connect()
// Start a session. This is necessary to hold on to a few keys the callback script will also need // Start a session. This is necessary to hold on to a few keys the callback script will also need
session_start(); session_start();
// Include the TumblrOAuth library
//require_once('addon/tumblr/tumblroauth/tumblroauth.php');
// Define the needed keys // Define the needed keys
$consumer_key = DI::config()->get('tumblr', 'consumer_key'); $consumer_key = DI::config()->get('tumblr', 'consumer_key');
$consumer_secret = DI::config()->get('tumblr', 'consumer_secret'); $consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
@ -141,7 +139,6 @@ function tumblr_callback()
{ {
// Start a session, load the library // Start a session, load the library
session_start(); session_start();
//require_once('addon/tumblr/tumblroauth/tumblroauth.php');
// Define the needed keys // Define the needed keys
$consumer_key = DI::config()->get('tumblr', 'consumer_key'); $consumer_key = DI::config()->get('tumblr', 'consumer_key');
@ -174,7 +171,7 @@ function tumblr_callback()
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token', $access_token['oauth_token']); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token', $access_token['oauth_token']);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'oauth_token_secret', $access_token['oauth_token_secret']);
$o = DI::l10n()->t("You are now authenticated to tumblr."); $o = DI::l10n()->t('You are now authenticated to tumblr.');
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>'; $o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
return $o; return $o;
@ -186,13 +183,13 @@ function tumblr_jot_nets(array &$jotnets_fields)
return; return;
} }
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'tumblr','post')) { if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post')) {
$jotnets_fields[] = [ $jotnets_fields[] = [
'type' => 'checkbox', 'type' => 'checkbox',
'field' => [ 'field' => [
'tumblr_enable', 'tumblr_enable',
DI::l10n()->t('Post to Tumblr'), DI::l10n()->t('Post to Tumblr'),
DI::pConfig()->get(DI::userSession()->getLocalUserId(),'tumblr','post_by_default') DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default')
] ]
]; ];
} }
@ -219,7 +216,7 @@ function tumblr_settings(array &$data)
$userinfo = $tum_oauth->get('user/info'); $userinfo = $tum_oauth->get('user/info');
$blogs = array_map(function ($blog) { $blogs = array_map(function ($blog) {
return substr(str_replace(["http://", "https://"], ["", ""], $blog->url), 0, -1); return substr(str_replace(['http://', 'https://'], ['', ''], $blog->url), 0, -1);
}, $userinfo->response->user->blogs); }, $userinfo->response->user->blogs);
$page_select = ['tumblr-page', DI::l10n()->t('Post to page:'), $page, '', $blogs]; $page_select = ['tumblr-page', DI::l10n()->t('Post to page:'), $page, '', $blogs];
@ -265,8 +262,10 @@ function tumblr_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || if (
!strstr($post['postopts'] ?? '', 'tumblr') || ($post['parent'] != $post['id'])) { $post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'] ?? '', 'tumblr') || ($post['parent'] != $post['id'])
) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -307,35 +306,26 @@ function tumblr_post_local(array &$b)
$b['postopts'] .= 'tumblr'; $b['postopts'] .= 'tumblr';
} }
function tumblr_send(array &$b)
{
function tumblr_send(array &$b) {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return; return;
} }
if (! strstr($b['postopts'],'tumblr')) { if (!strstr($b['postopts'], 'tumblr')) {
return; return;
} }
if ($b['parent'] != $b['id']) { if ($b['gravity'] != Item::GRAVITY_PARENT) {
return;
}
// Dont't post if the post doesn't belong to us.
// This is a check for forum postings
$self = DBA::selectFirst('contact', ['id'], ['uid' => $b['uid'], 'self' => true]);
if ($b['contact-id'] != $self['id']) {
return; return;
} }
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b)); $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
$oauth_token = DI::pConfig()->get($b['uid'], "tumblr", "oauth_token"); $oauth_token = DI::pConfig()->get($b['uid'], 'tumblr', 'oauth_token');
$oauth_token_secret = DI::pConfig()->get($b['uid'], "tumblr", "oauth_token_secret"); $oauth_token_secret = DI::pConfig()->get($b['uid'], 'tumblr', 'oauth_token_secret');
$page = DI::pConfig()->get($b['uid'], "tumblr", "page"); $page = DI::pConfig()->get($b['uid'], 'tumblr', 'page');
$tmbl_blog = 'blog/' . $page . '/post'; $tmbl_blog = 'blog/' . $page . '/post';
if ($oauth_token && $oauth_token_secret && $tmbl_blog) { if ($oauth_token && $oauth_token_secret && $tmbl_blog) {
@ -343,7 +333,7 @@ function tumblr_send(array &$b) {
$tag_arr = []; $tag_arr = [];
foreach($tags as $tag) { foreach ($tags as $tag) {
$tag_arr[] = $tag['name']; $tag_arr[] = $tag['name'];
} }
@ -353,7 +343,12 @@ function tumblr_send(array &$b) {
$title = trim($b['title']); $title = trim($b['title']);
$siteinfo = BBCode::getAttachedData($b["body"]); $media = Post\Media::getByURIId($b['uri-id'], [Post\Media::HTML, Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]);
$photo = array_search(Post\Media::IMAGE, array_column($media, 'type'));
$link = array_search(Post\Media::HTML, array_column($media, 'type'));
$audio = array_search(Post\Media::AUDIO, array_column($media, 'type'));
$video = array_search(Post\Media::VIDEO, array_column($media, 'type'));
$params = [ $params = [
'state' => 'published', 'state' => 'published',
@ -362,77 +357,65 @@ function tumblr_send(array &$b) {
'format' => 'html', 'format' => 'html',
]; ];
if (!isset($siteinfo["type"])) { $body = BBCode::removeShareInformation($b['body']);
$siteinfo["type"] = "";
}
if (($title == "") && isset($siteinfo["title"])) { if ($photo != false) {
$title = $siteinfo["title"]; $params['type'] = 'photo';
} if (!empty($body)) {
if (isset($siteinfo["text"])) {
$body = $siteinfo["text"];
} else {
$body = BBCode::removeShareInformation($b["body"]);
}
switch ($siteinfo["type"]) {
case "photo":
$params['type'] = "photo";
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);;
if (isset($siteinfo["url"])) {
$params['link'] = $siteinfo["url"];
}
$params['source'] = $siteinfo["image"];
break;
case "link":
$params['type'] = "link";
$params['title'] = $title;
$params['url'] = $siteinfo["url"];
$params['description'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
break;
case "audio":
$params['type'] = "audio";
$params['external_url'] = $siteinfo["url"];
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
break;
case "video":
$params['type'] = "video";
$params['embed'] = $siteinfo["url"];
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS); $params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
break; } elseif (!empty($params['caption'])) {
$params['caption'] = $photo['description'];
}
$params['source'] = $photo['url'];
} elseif ($link != false) {
$params['type'] = 'link';
$params['title'] = $link['name'];
$params['url'] = $link['url'];
$params['description'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
default: if (!empty($link['preview'])) {
$params['type'] = "text"; $params['thumbnail'] = $link['preview'];
$params['title'] = $title; }
$params['body'] = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); if (!empty($link['description'])) {
break; $params['excerpt'] = $link['description'];
}
if (!empty($link['author-name'])) {
$params['author'] = $link['author-name'];
} elseif (!empty($link['publisher-name'])) {
$params['author'] = $link['publisher-name'];
}
} elseif ($audio != false) {
$params['type'] = 'audio';
$params['external_url'] = $audio['url'];
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
} elseif ($video != false) {
$params['type'] = 'video';
$params['embed'] = $video['url'];
$params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);
} else {
$params['type'] = 'text';
$params['title'] = $title;
$params['body'] = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS);
} }
if (isset($params['caption']) && (trim($title) != "")) { if (isset($params['caption']) && (trim($title) != '')) {
$params['caption'] = '<h1>'.$title."</h1>". $params['caption'] = '<h1>' . $title . '</h1>' .
"<p>".$params['caption']."</p>"; '<p>' . $params['caption'] . '</p>';
} }
if (empty($params['caption']) && !empty($siteinfo["description"])) { if (empty($params['caption']) && !empty($siteinfo['description'])) {
$params['caption'] = BBCode::convertForUriId($b['uri-id'], "[quote]" . $siteinfo["description"] . "[/quote]", BBCode::CONNECTORS); $params['caption'] = BBCode::convertForUriId($b['uri-id'], '[quote]' . $siteinfo['description'] . '[/quote]', BBCode::CONNECTORS);
} }
$consumer_key = DI::config()->get('tumblr','consumer_key'); $consumer_key = DI::config()->get('tumblr', 'consumer_key');
$consumer_secret = DI::config()->get('tumblr','consumer_secret'); $consumer_secret = DI::config()->get('tumblr', 'consumer_secret');
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret); $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
// Make an API call with the TumblrOAuth instance. // Make an API call with the TumblrOAuth instance.
$x = $tum_oauth->post($tmbl_blog,$params); $x = $tum_oauth->post($tmbl_blog, $params);
$ret_code = $tum_oauth->http_code; $ret_code = $tum_oauth->http_code;
//print_r($params);
if ($ret_code == 201) { if ($ret_code == 201) {
Logger::notice('tumblr_send: success'); Logger::notice('tumblr_send: success');
} elseif ($ret_code == 403) { } elseif ($ret_code == 403) {

View file

@ -6,7 +6,6 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike> * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/ */
use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -33,13 +32,13 @@ function wppost_jot_nets(array &$jotnets_fields)
return; return;
} }
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'wppost','post')) { if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'wppost', 'post')) {
$jotnets_fields[] = [ $jotnets_fields[] = [
'type' => 'checkbox', 'type' => 'checkbox',
'field' => [ 'field' => [
'wppost_enable', 'wppost_enable',
DI::l10n()->t('Post to Wordpress'), DI::l10n()->t('Post to Wordpress'),
DI::pConfig()->get(DI::userSession()->getLocalUserId(),'wppost','post_by_default') DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'wppost', 'post_by_default')
] ]
]; ];
} }
@ -84,14 +83,14 @@ function wppost_settings(array &$data)
function wppost_settings_post(array &$b) function wppost_settings_post(array &$b)
{ {
if(!empty($_POST['wppost-submit'])) { if (!empty($_POST['wppost-submit'])) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'post' , intval($_POST['wppost'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'post', intval($_POST['wppost']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'post_by_default', intval($_POST['wp_bydefault'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'post_by_default', intval($_POST['wp_bydefault']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_username' , trim($_POST['wp_username'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_username', trim($_POST['wp_username']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_password' , trim($_POST['wp_password'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_password', trim($_POST['wp_password']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_blog' , trim($_POST['wp_blog'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_blog', trim($_POST['wp_blog']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'backlink' , intval($_POST['wp_backlink'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'backlink', intval($_POST['wp_backlink']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'shortcheck' , intval($_POST['wp_shortcheck'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'shortcheck', intval($_POST['wp_shortcheck']));
$wp_backlink_text = BBCode::convert(trim($_POST['wp_backlink_text']), false, BBCode::BACKLINK); $wp_backlink_text = BBCode::convert(trim($_POST['wp_backlink_text']), false, BBCode::BACKLINK);
$wp_backlink_text = HTML::toPlaintext($wp_backlink_text, 0, true); $wp_backlink_text = HTML::toPlaintext($wp_backlink_text, 0, true);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_backlink_text', $wp_backlink_text); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'wppost', 'wp_backlink_text', $wp_backlink_text);
@ -106,14 +105,17 @@ function wppost_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || if (
!strstr($post['postopts'] ?? '', 'wppost') || ($post['parent'] != $post['id'])) { $post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'] ?? '', 'wppost') || ($post['parent'] != $post['id'])
) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
} }
function wppost_post_local(array &$b) { function wppost_post_local(array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint // This can probably be changed to allow editing by pointing to a different API endpoint
@ -153,15 +155,15 @@ function wppost_post_local(array &$b) {
function wppost_send(array &$b) function wppost_send(array &$b)
{ {
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return; return;
} }
if(! strstr($b['postopts'],'wppost')) { if (!strstr($b['postopts'], 'wppost')) {
return; return;
} }
if($b['parent'] != $b['id']) { if ($b['gravity'] != Item::GRAVITY_PARENT) {
return; return;
} }
@ -176,8 +178,8 @@ function wppost_send(array &$b)
$wp_username = XML::escape(DI::pConfig()->get($b['uid'], 'wppost', 'wp_username')); $wp_username = XML::escape(DI::pConfig()->get($b['uid'], 'wppost', 'wp_username'));
$wp_password = XML::escape(DI::pConfig()->get($b['uid'], 'wppost', 'wp_password')); $wp_password = XML::escape(DI::pConfig()->get($b['uid'], 'wppost', 'wp_password'));
$wp_blog = DI::pConfig()->get($b['uid'],'wppost','wp_blog'); $wp_blog = DI::pConfig()->get($b['uid'], 'wppost', 'wp_blog');
$wp_backlink_text = DI::pConfig()->get($b['uid'],'wppost','wp_backlink_text'); $wp_backlink_text = DI::pConfig()->get($b['uid'], 'wppost', 'wp_backlink_text');
if ($wp_backlink_text == '') { if ($wp_backlink_text == '') {
$wp_backlink_text = DI::l10n()->t('Read the orig­i­nal post and com­ment stream on Friendica'); $wp_backlink_text = DI::l10n()->t('Read the orig­i­nal post and com­ment stream on Friendica');
} }
@ -187,15 +189,7 @@ function wppost_send(array &$b)
if (intval(DI::pConfig()->get($b['uid'], 'wppost', 'shortcheck'))) { if (intval(DI::pConfig()->get($b['uid'], 'wppost', 'shortcheck'))) {
// Checking, if its a post that is worth a blog post // Checking, if its a post that is worth a blog post
$postentry = false; $postentry = (bool)Post\Media::getByURIId($b['uri-id'], [Post\Media::HTML, Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]);
$siteinfo = BBCode::getAttachedData($b["body"]);
// Is it a link to an aricle, a video or a photo?
if (isset($siteinfo["type"])) {
if (in_array($siteinfo["type"], ["link", "audio", "video", "photo"])) {
$postentry = true;
}
}
// Does it have a title? // Does it have a title?
if ($wptitle != "") { if ($wptitle != "") {
@ -215,9 +209,9 @@ function wppost_send(array &$b)
// If the title is empty then try to guess // If the title is empty then try to guess
if ($wptitle == '') { if ($wptitle == '') {
// Fetch information about the post // Fetch information about the post
$siteinfo = BBCode::getAttachedData($b["body"]); $media = Post\Media::getByURIId($b['uri-id'], [Post\Media::HTML]);
if (isset($siteinfo["title"])) { if (!empty($media) && !empty($media[0]['name']) && ($media[0]['name'] != $media[0]['url'])) {
$wptitle = $siteinfo["title"]; $wptitle = $media[0]['name'];
} }
// If no bookmark is found then take the first line // If no bookmark is found then take the first line
@ -225,7 +219,7 @@ function wppost_send(array &$b)
// Remove the share element before fetching the first line // Remove the share element before fetching the first line
$title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $b['body'])); $title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $b['body']));
$title = BBCode::toPlaintext($title)."\n"; $title = BBCode::toPlaintext($title) . "\n";
$pos = strpos($title, "\n"); $pos = strpos($title, "\n");
$trailer = ""; $trailer = "";
if (($pos == 0) || ($pos > 100)) { if (($pos == 0) || ($pos > 100)) {
@ -233,7 +227,7 @@ function wppost_send(array &$b)
$trailer = "..."; $trailer = "...";
} }
$wptitle = substr($title, 0, $pos).$trailer; $wptitle = substr($title, 0, $pos) . $trailer;
} }
} }
@ -244,10 +238,10 @@ function wppost_send(array &$b)
$post = preg_replace('/<a.*?href="(https?:\/\/www.youtube.com\/.*?)".*?>(.*?)<\/a>/ism', "\n$1\n", $post); $post = preg_replace('/<a.*?href="(https?:\/\/www.youtube.com\/.*?)".*?>(.*?)<\/a>/ism', "\n$1\n", $post);
$post = preg_replace('/<a.*?href="(https?:\/\/youtu.be\/.*?)".*?>(.*?)<\/a>/ism', "\n$1\n", $post); $post = preg_replace('/<a.*?href="(https?:\/\/youtu.be\/.*?)".*?>(.*?)<\/a>/ism', "\n$1\n", $post);
$post = $title.$post; $post = $title . $post;
$wp_backlink = intval(DI::pConfig()->get($b['uid'],'wppost','backlink')); $wp_backlink = intval(DI::pConfig()->get($b['uid'], 'wppost', 'backlink'));
if($wp_backlink && $b['plink']) { if ($wp_backlink && $b['plink']) {
$post .= '<p><a href="' . $b['plink'] . '">' . $wp_backlink_text . '</a></p>'; $post .= '<p><a href="' . $b['plink'] . '">' . $wp_backlink_text . '</a></p>';
} }