WPLMS is a Learning Management System for WordPress. Translation files in WPLMS are located in
These language files will be overwritten with new files on every update, destroying any custom translation changes.
Move your theme into a child theme and translate your theme there (/wp-content/themes/your-child-theme/languages/).
Make sure that language files are loaded from your child theme. Add the following action to your functions.php and use „vibe“ as the domain, not the actual theme name.
1 2 3 4 5 |
add_action( 'after_setup_theme', 'my_child_theme_setup' ); function my_child_theme_setup() { load_child_theme_textdomain( 'vibe', get_stylesheet_directory() . "/languages" ); } |
Use the global language folder for the WPLMS plugin translations. The WPLMS plugin loader checks, if a global language file actually exists :)
1 2 3 4 5 |
if ( file_exists( $mofile_global ) ) { load_textdomain( 'vibe', $mofile_global ); } else { load_textdomain( 'vibe', $mofile_local ); } |
I suggest using Poedit, as it allows you to do the translation on the Desktop. It also offers options to update your file with an updated WPLMS language file, allowing you to add new translation strings if needed :)
A. Create the structure for the update and download new PO files from WPLMS
B. The target structure / your current language files
C. Open your current .PO file from target structure
D. Update with new and matching .PO file from A. (Catalog -> Update from POT file)
This will check for new or obsolete strings and update your language file.
E. New strings added
F. Obsolete strings removed
G. Save and upload updated .PO + .MO files from target structure to server.
Again, make sure to use the global language folder and the child theme languages folder !
Panic time after updates is over :)
Twital is a small addon for the Twig template engine, it adds shortcuts and makes Twig’s syntax more suitable for HTML based (XML, HTML5, XHTML, SGML) templates.
Should be also no problem to integrate it with Timber, currently looking into that ;)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<ul t:if="users"> <li t:for="user in users"> {{ user.name }} </li> </ul> // shorter than : {% if users %} <ul> {% for user in users %} <li> {{ user.name }} </li> {% endfor %} </ul> {% endif %} |
„In iOS 7.1, a property, minimal-ui, has been added for the viewport meta tag key that allows minimizing the top and bottom bars in Safari as the page loads. While on a page using minimal-ui, tapping the top bar brings the bars back. Tapping back in the content dismisses them again. Brim is a view (minimal-ui) manager for iOS 8“
„Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.“
The following will get you started, these offer the Doctrine\Common and Doctrine\DBAL namespaces.
In the end your structure should look something like that:
includes/
includes/doctrine
includes/doctrine/lib
includes/doctrine/lib/Doctrine
includes/doctrine/lib/Doctrine/Common
includes/doctrine/lib/Doctrine/DBAL
The following will add a class loader, so that all the other classes will be autoloaded.
1 2 3 4 5 6 |
use Doctrine\Common\ClassLoader; require dirname(__FILE__).'/includes/doctrine/lib/Doctrine/Common/ClassLoader.php'; $classLoader = new ClassLoader('Doctrine',dirname(__FILE__).'/includes/doctrine/lib'); $classLoader->register(); |
This will setup your first connection to a MySQL database.
1 2 3 4 5 6 7 8 9 10 |
$config = new \Doctrine\DBAL\Configuration(); $connectionParams = array( 'dbname' => 'my_db', 'user' => 'my_user', 'password' => 'my_pass', 'host' => 'localhost', 'driver' => 'pdo_mysql', ); $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); |
This will do a simple first query
1 2 3 4 5 6 |
$sql = "SELECT * FROM some_data"; $stmt = $conn->query($sql); while ($row = $stmt->fetch()) { echo $row['some_field']; } |
DBAL gives us some nice options to prepare queries.
1 2 3 4 |
$sql = "SELECT * FROM some_data WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bindValue(1, $id); $stmt->execute(); |
By using the bindValue the placeholder „?“ is replaced. You can also use named parameters :)
1 2 3 4 |
$sql = "SELECT * FROM some_data WHERE name = :name OR username = :name"; $stmt = $conn->prepare($sql); $stmt->bindValue("name", $name); $stmt->execute(); |
More about this in the official documentation.
That was not too difficult ;)
TWIG allows you to use regular expressions within its templates, this makes it possible to easily check if a post is sticky in Timber for WordPress.
1 2 |
{% if findme matches '/^[\\d\\.]+$/' %} {% endif %} |
This is the template that is called within the loop on the index.twig to show each post.
1 2 3 4 5 6 |
{% extends "tease.twig" %} {% block content %} <div class="{% if post.class matches '/sticky/' %}col-md-12{% else %}col-md-6{% endif %}"> <!--Your content --> </div> {% endblock %} |
The post.class holds the full set of classes assigned to a post, which includes the class „sticky“. We do the match magic and you can use that to style your sticky posts differently ;)
„Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the Twig Template Engine separate from your PHP files.
This cleans-up your theme code so, for example, your php file can focus on being the data/logic, while your twig file can focus 100% on the HTML and display.“
Twig is a modern template engine for PHP
Tracy helps you to:
1 2 3 4 5 6 |
require_once ('/includes/tracy/tracy.php'); use Tracy\Debugger; //Debugger::$strictMode = TRUE; Debugger::$logSeverity = E_NOTICE | E_WARNING; Debugger::enable(Debugger::DEVELOPMENT, '/cache/log'); Debugger::fireLog('Hello World'); |