{"id":5011,"date":"2019-10-05T14:46:02","date_gmt":"2019-10-05T14:46:02","guid":{"rendered":"https:\/\/musilda.cz\/?p=5011"},"modified":"2019-10-05T14:46:02","modified_gmt":"2019-10-05T14:46:02","slug":"wordpress-cron-a-cron-uloha-jake-jsou-rozdily","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/wordpress-cron-a-cron-uloha-jake-jsou-rozdily\/","title":{"rendered":"WordPress Cron a Cron \u00faloha – jak\u00e9 jsou rozd\u00edly?"},"content":{"rendered":"

Ka\u017ed\u00fd, kdo vlastn\u00ed e-shop na WordPressu, se dostane do situace, kdy bude muset \u0159e\u0161it spou\u0161t\u011bn\u00ed \u00faloh v pravideln\u00e9m intervalu.<\/p>\n

Typick\u00fdm p\u0159\u00edkladem, je generov\u00e1n\u00ed XML souboru pro Google Merchants, nebo jin\u00e9 srovn\u00e1va\u010de. V souboru pot\u0159ebujete m\u00edt neust\u00e1le aktu\u00e1ln\u00ed informace o zbo\u017e\u00ed a skladu.<\/p>\n

V p\u0159\u00edpad\u011b, \u017ee v\u00e1m n\u011bkdo naprogramuje plugin, nebo jej zakoup\u00edte, m\u016f\u017eete se setkat s v\u00fdrazem „CRON“.<\/p>\n

Mus\u00edte v\u0161ak v\u011bd\u011bt, zda to je Cron, nebo WP Cron, proto\u017ee se od sebe dost li\u0161\u00ed.\u00a0<\/p>\n

\u00a0<\/p>\n\n\n

\n\nRozd\u00edly mezi Cronem a WP Cronem\n\n<\/h2>\n\n\n\n

Cron je napl\u00e1novan\u00e1 \u00faloha na va\u0161em serveru, v\u011bt\u0161inou se tedy nastavuje na hostingu, kter\u00fd m\u00e1te pro web. <\/p>\n\n\n\n

Nastaven\u00ed cron \u00falohy na va\u0161em serveru je u v\u011bt\u0161iny hosting\u016f mo\u017en\u00e9 v administraci, jako nap\u0159\u00edklad u WP Hosting.cz<\/a>, kde si nastav\u00edte url adresy, jen\u017e chcete spou\u0161t\u011bt a v jak\u00e9m intervalu.<\/p>\n\n\n\n

Screeny z nastaven\u00ed cronu:<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n
\"\"<\/figure>\n\n\n\n
\"\"<\/figure>\n\n\n\n

Jak m\u016f\u017eete vid\u011bt, server v ur\u010den\u00fdch intervalech na\u010dte url adresu a d\u00edky tomu se provedou v\u0161echny funkce, kter\u00e9 script na adrese obsahuje. <\/p>\n\n\n\n

Takto je \u0159e\u0161ena aktualizace nap\u0159\u00edklad feed\u016f pro Heur\u00e9ku u pluginu od Toret.cz. <\/p>\n\n\n\n

Oproti tomu WP Cron jsou akce a funkce, jen\u017e se prov\u00e1d\u011bj\u00ed p\u0159i na\u010d\u00edt\u00e1n\u00ed WordPressu. Nez\u00e1le\u017e\u00ed na tom, zda jste v administraci, nebo na webu, poka\u017ed\u00e9, kdy\u017e se web na\u010d\u00edt\u00e1, doch\u00e1z\u00ed ke kontrole \u00faloh pro WP Cron. <\/p>\n\n\n\n

Ty se pak zkontroluj\u00ed, zda jsou aktu\u00e1ln\u011b na\u010dasovan\u00e9 a provedou se. <\/p>\n\n\n\n

Znamen\u00e1 to, \u017ee pokud m\u00e1te web s ni\u017e\u0161\u00ed n\u00e1v\u0161t\u011bvnost\u00ed a jsou napl\u00e1nov\u00e1ny \u00falohy na p\u016flnoc, je mo\u017en\u00e9, \u017ee nebude \u017e\u00e1dn\u00e1 n\u00e1v\u0161t\u011bva a prvn\u00ed n\u00e1v\u0161t\u011bvn\u00edk to r\u00e1no prost\u011b odsk\u00e1\u010de. Web to m\u016f\u017ee v\u00fdrazn\u011b zbrzdit. Na druhou stranu, m\u00e9n\u011b n\u00e1ro\u010dn\u00e9 \u00falohy, jako jsou t\u0159eba kontroly verz\u00ed plugin\u016f, web v\u00fdrazn\u011b neomez\u00ed. <\/p>\n\n\n\n

Pou\u017eit\u00ed Cronu nebo WP Cronu je t\u0159eba promyslet, ale j\u00e1 osobn\u011b, pokud mohu, pou\u017e\u00edv\u00e1m pouze cron nastaven\u00e1 na hostingu. <\/p>\n\n\n\n

V dal\u0161\u00ed \u010d\u00e1sti \u010dl\u00e1nku si ji\u017e budeme popisovat pouze WP Cron, tak\u017ee pro zjednodu\u0161en\u00ed pou\u017e\u00edv\u00e1m n\u00e1zev Cron i pro \u00falohy WP Cronu.<\/p>\n\n\n\n

Pl\u00e1nov\u00e1n\u00ed ud\u00e1losti ve WP Cronu <\/h2>\n\n\n\n

Chov\u00e1n\u00ed WordPress Cronu se d\u00e1 rozd\u011blit do dvou typ\u016f:<\/p>\n\n\n\n