How to Delete Hidden Files on Mac

Go to the directory –

find . -name '*.DS_Store' -type f -delete

or,

sudo find / -name .DS_Store -delete;

To remove .git file –

rm -rf .git

How to Update WPCS with Composer?

composer global require squizlabs/php_codesniffer
composer global require wp-coding-standards/wpcs
composer global require phpcompatibility/php-compatibility
composer global require dealerdirect/phpcodesniffer-composer-installer
phpcbf
phpcs
How to Add SSH Key to GitLab?

How to Add SSH Key to GitLab?

It’s very important to add an SSH key to GitLab to work on a remote project what is hosted on GitLab. Let see how we can do that –
We working on a Mac to set up this key –
1. Go to your terminal and write the command below –

ssh-keygen -t rsa -C "[email protected]"

Press Enter (to make a file with the default name)
Type ‘y’ (to overwrite
Press Enter (to skip passphrase)
2. To see the generated key type :

cat ~/.ssh/id_rsa.pub

Copy the key and paste it to your GitLab profile.

Done πŸ™‚

Now start pull / push / clone etc. commands.

How to Use zsh Alias

It’s very convenient to use an alias instead of full command. So, let’s see how we can make some aliases for git command –

To make an alias, open the terminal and write the command below –

vi ~/.zshrc

Write some aliases –

alias gs=”git status”
alias ga=”git add”
alias gm=”git commit -m”
alias bci=”brew cask install”

Colse and save the vim with clicking esc button and :wq

To make your created aliases work, run the command below –

source ~/.zshrc

Done. Now you can use the aliases you made as many times as you want.

Happy coding!

FB Video Showing

<div class="fb-video"
  data-href="https://www.facebook.com/Sixers/videos/10155469471232516/"
  data-width="500"
  data-allowfullscreen="true"></div>

  <!-- Load Facebook SDK for JavaScript -->
  <script>(function(d, s, id) {
	var js, fjs = d.getElementsByTagName(s)[0];
	if (d.getElementById(id)) return;
	js = d.createElement(s); js.id = id;
	js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6";
	fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>

PHP Tricks

  1. To see the var_dump output with decoration see below –
echo '<pre>', var_dump( $style_post ), '</pre>';

How to Show Admin Notice on Plugin Activation?

1. Add the code in the Notice Class like Below –

	/**
	 * Set transient only when the plugin is activated.
	 *
	 * @since 3.0.2
	 * @return void
	 */
	public static function add_the_transient() {
	    /* Create transient data */
	    set_transient( 'prefix-activation-notice', true, 5 );

	}
	/**
	 * Admin Notice on Activation.
	 *
	 * @since 3.0.2
	 * @return void
	 */
	public function add_activation_notice() {
		$itesm = get_posts( array( 'post_type' => 'my_post_type' ) );
		if ( count( $items ) > 0 ) {
			/* Check transient, if available display notice */
			if ( get_transient( 'prefix-activation-notice' ) ) {
				?>
				<div class="updated notice is-dismissible">
				<p>Thank you for using this plugin! <strong>You are awesome</strong>.</p>
				</div>
				<?php
				/* Delete transient, only display this notice once. */
				delete_transient( 'prefix-activation-notice' );
			}
		}
	}

Read More “How to Show Admin Notice on Plugin Activation?”

WPCS with Visual Studio Code

Installation

The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands:
# Download using curl
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar

# Or download using wget
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar

# Then test the downloaded PHARs
php phpcs.phar -h
php phpcbf.phar -h

Composer Read More “WPCS with Visual Studio Code”

Common Git Commands

Common Git Commands

Go to the directory you want to initiate GitΒ and then follow the commands:

  1. Initiate the git:
    git init
  2. Remove Git if you have initiated in a wrong place ( Be aware if there is another git in the subdirectory):
    rm -rf .git
  3. To add all the files(including subdirectory) to the staging step:
    git add .
    Or,
    git add -A
  4. Git branch –
    a. Create a new one from the current branch and Checkout to the new branch:
    git checkout -b newBranch
    b. Delete a branch branch:
    git branch -d branchName
    
  5. Merge master to development branch –
    1. //pull the latest changes of current development branch if any 
    git pull (current development branch)

    2. //switch to master branch
    git checkout master

    3. //pull all the changes if any
    git pull

    4. //Now merge development into master
    git merge develop

    5. //push the master branch
    git push origin master