Coupon Creator

  • Coupon Creator Pro
    • Coupon Creator Pro
    • Feature Demos
    • Premium Features
    • Release Notes
    • New Feature Suggestions
  • Support
    • Contact Support
    • Guides (Start Here)
    • Frequently Asked Questions
    • Documentation
    • Tutorials
    • Support Terms
  • Contact
  • My Account
  • 0 items

Two Methods To Creating a Plugin To Run Custom Snippets

Posted on 06.08.16 | brianjessee |

Knowledge Base


Two Methods To Creating a Plugin To Run Custom Snippets

Last Updated: 7 years ago in Customization,Setup,Troubleshooting Guides
Often you would like to change how a plugin works and you put the coding in your child theme. However, if you still need to update the child theme or want to store the snippets in one place that does not have a chance of being updated then a custom plugin is recommend.

This guide will show you two different ways to do it. The first way is to manually create the file and the second is to use a plugin called Pluginception to help you create it.

For the manual method you can download a base version of the plugin to install from Github.

Manual Creation

When creating a plugin I recommend putting it into a directory in the plugin directory of your site.

In this case I am going to call the plugin coupon-creator-snippets and going to create the following directory and file using my text editor or IDE:

/wp-content/plugins/coupon-creator-snippets/coupon-creator-snippets.php

In that file I am going to start with an opening php tag and the information header:

<?php
/*
Plugin Name: Coupon Creator Pro Snippets
Plugin URI: http://couponcreatorplugin.com
Description: A Plugin to store snippets for the Coupon Creator Pro
Author: brianjessee
Version: 1.0
Author URI: http://couponcreatorplugin.com
*/

Feel free to change any of that information on your site.

Once saved go to the plugin section of your admin and find the plugin you created and activate it.

Now it is ready to add some snippets.

Add the first on after the closing comment ( */ ) and do not include another opening php tag ( <?php ) or it will cause a fatal error.

Here is an example of a plugin that adds Google Fonts to the Print View, more snippets can be added just after the first one. For the most part there are no limits on snippets to add.

<?php
/*
Plugin Name: Coupon Creator Pro Snippets
Plugin URI: http://couponcreatorplugin.com
Description: A Plugin to store snippets for the Coupon Creator Pro
Author: brianjessee
Version: 1.0
Author URI: http://couponcreatorplugin.com
*/

/*
*   Coupon Creator - Add Google Fonts to Print View
*   Version 2.1.2
*/
add_action('coupon_print_meta', 'cctor_google_fonts_print_view' );
function cctor_google_fonts_print_view() {
     
    echo "<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>";
    echo "<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>";
     
}   

Pluginception

If you are unsure of how that all works you can use a plugin to give you a head start on plugin creation. To start using Pluginception add it to your WordPress install:

https://wordpress.org/plugins/pluginception/

Install, activate, and then go to the Plugins->Create a New Plugin menu fill in at least the title then create and active it.

After the plugin is created, it will take you to the edit screen to add the snippet or snippets you would like.

Add the coding in the line following the closing comment ( */ ) and please be careful not to include an opening php tag ‘ with your snippet as it will cause a fatal error.

If you are not able to edit files from the WordPress admin due to a security plugin or DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS this plugin will not work and you would have to create the plugin yourself using sftp or another method.

Also, once complete it is good idea to remove Pluginception from your site. Although it is secure any plugin like that should only be on your site when you are using it.

1 star1 star1 star1 star1 star
4.3 out of 5 stars
Downloads!

Get Started With Pro

Click to Buy Pro

What Users are Saying:


Wonderful Plugin & Top Notch Support – We purchased the pro version of this plugin after reviewing the free version for a while. The free version is great, but we needed some of the more advanced features that the pro version offered…more

— (infobeckettgraphics)

Great Support – I am using Coupon Creator fee version on two sites and love it! Easy to use and great support! Just what I was looking for.

— Kay (stahr5)

5-Star Rating All Day Long – I strongly recommend using this plugin if you EVER need a “Top Of The Line” well designed, clean coded, lightweight, easy to manage and style coupon plugin for whatever reason for your WP site….more

— Fish (fish911)

My client needed a coupon creator to add the mobile equivalent of clip-out paper coupons for their website. This Coupon Creator plugin was the best, most reliable solution that allows my client to easily make decent-to-good looking online coupons in-house with a minimum of design experience and fuss. Many other coupon plugins actually only generate coupon codes a-la RetailMeNot. This one lets you generate printable coupon-looking coupons or responsive, mobile-friendly discount coupons that users can pull up on their smartphone right there at the merchant.

— (typeadesign)

Simple Solution for My Site — First Rate Support! – A simple and useful plugin that offers a perfect solution for my website. … The videos are extremely helpful. Support from the developer was fast and very helpful…more

— Mike (msagman)

Login

  • Lost Password

Support Resources

  • Guides
  • Frequently Asked Questions
  • Documentation
  • Tutorials

Sign Up for Updates!

For the Coupon Creator Pro!

  • This field is for validation purposes and should be left unchanged.
  • Coupon Creator Pro
  • Coupon Creator
  • Guides
  • Frequently Asked Questions
  • Terms of Service
  • Privacy Policy

Copyright © 2023 Site · WordPress Web Design by Jessee Productions, LLC

7ads6x98y