Lviv Euro Drupal Camp 2015_От front-end разработки к темизации в Drupal
Wordpress theme
1. Что такое WordPress Тема ?
Это набор файлов состоящий из :
● style.css Информация и стили темы
● Index.php, footer.php, Шаблоны темы, файлы
header.php и т.д содержащие кусочки PHP кода.
● Functions.php Файл функций темы
● JavaScript, images, css Остальные файлы темы
2. Style.css
/*
Theme Name: P2
Theme URI: http://p2theme.com/
Author: Automattic
Author URI: http://automattic.com/
● Обьявление темы Description: A group blog theme for short update messages,
inspired by Twitter. Featuring: Hassle-free posting from the
front page. Perfect for group blogging, or as a liveblog
theme. Dynamic page updates. Threaded comment display on the
● Информация о теме front page. In-line editing for posts and comments. Live tag
suggestion based on previously used tags. A show/hide feature
for comments, to keep things tidy. Real-time notifications
when a new comment or update is posted. Super-handy keyboard
Таблица стилей
shortcuts. Helvetica Neue for you modern font lovers.
●
Version: 1.4.2
Tags: blue, two-columns, fixed-width, rtl-language-support,
right-sidebar, white, light, front-page-post-form,
translation-ready, custom-background, custom-header, custom-
menu, post-formats, sticky-post, theme-options
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what
you've learned with others.
*/
3. Файлы шаблонов темы
Header.php
<?php
/**
* Header template.
* @package P2
Содержит в себе всю */
верхню часть сайта, ?>
которая не меняется для <!DOCTYPE html>
<html <?php language_attributes(); ?>>
всех страниц. <head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php
● Обязательная часть bloginfo( 'html_type' ); ?>; charset=<?php
bloginfo( 'charset' ); ?>" />
wp_head(), используется <title><?php wp_title( '«', true, 'right' ); ?> <?
для хуков. php bloginfo( 'name' ); ?></title>
<link rel="stylesheet" href="<?php
bloginfo( 'stylesheet_url' ); ?>" type="text/css"
● Вызывается с помощью media="screen" />
<?php wp_head(); ?>
get_header(); </head>
<body <?php body_class(); ?>>
● get_sidebar(); вызывает <div id="header">
шаблон sidebar.php <div role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'primary',
'fallback_cb' => '__return_false', ) ); ?>
</div>
</div>
<div id="wrapper">
<?php get_sidebar(); ?>
4. Footer.php
● Содержит в себе
неизменную нижнюю </div><!--
div#wrapper -->
часть сайта
<?php wp_footer(); ?
>
● Обязательно содержит
</body>
wp_footer перед
закрывающимся </body> </html>
● Вызывается с помощью
get_footer();
5. Index.php
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php p2_load_entry(); ?>
● Основной шаблон для <?php endwhile; ?>
отображения контента
<?php else : ?>
● Одного его достаточно для <li class="no-posts">
отображения любых <h3><?php _e( 'No posts yet!', 'p2' ); ?
></h3>
разделов сайта. </li>
<?php endif; ?>
● Основная часть - цикл </ul>
WordPress
<div class="navigation">
<p class="nav-older"><?php next_posts_link( __(
'← Older posts', 'p2' ) ); ?></p>
<p class="nav-newer"><?php previous_posts_link(
__( 'Newer posts →', 'p2' ) ); ?></p>
</div>
<?php get_footer(); ?>