• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

XenForo 2 XenWord Pro 2017 Notes

LPH

Flight Director
Flight Instructor
XenForo 2 Developer Preview has been available for at least a week and I've had time to work through some of the ideas. Many of the new concepts are making XenWord much easier to code.

For example, pulling the latest threads code is much simpler:

PHP:
$limit = 10;

$finder = \XF::finder('XF:Thread');
$threads = $finder->order('post_date', 'DESC')->limit($limit)->fetch();

foreach ($threads as $thread) {

  $user_id = $thread['user_id'];

  $finder = \XF::finder('XF:User');
  $user = $finder->where('user_id', $user_id)->fetchOne();

  $postUrl = \XF::app()->router()->buildLink('canonical:threads', $thread);
  echo '<a href="' . $postUrl . '">' . $thread['title'] . '</a><br />';

  echo 'Posted by ' . $thread['username'] . ' with user_id ' . $thread['user_id'] . '<br />';

  echo '<pre>';
  print_r($user);
  echo '</pre>';
}

Finders make life very sweet. You'll also see a new way to build links.

There are still limitations to my knowledge and so it'll take a long time to build XenWord. It will be done from the ground up -- and fixing early design mistakes made because I didn't know what I was doing :D

Will I need to buy a new license?
No. XenWord 4 will be considered an upgrade.

When will XenWord 4 be released?
I have no idea. Bluntly I'm learning. The original version took me 6 months to write and 3 years to fix.

Will you release an Alpha version?
Yes. Holders of the developer's license will have access to the alpha. This is so they can start working with their clients.

Will you add new features?
My hope is to provide a bridge that is feature parity and easier to maintain. If I learn something new then I'll add it. I certainly don't want to take away features.

What features are working? What features are not working?
Login and logout are working. I'm attempting to work through thread creation. I'll most likely split apart the files like I did with comments. It makes life easier.
 

LPH

Flight Director
Flight Instructor
With the help of two XenForo developers, I was able to add a prefix to writing WordPress posts to XenForo 2.

XenWord 4 Thread Creation.png
 

Attachments

  • WordPress Post.png
    WordPress Post.png
    133.7 KB · Views: 144
  • Hello Titile.png
    Hello Titile.png
    81.8 KB · Views: 139

LPH

Flight Director
Flight Instructor
I just completed namespacing the completed files. It took a long time due to my ignorance of using Fully Qualified Names in a class_exist conditional.

You can now see a WordPress post creating the thread.


The bootstrap file is now set. It's working well. The main loader file is connected and I'm slowly adding other files to it.

I suspect it'll be several more months before XenWord 4 matches XenWord 3 features. The coding is much nicer -- use of namespace to avoid collisions, improved SOLID principles, and a better file structure.
 

LPH

Flight Director
Flight Instructor
This video shows XenWord 4 under XenForo 2 Beta 4.


The logout on the widget isn't working. The styles are loading now along with Redux Framework connected to turn features on and off.

The biggest challenge is flipping between XenForo development and XenForo 2 development. I prefer XenForo 2.
 

LPH

Flight Director
Flight Instructor
The logout on the widget isn't working.

It turns out the issue on logout is not mine. Mike from XenForo explained that XenForo 2 does not support custom redirects on logout at this time. At least I can get the widget to login and logout -- and let's hope Mike and the dev team add the custom redirects.
 

LPH

Flight Director
Flight Instructor
This is just a simple update showing the progress. In particular, the loading of the login file is causing an issue. If loaded from a higher-level file then login is working fine.


I'll keep working and reading up on why the loading is a problem.
 

LPH

Flight Director
Flight Instructor
Added the members online widget and the link to the thread.

Members Online
Code started the other day and the greatest challenge was having the online widget update as soon as the user was logged in through the login widget. Mike from XenForo helped point me in the right direction.

Discussion Link
The link to the thread was added; however, $post->thread_id didn't work and it was changed to $post->post_title matched to XenForo thread title.

Instead of always calling xenword_options several times in a file, each file now includes a protected $options which is set equal to get_option('xenword_options').

Link and Members Online Widget.png
 

LPH

Flight Director
Flight Instructor
XenWord is now a Composer-based WordPress plugin. PSR-4 autoloading has been enabled, which dramatically changes the code base for loading files.

XenWord 2017.10.15 File Structure.png


Besides autoloading, the namespaces are coming together quite nicely. A current snag is getting the \XF class to load in the Redux Framework init PHP file. Because it is above the src/ subdirectory then it's not loading \XF. I haven't found a solution.

Currently the connector works, redirects and stylesheets work, login in XenForo is recognized, threads are created, and four widgets are working.

XenWord 2017.10.15 Composer Based.png


Because of the dramatic departure from manually requiring files, and challenges to earlier numbering conventions, XenWord 4 code is being renamed to the last date of code changes. Currently, XenWord 4 is known as 2017.10.15.

This change will help me greatly understand support posts made regarding XenWord.

Feature Suggestion Under Consideration
Someone asked if the future release of XenWord would support XenForo 1 and 2. Currently it only supports 2. I can picture code in my head which will allow an option for the site webmaster to switch from connecting to 1 versus connecting to 2. This will require a rewrite of XenWord 3 due to the namespacing and changes to autoloading.
 

LPH

Flight Director
Flight Instructor
This is the backend with Links and Notices properly included in the plugin.

XenWord 2017.10.15 Framework.png
 

LPH

Flight Director
Flight Instructor
Wow. Autoload has sped up development. It took less than 30 minutes to rewrite and tie in the Dashboard and Support Widgets, including the proper conditionals. It's time to call it a night.

XenWord 2017.10.15 Support and Dashboard Widgets.png
 

LPH

Flight Director
Flight Instructor
Great news !

The connector works properly now. The new file structure, use of Composer, autoloading, namespaces all make XenWord much more powerful.
 

LPH

Flight Director
Flight Instructor
An interesting predicament happened late last night -- well -- early this morning (~12:30 AM).

The admin_enqueue_scripts stopped loading the xenword-admin.css file. The same file is loading the xenword-public.css file just fine. A var_dump is not returning any information. It appears the hook is not firing properly.
 

LPH

Flight Director
Flight Instructor
The admin_enqueue_scripts stopped loading the xenword-admin.css file. The same file is loading the xenword-public.css file just fine. A var_dump is not returning any information. It appears the hook is not firing properly.

Moved the admin_enqueue_scripts to its own file and located it to the directory with the admin backend files. The CSS loaded.

Admin Stylesheets.png


XenWord 2017.10.18-2017.png


I absolutely LOVE how the new XenWord is taking shape. This is beyond exciting.
 

LPH

Flight Director
Flight Instructor
Started work on the metaboxes. My first attempt to use a class structure failed. There are also core methods called and I’m rethinking how this should be done.
 

LPH

Flight Director
Flight Instructor
The three metaboxes now work in the edit post of WordPress. These are for setting the thread_id, forum_id, and checkbox for create or edit a thread.

A new option is now available for setting the text of the author. Here is a short video.

 

LPH

Flight Director
Flight Instructor
Using traits to avoid repeating code was introduced in PHP 5.4. Since XenForo 2 requires a minimum of PHP 5.4 then traits can be used in XenWord Pro 2017 development.

The following video shows how repeated code is being minimize with the use of traits.

 

LPH

Flight Director
Flight Instructor
Integrating the XenForo 1 and 2 code has turned out to be tougher than initially considered. The challenge is getting the Redux Framework to load the user mapping properly for each version. A conditional is challenging due to the possible states of the plugin.
  1. Bridge activated, no absolute path, no switch
  2. Bridge activated, no absolute path, XenForo 1 switch
  3. Bridge activated, no absolute path, XenForo 2 switch
  4. Bridge activated, path, no switch
  5. Bridge activated, path, XenForo 1 switch
  6. Bridge activated, path, XenForo 2 switch
The ini file cannot use the xenword_options for testing the different states because the options may not be in the WordPress Database yet.
 

LPH

Flight Director
Flight Instructor
Work on the members system included separating out methods into proper classes; keeping the SOLID principle in mind.

The sequence of the login is being changed, too. Currently, the user and role are inserted in the same array. I've decided to use wp_insert_user for inserting the array and use the WP_Users object to add and remove roles after the insertion.

There is also a separate file and class for updating the user meta information.

XenWord Pro 2017.11.2.png
 

LPH

Flight Director
Flight Instructor
Several hours were wasted last night while attempting to install XenWord Pro 2017 on this server. The dashboard widget conflicts with the UIX theme. It’s the same code used for years in earlier XenWord versions, which don’t conflict.

I suspect others are struggling with this, too. You can get the conflict information by turning on the error report switch then reloading the page.
 
Top