Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
Everything You Need to Know About WP_Query, WordCamp Russia 2014
Next
Download to read offline and view in fullscreen.

0

Share

Looking into WordPress Core, WordCamp Russia 2015

Download to read offline

https://russia.wordcamp.org/2015/

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Looking into WordPress Core, WordCamp Russia 2015

  1. 1. Почему стоит участвовать в разработке WordPress Сергей Бирюков WordCamp Russia 2015
  2. 2. Обо мне Сергей Бирюков ● Разработчик ядра WordPress core.trac.wordpress.org ● Локализатор WP в России ru.wordpress.org sergeybiryukov.ru @SergeyBiryukov
  3. 3. Зачем смотреть, как устроен WordPress?
  4. 4. Как следить за разработкой WordPress?
  5. 5. ● make.wordpress.org/core/ ● wp-svn ● wp-trac
  6. 6. wp-admin/edit-form-advanced.php wp-admin/includes/meta-boxes.php wp-includes/default-filters.php
  7. 7. grep, ack, cmd-f и т.д.
  8. 8. PhpStorm 8
  9. 9. PHPXref
  10. 10. Codex
  11. 11. developer.wordpress.org
  12. 12. add_action( 'publish_post' )
  13. 13. add_filter( 'all', function( $stuff ) { echo '<code>' . current_filter() . '</code>'; return $stuff; });
  14. 14. add_filter( 'gettext', function( $new, $old, $domain ) { if ( 'Set featured image' === $old ) { if ( 'company' === get_post_type() ) { $new = __( 'Set company logo', 'mydomain' ); } } return $new; }, 10, 3 );
  15. 15. add_filter( 'admin_post_thumbnail_html', function( $output, $post_id ) { if ( 'company' === get_post_type( $post_id ) ) { $output = str_replace( __( 'Set featured image' ), 'Select / Upload a company logo', $output ); $output = str_replace( __( 'Remove featured image' ), 'Remove company logo', $output ); } return $output; }, 10, 2 );
  16. 16. Для фильтров и действий важен контекст
  17. 17. apply_filters( 'media_view_strings', $strings, $post )
  18. 18. remove_post_type_support()
  19. 19. Экран редактирования — одна большая форма
  20. 20. <textarea name="excerpt" id="attachment_caption"> <?php echo $post->post_excerpt; ?> </textarea>
  21. 21. Произвольные таксономии
  22. 22. add_action( 'save_post', function( $post_id, $post ) { // Не забываем проверить nonce и привилегии if ( isset( $_POST['my_tax_ui'] ) ) { // array_map() $terms = $_POST['my_tax_ui']; wp_set_object_terms( $post_id, $terms, 'my_tax' ); } else { wp_delete_object_term_relationships( $post_id, 'my_tax' ); } }, 10, 2 );
  23. 23. <select name="tax_input['my_tax'][]">
  24. 24. add_action( 'save_post', function( $post_id, $post ) { // Не забываем проверить nonce и привилегии If ( ! isset( $_POST['my_tax_ui'] ) ) { wp_delete_object_term_relationships( $post_id, 'my_tax' ); } }, 10, 2 );
  25. 25. <input type="hidden" name="tax_input['my_tax'][]" value="0" />
  26. 26. add_rewrite_endpoint( 'export', EP_PAGES ) site.com/some-page/export/ site.com/some-page/export/json/
  27. 27. get_query_var( 'export' )
  28. 28. add_filter( 'request', function( $vars ) { if ( isset( $vars['export'] ) && empty( $vars['export'] ) ) { $vars['export'] = '1'; } return $vars; });
  29. 29. get_query_var( 'export', null )
  30. 30. Сложные запросы
  31. 31. 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'age', 'terms' => array( '5' ), ), array( 'relation' => 'OR', array( 'taxonomy' => 'academic_skills', 'terms' => array( 'reading', 'writing' ), ), array( 'taxonomy' => 'skills', 'terms' => array( 'focus', 'flexibility' ), ), ), )
  32. 32. term_id + taxonomy = term_taxonomy_id
  33. 33. sergeybiryukov.ru @SergeyBiryukov Спасибо! Вопросы?

https://russia.wordcamp.org/2015/

Views

Total views

2,146

On Slideshare

0

From embeds

0

Number of embeds

626

Actions

Downloads

4

Shares

0

Comments

0

Likes

0

×