{"id":3156,"date":"2016-10-08T15:56:53","date_gmt":"2016-10-08T15:56:53","guid":{"rendered":"http:\/\/musilda.cz\/?p=3156"},"modified":"2016-10-08T15:56:53","modified_gmt":"2016-10-08T15:56:53","slug":"automaticke-prepnuti-sablony-mobilni-zarizeni","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/automaticke-prepnuti-sablony-mobilni-zarizeni\/","title":{"rendered":"Automatick\u00e9 p\u0159epnut\u00ed \u0161ablony pro mobiln\u00ed za\u0159\u00edzen\u00ed"},"content":{"rendered":"

Rychlost na\u010d\u00edt\u00e1n\u00ed webov\u00e9 str\u00e1nky na mobiln\u00edm za\u0159\u00edzen\u00ed, je dramaticky odli\u0161n\u00e1, od desktopu. Proto m\u016f\u017ee b\u00fdt vhodn\u00e9, zm\u011bnit pro mobiln\u00ed za\u0159\u00edzen\u00ed celou \u0161ablonu, m\u00edsto pou\u017e\u00edv\u00e1n\u00ed jedn\u00e9, responzivn\u00ed.<\/p>\n

Nejprve si vytvo\u0159\u00edme funkci, pomoc\u00ed kter\u00e9 budeme detekovat za\u0159\u00edzen\u00ed:<\/p>\n

\nfunction 32090_detect_mobile() {\n    return preg_match(\"\/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\\.browser|up\\.link|webos|wos)\/i\", $_SERVER[\"HTTP_USER_AGENT\"]);\n}\n<\/pre>\n

N\u00e1sledn\u011b sta\u010d\u00ed jen ur\u010dit, jak\u00e1 \u0161ablona bude aktivn\u00ed a vlo\u017eit hodnotu do filtru. Funkce bude vracet n\u00e1zev slo\u017eky p\u0159\u00edslu\u0161n\u00e9 \u0161ablony.<\/p>\n

\nfunction 32090swith_theme() {\n    if(32090_detect_mobile()){\n        return 'mobile';\n    } else {\n        return 'non-mobile';\n    }\n}\nadd_filter( 'stylesheet', '32090swith_theme' );\nadd_filter( 'template', '32090swith_theme' );\n<\/pre>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

Rychlost na\u010d\u00edt\u00e1n\u00ed webov\u00e9 str\u00e1nky na mobiln\u00edm za\u0159\u00edzen\u00ed, je dramaticky odli\u0161n\u00e1, od desktopu. Proto m\u016f\u017ee b\u00fdt vhodn\u00e9, zm\u011bnit pro mobiln\u00ed za\u0159\u00edzen\u00ed celou \u0161ablonu, m\u00edsto pou\u017e\u00edv\u00e1n\u00ed jedn\u00e9, responzivn\u00ed. Nejprve si vytvo\u0159\u00edme funkci, pomoc\u00ed kter\u00e9 budeme detekovat za\u0159\u00edzen\u00ed: function 32090_detect_mobile() { return preg_match(„\/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\\.browser|up\\.link|webos|wos)\/i“, $_SERVER[„HTTP_USER_AGENT“]); } N\u00e1sledn\u011b sta\u010d\u00ed jen ur\u010dit, jak\u00e1 \u0161ablona bude aktivn\u00ed a vlo\u017eit hodnotu do filtru.<\/p>\n","protected":false},"author":1,"featured_media":2635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[305],"class_list":["post-3156","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety","tag-prepnuti-sablony"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/3156"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=3156"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/3156\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2635"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=3156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=3156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=3156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}