|
1 |
| -LifterLMS Snippets |
2 |
| -================== |
| 1 | +# Snippets Library for LifterLMS and related Add-ons |
3 | 2 |
|
4 |
| -Code snippets, tweaks, and hook examples for LifterLMS and LifterLMS add-ons |
| 3 | +We are aiming to collect all of the most useful Gists and Snippets here in one place. |
5 | 4 |
|
6 |
| ---- |
| 5 | +A few of the benefits of this collection will be: |
7 | 6 |
|
8 |
| -These code snippets are shared *as is* without warranty. These snippets serve as examples and many of them are largely untested. |
| 7 | +* **Quality Assurance:** Each snippet will get code reviewed for quality and compatibility |
| 8 | +* **Access:** Easy to search via GitHub (or locally) |
| 9 | +* **Offline Access:** Easy to checkout this repo locally by the team as needed |
| 10 | +* **Maintainability:** One place to update as changes are needed going forward for any snippet (not stuck on any one GitHub user account) |
| 11 | + |
| 12 | +A snippet should contain the full functionality — we should avoid having two separate snippets that rely on one another to achieve the desired result. |
| 13 | + |
| 14 | +These code snippets are shared *as is* without warranty. |
| 15 | + |
| 16 | +## Submitting new snippets or changes |
| 17 | + |
| 18 | +1. Go to the folder (or create a new path) for where you want to add/change a snippet. |
| 19 | +2. Create a fork and submit Pull Request with your snippet work. Never use underscores in snippet file names or folder names. |
| 20 | +3. The PR will be code reviewed. |
| 21 | +4. In the mean time, you can provide customers with your own Gist URL of the snippet. |
| 22 | +5. After PR is approved, the snippet will be merged. |
| 23 | +6. Now the snippet is ready for inclusion on our site! |
| 24 | + |
| 25 | +## Header Layout for snippets |
| 26 | +Please include the following header format when submitting a snippet |
| 27 | +``` |
| 28 | +/** |
| 29 | + * Describe what the snippet does in one sentence. (i.e. Add a checkbox to the checkout page.) |
| 30 | + * |
| 31 | + * Learn more at: https://lifterlms.com/link-to-content-if-available-or-remove-this-line/ |
| 32 | + * |
| 33 | + * You can add this recipe to your site by creating a custom plugin |
| 34 | + * or using the Code Snippets plugin available for free in the WordPress repository. |
| 35 | + * Read this companion documentation for step-by-step directions on either method. |
| 36 | + * https://lifterlms.com/docs/adding-custom-code/ |
| 37 | + */ |
| 38 | +``` |
| 39 | + |
| 40 | +## Choosing the "Collection" and Organizing Folders |
| 41 | + |
| 42 | +The snippet folder should match the plugin this code modifies. For example, if the snippet modifies a direct behavior of the LifterLMS core course catalog, place the snippet in the "lifterlms/course-catalog" folder. If the snippet modifies a setting or adds content to a LifterLMS screen in the WordPress admin, while this may affect frontend components, it belongs in the "lifterlms/admin-pages" folder. |
| 43 | + |
| 44 | +Choose the folder and subfolder that your snippet integrates with directly. |
| 45 | + |
| 46 | +- **Folders for Each Add On**: Anything related to an Add-on. Create a folder for the Add On that exactly matches the Add-on's folder name/slug. |
| 47 | +- **Folders for core LifterLMS**: Anything related to core LifterLMS. Use the subfolders for deeper structure. |
| 48 | + - **admin-pages**: Snippets that modify the core LifterLMS plugin's admin area under Memberships > Settings. |
| 49 | + - **blocks-shortcodes**: Snippets that adjust core LifterLMS block functionality or shortcode functionality OR snippets that add new custom block or shortcode features. |
| 50 | + - **courses-lessons**: Snippets that adjust core LifterLMS course catalog, single course pages, and single lesson pages. |
| 51 | + - **email**: Snippets that adjust how emails are sent, the email contents, adding additional emails, etc. |
| 52 | + - **frontend-pages**: Snippets that modify how the frontend pages appear and the contents on the frontend pages. |
| 53 | + - **memberships**: Snippets that adjust core LifterLMS membership features, memberships catalog, and single membership pages. |
| 54 | + - **orders**: Functionality that hooks into order updates, creation, changes, etc. |
| 55 | + - **payment-gateways**: Anything that modifies or extends payment gateway functionality. Create a subfolder for each gateway that exactly matches the gateway name in core LifterLMS. |
| 56 | + - **quizzes**: Snippets that adjust quiz functionality. |
| 57 | +- **localization**: Snippets related to translating LifterLMS terms to other languages or using translation functions to change plugin language. |
| 58 | +- **plugin-compatibility**: Basic snippets that integrate core LifterLMS with other plugins to resolve issues or bridge functionality. |
| 59 | +- **sql**: Queries that you can run in your WordPress site's MySQL database. |
| 60 | +- **theme-compatibility**: Basic snippets that support using LifterLMS and Add-ons with other themes to resolve issues or bridge functionality. |
| 61 | +- **wordpress**: This collection is general WordPress functions that don't belong into any created collections. |
0 commit comments