You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An easy, clean and simple way to add code snippets to your site.
10
-
11
-
## Description
12
-
13
8
Code Snippets is an easy, clean and simple way to add code snippets to your site. It removes the need to add custom snippets to your theme theme's `functions.php` file.
14
9
15
10
A snippet is a small chunk of PHP code that you can use to extend the functionality of a WordPress-powered website; essentially a mini-plugin with less load on your site.
@@ -31,90 +26,3 @@ Code Snippets can be used in these different languages thanks to the following t
31
26
* Serbo-Croatian - [Borisa Djuraskovic from Web Hosting Hub](http://www.webhostinghub.com/)
32
27
* Japanese - [mt8](http://mt8.biz/)
33
28
* French - [oWEB](http://office-web.net)
34
-
35
-
## Installation
36
-
37
-
### Automatic installation
38
-
39
-
1. Log into your WordPress admin
40
-
2. Click __Plugins__
41
-
3. Click __Add New__
42
-
4. Search for __Code Snippets__
43
-
5. Click __Install Now__ under "Code Snippets"
44
-
6. Activate the plugin
45
-
46
-
### Manual installation
47
-
48
-
1. Download the plugin
49
-
2. Extract the contents of the zip file
50
-
3. Upload the contents of the zip file to the `wp-content/plugins/` folder of your WordPress installation
51
-
4. Activate the Code Snippets plugin from 'Plugins' page.
52
-
53
-
**Network Activating** Code Snippets through the Network Dashboard will enable a special interface for running snippets across the entire network.
54
-
55
-
## Frequently Asked Questions
56
-
57
-
### How can I insert my snippet into the post text editor?
58
-
Snippets that you add to this plugin are not meant to be inserted into the text editor. Instead, they are run on your site just as if they were added to your functions.php file.
59
-
60
-
### Do I need to include the `<?php`, `<?` or `?>` tags in my snippet?
61
-
No, just copy all the content inside those tags. If you accidentally forget (or just like being lazy), the tags will be stripped from the beginning and end of the snippet when you save it. You can, however, use those tags *inside* your snippets to start and end HTML sections
62
-
63
-
### Help! I just activated a snippet, and my whole site broke!
64
-
You can try activating 'safe mode'. All snippets will not execute while safe mode is active, allowing you to access your site and deactivate the snippet that is causing the error. To activate safe mode, add the following line to your wp-config.php file, just before the line that reads `/* That's all, stop editing! Happy blogging. */`:
65
-
66
-
define('CODE_SNIPPETS_SAFE_MODE', true);
67
-
68
-
To turn safe mode off, either [comment out](http://php.net/manual/language.basic-syntax.comments.php) this line or delete it.
69
-
70
-
### Is there a way to add a snippet but not run it right away?
71
-
Yes. Just add it but do not activate it yet.
72
-
73
-
### What do I use to write my snippets?
74
-
The [CodeMirror](http://codemirror.net) source-code editor will add line numbers, syntax highlighting, bracket matching, search, tabulate and other cool features to the code editor.
75
-
76
-
### Can I preform search and replace commands in the code editor?
77
-
78
-
*__Ctrl-F / Cmd-F__ : Start searching
79
-
*__Ctrl-G / Cmd-G__ : Find next
80
-
*__Shift-Ctrl-G / Shift-Cmd-G__ : Find previous
81
-
*__Shift-Ctrl-F / Cmd-Option-F__ : Replace
82
-
*__Shift-Ctrl-R / Shift-Cmd-Option-F__ : Replace all
83
-
84
-
### Will I lose my snippets if I change the theme or upgrade WordPress?
85
-
No, the snippets are stored in the WordPress database and are independent of the theme and unaffected by WordPress upgrades.
86
-
87
-
### Can the plugin be completely uninstalled?
88
-
Yes, when you delete Code Snippets using the 'Plugins' menu in WordPress it will clean up the database table and a few other bits of data. Be careful not to remove Code Snippets by deleting it from the Plugins menu unless you want this to happen.
89
-
90
-
### Can I copy any snippets I've created to another WordPress site?
91
-
Yes! You can individually export a single snippet using the link below the snippet name on the 'Manage Snippets' page or bulk export multiple snippets using the 'Bulk Actions' feature. Snippets can later be imported using the 'Import Snippets' page by uploading the export file.
92
-
93
-
### Can I export my snippets to PHP for a site where I'm not using the Code Snippets plugin?
94
-
Yes. Click the checkboxes next to the snippets you want to export, and then choose **Export to PHP** from the Bulk Actions menu and click Apply. The generated PHP file will contain the exported snippets' code, as well as their name and description in comments.
95
-
96
-
### Can I run network-wide snippets on a multisite installation?
97
-
You can run snippets across an entire multisite network by **Network Activating** Code Snippets through the Network Dashboard. You can also activate Code Snippets just on the main site, and then individually on other sites of your choice.
98
-
99
-
### Where are the snippets stored in my WordPress database?
100
-
Snippets are stored in the `wp_snippets` table in the WordPress database. The table name may differ depending on what your table prefix is set to.
101
-
102
-
### I need help with Code Snippets / I have an idea for a new feature for Code Snippets
103
-
You can get help with Code Snippets, report bugs or errors, and suggest new features and improvements either on the [WordPress Support Forums](https://wordpress.org/support/plugin/code-snippets) or on [GitHub](https://github.com/sheabunge/code-snippets)
104
-
105
-
### I want to contribute to and help develop the Code Snippets plugin!
106
-
That's fantastic! Fork the [repository on GitHub](http://github.com/sheabunge/code-snippets) and send me a pull request.
0 commit comments