Git vs SVN commands

We use Git and SVN for managing projects.

I personally work on Github, GitLab and BitBucket. I’m more familiar with Git commands.

WordPress itself use the SVN for hosting plugins and themes. I have created a WordPress Theme and Plugins. But, I personally not use SVN though command line.

I personally use Tortoise SVN for managing my theme and plugins. It provides a GUI (Graphic User Interface) which allow working on SVN with a very easy way. Read more about Tortoise SVN.

I was always querying about,

  1. How to work on SVN though command line?
  2. Which are the basic SVN commands like Git?
  3. What is the difference between Git and SVN commands?
  4. etc.

I’ll create an article on all the above questions which I have tried to resolve soon.

For now, I have created a table of Git vs SVN commands. You can also check below the table of Git vs SVN commands for reference.

Description GIT Command SVN Command
Copy a repository git clone svn checkout
Record changes to file history git commit svn commit
View commit details git show svn cat
Confirm status git status svn status
Check differences git diff svn diff
Check log git log svn log
Addition git add svn add
Move git mv svn mv
Delete git rm svn rm
Cancel change git checkout svn revert1
Cancel change git reset svn revert1
Make a branch git branch svn copy2
Switch branch git checkout svn switch
Merge git merge svn merge
Create a tag git tag svn copy2
Update git pull svn update
Update git fetch svn update
It is reflected on the remote git push svn commit
Ignore file list .gitignore .svnignore

 

Get latest stable Plugin or Theme download zip URL from wp.org

Plugin Download URL

You can add a download button on your website with the link of latest plugin zip. So, Your users always get the latest zip of your plugin which is hosted on wp.org.

Stable plugin download zip URL is:

https://downloads.wordpress.org/plugin/{plugin-slug}.latest-stable.zip

Note: You need to use the plugin slug for {plugin-slug}.

How to find the plugin slug?

Visit any WordPress plugin page.

E.g. If you visit the plugin page Sample Data.
This page URL is https://wordpress.org/plugins/sample-data/

So, Plugin slug is sample-data
And its latest plugin download link is:
https://downloads.wordpress.org/plugin/sample-data.latest-stable.zip

Note: Plugin name and plugin slug is not always the same.

Another example, If you visit the plugin page Bulk Clean.
This page URL is https://wordpress.org/plugins/easy-clean/

So, Plugin slug is easy-clean
And its latest plugin download link is:
https://downloads.wordpress.org/plugin/easy-clean.latest-stable.zip

Some more plugin examples:

  1. Contact Form 7
    https://downloads.wordpress.org/plugin/contact-form-7.latest-stable.zip
  2. Bulk Clean
    https://downloads.wordpress.org/plugin/easy-clean.latest-stable.zip
  3. Copy Anything to Clipboard
    https://downloads.wordpress.org/plugin/copy-the-code.latest-stable.zip
  4. Free Images
    https://downloads.wordpress.org/plugin/free-images.latest-stable.zip
  5. Sample Data
    https://downloads.wordpress.org/plugin/sample-data.latest-stable.zip
  6. Site Reset
    https://downloads.wordpress.org/plugin/site-reset.latest-stable.zip

Theme Download URL

Same like a plugin, You can add a download button on your website with the link of your latest theme zip. So, Your users always get the latest zip of your theme which is hosted on wp.org.

Stable theme download zip URL is:

https://downloads.wordpress.org/theme/{theme-slug}.latest-stable.zip

Note: You need to use the theme slug for {theme-slug}.

How to find the theme slug?

Same as the plugin, Visit any WordPress theme.

If you visit the theme Bhari
This page URL is https://wordpress.org/themes/bhari/

So, Theme slug is bhari
https://downloads.wordpress.org/theme/bhari.latest-stable.zip

Some more theme examples:

  1. Bhari
    https://downloads.wordpress.org/theme/bhari.latest-stable.zip
  2. Twenty Twelve
    https://downloads.wordpress.org/theme/twentytwelve.latest-stable.zip
  3. Twenty Sixteen
    https://downloads.wordpress.org/theme/twentysixteen.latest-stable.zip
  4. Twenty Seventeen
    https://downloads.wordpress.org/theme/twentyseventeen.latest-stable.zip
  5. Twenty Nineteen
    https://downloads.wordpress.org/theme/twentynineteen.latest-stable.zip

Multisite Support for Site Metadata in WordPress 5.1

Quick Highlights:

  • WordPress multisite introduces a new database table wp_blogmeta to store metadata associated with sites. This allows for the storage of arbitrary site data relevant in a multisite/network context.

  • It provides an alternative to using options and can be retrieved from multiple sites in a more performant way—without calling  switch_to_blog(). Sites can now also be queried by their meta with parameters supported by WP_Meta_Query.

  • Note: A network update is required to install the new database table.

  • New API functions:
get_site_meta( $id, $meta_key, $single )
update_site_meta( $id, $meta_key, $meta_value, $prev_value )
add_site_meta( $id, $meta_key, $meta_value, $unique )
delete_site_meta( $id, $meta_key, $meta_value )

All of these functions are ONLY available in multisite, however they work similarly to other metadata wrapper functions, such as for posts, terms, comments and users. In addition to these functions, it is now possible to use the common meta query arguments when querying sites with  WP_Site_Query or its wrapper  get_sites().


Read more at https://make.wordpress.org/core/2019/01/28/multisite-support-for-site-metadata-in-5-1/

PHP 5.6 is the intended version from WordPress 5.1

Quick Highlights:

Warning about outdated PHP version in WordPress backend

  • Provided filter wp_update_php_url for a more dynamic approach on the code level. Replacing the URL should happen in cases where a more specific guide to update PHP on the given environment exists. E.g. screenshot:
Warning about outdated PHP version with custom URL and related annotation

  • Fatal Error Protection with the so-called WSOD protection (white-screen-of-death protection), A mechanism has been implemented to detect fatal errors and, in certain designated areas of WordPress, recover from them. E.g. Screenshot.
Default output in the frontend when WSOD protection detects has detected an error

Note that, while the primary reason for implementing the fatal error protection mechanism was making the process of updating PHP less “dangerous”, it is technically not tied to the update at all. In fact, it will be enabled permanently and discover fatal errors under any circumstances.


  • The functionality can also be disabled entirely if that is preferred, via a new constant WP_DISABLE_FATAL_ERROR_HANDLER or, more dynamically, a corresponding wp_fatal_error_handler_enabled filter.

  • WordPress 5.1 will display a warning for those plugins that require a higher PHP version than the one currently active.

Read more at https://make.wordpress.org/core/2019/01/14/php-site-health-mechanisms-in-5-1/

Setup WP CLI (WordPress Command Line Interface) on Windows Operating System

Step 1

Create folder wp-cli in C drive.

Step 2

Download wp-cli.phar from https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Step 3

Move downloaded wp-cli.phar file in C:\wp-cli\

Step 4

Create wp.bat file in C:\wp-cli\ and write below code in it.

@ECHO OFF
php "C:\wp-cli\wp-cli.phar" %*

Or download file from gist https://gist.github.com/maheshwaghmare/848b5a9f21f27239600cf08693a0bedb

Step 5

Open system environment and set C:\wp-cli as environment path.

Done!


Open Command Prompt and type command wp and press Enter. It’ll show you the like the below screenshot.

WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

Sorry, this file type is not permitted for security reasons due to WordPress 5.0.1 MIME validation for uploaded files fix for wp_handle_sideload()

If you have used function wp_handle_sideload() in any of your plugin/theme then you need to pass the mimes types too.

Because WordPress 5.0.1 Security Released. In which the uploaded files are validated with the real MIME type.

E.g. If you have set the application/xml MIME type though filter upload_mimes to upload the XML file and if the real MIME type of uploaded file is text/xml then the file was not uploaded. And it shows the below message.

Sorry, this file type is not permitted for security reasons.


To fix this you need to set the mimes for function wp_handle_sideload().

Check below code for reference.

For more details visit:

https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/

https://wordpress.org/news/2018/12/wordpress-5-0-1-security-release/