Tag: snippets

  • Make a query variable public

    In case you are messing with custom rewrite rules in WordPress and especially creating new ones with the generate_rewrite_rules hook, you should know how to make a private (or a custom, which is by default – non-public) query variable public in order to have it working correctly in the rewrite rule. It’s actually pretty simple…

  • “Sorry, you are not allowed to access this page.” on News Cherry theme options page

    The problem It happened to a client of mine just recently – they tried to change something in the theme options, but they couldn’t, as reaching out to http://their-site.com/wp-admin/admin.php?page=options.php produced “Sorry, you are not allowed to access this page.” message. The theme is News Cherry by Bdaia, found on ThemeForest. The solution Turns out the theme…

  • Resources on WordPress Override WooCommerce templates with a plugin

    Override WooCommerce templates with a plugin

    WooCommerce Templates WooCommerce has templates for everything including emails and provides developers an easy way override them. This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. This is very useful when you build a custom or a child theme and you want to modify the way WooCommerce looks according to your needs. But in…

  • Resources on WordPress Monitoring slow queries in MySQL

    Monitoring slow queries in MySQL

    If you are in doubt that some really slow queries are taking place on your server and they put you on too much load, then use this change in the configuration file to enable logging of slow queries: The config files usually is /etc/mysql/my.cnf. Uncomment these: slow-query-log = 1 slow-query-log-file = /var/log/mysql/mysql-slow.log long_query_time = 1…

  • Prevent hotlinking on your media files

    Whenever you want to ban/prevent hotlinking your media files and protect your server’s resources and bandwidth you may use the following snippet in the .htaccess file of your main directory of your site. # BEGIN Hotlinking Protection RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?YOURSITE.YOURDOMAIN [NC] RewriteRule .(webm|3g2|3gp|3gpp|flv|m3a|m4a|m4b|mka|mkv|mov|mp2|mp3|mp4|mpeg|swf|wav|wma|wmv|XYZ)$ – [NC,F,L] # END Hotlinking Protection Just replace…