phpBB post example for WP shortcode

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: phpBB post example for WP shortcode

Re: phpBB post example for WP shortcode

by axew3 » Tue Aug 08, 2017 8:12 pm

but in true seem the questions was about to display the entire Topic (with any reply).
It will be added on queue as feature to be added for WP_w3all shortcode options. DIsplay a single Post, or the entire Topic.

Re: phpBB post example for WP shortcode

by axew3 » Mon Aug 07, 2017 10:18 pm

p.s answering to a question, i've add an easy help about how to activate WordPress shortcode for comments widgets and excerpts:
https://www.axew3.com/w3/2017/08/wordpr ... -excerpts/

Re: phpBB post example for WP shortcode

by axew3 » Mon Aug 07, 2017 7:41 am

:D coffee coffee!! we'll go to add smilies and attachments! And even more.

Smilies can be replaced with easy, and maybe after all the rest has been processed (except eventually founded code blocks re-addition!) , so in class.wp.w3all-phpbb.php JUST AFTER this line:

Code: Select all

$res = self::w3all_bbcodeconvert($res); // convert all bbcode tags except
of function function wp_w3all_get_phpbb_post( $atts )
can be used something like this:

Code: Select all

$bbcode_smilies_on_posts = array( ";)", ":;)", ":(" ); // edit to match and add more
$smilies_replacements = array("urlTosmile1", "urlTosmile2", "urlTosmile3"); // edit to match and add more
$res = str_replace($bbcode_smilies_on_posts, $smilies_replacements, $res);
i've see on WP folder images, there is a folder with smilies.
We can chooose to link those smilies, instead than phpBB smilies, and/or we could copy/paste all phpBB smilies in use to this folder. So the urlTosmile1, urlTosmile2 etc can be URLs pointing to WP avatars of this folder folder (avoiding maybe to change so htaccess for images in phpBB that aren't served out of his directory). But this is merely a choose.
I've not test this but should work fine. We can also add with easy the option disable smiles that can be also added as param for the shortcode, something like:

Code: Select all

[w3allforumpost id="myPid" disablesmiles="1"]

Re: phpBB post example for WP shortcode

by kaspir » Mon Aug 07, 2017 6:42 am

axew3 wrote: Sat Aug 05, 2017 4:27 pm Hi Greg! about coffee ... mhh ... hope it was Italian coffee, like Lavazza or Segafredo, or Hilly ... done with Moka Bialetti .... and NOT NESCAFE! :cry: ... how to use a moka properly, to have a good coffee require also some little experienced trick! It require to be washed only with water, and is necessary to make some coffee leaving it on the moka for sometime, that you'll discard after ... than you'll start to have a good aroma, after some day, because the MOKA start to smell of coffee even after washed (EVER with only water!) ... and the moka will give you time by time a better coffee ... that's really nice ... well what i'm writing about in my bad Eng!!! :lol:
Sounds delightful! I need to learn more about your Italian coffee!
axew3 wrote: Sat Aug 05, 2017 4:27 pm about shortcode: you know sometime after you have finish something, you realize that it could be coded in another way.
All the time! Practice makes perfect, PHP7 new classes and objects are teching me more of that, and recently been looking at symphony framework. Always to be less repetitive, repeat code less.
axew3 wrote: Sat Aug 05, 2017 4:27 pm It can be improved and some modifier removed on some regex. I'm not a monster of science about regex, so be sure there is some more to be improved.
Argh regex, another thing I need improving on understanding too. Google has been my friend altering regex.
axew3 wrote: Sat Aug 05, 2017 4:27 pm str_ireplace() could be used conveniently, that is more fast, in some point maybe (or on all, looking on how the post containing bbcode parsed, is stored on DB by phpBB).
...
All very nicely explained Allesio! Nicely done, I'm glad I keep your gears grinding and teaching me new things! :)

About smileys.. argh.. I haven't yet been successful at re-parsing those, I need to remove them into a blank space.
I know you mainly work on WP, but have you seen phpBB's new re-parser? https://area51.phpbb.com/docs/dev/32x/e ... ode-engine
Does wanna make me install symphony on another application. Seems to be a highly qualified framework, and I want to teach myself new things, do you use any framework?

Re: phpBB post example for WP shortcode

by axew3 » Sat Aug 05, 2017 4:27 pm

Hi Greg! about coffee ... mhh ... hope it was Italian coffee, like Lavazza or Segafredo, or Hilly ... done with Moka Bialetti .... and NOT NESCAFE! :cry: ... how to use a moka properly, to have a good coffee require also some little experienced trick! It require to be washed only with water, and is necessary to make some coffee leaving it on the moka for sometime, that you'll discard after ... than you'll start to have a good aroma, after some day, because the MOKA start to smell of coffee even after washed (EVER with only water!) ... and the moka will give you time by time a better coffee ... that's really nice ... well what i'm writing about in my bad Eng!!! :lol:

about shortcode: you know sometime after you have finish something, you realize that it could be coded in another way. It can be improved and some modifier removed on some regex. I'm not a monster of science about regex, so be sure there is some more to be improved.
str_ireplace() could be used conveniently, that is more fast, in some point maybe (or on all, looking on how the post containing bbcode parsed, is stored on DB by phpBB).
The call to preg_replace_callback can be reduced to one, i've already edit it on local test, so like:

Code: Select all

$text = preg_replace_callback(
            "~<ul>(.*?)</ul>|<ol(.*?)</ol>~sm",
            "self::w3_bbcode_rep0",
            $text);
The returned html tag for code is wrapped into

Code: Select all

<pre><code>....</code></pre>
that should be only

Code: Select all

<code>....</code>
and i've forget to remove it on first 1.7.4 class.wp.w3all-phpbb.php (after patched with some little more) from line:

Code: Select all

$res = str_ireplace('#w3#bbcode#replace#'.$cccc, '<pre><code>'.$v[1].'</code></pre>', $res);
the php code require some little adjustment, in case the query to the post return an unexpected result.
Should be added the

Code: Select all

[attachment]
bbcode even if it after, should imply all about users permissions, to view or not the attachment in WP, that would be not require any important change ...
And an option more on shortcode to, display the post into WP post as text immediately visible, or like a button, that when clicked, so display the phpBB post into the WP post (convenient for stunning presentations maybe, and as showed by someone as example into an old request post).
new lines present some problem maybe, and some little improvement about this, adding corrects

Code: Select all

<br />
tags (or not) on output, should be done.

p.s thank for your appreciation on another post ;)

Re: phpBB post example for WP shortcode

by kaspir » Sat Aug 05, 2017 7:22 am

Nice option to have available! I just tried it out and works nicely. I noticed a custom bbcode on my phpBB didn't show as you explained it wouldn't. Perhaps we can begin a list of the more common bbcodes to be supported in plugin in the future! I'll start of by adding a simple one:

Strike-through [s] [/s], if I learned this correctly from you, it would be added to the bbcode regex array like so:

Code: Select all

'~\[s\](.*?)\[/s\]~usi',
And now that I've seen this, a light bulb just went off! I got to leave now and go re-read my code for my SEO extension I never finished. It's so close to completion, but the hold up was I couldn't rewrite out certain things within a post for the meta description tag. Argh, cleaning up the back burner sucks..

Thanks for the :idea: lightbulb!

EDIT: After a few cups of coffee (a.k.a. about a whole pot, lol), the lightbulb paid off! In case you were wondering what I was thinking about, I posted it here: viewtopic.php?p=2280#p2280

Top