{"id":4490,"date":"2016-12-21T18:30:54","date_gmt":"2016-12-21T18:30:54","guid":{"rendered":"http:\/\/fluffytech.co.uk\/fluff\/?p=4490"},"modified":"2018-09-21T16:39:15","modified_gmt":"2018-09-21T15:39:15","slug":"snippets","status":"publish","type":"post","link":"https:\/\/www.fluffytech.co.uk\/fluff\/snippets\/","title":{"rendered":"Snippets"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4491\" src=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-content\/uploads\/scissors.png\" alt=\"scissors\" width=\"256\" height=\"256\" title=\"\"><\/p>\n<h1>FORCE load new style.css<\/h1>\n<p>Put this code in your <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\" target=\"_blank\" rel=\"noopener nofollow\">child theme<\/a> header.php. It will check to see if it needs to reload a newer version of your stylesheet, even if you are heavily caching your site! Thanks for this gem <a href=\"https:\/\/devcereal.com\/force-css-update-wordpress\/\" target=\"_blank\" rel=\"noopener nofollow\">Ben from Dev Cereal<\/a>!<\/p>\n<p><code class=\" language-markup\">&lt;!-- FLUFFYTECH: START force load style.css if it's new\u00a0 --&gt; &lt;link rel=\"stylesheet\" href=\"<span class=\"token prolog\">&lt;?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '\/style.css'); ?&gt;<\/span>\" type=\"text\/css\" \/&gt;<a href=\"https:\/\/www.fluffytech.co.uk\/fluff\/wp-admin\/post.php?post=4490&amp;action=edit\">Edit<\/a><\/code><\/p>\n<h1>\u00a0<\/h1>\n<h1>\u00a0<\/h1>\n<h1>RE_DIRECT to homepage after login<\/h1>\n<p>Put this code in your <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\" target=\"_blank\" rel=\"noopener nofollow\">child theme<\/a> functions.php<\/p>\n<p><code>\/* FLUFFYTECH: re-direct on homepage after login --------------------------- *\/ function login_redirect( $redirect_to, $request, $user ){ return home_url('\/'); } add_filter( 'login_redirect', 'login_redirect', 10, 3 ); <\/code><\/p>\n<h1>\u00a0<\/h1>\n<h1>\u00a0<\/h1>\n<h1>DISABLE WordPress front-end Admin Bar for all users<\/h1>\n<p>Put this code in your <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\" target=\"_blank\" rel=\"noopener nofollow\">child theme<\/a> functions.php<\/p>\n<p><code>\/* FLUFFYTECH: Disable WordPress Front-end Admin Bar for all users ---------------------------------------------------------------- *\/ show_admin_bar(false); <\/code><\/p>\n<h1>\u00a0<\/h1>\n<h1>\u00a0<\/h1>\n<h1>REMOVE edit button on front-end for specific user roles (Editor)<\/h1>\n<p>Put this code in your <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\" target=\"_blank\" rel=\"noopener nofollow\">child theme<\/a> functions.php<\/p>\n<p><code>\/* FLUFFYTECH: REMOVE edit button on FRONT-END for specific user role (editor) -------------------------------------------------------------- *\/ if ( current_user_can('editor') ) add_filter( 'edit_post_link', '__return_false' ); <\/code><\/p>\n<h1>\u00a0<\/h1>\n<h1>\u00a0<\/h1>\n<h1>STOP comments period<\/h1>\n<p>A small trick is checking your current theme and creating a new file comments.php (if you don&#8217;t have). On this file, you just place this code:<\/p>\n<p><code> &lt;!-- FLUFFYTECH: STOP ALL COMMENTS!! --&gt; &lt;?php return false; ?&gt;<\/code><\/p>\n<p>It will prevent any bot to use your comment form for posting.<\/p>\n<h1>\u00a0<\/h1>\n<h1>\u00a0<\/h1>\n<h1>HIDE shortcodes ultimate button<\/h1>\n<p>Put this code in your <a href=\"https:\/\/codex.wordpress.org\/Child_Themes\" target=\"_blank\" rel=\"noopener nofollow\">child theme<\/a> functions.php<\/p>\n<p><code>\/* FLUFFYTECH: HIDE shortcodes ultimate button --------------------------- *\/ function fluffytech_hide_shortcodes_ultimate_button() { ?&gt;&lt;style type=\"text\/css\"&gt;.su-generator-button {display:none !important;}&lt;\/style&gt;&lt;?php } add_action( 'admin_head', 'fluffytech_hide_shortcodes_ultimate_button' );<\/code><\/p>\n<p>&nbsp;<\/p>\n<h1>\u00a0<\/h1>\n<h1>QUERY OBJECT<\/h1>\n<p>Query the current object (page, taxonomy, post etc..) and show it&#8217;s attributes<\/p>\n<p><code>&lt;?php<\/code><br \/>\n <code> $queried_object = get_queried_object();<\/code><br \/>\n <code> var_dump( $queried_object );<\/code><br \/>\n <code> ?&gt;<\/code><\/p>\n<p>&nbsp;<\/p>\n<h1>MAILTO:<\/h1>\n<p>It is not possible to have html in the body of the email if you to generate it using mailto: &#8211; but you can generate a link here which adds body text and a subject automatically<\/p>\n<p><a href=\"https:\/\/e-mailer.link\/en\/\" target=\"_blank\" rel=\"noopener nofollow\">https:\/\/e-mailer.link\/en\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Useful snippets of code for wordpress children&#8230;<\/p>\n","protected":false},"author":6,"featured_media":4491,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[87,35,1,80,58,41],"tags":[],"class_list":["post-4490","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fluffy-fix","category-fluffy-tech-tips","category-random-mix","category-stuff-we-fluff","category-tools","category-wordpress",""],"_links":{"self":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts\/4490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/comments?post=4490"}],"version-history":[{"count":0,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/posts\/4490\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/media\/4491"}],"wp:attachment":[{"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/media?parent=4490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/categories?post=4490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fluffytech.co.uk\/fluff\/wp-json\/wp\/v2\/tags?post=4490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}