{"id":260,"date":"2009-05-14T20:55:32","date_gmt":"2009-05-14T16:55:32","guid":{"rendered":"http:\/\/judepereira.com\/blog\/?p=260"},"modified":"2009-05-14T21:03:48","modified_gmt":"2009-05-14T17:03:48","slug":"howto-dynamic-plugins-for-wordpress","status":"publish","type":"post","link":"https:\/\/judepereira.com\/blog\/howto-dynamic-plugins-for-wordpress\/","title":{"rendered":"[HOWTO] Dynamic Plugins for WordPress"},"content":{"rendered":"<p><strong>Problem: <\/strong> Installed the hemingwayEx theme. Looks great, but the pagination doesn&#8217;t work well without the <a href=\"http:\/\/moggy.laceous.com\/2008\/08\/15\/paging-hemingway-part-deux\/\">custom hemingwayEx pagination plugin<\/a>. I got that installed. The hemmingwayEx theme looks cool when it displays two posts per page. The plugin worked well except that for my other two themes, displayed two posts per page. I posted a topic at <a href=\"http:\/\/wordpress.org\/support\/topic\/269620\">WordPress Forums<\/a>. No results.<\/p>\n<p><strong>Solution: <\/strong> Just at the beginning of the hemingwayEx theme, I modified it to create a cookie, like this:<\/p>\n<pre>\r\n&lt;?php\r\nif(!isset($_COOKIE[\"wptheme\" . COOKIEHASH])) {\r\n\t\t$expire=time()+3600;\r\n\t\t$ctheme=\"hemingwayEx\";\r\n\t\tsetcookie(\"wptheme\".COOKIEHASH, stripslashes($ctheme), $expire);\r\n}\r\n?&gt;\r\n<\/pre>\n<p><!--more--><br \/>\nThat&#8217;s the exact same cookie that &#8220;Theme Switcher Reloaded&#8221; creates. So it checks if the cookie is created, if not, it will create one.<\/p>\n<p>Then add a condition before the plugin code.<\/p>\n<pre>\r\n&lt;?php\r\nfunction getTheme() {\r\n\tif (isset($_COOKIE[\"wptheme\" . COOKIEHASH])) {\r\n\t\treturn $_COOKIE[\"wptheme\" . COOKIEHASH];\r\n\t}\r\n}\r\n$ctheme=getTheme();\r\nif ($ctheme==\"hemingwayEx\") {\r\n\/\/ put the rest of the plugin code here (everything)\r\n}\r\n?&gt;\r\n<\/pre>\n<p>That&#8217;s it! Use this technique to enable any plugin only for certain themes. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: Installed the hemingwayEx theme. Looks great, but the pagination doesn&#8217;t work well without the custom hemingwayEx pagination plugin. I got that installed. The hemmingwayEx theme looks cool when it displays two posts per page. The plugin worked well except that for my other two themes, displayed two posts per page. I posted a topic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[52],"tags":[65,63,64],"class_list":["post-260","post","type-post","status-publish","format-standard","hentry","category-code","tag-dynamic","tag-dynamic-plugins","tag-plugins"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pqtyx-4c","jetpack-related-posts":[{"id":1936,"url":"https:\/\/judepereira.com\/blog\/taming-a-throttled-api-with-dynamic-proxies-in-java\/","url_meta":{"origin":260,"position":0},"title":"Taming a throttled API with Dynamic Proxies in Java","author":"Jude Pereira","date":"January 20, 2021","format":false,"excerpt":"Recently, at CleverTap, we've begun migrating some of our largest clusters to a new protocol (for starters, think ~115 instances at a time). One of the most fun things I've had my hands on during this migration was the AWS Systems Manager API. When we scaled up our migrations gradually\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1685,"url":"https:\/\/judepereira.com\/blog\/compile-less-on-the-fly-for-your-exploded-war-in-intellij\/","url_meta":{"origin":260,"position":1},"title":"Compile LESS on the fly for your exploded WAR in IntelliJ","author":"Jude Pereira","date":"February 5, 2016","format":false,"excerpt":"At CleverTap, we've recently started using LESS for dynamic CSS. While it has it's upsides, the biggest downside\u00a0was that most of our developers couldn't use the hot deploy feature for their local deployments. After an hour or so, we came up with a neat solution. \u00a0 There are two parts\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"External Tool configuration for compiling LESS files before deployment","src":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/Screen-Shot-2016-02-05-at-01.32.45-1024x494.png?resize=525%2C300 1.5x"},"classes":[]},{"id":893,"url":"https:\/\/judepereira.com\/blog\/coloured-varlogmessages-at-tty12\/","url_meta":{"origin":260,"position":2},"title":"Coloured \/var\/log\/messages at tty12","author":"Jude Pereira","date":"April 26, 2011","format":false,"excerpt":"Reading logs could never become any more easier, at just a keystroke, you have your logs displayed where you want, in some fancy colour. They look great too. TTY's can be accessed by pressing Alt + Ctrl + F[1 - 12] simultaneously. In the following, you'll get a decent, colourized\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1659,"url":"https:\/\/judepereira.com\/blog\/clion-and-openframeworks\/","url_meta":{"origin":260,"position":3},"title":"CLion 1.1.1 and openFrameworks 0.8.4","author":"Jude Pereira","date":"October 2, 2015","format":false,"excerpt":"A basic template to start building oF projects using CMake within CLion. It's here on GitHub! All credits go to kureta for the CMake files. I've just pieced it together as a project which can be imported.","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1696,"url":"https:\/\/judepereira.com\/blog\/mocking-the-http2-apple-push-notification-gateway-in-go\/","url_meta":{"origin":260,"position":4},"title":"Mocking the HTTP\/2 Apple push notification gateway in Go","author":"Jude Pereira","date":"February 17, 2016","format":false,"excerpt":"At CleverTap, we had the need to mock the new HTTP\/2 Apple push gateway API. After trying to do this in Java, and then in Python, I succeeded in getting it to work in Go. Go out of all languages! To me, Go has a completely strange syntax, compared to\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1675,"url":"https:\/\/judepereira.com\/blog\/sending-notifications-via-apples-new-http2-api-using-jetty-9-3-6\/","url_meta":{"origin":260,"position":5},"title":"Sending notifications via Apple&#8217;s new HTTP\/2 API (using Jetty 9.3.6)","author":"Jude Pereira","date":"January 9, 2016","format":false,"excerpt":"HTTP\/2 is still very much new to Java, and as such, there are just two libraries who support it - Jetty (from 9.3), and Netty (in alpha). If you're going the Jetty way (as I have), you'll need to add their ALPN library to your boot classpath. Note: Jetty 9.3.x\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":12,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}