what we can learn from wordpress as a developer

22
What we can learn from WordPress Chandra Maharzan tweet @maharzan Sunday, March 25, 12

Upload: chandra-maharzan

Post on 15-Jan-2015

501 views

Category:

Technology


0 download

DESCRIPTION

What we can learn from WordPress - become a better developer.

TRANSCRIPT

Page 1: What we can learn from WordPress as a developer

What we can learn fromWordPress

Chandra Maharzantweet @maharzan

Sunday, March 25, 12

Page 2: What we can learn from WordPress as a developer

Sunday, March 25, 12

Page 3: What we can learn from WordPress as a developer

Sunday, March 25, 12

Page 4: What we can learn from WordPress as a developer

What we ignore

• Most simplest parts

• Comments

• White Space

• Proper Names

Sunday, March 25, 12

Page 5: What we can learn from WordPress as a developer

CSS

Sunday, March 25, 12

Page 6: What we can learn from WordPress as a developer

/* =Quote----------------------------- */

.format-quote blockquote {! color: #555;! font-size: 17px;! margin: 0;}

/* =Image----------------------------- */

/* red color */

Sunday, March 25, 12

Page 7: What we can learn from WordPress as a developer

/* =Menu----------------------------- */

#access ul ul ul {! left: 100%;! top: 0;}

/* Search Form */#branding #searchform {! position: absolute;! top: 3.8em;! right: 7.6%;}

Sunday, March 25, 12

Page 8: What we can learn from WordPress as a developer

selector { property: value;}

#selector-1 { background: #fff; color: #000; }

#selector-1,#selector-2,#selector-3 { background: #fff; color: #000;}

Sunday, March 25, 12

Page 9: What we can learn from WordPress as a developer

#comment-form { margin: 0;}

#commentForm {}#comment_form {}#abc-12 {}

Class names

Sunday, March 25, 12

Page 10: What we can learn from WordPress as a developer

#comment-form {-moz-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);-webkit-box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.2);font-size: 1em;position: absolute;top: 0;right: 0;bottom: 0;left: 0;width: 500px;height: auto;

}

Property : Value

Sunday, March 25, 12

Page 12: What we can learn from WordPress as a developer

PHP

Sunday, March 25, 12

Page 13: What we can learn from WordPress as a developer

/** * Tell WordPress to run twentyeleven_setup() when the * 'after_setup_theme' hook is run. */add_action( 'after_setup_theme', 'twentyeleven_setup' );

Comments

/** * Sets the post excerpt length to 40 words. * * To override this length in a child theme, * remove the filter and add your own * function tied to the excerpt_length filter hook. */function twentyeleven_excerpt_length( $length ) {

Sunday, March 25, 12

Page 14: What we can learn from WordPress as a developer

// Turn on random header image rotation by default.add_theme_support( 'custom-header', array( 'random-default' => true ) );

// Has the text been hidden?if ( 'blank' == get_header_textcolor() ) :

...

...// If the user has set a custom color for the text useelse :

....

....endif;

Comments

Sunday, March 25, 12

Page 15: What we can learn from WordPress as a developer

/** * The Template for displaying all single posts. * * @package WordPress * @subpackage Twenty_Eleven * @since Twenty Eleven 1.0 */

<div id="primary">! <div id="content" role="main">

.....

.....</div><!-- #content -->

</div><!-- #primary -->

Comments

Sunday, March 25, 12

Page 16: What we can learn from WordPress as a developer

$foo='somevalue';$foo2='somevalue2';$foo34var='somevalue3';$nicevar=somevalue4';

Variables

$my_array=array( 'foo'=>'somevalue', 'foo2'=>'somevalue2', 'foo3'=>'somevalue3', 'foo34'=>'somevalue3');

Sunday, March 25, 12

Page 17: What we can learn from WordPress as a developer

$foo = 'somevalue';$foo2 = 'somevalue2';$foo34var = 'somevalue3';$nicevar = somevalue4';

$my_array = array( 'foo' => 'somevalue', 'foo2' => 'somevalue2', 'foo3' => 'somevalue3', 'foo34' => 'somevalue3');

Better?

Sunday, March 25, 12

Page 18: What we can learn from WordPress as a developer

<?php if ( ! have_posts() ) : ?> <div id="post-1" class="post"> <h1 class="entry-title">Not Found</h1> <div class="entry-content"> <p>Apologies, but no results were found.</p> <?php get_search_form(); ?> </div> </div><?php endif; ?>

HTML

Sunday, March 25, 12

Page 19: What we can learn from WordPress as a developer

function te_custom_excerpt( $output ) {! if ( has_excerpt() && ! is_attachment() ) {! $output .= te_continue_reading_link();! }! return $output;}add_filter( 'get_the_excerpt', 'te_custom_excerpt' );

White Space

Sunday, March 25, 12

Page 20: What we can learn from WordPress as a developer

•x == 23

•foo && bar

•! foo

•function( $a, $b, $c )

•$concat . '-5'

•$term .= 'X'

In General

Sunday, March 25, 12

Page 22: What we can learn from WordPress as a developer

Thank you

Sunday, March 25, 12