Tutorial do WordPress: Ahoana no Mamorona Torohevitra Mahaliana Flash Flip

Fanamarihana: Tsy manohana ity plugin WP é inyony isika raha tsy manoratra ho antsika ny mpanoratra amin’izao fotoana izao.


Manomboka androany, is-kerinandro isika dia hanolotra lesona mahatalanjona coding, mampianatra anao ny fomba fanaovana zavatra manokana amin’ny fampiasana WordPress, and amin’ny fototra mankany amin’ny fandrosoana. Androany dia hamorona plugin izahay (mba hahalalanareo ny dingana fototra amin’izany) mba hamoronana galerie "virar a página", mampiasa JS.

Azoko an-tsaina fa nahita iray tamin’ireo tao amin’ny tranonkalanao ianao tamin’ny voalohany, saingy nampiasana flash izy ireny, izay tsy misy intsony izany (mbola manan-danja ihany izy io, fa tsy ny safidy tsara ity karazana zavatra ity intsony).

Ny fanalahidy fototra dia hamorona vaova karazana galeria mifototra amin’ny sary vitsivitsy sy ny habeny, amin’ny alalan’ny codecode.

Andao atomboka dieny izao!

Fecho eclair & Fametrahana

Ny fomba tsara indrindra hijerena azy amin’ny asa dia mametraka azy manokana. Ianao dia afaka faça o download aqui. Mametraka sy manantona ny plugin, amiz’ay ny zavatra tokony hataonao dia ny manampy ny codecode amin’ny pejy, toy ity:

[ids do flip_book = "78 79 78 79 79 78 78 79 79" width = "78" height = "300" display = "em dobro"]

Visualização rápida

Ary izao no vokatra mety ho azonao:

Efeito Flipbook

Fa inona kosa ny majika mainty tonga ao? Eny ary, tena tsotra tsotra izao. Andao hianatra ny fomba hamoronana zavatra toy izany.

O cabeçalho

Voalohany indrindra ianao dia mila mamorona tranokala vaovao sy vaovao iray vaovao. Amin’ity fotoana ity mety hahagaga raha manana tontolo iainana fitsapana ianao, noho izany dia afaka mamotika sy mamandrika zavatra ianao.

Você pode encontrar todos os dias tokony hanana anarana tsotra sy miavaka, ka tsy hifanohitra amin’ny plugins efa misy. Avy e o ny votoatin’ny fotodrafitrasa misy anay dia toy izao:

/ * Nome do plug-in: Galeria da FlipBook Descrição: Mamorona kaody fohy ho an’ny flipbook galleries. Versão: 1.0 Mpanoratra: Blog de receitas da Web Idioma: GPL2 * /

Tena tsotra, hein? Raha vao mamorona it rakitra ity ianao dia hahita ny plugin anao ao amin’ny lisitry ny WP admin> Plugins, ary afaka manaisotra azy ianao (saingy raha manana izany votoaty ao amin’ny rakitrao ianao dia tsy hanova betsaka ny tranonkalanao).

Chamando scripts

Amin’izao fotoana isiza dia mila ampidirina zava-dehibe sasany qualquer ivelany. Ireo antontan-taratasy ilaina ho an’ny fandefasana fototra dia:

  • jQuery (1.9 +)
  • Script Turn.js
  • Hanova fomba fanao fototra

Raha ampidirina fotsiny ny script sy ny tags de estilo dia misy olana sasany. Ohatra, ny fiantsoana jQuery indroa dia mety hamaky ny tranonkalanao. WordPress ihany koa dia tsy "hahalala" fa efa namoradas ireo zavatra ireo, ka raha misy plugin hafa miantso turn.js indray fomba hafa dia handrava ny tranokalanao.

Izany no antony tokony hampiasantsika mandrakariva ny wp_enqueue_script sy ny wp_enqueue_style asa. Ity ny fototra ampiasaina:

função plugin_scripts () {wp_enqueue_script (‘jquery’); wp_enqueue_script (‘miova’, plugins_url (‘js / turn.js’, __FILE__), matriz (‘jquery’), ‘1.3’, diso); wp_enqueue_style (‘turnCSS’, plugins_url (‘css / style.css’, __FILE__), diso, ‘1.3’, ‘todos’); }

Miantso ireo zavatra hafahafa amin’ny 3 izahay, dia ireto:

  • Fiantsoana singa efa misy: jQuery – Tsy mila mametraka safidy marobe isika raha fantatsika fa ny WordPress day ora mandramaka ity script ity, dia milaza azy fotsiny ise hoe: "Cara, ity script ity dia tokony eto raha tsy ny code no tsy asa "
  • Mamorona sora-tanana vaovao – ianao dia tokony handalo toetra sasantsasy toy ny anarana, ny toerana misy ny rakitra, ny zavatra ilaina (amizade ami’ity raharaha ity dia mandefa jQuery), versão, ary raha ampidirina ao amin’ny rodapé (false) = cabeçalho, verdadeiro = rodapé)
  • Mamorona fomba vaovao – Mafy be toy ny teo aloha, ary misy fahasamihafana kely amin’ny toetra farany, izay milaza fa ny media dia manondro ity style ity raha toa ka

Agora, como criar um código zava-tokony, reerfa os scripts gigantes e instala um código misy no código hafa e cria um plugin io io. Izany indrindra no hamaritana raha ny lohateninao dia hantsoina amin’ny lohateny no rodapé.

Amin’ny tranga misy antsika, misy sora-tanana maro hafa hananganana galeria raha vao nooforonina ny HTML, ampiana ao amin’ny vatany izany. Izany no mahatonga antsika mametraka ity script ity e o amin’ny loha, raha tsy hoe mbola misy ny fehezan-dalàna antsoina hoe "virar".

Aorian’ity code-tsara ity dia ilaintsika n miteny WordPress mba hamenoana azy ireo amin’ny sora-baventy, ny hetsika "wp_enqueue_scripts" dia hanao izany:

add_action (‘wp_enqueue_scripts’, ‘plugin_scripts’);

Ny Shortcode

Andeha isika hanomboka amin’ny hetsika mba hamoronana ny codecode. Tsotra tsotra izao, mila ampidirinao fotsiny ny fandefasam-peo fohy, ary ny asa izay hovonoina:

add_shortcode ( "flip_book", "create_flip_book");

Ankehitriny dia mila mamorona ny asantsika isy ary mahazo ny toetrantsika. De qualquer maneira, qualquer tipo de dia é dia, ou dia, dia midika de mila mamorona fitsipika fototra ho azy ireo isika. Afaka mamorona betsaka isha raha toa ka misy ny fitsapana raha tsy misy ny toetra, fa iray amin’ireo tranga izay mety tsara kokoa noho ny mahazatra raha antsoina.

Ny hetsika Ternergy dia tsara raha to qualquer fanambarana mivantana amin’ny sandan’ny fari-dalany. Raha manaraka ity rafitra ity:

Variáveis ​​$ = (CONDITION)? "MAHALALA NY FAHAMARINANA ISIKA": "MAHALALA FA TSY MANAIKY NY FITIAVANA";

Azonao atao ny mahita azy ireo e o amin’ny sehatra voalohany amin’ny asantsika:

função create_flip_book ($ attr) {// Manomana IDs de iroo mba handraisana array $ ” ” = explode ("", $ attr [‘ids’]); // modo de exibição $ array [‘display’] = foana ($ attr [‘display’])? "tokana": $ attr [‘display’]; // marim-pejy // malalaka $ array [‘width’] = foana ($ attr [‘width’])? 400: $ attr [‘width’]; // height $ array [‘haavo’] = foana ($ attr [‘height’])? 300: $ attr [‘haavo’]; // sysy ny HTML sisa amin’ny code dia mandeha eto}

Avy e o dia mila mamorona em HTML izahay, ny fiantsoana fototra ho an’ny sary. Ny hevi-dehibe iray lehibe eto dia ny fanitsiana ny habeny raha mampiasa ny magazine (tokony ho 2x ny sakany satria manana sary 2 fa tsy iray):

<? php if ($ array [‘display’] == "em dobro") {$ array [‘width’] = $ array [‘width’] * 2; } // HTML, JS sy Black Magic?> <? Php para ($ i = 0; $ i < div> <? php echo wp_get_attachment_image ($ array [‘ids’] [$ i], ‘feno’); Raha ($ array [‘display’] == "tokana") {?> <? = "". ($ i + 1)? / /? aho, + 1)?> / <? Eco "" .sizeof ($ array [‘ids’]); jQuery ("# Flipbook") , autoCenter: true, exibição: ‘<? php echo $ array [‘display’]; php echo $ array [‘largura’]; ?> ‘, // pejy tokana na pejy fanaparitahana: marina, gradientes :! jQuery.isTouch,});

Inona ny hevitrao?

Azonao aty mamaky sy manova izany araka izay irinao, manampy iroo safidy maromaro (jereo ny ohatra tsara azon’izy ireo hahazoana fitaomam-panahy bebe kokoa), manitsy izay tsy miasa ho anao, mampifandray izay.

Manana hevitra WordPress tem mba te hianatra bebe kokoa? Angamba zavatra tianao hianaranao hatao? Ampahafantaro pode dizer que todos são alane’ny fanehoan-kevitra são faly izahay hampiditra izany ao amin’ny lahatsoratra manaraka!

Jeffrey Wilson Administrator
Sorry! The Author has not filled his profile.
follow me
    Like this post? Please share to your friends:
    Adblock
    detector
    map