{"id":476,"date":"2019-09-12T10:40:37","date_gmt":"2019-09-12T08:40:37","guid":{"rendered":"http:\/\/awhitepixel.com\/?p=476"},"modified":"2020-07-25T12:02:05","modified_gmt":"2020-07-25T10:02:05","slug":"autoloader-namespaces-theme-plugin","status":"publish","type":"post","link":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/","title":{"rendered":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin"},"content":{"rendered":"\n<p>If you are writing object-oriented code an autoloader is a must-have. Without an autoloader you would need to add a line with including the class file, before you can initialize it. It can quickly be cumbersome when you work with a lot of classes. An autoloader is a function that triggers everytime a new class is instantiated, and includes the class file before instantiation happens.<\/p>\n\n\n\n<p>Namespaces are a way of structuring and encapsulating your code, and helps avoiding name collisions. If you are going to write OOP, it&#8217;s recommended to use namespaces as well. Keep in mind that you can implement an autoloader without using namespaces in your OOP code. <\/p>\n\n\n\n<p>You can use this code for your WordPress theme or plugin, or any PHP code outside WordPress for that matter &#8211; just modify the paths correspondingly. For this example I&#8217;m creating an autoloader for a WordPress theme.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rules for class namespace and structure<\/h2>\n\n\n\n<p>Implementing an autoloader would require some defined rules for your code structure and where to find them. Using namespaces simplifies this somewhat, as your namespace can refer to which folder the classes are in. <\/p>\n\n\n\n<p>First make a decision of what your namespace should be named. Usually it&#8217;s something unique for your code, for example your theme name. For example, the namespace for this site&#8217;s theme is <code>AWhitePixel\\Theme<\/code>. This means that for the autoloader to work, any classes must be inside this namespace.<\/p>\n\n\n\n<pre class=\"prettyprint\">namespace AWhitePixel\\Theme;\n<\/pre>\n\n\n\n<p>My first rule is that any class file will always contain only one class, and the class name must be the same as the file name. For example; a class <code>MyTest<\/code> must be defined inside a file <code>MyTest.php<\/code>.<\/p>\n\n\n\n<p>My second rule is how to structure the classes in folders. I decide that all classes goes inside a folder <code>src<\/code> in my theme. I can put class files directly in this folder, and for that they must be inside &#8220;root&#8221; namespace defined above. But if I want to create subfolders and put class files in them, their namespaces must include the folder structure. For example a class file <code>MyTest.php<\/code> that resides in the folder <code>src\/Test\/<\/code>, must have this namespace defined:<\/p>\n\n\n\n<code class=\"code-header\">src\/Test\/MyTest.php<\/code>\n<pre class=\"prettyprint\">namespace AWhitePixel\\Theme\\Test;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the autoloader<\/h2>\n\n\n\n<p>I like to keep the autoloader in a separate file, and outside the <code>src\/<\/code> folder which is defined for namespaced class files only. As an example I&#8217;ll create a file <code>autoloader.php<\/code> in the folder <code>inc\/<\/code> in my theme.<\/p>\n\n\n\n<p>PHP has a built-in autoloader function: <a rel=\"noreferrer noopener\" aria-label=\"spl_autoload_register (opens in a new tab)\" href=\"https:\/\/www.php.net\/manual\/en\/function.spl-autoload-register.php\" target=\"_blank\">spl_autoload_register<\/a>. You provide your autoloader function name as parameter, and in that function you get the requested class as argument (what you put after <code>new<\/code> when instantiating the class). When instantiating classes with namespaces, e.g. <code>new AWhitePixel\\Theme\\Test\\MyTest()<\/code>, the provided variable to this function would be <code>\"AWhitePixel\\Theme\\Test\\MyTest\"<\/code>.<\/p>\n\n\n\n<p>Let&#8217;s add the autoloader function, and in it we define our required namespace for the autoloader:<\/p>\n\n\n\n<code class=\"code-header\">inc\/autoloader.php<\/code>\n<pre class=\"prettyprint linenums\">&lt;?php\nspl_autoload_register('awhitepixel_autoloader');\nfunction awhitepixel_autoloader($class) {\n\t$namespace = 'AWhitePixel\\Theme';\n\n}\n<\/pre>\n\n\n\n<p>Then we need to include this file so that our autoloader is registered. As this is in a theme, I&#8217;ll add the include in the theme&#8217;s <code>functions.php<\/code>. If you are using this for a plugin, put it inside your plugin files. The autoloader file needs to be added early, <em>before<\/em> any instantiation of classes. I&#8217;m putting this at the very first line in my <code>functions.php<\/code>:<\/p>\n\n\n\n<code class=\"code-header\">functions.php<\/code>\n<pre class=\"prettyprint\">require_once(get_template_directory() . '\/inc\/autoloader.php');\n<\/pre>\n\n\n\n<p>If you are using it for a child theme, or a plugin, modify the path for your needs.<\/p>\n\n\n\n<p>And that&#8217;s it. Now the autoloader is in place, but it&#8217;s not doing anything. Let&#8217;s return to the autoloader function and finish it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Writing and testing the autoloader function<\/h2>\n\n\n\n<p>First we need to ensure that the requested class name is actually inside our namespace. We simply check if the namespace class name provided contains the namespace string, and if not, exit the function. After that we remove the namespace name from the string, so that we can work out any subfolders and class file.<\/p>\n\n\n\n<code class=\"code-header\">inc\/autoloader.php<\/code>\n<pre class=\"prettyprint linenums faded\">&lt;?php\nspl_autoload_register('awhitepixel_autoloader');\nfunction awhitepixel_autoloader($class) {\n\t$namespace_name = 'AWhitePixel\\Theme';\n\n<span class=\"featured\">\tif (strpos($class, $namespace) !== 0) {\n\t\treturn;\n\t}\n\n\t$class = str_replace($namespace, '', $class);<\/span>\n}\n<\/pre>\n\n\n\n<p>Now we&#8217;ll transform the provided namespace into an actual path to the file. First, we&#8217;ll replace any backslash <code>\"\\\"<\/code> in the namespace with the character for folder separator &#8211; for this we use the PHP constant <code>DIRECTORY_SEPARATOR<\/code>. At the very end we add a <code>\".php\"<\/code>. And finally before the string we add the full root path. Because this is inside a theme, I&#8217;m using <code>get_template_directory()<\/code>. If you are using this for a plugin, use a method that returns the full path to your plugin.<\/p>\n\n\n\n<code class=\"code-header\">inc\/autoloader.php<\/code>\n<pre class=\"prettyprint linenums faded\">\t...\n\t$class = str_replace($namespace, '', $class);\n\n<span class=\"featured\">\t$class = str_replace('\\\\', DIRECTORY_SEPARATOR, $class) . '.php';\n\n\t$directory = get_template_directory();\n\t$path = $directory . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $class;<\/span>\n}\n<\/pre>\n\n\n\n<p>All we need to do now is to check if the file exists, and if it does, require it.<\/p>\n\n\n\n<code class=\"code-header\">inc\/autoloader.php<\/code>\n<pre class=\"prettyprint linenums faded\">\t...\n\t$path = $directory . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $class;\n\n<span class=\"featured\">\tif (file_exists($path)) {\n\t\trequire_once($path);\n\t}<\/span>\n}\n<\/pre>\n\n\n\n<p>That&#8217;s it! <\/p>\n\n\n\n<p>Let&#8217;s test it out. Create a subfolder <code>Test<\/code> in your theme&#8217;s <code>src\/<\/code> folder, and inside it put a php file named <code>MyTest.php<\/code>. Define a class <code>MyTest<\/code> in it, following the rules for namespace: <code>AWhitePixel\\Theme\\Test<\/code>. I&#8217;ll just add a print of &#8216;Success&#8217; in the construct function so we can easily see that it actually initializes the class.<\/p>\n\n\n\n<code class=\"code-header\">src\/Test\/MyTest.php<\/code>\n<pre class=\"prettyprint linenums\">&lt;?php\nnamespace AWhitePixel\\Theme\\Test;\n\nclass MyTest {\n\tpublic function __construct() {\n\t\tvar_dump('Success!');\n\t}\n}\n<\/pre>\n\n\n\n<p>In our functions.php, <em>after<\/em> requiring the autoloader, we simply instantiate the class:<\/p>\n\n\n\n<code class=\"code-header\">functions.php<\/code>\n<pre class=\"prettyprint\">$test = new AWhitePixel\\Theme\\Test\\MyTest();\n<\/pre>\n\n\n\n<p>Refresh your WordPress site and see that you get the &#8216;Success!&#8217; outputted.<\/p>\n\n\n\n<p>The autoloader will autoload any class files that are inside our defined namespace, and follows the correct rules. You can instantiate classes from anywhere inside your theme, even inside the classes themselves.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The full autoloader function<\/h2>\n\n\n\n<p>For reference, here&#8217;s our final autoloader function:<\/p>\n\n\n\n<code class=\"code-header\">inc\/autoloader.php<\/code>\n<pre class=\"prettyprint linenums\">spl_autoload_register('awhitepixel_autoloader');\nfunction awhitepixel_autoloader($class) {\n\t$namespace = 'AWhitePixel\\Theme';\n\n\tif (strpos($class, $namespace) !== 0) {\n\t\treturn;\n\t}\n\n\t$class = str_replace($namespace, '', $class);\n\t$class = str_replace('\\\\', DIRECTORY_SEPARATOR, $class) . '.php';\n\n\t$directory = get_template_directory();\n\t$path = $directory . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $class;\n\n\tif (file_exists($path)) {\n\t\trequire_once($path);\n\t}\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are writing object-oriented code an autoloader is a must-have. Without an autoloader you would need to add a line with including the class file, before you can initialize it. It can quickly be cumbersome when you work with a lot of classes. An autoloader is a function that triggers everytime a new class [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":480,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"hide_page_title":false,"footnotes":""},"categories":[20,3],"tags":[23],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel<\/title>\n<meta name=\"description\" content=\"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel\" \/>\n<meta property=\"og:description\" content=\"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"A White Pixel\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-12T08:40:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-25T10:02:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/awhitepixel.com\/wp-content\/uploads\/2019\/09\/featured-oop.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"1148\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"AWhitePixel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"AWhitePixel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\"},\"author\":{\"name\":\"AWhitePixel\",\"@id\":\"https:\/\/awhitepixel.com\/#\/schema\/person\/35e73a52e02ff0446ec9cadae3dd4072\"},\"headline\":\"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin\",\"datePublished\":\"2019-09-12T08:40:37+00:00\",\"dateModified\":\"2020-07-25T10:02:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\"},\"wordCount\":871,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/awhitepixel.com\/#organization\"},\"keywords\":[\"object-oriented\"],\"articleSection\":[\"Themes\",\"WordPress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\",\"url\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\",\"name\":\"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel\",\"isPartOf\":{\"@id\":\"https:\/\/awhitepixel.com\/#website\"},\"datePublished\":\"2019-09-12T08:40:37+00:00\",\"dateModified\":\"2020-07-25T10:02:05+00:00\",\"description\":\"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.\",\"breadcrumb\":{\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/awhitepixel.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/awhitepixel.com\/#website\",\"url\":\"https:\/\/awhitepixel.com\/\",\"name\":\"A White Pixel\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/awhitepixel.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/awhitepixel.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/awhitepixel.com\/#organization\",\"name\":\"A White Pixel\",\"url\":\"https:\/\/awhitepixel.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/awhitepixel.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/awhitepixel.com\/wp-content\/uploads\/2020\/07\/cta-fox-wordpress-computer-blue.png\",\"contentUrl\":\"https:\/\/awhitepixel.com\/wp-content\/uploads\/2020\/07\/cta-fox-wordpress-computer-blue.png\",\"width\":365,\"height\":302,\"caption\":\"A White Pixel\"},\"image\":{\"@id\":\"https:\/\/awhitepixel.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/awhitepixel.com\/#\/schema\/person\/35e73a52e02ff0446ec9cadae3dd4072\",\"name\":\"AWhitePixel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/awhitepixel.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/54b82f3f4c246724797e2a5bfeffa27f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/54b82f3f4c246724797e2a5bfeffa27f?s=96&d=mm&r=g\",\"caption\":\"AWhitePixel\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel","description":"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/","og_locale":"en_US","og_type":"article","og_title":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel","og_description":"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.","og_url":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/","og_site_name":"A White Pixel","article_published_time":"2019-09-12T08:40:37+00:00","article_modified_time":"2020-07-25T10:02:05+00:00","og_image":[{"width":2000,"height":1148,"url":"https:\/\/awhitepixel.com\/wp-content\/uploads\/2019\/09\/featured-oop.jpg","type":"image\/jpeg"}],"author":"AWhitePixel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"AWhitePixel","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#article","isPartOf":{"@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/"},"author":{"name":"AWhitePixel","@id":"https:\/\/awhitepixel.com\/#\/schema\/person\/35e73a52e02ff0446ec9cadae3dd4072"},"headline":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin","datePublished":"2019-09-12T08:40:37+00:00","dateModified":"2020-07-25T10:02:05+00:00","mainEntityOfPage":{"@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/"},"wordCount":871,"commentCount":2,"publisher":{"@id":"https:\/\/awhitepixel.com\/#organization"},"keywords":["object-oriented"],"articleSection":["Themes","WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/","url":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/","name":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin - A White Pixel","isPartOf":{"@id":"https:\/\/awhitepixel.com\/#website"},"datePublished":"2019-09-12T08:40:37+00:00","dateModified":"2020-07-25T10:02:05+00:00","description":"A guide in how to write an autoloader allowing for namespaces for your object-oriented code to a WordPress theme or plugin.","breadcrumb":{"@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/awhitepixel.com\/autoloader-namespaces-theme-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/awhitepixel.com\/"},{"@type":"ListItem","position":2,"name":"How to Implement an Autoloader with Namespaces in Your WordPress Theme or Plugin"}]},{"@type":"WebSite","@id":"https:\/\/awhitepixel.com\/#website","url":"https:\/\/awhitepixel.com\/","name":"A White Pixel","description":"","publisher":{"@id":"https:\/\/awhitepixel.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/awhitepixel.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/awhitepixel.com\/#organization","name":"A White Pixel","url":"https:\/\/awhitepixel.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/awhitepixel.com\/#\/schema\/logo\/image\/","url":"https:\/\/awhitepixel.com\/wp-content\/uploads\/2020\/07\/cta-fox-wordpress-computer-blue.png","contentUrl":"https:\/\/awhitepixel.com\/wp-content\/uploads\/2020\/07\/cta-fox-wordpress-computer-blue.png","width":365,"height":302,"caption":"A White Pixel"},"image":{"@id":"https:\/\/awhitepixel.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/awhitepixel.com\/#\/schema\/person\/35e73a52e02ff0446ec9cadae3dd4072","name":"AWhitePixel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/awhitepixel.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/54b82f3f4c246724797e2a5bfeffa27f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/54b82f3f4c246724797e2a5bfeffa27f?s=96&d=mm&r=g","caption":"AWhitePixel"}}]}},"_links":{"self":[{"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/posts\/476"}],"collection":[{"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/comments?post=476"}],"version-history":[{"count":8,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/posts\/476\/revisions"}],"predecessor-version":[{"id":1110,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/posts\/476\/revisions\/1110"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/media\/480"}],"wp:attachment":[{"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/media?parent=476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/categories?post=476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/awhitepixel.com\/wp-json\/wp\/v2\/tags?post=476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}