SlideShare a Scribd company logo
Как получить чёрный пояс
по WordPress?
Евгений Котельницкий
WordCamp Russia 2015
Евгений Котельницкий
+YevhenKotelnytskyi
@yeeevhen
http://4coder.info/me
Как получить чёрный пояс по WordPress?
План
1. Что определяет уровень разработчика?
2. Через что проходит WP разработчик?
3. Что дальше?
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
Шаг 1 - Регестрируем блог на WP.com
Шаг 2 - Поднимаем WP на Shared-хостинге
Шаг 3 - Устанавливаем темы
Шаг 4 - Вносим правки в тему
Шаг 5 - Устанавливаем плагины
Шаг 6 - Изучаем админку
WordPress User Roles
User Roles
● Super Admin – site network administration;
● Administrator – administration features within a single site;
● Editor – can publish and manage posts of other users;
● Author – can publish and manage their own posts;
● Contributor – can write posts but cannot publish them;
● Subscriber – can only manage their profile.
Первый пояс есть!
FTP / SFTP
PhpMyAdmin
Начинаем создавать темы осмысленно
Знакомимся с теорией:
● http://codex.wordpress.org/Theme_Development
● http://codex.wordpress.org/Template_Hierarchy
● http://codex.wordpress.org/Conditional_Tags
● ...
Plugins & MU plugins
Post Types
● Post (Post Type: 'post')
● Page (Post Type: 'page')
● Attachment (Post Type: 'attachment')
● Revision (Post Type: 'revision')
● Navigation menu (Post Type: 'nav_menu_item')
● Custom Post Type (CPT): register_post_type()
Taxonomies
● Category (taxonomy: 'category')
● Tag (taxonomy: 'post_tag')
● Link Category (taxonomy: 'link_category')
● Post Formats (taxonomy: 'post_format')
● Custom Taxonomies: register_taxonomy()
Data Access API
● WP_Query
● WP_Tax_Query
● WP_User_Query
● get_posts ()
● get_terms ()
● get_option ()
● get_post_meta ()
● get_user_meta ()
● ...
Второй пояс получен!
Database Structure
Direct Database Access abstraction
<?php
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"DELETE FROM $wpdb->postmeta
WHERE post_id = %d
AND meta_key = %s",
13, 'gargle' ) );
?>
/**
* WordPress Database Access Abstraction
*/
class wpdb {
public function prepare( $query, $args );
public function show_errors( $show = true );
public function query( $query );
public function get_results( $query = null, $output = OBJECT ) {
public function get_row( $query = null, $output = OBJECT, $y = 0 );
public function get_col( $query = null , $x = 0 );
public function get_var( $query = null, $x = 0, $y = 0 );
public function update( $table, $data, $where, $format = null, $where_format = null );
...
Direct Database Access abstraction
Система хуков
<?php
do_action( $tag, $arg_a, $arg_b, $etc );
add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 );
?>
<?php
apply_filters( $tag, $value );
add_filter( $tag, $function_to_add, $priority, $accepted_args );
?>
Actions
Filters
Достигнут новый пояс!
Source Code Management Systems
Стандарты кодирования
PHP Coding Standards
HTML Coding Standards
CSS Coding Standards
JavaScript Standards
Localization
Localization
<?php
load_textdomain( $domain, $mofile );
load_plugin_textdomain( $domain, $abs_rel_path, $plugin_rel_path );
?>
<?php
$translated = __( 'Hello World!', 'domain' );
?>
<?php _e( 'Hello World!', 'domain' ) ?>
Localization & JS
<?php
// Register the script first
wp_register_script( 'some_handle', 'path/to/myscript.js' );
// Now we can localize the script with our data
$translation = array(
'some_str' => __( 'Some string', 'domain' ),
'a_value' => '10'
);
wp_localize_script( 'handle', 'object_name', $translation );
// The script can be enqueued now or later
wp_enqueue_script( 'handle' );
Зелёный пояс!
WP Network
WP Network
<?php
switch_to_blog( $blog_id );
// Do something
restore_current_blog();
?>
Network Database
● wp_blogs
● wp_blog_versions
● wp_registration_log
● wp_signups
● wp_site
● wp_sitemeta
Быстродействие
Синий пояс!
WordPress User Roles
Super Admin capabilities
● manage_network
● manage_sites
● manage_network_users
● manage_network_plugins
● manage_network_themes
● manage_network_options
● ...
Subscriber capabilities
● read
WordPress User Roles
class WP_Roles {
/**
* Add role name with capabilities to list.
*/
public function add_role( $role, $display_name, $capabilities = array() );
public function remove_role( $role );
/**
* Add capability to role.
*/
public function add_cap( $role, $cap, $grant = true );
public function remove_cap( $role, $cap );
...
WordPress User class
class WP_User {
/**
* Add role to user.
*/
public function add_role( $role );
public function remove_role( $role );
public function set_role( $role );
/**
* Add capability and grant or deny access to capability.
*/
public function add_cap( $cap, $grant = true );
public function remove_cap( $cap );
...
class WP_User {
/**
* Whether user has capability or role name.
* @return bool True, if user has capability;
* false, if user does not have capability.
*/
public function has_cap( $cap ) {
$caps = call_user_func_array( 'map_meta_cap', $args );
...
// Must have ALL requested caps
$capabilities = apply_filters(
'user_has_cap', $this->allcaps,
$caps, $args, $this );
...
WordPress User class
Впервые задумываемся о безопасности
Коричневый пояс!
Как работает WordPress?
WordPress environment setup class
class WP {
/**
* Sets up all of the variables required by the WordPress environment.
* @param string|array $query_args Passed to {@link parse_request()}
*/
public function main($query_args = '') {
$this->init();
$this->parse_request($query_args);
$this->send_headers();
$this->query_posts();
$this->handle_404();
$this->register_globals();
do_action_ref_array( 'wp', array( &$this ) );
}
...
WP_Rewrite - “Роутинг”
WP_Rewrite - “Роутинг”
class WP_Rewrite {
/**
* Retrieve the rewrite rules.
* @return array Rewrite rules.
*/
public function wp_rewrite_rules() {
$this->rules = get_option('rewrite_rules');
if ( empty($this->rules) ) {
$this->matches = 'matches';
$this->rewrite_rules();
update_option('rewrite_rules', $this->rules);
}
return $this->rules;
}
...
WP_Rewrite - “Роутинг”
Rewrite Rules
<?php
$rewrite = $wp_rewrite->wp_rewrite_rules();
array(
[robots.txt$] => index.php?robots=1
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
[search/(.+)/?$] => index.php?s=$matches[1]
[([0-9]{4})/?$] => index.php?year=$matches[1]
[.?.+?/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
[(.?.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]
...
WP_Rewrite - “Роутинг”
Rewrite Rules filters
1. apply_filters( 'post_rewrite_rules', $post_rewrite );
2. apply_filters( 'date_rewrite_rules', $date_rewrite );
3. apply_filters( 'root_rewrite_rules', $root_rewrite );
4. apply_filters( 'comments_rewrite_rules', $comments_rewrite );
5. apply_filters( 'search_rewrite_rules', $search_rewrite );
6. apply_filters( 'author_rewrite_rules', $author_rewrite );
7. apply_filters( 'page_rewrite_rules', $page_rewrite );
8. apply_filters( $permastructname . '_rewrite_rules', $rules );
9. apply_filters( 'rewrite_rules_array', $this->rules );
WP_Rewrite - “Роутинг”
WP_Rewrite::add_rule ()
// http://example.com/properties/123/
add_action( 'init', '_rewrites_init' );
function _rewrites_init() {
add_rewrite_rule(
'properties/([0-9]+)/?$',
'index.php?pagename=properties&property_id=$matches[1]', 'top' );
}
add_filter( 'query_vars', '_query_vars' );
function _query_vars( $query_vars ) {
$query_vars[] = 'property_id';
return $query_vars;
}
WP_Rewrite - “Роутинг”
WP_Rewrite::add_permastruct ()
<?php
class WP_Rewrite {
/**
* Add a new permalink structure.
*/
public function add_permastruct( $name, $struct, $args = array() ) {
...
$this->extra_permastructs[ $name ] = $args;
}
...
?>
WP_Rewrite - “Роутинг”
WP_Rewrite::add_permastruct ()
<?php
// http://example.com/au/some-prize-category/some-competition/
$wp_rewrite->add_rewrite_tag('%competition%', '([^/]+)', 'competition=');
$wp_rewrite->add_rewrite_tag('%prize_category%', '([^/]+)', 'prize_category=');
$wp_rewrite->add_permastruct(
'competition',
'/au/%prize_category%/%competition%/',
array( 'walk_dirs' => false ));
?>
WP_Query - The Query class
WordPress environment setup class
class WP {
/**
* Sets up all of the variables required by the WordPress environment.
* @param string|array $query_args Passed to {@link parse_request()}
*/
public function main($query_args = '') {
$this->init();
$this->parse_request($query_args);
$this->send_headers();
$this->query_posts();
$this->handle_404();
$this->register_globals();
do_action_ref_array( 'wp', array( &$this ) );
}
...
WP_Query - The Query class
The Main Query
/**
* WordPress environment setup class.
*/
class WP {
/**
* Set up the Loop based on the query variables.
*/
public function query_posts() {
global $wp_the_query;
$this->build_query_string();
$wp_the_query->query($this->query_vars);
}
...
WP_Query - The Query class
class WP_Query {
/**
* Sets up the WordPress query by parsing query string.
* @return array List of posts.
*/
public function query( $query ) {
$this->init();
$this->query = $this->query_vars = wp_parse_args( $query );
return $this->get_posts();
}
/**
* Retrieve the posts based on query variables.
* @return array List of posts.
*/
public function get_posts() {
...
do_action_ref_array( 'pre_get_posts', array( &$this ) );
...
WP_Query - The Query class
Query vars
/**
* Retrieve variable in the WP_Query class.
*
* @see WP_Query::get()
* @uses $wp_query
*
* @return mixed
*/
function get_query_var( $var, $default = '' ) {
global $wp_query;
return $wp_query->get( $var, $default );
}
Чёрный пояс!
Это всё?
Это начало :)
Highload & Perfomance,
Architecture, Supportability, Usability,
UNIX/Linux CLI, Stability, Unit
Testing, Continius integration,
… Communication skills,
Time management
Вопросы?
Спасибо!

More Related Content

PDF
Doctrine For Beginners
Jonathan Wage
 
PDF
Design how your objects talk through mocking
Konstantin Kudryashov
 
PDF
Doctrine fixtures
Bill Chang
 
PDF
Advanced symfony Techniques
Kris Wallsmith
 
PDF
Intro programacion funcional
NSCoder Mexico
 
PDF
WCLV13 JavaScript
Jeffrey Zinn
 
PDF
Hooks WCSD12
Jeffrey Zinn
 
PDF
A New Baseline for Front-End Devs
Rebecca Murphey
 
Doctrine For Beginners
Jonathan Wage
 
Design how your objects talk through mocking
Konstantin Kudryashov
 
Doctrine fixtures
Bill Chang
 
Advanced symfony Techniques
Kris Wallsmith
 
Intro programacion funcional
NSCoder Mexico
 
WCLV13 JavaScript
Jeffrey Zinn
 
Hooks WCSD12
Jeffrey Zinn
 
A New Baseline for Front-End Devs
Rebecca Murphey
 

What's hot (20)

ODP
Symfony2, creare bundle e valore per il cliente
Leonardo Proietti
 
ODP
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
 
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
PDF
Silex meets SOAP & REST
Hugo Hamon
 
PDF
You Don't Know Query (WordCamp Netherlands 2012)
andrewnacin
 
PDF
The Zen of Lithium
Nate Abele
 
PDF
PHPUnit でよりよくテストを書くために
Yuya Takeyama
 
PDF
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
PDF
PHP 5.3 and Lithium: the most rad php framework
G Woo
 
PDF
The Origin of Lithium
Nate Abele
 
KEY
Api Design
sartak
 
PDF
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
PDF
Design Patterns avec PHP 5.3, Symfony et Pimple
Hugo Hamon
 
PDF
CQRS and Event Sourcing in a Symfony application
Samuel ROZE
 
PDF
Decoupling the Ulabox.com monolith. From CRUD to DDD
Aleix Vergés
 
PPTX
WordPress plugin #3
giwoolee
 
PDF
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
PDF
Unit and Functional Testing with Symfony2
Fabien Potencier
 
PDF
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
 
PDF
Rich Model And Layered Architecture in SF2 Application
Kirill Chebunin
 
Symfony2, creare bundle e valore per il cliente
Leonardo Proietti
 
Rich domain model with symfony 2.5 and doctrine 2.5
Leonardo Proietti
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
arcware
 
Silex meets SOAP & REST
Hugo Hamon
 
You Don't Know Query (WordCamp Netherlands 2012)
andrewnacin
 
The Zen of Lithium
Nate Abele
 
PHPUnit でよりよくテストを書くために
Yuya Takeyama
 
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
PHP 5.3 and Lithium: the most rad php framework
G Woo
 
The Origin of Lithium
Nate Abele
 
Api Design
sartak
 
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Hugo Hamon
 
CQRS and Event Sourcing in a Symfony application
Samuel ROZE
 
Decoupling the Ulabox.com monolith. From CRUD to DDD
Aleix Vergés
 
WordPress plugin #3
giwoolee
 
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
Unit and Functional Testing with Symfony2
Fabien Potencier
 
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
 
Rich Model And Layered Architecture in SF2 Application
Kirill Chebunin
 
Ad

Viewers also liked (10)

PDF
WordCamp Moscow 2016: Как получить качество
Yevhen Kotelnytskyi
 
PDF
Как получить чёрный пояс по WordPress? v2.0
Yevhen Kotelnytskyi
 
PDF
Как устроен WordPress - WP Kharkiv Meetup #1
Yevhen Kotelnytskyi
 
PDF
Как не сойти с ума при разработке крупных проектов на WordPress
Yevhen Kotelnytskyi
 
PDF
Архитектура крупных WordPress сайтов
Yevhen Kotelnytskyi
 
PDF
Вёрстка WordPress тем - WP Kharkiv Meetup #1
dima_kuzovlev
 
PDF
Защищаем WordPress-сайт от хакерских атак
Ruslan Sukhar
 
PDF
SEO - поведенческие факторы.
Pavel Karpov
 
PDF
Premium-темы WordPress
versusbassz
 
PDF
Вёрстка по методологии БЭМ
versusbassz
 
WordCamp Moscow 2016: Как получить качество
Yevhen Kotelnytskyi
 
Как получить чёрный пояс по WordPress? v2.0
Yevhen Kotelnytskyi
 
Как устроен WordPress - WP Kharkiv Meetup #1
Yevhen Kotelnytskyi
 
Как не сойти с ума при разработке крупных проектов на WordPress
Yevhen Kotelnytskyi
 
Архитектура крупных WordPress сайтов
Yevhen Kotelnytskyi
 
Вёрстка WordPress тем - WP Kharkiv Meetup #1
dima_kuzovlev
 
Защищаем WordPress-сайт от хакерских атак
Ruslan Sukhar
 
SEO - поведенческие факторы.
Pavel Karpov
 
Premium-темы WordPress
versusbassz
 
Вёрстка по методологии БЭМ
versusbassz
 
Ad

Similar to Как получить чёрный пояс по WordPress? (20)

PDF
A WordPress workshop at Cefalo
Beroza Paul
 
PDF
Laying the proper foundation for plugin and theme development
Tammy Hart
 
PPT
WordPress theme frameworks
Eddie Johnston
 
PDF
Gail villanueva add muscle to your wordpress site
references
 
PDF
Wordpress #2 : customisation
Jean Michel
 
PDF
Becoming a better WordPress Developer
Joey Kudish
 
PPT
WordPress as a Content Management System
Valent Mustamin
 
PPT
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Mike Schinkel
 
PPTX
Take Command of WordPress With WP-CLI
Diana Thompson
 
KEY
doing_it_right() with WordPress
ryanduff
 
PPT
WordPress Plugins: ur doin it wrong
Will Norris
 
PDF
Do you really need a Child Theme?
pixolin
 
PPTX
The Way to Theme Enlightenment
Amanda Giles
 
PPTX
The Way to Theme Enlightenment 2017
Amanda Giles
 
PPTX
WordPress 3.0 at DC PHP
andrewnacin
 
PPTX
WordPress Structure and Best Practices
markparolisi
 
PDF
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
LinnAlexandra
 
PDF
WordPress as an application framework
Dustin Filippini
 
PDF
Using Wordpress with Reclaim Hosting
Cindy Royal
 
PDF
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Jer Clarke
 
A WordPress workshop at Cefalo
Beroza Paul
 
Laying the proper foundation for plugin and theme development
Tammy Hart
 
WordPress theme frameworks
Eddie Johnston
 
Gail villanueva add muscle to your wordpress site
references
 
Wordpress #2 : customisation
Jean Michel
 
Becoming a better WordPress Developer
Joey Kudish
 
WordPress as a Content Management System
Valent Mustamin
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Mike Schinkel
 
Take Command of WordPress With WP-CLI
Diana Thompson
 
doing_it_right() with WordPress
ryanduff
 
WordPress Plugins: ur doin it wrong
Will Norris
 
Do you really need a Child Theme?
pixolin
 
The Way to Theme Enlightenment
Amanda Giles
 
The Way to Theme Enlightenment 2017
Amanda Giles
 
WordPress 3.0 at DC PHP
andrewnacin
 
WordPress Structure and Best Practices
markparolisi
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
LinnAlexandra
 
WordPress as an application framework
Dustin Filippini
 
Using Wordpress with Reclaim Hosting
Cindy Royal
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Jer Clarke
 

Recently uploaded (20)

DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Presentation about variables and constant.pptx
safalsingh810
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 

Как получить чёрный пояс по WordPress?

  • 1. Как получить чёрный пояс по WordPress? Евгений Котельницкий WordCamp Russia 2015
  • 4. План 1. Что определяет уровень разработчика? 2. Через что проходит WP разработчик? 3. Что дальше?
  • 7. Шаг 1 - Регестрируем блог на WP.com
  • 8. Шаг 2 - Поднимаем WP на Shared-хостинге
  • 9. Шаг 3 - Устанавливаем темы
  • 10. Шаг 4 - Вносим правки в тему
  • 11. Шаг 5 - Устанавливаем плагины
  • 12. Шаг 6 - Изучаем админку
  • 13. WordPress User Roles User Roles ● Super Admin – site network administration; ● Administrator – administration features within a single site; ● Editor – can publish and manage posts of other users; ● Author – can publish and manage their own posts; ● Contributor – can write posts but cannot publish them; ● Subscriber – can only manage their profile.
  • 17. Начинаем создавать темы осмысленно Знакомимся с теорией: ● http://codex.wordpress.org/Theme_Development ● http://codex.wordpress.org/Template_Hierarchy ● http://codex.wordpress.org/Conditional_Tags ● ...
  • 18. Plugins & MU plugins
  • 19. Post Types ● Post (Post Type: 'post') ● Page (Post Type: 'page') ● Attachment (Post Type: 'attachment') ● Revision (Post Type: 'revision') ● Navigation menu (Post Type: 'nav_menu_item') ● Custom Post Type (CPT): register_post_type()
  • 20. Taxonomies ● Category (taxonomy: 'category') ● Tag (taxonomy: 'post_tag') ● Link Category (taxonomy: 'link_category') ● Post Formats (taxonomy: 'post_format') ● Custom Taxonomies: register_taxonomy()
  • 21. Data Access API ● WP_Query ● WP_Tax_Query ● WP_User_Query ● get_posts () ● get_terms () ● get_option () ● get_post_meta () ● get_user_meta () ● ...
  • 24. Direct Database Access abstraction <?php global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", 13, 'gargle' ) ); ?>
  • 25. /** * WordPress Database Access Abstraction */ class wpdb { public function prepare( $query, $args ); public function show_errors( $show = true ); public function query( $query ); public function get_results( $query = null, $output = OBJECT ) { public function get_row( $query = null, $output = OBJECT, $y = 0 ); public function get_col( $query = null , $x = 0 ); public function get_var( $query = null, $x = 0, $y = 0 ); public function update( $table, $data, $where, $format = null, $where_format = null ); ... Direct Database Access abstraction
  • 26. Система хуков <?php do_action( $tag, $arg_a, $arg_b, $etc ); add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ); ?> <?php apply_filters( $tag, $value ); add_filter( $tag, $function_to_add, $priority, $accepted_args ); ?> Actions Filters
  • 29. Стандарты кодирования PHP Coding Standards HTML Coding Standards CSS Coding Standards JavaScript Standards
  • 31. Localization <?php load_textdomain( $domain, $mofile ); load_plugin_textdomain( $domain, $abs_rel_path, $plugin_rel_path ); ?> <?php $translated = __( 'Hello World!', 'domain' ); ?> <?php _e( 'Hello World!', 'domain' ) ?>
  • 32. Localization & JS <?php // Register the script first wp_register_script( 'some_handle', 'path/to/myscript.js' ); // Now we can localize the script with our data $translation = array( 'some_str' => __( 'Some string', 'domain' ), 'a_value' => '10' ); wp_localize_script( 'handle', 'object_name', $translation ); // The script can be enqueued now or later wp_enqueue_script( 'handle' );
  • 35. WP Network <?php switch_to_blog( $blog_id ); // Do something restore_current_blog(); ?>
  • 36. Network Database ● wp_blogs ● wp_blog_versions ● wp_registration_log ● wp_signups ● wp_site ● wp_sitemeta
  • 39. WordPress User Roles Super Admin capabilities ● manage_network ● manage_sites ● manage_network_users ● manage_network_plugins ● manage_network_themes ● manage_network_options ● ... Subscriber capabilities ● read
  • 40. WordPress User Roles class WP_Roles { /** * Add role name with capabilities to list. */ public function add_role( $role, $display_name, $capabilities = array() ); public function remove_role( $role ); /** * Add capability to role. */ public function add_cap( $role, $cap, $grant = true ); public function remove_cap( $role, $cap ); ...
  • 41. WordPress User class class WP_User { /** * Add role to user. */ public function add_role( $role ); public function remove_role( $role ); public function set_role( $role ); /** * Add capability and grant or deny access to capability. */ public function add_cap( $cap, $grant = true ); public function remove_cap( $cap ); ...
  • 42. class WP_User { /** * Whether user has capability or role name. * @return bool True, if user has capability; * false, if user does not have capability. */ public function has_cap( $cap ) { $caps = call_user_func_array( 'map_meta_cap', $args ); ... // Must have ALL requested caps $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args, $this ); ... WordPress User class
  • 43. Впервые задумываемся о безопасности
  • 45. Как работает WordPress? WordPress environment setup class class WP { /** * Sets up all of the variables required by the WordPress environment. * @param string|array $query_args Passed to {@link parse_request()} */ public function main($query_args = '') { $this->init(); $this->parse_request($query_args); $this->send_headers(); $this->query_posts(); $this->handle_404(); $this->register_globals(); do_action_ref_array( 'wp', array( &$this ) ); } ...
  • 47. WP_Rewrite - “Роутинг” class WP_Rewrite { /** * Retrieve the rewrite rules. * @return array Rewrite rules. */ public function wp_rewrite_rules() { $this->rules = get_option('rewrite_rules'); if ( empty($this->rules) ) { $this->matches = 'matches'; $this->rewrite_rules(); update_option('rewrite_rules', $this->rules); } return $this->rules; } ...
  • 48. WP_Rewrite - “Роутинг” Rewrite Rules <?php $rewrite = $wp_rewrite->wp_rewrite_rules(); array( [robots.txt$] => index.php?robots=1 [category/(.+?)/?$] => index.php?category_name=$matches[1] [page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1] [search/(.+)/?$] => index.php?s=$matches[1] [([0-9]{4})/?$] => index.php?year=$matches[1] [.?.+?/attachment/([^/]+)/?$] => index.php?attachment=$matches[1] [(.?.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2] ...
  • 49. WP_Rewrite - “Роутинг” Rewrite Rules filters 1. apply_filters( 'post_rewrite_rules', $post_rewrite ); 2. apply_filters( 'date_rewrite_rules', $date_rewrite ); 3. apply_filters( 'root_rewrite_rules', $root_rewrite ); 4. apply_filters( 'comments_rewrite_rules', $comments_rewrite ); 5. apply_filters( 'search_rewrite_rules', $search_rewrite ); 6. apply_filters( 'author_rewrite_rules', $author_rewrite ); 7. apply_filters( 'page_rewrite_rules', $page_rewrite ); 8. apply_filters( $permastructname . '_rewrite_rules', $rules ); 9. apply_filters( 'rewrite_rules_array', $this->rules );
  • 50. WP_Rewrite - “Роутинг” WP_Rewrite::add_rule () // http://example.com/properties/123/ add_action( 'init', '_rewrites_init' ); function _rewrites_init() { add_rewrite_rule( 'properties/([0-9]+)/?$', 'index.php?pagename=properties&property_id=$matches[1]', 'top' ); } add_filter( 'query_vars', '_query_vars' ); function _query_vars( $query_vars ) { $query_vars[] = 'property_id'; return $query_vars; }
  • 51. WP_Rewrite - “Роутинг” WP_Rewrite::add_permastruct () <?php class WP_Rewrite { /** * Add a new permalink structure. */ public function add_permastruct( $name, $struct, $args = array() ) { ... $this->extra_permastructs[ $name ] = $args; } ... ?>
  • 52. WP_Rewrite - “Роутинг” WP_Rewrite::add_permastruct () <?php // http://example.com/au/some-prize-category/some-competition/ $wp_rewrite->add_rewrite_tag('%competition%', '([^/]+)', 'competition='); $wp_rewrite->add_rewrite_tag('%prize_category%', '([^/]+)', 'prize_category='); $wp_rewrite->add_permastruct( 'competition', '/au/%prize_category%/%competition%/', array( 'walk_dirs' => false )); ?>
  • 53. WP_Query - The Query class WordPress environment setup class class WP { /** * Sets up all of the variables required by the WordPress environment. * @param string|array $query_args Passed to {@link parse_request()} */ public function main($query_args = '') { $this->init(); $this->parse_request($query_args); $this->send_headers(); $this->query_posts(); $this->handle_404(); $this->register_globals(); do_action_ref_array( 'wp', array( &$this ) ); } ...
  • 54. WP_Query - The Query class The Main Query /** * WordPress environment setup class. */ class WP { /** * Set up the Loop based on the query variables. */ public function query_posts() { global $wp_the_query; $this->build_query_string(); $wp_the_query->query($this->query_vars); } ...
  • 55. WP_Query - The Query class class WP_Query { /** * Sets up the WordPress query by parsing query string. * @return array List of posts. */ public function query( $query ) { $this->init(); $this->query = $this->query_vars = wp_parse_args( $query ); return $this->get_posts(); } /** * Retrieve the posts based on query variables. * @return array List of posts. */ public function get_posts() { ... do_action_ref_array( 'pre_get_posts', array( &$this ) ); ...
  • 56. WP_Query - The Query class Query vars /** * Retrieve variable in the WP_Query class. * * @see WP_Query::get() * @uses $wp_query * * @return mixed */ function get_query_var( $var, $default = '' ) { global $wp_query; return $wp_query->get( $var, $default ); }
  • 60. Highload & Perfomance, Architecture, Supportability, Usability, UNIX/Linux CLI, Stability, Unit Testing, Continius integration, … Communication skills, Time management