{"id":2914,"date":"2016-04-30T19:35:15","date_gmt":"2016-04-30T19:35:15","guid":{"rendered":"http:\/\/musilda.cz\/?p=2914"},"modified":"2016-04-30T19:35:15","modified_gmt":"2016-04-30T19:35:15","slug":"zmena-stranka-muj-ucet-ve-woocommerce-2-6","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/zmena-stranka-muj-ucet-ve-woocommerce-2-6\/","title":{"rendered":"Zm\u011bna str\u00e1nky M\u016fj \u00fa\u010det ve WooCommerce 2.6"},"content":{"rendered":"\n

Nov\u00e1 WooCommerce p\u0159inese n\u011bkolik zm\u011bn a mezi nimi i \u00fapravu vzhledu str\u00e1nky m\u016fj \u00fa\u010det. Aktualizace umo\u017en\u00ed developer\u016fm \u0161ablon a plugin\u016f, vytv\u00e1\u0159et vlastn\u00ed podstr\u00e1nky \u00fa\u010dtu z\u00e1kazn\u00edka.<\/p>\n\n\n\n

Jen pro p\u0159ipomenut\u00ed, na str\u00e1nce m\u016fj \u00fa\u010det, m\u016f\u017ee z\u00e1kazn\u00edk vid\u011bt a prohl\u00ed\u017eet sv\u00e9 objedn\u00e1vky, soubory ke sta\u017een\u00ed, upravovat sv\u00e9 \u00fadaje.<\/p>\n\n\n\n

V aktu\u00e1ln\u00ed verzi je na ka\u017ed\u00e9 podstr\u00e1nce pouze obsah, na rozd\u00edl od nov\u00e9 verze, kde je na lev\u00e9 stran\u011b navigace (taby).<\/p>\n\n\n

\n
\"my-account\"<\/a><\/figure><\/div>\n\n\n

D\u00edky tomu, je mo\u017en\u00e9 p\u0159id\u00e1vat dal\u0161\u00ed taby a p\u0159ehledn\u011b roz\u0161\u00ed\u0159it obsah z\u00e1kaznick\u00e9ho \u00fa\u010dtu.<\/p>\n\n\n\n

Pomoc\u00ed jednoduch\u00e9 t\u0159\u00eddy, vytvo\u0159\u00edte bez probl\u00e9mu, novou str\u00e1nku:<\/p>\n\n\n\n

class My_Custom_My_Account_Endpoint {\n \/**\n * Custom endpoint name.\n *\n * @var string\n *\/\n public static $endpoint = 'novy-tab';\n \/**\n * Plugin actions.\n *\/\n public function __construct() {\n \/\/ Actions used to insert a new endpoint in the WordPress.\n add_action( 'init', array( $this, 'add_endpoints' ) );\n add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );\n \/\/ Change the My Accout page title.\n add_filter( 'the_title', array( $this, 'endpoint_title' ) );\n \/\/ Insering your new tab\/page into the My Account page.\n add_filter( 'woocommerce_account_menu_items', array( $this, 'new_menu_items' ) );\n add_action( 'woocommerce_account_' . self::$endpoint . '_endpoint', array( $this, 'endpoint_content' ) );\n }\n \/**\n * Register new endpoint to use inside My Account page.\n *\n * @see https:\/\/developer.wordpress.org\/reference\/functions\/add_rewrite_endpoint\/\n *\/\n public function add_endpoints() {\n add_rewrite_endpoint( self::$endpoint, EP_ROOT | EP_PAGES );\n }\n \/**\n * Add new query var.\n *\n * @param array $vars\n * @return array\n *\/\n public function add_query_vars( $vars ) {\n $vars[] = self::$endpoint;\n return $vars;\n }\n \/**\n * Set endpoint title.\n *\n * @param string $title\n * @return string\n *\/\n public function endpoint_title( $title ) {\n global $wp_query;\n $is_endpoint = isset( $wp_query->query_vars[ self::$endpoint ] );\n if ( $is_endpoint && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) {\n \/\/ New page title.\n $title = __( 'Nov\u00fd tab', 'woocommerce' );\n remove_filter( 'the_title', array( $this, 'endpoint_title' ) );\n }\n return $title;\n }\n \/**\n * Insert the new endpoint into the My Account menu.\n *\n * @param array $items\n * @return array\n *\/\n public function new_menu_items( $items ) {\n \/\/ Remove the logout menu item.\n $logout = $items['customer-logout'];\n unset( $items['customer-logout'] );\n \/\/ Insert your custom endpoint.\n $items[ self::$endpoint ] = __( 'Nov\u00fd tab', 'woocommerce' );\n \/\/ Insert back the logout item.\n $items['customer-logout'] = $logout;\n return $items;\n }\n \/**\n * Endpoint HTML content.\n *\/\n public function endpoint_content() {\n wc_get_template( 'myaccount\/navigation.php' ); ?>\n\n<div class=\"woocommerce-MyAccount-content\">\n\n<h2>Nov\u00fd tab<\/h2>\n <p>Html obsah nov\u00e9 str\u00e1nky z\u00e1kaznick\u00e9ho \u00fa\u010dtu.<\/p>\n\n<\/div>\n\n<?php\n }\n \/**\n * Plugin install action.\n * Flush rewrite rules to make our custom endpoint available.\n *\/\n public static function install() {\n flush_rewrite_rules();\n }\n}\nnew My_Custom_My_Account_Endpoint();\n\nregister_activation_hook( __FILE__, array( 'My_Custom_My_Account_Endpoint', 'install' ) );<\/pre>\n\n\n\n

Po vytvo\u0159en\u00ed t\u0159\u00eddy, je nutn\u00e9 p\u0159eulo\u017eit permalinky, jinak bude odkaz vracet 404.<\/p>\n\n\n

\n
\"novy-tab\"<\/a><\/figure><\/div>\n\n\n

Tato novinka ve WooCommerce je opravdu p\u0159\u00ednosn\u00e1 a ji\u017e nyn\u00ed vid\u00edm r\u016fzn\u00e9 mo\u017enosti vyu\u017eit\u00ed.<\/p>\n","protected":false},"excerpt":{"rendered":"

Nov\u00e1 WooCommerce p\u0159inese n\u011bkolik zm\u011bn a mezi nimi i \u00fapravu vzhledu str\u00e1nky m\u016fj \u00fa\u010det. Aktualizace umo\u017en\u00ed developer\u016fm \u0161ablon a plugin\u016f, vytv\u00e1\u0159et vlastn\u00ed podstr\u00e1nky \u00fa\u010dtu z\u00e1kazn\u00edka. Jen pro p\u0159ipomenut\u00ed, na str\u00e1nce m\u016fj \u00fa\u010det, m\u016f\u017ee z\u00e1kazn\u00edk vid\u011bt a prohl\u00ed\u017eet sv\u00e9 objedn\u00e1vky, soubory ke sta\u017een\u00ed, upravovat sv\u00e9 \u00fadaje. V aktu\u00e1ln\u00ed verzi je na ka\u017ed\u00e9 podstr\u00e1nce pouze obsah, na<\/p>\n","protected":false},"author":1,"featured_media":8732,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[427],"class_list":["post-2914","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce","tag-woocommerce-2-6"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2914"}],"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=2914"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2914\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8732"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}