Práce s formáty příspěvků

Post Formats are not the same as Custom Post Types. WordPress has five major default Post Types (Post, Page, Attachment, Revision and Nav Menu) and in the release of WordPress 3.0, we were given the ability to register our own types, e.g. Podcast, Book, Gallery etc. These new types appear separately within WordPress admin panel and are independent “channels” of content.

In contrast Post Formats are applied to the Post Post Type and add an additional piece of information that can then be used for formatting on a per post basis.

„Více »“:http://www.netmagazine.com/features/wordpress-post-formats-made-easy

Nastavení úrovně přístupu v pluginech

Almost every plugin needs to have at least one page in the admin area to let users customize how the plugin is used. In order to do this, you need to add your own administration menu items. There are a bunch of WordPress functions which let you do this:

/—code php
// add top level menu
add_menu_page(page_title, menu_title, capability, handle, [function], [icon_url]);

// add sub-menu pages
add_submenu_page(parent, page_title, menu_title, capability, file/handle, [function]);

// add Options sub-menu
add_options_page(page_title, menu_title, capability, handle, [function]);

// add Management sub-menu
add_management_page(page_title, menu_title, capability, handle, [function]);

// add Pages sub-menu
add_pages_page( page_title, menu_title, capability, handle, [function]);

// add Posts sub-menu
add_posts_page( page_title, menu_title, capability, handle, [function]);

// add Appearances sub-menu
add_theme_page( page_title, menu_title, capability, handle, [function]);
\—

**Více informací viz**
„Ultimate Guide to Roles and Capabilities“:http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/

Co dělat, když selže automatická aktualizace WP

After initiating the auto-update of the WordPress core (say, from 3.1.0 to 3.1.1), the “Update WordPress” screen will begin displaying the status of each step, beginning with these messages:

*Downloading update from http://wordpress.org/wordpress-3.1.1.zip…
Unpacking the update…
Verifying the unpacked files…
Installing the latest version…
Couldn’t copy file…
Installation failed*

The status message that appears just before “Installation Failed” explains what WordPress thinks is the issue, but there are cases where things go wrong and no messages are displayed. In either case, the user can get locked out of the site. When this happens, trying to load any of your pages – admin, blog, login, etc. – gets you the nothing but the WordPress maintenance page:

*Briefly unavailable for scheduled maintenance.
Check back in a minute.*

Very frustrating, and very difficult to fix things when you can’t log in to Admin. Fortunately, you don’t need Admin to fix it and get back in. Just FTP your way to the root directory and delete the **.maintenance** file. The name begins with a dot, so if you don’t see it using your FTP program, try logging into your server’s control panel and using the file manager to find and delete.

Zdroj: „http://digwp.com/2011/04/wordpress-auto-updates/“:http://digwp.com/2011/04/wordpress-auto-updates/

Překlad počtu komentářů

Určitě jste se s tím setkali. Po projití desítek webů s šablonami konečně naleznete takovou, která je natolik levná, že kvůli ní nemusíte posílat svoje poslední spodky na aukro a zároveň se jeví natolik hezky, že se za ní nemusíte ani trochu stydět. Je samozřejmě v angličtině a na nějakou vícejazyčnost vám z vysoka kašle. Ručně tedy upravujete šablonu, řádek po řádce se snažíte přeložit každé anglické slovíčko. Ale ejhle, jakmile narazíte na komentáře, jsou na ně vaše překladatelné schopnosti krátké. Čeština je natolik vymyšlená, že potřebujete hned čtyři verze – žádné komentáře, 1 komentář, 2-4 komentáře a 5 a více komentářů. Šablona vám ale nabízí jen tři možnosti (viz. níže), co tedy dál?

comments_number('Add Comment »','1 Comment »','% Comments »');

Tímto kódem jsou komentáře obvykle vkládány. Zápis se ale může lišit šablonu od šablonu od šablony, ale po chvíli hledání byste ho měli být schopni najít. Abychom se skamarádili s češtinou, tak vytvoříme vlastní funkci, která bude naše komentáře vkládat. Tu vložíme do souboru functions.php, jež je standardní součástí všech šablon.

function pocetKomentaru(){
	$pocetKomentaru = get_comments_number();
	if(comments_open()){
		if($pocetKomentaru == 0) $komentText = "Žádné komentáře";
		elseif($pocetKomentaru == 1) $komentText = "1 komentář";
		elseif($pocetKomentaru < 5) $komentText = $pocetKomentaru . " komentáře";
		else $komentText = $pocetKomentaru . " komentářů";
		return "<a href='" . get_comments_link() ."'>". $komentText."</a>";
		}
	else return "Komentáře byly vypnuty";
	}

Co se ve funkci děje? Nejdřív zjistíme počet komentářů u příspěvku, slušně se WordPressu zeptáme jestli jsou komentáře povolené a následně podle počtu vrátíme příslušný text. Radujme se a slavme, naše funkce je hotová a plně použitelná. Do kódu šablony stačí vložit:

echo pocetKomentaru();

a komentáře se již zobrazují hezky česky.

Integrování obsahu blogu na Facebook

**Add Link to Facebook**
„http://wordpress.org/extend/plugins/add-link-to-facebook/“:http://wordpress.org/extend/plugins/add-link-to-facebook/

Automatically add links to posts that are being published to your Facebook wall, pages or groups. Simple one time setup and forget. The way links appear on Facebook can be customized. This plugin comes with full support.

The link title will be the post title. The link description will be the excerpt, or part of the post text if there is none. It is possible to configure a link image (WordPress icon, first image in the media library or in the text, featured image or custom image) or you can let Facebook select one automatically. It is possible to exclude individual post links from being added to your wall, pages or groups by ticking a check box just above the publish button.

**Facebook Tab Manager**
„http://wordpress.org/extend/plugins/facebook-tab-manager/“:http://wordpress.org/extend/plugins/facebook-tab-manager/

Makes WordPress function as an editor for tabs you can embed in a Facebook page for your business, campaign, or organization.
The Facebook Tab Manager allows you to create landing pages and other types of content to be displayed within Facebook, particularly within the tabs that appear on Facebook business pages and pages for other types of organizations. This provides a way of putting more interesting layouts and functionality into your Facebook pages, without the need to get too deep into fancy programming.

The Facebook Tab Manager was specifically designed to take advantage of a recent Facebook page redesign that added support for iframe tabs on Facebook pages. Optionally, you can now also specify content to be displayed on an associated canvas page.

Tab content can include most any WordPress content, including output from Shortcodes and other plugin functions.

**Návod:**
„http://wpmu.org/how-to-create-a-custom-facebook-page-for-your-band-or-business-using-wordpress/“:http://wpmu.org/how-to-create-a-custom-facebook-page-for-your-band-or-business-using-wordpress/

*Alternativa*

**WPBook**
„http://wordpress.org/extend/plugins/wpbook/“:http://wordpress.org/extend/plugins/wpbook/
„http://wpbook.net/“:http://wpbook.net/

WPBook is a plugin for integrating WordPress and Facebook. It provides robust functionality, including:

– Support for a view of your WordPress blog as a Facebook application, including full pages and posts, with embedded media. This view is highly customizable, with custom headers/footers for each post, share links, and links to each post on the external WordPress blog.
– Support for comments posted by users within that Facebook application view; these are treated as native WordPress comments.
– Tabs for Facebook Pages. Tab view can include full posts but strips out tags that Facebook does not allow (embedded videos, iframes).
– Support for posting excerpts to Facebook wall (on individual profile and/or Page) with urls pointing to either the external blog permalink or to the Facebook application view.
– Support for importing to WordPress comments made against excerpts posted on Facebook walls.
– Facebook Avatar support for gravatars

**The Complete Guide to Optimizing Your WordPress Site for Sharing on Facebook**
„http://wpmu.org/the-complete-guide-to-optimizing-your-wordpress-site-for-sharing-on-facebook/“:http://wpmu.org/the-complete-guide-to-optimizing-your-wordpress-site-for-sharing-on-facebook/

Umístění uživatelských funkcí do pluginu

Standardní umístění uživatelských funkcí je v souboru *functions.php*.
Nešikovná na tomto postupu je skutečnost, že jsou pak vaše funkce vázány pouze na danou šablonu vzhledu a pro každou jinou šablonu je musíte do *functions.php* zkopírovat. Šikovnější metoda, umožňující jejich snadnou přenositelnost nezávisle na šablonách vzhledu, je proto umístění těchto funkcí do *pluginu*.

Vytvoříme si soubor *s u* s následujícím kódem:

/—code php

\—

Soubor *my-custom-functions.php* umístíme do adresáře */wp-content/mu-plugins/* (podadresář */mu-plugins* musíme nejprve vytvořit). Veškeré pluginy umístěné v tomto podadresáři se spouští automaticky (mu = must use), není je tedy třeba aktivovat (a nelze je ani deaktivovat či odinstalovat, v seznamu pluginů se zobrazují bez těchto možností).

Chcete-li mít možnost plugin s funkcemi standardně aktivovat, vložíte soubor *my-custom-functions.php* jako každý jiný plugin do adresáře */wp-content/plugins/*.

„Zdroj: Creating a custom functions plugin for end users »“:http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users

„How to create your own WordPress functionality plugin »“:http://wpcandy.com/teaches/how-to-create-a-functionality-plugin

Shortcode pro přímé zobrazení PDF souboru

Just open *functions.php* file and put following code in that file.

/—code php
function pdflink($attr, $content) {
return ‚‚.$content.‘‚;
}
add_shortcode(‚pdf‘, ‚pdflink‘);
\—

Upload the PDF file to your wordpress and then get the path of PDF file and then put above lines in article.
For showing link of PDF file in article or post you need add the following lines in the article.

/—code php
[pdf href=“http://yoursite.com/linktoyour/file.pdf“]View PDF[/pdf]
\—

If you does not want to create PDF link in your site and you want to show the pdf doc in your site then use following code.

/—code php
function pdfshow($attr, $content) {
return ‚‚;
}
add_shortcode(‚pdfshow‘, ‚pdfshow‘);
\—

For showing the PDF file in article or post you need add the following lines in the article.

/—code php
[pdfshow href=“http://yoursite.com/linktoyour/file.pdf“]View PDF[/pdf]
\—

„Zdroj »“:http://wordpressapi.com/2011/01/18/show-pdf-file-wordpress-blog-site/

Přiřazení stejného obrázku více příspěvkům (opakované použití)

If you use the library and use a lot of pictures in the posts, the following small link in the library will surely help you. Thus, images can be easily reused. A link will be created so you can access the image directly and there is no need to upload the image again to your new post.

[* http://wpengineer.com/wp-content/uploads/medialibrary3.png 645×316 *]

/—code php
function upload_columns($columns) {
unset($columns[‚parent‘]);
$columns[‚better_parent‘] = __( ‚Parent‘ );
return $columns;
}

function media_custom_columns($column_name, $id) {
$post = get_post($id);

if ( $column_name != ‚better_parent‘ )
return;

if ( $post->post_parent > 0 ) {
if ( get_post($post->post_parent) )
$title = _draft_or_post_title($post->post_parent);
?>

Jak přidat Facebook tlačítko „Líbí se mi“

**Like**
„http://wordpress.org/extend/plugins/like/“:http://wordpress.org/extend/plugins/like/

The Facebook Like Button Widget adds a ‚Like‘ button to your WordPress blog posts. It uses the new Facebook Like button released on Apr. 21st 2010.

*Alternativy*

**Facebook Likes You!**
„http://wordpress.org/extend/plugins/facebook-likes-you/“:http://wordpress.org/extend/plugins/facebook-likes-you/

Facebook Likes You! is simple plugin which makes it easy to add Facebook Like button and widgetable Like box. K dispozici i v české jazykové verzi.

**WordPress Facebook Like Plugin**
„http://wordpress.org/extend/plugins/wordpress-facebook-like-plugin/“:http://wordpress.org/extend/plugins/wordpress-facebook-like-plugin/

Add a Facebook „Like“ Button to your blog posts and increase your visitor engagement instantly! This plugin adds a simple and easy to use Facebook Like functionality with admin options to change the location of Facebook Like button, font, show faces, use the box with count as well as other cool and useful options.

**Bez pluginu do šablony**
„http://duben.org/wordpress/pridavame-facebookove-tlacitko-to-se-mi-libi-do-wordpressu“:http://duben.org/wordpress/pridavame-facebookove-tlacitko-to-se-mi-libi-do-wordpressu

/—code php