Download - Pourquoi WordPress n’est pas un CMS
![Page 1: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/1.jpg)
WordPress is not a Content Management System
Do not use it for your websites!
[email protected] @methylbro
Tuesday 6th of May 2014 @LaCantine_Tlse, Toulouse
![Page 2: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/2.jpg)
involvededition=2013
spokeedition=2012
Who I am ?
name=Thomas G.type=person
spokeedition=11/12/2012
name=Human Talkstype=event
name=PHP Tourtype=event
name=Paris Webtype=event
name=Sud Webtype=event
attendeeedition=2012, 2013
name=Forum PHPtype=event
membervolunteer=2012, 2013office=2014
name=AFUPtype=organization
attendeeedition=2013, 2014
attendeeedition=2012, 2013
attendeeedition=2014
organized
14
organized
3
2
2
2
inspired inspired
http://methylbro.fr/
![Page 3: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/3.jpg)
WordPress is web software you can use to create a beautiful website or blog
wordpress.org
![Page 4: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/4.jpg)
WordPress is shit!
![Page 5: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/5.jpg)
5 horribles things in WordPress
about themes, metadata, plugins, core, ...
![Page 6: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/6.jpg)
wp-content/themes/
<?php
// WordPress template
while($latest_cat_post->have_posts()) :
$latest_cat_post->the_post();the_title();the_excerpt();
endwhile;
<?php
// as it should be
foreach ($lastest_posts as $post) {
echo $post->title;echo $post->excerpt;
}
http://codex.wordpress.org/Global_Variables
![Page 7: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/7.jpg)
Spaghetti Codehttp://en.wikipedia.org/wiki/Spaghetti_code
![Page 8: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/8.jpg)
wp-includes/meta.php
/* post's enhancement with metadata */
function add_metadata(
string $meta_type, int $object_id,string $meta_key,mixed $meta_value, bool $unique = false
);
function get_metadata(
string $meta_type,int $object_id,string $meta_key = ‘’,bool $single = false
);
<?php
// define a connexion between 2 posts
$post_id = 14;$next_post_id = 17;
add_metadata(‘post’, $post_id, ‘next_post’, $next_post_id
);
// what’s happen if … ?
wp_delete_post( $next_post_id );
http://codex.wordpress.org/Function_Reference/the_meta
![Page 9: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/9.jpg)
Video
Content Managing System
<Content> Article
Song
Video Clip
Lyrics
http://en.wikipedia.org/wiki/Content_management_system
![Page 10: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/10.jpg)
wp-includes/plugin.php
<?php
// how WordPress plugin works
function plugin_footer() {
echo ‘hello world !’;}
add_action( ‘wp_footer’ , ‘plugin_footer );
do_action( ‘wp_footer’ );
<?php
// how plugins should works
class Footer extends SPLSubject { /*...*/ }class FooterPlugin extends SPLObserver{
function update() {
echo ‘hello world !’;}
}
$wp_footer = new Footer();
$wp_footer->attach( new FooterPlugin() );
$wp_footer->notify();
http://codex.wordpress.org/Plugin_API
![Page 11: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/11.jpg)
SPLObserver Interface
: SPLSubject : SPLObserver
notify()
attach()
update()
http://www.php.net/manual/en/class.splobserver.php
![Page 12: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/12.jpg)
wp-includes/class-wp.phphttp://develop.svn.wordpress.org/branches/3.9/src/wp-includes/class-wp.php
<?php
class WP {
// ...
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 )
);}
}
// ...
require '/template-loader.php' ;
1. initiatebuild WP_User instance into $current_user global
2. parse requestretrieves params into self::$query_vars
3. send http headerssend headers and terminate if needed
4. retrieves infos from databaseparse and execute $wp_query and then retrieves posts
5. handle 404changes the http headers already sent if a not found error occurred during the request
6. register lot of globalsretrieves posts data and set them into globals vars
7. send signal to pluginssay to the plugins that they can do things here
8. render php script as templateexecute a php script as a template and directly output the result
![Page 13: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/13.jpg)
HTTPKernel
Request requestresolve
controller
controller
resolve arguments
view
response Response
terminate
exception
Sub-Request
Call Controller
exception
“sub-response” content
response?
http://symfony.com/doc/current/components/http_kernel/introduction.html
![Page 14: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/14.jpg)
wp-includes/class-wp.php
<?php
class WP {
// ...
function query_posts() {
global $wp_the_query;
$this->build_query_string();
$wp_the_query->query($this->query_vars
); }
}
not even passed as parameter !! WTF ?!
http://develop.svn.wordpress.org/branches/3.9/src/wp-includes/class-wp.php
![Page 15: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/15.jpg)
Dependency Injectionhttp://php-di.org/doc/understanding-di.html
![Page 16: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/16.jpg)
It’s all about interoperability
PHP Framework Interoperability Group
http://www.php-fig.org/
![Page 17: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/17.jpg)
All these things are in Drupal 8
Drupal 8
http://symfony.com/blog/symfony2-meets-drupal-8
- EventDispatcher- HTTPKernel- DependencyInjection
and more ...
![Page 18: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/18.jpg)
Use cool tools
terminal
cool toolsand even more
![Page 19: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/19.jpg)
More powerful than WordPress templates
Template Engine
CSS Framework
∞templatesImage
Editor
infinity
![Page 20: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/20.jpg)
More powerful than WordPress plugins
PackagistComposer
30 000+packages
http://getcomposer.org/doc/00-intro.md
![Page 21: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/21.jpg)
Conclusion: Don’t be afraid (to code) !
![Page 22: Pourquoi WordPress n’est pas un CMS](https://reader034.vdocuments.site/reader034/viewer/2022051610/54978d0fac795959288b54f8/html5/thumbnails/22.jpg)
Thank you, Any questions?
Illustrations :http://thenounproject.com/
www.afup.orgFrench Association of PHP Users
Join
www.phptour.orgLyon, France
June, 23rd & 24th 2014