{"id":1400728,"date":"2017-12-07T13:51:32","date_gmt":"2017-12-07T21:51:32","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/"},"modified":"2017-12-07T13:51:32","modified_gmt":"2017-12-07T21:51:32","slug":"php-snippets-for-events-calendar-create-high-cpu-usage","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/","title":{"rendered":"PHP snippets for Events Calendar create high CPU usage"},"content":{"rendered":"<p>PHP snippets seem to call to a database for Events Calendar and create extremely high usage to the point the server shuts down the site.  They are:<\/p>\n<p>\/*<br \/>\n* EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR<br \/>\n* See the codex to learn more about WP text domains:<br \/>\n* http:\/\/codex.wordpress.org\/Translating_WordPress#Localization_Technology<br \/>\n* Example Tribe domains: &#8216;tribe-events-calendar&#8217;, &#8216;tribe-events-calendar-pro&#8217;&#8230;<br \/>\n*\/<br \/>\nfunction tribe_custom_theme_text ( $translation, $text, $domain ) {<br \/>\n                \/\/ Put your custom text here in a key =&gt; value pair<br \/>\n                \/\/ Example: &#8216;Text you want to change&#8217; =&gt; &#8216;This is what it will be changed to&#8217;<br \/>\n                \/\/ The text you want to change is the key, and it is case-sensitive<br \/>\n                \/\/ The text you want to change it to is the value<br \/>\n                \/\/ You can freely add or remove key =&gt; values, but make sure to separate them with a comma<br \/>\n                \/\/ This example changes the label &#8220;Venue&#8221; to &#8220;Location&#8221;, and &#8220;Related Events&#8221; to &#8220;Similar Events&#8221;<br \/>\n                $custom_text = array(<br \/>\n                                &#8216;Venue&#8217; =&gt; &#8216;Location&#8217;,<br \/>\n                                &#8216;Related %s&#8217; =&gt; &#8216;More %s&#8217;,<br \/>\n                );<br \/>\n                \/\/ If this text domain starts with &#8220;tribe-&#8220;, &#8220;the-events-&#8220;, or &#8220;event-&#8221; and we have replacement text<br \/>\n                if( (strpos($domain, &#8216;tribe-&#8216;) === 0 || strpos($domain, &#8216;the-events-&#8216;) === 0 || strpos($domain, &#8216;event-&#8216;) === 0) &amp;&amp; array_key_exists($translation, $custom_text) ) {<br \/>\n                                $translation = $custom_text[$translation];<br \/>\n                }<br \/>\n    return $translation;<br \/>\n}<br \/>\nadd_filter(&#8216;gettext&#8217;, &#8216;tribe_custom_theme_text&#8217;, 20, 3);<\/p>\n<p>AND<\/p>\n<p>if ( function_exists( &#8216;tribe_get_events&#8217; ) ) {<br \/>\n                \/**<br \/>\n                * Open event website links in new tab.<br \/>\n                *<br \/>\n                * @since Nov 9 2015<br \/>\n                *\/<br \/>\n                function tribe_support_1023056() {<br \/>\n                                if ( ! wp_script_is( &#8216;enqueued&#8217;, &#8216;jquery&#8217; ) )<br \/>\n                                                wp_enqueue_script( &#8216;jquery&#8217; );<br \/>\n                                ?&gt;<br \/>\n                                                &lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n                                                                jQuery( &#8216;.tribe-events-event-url, .url&#8217; ).on( &#8216;click&#8217;, &#8216;a&#8217;, function(e) {<br \/>\n                                                                                e.preventDefault()<\/p>\n<p>                                                                                var in_tab = window.open( e.currentTarget.href, &#8216;_blank&#8217; );<\/p>\n<p>                                                                                if ( in_tab )<br \/>\n                                                                                                in_tab.focus()<br \/>\n                                                                                else<br \/>\n                                                                                                alert( &#8216;Please allow popups for this site.&#8217; )<br \/>\n                                                                });<br \/>\n                                                &lt;\/script&gt;<br \/>\n                                &lt;?php<br \/>\n                }<br \/>\n                add_action( &#8216;wp_footer&#8217;, &#8216;tribe_support_1023056&#8217; );<br \/>\n}<\/p>\n<p>Why is this??<\/p>\n","protected":false},"template":"","class_list":["post-1400728","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP snippets for Events Calendar create high CPU usage -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP snippets for Events Calendar create high CPU usage -\" \/>\n<meta property=\"og:description\" content=\"PHP snippets seem to call to a database for Events Calendar and create extremely high usage to the point the server shuts down the site. They are: \/* * EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR * See the codex to learn more about WP text domains: * http:\/\/codex.wordpress.org\/Translating_WordPress#Localization_Technology * Example Tribe [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/\",\"name\":\"PHP snippets for Events Calendar create high CPU usage -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-12-07T21:51:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Welcome!\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/_welcome\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Pre-Sales Questions\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/_welcome\/pre-sales-questions\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"PHP snippets for Events Calendar create high CPU usage\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP snippets for Events Calendar create high CPU usage -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/","og_locale":"en_US","og_type":"article","og_title":"PHP snippets for Events Calendar create high CPU usage -","og_description":"PHP snippets seem to call to a database for Events Calendar and create extremely high usage to the point the server shuts down the site. They are: \/* * EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR * See the codex to learn more about WP text domains: * http:\/\/codex.wordpress.org\/Translating_WordPress#Localization_Technology * Example Tribe [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/","name":"PHP snippets for Events Calendar create high CPU usage -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-12-07T21:51:32+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/php-snippets-for-events-calendar-create-high-cpu-usage\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Welcome!","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/_welcome\/"},{"@type":"ListItem","position":4,"name":"Pre-Sales Questions","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/_welcome\/pre-sales-questions\/"},{"@type":"ListItem","position":5,"name":"PHP snippets for Events Calendar create high CPU usage"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1400728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1400728\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1400728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}