Making WordPress.org

Changeset 10088


Ignore:
Timestamp:
07/22/2020 03:06:25 AM (4 years ago)
Author:
tellyworth
Message:

Plugin directory: add some helper functions to the block validator class.

See #5303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-block-plugin-checker.php

    r10085 r10088  
    5555
    5656    /**
     57     * Magic accessor method, for read-only access to internals.
     58     *
     59     * @param string $name Property name.
     60     */
     61    public function __get( $name ) {
     62        if ( property_exists( $this, $name ) ) {
     63            return $this->$name;
     64        }
     65    }
     66
     67    /**
    5768     * Getter function for results.
    5869     */
     
    6980
    7081        return $out;
     82    }
     83
     84    /**
     85     * Return a trac/github browser link to a file in the plugin.
     86     *
     87     * @param string $file The file pathname.
     88     */
     89    public function get_browser_url( $file ) {
     90        if ( !empty( $this->repo_url ) ) {
     91            $file = $this->relative_filename( $file );
     92            if ( 0 === strpos( $this->repo_url, 'https://github.com' ) ) {
     93                return str_replace( '.git/trunk', '/blob/master', $this->repo_url ) . '/' . $file;
     94            } elseif ( 0 === strpos( $this->repo_url, 'https://plugins.svn.wordpress.org' ) ) {
     95                return str_replace( 'https://plugins.svn.wordpress.org', 'https://plugins.trac.wordpress.org/browser', $this->repo_url ) . '/' . $file;
     96            }
     97        }
    7198    }
    7299
Note: See TracChangeset for help on using the changeset viewer.