<!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>[BuddyPress][8408] trunk: Introduce 'latest_format' param for bp_get_blog_latest_post()</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">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/8408">8408</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2014-05-10 01:37:05 +0000 (Sat, 10 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce 'latest_format' param for bp_get_blog_latest_post()

This param allows themers to omit BP's 'Latest post: %s' wrapper around the
link to the latest post.

Fixes <a href="http://buddypress.trac.wordpress.org/ticket/5392">#5392</a>

Props lenasterg</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpblogsbpblogstemplatephp">trunk/src/bp-blogs/bp-blogs-template.php</a></li>
<li><a href="#trunksrcbplanguagesbuddypresspot">trunk/src/bp-languages/buddypress.pot</a></li>
<li><a href="#trunktestsphpunittestcasesblogstemplatephp">trunk/tests/phpunit/testcases/blogs/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpblogsbpblogstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/bp-blogs/bp-blogs-template.php (8407 => 8408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/bp-blogs/bp-blogs-template.php 2014-05-10 01:13:22 UTC (rev 8407)
+++ trunk/src/bp-blogs/bp-blogs-template.php    2014-05-10 01:37:05 UTC (rev 8408)
</span><span class="lines">@@ -671,22 +671,39 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Output the latest post from the current blog in the loop.
</span><ins>+ *
+ * @param array $args See {@link bp_get_blog_latest_post()}.
</ins><span class="cx">  */
</span><del>-function bp_blog_latest_post() {
-       echo bp_get_blog_latest_post();
</del><ins>+function bp_blog_latest_post( $args = array() ) {
+       echo bp_get_blog_latest_post( $args );
</ins><span class="cx"> }
</span><span class="cx">  /**
</span><span class="cx">   * Return the latest post from the current blog in the loop.
</span><span class="cx">   *
</span><ins>+        * @param array $args {
+        *     Array of optional arguments.
+        *     @type bool $latest_format If true, formatted "Latest post:
+        *           [link to post]". If false, formatted "[link to post]".
+        *           Default: true.
+        * }
</ins><span class="cx">    * @return string $retval String of the form 'Latest Post: [link to post]'.
</span><span class="cx">   */
</span><del>-       function bp_get_blog_latest_post() {
</del><ins>+        function bp_get_blog_latest_post( $args = array() ) {
</ins><span class="cx">           global $blogs_template;
</span><span class="cx"> 
</span><ins>+               $r = wp_parse_args( $args, array(
+                       'latest_format' => true,
+               ) );
+
</ins><span class="cx">           $retval = bp_get_blog_latest_post_title();
</span><span class="cx"> 
</span><del>-               if ( ! empty( $retval ) )
-                       $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
</del><ins>+                if ( ! empty( $retval ) ) {
+                       if ( ! empty( $r['latest_format'] ) ) {
+                               $retval = sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
+                       } else {
+                               $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
+                       }
+               }
</ins><span class="cx"> 
</span><span class="cx">          return apply_filters( 'bp_get_blog_latest_post', $retval );
</span><span class="cx">  }
</span></span></pre></div>
<a id="trunksrcbplanguagesbuddypresspot"></a>
<div class="modfile"><h4>Modified: trunk/src/bp-languages/buddypress.pot (8407 => 8408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/bp-languages/buddypress.pot    2014-05-10 01:13:22 UTC (rev 8407)
+++ trunk/src/bp-languages/buddypress.pot       2014-05-10 01:37:05 UTC (rev 8408)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> msgstr ""
</span><span class="cx"> "Project-Id-Version: BuddyPress 2.1-alpha\n"
</span><span class="cx"> "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/buddypress\n"
</span><del>-"POT-Creation-Date: 2014-05-10 00:44:57+00:00\n"
</del><ins>+"POT-Creation-Date: 2014-05-10 01:35:41+00:00\n"
</ins><span class="cx"> "MIME-Version: 1.0\n"
</span><span class="cx"> "Content-Type: text/plain; charset=utf-8\n"
</span><span class="cx"> "Content-Transfer-Encoding: 8bit\n"
</span><span class="lines">@@ -783,7 +783,7 @@
</span><span class="cx"> msgid "You do not have access to this activity."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-activity/bp-activity-screens.php:271 bp-blogs/bp-blogs-template.php:997
</del><ins>+#: bp-activity/bp-activity-screens.php:271 bp-blogs/bp-blogs-template.php:1035
</ins><span class="cx"> #: bp-friends/bp-friends-screens.php:86 bp-groups/bp-groups-screens.php:937
</span><span class="cx"> #: bp-messages/bp-messages-screens.php:169
</span><span class="cx"> #: bp-templates/bp-legacy/buddypress/members/register.php:148
</span><span class="lines">@@ -791,7 +791,7 @@
</span><span class="cx"> msgid "Yes"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-activity/bp-activity-screens.php:272 bp-blogs/bp-blogs-template.php:1001
</del><ins>+#: bp-activity/bp-activity-screens.php:272 bp-blogs/bp-blogs-template.php:1039
</ins><span class="cx"> #: bp-friends/bp-friends-screens.php:87 bp-groups/bp-groups-screens.php:938
</span><span class="cx"> #: bp-messages/bp-messages-screens.php:170
</span><span class="cx"> #: bp-templates/bp-legacy/buddypress/members/register.php:149
</span><span class="lines">@@ -959,8 +959,8 @@
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><span class="cx"> #: bp-blogs/bp-blogs-loader.php:208 bp-blogs/bp-blogs-screens.php:204
</span><del>-#: bp-blogs/bp-blogs-template.php:1114 bp-blogs/bp-blogs-template.php:1182
-#: bp-blogs/bp-blogs-template.php:1183 bp-core/bp-core-filters.php:466
</del><ins>+#: bp-blogs/bp-blogs-template.php:1152 bp-blogs/bp-blogs-template.php:1220
+#: bp-blogs/bp-blogs-template.php:1221 bp-core/bp-core-filters.php:466
</ins><span class="cx"> #: bp-themes/bp-default/blogs/create.php:21
</span><span class="cx"> #: bp-themes/bp-default/blogs/index.php:21
</span><span class="cx"> msgid "Create a Site"
</span><span class="lines">@@ -976,7 +976,7 @@
</span><span class="cx"> msgid "Profile picture of site author %s"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:648 bp-core/bp-core-classes.php:816
</del><ins>+#: bp-blogs/bp-blogs-template.php:661 bp-core/bp-core-classes.php:816
</ins><span class="cx"> #: bp-groups/bp-groups-template.php:3394 bp-groups/bp-groups-widgets.php:85
</span><span class="cx"> #: bp-groups/bp-groups-widgets.php:197 bp-members/bp-members-template.php:811
</span><span class="cx"> #: bp-members/bp-members-template.php:1231
</span><span class="lines">@@ -987,66 +987,70 @@
</span><span class="cx"> msgid "active %s"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:668
</del><ins>+#: bp-blogs/bp-blogs-template.php:666 bp-members/bp-members-template.php:816
+msgid "Never active"
+msgstr ""
+
+#: bp-blogs/bp-blogs-template.php:702
</ins><span class="cx"> msgid "Latest Post: %s"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:915
</del><ins>+#: bp-blogs/bp-blogs-template.php:953
</ins><span class="cx"> msgid "There was a problem, please correct the form below and try again."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:918
</del><ins>+#: bp-blogs/bp-blogs-template.php:956
</ins><span class="cx"> msgid ""
</span><span class="cx"> "By filling out the form below, you can <strong>add a site to your "
</span><span class="cx"> "account</strong>. There is no limit to the number of sites that you can "
</span><span class="cx"> "have, so create to your heart's content, but blog responsibly!"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:920
</del><ins>+#: bp-blogs/bp-blogs-template.php:958
</ins><span class="cx"> msgid ""
</span><span class="cx"> "If you&#8217;re not going to use a great domain, leave it for a new user. "
</span><span class="cx"> "Now have at it!"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:929
</del><ins>+#: bp-blogs/bp-blogs-template.php:967
</ins><span class="cx"> msgid "Create Site"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:951
</del><ins>+#: bp-blogs/bp-blogs-template.php:989
</ins><span class="cx"> msgid "Site Name:"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:953
</del><ins>+#: bp-blogs/bp-blogs-template.php:991
</ins><span class="cx"> msgid "Site Domain:"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:967
</del><ins>+#: bp-blogs/bp-blogs-template.php:1005
</ins><span class="cx"> msgid "Your address will be "
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:970
</del><ins>+#: bp-blogs/bp-blogs-template.php:1008
</ins><span class="cx"> msgid "blogname"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:972
</del><ins>+#: bp-blogs/bp-blogs-template.php:1010
</ins><span class="cx"> msgid "domain."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:975
</del><ins>+#: bp-blogs/bp-blogs-template.php:1013
</ins><span class="cx"> msgid ""
</span><span class="cx"> "Must be at least 4 characters, letters and numbers only. It cannot be "
</span><span class="cx"> "changed so choose carefully!)"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:981
</del><ins>+#: bp-blogs/bp-blogs-template.php:1019
</ins><span class="cx"> msgid "Site Title:"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:992
</del><ins>+#: bp-blogs/bp-blogs-template.php:1030
</ins><span class="cx"> msgid "Privacy:"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:993
</del><ins>+#: bp-blogs/bp-blogs-template.php:1031
</ins><span class="cx"> #: bp-templates/bp-legacy/buddypress/members/register.php:145
</span><span class="cx"> #: bp-themes/bp-default/registration/register.php:229
</span><span class="cx"> msgid ""
</span><span class="lines">@@ -1054,29 +1058,29 @@
</span><span class="cx"> "around this network."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1100
</del><ins>+#: bp-blogs/bp-blogs-template.php:1138
</ins><span class="cx"> msgid "Congratulations! You have successfully registered a new site."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1102
</del><ins>+#: bp-blogs/bp-blogs-template.php:1140
</ins><span class="cx"> msgid ""
</span><span class="cx"> "<a href=\"%1$s\">%2$s</a> is your new site.  <a href=\"%3$s\">Login</a> as "
</span><span class="cx"> "\"%4$s\" using your existing password."
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1131
</del><ins>+#: bp-blogs/bp-blogs-template.php:1169
</ins><span class="cx"> msgid "%s's Sites"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1132
</del><ins>+#: bp-blogs/bp-blogs-template.php:1170
</ins><span class="cx"> msgid "%s's Recent Posts"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1133
</del><ins>+#: bp-blogs/bp-blogs-template.php:1171
</ins><span class="cx"> msgid "%s's Recent Comments"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1149 bp-core/deprecated/1.5.php:417
</del><ins>+#: bp-blogs/bp-blogs-template.php:1187 bp-core/deprecated/1.5.php:417
</ins><span class="cx"> #: bp-forums/bp-forums-template.php:2196 bp-groups/bp-groups-template.php:2798
</span><span class="cx"> #: bp-members/bp-members-template.php:999
</span><span class="cx"> #: bp-messages/bp-messages-template.php:471 bp-themes/bp-default/header.php:30
</span><span class="lines">@@ -1084,11 +1088,11 @@
</span><span class="cx"> msgid "Search"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1232 bp-blogs/bp-blogs-template.php:1233
</del><ins>+#: bp-blogs/bp-blogs-template.php:1270 bp-blogs/bp-blogs-template.php:1271
</ins><span class="cx"> msgid "Visit Site"
</span><span class="cx"> msgstr ""
</span><span class="cx"> 
</span><del>-#: bp-blogs/bp-blogs-template.php:1288
</del><ins>+#: bp-blogs/bp-blogs-template.php:1326
</ins><span class="cx"> msgid "%s site"
</span><span class="cx"> msgid_plural "%s sites"
</span><span class="cx"> msgstr[0] ""
</span><span class="lines">@@ -4634,10 +4638,6 @@
</span><span class="cx"> msgstr[0] ""
</span><span class="cx"> msgstr[1] ""
</span><span class="cx"> 
</span><del>-#: bp-members/bp-members-template.php:816
-msgid "Never active"
-msgstr ""
-
</del><span class="cx"> #: bp-members/bp-members-template.php:1693
</span><span class="cx"> msgid "Your Avatar"
</span><span class="cx"> msgstr ""
</span></span></pre></div>
<a id="trunktestsphpunittestcasesblogstemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/tests/phpunit/testcases/blogs/template.php (8407 => 8408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/phpunit/testcases/blogs/template.php 2014-05-10 01:13:22 UTC (rev 8407)
+++ trunk/tests/phpunit/testcases/blogs/template.php    2014-05-10 01:37:05 UTC (rev 8408)
</span><span class="lines">@@ -61,4 +61,58 @@
</span><span class="cx">  public function test_bp_get_blog_last_active_active_no_last_activity() {
</span><span class="cx">          $this->assertEquals( __( 'Never active', 'buddypress' ), bp_get_blog_last_active() );
</span><span class="cx">  }
</span><ins>+
+       /**
+        * @group bp_get_blog_latest_post
+        */
+       public function test_bp_get_blog_latest_post_default_params() {
+               // Fake the global
+               global $blogs_template;
+
+               $blogs_template = new stdClass;
+               $blogs_template->blog = new stdClass;
+               $blogs_template->blog->latest_post = new stdClass;
+               $blogs_template->blog->latest_post->guid = 'foo';
+               $blogs_template->blog->latest_post->post_title = 'bar';
+
+               $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post() );
+
+               $blogs_template->blog = null;
+       }
+
+       /**
+        * @group bp_get_blog_latest_post
+        */
+       public function test_bp_get_blog_latest_post_latest_format_true() {
+               // Fake the global
+               global $blogs_template;
+
+               $blogs_template = new stdClass;
+               $blogs_template->blog = new stdClass;
+               $blogs_template->blog->latest_post = new stdClass;
+               $blogs_template->blog->latest_post->guid = 'foo';
+               $blogs_template->blog->latest_post->post_title = 'bar';
+
+               $this->assertSame( sprintf( __( 'Latest Post: %s', 'buddypress' ), '<a href="foo">bar</a>' ), bp_get_blog_latest_post( array( 'latest_format' => true, ) ) );
+
+               $blogs_template->blog = null;
+       }
+
+       /**
+        * @group bp_get_blog_latest_post
+        */
+       public function test_bp_get_blog_latest_post_latest_format_false() {
+               // Fake the global
+               global $blogs_template;
+
+               $blogs_template = new stdClass;
+               $blogs_template->blog = new stdClass;
+               $blogs_template->blog->latest_post = new stdClass;
+               $blogs_template->blog->latest_post->guid = 'foo';
+               $blogs_template->blog->latest_post->post_title = 'bar';
+
+               $this->assertSame( '<a href="foo">bar</a>', bp_get_blog_latest_post( array( 'latest_format' => false, ) ) );
+
+               $blogs_template->blog = null;
+       }
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>