LilyPond → WordPress: update your sheets easy
Sorry, but this post is not available in English yet
around the essentials…
Sorry, but this post is not available in English yet
Коментуючи одну з попередніх публікацій, Юрко спонукав таки мене написати короткий код (shortcode) для вставляння програвача з переліком всіх долучених до публікації аудіофрагментів.
Тобто, я хочу до даної публікації доліпити кілька mp3 файлів, підписати їх і у публікації використати якийсь короткий код… Словом, нижче.
У файлі functions.php
дописуємо таке:
function get_player( $post ) { $urls = array(); $titles = array(); $artists = array(); $attachments = get_children( array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'audio/mpeg', 'order_by' => 'menu_order', 'order' => 'ASC')); if( $attachments ) { foreach ( $attachments as $att_id => $att ) { // allow non-latin chars in file names: $url = wp_get_attachment_url($att_id); $url = preg_replace('#(.*/)([^/]*)$#e', "'\\1'.rawurlencode('\\2')", $url); $url = rawurlencode( $url ); $urls[] = $url; $title = rawurlencode( str_replace(",", ":", $att->post_title) ); $titles[] = $title; } $player_id = 'audioplayer-' . $post->ID; $player = '<p class="audioplayer_container"><div class="np-audioplayer" id="'. $player_id .'">(No Adobe Flash Player?..)</div></p>' . "\n" . '<script type="text/javascript">' . "\n" . ' AudioPlayer.embed("' . $player_id . "\", {\n" . ' soundFile: "' . implode(",", $urls) . "\" // ,\n" . ' titles: "' . implode(",", $titles) . "\"\n" . " });\n" . "</script>\n"; return $player; } return false; } function playall( $atts ) { global $post; return get_player($post); } add_shortcode( "playall", "playall" ); |
Після цього ми можемо у тілі повідомлення написати [playall]
. Ось, для прикладу, я причепив до цього повідомлення три фрагменти:
Всі фрагменти я підписав через відповідний інтерфейс вордпреса, їх порядок також виставив саме там. До речі, якщо закоментувати titles: ...
, audioplayer візьме відповідне поле з mp3 id tag
. У цьому конкретному випадку він звідти бере інформацію для artists
(«Neville Marriner – Academy of St Martin in the Fields» у даному випадку).
Чому двічі rawurlencode
? Не знаю :-)
До речі, у налаштуваннях вордпресівського Audio Player’а треба вимкнути «криптування» посилань.
I wrote a small plugin for WordPress, which can search for specified strings (as regular expressions) in posts and pages and replace them with something else.
Just take a look:
Typed as PARDON
, you see as:
Typed as , you see as:
Under debugging
You can download re.place
plugin here.
And here is an official re.place
plugin page .
Finished translation for NextGEN Gallery interface.
Great (*great*) plugin for image gallery and albums of galleries creation, can «associate» posts with images, slideshow creation etc-etc. Great plugin, very accurate :-)
Thanks, Alex!
Here is the translation (.po file) — test, comment…
I have found a great plugin for WordPress: Language Switcher.
Just one issue so far: NextGEN Gallery widget does not allow to edit its title to switch between languages.
Well, and it’s nesessary to edit theme files — replace „smth” with __(‘smth”), and «correct» language file (<lang>.po
, and converting to .mo with command msgfmt <lang>.po -o <lang>.mo
).