Simple:Press Documentation

Minor Changes – Creating sp-user-functions.php

Then

Prior to Simple:Press version 5.5.7 the only way to protect against custom changes to any part of a standard supplied Simple:Press theme being lost due to future updates was to develop a Child Theme starting with a Child Theme Framework or a Custom Theme to hold the customizations. This was true even if only minor custom changes utilizing a filter or an action were wanted because the standard theme’s spFunction.php file would have to be modified with the changes.

Now

With Simple:Press version 5.5.7 the standard theme’s spFunction.php need not change so Child or Custom Themes are not required for minor changes utilizing a filter or an action. Instead a completely new file with the name ‘sp-user-functions.php’ can be made to accommodate the minor custom filter(s) or action(s). Having a place to put implementations that tie into the filters and actions available in Display Template Functions is the main purpose of this ‘.php’ file.

Note: The ‘sp-user-functions.php’ file is not intended to support CSS styling changes nor Display Template function argument modification. It is recommended a Child Theme be developed for those purposes and other minor changes. A Custom theme is recommended if those and more extensive changes are being considered.

The new file is to be placed in the “wp-content” file where it will not be affected by Simple:Press updates.

This new functions file always runs before the active theme’s ‘spFunction.php’ file. It will affect any Simple:Press theme that is active.

‘sp-user-functions.php’ File Development Rules

The development rules for the file are simple.

  • The file has to be a “.php” file which means it requires opening/closing php tags on the first and last lines of the file.
  • It must be a plain text file.
  • The primary aim of the file is to accommodate file and action functions although the user can define functions of their own.

As always, it is suggested a descriptive header be included in the file along with clear and descriptive comments regarding the changes being implemented.

Locating the ‘sp-user-functions.php’ File

Once developed, this new file is to be placed in in the ‘wp-content’ folder for the website.

Changelog

Since Simple:Press version 5.5.7.

Codex page sync’d to code version 5.5.7.


Copyright © 2006-2019 Simple:Press. All Rights Reserved.