{"id":178,"date":"2021-05-11T00:41:31","date_gmt":"2021-05-11T00:41:31","guid":{"rendered":"http:\/\/iplocationblock.test\/codex\/ip-geo-block-api-dir\/"},"modified":"2021-05-11T11:55:32","modified_gmt":"2021-05-11T11:55:32","slug":"ip-location-block-api-dir","status":"publish","type":"codex","link":"https:\/\/iplocationblock.com\/codex\/ip-location-block-api-dir\/","title":{"rendered":"ip-location-block-api-dir"},"content":{"rendered":"<p>The directory where IP address geolocation APIs are installed.<\/p>\n<p><!--more--><\/p>\n<h3 id=\"description\">Description<\/h3>\n<p>The filter hook \u201c<strong>ip-location-block-api-dir<\/strong>\u201d assigns the absolute path to the  directory where the class libraries of IP address geolocation APIs for    <a href=\"https:\/\/www.maxmind.com\/\" title=\"IP Geolocation and Online Fraud Prevention | MaxMind\">MaxMind<\/a> and    <a href=\"https:\/\/www.ip2location.com\/\" title=\"IP Address Geolocation to Identify Website Visitor's Geographical Location\">IP2Location<\/a> are installed. The directory is also used as a storage of IP geolocation databases.<\/p>\n<p>The class libraries can be available from <a href=\"https:\/\/github.com\/tokkonopapa\/WordPress-IP-Geo-API\" title=\"tokkonopapa\/WordPress-IP-Geo-API - GitHub\">WordPress-IP-Geo-API<\/a>.<\/p>\n<h3 id=\"parameters\">Parameters<\/h3>\n<ul>\n<li>$dir<br \/> (string) <code class=\"highlighter-rouge\">\/absolute\/path\/to\/wp-content\/<\/code><\/li>\n<\/ul>\n<h3 id=\"use-case\">Use case<\/h3>\n<p>If you want change it to your <code class=\"highlighter-rouge\">\/wp-content\/uploads\/<\/code> directory, put the  following code snippet into the <code class=\"highlighter-rouge\">functions.php<\/code> in your theme.<\/p>\n<figure class=\"highlight\">\n<pre><code class=\"language-php\" data-lang=\"php\"><span class=\"n\">function<\/span> <span class=\"n\">my_api_dir<\/span><span class=\"p\">(<\/span> <span class=\"vg\">$dir<\/span> <span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n    <span class=\"vg\">$upload<\/span> <span class=\"o\">=<\/span> <span class=\"n\">wp_upload_dir<\/span><span class=\"p\">();<\/span>\n    <span class=\"k\">return<\/span> <span class=\"vg\">$upload<\/span><span class=\"p\">[<\/span><span class=\"s1\">'basedir'<\/span><span class=\"p\">];<\/span>\n<span class=\"p\">}<\/span>\n<span class=\"n\">add_filter<\/span><span class=\"p\">(<\/span> <span class=\"s1\">'ip-location-block-api-dir'<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'my_api_dir'<\/span> <span class=\"p\">);<\/span><\/code><\/pre>\n<\/figure>\n<p>You should download <a href=\"https:\/\/github.com\/tokkonopapa\/WordPress-IP-Geo-API\" title=\"tokkonopapa\/WordPress-IP-Geo-API - GitHub\">WordPress-IP-Geo-API<\/a> and upload <code class=\"highlighter-rouge\">ip-geo-api<\/code>  to <code class=\"highlighter-rouge\">\/absolute\/path\/to\/wp-content\/uploads\/<\/code> with write permission.<\/p>\n<div class=\"alert alert-info\"> <strong>NOTE:<\/strong> When you select <code>\"mu-plugins\" (ip-location-block-mu.php)<\/code> as <a href=\"\/codex\/validation-timing.html\" title=\"Validation timing | IP Location Block\"> Validation timing <\/a>, you should put your code snippet into <code>drop-in.php<\/code> in <a href=\"\/codex\/geolocation-api-library.html\" title=\"Geolocation API library | IP Location Block\"> Geolocation API folder <\/a> instead of <code>functions.php<\/code>. See <a href=\"https:\/\/iplocationblock.com\/codex\/my-custom-functions-in-functions-php-doesnt-work\/\" title=\"My custom functions in \u201cfunctions.php\u201d doesn\u2019t work. | IP Location Block\"> My custom functions in \u201cfunctions.php\u201d doesn\u2019t work. <\/a> in FAQ for detail. <\/div>\n<h3 id=\"since\">Since<\/h3>\n<p>0.2.2.1<\/p>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","class_list":["post-178","codex","type-codex","status-publish","hentry","codex-category-actions-and-filters"],"_links":{"self":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/codex\/178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/codex"}],"about":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/types\/codex"}],"replies":[{"embeddable":true,"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/comments?post=178"}],"wp:attachment":[{"href":"https:\/\/iplocationblock.com\/wp-json\/wp\/v2\/media?parent=178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}