@@ -96,13 +96,10 @@ private function do_site_upgrades() {
9696
9797 if ( false === $ prev_version ) {
9898 if ( apply_filters ( 'code_snippets/create_sample_content ' , true ) ) {
99-
10099 foreach ( $ sample_snippets as $ sample_snippet ) {
101100 save_snippet ( $ sample_snippet );
102101 }
103102 }
104- } elseif ( version_compare ( $ prev_version , '2.14.0 ' , '< ' ) ) {
105- save_snippet ( $ sample_snippets ['orderby_date ' ] );
106103 }
107104 }
108105
@@ -173,57 +170,38 @@ private function migrate_scope_data( $table_name ) {
173170 * @return array List of Snippet objects.
174171 */
175172 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 ' );
177174
178175 $ snippets_data = array (
179176
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 ' ),
199182 ),
200183
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 ' ),
209189 'scope ' => 'front-end ' ,
210190 ),
211191
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 ' ),
218197 ),
219198
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 ' ,
227205 ),
228206 );
229207
0 commit comments