diff --git a/php/class-upgrade.php b/php/class-upgrade.php index ef4c81bf..0fa29287 100644 --- a/php/class-upgrade.php +++ b/php/class-upgrade.php @@ -96,13 +96,10 @@ private function do_site_upgrades() { if ( false === $prev_version ) { if ( apply_filters( 'code_snippets/create_sample_content', true ) ) { - foreach ( $sample_snippets as $sample_snippet ) { save_snippet( $sample_snippet ); } } - } elseif ( version_compare( $prev_version, '2.14.0', '<' ) ) { - save_snippet( $sample_snippets['orderby_date'] ); } } @@ -173,57 +170,38 @@ private function migrate_scope_data( $table_name ) { * @return array List of Snippet objects. */ private function get_sample_content() { - $tag = "\n\n" . esc_html__( 'You can remove it, or edit it to add your own content.', 'code-snippets' ); + $tag = "\n\n" . esc_html__( 'This is a sample snippet. Feel free to use it, edit it, or remove it.', 'code-snippets' ); $snippets_data = array( - 'example_html' => array( - 'name' => esc_html__( 'Example HTML shortcode', 'code-snippets' ), - 'code' => sprintf( - "\nadd_shortcode( 'shortcode_name', function () {\n\n\t\$out = '

%s

';\n\n\treturn \$out;\n} );", - wp_strip_all_tags( __( 'write your HTML shortcode content here', 'code-snippets' ) ) - ), - 'desc' => esc_html__( 'This is an example snippet for demonstrating how to add an HTML shortcode.', 'code-snippets' ) . $tag, - 'tags' => array( 'shortcode' ), - ), - - 'example_css' => array( - 'name' => esc_html__( 'Example CSS snippet', 'code-snippets' ), - 'code' => sprintf( - "\nadd_action( 'wp_head', function () { ?>\n\n esc_html__( 'This is an example snippet for demonstrating how to add custom CSS code to your website.', 'code-snippets' ) . $tag, - 'tags' => array( 'css' ), - 'scope' => 'front-end', + 'lowercase_filenames' => array( + 'name' => esc_html__( 'Make upload filenames lowercase', 'code-snippets' ), + 'code' => "add_filter( 'sanitize_file_name', 'mb_strtolower' );", + 'desc' => esc_html__( 'Makes sure that image and file uploads have lowercase filenames.', 'code-snippets' ) . $tag, + 'tags' => array( 'sample', 'media' ), ), - 'example_js' => array( - 'name' => esc_html__( 'Example JavaScript snippet', 'code-snippets' ), - 'code' => sprintf( - "\nadd_action( 'wp_head', function () { ?>\n\n esc_html__( 'This is an example snippet for demonstrating how to add custom JavaScript code to your website.', 'code-snippets' ) . $tag, - 'tags' => array( 'javascript' ), + 'disable_admin_bar' => array( + 'name' => esc_html__( 'Disable admin bar', 'code-snippets' ), + 'code' => "add_action( 'wp', function () {\n\tif ( ! current_user_can( 'manage_options' ) ) {\n\t\tshow_admin_bar( false );\n\t}\n} );", + 'desc' => esc_html__( 'Turns off the WordPress admin bar for everyone except administrators.', 'code-snippets' ) . $tag, + 'tags' => array( 'sample', 'admin-bar' ), 'scope' => 'front-end', ), - 'orderby_name' => array( - 'name' => esc_html__( 'Order snippets by name', 'code-snippets' ), - 'code' => "\nadd_filter( 'code_snippets/list_table/default_orderby', function () {\n\treturn 'name';\n} );\n", - 'desc' => esc_html__( 'Order snippets by name by default in the snippets table.', 'code-snippets' ), - 'tags' => array( 'code-snippets-plugin' ), - 'scope' => 'admin', + 'allow_smilies' => array( + 'name' => esc_html__( 'Allow smilies', 'code-snippets' ), + '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' );", + 'desc' => esc_html__( 'Allows smiley conversion in obscure places.', 'code-snippets' ) . $tag, + 'tags' => array( 'sample' ), ), - 'orderby_date' => array( - 'name' => esc_html__( 'Order snippets by date', 'code-snippets' ), - 'code' => "\nadd_filter( 'code_snippets/list_table/default_orderby', function () {\n\treturn 'modified';\n} );\n" . - "\nadd_filter( 'code_snippets/list_table/default_order', function () {\n\treturn 'desc';\n} );\n", - 'desc' => esc_html__( 'Order snippets by last modification date by default in the snippets table.', 'code-snippets' ), - 'tags' => array( 'code-snippets-plugin' ), - 'scope' => 'admin', + 'current_year' => array( + 'name' => esc_html__( 'Current year', 'code-snippets' ), + 'code' => "", + 'desc' => esc_html__( 'Shortcode for inserting the current year into a post or page..', 'code-snippets' ) . $tag, + 'tags' => array( 'sample', 'dates' ), + 'scope' => 'content', ), );