Snippets

Plugin Description

Allows snippets of HTML, PHP, JavaScript and CSS to be created; an alternative to using a functions.php file or adding styles to a child theme.

Snippets can be used to create re-usable HTML or JavaScript snippets or to create PHP to add_actions or add_filters without needing to add them to the functions.php file or create a plugin.

The following types of snippet can be created:

  • HTML – can be loaded using the shortcode.
  • Internal CSS – automatically added as internal stylesheet.
  • CSS Stylesheet – automatically loaded.
  • Internal JavaScript – automatically added as internal JavaScript.
  • JavaScript File – automatically loaded.
  • PHP – can be loaded using the shortcode (advanced mode only).
  • PHP File – automatically loaded (advanced mode only).
  • PHP File (Header) – automatically loaded in wp_head; allows use of add_action, add_filter and add_shortcode (advanced mode only).

Shortcode usage is either [snippet id=1013] (where the supplied id value is a snippet post_id) or [snippet slug='hello-world'].

All snippets are loaded only on the site frontend; this protects the admin dashboard from white screen errors caused by badly formed PHP; only enable PHP if you really know what you’re doing.

Installation

  • Download the latest release of the plugin from GitHub.
  • Upload the entire zip file using the Plugins upload function in your ClassicPress admin panel.
  • Activate the plugin.
  • Configure relevant settings via the settings page in the admin control panel (azurecurve menu).

Frequently Asked Questions

Can I translate this plugin?

Yes, the .pot file is in the plugins languages folder; if you do translate this plugin, please sent the .po and .mo files to [email protected] for inclusion in the next version (full credit will be given).

Is this plugin compatible with both WordPress and ClassicPress?

This plugin is developed for ClassicPress, but will likely work on WordPress.

Changelog

Version 2.2.0

  • Add script type of PHP Header.

Version 2.1.5

  • Update readme file for compatibility with ClassicPress Directory.

Version 2.1.4

  • Fix bug with instructions on settings page not displaying correctly.

Version 2.1.3

  • Fix bug to prevent error if snippet selected in shortcode does not exist.

Version 2.1.2

  • Update readme files.
  • Update language template.
  • Fix bug with azurecurve menu.

Version 2.1.1

  • Update azurecurve menu.
  • Update readme files.

Version 2.1.0

  • Remove debug code.
  • Change priority of loading css/php to 10.

Version 2.0.2

  • Fix bug with load of PHP files.

Version 2.0.1

  • Fix bug with load of snippet folder option.

Version 2.0.0

  • Add missing snippet url setting; this is a breaking change requiring settings to be updated.
  • Add uninstall.
  • Update translations to escape strings.
  • Update azurecurve menu and logo.

Version 1.4.0

  • Set priority on enqueue of CSS and JavaScript.

Version 1.3.0

  • Replace admin menu icon with svg.

Version 1.2.0

  • Add advanced mode toggle; until enabled PHP/JavaScript snippets and files are unavailable for creation, but existing ones will continue to function.

Version 1.1.1

  • Fix bug when deleting post.

Version 1.1.0

  • Amend to ensure snippets are not visible or accessible from the front end.
  • Update azurecurve menu.
  • Fix bug in azurecurve menu.

Version 1.0.1

  • Fix bug with internal CSS and JavaScript not loading correctly.

Version 1.0.0

  • Initial release.

Other Notes

azurecurve was one of the first plugin developers to start developing for ClassicPress; all plugins are available from azurecurve Development and are integrated with the Update Manager plugin for fully integrated, no hassle, updates.

The other plugins available from azurecurve are: