Making WordPress.org


Ignore:
Timestamp:
04/22/2020 09:22:31 PM (4 years ago)
Author:
coffee2code
Message:

Developer theme: Filter Markdown edit URL for imported block editor handbook pages to point to the source repo's master branch instead of branch for current WP release.

Props mkaz, coffee2code.
Fixes #5151.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/import-block-editor.php

    r9678 r9764  
    2424        add_filter( 'wporg_markdown_before_transform', array( $this, 'wporg_markdown_before_transform' ),  10, 2 );
    2525        add_filter( 'wporg_markdown_after_transform',  array( $this, 'wporg_markdown_after_transform' ), 10, 2 );
     26        add_filter( 'wporg_markdown_edit_link',        array( $this, 'wporg_markdown_edit_link' ), 10, 2 );
    2627
    2728        add_filter( 'syntaxhighlighter_htmlresult',    array( $this, 'fix_code_entity_encoding' ) );
     
    290291
    291292    /**
     293     * Modifies the GitHub edit URL to point to master instead of the imported branch.
     294     *
     295     * @param string $link    The link to edit the post on GitHub.
     296     * @param int    $post_id The post ID.
     297     * @return string
     298     */
     299    public function wporg_markdown_edit_link( $link, $post_id ) {
     300        if ( $this->get_post_type() === get_post_type( $post_id ) ) {
     301            $link = str_replace( '/wp/' . WP_CORE_STABLE_BRANCH . '/', '/master/', $link );
     302        }
     303
     304        return $link;
     305    }
     306
     307    /**
    292308     * Callback for the preg_replace_callback() in wporg_markdown_after_transform()
    293309     * to transform a block of code tabs into HTML.
Note: See TracChangeset for help on using the changeset viewer.