<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: BhanuSingh</title>
    <description>The latest articles on DEV Community by BhanuSingh (@bhanusingh).</description>
    <link>https://dev.to/bhanusingh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F30654%2F424174b1-ddb3-499b-93fb-3a588122cb39.jpg</url>
      <title>DEV Community: BhanuSingh</title>
      <link>https://dev.to/bhanusingh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bhanusingh"/>
    <language>en</language>
    <item>
      <title>WooCommerce Default Import &amp; Export : How to return error when using woocommerce_product_import_pre_insert_product_object</title>
      <dc:creator>BhanuSingh</dc:creator>
      <pubDate>Fri, 30 Oct 2020 18:48:53 +0000</pubDate>
      <link>https://dev.to/bhanusingh/woocommerce-default-import-export-how-to-return-error-when-using-woocommerceproductimportpreinsertproductobject-bol</link>
      <guid>https://dev.to/bhanusingh/woocommerce-default-import-export-how-to-return-error-when-using-woocommerceproductimportpreinsertproductobject-bol</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pTF_nE4a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/64613859/woocommerce-default-import-export-how-to-return-error-when-using-woocommerce" rel="noopener noreferrer"&gt;
               WooCommerce Default Import &amp;amp; Export : How to return error when using woocommerce_product_import_pre_insert_product_object
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct 30 '20&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 0&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/64613859/woocommerce-default-import-export-how-to-return-error-when-using-woocommerce" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5MiFESHx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rk_a5QFN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;I am adding support to import custom taxonomy in a WooCommerce store.&lt;/p&gt;
&lt;pre class="lang-php prettyprint-override"&gt;&lt;code&gt;function process_import( $object, $data ) {
  if (is_a($object, 'WC_Product')) {
    if (!empty($data['color_tax'])) {
      $object-&amp;gt;save();
      $set_taxonomy = process_taxonomy_save($object, $data['color_tax'], 'color');
     // How to handle an error so that it gets logged
    }
  }
  return $object;
}
add_filter( 'woocommerce_product_import_pre_insert_product_object', __NAMESPACE__.'\\process_import',&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/64613859/woocommerce-default-import-export-how-to-return-error-when-using-woocommerce" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>wordpress</category>
    </item>
    <item>
      <title>Deploying Sage(WordPress Starter theme) to your host using Github Actions</title>
      <dc:creator>BhanuSingh</dc:creator>
      <pubDate>Wed, 05 Aug 2020 18:09:12 +0000</pubDate>
      <link>https://dev.to/bhanusingh/deploying-roots-wordpress-starter-theme-to-your-host-using-github-actions-2648</link>
      <guid>https://dev.to/bhanusingh/deploying-roots-wordpress-starter-theme-to-your-host-using-github-actions-2648</guid>
      <description>&lt;p&gt;I had recently started using &lt;a href="https://roots.io/sage/" rel="noopener noreferrer"&gt;sage&lt;/a&gt; for theme development of a new design upgrade for an old WordPress website. This website was hosted on Digital Ocean droplet having &lt;a href="https://marketplace.digitalocean.com/apps/openlitespeed-wordpress" rel="noopener noreferrer"&gt;OpenLiteSpeed server&lt;/a&gt; installed on it. &lt;/p&gt;

&lt;p&gt;If you look at the &lt;a href="https://roots.io" rel="noopener noreferrer"&gt;roots&lt;/a&gt; ecosystem, you will see that they Trellis project which take care of Production, Staging and Development environments. But in my case I couldn't change the host. To solve this problem I used &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;Github Actions&lt;/a&gt; to setup continuous deployment.&lt;/p&gt;

&lt;h1&gt;
  
  
  Steps Involved
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Setting up Github Repository&lt;/li&gt;
&lt;li&gt;Setting up your host machine&lt;/li&gt;
&lt;li&gt;Command to push code to Host from local&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Setting up Github Repository
&lt;/h3&gt;

&lt;p&gt;I am considering that you have your sage code pushed to your remote github repository.&lt;/p&gt;

&lt;p&gt;We will start by adding actions. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the "Actions" tab in your repository.&lt;/li&gt;
&lt;li&gt;Click on the button "Skip this and set up a workflow yourself -&amp;gt;" next. You will find it in the top section.&lt;/li&gt;
&lt;li&gt;You will be taken to a page where which would be at &lt;code&gt;your-repo/.github/workflows/main.yml&lt;/code&gt;. Change the name of the file to &lt;code&gt;deployment.yml&lt;/code&gt; as we are creating actions to deploy our code.&lt;/li&gt;
&lt;li&gt;Copy the code from below and paste it in your &lt;code&gt;deployment.yml&lt;/code&gt; file.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;In line no. 27 you will have to change the value of &lt;code&gt;dest&lt;/code&gt;. This is what the value of dist will be for you &lt;code&gt;&amp;lt;user&amp;gt;@&amp;lt;host ip&amp;gt;:&amp;lt;path-to-your-theme&amp;gt;&lt;/code&gt;. So for example &lt;code&gt;bhanu@111.11.111.111:/var/www/html/wp-content/themes/theme-name&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;After this is done you have to on "&lt;em&gt;Start Commit&lt;/em&gt;" button and merge it into your master branch.&lt;/li&gt;
&lt;li&gt;You will have to add a secret &lt;code&gt;DEPLOY_KEY&lt;/code&gt; which we will revisit after setting up our host.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Setting up your host machine
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ssh&lt;/code&gt; into your machine. We will create a SSH key and add it our github repository in order for our give our github repository access to our host machine.&lt;/p&gt;

&lt;p&gt;We do this in the following steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"your_email@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to change the email ID to yours. &lt;br&gt;
This will give you some prompts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Generating public/private rsa key pair.
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Enter a file &lt;span class="k"&gt;in &lt;/span&gt;which to save the key &lt;span class="o"&gt;(&lt;/span&gt;/home/you/.ssh/id_rsa&lt;span class="o"&gt;)&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;Press enter]
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Enter passphrase &lt;span class="o"&gt;(&lt;/span&gt;empty &lt;span class="k"&gt;for &lt;/span&gt;no passphrase&lt;span class="o"&gt;)&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;Type a passphrase]
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Enter same passphrase again: &lt;span class="o"&gt;[&lt;/span&gt;Type passphrase again]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have to press enter and skip all of the above. In some cases you may already have an SSH key and you can overwrite it in order to create a fresh one.&lt;/p&gt;

&lt;p&gt;You have now created a new ssh at &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding SSH key to the ssh-agent
&lt;/h4&gt;

&lt;p&gt;Enter the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; Agent pid 59566
ssh-add ~/.ssh/id_rsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to add our public key &lt;code&gt;id_rsa.pub&lt;/code&gt; to the authorized_keys. &lt;/p&gt;

&lt;p&gt;You can do this by.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Getting inside SSH file&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/.ssh/

&lt;span class="c"&gt;# Copying pub key into your clipboard&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;id_rsa.pub
&lt;span class="c"&gt;# This would print the content on the screen which you have to copy&lt;/span&gt;

&lt;span class="c"&gt;# paste the content inside authorized_keys&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;nano authorized_keys
&lt;span class="c"&gt;# To save press Ctrl+X -&amp;gt; y -&amp;gt; Press Enter&lt;/span&gt;

&lt;span class="c"&gt;# Copy the content of public key&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;id_rsa
&lt;span class="c"&gt;# This will paste the content of the public key which you have to copy starting from Start here till the end.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;This is the point where we go back to point 7 of Setting up Github Repository&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In your Github repository you go &lt;br&gt;
-&amp;gt; settings tab&lt;br&gt;
-&amp;gt; Secrets&lt;br&gt;
-&amp;gt; Click on &lt;code&gt;New secret&lt;/code&gt;button&lt;br&gt;
-&amp;gt; Type the name of the secret as &lt;code&gt;DEPLOY_KEY&lt;/code&gt;&lt;br&gt;
-&amp;gt; Paste the content of public key copied above here and hit &lt;code&gt;Add secret&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We are almost done. We just have to test if everything is working fine or not.&lt;/p&gt;

&lt;p&gt;Go to your local development and git push all the changes you want to deploy. When you are satisfied with the changes and you have pushed those in your master branch use this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin master:production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will push all the contents of master branch to production branch.&lt;/p&gt;

&lt;p&gt;Now if you look closely at our &lt;code&gt;deployment.yml&lt;/code&gt; file you can see these lines of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;production&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These lines tells that this action gets triggered when there is a push in the production branch.&lt;/p&gt;

&lt;p&gt;You can look at your progress by going to the &lt;code&gt;Actions&lt;/code&gt; tab. You would see a action is running. You can click on deploy to check the status and log of the same.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpth0cputb5rcifph6pzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpth0cputb5rcifph6pzm.png" alt="Screenshot of a finished deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions regarding this method, or you are stuck somewhere in the process.&lt;/p&gt;

</description>
      <category>wordpress</category>
    </item>
  </channel>
</rss>
