# Pressbooks Name Spaces

**URL:** <https://pressbooks.community/t/pressbooks-name-spaces/189>\
**Category:** Developer Questions\
**Created:** [June 14, 2017, 12:04pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189 "2017-06-14T12:04:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MobiApp121](https://pressbooks.community/user_avatar/pressbooks.community/mobiapp121/32/160_2.png) [@MobiApp121](https://pressbooks.community/u/MobiApp121)\
**Post date:** [June 14, 2017, 12:04pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189/1 "2017-06-14T12:04:54Z")

</div>

I’m a little confused about namespaces in Pressbooks. Working on a local Windows Xampp development environment, 3.9.9/WP 4.7.5 and only approved PB plugins. I have created a TinyMCE Drop cap button that creates a span around the 1st letter/s of a paragraph. I have tried to follow best coding practices, placing it in symbionts, and adding the css/scss to the relevant files (`partials: _editor.scss/components: specials:_dropcap.scss`).Everything is working fine including export.

However, my php file contains the namespace,I thought would be correct - Pressbooks\Symbionts; but unless I also create a symbionts folder in the Luther/main theme it cannot find the javascript file.Which namespace, to point to the plugin folder symbionts should I use?

I also found I had to enter the css in both the root theme style.css/scss files for the dropcap effect to display on both the editor and web reader - is this correct?

Thanks

---

<div class="post-metadata">

**Author:** ![dac.chartrand](https://pressbooks.community/user_avatar/pressbooks.community/dac.chartrand/32/152_2.png) [@dac.chartrand](https://pressbooks.community/u/dac.chartrand)\
**Post date:** [June 15, 2017, 1:43pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189/2 "2017-06-15T13:43:46Z")

</div>

Hi MobiApp121

Our use of Namespaces is a bit like [PHP’s PSR-0 standard](http://www.php-fig.org/psr/psr-0/).

That means that if you are using `namespace Pressbooks\Symbionts` then the file should be in the `/includes/symbionts/` folder.

There is no such folder in Pressbooks?

Try:

- Not using a namespace if your file is in symbionts.
  - No autoload functionality so don’t forget to `require` whatever new PHP file you are adding.

- Using the correct, folder mapped, namespace.

[More info about Namespaces](http://php.net/manual/en/language.namespaces.rationale.php).

---

<div class="post-metadata">

**Author:** ![MobiApp121](https://pressbooks.community/user_avatar/pressbooks.community/mobiapp121/32/160_2.png) [@MobiApp121](https://pressbooks.community/u/MobiApp121)\
**Post date:** [June 15, 2017, 5:28pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189/3 "2017-06-15T17:28:41Z")

</div>

Hi Dac,

Thanks for that. I used the require method in an earlier version of PB but it seemed to complain when I tried it with 3.9.9. As I say it’s working well if a little inelegant. Incidentally `namespace Pressbooks\Symbionts;` points to /pressbooks-book/symbionts/mce-dropcap-button/ for me (yes I created a symbionts folder in the root theme as a result) , but then I have this function in my mce-dropcap-button.php:

```
function addDropcapButton( $plugin_array ) {

		$plugin_array['dropcapbutton'] = get_template_directory_uri() . '/symbionts/mce-dropcap-button/assets/js/dropcap-button.js';
		return $plugin_array;
	}

```

Is there anyway to avoid the approved plugin warning when I go to the upload new plugin page? With the current namespace method I entered it into the pb-utility.php file, like so:

```
function include_plugins() {
	$plugins = array(
		'custom-metadata/custom_metadata.php' => 1,
		'pressbooks-latex/pb-latex.php' => 1,
		'mce-dropcap-button/mce-dropcap-button.php' => 1,
	);

```

But I’m guessing there is more to it and dare say you will think me foolish?

---

<div class="post-metadata">

**Author:** ![dac.chartrand](https://pressbooks.community/user_avatar/pressbooks.community/dac.chartrand/32/152_2.png) [@dac.chartrand](https://pressbooks.community/u/dac.chartrand)\
**Post date:** [June 15, 2017, 5:42pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189/4 "2017-06-15T17:42:48Z")

</div>

I don’t quite understand what you are trying to do. Your initial question was about namespaces. If now your question is how to add a button to TinyMce then you should write a separate plugin please look at:

- [https://codex.wordpress.org/Plugin\_API/Filter\_Reference/mce\_external\_plugins](https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_external_plugins)
- [https://codex.wordpress.org/Plugin\_API/Filter\_Reference/mce\_buttons,\_mce\_buttons\_2,\_mce\_buttons\_3,\_mce\_buttons\_4](https://codex.wordpress.org/Plugin_API/Filter_Reference/mce_buttons,_mce_buttons_2,_mce_buttons_3,_mce_buttons_4)

Adding code to Pressbooks, unless you are submitting a PR to github for everyone to use, is not the best idea. Your code will get wiped out on upgrades.

Cheers.

---

<div class="post-metadata">

**Author:** ![MobiApp121](https://pressbooks.community/user_avatar/pressbooks.community/mobiapp121/32/160_2.png) [@MobiApp121](https://pressbooks.community/u/MobiApp121)\
**Post date:** [June 15, 2017, 6:14pm UTC](https://pressbooks.community/t/pressbooks-name-spaces/189/5 "2017-06-15T18:14:51Z")

</div>

OK thanks, I’ve already added the button and it’s working and I fully intend to make it available for everyone. This is on a local development platform, so I’m trying things out for the moment. The problem with an TinyMce format plugin with PB is it has to parse through all stages up to export for ePub, mobi and PDf for it to be useful, this it does. A plugin is more difficult for me to achieve the same, this is why I am asking questions and I think I’ve been very clear with what is intended. But thanks anyway. Here it is working:  
 ![](https://pressbooks.community/uploads/default/original/1X/280c9b59cc5fa96cea4c4dc6a215cb6b0e8695f4.png)  
 ![](https://pressbooks.community/uploads/default/original/1X/978a44ea809cb0ca9fbeb1a572a1822ed906ded1.png)  
 ![](https://pressbooks.community/uploads/default/original/1X/36e1b34a46eaaea0d67b0892e7d80666e8efb12f.png)
