Creating a plugin with js and css that works!

Hello men in tights and Kasia Swiderska ,

So - earlier this week, Patrick pointed me to a really funky JS on Github.

Now - I'd like to use that on 3 of my sites. :slight_smile:

In order to make it easier to plop into my different sites, and also in order to dodge updates to themes and wordpress and such, I was thinking to create a simple plugin, as opposed to a child theme or just rudely plonking the code into a plugin that allows you to - well, plonk code in. :slight_smile:

Here's what I've done so far, and I'm getting a couple of oopses on activating my "plugin".
- Create a new directory under Plugins
- name it my plugin name
- create a .php file with the same name as the folder

- name the plugin / give it license and home page version number etc.

- now - register and enqueue the JS and the CSS that makes up the js on github, after pasting them into the plugin directory.




Here's my funky bit of code that doesn't work:

function simpletextrotator() {
wp_register_script('simpletextrotator', plugins_url('jquery.simple-text-rotator.js','jquery.simple-text-rotator.min.js' ), array('jquery'),'', false);

add_action( 'wp_enqueue_scripts', 'simpletextrotator' );

wp_enqueue_style( 'simpletextrotator', get_template_directory_uri() . '/simpletextrotator.css',false,'1.1','all');

Now - the same "plugin", allows you to set different speeds, and different effects.

How would i go about making those settings into "plugin settings"?

  • Ken Kimbrell
    • The Crimson Coder

    Hello Symi-

    When I first started making plugins, I wish I would have come across this SITE sooner . This is by far the best automated template I have come across. All you have to do is put your desired plugin name, and it literally generates all the files you will need to create a successful plugin. Including how to structure the backend settings. With tons of notes to explain what each code is doing and documentation on their site. I highly recommend you give it a try, as it will boost you into plugin design in no time :slight_smile:

    At first glance I am not seeing anything wrong with your code, it may just be your file structure. Let this template structure your files and see how it works for you.

    Furthermore, if you plan on having a back-end settings page, I recommend this AMAZING plugin, WORDPRESS ADMIN STYLE it will give you templates and provide custom styling including layouts and all you have to do is paste in the HTML and get to coding!

    Happy developing!

    Take Care,

    Ken - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.