<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[36752] trunk/tools/i18n/makepot.php: i18n tools: Sync makepot.php with i18n.svn.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/36752">36752</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/36752","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>ocean90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-02-28 10:33:15 +0000 (Sun, 28 Feb 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>i18n tools: Sync makepot.php with i18n.svn.
Changes: https://i18n.trac.wordpress.org/log/tools/trunk/makepot.php?rev=40331&stop_rev=24749
Fixes <a href="https://core.trac.wordpress.org/ticket/34910">#34910</a>, <a href="https://core.trac.wordpress.org/ticket/34749">#34749</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktoolsi18nmakepotphp">trunk/tools/i18n/makepot.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktoolsi18nmakepotphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tools/i18n/makepot.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tools/i18n/makepot.php 2016-02-28 02:18:22 UTC (rev 36751)
+++ trunk/tools/i18n/makepot.php 2016-02-28 10:33:15 UTC (rev 36752)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,28 +7,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'STDERR', fopen( 'php://stderr', 'w' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Class to create POT files for
+ * - WordPress 3.4+
+ * - WordPress plugins
+ * - WordPress themes
+ * - GlotPress (standalone)
+ * - WordPress.org projects (Rosetta, forums, directories)
+ * - WordCamp.org
+ *
+ * Support for older projects can be found in the legacy branch:
+ * https://i18n.trac.wordpress.org/browser/tools/branches/legacy
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> class MakePOT {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $max_header_lines = 30;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private $max_header_lines = 30;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $projects = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $projects = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'generic',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-frontend',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-admin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-network-admin',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wp-core',
- 'wp-ms',
</del><span class="cx" style="display: block; padding: 0 10px"> 'wp-tz',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-plugin',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-theme',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'bb',
- 'mu',
- 'bp',
</del><span class="cx" style="display: block; padding: 0 10px"> 'glotpress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'rosetta',
</span><span class="cx" style="display: block; padding: 0 10px"> 'wporg-bb-forums',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wporg-themes',
+ 'wporg-plugins',
+ 'wporg-forums',
+ 'wordcamporg',
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $rules = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $rules = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> '_' => array('string'),
</span><span class="cx" style="display: block; padding: 0 10px"> '__' => array('string'),
</span><span class="cx" style="display: block; padding: 0 10px"> '_e' => array('string'),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,11 +64,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'comments_number_link' => array('string', 'singular', 'plural'),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $ms_files = array( 'ms-.*', '.*/ms-.*', '.*/my-.*', 'wp-activate\.php', 'wp-signup\.php', 'wp-admin/network\.php', 'wp-admin/includes/ms\.php', 'wp-admin/network/.*\.php', 'wp-admin/includes/class-wp-ms.*' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private $ms_files = array(
+ 'ms-.*', '.*/ms-.*', '.*/my-.*', 'wp-activate\.php', 'wp-signup\.php',
+ 'wp-admin/network\.php', 'wp-admin/network/.*\.php', 'wp-admin/includes/ms\.php',
+ 'wp-admin/includes/class-wp-ms.*', 'wp-admin/includes/network\.php',
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $temp_files = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private $temp_files = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $meta = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $meta = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'default' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'from-code' => 'utf-8',
</span><span class="cx" style="display: block; padding: 0 10px"> 'msgid-bugs-address' => 'https://make.wordpress.org/polyglots/',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,29 +99,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-name' => 'WordPress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-version' => '{version}',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wp-core' => array(
- 'description' => 'Translation of WordPress {version}',
- 'copyright-holder' => 'WordPress',
- 'package-name' => 'WordPress',
- 'package-version' => '{version}',
- ),
- 'wp-ms' => array(
- 'description' => 'Translation of multisite strings in WordPress {version}',
- 'copyright-holder' => 'WordPress',
- 'package-name' => 'WordPress',
- 'package-version' => '{version}',
- ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'wp-tz' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'Translation of timezone strings in WordPress {version}',
</span><span class="cx" style="display: block; padding: 0 10px"> 'copyright-holder' => 'WordPress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-name' => 'WordPress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-version' => '{version}',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'bb' => array(
- 'description' => 'Translation of bbPress',
- 'copyright-holder' => 'bbPress',
- 'package-name' => 'bbPress',
- ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'wp-plugin' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'Translation of the WordPress plugin {name} {version} by {author}',
</span><span class="cx" style="display: block; padding: 0 10px"> 'msgid-bugs-address' => 'https://wordpress.org/support/plugin/{slug}',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,11 +120,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-version' => '{version}',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comments' => 'Copyright (C) {year} {author}\nThis file is distributed under the same license as the {package-name} package.',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'bp' => array(
- 'description' => 'Translation of BuddyPress',
- 'copyright-holder' => 'BuddyPress',
- 'package-name' => 'BuddyPress',
- ),
</del><span class="cx" style="display: block; padding: 0 10px"> 'glotpress' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'Translation of GlotPress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'copyright-holder' => 'GlotPress',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,6 +130,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'copyright-holder' => 'WordPress',
</span><span class="cx" style="display: block; padding: 0 10px"> 'package-name' => 'WordPress.org International Forums',
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wporg' => array(
+ 'description' => 'WordPress.org',
+ 'copyright-holder' => 'WordPress',
+ 'package-name' => 'WordPress.org',
+ ),
+ 'wordcamporg' => array(
+ 'description' => 'WordCamp.org',
+ 'copyright-holder' => 'WordPress',
+ 'package-name' => 'WordCamp.org',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'rosetta' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'Rosetta (.wordpress.org locale sites)',
</span><span class="cx" style="display: block; padding: 0 10px"> 'copyright-holder' => 'WordPress',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -144,26 +147,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function __construct($deprecated = true) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function __construct($deprecated = true) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->extractor = new StringExtractor( $this->rules );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function __destruct() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function __destruct() {
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $this->temp_files as $temp_file )
</span><span class="cx" style="display: block; padding: 0 10px"> unlink( $temp_file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function tempnam( $file ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function tempnam( $file ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $tempnam = tempnam( sys_get_temp_dir(), $file );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->temp_files[] = $tempnam;
</span><span class="cx" style="display: block; padding: 0 10px"> return $tempnam;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function realpath_missing($path) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function realpath_missing($path) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return realpath(dirname($path)).DIRECTORY_SEPARATOR.basename($path);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array()) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function xgettext($project, $dir, $output_file, $placeholders = array(), $excludes = array(), $includes = array()) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $meta = array_merge( $this->meta['default'], $this->meta[$project] );
</span><span class="cx" style="display: block; padding: 0 10px"> $placeholders = array_merge( $meta, $placeholders );
</span><span class="cx" style="display: block; padding: 0 10px"> $meta['output'] = $this->realpath_missing( $output_file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,14 +195,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_generic($dir, $args) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_generic($dir, $args) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'project' => 'wp-core',
</span><span class="cx" style="display: block; padding: 0 10px"> 'output' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_output' => 'wordpress.pot',
</span><span class="cx" style="display: block; padding: 0 10px"> 'includes' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'excludes' => array_merge(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array('wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*', ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ array( 'wp-admin/includes/continents-cities\.php', 'wp-content/themes/twenty.*', ),
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->ms_files
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'extract_not_gettexted' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -232,17 +235,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $res;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_core($dir, $output) {
- if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
-
- return $this->wp_generic( $dir, array(
- 'project' => 'wp-core', 'output' => $output,
- 'extract_not_gettexted' => true,
- 'not_gettexted_files_filter' => array( $this, 'is_not_ms_file' ),
- ) );
- }
-
- function wp_frontend( $dir, $output ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_frontend( $dir, $output ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,11 +255,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_admin($dir, $output) {
- if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) {
- return false;
- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_admin($dir, $output) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $frontend_pot = $this->tempnam( 'frontend.pot' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false === $frontend_pot ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -277,10 +266,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $network_admin_files = $this->get_wp_network_admin_files( $dir );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $result = $this->wp_generic( $dir, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'project' => 'wp-admin', 'output' => $output,
</span><span class="cx" style="display: block; padding: 0 10px"> 'includes' => array( 'wp-admin/.*' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'excludes' => array( 'wp-admin/includes/continents-cities\.php', 'wp-admin/network/.*', 'wp-admin/network.php' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'excludes' => array_merge( array( 'wp-admin/includes/continents-cities\.php' ), $network_admin_files ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'default_output' => 'wordpress-admin.pot',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $result ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,7 +306,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_network_admin($dir, $output) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_network_admin($dir, $output) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $frontend_pot = $this->tempnam( 'frontend.pot' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -334,7 +325,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->wp_generic( $dir, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'project' => 'wp-network-admin', 'output' => $output,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'includes' => array( 'wp-admin/network/.*', 'wp-admin/network.php' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'includes' => $this->get_wp_network_admin_files( $dir ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'excludes' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_output' => 'wordpress-admin-network.pot',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -353,70 +344,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_ms($dir, $output) {
- if ( file_exists( "$dir/wp-admin/user/about.php" ) ) return false;
- if ( !is_file("$dir/wp-admin/ms-users.php") ) return false;
- $core_pot = $this->tempnam( 'wordpress.pot' );
- if ( false === $core_pot ) return false;
- $core_result = $this->wp_core( $dir, $core_pot );
- if ( ! $core_result )
- return false;
- $ms_result = $this->wp_generic( $dir, array(
- 'project' => 'wp-ms', 'output' => $output,
- 'includes' => $this->ms_files,
- 'excludes' => array(),
- 'default_output' => 'wordpress-ms.pot',
- 'extract_not_gettexted' => true,
- 'not_gettexted_files_filter' => array( $this, 'is_ms_file' ),
- ) );
- if ( !$ms_result ) {
- return false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function get_wp_network_admin_files( $dir ) {
+ $wp_version = $this->wp_version( $dir );
+
+ // https://core.trac.wordpress.org/ticket/19852
+ $files = array( 'wp-admin/network/.*', 'wp-admin/network.php' );
+
+ // https://core.trac.wordpress.org/ticket/34910
+ if ( version_compare( $wp_version, '4.5-beta', '>=' ) ) {
+ $files = array_merge( $files, array(
+ 'wp-admin/includes/class-wp-ms.*',
+ 'wp-admin/includes/network.php',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $common_pot = $this->tempnam( 'common.pot' );
- if ( ! $common_pot )
- return false;
- $ms_pot = realpath( is_null( $output )? 'wordpress-ms.pot' : $output );
- system( "msgcat --more-than=1 --use-first $core_pot $ms_pot > $common_pot" );
- system( "msgcat -u --use-first $ms_pot $common_pot -o $ms_pot" );
- return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ return $files;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_tz($dir, $output) {
- $continents_path = 'wp-admin/includes/continents-cities.php';
- if ( !file_exists( "$dir/$continents_path" ) ) return false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_tz( $dir, $output ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->wp_generic( $dir, array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'project' => 'wp-tz', 'output' => $output,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'includes' => array( $continents_path ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'includes' => array( 'wp-admin/includes/continents-cities\.php' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'excludes' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'default_output' => 'wordpress-continents-cities.pot',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_version($dir) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function wp_version( $dir ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $version_php = $dir.'/wp-includes/version.php';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !is_readable( $version_php ) ) return false;
</span><span class="cx" style="display: block; padding: 0 10px"> return preg_match( '/\$wp_version\s*=\s*\'(.*?)\';/', file_get_contents( $version_php ), $matches )? $matches[1] : false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- function mu($dir, $output) {
- $placeholders = array();
- if (preg_match('/\$wpmu_version\s*=\s*\'(.*?)\';/', file_get_contents($dir.'/wp-includes/version.php'), $matches)) {
- $placeholders['version'] = $matches[1];
- }
- $output = is_null($output)? 'wordpress.pot' : $output;
- return $this->xgettext('wp', $dir, $output, $placeholders);
- }
-
-
- function bb($dir, $output) {
- $placeholders = array();
- $output = is_null($output)? 'bbpress.pot' : $output;
- return $this->xgettext('bb', $dir, $output, $placeholders);
-
- }
-
- function get_first_lines($filename, $lines = 30) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_first_lines($filename, $lines = 30) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $extf = fopen($filename, 'r');
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$extf) return false;
</span><span class="cx" style="display: block; padding: 0 10px"> $first_lines = '';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -428,23 +388,45 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $first_lines .= $line;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // PHP will close file handle, but we are good citizens.
+ fclose( $extf );
+
+ // Make sure we catch CR-only line endings.
+ $first_lines = str_replace( "\r", "\n", $first_lines );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $first_lines;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- function get_addon_header($header, &$source) {
- if (preg_match('|'.$header.':(.*)$|mi', $source, $matches))
- return trim($matches[1]);
- else
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_addon_header($header, &$source) {
+ /*
+ * A few things this needs to handle:
+ * - 'Header: Value\n'
+ * - '// Header: Value'
+ * - '/* Header: Value * /'
+ * - '<?php // Header: Value ?>'
+ * - '<?php /* Header: Value * / $foo='bar'; ?>'
+ */
+ if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $header, '/' ) . ':(.*)$/mi', $source, $matches ) ) {
+ return $this->_cleanup_header_comment( $matches[1] );
+ } else {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function generic($dir, $output) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Removes any trailing closing comment / PHP tags from the header value
+ */
+ private function _cleanup_header_comment( $str ) {
+ return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) );
+ }
+
+ public function generic($dir, $output) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $output = is_null($output)? "generic.pot" : $output;
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->xgettext('generic', $dir, $output, array());
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function guess_plugin_slug($dir) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ private function guess_plugin_slug($dir) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ('trunk' == basename($dir)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $slug = basename(dirname($dir));
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif (in_array(basename(dirname($dir)), array('branches', 'tags'))) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -455,7 +437,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $slug;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_plugin($dir, $output, $slug = null) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_plugin( $dir, $output, $slug = null, $args = array() ) {
+ $defaults = array(
+ 'excludes' => array(),
+ 'includes' => array(),
+ );
+ $args = array_merge( $defaults, $args );
</ins><span class="cx" style="display: block; padding: 0 10px"> $placeholders = array();
</span><span class="cx" style="display: block; padding: 0 10px"> // guess plugin slug
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_null($slug)) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -506,7 +493,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $placeholders['slug'] = $slug;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $output = is_null($output)? "$slug.pot" : $output;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = $this->xgettext('wp-plugin', $dir, $output, $placeholders);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->xgettext( 'wp-plugin', $dir, $output, $placeholders, $args['excludes'], $args['includes'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!$res) return false;
</span><span class="cx" style="display: block; padding: 0 10px"> $potextmeta = new PotExtMeta;
</span><span class="cx" style="display: block; padding: 0 10px"> $res = $potextmeta->append($main_file, $output);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -516,7 +503,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $res;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wp_theme($dir, $output, $slug = null) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wp_theme($dir, $output, $slug = null) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $placeholders = array();
</span><span class="cx" style="display: block; padding: 0 10px"> // guess plugin slug
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_null($slug)) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -571,49 +558,65 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $res;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function bp($dir, $output) {
- $output = is_null($output)? "buddypress.pot" : $output;
- return $this->xgettext('bp', $dir, $output, array(), array('bp-forums/bbpress/.*'));
- }
-
- function glotpress( $dir, $output ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function glotpress( $dir, $output ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $output = is_null( $output ) ? "glotpress.pot" : $output;
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->xgettext( 'glotpress', $dir, $output );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function wporg_bb_forums( $dir, $output ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wporg_bb_forums( $dir, $output ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $output = is_null( $output ) ? 'wporg.pot' : $output;
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->xgettext( 'wporg-bb-forums', $dir, $output, array(), array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'bb-plugins/elfakismet/.*',
</span><span class="cx" style="display: block; padding: 0 10px"> 'bb-plugins/support-forum/.*',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'themes/.*',
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function rosetta( $dir, $output ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function wporg_themes( $dir, $output ) {
+ $output = is_null( $output ) ? 'wporg-themes.pot' : $output;
+ return $this->xgettext( 'wporg', $dir, $output, array(), array(), array(
+ 'plugins/theme-directory/.*',
+ 'themes/pub/wporg-themes/.*'
+ ) );
+ }
+
+ public function wporg_plugins( $dir, $output ) {
+ $output = is_null( $output ) ? 'wporg-plugins.pot' : $output;
+ return $this->xgettext( 'wporg', $dir, $output, array(), array(
+ 'plugins/svn-track/i18n-tools/.*'
+ ), array(
+ '.*\.php',
+ ) );
+ }
+
+ public function wporg_forums( $dir, $output ) {
+ $output = is_null( $output ) ? 'wporg-forums.pot' : $output;
+ return $this->xgettext( 'wporg', $dir, $output, array(), array(), array(
+ '.*\.php',
+ ) );
+ }
+
+ public function wordcamporg( $dir, $output ) {
+ $output = is_null( $output ) ? 'wordcamporg.pot' : $output;
+ return $this->xgettext( 'wordcamporg', $dir, $output, array(), array(), array(
+ '.*\.php',
+ ) );
+ }
+
+ public function rosetta( $dir, $output ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $output = is_null( $output )? 'rosetta.pot' : $output;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->xgettext( 'rosetta', $dir, $output, array(), array(), array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->xgettext( 'rosetta', $dir, $output, array(), array(
+ 'mu-plugins/rosetta/i18n-tools/.*',
+ 'mu-plugins/rosetta/locales/.*',
+ ), array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'mu-plugins/(roles|showcase|downloads)/.*\.php',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'mu-plugins/jetpack-settings.php',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'mu-plugins/rosetta.*\.php',
</span><span class="cx" style="display: block; padding: 0 10px"> 'mu-plugins/rosetta/[^/]+\.php',
</span><span class="cx" style="display: block; padding: 0 10px"> 'mu-plugins/rosetta/tmpl/.*\.php',
</span><span class="cx" style="display: block; padding: 0 10px"> 'themes/rosetta/.*\.php',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- function is_ms_file( $file_name ) {
- $is_ms_file = false;
- $prefix = substr( $file_name, 0, 2 ) === './'? '\./' : '';
- foreach( $this->ms_files as $ms_file )
- if ( preg_match( '|^'.$prefix.$ms_file.'$|', $file_name ) ) {
- $is_ms_file = true;
- break;
- }
- return $is_ms_file;
- }
-
- function is_not_ms_file( $file_name ) {
- return !$this->is_ms_file( $file_name );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // run the CLI only if the file
</span></span></pre>
</div>
</div>
</body>
</html>