Making WordPress.org

Changeset 9090


Ignore:
Timestamp:
08/05/2019 02:42:57 AM (5 years ago)
Author:
dd32
Message:

Helphub: Don't use the translated titles for post type slugs.

While in english it's fine, not all locales want the translated slugs and it doesn't fit the rest of WordPress.org where there are no translated slugs.

See #4575.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-helphub/inc/helphub-post-types/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-helphub/inc/helphub-post-types/classes/class-helphub-post-types-post-type.php

    r8079 r9090  
    3333
    3434    /**
     35     * The slug used in URLs for the post type items.
     36     *
     37     * @access public
     38     * @since  1.0.0
     39     * @var    string
     40     */
     41    public $single_slug;
     42
     43    /**
     44     * The slug used in URLs for the archive of the post type.
     45     *
     46     * @access public
     47     * @since  1.0.0
     48     * @var    string
     49     */
     50    public $archive_slug;
     51
     52    /**
    3553     * The post type singular label.
    3654     *
     
    7896     * @param string $plural The plural pronunciation of the post type name.
    7997     * @param array $args The typical arguments allowed to register a post type.
     98     * @param string $single_slug The 'singular' slug for the post type.
     99     * @param string $archive_slug The 'archive' slug for the post type.
    80100     * @param array $taxonomies The list of taxonomies that the post type is associated with.
    81101     */
    82     public function __construct( $post_type = 'thing', $singular = '', $plural = '', $args = array(), $taxonomies = array() ) {
     102    public function __construct( $post_type = 'thing', $singular = '', $plural = '', $args = array(), $taxonomies = array(), $single_slug = false, $archive_slug = false ) {
    83103        $this->post_type  = $post_type;
    84104        $this->singular   = $singular;
     
    86106        $this->args       = $args;
    87107        $this->taxonomies = $taxonomies;
     108
     109        if ( ! $single_slug ) {
     110            $single_slug = sanitize_title_with_dashes( $this->singular );
     111        }
     112        $this->single_slug  = apply_filters( 'helphub_single_slug', $single_slug );
     113
     114        if ( ! $archive_slug ) {
     115            $archive_slug = sanitize_title_with_dashes( $this->plural );
     116        }
     117        $this->archive_slug = apply_filters( 'helphub_archive_slug', $archive_slug );
    88118
    89119        add_action( 'init', array( $this, 'register_post_type' ) );
     
    148178        );
    149179
    150         $single_slug  = apply_filters( 'helphub_single_slug', sanitize_title_with_dashes( $this->singular ) );
    151         $archive_slug = apply_filters( 'helphub_archive_slug', sanitize_title_with_dashes( $this->plural ) );
    152 
    153180        $defaults = array(
    154181            'labels'                => $labels,
     
    159186            'query_var'             => true,
    160187            'rewrite'               => array(
    161                 'slug' => $single_slug,
     188                'slug' => $this->single_slug,
    162189            ),
    163190            'capability_type'       => 'post',
    164             'has_archive'           => $archive_slug,
     191            'has_archive'           => $this->archive_slug,
    165192            'hierarchical'          => false,
    166193            'supports'              => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes', 'revisions' ),
     
    168195            'menu_icon'             => 'dashicons-smiley',
    169196            'show_in_rest'          => true,
    170             'rest_base'             => $archive_slug,
     197            'rest_base'             => $this->archive_slug,
    171198            'rest_controller_class' => 'WP_REST_Posts_Controller',
    172199        );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-helphub/inc/helphub-post-types/classes/class-helphub-post-types.php

    r7354 r9090  
    128128
    129129        $this->post_types['post']            = new HelpHub_Post_Types_Post_Type(
    130             'post', __( 'Post', 'wporg-forums' ), __( 'Posts', 'wporg-forums' ), array(
     130            'post',
     131            __( 'Post', 'wporg-forums' ),
     132            __( 'Posts', 'wporg-forums' ),
     133            array(
    131134                'menu_icon' => 'dashicons-post',
    132             )
     135            ),
     136            array(),
     137            'post',
     138            'posts'
    133139        );
    134140        $this->post_types['helphub_article'] = new HelpHub_Post_Types_Post_Type(
    135             'helphub_article', __( 'Article', 'wporg-forums' ), __( 'Articles', 'wporg-forums' ), array(
     141            'helphub_article',
     142            __( 'Article', 'wporg-forums' ),
     143            __( 'Articles', 'wporg-forums' ),
     144            array(
    136145                'menu_icon' => 'dashicons-media-document',
    137             )
     146            ),
     147            array(),
     148            'article',
     149            'articles'
    138150        );
    139151        $this->post_types['helphub_version'] = new HelpHub_Post_Types_Post_Type(
    140             'helphub_version', __( 'WordPress Version', 'wporg-forums' ), __( 'WordPress Versions', 'wporg-forums' ), array(
     152            'helphub_version',
     153            __( 'WordPress Version', 'wporg-forums' ),
     154            __( 'WordPress Versions', 'wporg-forums' ),
     155            array(
    141156                'menu_icon' => 'dashicons-wordpress',
    142             )
     157            ),
     158            array(),
     159            'wordpress-version',
     160            'wordpress-versions'
    143161        );
    144162
Note: See TracChangeset for help on using the changeset viewer.