1 / 6

Post-Module WordPress Plugins

Post-Module WordPress Plugins. BTM 395: Internet Programming. 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

sheryl
Download Presentation

Post-Module WordPress Plugins

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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: • Simple but awkward: Use a prefix before all variables and functions, e.g. $mfwp_options and mfwp_set_options() • Rigorous but elegant: Use an object-oriented class to contain the entire plugin, so that all variables and methods are locally scoped

  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 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. • 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. • 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”) • Tutorials exist for details

More Related