WordPress: Difference between revisions
imported>Onny Add infos about error logging |
imported>Onny Add note about auto enable plugins |
||
| Line 50: | Line 50: | ||
Make sure that the source of your language package corresponds to the Wordpress package version you're using. Consult the [https://translate.wordpress.org translation portal] of Wordpress for the specific country and language codes available. This example is using the code <code>de_DE</code> (Germany/German) in the source URL and also the <code>extraConfig</code> part. | Make sure that the source of your language package corresponds to the Wordpress package version you're using. Consult the [https://translate.wordpress.org translation portal] of Wordpress for the specific country and language codes available. This example is using the code <code>de_DE</code> (Germany/German) in the source URL and also the <code>extraConfig</code> part. | ||
=== | === Themes === | ||
In case you want to package and add custom | Unfortunately themes and plugins [https://github.com/NixOS/nixpkgs/pull/173622 haven't been packaged yet in nixpkgs]. In case you want to package and add custom themes yourself, the configuration could look like this | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
let | let | ||
responsive = pkgs.stdenv.mkDerivation { | responsive = pkgs.stdenv.mkDerivation { | ||
name = "responsive"; | name = "responsive"; | ||
src = pkgs.fetchurl { | src = pkgs.fetchurl { | ||
url = http://wordpress.org/themes/download/responsive.1.9.7.6.zip; | url = http://wordpress.org/themes/download/responsive.1.9.7.6.zip; | ||
sha256 = "06i26xlc5kdnx903b1gfvnysx49fb4kh4pixn89qii3a30fgd8r8"; | sha256 = "06i26xlc5kdnx903b1gfvnysx49fb4kh4pixn89qii3a30fgd8r8"; | ||
}; | }; | ||
buildInputs = [ pkgs.unzip ]; | buildInputs = [ pkgs.unzip ]; | ||
installPhase = "mkdir -p $out; cp -R * $out/"; | installPhase = "mkdir -p $out; cp -R * $out/"; | ||
}; | }; | ||
in { | |||
services.wordpress.sites."localhost" = { | |||
themes = [ responsive ]; | |||
virtualHost.adminAddr = "hello@example.org"; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
You can package any available Wordpress theme, for example from the [https://wordpress.org/themes official themes repository]. Be sure to replace the ''name'', url and ''sha256'' part according to your desired theme. | |||
If you want to automatically enable the ''responsive'' theme, add this </code>extraConfig</code> line | |||
<syntaxHighlight lang="nix"> | |||
extraConfig = '' | |||
// Activate and enable theme responsive as default | |||
define ('WP_DEFAULT_THEME', 'responsive'); | |||
''; | |||
</syntaxHighlight> | |||
=== Plugins === | |||
Packaging plugins, for example from the [https://wordpress.org/plugins official plugins repository], is similar to the approach used above | |||
<syntaxHighlight lang="nix"> | |||
let | |||
akismet = pkgs.stdenv.mkDerivation { | akismet = pkgs.stdenv.mkDerivation { | ||
name = "akismet"; | name = "akismet"; | ||
src = pkgs.fetchurl { | src = pkgs.fetchurl { | ||
url = https://downloads.wordpress.org/plugin/akismet.3.1.zip; | url = https://downloads.wordpress.org/plugin/akismet.3.1.zip; | ||
sha256 = "1i4k7qyzna08822ncaz5l00wwxkwcdg4j9h3z2g0ay23q640pclg"; | sha256 = "1i4k7qyzna08822ncaz5l00wwxkwcdg4j9h3z2g0ay23q640pclg"; | ||
}; | }; | ||
buildInputs = [ pkgs.unzip ]; | buildInputs = [ pkgs.unzip ]; | ||
installPhase = "mkdir -p $out; cp -R * $out/"; | installPhase = "mkdir -p $out; cp -R * $out/"; | ||
}; | }; | ||
| Line 88: | Line 108: | ||
services.wordpress.sites."localhost" = { | services.wordpress.sites."localhost" = { | ||
plugins = [ akismet ]; | plugins = [ akismet ]; | ||
virtualHost.adminAddr = "hello@example.org"; | virtualHost.adminAddr = "hello@example.org"; | ||
}; | }; | ||
| Line 100: | Line 115: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
In case you want to automatically enable the plugin, in this example ''akismet'', you can add following to <code>extraConfig</code> | |||
<syntaxHighlight lang="nix"> | |||
extraConfig = '' | |||
// Activate and enable theme responsive as default | |||
if ( !defined('ABSPATH') ) | |||
define('ABSPATH', dirname(__FILE__) . '/'); | |||
require_once(ABSPATH . 'wp-settings.php'); | |||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |||
activate_plugin( 'akismet/akismet.php' ); | |||
''; | |||
</syntaxHighlight> | |||
== Tips and tricks == | == Tips and tricks == | ||