{"id":5123,"date":"2016-03-26T13:49:19","date_gmt":"2016-03-26T17:49:19","guid":{"rendered":"localhost\/officeblog\/?page_id=5123"},"modified":"2018-04-17T00:01:57","modified_gmt":"2018-04-17T04:01:57","slug":"wordpress-command-line-interface-wp-cli","status":"publish","type":"page","link":"https:\/\/baystateacademy.net\/realestatetraining\/?page_id=5123","title":{"rendered":"WordPress Command Line Interface WP-CLI"},"content":{"rendered":"<p>This page is an overview of the WP-CLI. It is very powerful tool to be able to generate content truely at the speed of thought.<\/p>\n<p>I found this plugin that allows me to add indexes to to pages or posts. I am going to use this to create these organizational pages about different categories of information.<\/p>\n<p><span class=\"innerbold\">Posts Regarding The WP-CLI<\/span><br \/>\n<ul class=\"lcp_catlist\" id=\"lcp_instance_0\"><\/ul><\/p>\n<h2 id=\"installing-wp-cli\"><a title=\"heading link\"href=\"#installing-wp-cli\" class=\"heading-link\"><i class=\"glyphicon glyphicon-link\"><\/i><\/a> Installing WP-CLI <sup><a title=\"scroll to top\" href=\"#scroll-top\">\u2191<\/a><\/sup><\/h2>\n<p>Here is the main website for the <a href=\"https:\/\/wp-cli.org\"> WP-CLI<\/a><\/p>\n<p>First get the Phar file<\/p>\n<pre>\n\/\/\n\/\/\nwget https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar\n\n<\/pre>\n<p>Now check that it is working:<\/p>\n<pre>\n\/\/\n\/\/\nphp wp-cli.phar --info\n<\/pre>\n<pre>\n\/\/\n\/\/\nchmod +x wp-cli.phar\nsudo mv wp-cli.phar \/usr\/local\/bin\/wp\n<\/pre>\n<p>Now check that WP-CLI was successfully installed<\/p>\n<pre>\n\/\/\n\/\/\nwp --info\n<\/pre>\n<h2 id=\"updating-wp-cli\"><a title=\"heading link\"href=\"#updating-wp-cli\" class=\"heading-link\"><i class=\"glyphicon glyphicon-link\"><\/i><\/a> Updating WP-CLI <sup><a title=\"scroll to top\" href=\"#scroll-top\">\u2191<\/a><\/sup><\/h2>\n<p>This is more complicated than it should be<\/p>\n<pre>\n\/\/\n\/\/You should be able to just do this\nwp cli update\n\n\/\/ But that will give you the following error\nError: \/usr\/local\/bin is not writable by current user.\n\n\/\/ So you have to do\nsudo wp cli update\n\n\/\/ But that will give you a path error like this\n\/usr\/bin\/env: php: No such file or directory\n<\/pre>\n<div class=\"postwarning\">\nI can not stress enough how frustrating it has been to figure out this issue.<br \/>\nYou should not assume that the $PATH variable set by the currently logged in<br \/>\n user is the one that the sudoers are going to use. The &#8220;sudo&#8221; command uses<br \/>\na &#8220;secure_path&#8221;. You can see the two paths like this:<\/p>\n<pre>\n\/\/\n\/\/\nenv | grep ^PATH\nsudo env | grep ^PATH\n\n\/\/ Sudo might be overriding your path.\n\/\/ If you would like to see if the \"secure_path\" do this:\nsudo -V | grep 'Value to override'\n\n\/\/ This will give you the \"secure_path\"\nValue to override user's $PATH with: \/sbin:\/bin:\/usr\/sbin:\/usr\/bin\n\n\/\/ If this is the case you can always edit \"\/etc\/sudoers\" like this:\nvisudo\n\/\/or\nvim \/etc\/sudoers\n\n\/\/ You can force sudo to use the path that you choose like this:\nsudo -E env \"PATH=$PATH\" wp cli update\n\n<\/pre>\n<div class=\"postsuggestion\">\nI have found this control over the sudo path to be extreamly useful so I made a alias for it like this:<\/p>\n<pre class=\"wrap:true\">\n\/\/\n\/\/\n\/\/ Make sure this file exists\ntouch \/etc\/profile.d\/00-aliases.sh\n\/\/ Add this alias to it\nsed -i \"$ a alias mysudo=\\'sudo -E env \\\"PATH=\\$PATH\\\"\\' \" \/etc\/profile.d\/00-aliases.sh\n<\/pre>\n<p>Now every time you want to make sure &#8220;sudo&#8221; uses your current path all you need to do is use &#8220;mysudo&#8221; like this:<\/p>\n<pre class=\"wrap:yes\">\n\/\/\n\/\/ so instead of having to remember and type this\nsudo -E env \"PATH=$PATH\" wp cli update\n\n\/\/ You can now do \nmysudo wp cli update\n\n<\/pre>\n<\/div>\n<\/div>\n<p>This is the WP-CLI_Index-Page.txt Id has PostId of 5123<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This page is an overview of the WP-CLI. It is very powerful tool to be able to generate content truely at the speed of thought. I found this plugin that allows me to add indexes to to pages or posts.<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/baystateacademy.net\/realestatetraining\/?page_id=5123\">Read more <span class=\"screen-reader-text\">WordPress Command Line Interface WP-CLI<\/span><span class=\"meta-nav\"> &#8250;<\/span><\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[22,135],"tags":[136,137],"class_list":["post-5123","page","type-page","status-publish","hentry","category-wordpress","category-wp-cli","tag-wordpress","tag-wp-cli"],"_links":{"self":[{"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/pages\/5123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5123"}],"version-history":[{"count":16,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/pages\/5123\/revisions"}],"predecessor-version":[{"id":8057,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=\/wp\/v2\/pages\/5123\/revisions\/8057"}],"wp:attachment":[{"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/baystateacademy.net\/realestatetraining\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}