@@ -96,13 +96,10 @@ private function do_site_upgrades() {
96
96
97
97
if ( false === $ prev_version ) {
98
98
if ( apply_filters ( 'code_snippets/create_sample_content ' , true ) ) {
99
-
100
99
foreach ( $ sample_snippets as $ sample_snippet ) {
101
100
save_snippet ( $ sample_snippet );
102
101
}
103
102
}
104
- } elseif ( version_compare ( $ prev_version , '2.14.0 ' , '< ' ) ) {
105
- save_snippet ( $ sample_snippets ['orderby_date ' ] );
106
103
}
107
104
}
108
105
@@ -173,57 +170,38 @@ private function migrate_scope_data( $table_name ) {
173
170
* @return array List of Snippet objects.
174
171
*/
175
172
private function get_sample_content () {
176
- $ tag = "\n\n" . esc_html__ ( 'You can remove it, or edit it to add your own content . ' , 'code-snippets ' );
173
+ $ tag = "\n\n" . esc_html__ ( 'This is a sample snippet. Feel free to use it, edit it, or remove it . ' , 'code-snippets ' );
177
174
178
175
$ snippets_data = array (
179
176
180
- 'example_html ' => array (
181
- 'name ' => esc_html__ ( 'Example HTML shortcode ' , 'code-snippets ' ),
182
- 'code ' => sprintf (
183
- "\nadd_shortcode( 'shortcode_name', function () { \n\n\t\$out = '<p>%s</p>'; \n\n\treturn \$out; \n} ); " ,
184
- wp_strip_all_tags ( __ ( 'write your HTML shortcode content here ' , 'code-snippets ' ) )
185
- ),
186
- 'desc ' => esc_html__ ( 'This is an example snippet for demonstrating how to add an HTML shortcode. ' , 'code-snippets ' ) . $ tag ,
187
- 'tags ' => array ( 'shortcode ' ),
188
- ),
189
-
190
- 'example_css ' => array (
191
- 'name ' => esc_html__ ( 'Example CSS snippet ' , 'code-snippets ' ),
192
- 'code ' => sprintf (
193
- "\nadd_action( 'wp_head', function () { ?> \n<style> \n\n\t/* %s */ \n\n</style> \n<?php } ); \n" ,
194
- wp_strip_all_tags ( __ ( 'write your CSS code here ' , 'code-snippets ' ) )
195
- ),
196
- 'desc ' => esc_html__ ( 'This is an example snippet for demonstrating how to add custom CSS code to your website. ' , 'code-snippets ' ) . $ tag ,
197
- 'tags ' => array ( 'css ' ),
198
- 'scope ' => 'front-end ' ,
177
+ 'lowercase_filenames ' => array (
178
+ 'name ' => esc_html__ ( 'Make upload filenames lowercase ' , 'code-snippets ' ),
179
+ 'code ' => "add_filter( 'sanitize_file_name', 'mb_strtolower' ); " ,
180
+ 'desc ' => esc_html__ ( 'Makes sure that image and file uploads have lowercase filenames. ' , 'code-snippets ' ) . $ tag ,
181
+ 'tags ' => array ( 'sample ' , 'media ' ),
199
182
),
200
183
201
- 'example_js ' => array (
202
- 'name ' => esc_html__ ( 'Example JavaScript snippet ' , 'code-snippets ' ),
203
- 'code ' => sprintf (
204
- "\nadd_action( 'wp_head', function () { ?> \n<script> \n\n\t/* %s */ \n\n</script> \n<?php } ); \n" ,
205
- wp_strip_all_tags ( __ ( 'write your JavaScript code here ' , 'code-snippets ' ) )
206
- ),
207
- 'desc ' => esc_html__ ( 'This is an example snippet for demonstrating how to add custom JavaScript code to your website. ' , 'code-snippets ' ) . $ tag ,
208
- 'tags ' => array ( 'javascript ' ),
184
+ 'disable_admin_bar ' => array (
185
+ 'name ' => esc_html__ ( 'Disable admin bar ' , 'code-snippets ' ),
186
+ 'code ' => "add_action( 'wp', function () { \n\tif ( ! current_user_can( 'manage_options' ) ) { \n\t\tshow_admin_bar( false ); \n\t} \n} ); " ,
187
+ 'desc ' => esc_html__ ( 'Turns off the WordPress admin bar for everyone except administrators. ' , 'code-snippets ' ) . $ tag ,
188
+ 'tags ' => array ( 'sample ' , 'admin-bar ' ),
209
189
'scope ' => 'front-end ' ,
210
190
),
211
191
212
- 'orderby_name ' => array (
213
- 'name ' => esc_html__ ( 'Order snippets by name ' , 'code-snippets ' ),
214
- 'code ' => "\nadd_filter( 'code_snippets/list_table/default_orderby', function () { \n\treturn 'name'; \n} ); \n" ,
215
- 'desc ' => esc_html__ ( 'Order snippets by name by default in the snippets table. ' , 'code-snippets ' ),
216
- 'tags ' => array ( 'code-snippets-plugin ' ),
217
- 'scope ' => 'admin ' ,
192
+ 'allow_smilies ' => array (
193
+ 'name ' => esc_html__ ( 'Allow smilies ' , 'code-snippets ' ),
194
+ 'code ' => "add_filter( 'widget_text', 'convert_smilies' ); \nadd_filter( 'the_title', 'convert_smilies' ); \nadd_filter( 'wp_title', 'convert_smilies' ); \nadd_filter( 'get_bloginfo', 'convert_smilies' ); " ,
195
+ 'desc ' => esc_html__ ( 'Allows smiley conversion in obscure places. ' , 'code-snippets ' ) . $ tag ,
196
+ 'tags ' => array ( 'sample ' ),
218
197
),
219
198
220
- 'orderby_date ' => array (
221
- 'name ' => esc_html__ ( 'Order snippets by date ' , 'code-snippets ' ),
222
- 'code ' => "\nadd_filter( 'code_snippets/list_table/default_orderby', function () { \n\treturn 'modified'; \n} ); \n" .
223
- "\nadd_filter( 'code_snippets/list_table/default_order', function () { \n\treturn 'desc'; \n} ); \n" ,
224
- 'desc ' => esc_html__ ( 'Order snippets by last modification date by default in the snippets table. ' , 'code-snippets ' ),
225
- 'tags ' => array ( 'code-snippets-plugin ' ),
226
- 'scope ' => 'admin ' ,
199
+ 'current_year ' => array (
200
+ 'name ' => esc_html__ ( 'Current year ' , 'code-snippets ' ),
201
+ 'code ' => "<?php echo date( 'Y' ); ?> " ,
202
+ 'desc ' => esc_html__ ( 'Shortcode for inserting the current year into a post or page.. ' , 'code-snippets ' ) . $ tag ,
203
+ 'tags ' => array ( 'sample ' , 'dates ' ),
204
+ 'scope ' => 'content ' ,
227
205
),
228
206
);
229
207
0 commit comments