Download presentation
Presentation is loading. Please wait.
Published byPaul Benedict Russell Modified over 8 years ago
1
Post-Module WordPress Plugins BTM 395: Internet Programming
2
Plugin namespacing Bad things can happen if two different plugins have functions or variables with the same names Namespacing means using some sort of system or method to limit the scope of names to avoid such clashes Two namespacing strategies: 1.Simple but awkward: Use a prefix before all variables and functions, e.g. $mfwp_options and mfwp_set_options()prefix before all variables and functions 2.Rigorous but elegant: Use an object-oriented class to contain the entire plugin, so that all variables and methods are locally scopedobject-oriented class to contain the entire plugin
3
WordPress Codex The Codex: Official documentation for using and programming WordPress –Not very user-friendly, but authoritative WordPress Function Reference –Built-in functions to make WordPress programming easier Writing plugins and the Plugin APIWriting pluginsPlugin API Developing themes
4
Hooks, actions and filters Plugins change how WordPress behaves. They specify these changes by adding a hook to an action or to a filter. Action: An event, something that happens at a point in time.Action –E.g. init, wp_head, wp_footer –Action hooks are used to call plugin functions that run at a certain time during WordPress execution Filter: Something that changes text or content in WordPress.Filter –E.g. the_content, the_title, wp_list_pages –Filter hooks are used to change some text or content either before or after it is sent to the browser, or either before or after it is saved to the database
5
Internationalization and localization (i18n and l10n) Internationalization: coding a computer system such that it is easy to localize into different human languages and cultures Localization: converting a computer system from one human language/culture to another –Translation of words from one human language to another –Changing number, time, date formats; adapting culturally- appropriate images, etc. Normally, only user-visible text is localized. Code only visible to programmers is usually not localized. I18n and l10n –Internationalization has 20 letters: the letter I, 18 letters, and then the letter N; thus it is abbreviated i18n –Localization has 12 letters: the letter L, 10 letters, and then the letter N; thus it is abbreviated l10n
6
I18n and l10n in WordPress WordPress core code is fully internationalized Strongly recommended for writing plugins and themes designed for public distribution Many built-in functions exist to make it easier –__('English text','text_domain'): returns a string –_e('English text','text_domain'): echoes a string –Many others (see “Localization”)Many others Tutorials exist for detailsTutorials exist
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.