{"id":2000,"date":"2019-04-22T12:30:10","date_gmt":"2019-04-22T11:30:10","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2000"},"modified":"2025-05-10T09:23:10","modified_gmt":"2025-05-10T08:23:10","slug":"useful-hooks-high-level","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/plugin-api\/useful-hooks-high-level","title":{"rendered":"Useful hooks &#8211; High level"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Page load<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/************************************************************\n\/\/************************************************************\n\/\/********** HIGH LEVEL FILTERING &amp; VALIDATION HOOK **********\n\/\/************************************************************\n\/\/************************************************************\n\/\/\"wp\" runs immediately after the global WP class object is set up, it is an effective place to perform any high-level filtering or validation, following queries,\n\/\/but before WordPress does any routing, processing, or handling. It is run in the main() WP method in which the $query_args are passed to parse_request(), as well\n\/\/as when send_headers() , query_posts(), handle_404(), and register_globals() are setup.\nadd_action( 'wp', 'mysite_wp' );\nfunction mysite_wp()\n{\n\t\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/*************************************************\n\/\/*************************************************\n\/\/********** TEMPLATE PAGE ABOUT TO LOAD **********\n\/\/*************************************************\n\/\/*************************************************\n\/\/Hook executes just before WordPress determines which template page to load. It is a good hook to use if you need to do a redirect with full knowledge of the\n\/\/content that has been queried.  NOTE THIS DOES NOT FIRE FOR ADMIN PAGES!\nadd_action(\"template_redirect\", 'mysite_template_redirect');\nfunction mysite_template_redirect()\n{\n\t\n  if( ($_SERVER&#91;\"REQUEST_URI\"] == '\/members\/') &amp;&amp; !(is_user_logged_in()) )\n  {\n    wp_redirect( home_url( '\/' ) );\n    die;\n  }\n\t\n\t\/\/echo \"&lt;h1>TEST&lt;\/h1>\";\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">In Header area<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/***********************************************\n\/\/***********************************************\n\/\/********** HEADERA AREA IN WORDPRESS **********\n\/\/***********************************************\n\/\/***********************************************\nadd_action('wp_head', 'custom_header_code');\nfunction custom_header_code()\n{\n\n  $HtmlOutput = \"\";\n  $HtmlOutput .= &lt;&lt;&lt;_END\n\n    &lt;!----- DISABLE CACHING OF PAGES-----&gt;\n    &lt;meta http-equiv=\"cache-control\" content=\"max-age=0\" \/&gt;\n    &lt;meta http-equiv=\"cache-control\" content=\"no-cache\" \/&gt;\n    &lt;meta http-equiv=\"expires\" content=\"0\" \/&gt;\n    &lt;meta http-equiv=\"expires\" content=\"Tue, 01 Jan 1980 1:00:00 GMT\" \/&gt;\n    &lt;meta http-equiv=\"pragma\" content=\"no-cache\" \/&gt;\n\n_END;\n\n  echo($HtmlOutput);\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Just after body tag<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/***************************************************\n\/\/***************************************************\n\/\/********** TOP OF BODY AREA IN WORDPRESS **********\n\/\/***************************************************\n\/\/***************************************************\n\/\/(Note not all themes have wp_body_open hopok, its quite new)\nadd_action('wp_body_open', 'custom_content_after_body_open_tag');\nfunction custom_content_after_body_open_tag()\n{\n  $HtmlOutput = \"\";\n  $HtmlOutput .= &lt;&lt;&lt;_END\n\n\n_END;\n\n  echo($HtmlOutput);\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">In Footer area<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/**********************************************\n\/\/**********************************************\n\/\/********** FOOTER AREA IN WORDPRESS **********\n\/\/**********************************************\n\/\/**********************************************\nadd_action('wp_footer', 'custom_footer_code');\nfunction custom_footer_code()\n{\n  $HtmlOutput = \"\";\n  $HtmlOutput .= &lt;&lt;&lt;_END\n\n\n\n_END;\n\n  echo($HtmlOutput);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Page load In Header area Just after body tag In Footer area<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[309,164],"tags":[],"class_list":["post-2000","post","type-post","status-publish","format-standard","hentry","category-actions","category-plugin-api"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2000"}],"version-history":[{"count":7,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2000\/revisions"}],"predecessor-version":[{"id":3744,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2000\/revisions\/3744"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}