{"_id":"54324b909afb2a080013cce0","category":{"_id":"54e9cfb4f152c50d009b49ed","project":"5431c59ea55723080068e155","pages":["568507b4f72e9e0d00e09934"],"version":"5431c59ea55723080068e158","__v":1,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-22T12:46:44.278Z","from_sync":false,"order":1,"slug":"creation","title":"Tutorial"},"user":"542ea80e6b0eb6080066c9d5","version":{"_id":"5431c59ea55723080068e158","project":"5431c59ea55723080068e155","__v":8,"createdAt":"2014-10-05T22:26:38.927Z","releaseDate":"2014-10-05T22:26:38.927Z","categories":["5431c59ea55723080068e159","54325f53f2f806080098ad37","543264b1f2f806080098ad3e","543264c8f2f806080098ad3f","543264d3f2f806080098ad40","543264f42aca39080046d81e","5435bbf15e1b20200043834d","54e9cfb4f152c50d009b49ed"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":10,"is_link":false,"parentDoc":null,"project":"5431c59ea55723080068e155","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-06T07:58:08.245Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"settings":"","try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Make the Tea Theme Options working\"\n}\n[/block]\nAs we said before:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse crewstyle\\\\TeaThemeOptions\\\\TeaThemeOptions;\\n\\n//Include composer autoload\\nrequire_once __DIR__.'/vendor/autoload.php';\\n\\n//Instanciate a new TeaThemeOptions\\n$tea = new TeaThemeOptions();\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Define what you want\"\n}\n[/block]\nSpecify your wanted components:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n//Define an example page and build menu\\n$tea->addMenu(array(\\n    'title' => __('Example page'),\\n    'name' => __('Example page'),\\n    'slug' => 'examplepage'\\n));\\n\\n//Build contents with a filter composed by `tto_template_%s_contents`\\n//replacing `%s` by the slug's page\\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\\nfunction tto_examplepage($contents)\\n{\\n\\treturn array(\\n    array(\\n      'type' => 'heading',\\n      'title' => __('Header.')\\n    ),\\n    array(\\n      'type' => 'radio',\\n      'title' => __('Fix the main menu bar to the top of the screen?'),\\n      'id' => 'header_menu_position',\\n      'default' => 'yes',\\n      'options' => array(\\n        'yes' => __('Yes'),\\n        'no' => __('No')\\n      )\\n    ),\\n    array(\\n      'type' => 'heading',\\n      'title' => __('Footer.')\\n    ),\\n    array(\\n      'type' => 'text',\\n      'title' => __('Copyright.'),\\n      'id' => 'footer_copyright',\\n      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\\n    ),\\n  );\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Build the menu\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n//Build menus\\n$tea->buildMenus();\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. All in one\"\n}\n[/block]\nHere is a complete snapshot of what you have to do. Remember to make all these modifications in your `functions.php` theme file.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nuse crewstyle\\\\TeaThemeOptions\\\\TeaThemeOptions;\\n\\n//Include composer autoload\\nrequire_once __DIR__.'/vendor/autoload.php';\\n\\n//Instanciate a new TeaThemeOptions\\n$tea = new TeaThemeOptions();\\n\\n//Define an example page and build menu\\n$tea->addMenu(array(\\n    'title' => __('Example page'),\\n    'name' => __('Example page'),\\n    'slug' => 'examplepage'\\n));\\n\\n//Build contents with a filter composed by `tto_template_%s_contents`\\n//replacing `%s` by the slug's page\\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\\nfunction tto_examplepage($contents)\\n{\\n\\treturn array(\\n    array(\\n      'type' => 'heading',\\n      'title' => __('Header.')\\n    ),\\n    array(\\n      'type' => 'radio',\\n      'title' => __('Fix the main menu bar to the top of the screen?'),\\n      'id' => 'header_menu_position',\\n      'default' => 'yes',\\n      'options' => array(\\n        'yes' => __('Yes'),\\n        'no' => __('No')\\n      )\\n    ),\\n    array(\\n      'type' => 'heading',\\n      'title' => __('Footer.')\\n    ),\\n    array(\\n      'type' => 'text',\\n      'title' => __('Copyright.'),\\n      'id' => 'footer_copyright',\\n      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\\n    ),\\n  );\\n}\\n\\n//Build menus\\n$tea->buildMenus();\",\n      \"language\": \"php\",\n      \"name\": \"functions.php\"\n    }\n  ]\n}\n[/block]\nPay attention: do not hesitate to make conditions on what you need in your backend panel versus what you need in your frontend website.","excerpt":"With a tiny example :)","slug":"create-a-custom-page","type":"basic","title":"Create a custom menu"}

Create a custom menu

With a tiny example :)

[block:api-header] { "type": "basic", "title": "1. Make the Tea Theme Options working" } [/block] As we said before: [block:code] { "codes": [ { "code": "<?php\n\nuse crewstyle\\TeaThemeOptions\\TeaThemeOptions;\n\n//Include composer autoload\nrequire_once __DIR__.'/vendor/autoload.php';\n\n//Instanciate a new TeaThemeOptions\n$tea = new TeaThemeOptions();", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "2. Define what you want" } [/block] Specify your wanted components: [block:code] { "codes": [ { "code": "<?php\n\n//Define an example page and build menu\n$tea->addMenu(array(\n 'title' => __('Example page'),\n 'name' => __('Example page'),\n 'slug' => 'examplepage'\n));\n\n//Build contents with a filter composed by `tto_template_%s_contents`\n//replacing `%s` by the slug's page\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\nfunction tto_examplepage($contents)\n{\n\treturn array(\n array(\n 'type' => 'heading',\n 'title' => __('Header.')\n ),\n array(\n 'type' => 'radio',\n 'title' => __('Fix the main menu bar to the top of the screen?'),\n 'id' => 'header_menu_position',\n 'default' => 'yes',\n 'options' => array(\n 'yes' => __('Yes'),\n 'no' => __('No')\n )\n ),\n array(\n 'type' => 'heading',\n 'title' => __('Footer.')\n ),\n array(\n 'type' => 'text',\n 'title' => __('Copyright.'),\n 'id' => 'footer_copyright',\n 'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\n ),\n );\n}", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Build the menu" } [/block] [block:code] { "codes": [ { "code": "<?php\n\n//Build menus\n$tea->buildMenus();", "language": "php" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. All in one" } [/block] Here is a complete snapshot of what you have to do. Remember to make all these modifications in your `functions.php` theme file. [block:code] { "codes": [ { "code": "<?php\n\nuse crewstyle\\TeaThemeOptions\\TeaThemeOptions;\n\n//Include composer autoload\nrequire_once __DIR__.'/vendor/autoload.php';\n\n//Instanciate a new TeaThemeOptions\n$tea = new TeaThemeOptions();\n\n//Define an example page and build menu\n$tea->addMenu(array(\n 'title' => __('Example page'),\n 'name' => __('Example page'),\n 'slug' => 'examplepage'\n));\n\n//Build contents with a filter composed by `tto_template_%s_contents`\n//replacing `%s` by the slug's page\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\nfunction tto_examplepage($contents)\n{\n\treturn array(\n array(\n 'type' => 'heading',\n 'title' => __('Header.')\n ),\n array(\n 'type' => 'radio',\n 'title' => __('Fix the main menu bar to the top of the screen?'),\n 'id' => 'header_menu_position',\n 'default' => 'yes',\n 'options' => array(\n 'yes' => __('Yes'),\n 'no' => __('No')\n )\n ),\n array(\n 'type' => 'heading',\n 'title' => __('Footer.')\n ),\n array(\n 'type' => 'text',\n 'title' => __('Copyright.'),\n 'id' => 'footer_copyright',\n 'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\n ),\n );\n}\n\n//Build menus\n$tea->buildMenus();", "language": "php", "name": "functions.php" } ] } [/block] Pay attention: do not hesitate to make conditions on what you need in your backend panel versus what you need in your frontend website.