<!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>[87] sites/trunk/wordpress.org/public_html/wp-content/plugins: Open source the slight fork of github.com/rmccue/WP-Parser powering the developer reference.</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://meta.trac.wordpress.org/changeset/87">87</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2013-09-24 16:24:09 +0000 (Tue, 24 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Open source the slight fork of github.com/rmccue/WP-Parser powering the developer reference.</pre>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/</li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencedeveloperreferencephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/developer-reference.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencepluginphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/plugin.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencetemplatephp">sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencedeveloperreferencephp"></a>
<div class="addfile"><h4>Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/developer-reference.php (0 => 87)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/developer-reference.php                             (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/developer-reference.php        2013-09-24 16:24:09 UTC (rev 87)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<?php
+/**
+ * Plugin Name: WP.org Developer Reference
+ * Version: 1.0
+ */
+
+add_action( 'plugins_loaded', 'wporg_ref_plugins_loaded' );
+function wporg_ref_plugins_loaded() {
+       if ( ! function_exists( 'wpfuncref_return_type' ) )
+               require __DIR__ . '/plugin.php';
+}
</ins><span class="cx">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/developer-reference.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencepluginphp"></a>
<div class="addfile"><h4>Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/plugin.php (0 => 87)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/plugin.php                          (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/plugin.php     2013-09-24 16:24:09 UTC (rev 87)
</span><span class="lines">@@ -0,0 +1,212 @@
</span><ins>+<?php
+
+namespace WPFuncRef;
+
+require_once __DIR__ . '/template.php';
+
+add_action( 'init', __NAMESPACE__ . '\\register_post_types' );
+add_action( 'init', __NAMESPACE__ . '\\register_taxonomies' );
+add_filter( 'wpfuncref_get_the_arguments', __NAMESPACE__ . '\\make_args_safe' );
+add_filter( 'wpfuncref_the_return_type', __NAMESPACE__ . '\\humanize_separator' );
+
+add_filter( 'the_content', __NAMESPACE__ . '\\expand_content' );
+add_filter( 'the_content', __NAMESPACE__ . '\\autop_for_non_funcref' );
+remove_filter( 'the_content', 'wpautop' );
+
+/**
+ * Register the function and class post types
+ */
+function register_post_types() {
+       $supports = array(
+               'comments',
+               'custom-fields',
+               'editor',
+               'excerpt',
+               'revisions',
+               'title',
+       );
+
+       // Functions
+       register_post_type( 'wpapi-function', array(
+               'has_archive' => 'functions',
+               'label' => __( 'Functions', 'wpfuncref' ),
+               'public' => true,
+               'rewrite' => array(
+                       'feeds' => false,
+                       'slug' => 'reference/function',
+                       'with_front' => false,
+               ),
+               'supports' => $supports,
+       ) );
+
+       // Methods
+       add_rewrite_rule( 'method/([^/]+)/([^/]+)/?$', 'index.php?post_type=wpapi-function&name=$matches[1]-$matches[2]', 'top' );
+
+       // Classes
+       register_post_type( 'wpapi-class', array(
+               'has_archive' => 'classes',
+               'label' => __( 'Classes', 'wpfuncref' ),
+               'public' => true,
+               'rewrite' => array(
+                       'feeds' => false,
+                       'slug' => 'reference/class',
+                       'with_front' => false,
+               ),
+               'supports' => $supports,
+       ) );
+
+       // Hooks
+       register_post_type( 'wpapi-hook', array(
+               'has_archive' => 'hooks',
+               'label' => __( 'Hooks', 'wpfuncref' ),
+               'public' => true,
+               'rewrite' => array(
+                       'feeds' => false,
+                       'slug' => 'reference/hook',
+                       'with_front' => false,
+               ),
+               'supports' => $supports,
+       ) );
+}
+
+/**
+ * Register the file and @since taxonomies
+ */
+function register_taxonomies() {
+       // Files
+       register_taxonomy( 'wpapi-source-file', array( 'wpapi-class', 'wpapi-function', 'wpapi-hook' ), array(
+               'label'                 => __( 'Files', 'wpfuncref' ),
+               'public'                => true,
+               'rewrite'               => array( 'slug' => 'reference/files' ),
+               'sort'                  => false,
+               'update_count_callback' => '_update_post_term_count',
+       ) );
+
+       // Package
+       register_taxonomy( 'wpapi-package', array( 'wpapi-class', 'wpapi-function', 'wpapi-hook' ), array(
+               'hierarchical'          => true,
+               'label'                 => '@package',
+               'public'                => true,
+               'rewrite'               => array( 'slug' => 'reference/package' ),
+               'sort'                  => false,
+               'update_count_callback' => '_update_post_term_count',
+       ) );
+
+       // @since
+       register_taxonomy( 'wpapi-since', array( 'wpapi-class', 'wpapi-function', 'wpapi-hook' ), array(
+               'hierarchical'          => true,
+               'label'                 => __( '@since', 'wpfuncref' ),
+               'public'                => true,
+               'rewrite'               => array( 'slug' => 'reference/since' ),
+               'sort'                  => false,
+               'update_count_callback' => '_update_post_term_count',
+       ) );
+}
+
+function method_permalink( $link, $post ) {
+       if ( $post->post_type !== 'wpapi-function' || $post->post_parent == 0 )
+               return $link;
+
+       list( $class, $method ) = explode( '-', $post->post_name );
+       $link = home_url( user_trailingslashit( "method/$class/$method" ) );
+       return $link;
+}
+add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 );
+
+/**
+ * Raw phpDoc could potentially introduce unsafe markup into the HTML, so we sanitise it here.
+ *
+ * @param array $args Parameter arguments to make safe
+ * @param array Filtered arguments
+ * @return array
+ */
+function make_args_safe( $args ) {
+       $filters = array(
+               'wp_filter_kses',
+               'make_clickable',
+               'force_balance_tags',
+               'wptexturize',
+               'convert_smilies',
+               'convert_chars',
+               'stripslashes_deep',
+       );
+
+       foreach ( $args as &$arg ) {
+               foreach ( $arg as &$value ) {
+                       foreach ( $filters as $filter_function )
+                               if ( is_array( $value ) ) {
+                                       foreach ( $value as &$v )
+                                               $v = call_user_func( $filter_function, $v );
+                               } else {
+                                       $value = call_user_func( $filter_function, $value );
+                               }
+               }
+       }
+
+       return apply_filters( 'wpfuncref_make_args_safe', $args );
+}
+
+/**
+ * Replace separators with a more readable version
+ *
+ * @param string $type Variable type
+ * @return string
+ */
+function humanize_separator( $type ) {
+       return str_replace( '|', '<span class="wpapi-item-type-or">' . _x( ' or ', 'separator', 'wpfuncref' ) . '</span>', $type );
+}
+
+/**
+ * Extend the post's content with function reference pieces
+ *
+ * @param string $content Unfiltered content
+ * @return string Content with Function reference pieces added
+ */
+function expand_content( $content ) {
+       $post = get_post();
+
+       if ( $post->post_type !== 'wpapi-class' && $post->post_type !== 'wpapi-function' && $post->post_type !== 'wpapi-hook' )
+               return $content;
+
+       $before_content = wpfuncref_prototype();
+       $before_content .= '<p class="wpfuncref-description">' . get_the_excerpt() . '</p>';
+       $before_content .= '<div class="wpfuncref-longdesc">';
+
+       $after_content = '</div>';
+       $after_content .= '<div class="wpfuncref-arguments"><h3>Arguments</h3>';
+       $args = wpfuncref_get_the_arguments();
+       foreach ( $args as $arg ) {
+               $after_content .= '<div class="wpfuncref-arg">';
+               $after_content .= '<h4><code><span class="type">' . implode( '|', $arg['types'] ) . '</span> <span class="variable">' . $arg['name'] . '</span></code></h4>';
+               $after_content .= wpautop( $arg['desc'], false );
+               $after_content .= '</div>';
+       }
+       $after_content .= '</div>';
+
+       $source = wpfuncref_source_link();
+       if ( $source )
+               $after_content .= '<a href="' . $source . '">Source</a>';
+
+       $before_content = apply_filters( 'wpfuncref_before_content', $before_content );
+       $after_content = apply_filters( 'wpfuncref_after_content', $after_content );
+
+       return $before_content . $content . $after_content;
+}
+
+/**
+ * Re-enable autopee for the non-funcref posts
+ *
+ * We can't selectively filter the_content for wpautop, so we remove it and
+ * readd this to check instead.
+ *
+ * @param string $content Unfiltered content
+ * @return string Autopeed content
+ */
+function autop_for_non_funcref( $content ) {
+       $post = get_post();
+
+       if ( $post->post_type !== 'wpapi-class' && $post->post_type !== 'wpapi-function' )
+               $content = wpautop( $content );
+
+       return $content;
+}
</ins><span class="cx">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/plugin.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span><a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsdeveloperreferencetemplatephp"></a>
<div class="addfile"><h4>Added: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/template.php (0 => 87)</h4>
<pre class="diff"><span>
<span class="info">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/template.php                                (rev 0)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/template.php   2013-09-24 16:24:09 UTC (rev 87)
</span><span class="lines">@@ -0,0 +1,180 @@
</span><ins>+<?php
+
+/**
+ * Get the current function's return types
+ *
+ * @return array
+ */
+function wpfuncref_return_type() {
+       $function_data = get_post_meta( get_the_ID(), '_wpapi_tags', true );
+       $return_type   = wp_list_filter( $function_data, array( 'name' => 'return' ) );
+
+       if ( ! empty( $return_type ) ) {
+               // Grab the description from the return type
+               $return_type = array_shift( $return_type );
+               $return_type = $return_type['types'];
+       } else {
+               $return_type = array( 'void' );
+       }
+
+       return apply_filters( 'wpfuncref_the_return_type', $return_type );
+}
+
+/**
+ * Print the current function's return type
+ *
+ * @see wpfuncref_return_type
+ */
+function wpfuncref_the_return_type() {
+       echo implode( '|', wpfuncref_return_type() );
+}
+
+/**
+ * Get the current function's return description
+ *
+ * @return string
+ */
+function wpfuncref_return_desc() {
+       $function_data = get_post_meta( get_the_ID(), '_wpapi_tags', true );
+       $return_desc   = wp_list_filter( $function_data, array( 'name' => 'return' ) );
+
+       if ( ! empty( $return_desc ) ) {
+               // Grab the description from the return type
+               $return_desc = array_shift( $return_desc );
+               $return_desc = $return_desc['content'];
+       } else {
+               $return_desc = '';
+       }
+
+       return apply_filters( 'wpfuncref_the_return_desc', $return_desc );
+}
+
+/**
+ * Print the current function's return description
+ */
+function wpfuncref_the_return_desc() {
+       echo wpfuncref_return_desc();
+}
+
+/**
+ * Do any of the current function's arguments have a default value?
+ *
+ * @return bool
+ */
+function wpfuncref_arguments_have_default_values() {
+       $retval = wp_list_filter( get_post_meta( get_the_ID(), '_wpapi_args', true ), array( 'name' => 'default' ) );
+       return apply_filters( 'wpfuncref_arguments_have_default_values', ! empty( $retval ) );
+}
+
+/**
+ * Is the current function deprecated?
+ *
+ * @return bool
+ */
+function wpfuncref_is_function_deprecated() {
+       $retval = wp_list_filter( get_post_meta( get_the_ID(), '_wpapi_tags', true ), array( 'name' => 'deprecated' ) );
+       return apply_filters( 'wpfuncref_is_function_deprecated', ! empty( $retval ) );
+}
+
+/**
+ * Return the current function's arguments.
+ *
+ * @return array array( [0] => array( 'name' => '', 'type' => '', 'desc' => '' ), ... )
+ */
+function wpfuncref_get_the_arguments() {
+       $args_data     = get_post_meta( get_the_ID(), '_wpapi_args', true );
+       $function_data = get_post_meta( get_the_ID(), '_wpapi_tags', true );
+       $params        = wp_list_filter( $function_data, array( 'name' => 'param' ) );
+       $return_args   = array();
+
+       if ( ! empty( $args_data ) ) {
+               foreach ( $args_data as $arg ) {
+                       $param_tag = wp_list_filter( $params, array( 'variable' => $arg['name'] ) );
+                       $param_tag = array_shift( $param_tag );
+
+                       $param = array(
+                               'name' => $arg['name'],
+                       );
+
+                       if ( ! empty( $arg['default'] ) )
+                               $param['default_value'] = $arg['default'];
+
+                       if ( ! empty( $arg['type'] ) )
+                               $param['types'] = array( $arg['type'] );
+                       else if ( ! empty( $param_tag['types'] ) )
+                               $param['types'] = $param_tag['types'];
+                       else
+                               $param['types'] = array();
+
+                       if ( ! empty( $param_tag['content'] ) )
+                               $param['desc'] = $param_tag['content'];
+
+                       $return_args[] = $param;
+               }
+       }
+
+       return apply_filters( 'wpfuncref_get_the_arguments', $return_args );
+}
+
+/**
+ * Retrieve the function's prototype as HTML
+ *
+ * Use the wpfuncref_prototype filter to change the content of this.
+ *
+ * @return string Prototype HTML
+ */
+function wpfuncref_prototype() {
+       $type = wpfuncref_return_type();
+
+       $friendly_args = array();
+       $args = wpfuncref_get_the_arguments();
+       foreach ( $args as $arg ) {
+               $friendly = sprintf( '<span class="type">%s</span> <span class="variable">%s</span>', implode( '|', $arg['types'] ), $arg['name'] );
+               if ( !empty( $arg['default_value'] ) )
+                       $friendly .= ' <span class="default"> = <span class="value">' . $arg['default_value'] . '</span></span>';
+
+               $friendly_args[] = $friendly;
+       }
+       $friendly_args = implode( ', ', $friendly_args );
+
+       $name = get_the_title();
+
+       $prototype = sprintf( '<p class="wpfuncref-prototype"><code><span class="type">%s</span> %s ( %s )</code></p>', implode( '|', $type ), $name, $friendly_args );
+
+       return apply_filters( 'wpfuncref_prototype', $prototype );
+}
+
+/**
+ * Print the function's prototype
+ *
+ * @see wpfuncref_prototype
+ */
+function wpfuncref_the_prototype() {
+       echo wpfuncref_prototype();
+}
+
+
+/**
+ * Returns the URL to the current function on the bbP/BP trac.
+ *
+ * @return string
+ */
+function wpfuncref_source_link() {
+       $trac_url = apply_filters( 'wpfuncref_source_link_base', false );
+       if ( empty( $trac_url ) )
+               return '';
+
+       // Find the current post in the wpapi-source-file term
+       $term = get_the_terms( get_the_ID(), 'wpapi-source-file' );
+       if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
+               $term      = array_shift( $term );
+               $line_num  = (int) get_post_meta( get_the_ID(), '_wpapi_line_num', true );
+
+               // The format here takes the base URL, the term name, and the line number
+               $format = apply_filters( 'wpfuncref_source_link_format', '%s%s#L%d' );
+               // Link to the specific file name and the line number on trac
+               $trac_url = sprintf( $format, $trac_url, $term->name, $line_num );
+       }
+
+       return $trac_url;
+}
</ins><span class="cx">Property changes on: sites/trunk/wordpress.org/public_html/wp-content/plugins/developer-reference/template.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<ins>+native
</ins><span class="cx">\ No newline at end of property
</span></div>

</body>
</html>