4. Tak o tom to dnes
vážně nebude
Pluginy
#wpweekendcz | @hlavacm
5. ● PHP soubor(y) obvykle v rootu WP
● Zpracování vlastní logiky nad
rámec WP (pro CRON)
● Plná funkčnost šablony, ale bez UI
“root” skripty
#wpweekendcz | @hlavacm
6. Integrating WordPress with
Your Website
https://codex.wordpress.org/Integrating_WordPress_with_Your_Website
Codex
#wpweekendcz | @hlavacm
8. ?php
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
wp-blog-header.php
#wpweekendcz | @hlavacm
9. It's a global variable that can be
checked by user functions and
filters to see whether or not
WordPress has already sent
headers. It's just there to help.
Zdroj: “EAMann” https://wordpress.stackexchange.com/a/20629
$wp_did_header = true;
#wpweekendcz | @hlavacm
10. /** Set up the WordPress query. */
function wp( $query_vars = '' ) {
global $wp, $wp_query, $wp_the_query;
$wp-main( $query_vars );
if ( !isset($wp_the_query) )
$wp_the_query = $wp_query;
}
wp()
#wpweekendcz | @hlavacm
11. ?php
/**
* Loads the correct template based on the visitor's url
* @package WordPress
*/
if (defined('WP_USE_THEMES') WP_USE_THEMES)
...
= 404 template (anebo filter “template_include”)
template-loader.php
#wpweekendcz | @hlavacm
12. ?php
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
wp-blog-header.php
#wpweekendcz | @hlavacm
17. ● Libovolný vlastní PHP kód
● PHP knihovny (přes Composer?)
● WP kód (WP_Query, WPDB, ...)
● Kód ze šablony
○ WPFW - “pomocné” třídy
Jak na to, aneb co použít?
#wpweekendcz | @hlavacm
18. ● Import/export/údržba dat
● Propojení s API třetích stran
● Generování PDF, XML, atd.
● Print Label
● Download skrytých souborů
● OAuth2 callback
Příklady využití
#wpweekendcz | @hlavacm