<!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>[13443] sites/trunk/wordpress.org/public_html/wp-content: Plugin Directory: Store error codes (rather than english error messages) that occur during a plugin import, to allow the errors to be generated with the appropriate translations.</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 { white-space: pre-line; 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="http://meta.trac.wordpress.org/changeset/13443">13443</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/13443","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-04-03 07:01:21 +0000 (Wed, 03 Apr 2024)</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'>Plugin Directory: Store error codes (rather than english error messages) that occur during a plugin import, to allow the errors to be generated with the appropriate translations.
This expands some errors to better highlight what is invalid as well.
See <a href="http://meta.trac.wordpress.org/ticket/6108">#6108</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycliclassimportphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryreadmeclassparserphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryreadmeclassvalidatorphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginsinctemplatetagsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgplugins2024inctemplatetagsphp">sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycliclassimportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2024-04-03 06:52:32 UTC (rev 13442)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2024-04-03 07:01:21 UTC (rev 13443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,14 +105,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If the readme generated any warnings, raise it to self::$import_warnings;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $readme->warnings ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Convert the warnings to a human readable format.
- $readme_warnings = Readme_Validator::instance()->validate_content( $readme->raw_contents );
-
- foreach ( [ 'errors', 'warnings' ] as $field ) {
- foreach ( $readme_warnings[ $field ] ?? [] as $warning ) {
- $this->warnings[] = "Readme: {$warning}";
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->warnings = array_merge( $this->warnings, $readme->warnings );
</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"> // Validate various headers:
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,9 +120,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $headers->UpdateURI ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $update_uri_valid = preg_match( '!^(https?://)?(wordpress.org|w.org)/plugins?/(?P<slug>[^/]+)/?$!i', $headers->UpdateURI, $update_uri_matches );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $update_uri_valid || $update_uri_matches['slug'] !== $plugin_slug ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->warnings['invalid_update_uri'] = 'Invalid Update URI header detected: ' . $headers->UpdateURI;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->warnings['invalid_update_uri'] = $headers->UpdateURI;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new Exception( $this->warnings['invalid_update_uri'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new Exception( Readme_Validator::instance()->translate_code_to_message( 'invalid_update_uri' ) );
</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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,9 +145,9 @@
</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"> if ( $unmet_dependencies ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->warnings['unmet_dependencies'] = 'Invalid plugin dependencies specified. The following dependencies could not be resolved: ' . implode( ', ', $requires_plugins_unmet );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->warnings['unmet_dependencies'] = $requires_plugins_unmet;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new Exception( $this->warnings['unmet_dependencies'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new Exception( Readme_Validator::instance()->translate_code_to_message( 'unmet_dependencies', $requires_plugins_unmet ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $_requires_plugins, $unmet_dependencies );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1168,7 +1161,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">- // Normalise a "install theme from url" to a install-by-slug.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Normalize a "install theme from url" to a install-by-slug.
</ins><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> 'installTheme' === $step['step'] &&
</span><span class="cx" style="display: block; padding: 0 10px"> isset( $step['themeZipFile']['url'] ) &&
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1209,7 +1202,6 @@
</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">-
</del><span class="cx" style="display: block; padding: 0 10px"> $contents = json_encode( $decoded_file ); // Re-encode to minimize whitespace
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryreadmeclassparserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php 2024-04-03 06:52:32 UTC (rev 13442)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php 2024-04-03 07:01:21 UTC (rev 13443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,31 +307,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->tags = explode( ',', $headers['tags'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->tags = array_map( 'trim', $this->tags );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->tags = array_filter( $this->tags );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( array_intersect( $this->tags, $this->ignore_tags ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->tags = array_diff( $this->tags, $this->ignore_tags );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->warnings['ignored_tags'] = 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">- // Check if the tags are low-quality (ie. little used)
- if ( $this->tags && taxonomy_exists( 'plugin_tags' ) ) {
- $tags = get_terms( array(
- 'taxonomy' => 'plugin_tags',
- 'name' => $this->tags,
- ) );
-
- $low_usage_tags = array_filter(
- $tags,
- function( $term ) {
- return $term->count < 5;
- }
- );
-
- $this->warnings['low_usage_tags'] = wp_list_pluck( $low_usage_tags, 'name' );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( count( $this->tags ) > 5 ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->warnings['too_many_tags'] = array_slice( $this->tags, 4 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->tags = array_slice( $this->tags, 0, 5 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->warnings['too_many_tags'] = true;
</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"> if ( ! empty( $headers['requires'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -714,8 +698,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // In the event that something invalid is used, we'll ignore it (Example: 'Joe Bloggs (Australian Translation)')
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $user ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->warnings['contributor_ignored'] ??= [];
+ $this->warnings['contributor_ignored'][] = $name;
</ins><span class="cx" style="display: block; padding: 0 10px"> unset( $users[ $i ] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->warnings['contributor_ignored'] = true;
</del><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -722,7 +707,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Overwrite whatever the author has specified with the sanitized nicename.
</span><span class="cx" style="display: block; padding: 0 10px"> $users[ $i ] = $user->user_nicename;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> return $users;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectoryreadmeclassvalidatorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php 2024-04-03 06:52:32 UTC (rev 13442)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php 2024-04-03 07:01:21 UTC (rev 13443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,137 +62,110 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Array of the readme validation results.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function validate_content( $readme ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output = $this->validate( $readme );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Translate error codes to human-readable messages.
+ foreach ( $output as $type => $items ) {
+ foreach ( $items as $error_code => $error_data ) {
+ $output[ $type ][ $error_code ] = $this->translate_code_to_message( $error_code, $error_data );
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Validates a readme by string, and returns a structured array of errors, warnings, and notes.
+ *
+ * These elements can be swapped for a textual translated string at display time via translate_code_to_message().
+ *
+ * @param string $readme The text of the readme.
+ * @return array Array of the readme validation result codes.
+ */
+ public function validate( $readme ) {
+ $errors = $warnings = $notes = array();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Security note: Keep the data: protocol here, Parser accepts a string HOWEVER
</span><span class="cx" style="display: block; padding: 0 10px"> // if a submitted readme.txt URL contents were to contain a file or URL-like string,
</span><span class="cx" style="display: block; padding: 0 10px"> // it could bypass the protections above in validate_url().
</span><span class="cx" style="display: block; padding: 0 10px"> $readme = new Parser( 'data:text/plain,' . urlencode( $readme ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $errors = $warnings = $notes = array();
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Fatal errors.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $readme->name ) || isset( $readme->warnings['invalid_plugin_name_header'] ) ) {
- $errors[] = sprintf(
- /* translators: 1: 'Plugin Name' section title, 2: 'Plugin Name' */
- __( 'We cannot find a plugin name in your readme. Plugin names look like: %1$s. Please change %2$s to reflect the actual name of your plugin.', 'wporg-plugins' ),
- '<code>=== Plugin Name ===</code>',
- '<code>Plugin Name</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $readme->warnings['invalid_plugin_name_header'] ) ) {
+ $errors['invalid_plugin_name_header'] = $readme->warnings['invalid_plugin_name_header'];
+ } elseif ( empty( $readme->name ) ) {
+ $errors['invalid_plugin_name_header'] = true;
</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"> // Warnings & Notes.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $readme->warnings['requires_header_ignored'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '5.0';
-
- $warnings[] = sprintf(
- /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 4.9. */
- __( 'The %1$s field was ignored. This field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
- '<code>Requires at least</code>',
- '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
- '<code>' . number_format( $latest_wordpress_version - 0.1, 1 ) . '</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['requires_header_ignored'] = $readme->warnings['requires_header_ignored'];
</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"> if ( isset( $readme->warnings['tested_header_ignored'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '5.0';
-
- $warnings[] = sprintf(
- /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 5.1. */
- __( 'The %1$s field was ignored. This field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
- '<code>Tested up to</code>',
- '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
- '<code>' . number_format( $latest_wordpress_version + 0.1, 1 ) . '</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['tested_header_ignored'] = $readme->warnings['tested_header_ignored'];
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( empty( $readme->tested ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = sprintf(
- /* translators: %s: plugin header tag */
- __( 'The %s field is missing.', 'wporg-plugins' ),
- '<code>Tested up to</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['tested_header_missing'] = true;
</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"> if ( isset( $readme->warnings['requires_php_header_ignored'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = sprintf(
- /* translators: 1: plugin header tag; 2: Example version 5.2.4. 3: Example version 7.0. */
- __( 'The %1$s field was ignored. This field should only contain a PHP version such as %2$s or %3$s.', 'wporg-plugins' ),
- '<code>Requires PHP</code>',
- '<code>5.2.4</code>',
- '<code>7.0</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['requires_php_header_ignored'] = $readme->warnings['requires_php_header_ignored'];
</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"> if ( empty( $readme->stable_tag ) || str_contains( $readme->stable_tag, 'trunk' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = sprintf(
- /* translators: 1: 'Stable tag', 2: /trunk/ SVN directory */
- __( 'The %1$s field is missing or invalid. Note: We ask you no longer attempt to use %2$s as stable, so that all plugins can be rolled back.', 'wporg-plugins' ),
- '<code>Stable tag</code>',
- '<code>/trunk/</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['stable_tag_invalid'] = true;
</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"> if ( isset( $readme->warnings['contributor_ignored'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = sprintf(
- /* translators: %s: plugin header tag */
- __( 'One or more contributors listed were ignored. The %s field should only contain WordPress.org usernames. Remember that usernames are case-sensitive.', 'wporg-plugins' ),
- '<code>Contributors</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['contributor_ignored'] = $readme->warnings['contributor_ignored'];
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif ( ! count( $readme->contributors ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: plugin header tag */
- __( 'The %s field is missing.', 'wporg-plugins' ),
- '<code>Contributors</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['contributors_missing'] = true;
</ins><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">+ if ( empty( $readme->license ) ) {
+ $warnings['license_missing'] = true;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $readme->warnings['too_many_tags'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = __( 'One or more tags were ignored. Please limit your plugin to 5 tags.', 'wporg-plugins' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['too_many_tags'] = $readme->warnings['too_many_tags'];
</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"> if ( isset( $readme->warnings['ignored_tags'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $warnings[] = sprintf(
- /* translators: %s: list of tags not supported */
- __( 'One or more tags were ignored. The following tags are not permitted: %s', 'wporg-plugins' ),
- '<code>' . implode( '</code>, <code>', $readme->ignore_tags ) . '</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings['ignored_tags'] = $readme->warnings['ignored_tags'];
</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">- if ( isset( $readme->warnings['low_usage_tags'] ) ) {
- $notes[] = sprintf(
- /* translators: %s: list of tags with low usage. */
- __( 'The following tags are not widely used: %s', 'wporg-plugins' ),
- '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $readme->warnings['low_usage_tags'] ) ) . '</code>'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check if the tags are low-quality (ie. little used)
+ if ( $readme->tags && taxonomy_exists( 'plugin_tags' ) ) {
+ $tags = get_terms( array(
+ 'taxonomy' => 'plugin_tags',
+ 'name' => $readme->tags,
+ ) );
+
+ $low_usage_tags = array_filter(
+ $tags,
+ function( $term ) {
+ return $term->count < 5;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( $low_usage_tags ) {
+ $notes['low_usage_tags'] = wp_list_pluck( $low_usage_tags, 'name' );
+ }
</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"> if ( empty( $readme->requires ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: plugin header tag */
- __( 'The %s field is missing. It should be defined here, or in your main plugin file.', 'wporg-plugins' ),
- '<code>Requires at least</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['requires_header_missing'] = true;
</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"> if ( empty( $readme->requires_php ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: plugin header tag */
- __( 'The %s field is missing. It should be defined here, or in your main plugin file.', 'wporg-plugins' ),
- '<code>Requires PHP</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['requires_php_header_missing'] = true;
</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"> if ( isset( $readme->warnings['no_short_description_present'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: section title */
- __( 'The %s section is missing. An excerpt was generated from your main plugin description.', 'wporg-plugins' ),
- '<code>Short Description</code>'
- );
- } elseif( isset( $readme->warnings['trimmed_short_description'] ) ) {
- $warnings[] = sprintf(
- /* translators: %s: section title */
- __( 'The %s section is too long and was truncated. A maximum of 150 characters is supported.', 'wporg-plugins' ),
- '<code>Short Description</code>',
- number_format_i18n( $readme->maximum_field_lengths['short_description'] )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['no_short_description_present'] = $readme->warnings['no_short_description_present'];
+
+ } elseif ( isset( $readme->warnings['trimmed_short_description'] ) ) {
+ $warnings['trimmed_short_description'] = $readme->warnings['trimmed_short_description'];
</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"> $trimmed_sections = array_filter( $readme->warnings, function( $warning ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -199,59 +172,232 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return str_contains( $warning, 'trimmed_section_' );
</span><span class="cx" style="display: block; padding: 0 10px"> }, ARRAY_FILTER_USE_KEY );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $trimmed_sections as $section_name => $dummy ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $section_name = str_replace( 'trimmed_section_', '', $section_name );
-
- $max_length_field = "section-{$section_name}";
- if ( ! isset( $readme->maximum_field_lengths[ $max_length_field ] ) ) {
- $max_length_field = 'section';
- }
-
- $warnings[] = sprintf(
- /* translators: %s: section title */
- __( 'The %s section is too long and was truncated. A maximum of %s words is supported.', 'wporg-plugins' ),
- '<code>' . esc_html( ucwords( str_replace( '_', ' ', $section_name ) ) ) . '</code>',
- number_format_i18n( $readme->maximum_field_lengths[ $max_length_field ] )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $warnings[ $section_name ] = true;
</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"> if ( empty( $readme->sections['faq'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: section title */
- __( 'No %s section was found', 'wporg-plugins' ),
- '<code>== Frequently Asked Questions ==</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['faq_missing'] = true;
</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"> if ( empty( $readme->sections['changelog'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: section title */
- __( 'No %s section was found', 'wporg-plugins' ),
- '<code>== Changelog ==</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['changelog_missing'] = true;
</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"> if ( empty( $readme->upgrade_notice ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: section title */
- __( 'No %s section was found', 'wporg-plugins' ),
- '<code>== Upgrade Notice ==</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['upgrade_notice_missing'] = true;
</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"> if ( empty( $readme->screenshots ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = sprintf(
- /* translators: %s: section title */
- __( 'No %s section was found', 'wporg-plugins' ),
- '<code>== Screenshots ==</code>'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['screenshots_missing'] = true;
</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"> if ( empty( $readme->donate_link ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notes[] = __( 'No donate link was found', 'wporg-plugins' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notes['donate_link_missing'] = true;
</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"> return compact( 'errors', 'warnings', 'notes' );
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Translate an error code to a human-readable message.
+ *
+ * @param string $error_code The error code to translate.
+ * @param mixed $data Optional data to provide context in the message.
+ * @return string|false The translated message, or false if the error code is not recognized.
+ */
+ public function translate_code_to_message( $error_code, $data = false ) {
+ if ( $data && is_bool( $data ) ) {
+ $data = false;
+ }
+
+ switch( $error_code ) {
+ case 'invalid_plugin_name_header':
+ return sprintf(
+ /* translators: 1: 'Plugin Name' section title, 2: 'Plugin Name' */
+ __( 'We cannot find a plugin name in your readme. Plugin names look like: %1$s. Please change %2$s to reflect the actual name of your plugin.', 'wporg-plugins' ),
+ '<code>=== Plugin Name ===</code>',
+ '<code>Plugin Name</code>'
+ );
+ case 'requires_header_ignored':
+ $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '6.5';
+
+ return sprintf(
+ /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 4.9. */
+ __( 'The %1$s field was ignored. This field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
+ '<code>Requires at least</code>',
+ '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
+ '<code>' . number_format( $latest_wordpress_version - 0.1, 1 ) . '</code>'
+ );
+ case 'tested_header_ignored':
+ $latest_wordpress_version = defined( 'WP_CORE_STABLE_BRANCH' ) ? WP_CORE_STABLE_BRANCH : '6.5';
+
+ return sprintf(
+ /* translators: 1: plugin header tag; 2: Example version 5.0. 3: Example version 5.1. */
+ __( 'The %1$s field was ignored. This field should only contain a valid WordPress version such as %2$s or %3$s.', 'wporg-plugins' ),
+ '<code>Tested up to</code>',
+ '<code>' . number_format( $latest_wordpress_version, 1 ) . '</code>',
+ '<code>' . number_format( $latest_wordpress_version + 0.1, 1 ) . '</code>'
+ );
+ case 'tested_header_missing':
+ return sprintf(
+ /* translators: %s: plugin header tag */
+ __( 'The %s field is missing.', 'wporg-plugins' ),
+ '<code>Tested up to</code>'
+ );
+ case 'requires_header_missing':
+ return sprintf(
+ /* translators: %s: plugin header tag */
+ __( 'The %s field is missing. It should be defined here, or in your main plugin file.', 'wporg-plugins' ),
+ '<code>Requires at least</code>'
+ );
+ case 'requires_php_header_ignored':
+ global $required_php_version; // WP wp-includes/version.php.
+ return sprintf(
+ /* translators: 1: plugin header tag; 2: Example version 7.0. 3: Example version 8.2. */
+ __( 'The %1$s field was ignored. This field should only contain a PHP version such as %2$s or %3$s.', 'wporg-plugins' ),
+ '<code>Requires PHP</code>',
+ '<code>' . esc_html( $required_php_version ?? '7.0' ) . '</code>',
+ '<code>8.2</code>'
+ );
+ case 'requires_php_header_missing':
+ return sprintf(
+ /* translators: %s: plugin header tag */
+ __( 'The %s field is missing. It should be defined here, or in your main plugin file.', 'wporg-plugins' ),
+ '<code>Requires PHP</code>'
+ );
+ case 'stable_tag_invalid':
+ return sprintf(
+ /* translators: 1: 'Stable tag', 2: /trunk/ SVN directory */
+ __( 'The %1$s field is missing or invalid. Note: We ask you no longer attempt to use %2$s as stable, so that all plugins can be rolled back.', 'wporg-plugins' ),
+ '<code>Stable tag</code>',
+ '<code>/trunk/</code>'
+ );
+ case 'contributor_ignored':
+ if ( ! $data ) {
+ return sprintf(
+ /* translators: %s: plugin header tag */
+ __( 'One or more contributors listed were ignored. The %s field should only contain WordPress.org usernames.', 'wporg-plugins' ),
+ '<code>Contributors</code>'
+ );
+ } else {
+ return sprintf(
+ /* translators: 1: List of authors from the readme 2: plugin header tag */
+ __( 'The following contributors listed were ignored, as the WordPress.org user could not be found. %1$s. The %2$s field should only contain WordPress.org usernames.', 'wporg-plugins' ),
+ '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $data ) ) . '</code>',
+ '<code>Contributors</code>'
+ );
+ }
+ case 'contributors_missing':
+ return sprintf(
+ /* translators: %s: plugin header tag */
+ __( 'The %s field is missing.', 'wporg-plugins' ),
+ '<code>Contributors</code>'
+ );
+ case 'too_many_tags':
+ if ( $data ) {
+ return sprintf(
+ /* translators: %s: list of tags not supported */
+ __( 'One or more tags were ignored: %s. Please limit your plugin to 5 tags.', 'wporg-plugins' ),
+ '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $data ) ) . '</code>'
+ );
+ } else {
+ return __( 'One or more tags were ignored. Please limit your plugin to 5 tags.', 'wporg-plugins' );
+ }
+ case 'ignored_tags':
+ return sprintf(
+ /* translators: %s: list of tags not supported */
+ __( 'One or more tags were ignored. The following tags are not permitted: %s', 'wporg-plugins' ),
+ '<code>' . implode( '</code>, <code>', $readme->ignore_tags ) . '</code>'
+ );
+ case 'low_usage_tags':
+ return sprintf(
+ /* translators: %s: list of tags with low usage. */
+ __( 'The following tags are not widely used: %s', 'wporg-plugins' ),
+ '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $data ) ) . '</code>'
+ );
+ case 'no_short_description_present':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'The %s section is missing. An excerpt was generated from your main plugin description.', 'wporg-plugins' ),
+ '<code>Short Description</code>'
+ );
+ case 'trimmed_short_description':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'The %s section is too long and was truncated. A maximum of %s characters is supported.', 'wporg-plugins' ),
+ '<code>Short Description</code>',
+ number_format_i18n( (new Parser)->maximum_field_lengths['short_description'] )
+ );
+ case 'trimmed_section_description':
+ case 'trimmed_section_installation':
+ case 'trimmed_section_faq':
+ case 'trimmed_section_screenshots':
+ case 'trimmed_section_changelog':
+ case 'trimmed_section_upgrade_notice':
+ case 'trimmed_section_other_notes':
+ $readme = new Parser;
+ $section_name = str_replace( 'trimmed_section_', '', $error_code );
+
+ $max_length_field = "section-{$section_name}";
+ if ( ! isset( $readme->maximum_field_lengths[ $max_length_field ] ) ) {
+ $max_length_field = 'section';
+ }
+
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'The %s section is too long and was truncated. A maximum of %s words is supported.', 'wporg-plugins' ),
+ '<code>' . esc_html( ucwords( str_replace( '_', ' ', $section_name ) ) ) . '</code>',
+ number_format_i18n( $readme->maximum_field_lengths[ $max_length_field ] )
+ );
+ case 'faq_missing':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'No %s section was found', 'wporg-plugins' ),
+ '<code>== Frequently Asked Questions ==</code>'
+ );
+ case 'changelog_missing':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'No %s section was found', 'wporg-plugins' ),
+ '<code>== Changelog ==</code>'
+ );
+ case 'upgrade_notice_missing':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'No %s section was found', 'wporg-plugins' ),
+ '<code>== Upgrade Notice ==</code>'
+ );
+ case 'screenshots_missing':
+ return sprintf(
+ /* translators: %s: section title */
+ __( 'No %s section was found', 'wporg-plugins' ),
+ '<code>== Screenshots ==</code>'
+ );
+ case 'donate_link_missing':
+ return __( 'No donate link was found', 'wporg-plugins' );
+ case 'license_missing':
+ return sprintf(
+ /* translators: 1: 'License' */
+ __( 'The %1$s field is missing or invalid. A GPLv2 or later compatible license should be specified.', 'wporg-plugins' ),
+ '<code>License</code>'
+ );
+
+ /* The are not generated by the Readme Parser, but rather the import parser. */
+ case 'invalid_update_uri':
+ return sprintf(
+ /* translators: %s 'Update URI' */
+ __( 'The %s specified is invalid. This field should not be used with WordPress.org hosted plugins.', 'wporg-plugins' ),
+ '<code>Update URI</code>'
+ );
+ case 'unmet_dependencies':
+ return sprintf(
+ /* translators: %s: list of plugin dependencies */
+ __( 'Invalid plugin dependencies specified. The following dependencies could not be resolved: %s', 'wporg-plugins' ),
+ '<code>' . implode( '</code>, <code>', array_map( 'esc_html', $data ) ) . '</code>'
+ );
+ }
+
+ return false;
</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></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgpluginsinctemplatetagsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php 2024-04-03 06:52:32 UTC (rev 13442)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php 2024-04-03 07:01:21 UTC (rev 13443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -720,6 +720,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $import_warnings = get_post_meta( $post->ID, '_import_warnings', true );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $import_warnings ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( ! wp_is_numeric_array( $import_warnings ) ) {
+ // error_code => error_data, convert to error_code => human_readable_error
+
+ foreach ( $import_warnings as $error_code => $error_data ) {
+ $import_warnings[ $error_code ] = Readme_Validator::instance()->translate_code_to_message( $error_code, $error_data );
+ }
+ } else {
+ // back-compat; previously this was an array of numeric indexed human-readable strings.
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $import_warnings = '<ul><li>' . implode( '</li><li>', $import_warnings ) . '</li></ul>';
</span><span class="cx" style="display: block; padding: 0 10px"> printf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="notice notice-error notice-alt">%s</div>',
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentthemespubwporgplugins2024inctemplatetagsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php 2024-04-03 06:52:32 UTC (rev 13442)
+++ sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php 2024-04-03 07:01:21 UTC (rev 13443)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -720,6 +720,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $import_warnings = get_post_meta( $post->ID, '_import_warnings', true );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $import_warnings ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( ! wp_is_numeric_array( $import_warnings ) ) {
+ // error_code => error_data, convert to error_code => human_readable_error
+
+ foreach ( $import_warnings as $error_code => $error_data ) {
+ $import_warnings[ $error_code ] = Readme_Validator::instance()->translate_code_to_message( $error_code, $error_data );
+ }
+ } else {
+ // back-compat; previously this was an array of numeric indexed human-readable strings.
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $import_warnings = '<ul><li>' . implode( '</li><li>', $import_warnings ) . '</li></ul>';
</span><span class="cx" style="display: block; padding: 0 10px"> printf(
</span><span class="cx" style="display: block; padding: 0 10px"> '<div class="notice notice-error notice-alt">%s</div>',
</span></span></pre>
</div>
</div>
</body>
</html>