FAQ for the Script Manager Plugin

The following FAQ sheet is written using HTML5. It is best viewed with the latest Chrome browser. If you are not using Chrome, do not worry. I added a jQuery script for allowing other browser types to use this same functionality. You can see how I made this page in my tutorial FAQ post type

After creating a script, I can not find it. What happened?

Script Manager 1.0 does not automatically select a newly created script. When you create a script, you must then select the script icon before editing. If you put code into the editor while a script is not selected, that code will be lost. Therefore, when you create a script, you must select the script before adding code (the script's icon should be highlighted, which means it is selected).

Can I mix scripts together into one larger script?

Yes. You can combine any number of scripts into a HTML script by using the "CodeInsert" shortcode. Then you can embed that larger script into you page once, instead of each one of the scripts at a time. This is shown in the example script in the documentation for Script Manager.

Can I use the plugin on all my websites?

Yes, but you have to buy a copy for each site. The plugin is licensed per website. Therefore, if you want to put it on many websites, you would have to buy as many copies as websites you put it on. That is why the cost is so low. A plugin of this complexity would normally sell for $50+, but I charge less so that people would more likely be honest and purchase a per site license.

Can more than one parameter be passed in the shortcode?

Yes. The param variable in the shortcode is simple a script segment appended to the script before execution. If you want to pass more than one parameter in the param variable, simple separate them with a semicolon.

I get ‘Fatal error: Cannot redeclare…’ type message.

This message means that you created an PHP function with the same name as another function. This happens when you duplicate a function name from WordPress, a theme, or from a plugin. This will also happen if you create a PHP script that declares a unique function once and then embed it into a page or post. Some themes will end up loading a page or post contents more than once. I have seen this several times. Therefore, it is best to declare unique functions in an Action that loads once (init or wp_header would be idea). Then use the function in a different WPPHP script in the page or post.

My browser does not seem to work with Script Manager.

Script Manager was developed using the Google Chrome web browser, but was tested under FireFox, Safari, and Opera. The latest version of each browser was working as of February 2012. I did not do regression testing for older versions. Everything was tested with IE9 and seems to work as well. Other versions and other browsers, we can not guarantee the main editing screen and options screens in the administration panel will completely work (but, really they should). All embedding of code is done in PHP on the server. Therefore, the user side should always work and look correctly. If it does not, then it is a problem with your coding.

Problems with multiple ‘CodeInsert’ and ‘CodeHighlight’ tags in page/post

When you use the 'CodeHighlight' or 'CodeInsert' shortcodes more than once on a page, you can have a problem. The problem is a known problem with WordPress. It comes about when using shortcode closures. A shortcode closure is when you use a shortcode to encompass other text, as in:

[CodeHighlight lang='WPPHP'] 
     ...some PHP code... 
[/CodeHighlight]

The problem comes when you have the closure type and a non-closure type together. When hunting for a closure, WordPress does not recognise other uses of the shortcode. Therefore, an internal shortcode will be ignored. For example:

[CodeHighlight lang='WPPHP' name='test'] 
     ...Some HTML...
[CodeHighlight lang='HTML'] 
     ... Some HTML that should be highlighted ... 
[/CodeHighlight]

The expected behaviour would be to insert the PHP code named 'test' as highlighted code, the next HTML displayed normally, and then the next chunk of HTML that should be highlighted. The actual result would be the first 'CodeHighlight' will highlight all the code until the closure.

Therefore, if you are mixing shortcodes with closures with shortcodes without closures, it is best to have an empty closure on all of them. In the above example, the safe way is to do:

[CodeHighlight lang='WPPHP' name='test'][/CodeHighlight] 
     ...Some HTML...
[CodeHighlight lang='HTML'] 
     ... Some HTML that should be highlighted ... 
[/CodeHighlight]

This will give the expected results.

Why do I keep getting “error in eval code”.

Any error you get from the server with the phrase "eval code" means that your script has a bug in it. The plugin has been check over several different servers types and lots of different scripts. The scripts are executed by using the PHP function eval(). Therefore, errors in the eval() function are due to scripts that was saved into the Script Manager.

It is recommended to test all scripts on a local server that is not mission critical first. Once you are satisfied that the script works okay, then put it on a production system. I try to ensure all scripts in the tutorials are accurate, but sometimes copy errors to occur. No matter what the source is, be careful what scripts you use and that they are functional before placing on a production server.

Why does the source files look so strange?

The PHP and JavaScript files are all "compiled" by a program to take out all comments, spaces, line breaks, etc. This allows the files to be loaded much faster. In some cases, the compiled scripts are 20% faster than none, especially as much as I comment my programs.

Will Script Manager do XYZ?

Script Manager is a aid to programming your WordPress site. Therefore, yes you can use Script Manager to change your WordPress site any way you want. But, you will have to do the programming yourself or follow one of our tutorials. If you would like to suggest a tutorial to add a functionality you would like, just let me know.