{"id":1954112,"date":"2022-09-09T07:25:14","date_gmt":"2022-09-09T11:25:14","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?post_type=post&#038;p=1954112"},"modified":"2024-08-20T11:17:25","modified_gmt":"2024-08-20T15:17:25","slug":"custom-templates-custom-hooks-and-upgrading-to-tec-6-0","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/custom-templates-custom-hooks-and-upgrading-to-tec-6-0\/","title":{"rendered":"Custom Templates, Custom Hooks, and Upgrading to TEC 6.0"},"content":{"rendered":"\n<p>So you&#8217;ve got our calendar and events templates customized and looking just the way you want. Maybe you&#8217;ve even hooked into the event query to alter what&#8217;s showing on specific pages. Then you update to the latest version of the plugin, and<em> <\/em>now there are scary errors. What happened, and how can you fix it?<\/p>\n\n<p>In The Events Calendar 6.0, we removed a number of functions and methods. These elements were previously deprecated in previous versions, as far back as TEC 4.0 (2015). If you&#8217;re using a deprecated function, your site will usually show a warning so that you can deal with the change before the element is fully removed. However, if you have a plugin or snippet that suppresses the warnings, you wouldn&#8217;t have seen anything to prompt you to prepare for the final removal of these elements. <strong>If you want to use The Events Calendar 6.0+, you&#8217;ll need to now take the time to adjust your customizations.<\/strong> <\/p>\n\n<h2 class=\"wp-block-heading\" id=\"h-custom-templates\">Custom Templates<\/h2>\n\n<p>The first step to resolving these issues is to review and decode the error message. Let&#8217;s say you get something like:<\/p>\n\n<pre class=\"wp-block-code\"><code>Fatal error: Uncaught Error: Call to undefined function tribe_events_the_notices() in \/home\/my-site\/www\/wp-content\/themes\/my-theme\/tribe-events\/single-event.php:30<\/code><\/pre>\n\n<p>That&#8217;s a bit scary, but it includes important and helpful information:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>It&#8217;s happening in the custom template as the path includes the <strong>theme<\/strong>: <code>wp-content\/<strong>themes\/my-theme<\/strong>\/tribe-events\/single-event.php<\/code><\/li>\n\n<li>The failing function is <code>tribe_events_the_notices()<\/code><\/li>\n<\/ul>\n\n<p>Next, check the <a href=\"https:\/\/theeventscalendar.com\/release-notes\/the-events-calendar\/the-events-calendar-6-0-0\/\" target=\"_blank\" rel=\"noreferrer noopener\">release notes<\/a> for the update. For an error like the above, you&#8217;ll want the <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/developer-changes-version-6-0-with-legacy-views-removal\/\" target=\"_blank\" rel=\"noreferrer noopener\">developer notes on templates<\/a>.<\/p>\n\n<p>If you search for the failing function <code>tribe_events_the_notices()<\/code>, you&#8217;ll find it under &#8220;Removed functions &amp; methods&#8221;. Next, we&#8217;ll go to the release readme file for more information.<\/p>\n\n<p class=\"has-background\" style=\"background-color:var(--global-palette8)\">For simplicity&#8217;s sake, <a href=\"https:\/\/github.com\/the-events-calendar\/the-events-calendar\/blob\/master\/readme.txt\" target=\"_blank\" rel=\"noreferrer noopener\">here&#8217;s a link to the readme on GitHub<\/a>, but it&#8217;s in the folder of our plugin &#8211; we can get to it using the plugin editor on-site, via FTP, or by downloading the plugin from wordpress.org and opening the zip file.<\/p>\n\n<p>If you search for the above function in the readme, you&#8217;ll find it deprecated in the TEC 4.0 release. Most importantly, it says:<\/p>\n\n<pre class=\"wp-block-code\"><code>Deprecated - tribe_events_the_notices() in favor of tribe_the_notices() <\/code><\/pre>\n\n<p>That means to fix it, you&#8217;ll need to change the use of <code>tribe_events_the_notices()<\/code> to<code> tribe_the_notices()<\/code> in your custom template. Once you&#8217;ve done that, the error will be resolved.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"h-hooked-functions\">Hooked Functions<\/h2>\n\n<p>If you have hooked into an event query or a template to customize your site, the error will point to the customization. For example, you might see something like this:<\/p>\n\n<pre class=\"wp-block-code\"><code>Fatal error: Uncaught Error: Call to undefined function tribe_events_the_notices() in \/Users\/stephenpage\/Sites\/tec\/dev\/themes\/twentytwentyone\/functions.php:662<\/code><\/pre>\n\n<p>In this example, we&#8217;re using the Twenty One theme, and we&#8217;ve put a filter in the theme <code>functions.php<\/code> file. There are other places it could be on your site, such as in a custom plugin, a code snippet plugin, a child theme, etc.<\/p>\n\n<p>The example customization hooks into <code>tribe_get_events_title<\/code> though it doesn&#8217;t really matter which hook we&#8217;re using just to demonstrate. Nor does it matter if it&#8217;s a filter or action hook\u2013we just need one that will fire on an events page load. We&#8217;ll also use the same example function for consistency &#8211; <code>tribe_events_the_notices()<\/code>.<\/p>\n\n<p>Say your customization looks something like this:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter(\n\t&#039;tribe_get_events_title&#039;,\n\tfunction ( $title, $depth, $context ) {\n\t\t\/\/ Let&#039;s break something :wink:\n\t\t$notices = tribe_events_the_notices();\t\treturn $title;\n\t},\n\t10,\n\t3\n);\n<\/pre><\/div>\n<p>Reviewing the error message, you can see the file is in the theme&#8217;s functions.php file, and a line number &#8211; 662. Go to line 662 in functions.php, and look for the problematic element. In our example, it&#8217;s <code>tribe_events_the_notices()<\/code> from the snippet above. <\/p>\n\n<p>Next, look for the function in the <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/developer-changes-version-6-0-with-legacy-views-removal\/\" target=\"_blank\" rel=\"noreferrer noopener\">developer notes<\/a> from the release, and then in the plugin <a href=\"http:\/\/github.com\/the-events-calendar\/the-events-calendar\/blob\/master\/readme.txt(opens in a new tab)\" target=\"_blank\" rel=\"noreferrer noopener\">readme<\/a>. The readme shows that <code>tribe_events_the_notices()<\/code> was replaced by the new<code> tribe_the_notices()<\/code>. Adjust your customization to use the new function, and the error will be resolved.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"h-dealing-with-multiple-errors\">Dealing with Multiple Errors<\/h2>\n\n<p>Quite a few functions, classes, and methods that had been deprecated in previous versions were fully removed in 6.0. If you&#8217;re running into multiple errors caused by missing elements, you may need some time to find all the issues and get your site  straightened out. <\/p>\n\n<p>We recommend that you <a href=\"https:\/\/staging.theeventscalendar.com\/knowledgebase\/k\/accessing-older-plugin-versions\/\">downgrade<\/a> to The Events Calendar 5.16.4, and then <strong>find and remove whatever was previously suppressing deprecation warnings<\/strong>. This could be a plugin or a snippet in your theme <code>functions.php<\/code>&nbsp;file. It&#8217;s important to see deprecation warnings<em> <\/em>on your site so that you can make required changes before something triggers an actual error. If you have any of our other calendar or tickets plugins, you&#8217;ll also need to downgrade those (see versions below).<\/p>\n\n<p>Once you&#8217;ve downgraded and can view deprecation warnings, you can go through the same steps described above to replace any use of deprecated functions, methods, or classes. When you have resolved all warnings both in the WordPress admin and on the site frontend, you can then confidently update back to the most recent version of The Events Calendar (6.0+) and any other plugins.<\/p>\n\n<div class=\"wp-block-group has-background\" style=\"background-color:var(--global-palette8)\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p>The following versions of our plugins are compatible with The Events Calendar 5.16.4. Be sure to downgrade any of these that you have active:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>Events Calendar Pro 5.14.4<\/li>\n\n<li>Event Tickets 5.4.4<\/li>\n\n<li>Event Tickets Plus 5.5.3<\/li>\n\n<li>Community Events 4.9.3<\/li>\n\n<li>Filter Bar 5.3.1<\/li>\n\n<li>Eventbrite Tickets 4.6.11<\/li>\n<\/ul>\n<\/div><\/div>\n\n<p><\/p>\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you&#8217;ve got our calendar and events templates customized and looking just the way you want. Maybe you&#8217;ve even hooked into the event query to alter what&#8217;s showing on specific pages. Then you update to the latest version of the plugin, and now there are scary errors. What happened, and how can you fix it?&#8230;<\/p>\n","protected":false},"author":3,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[59,136,84,93],"tags":[25,58,83],"stellar-product-taxonomy":[],"class_list":["post-1954112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing-resources","category-updating-plugins","category-theming-overview","category-errors","tag-customizations","tag-php","tag-templates"],"acf":[],"taxonomy_info":{"category":[{"value":59,"label":"PHP &amp; Functions"},{"value":136,"label":"Plugin Updates"},{"value":84,"label":"Templating &amp; Layout"},{"value":93,"label":"Troubleshooting"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"},{"value":83,"label":"Templates"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Jaime Marchwinski","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":59,"name":"PHP &amp; Functions","slug":"customizing-resources","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":101,"filter":"raw","term_order":"0","cat_ID":59,"category_count":101,"category_description":"","cat_name":"PHP &amp; Functions","category_nicename":"customizing-resources","category_parent":24},{"term_id":136,"name":"Plugin Updates","slug":"updating-plugins","term_group":0,"term_taxonomy_id":136,"taxonomy":"category","description":"","parent":63,"count":11,"filter":"raw","term_order":"0","cat_ID":136,"category_count":11,"category_description":"","cat_name":"Plugin Updates","category_nicename":"updating-plugins","category_parent":63},{"term_id":84,"name":"Templating &amp; Layout","slug":"theming-overview","term_group":0,"term_taxonomy_id":84,"taxonomy":"category","description":"","parent":24,"count":59,"filter":"raw","term_order":"0","cat_ID":84,"category_count":59,"category_description":"","cat_name":"Templating &amp; Layout","category_nicename":"theming-overview","category_parent":24},{"term_id":93,"name":"Troubleshooting","slug":"errors","term_group":0,"term_taxonomy_id":93,"taxonomy":"category","description":"","parent":0,"count":67,"filter":"raw","term_order":"0","cat_ID":93,"category_count":67,"category_description":"","cat_name":"Troubleshooting","category_nicename":"errors","category_parent":0}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"},{"term_id":83,"name":"Templates","slug":"templates","term_group":0,"term_taxonomy_id":83,"taxonomy":"post_tag","description":"","parent":0,"count":6,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1954112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1954112"}],"version-history":[{"count":5,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1954112\/revisions"}],"predecessor-version":[{"id":1962595,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1954112\/revisions\/1962595"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1954112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1954112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1954112"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1954112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}