Skip to content

Fix duplicate function names.#4980

Closed
1shiharat wants to merge 1 commit intoWordPress:masterfrom
growgroup:fix/docs-templates
Closed

Fix duplicate function names.#4980
1shiharat wants to merge 1 commit intoWordPress:masterfrom
growgroup:fix/docs-templates

Conversation

@1shiharat
Copy link
Copy Markdown

@1shiharat 1shiharat commented Feb 9, 2018

No description provided.


```php
function register_post_type() {
function my_template_to_books() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on this conflicting with the core register_post_type function name. To better reflect that this is registering a post type, though, maybe it should be named as such, while still avoiding the conflict?

Thinking something along the lines of...

function register_book_post_type() {}
function myplugin_register_post_types() {}

Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

myplugin_register_book_post_type would be best.

Since this is PHP code in the global namespace, it's best practice to use a vendor prefix in the function. Using unique function prefixes or namespaces is required by dot org theme and plug-in directories.

@youknowriad
Copy link
Copy Markdown
Contributor

Superseded by #5150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants