Using absint() in WordPress

It convert a value to non-negative integer.

Internally this function used abs( intval( $maybeint ) ).


You can try below examples yourself.

Examples Output var_dump
absint( 0 ) 0 int(0)
absint( '0' ) 0 int(0)
absint( 1 ) 1 int(1)
absint( '8' ) 8 int(8)
absint( -27 ) 27 int(27)
absint( '-8' ) 8 int(8)
absint( 'abc' ) 0 int(0)
echo absint( 0 );
// Output: 0 
// var_dump() int(0)

echo absint( '0' );
// Output: 0 
// var_dump() int(0)

echo absint( 1 );
// Output: 1 
// var_dump() int(1)

echo absint( '8' );
// Output: 8 
// var_dump() int(8)

echo absint( -27 );
// Output: 27 
// var_dump() int(27)

echo absint( '-8' );
// Output: 8 
// var_dump() int(8)

echo absint( 'abc' );
// Output: 0 
// var_dump() int(0)

Advertisements

Finally plugin Sample Data approved!

You can now download the Theme Unit Test for testing your theme or import the WooCommercebbPress plugin sample data with simple ONE click using WordPress plugin Sample Data.

Note: Use Sample Data plugin on your testing/staging environment.

Quick Start:

Follow below simple steps to import the dummy content:

  • Install & Activate plugin.
  • Click on Get Started » from plugin/theme. It read the file and get import content.
  • Click on Start Import and confirm to import the data.
  • For more details check below screenshots or youtube video.

Screenshots:

screenshot-1
Step 1: Install & Activate plugin
screenshot-2
Step 2: Click on `Get Started`
screenshot-3
Step 3: It get the content from file
screenshot-4
Step 4: Click on `Start Import`
screenshot-5
Step 5: Click `Ok` to confirm import
screenshot-6
Step 6: Import Started!
screenshot-7
Step 7: Import Completed!
screenshot-8
Step 8: Imported Contents.

Plugin import the data form the XML file. For now plugin added in-build support for:

  • Theme Unit Test Data
  • WooCommerce
  • bbPress

Do you want another plugin support? Request for support »

Do you know coding? Let’s fork & extend it from Github.

You can download it from wp.orgVisit plugin page Sample Data.

Importing Theme Unit Test Data

Importing Theme Unit Test Data in WordPress with one click.

1) Quick Import:

I have created a simple plugin which imports the Theme Unit Test Data on your site within a few minutes. Check below video:

The plugin will approve on wp.org in this week. For now, you can download it from Github repo Sample Data.

Click on the download plugin to download.


2) Manual Download

  1. Clone the theme test data file themeunittestdata.wordpress.xml from the GitHub repository https://github.com/WPTRT/theme-unit-test (last updated 18/Apr/2017) Or Download a copy from https://raw.githubusercontent.com/WPTRT/theme-unit-test/master/themeunittestdata.wordpress.xml
  2. Import test data into your WordPress install by going to Tools => Import => WordPress
  3. Select the XML file from your computer
  4. Click on “Upload file and import”.
  5. Under “Import Attachments,” check the “Download and import file attachments” box and click submit.
    Note: you may have to repeat the Import step until you see “All Done” to obtain the full list of Posts and Media.
  6. Read Becoming a reviewer, and follow the easy steps.

Source Theme Unit Test

Importing bbPress dummy data

Import the bbPress sample data with one click.

1) Quick Import:

I have created a simple plugin which imports the bbPress dummy data on your site within a few minutes. Check below video:

The plugin will approve on wp.org in this week. For now, you can download it from Github repo Sample Data.

Click on the download plugin to download.


2) Manual Download

You can acquire the file from this trac. ticket here. If you want to directly download the file click here.

  1. Go to Tools > Import.
  2. Go all the way down to where it says WordPress and click the link.
  3. If you haven’t installed the WordPress importer plugin already, click Install Now.
  4. If you have the WordPress Importer plugin installed and activated, proceed to the import process.
  5. Click the Choose File button, now select the file you just downloaded before.
  6. Click Upload file and import.
  7. You can now assign the posts to a specific user of your choice and check Import Attachments
  8. Now click Submit
  9. After that, it should import all of the posts in the file and tell you that it is done at the very bottom.

Source Creating Test Data

 

Envato Elements – Template Kits (Beta)

Envato released the plugin Envato Elements – Template Kits (Beta) plugin to import the templates. It supports now for Elementor & Beaver Builder page builder.

Plugin URL: https://wordpress.org/plugins/envato-elements/

How to find broken links of website using command line interface (CLI) (Using wget)

Check the broken links on website using. Try below example command which generate the wget.log it list all the broken links.

  1. Download & Install wget
  2. Add the installation directory to PATH:
    C:\Program Files (x86)\GnuWin32\bin

Syntax:

wget -o wget.log -r -l 10 --spider http://example.com

Usage:

wget -o wget.log -r -l 10 --spider https://maheshwaghmare.wordpress.com --no-check-certificate

Output:

Spider mode enabled. Check if remote file exists.
--2018-06-29 10:11:59-- https://maheshwaghmare.wordpress.com/
Connecting to maheshwaghmare.wordpress.com|192.0.78.12|:443... connected.
WARNING: cannot verify maheshwaghmare.wordpress.com's certificate, issued by `/C=US/ST=Arizona/L=Scottsdale/O=GoDaddy.com, Inc./OU=http://certs.godaddy.com/repository//CN=Go Daddy Secure Certificate Authority - G2':
Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `maheshwaghmare.wordpress.com/index.html'

0K .......... .......... .......... .......... .......... 318K
50K .......... .......... .......... .......... .......... 80.5K
100K .......... .......... .......... .......... .......... 664K
150K .......... .......... .......... .......... .......... 2.07M
200K ..... 5.80M=0.9s

2018-06-29 10:12:01 (234 KB/s) - `maheshwaghmare.wordpress.com/index.html' saved [210113]

Check which template loading in WordPress site

Below is the simple function which you can use for debugging the site. It  display the template file path of the current page. Like below image:

Add below code snippet into your themes functions.php file.