Neočekávaný výstup (unexpected output) při aktivaci pluginu

Po vydání WordPressu 3.0 se mnoha uživatelům objevila během aktivace některých pluginů chybová hláška o vygenerovaném neočekávaném výstupu (unexpected output). I přesto, že plugin v mnoha případech nakonec v pořádku fungoval, tak to rozhodně nebyl ideální první dojem na uživatele, kteří si plugin nainstalovali a chtěli ho vyzkoušet (nehledě na možné zástupné problémy). Kde se tato hláška vzala, co přesně znamená a jak mohou […]

Úprava pluginů v repozitáři WordPressu

Minule jste se mohli dozvědět něco o tom, jak se vlastně dělá plugin pro jeden z nejrozšířenějších redakčních systémů. Dnes se podíváme na to, jak plugin dostat do oficiálního repozitáře wordpressáckých pluginů a jak nahrané soubory editovat. Ještě předtím, než získáte přístup do Plugin Directory, musíte dát vědět o svém pluginu. Až bude požadavek schválen, […]

Testování vývojových verzí

**Theme Test Drive**
„https://wordpress.org/plugins/theme-test-drive/“:https://wordpress.org/plugins/theme-test-drive/

Theme Test Drive WordPress plugin allows you to safely test drive any theme on your blog as administrator, while visitors still use the default one. It happens completely transparent and they will not even notice you run a different theme for yourself.

Best part is you can even set the testing theme options (if it has them) in the Admin panel while you are testing the theme.

**Development Theme Test**
„http://www.kwista.com/programming/dev-theme-test-wordpress-plugin-release/“:http://www.kwista.com/programming/dev-theme-test-wordpress-plugin-release/

Trying to edit your theme or test a new theme can be very difficult without a testing server or a dev location. Dev Theme Test allows you to create a password protected and non-password protected subdomain such as dev.yoursite.com in order to make modifications to your current theme or a new theme while still displaying your original theme to site visitors. Test drive your themes and use our theme tester!

Jak udělat jednoduchý plugin pro WordPress

Tvoření pluginů pro platformu WordPress není nijak složité. V podstatě bohatě stačí, když umíte alespoň základy jazyka PHP (případně SQL). V první části seriálu se podíváme na to, jak dát dohromady velmi triviální plugin.
Tvorbu budu názorně demonstrovat na imaginárním pluginu „Database Optimization“, který bude mít za úkol defragmentovat (optimalizovat) všechny tabulky s nastaveným prefixem přes […]

Problém s funkcí query_post při stránkování

Jestliže v šabloně z nějakých důvodů nevystačíme se standardním načtením článků pomocí konstrukce

/—code php
if (have_posts()) : while (have_posts()) : the_post();
\—

a potřebujeme využít funkci „query_posts()“:http://codex.wordpress.org/Function_Reference/query_posts například pro vyloučení některých kategorií, tagů, autora a podobně, typicky v podobě:

/—code php
// výběr článků z vybraných rubrik
query_posts(‚cat=2,6,17,38‘);

// výběr článků patřících do několika rubrik současně
query_posts(array(‚category__and‘ => array(2,6)));

// výběr článků s vyloučením určité rubriky
query_posts(‚cat=-3‘);
\—

Rychle zjistíme, že tento postup sice vede k cíli, nicméně **přestane fungovat stránkování** a tím i pluginy jako např. výborný „WP-PageNavi“:222.

Náprava je jednoduchá:

/—code php
if (have_posts()):

// obnovíme parametr ‚paged‘
$paged = (get_query_var(‚paged‘)) ? get_query_var(‚paged‘) : 1;
query_posts(„cat=-3&paged=$paged“);

// a pak už pokračujeme standardním
while (have_posts()) : the_post();
\—

Viz též „Separatista“:http://www.separatista.net/wordpress/tipy-a-triky/problemy-se-strankovanim-prispevku-pri-pouziti-funkce-query_posts nebo „David Binda“:http://david.binda.cz/wordpress-nefunkcni-strankovani-v-dusledku-query_posts.

„Properly using wp_reset_postdata(), wp_reset_query() and variable naming in queries »“:http://www.poststat.us/properly-reset-wordpress-query/

„How to fix pagination for custom loops »“:http://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops

Vkládání a náhrada bloků dat – textu, PHP kódu, databáze

**Sniplets**
„http://wordpress.org/extend/plugins/sniplets/“:http://wordpress.org/extend/plugins/sniplets/
„http://urbangiraffe.com/plugins/sniplets/“:http://urbangiraffe.com/plugins/sniplets/

Sniplets is a generic text insertion plugin with support for an extensible processing framework. At it’s simplest this means you can dynamically replace text in your posts with text that may be defined elsewhere, or created by some other module. For example, you can use Sniplets to perform syntax highlighting of files, execute custom PHP code, insert data from a database, and perform all manner of other useful tasks within a standard interface. On top of this, Sniplets can be automatically inserted at key points on a page. For example, you can automatically insert text on every RSS post.

– Replace tags in a post with pre-defined text
– Customizable placement points and templates
– Apply processing modules to the pre-defined text to perform additional functionality
– Automatically insert Sniplets in key points of a page (before post, after post, more tag, header, footer, comment form, sidebar, and initialization)
– Apply pre-defined templates to Sniplets
– Includes a Sidebar Widget to allow Sniplets in the sidebar
– Custom modules can be written by the user
– Fully localized

Používání sessions

WordPress standardně nepodporuje sessions, což může být velmi potřebné např. při vytváření pluginu.

Stačí do functions.php (Vzhled > Upravit soubory) přidat:

/—code php
if (!session_id())
add_action(‚init‘, ‚session_start‘);
\—

*Alternativa*

Na začátek souboru wp-config.php (hned za úvodní

Validace kódu WordPressu

Dnes jsem konečně oficiálně zveřejnil plugin ušitý pro WordPress zvaný Validation Helper. Tentokrát se opravdu nejedná o žádný apríl, byť by tuto myšlenku mohlo podporovat dnešní datum.
Validation Helper je určen pro všechny uživatele, kteří nejsou spokojeni s nevalidním zdrojovým kódem své šablony. Plugin automaticky převádí XHTML kód na HTML, čímž se odstraní většina chyb. V […]

Zvýraznění syntaxe kódu v editaci šablon a pluginů

**Power Code Editor**
„http://wordpress.org/extend/plugins/power-code-editor/“:http://wordpress.org/extend/plugins/power-code-editor/
„http://anetech.eu/power-code-editor/“:http://anetech.eu/power-code-editor/

Helps you more effectively edit your themes or plugins when you only have access to a browser, by enabling syntax highlighting in WordPress‘ integrated source code editors. Supports PHP, HTML, CSS and JavaScript.

*Alternativy:*

**WP Code Editor Plus**
„http://wordpress.org/extend/plugins/wp-code-editor-plus/“:http://wordpress.org/extend/plugins/wp-code-editor-plus/

Current Features Include: * Syntax Highlighter * JavaScript Code Completion * Ability to resize editor via click & drag

**HTML Editor Syntax Highlighter**
„http://wordpress.org/extend/plugins/html-editor-syntax-highlighter/screenshots/“:http://wordpress.org/extend/plugins/html-editor-syntax-highlighter/screenshots/

[* http://s.wordpress.org/extend/plugins/html-editor-syntax-highlighter/screenshot-1.png?r=599322 500×261 *]

**WP Editarea**
„http://wordpress.org/extend/plugins/wp-editarea/“:http://wordpress.org/extend/plugins/wp-editarea/
„http://takien.com/606/wp-editarea-wordpress-plugin.php“:http://takien.com/606/wp-editarea-wordpress-plugin.php

Umožňuje editor vypínat a zapínat, v kódu lze vyhledávat a nahrazovat.

Implementováno na tomto webu.

**WP Editor**
„http://wpeditor.net/“:http://wpeditor.net/
„http://wordpress.org/plugins/wp-editor/“:http://wordpress.org/plugins/wp-editor/

WP Editor is a plugin for WordPress that replaces the default plugin and theme editors as well as the page/post editor. Using integrations with CodeMirror and FancyBox to create a feature rich environment, WP Editor completely reworks the default WordPress file editing capabilities. Using Asynchronous Javascript and XML (AJAX) to retrieve files and folders, WP Editor sets a new standard for speed and reliability.