Hi all, the Q2A 1.7 beta should finally be released very soon! Myself or Gideon will make a post about that later but I wanted to post a few notes for plugin and theme development.
File structure
Firstly, I just made a major change to the structure of the qa-include folder. Most of the files now live in subfolders, for example qa-include/qa-app-format.php is now qa-include/app/format.php. For backwards compatibility, the old files have been kept as "stubs" which just 'require_once' the new files, but all developers should update their paths as they will be removed in a future version (probably 1.9).
For example where you used
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
Replace with
require_once QA_INCLUDE_DIR . 'app/format.php';
For reference:
-
qa-ajax-* files are in ajax/
-
qa-app-* files are in app/
-
qa-db-* files are in db/
-
qa-lang-* files are in lang/ (not renamed)
-
qa-page-* & qa-page-admin-* files are in page/ & page/admin/
-
qa-util-* files are in util/
-
Plugin files are in plugins/
-
Third party code (htmlawed and phpmailer) is in vendor/
Themes
There is a new option for themes, '$ranking_block_layout' which shows ranking pages (Users/Tags) in blocks (similar to Stack Overflow) instead of a table. The Snow/Classic/Candy themes now have this, but the new SnowFlat theme does not yet. You can set this in your theme class with
protected $ranking_block_layout = true;
Both layouts use the same classes so it shouldn't be too big a task to update the CSS for the new layout. Look in the Snow or Classic theme CSS for examples.
Also, there a new option in the admin area to specify text direction (i.e. left-to-right or right-to-left). If you're developing a theme that supports both you can now use this to determine which stylesheet(s) to show. The $qa_content stores the direction 'ltr' or 'rtl' and can be accessed in themes using $this->content['direction']. The base theme also sets a boolean variable 'isRTL' so you can easily check in your theme by using for example
if ($this->isRTL) { ... }
Languages
As usual there are several new language keys. These will be listed in the upgrade notes but you can also just use the language checker in Admin>General.
Based on suggestions from pupi1985 we are also moving towards a new and easier system for metadata. Language metadata can be stored in a `metadata.php` file instead of a comment (see qa-lang/en-GB for an example). Currently this only supports `display_name` as the language name, but will be improved and expanded to themes and plugins in the future. This has been replaced by metadata.json, see the new thread.
Plugins
There is one notable change to the init_queries function in plugins - the table names are no longer passed in lowercase. There was an issue when using an uppercase table prefix (e.g. QA_ instead of qa_) - the table names would be lowercase but the function to add prefixes would add the uppercase one.
This change may potentially break a plugin in one situation: when a developer has manually called strtolower on the table they are checking against. In other words this:
$tablename = strtolower(qa_db_add_table_prefix('mytable'));
if (!in_array($tablename, $tableslc)) { ... }
I have checked dozens of plugins and not found a single one for which this change will be a problem (and in fact it fixes the original issue for all those plugins).
Github development
I should also note here that from now on there is a small change to the Github workflow. I've created a new branch "1.8" which is for the next major version of Q2A. All new features and major changes will go here. The dev branch will serve as a "hotfix" branch for the current stable version.
In other words, anything for a 1.7.1 release would be on dev (then merged into master for release), with major changes on the 1.8 branch. When version 1.8 is released that will be merged into dev/master and a new 1.9 branch created. 1.8.1 would be on dev with major changes on 1.9.
Note, as well as new features, "major changes" include:
-
New language keys
-
Databse upgrades
-
Changes to the minimum PHP/MySQL requirements
-
Any other potentially backwards compatible change