56
7 Tips on Getting Your Theme Approved The First Time Dmitry Mayorov / www.themepatio.com WordCamp London 2016

7 Tips on Getting Your Theme Approved the First Time

Embed Size (px)

Citation preview

Page 1: 7 Tips on Getting Your Theme Approved the First Time

7 Tips on Getting Your Theme Approved The First Time

Dmitry Mayorov / www.themepatio.com

WordCamp London 2016

Page 2: 7 Tips on Getting Your Theme Approved the First Time
Page 3: 7 Tips on Getting Your Theme Approved the First Time
Page 4: 7 Tips on Getting Your Theme Approved the First Time

Why Release Your Theme Publicly?

Page 5: 7 Tips on Getting Your Theme Approved the First Time

Why Release Your Theme Publicly

- Give back to the community

- Get real feedback

- Become a better designer/developer

Page 6: 7 Tips on Getting Your Theme Approved the First Time

1. GPL License

Page 7: 7 Tips on Getting Your Theme Approved the First Time

With GPL Users are Free to :

- Use the theme for any purpose

- Study the source code

- Modify the theme

- Redistribute the theme

Page 8: 7 Tips on Getting Your Theme Approved the First Time

How To Make Sure Your Theme is GPL-friendly?

Page 9: 7 Tips on Getting Your Theme Approved the First Time

/*Theme Name: MakerAuthor: ThemePatioText Domain: makerLicense: GNU GPL v2 or laterLicense URI: http://www.gnu.org/licenses/gpl-2.0.html

Declare the License in style.css

Page 10: 7 Tips on Getting Your Theme Approved the First Time

=== Maker ===Contributors: iamdmitrymayorovVersion: 0.2.0License: GNU GPL v2 or laterLicense URI: http://www.gnu.org/licenses/gpl-2.0.htmlTags: black, gray, red, white, dark, light,

Declare the License in readme.txt

Page 11: 7 Tips on Getting Your Theme Approved the First Time

TypiconsAuthor: Stephen HutchingsLicense: SIL (http://scripts.sil.org/OFL)URL: http://typicons.com/

Bundle Only GPL-friendly Resources

Page 12: 7 Tips on Getting Your Theme Approved the First Time

Chair & TableAuthor: Jordan SanchezLicence: CC0 1.0URL: https://unsplash.com/photos/KyB-Eo4xS_c

Use Only GPL-friendly Images

Page 13: 7 Tips on Getting Your Theme Approved the First Time

Check License Compatibilitywww.gnu.org/licenses/license-list.en.html

#GPLCompatibleLicenses

Page 14: 7 Tips on Getting Your Theme Approved the First Time

GPL Summary

- Declare the license in style.css and readme.txt

- Bundle only GPL-friendly code

- Use only GPL-friendly images

- Provide info in the readme.txt

Page 15: 7 Tips on Getting Your Theme Approved the First Time

2. Don’t Start From Scratch

Page 16: 7 Tips on Getting Your Theme Approved the First Time

Underscores (_s)components.underscores.me

Page 17: 7 Tips on Getting Your Theme Approved the First Time

Componentscomponents.underscores.me

Page 18: 7 Tips on Getting Your Theme Approved the First Time

3. Requirements

Page 19: 7 Tips on Getting Your Theme Approved the First Time

<head>...<script src=’theme.js’></script>...</head>

3.1 Don’t Hardcode Scripts and Styles

Page 20: 7 Tips on Getting Your Theme Approved the First Time

wp_enqueue_script( ‘maker-custom’, get_template_directory_uri() .‘theme.js’,);

functions.php

Page 21: 7 Tips on Getting Your Theme Approved the First Time

wp_enqueue_script( ‘jquery’ );

functions.php

Page 22: 7 Tips on Getting Your Theme Approved the First Time

Full List of Bundled Resourcesdeveloper.wordpress.org/reference/functions/

wp_enqueue_script/

Page 23: 7 Tips on Getting Your Theme Approved the First Time

3.2 Prefix Everything

- Functions

- Classes

- Actions and filters

- Global variables

- Database entries

Page 24: 7 Tips on Getting Your Theme Approved the First Time

function output() { // Code goes here.}

Bad Example

Page 25: 7 Tips on Getting Your Theme Approved the First Time
Page 26: 7 Tips on Getting Your Theme Approved the First Time

function maker_entry_meta() { // Code goes here.}

Good Example

Page 27: 7 Tips on Getting Your Theme Approved the First Time

3.3 Validate & Sanitize

Page 28: 7 Tips on Getting Your Theme Approved the First Time
Page 29: 7 Tips on Getting Your Theme Approved the First Time
Page 30: 7 Tips on Getting Your Theme Approved the First Time

sanitize_text_field( $input )

Sanitize On The Input

Page 31: 7 Tips on Getting Your Theme Approved the First Time

$wp_customize->add_setting( ‘footer’, array( ‘sanitize_callback’ => ‘sanitize_text_field’,) );

Sanitize On The Input

Page 32: 7 Tips on Getting Your Theme Approved the First Time

esc_html( $output );

Escape On The Output

Page 33: 7 Tips on Getting Your Theme Approved the First Time

// Get the data.$prefix_name = get_theme_mod( ‘footer’ );

// Escape as a late as possible and display.echo esc_html( $prefix_name );

Escape On The Output

Page 34: 7 Tips on Getting Your Theme Approved the First Time

More Detailed Explanationcodex.wordpress.org/Data_Validation

Page 35: 7 Tips on Getting Your Theme Approved the First Time

3.4 Translatable Strings

Page 36: 7 Tips on Getting Your Theme Approved the First Time

echo ‘Comments’;

Theme For a Client

Page 37: 7 Tips on Getting Your Theme Approved the First Time

echo __( ‘Comments’, ‘themeslug’ );

Public Theme

Page 38: 7 Tips on Getting Your Theme Approved the First Time

_e( ‘Comments’, ‘themeslug’ );

Public Theme

Page 39: 7 Tips on Getting Your Theme Approved the First Time

esc_html_e( ‘Comments’, ‘themeslug’ );

Public Theme

Page 40: 7 Tips on Getting Your Theme Approved the First Time

More Info On I18Ncodex.wordpress.org/I18n_for_WordPress_Developers

Page 41: 7 Tips on Getting Your Theme Approved the First Time

3.5 Theme vs. Plugin Territory

Page 42: 7 Tips on Getting Your Theme Approved the First Time

More Info on Requirementsmake.wordpress.org/themes/handbook/

review/required

Page 43: 7 Tips on Getting Your Theme Approved the First Time

4. Learn From Others

Page 44: 7 Tips on Getting Your Theme Approved the First Time

4.1. Study Default Themes

Page 45: 7 Tips on Getting Your Theme Approved the First Time

4.2 Study Other Themes From the Repository

Page 46: 7 Tips on Getting Your Theme Approved the First Time

5. Test

Page 47: 7 Tips on Getting Your Theme Approved the First Time

define( ‘WP_DEBUG’, true );

5.1 wp-config.php

Page 48: 7 Tips on Getting Your Theme Approved the First Time

5.2 Theme Check Pluginwordpress.org/plugins/theme-check

Page 49: 7 Tips on Getting Your Theme Approved the First Time
Page 50: 7 Tips on Getting Your Theme Approved the First Time

5.3 Codesniffer with WPCSgithub.com/WordPress-Coding-Standards/

WordPress-Coding-Standards

Page 51: 7 Tips on Getting Your Theme Approved the First Time

5.4 Theme Unit Testcodex.wordpress.org/Theme_Unit_Test

Page 52: 7 Tips on Getting Your Theme Approved the First Time

5.5 Monster Widget Pluginwordpress.org/plugins/theme-check

Page 53: 7 Tips on Getting Your Theme Approved the First Time

5.6 Real Content

Page 54: 7 Tips on Getting Your Theme Approved the First Time

6. Become a Reviewer

Page 55: 7 Tips on Getting Your Theme Approved the First Time

7. Keep It Simple

Page 56: 7 Tips on Getting Your Theme Approved the First Time

Questions?Dmitry Mayorov / www.themepatio.com

WordCamp London 2016