RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.38% (6.14%*) • Home Loan Fixed: 5.44% (6.26%*) • Fixed: 5.44% (6.26%*) • Variable: 5.38% (6.14%*) • Investment IO: 5.69% (6.52%*) • Investment PI: 5.49% (5.98%*)

Display WordPress Import Plugins With Shortcode

Display WordPress Import Plugins With Shortcode

One of the APIs on the WordPress website returns a list of third-party import tools. If you're in the web business, the list might come in handy as something you can render on your website. The shortcode function (and PHP function) on this page will do nothing other than display them in a list. We list them on our reference page (as a reference for us as much as our clients).

The Result

The shortcode of [wpimporters] returns the following list of plugins.

  • Blogger
    Install the Blogger importer to import posts, comments, and users from a Blogger blog.
    [ Plugin Page ] [ Download ]
  • Categories and Tags Converter
    Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.
    [ Plugin Page ] [ Download ]
  • LiveJournal
    Install the LiveJournal importer to import posts from LiveJournal using their API.
    [ Plugin Page ] [ Download ]
  • Movable Type and TypePad
    Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.
    [ Plugin Page ] [ Download ]
  • Blogroll
    Install the blogroll importer to import links in OPML format.
    [ Plugin Page ] [ Download ]
  • RSS
    Install the RSS importer to import posts from an RSS feed.
    [ Plugin Page ] [ Download ]
  • Tumblr
    Install the Tumblr importer to import posts & media from Tumblr using their API.
    [ Plugin Page ] [ Download ]
  • WordPress
    Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.
    [ Plugin Page ] [ Download ]

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

1
<?php 
2
/*
3
 Display WordPress Import Plugins With Shortcode
4
 http://www.beliefmedia.com/wordpress-import-plugins
5
*/
6
 
7
8
 
9
  $atts = shortcode_atts(array(
10
    'cache_temp' => 600,
11
    'cache' => 3600 * 24 * 14
12
  ), $atts);
13
 
14
 $transient = 'wpimp_' . md5(serialize($atts));
15
 $cached_data = get_transient($transient);
16
 
17
 if ($cached_data !== false) {
18
 $return = $cached_data;
19
 
20
  } else {
21
 
22
     $data = @file_get_contents('https://api.wordpress.org/core/importers/1.1/');
23
 
24
     if ($data !== false) {
25
 
26
       $data = json_decode($data, true);
27
 
28
         if ($data !== false) {
29
 
30
           $importers = $data['importers'];
31
 
32
             foreach ($importers AS $import) {
33
               $result .= '
34
<li><span style="font-weight: bold;">' . $import['name'] . '</span><span style="font-size: 0.9em";>' . $import['description'] . '[ <a href="https://wordpress.org/plugins/' . $import['plugin-slug'] . '/">Plugin Page</a> ] [ <a href="https://downloads.wordpress.org/plugin/' . $import['plugin-slug'] . '.zip">Download</a> ]</span></li>
35
 
36
';
37
             }
38
 
39
           $return = '
40
<ul>' . $result . '</ul>
41
 
42
';
43
 
44
           /* Set transient */
45
           set_transient($transient, $return, $atts['cache']);
46
 
47
           } else {
48
 
49
           $return = '
50
<ul>
51
<li>Importer list temporarily unavailable.</li>
52
</ul>
53
 
54
';
55
 
56
           /* Set temp transient */
57
           set_transient($transient, $return, $atts['cache_temp']);
58
 
59
         }
60
 
61
     }
62
 
63
  }
64
 
65
 return $return;
66
}
67
add_shortcode('wpimporters','beliefmedia_wordpress_importers');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

PHP Function

Used outside of WordPress the following function may be used. Usage requires Simple Cache.

1
<?php 
2
/*
3
 Display WordPress Import Plugins With PHP
4
 http://www.beliefmedia.com/wordpress-import-plugins
5
*/
6
 
7
8
 
9
  $atts = array(
10
    'cache_temp' => 600,
11
    'cache' => 3600 * 24 * 14
12
  );
13
 
14
 $transient = 'wp_importers_' . md5(serialize($atts));
15
 $cached_data = beliefmedia_get_transient($transient, $atts['cache']);
16
 
17
 if ($cached_data !== false) {
18
 $return = $cached_data;
19
 
20
  } else {
21
 
22
     $data = @file_get_contents('https://api.wordpress.org/core/importers/1.1/');
23
 
24
     if ($data !== false) {
25
 
26
       $data = json_decode($data, true);
27
 
28
         if ($data !== false) {
29
 
30
           $importers = $data['importers'];
31
 
32
             foreach ($importers AS $import) {
33
               $result .= '
34
<li><span style="font-weight: bold;">' . $import['name'] . '</span><span style="font-size: 0.9em";>' . $import['description'] . '[ <a href="https://wordpress.org/plugins/' . $import['plugin-slug'] . '/">Plugin Page</a> ] [ <a href="https://downloads.wordpress.org/plugin/' . $import['plugin-slug'] . '.zip">Download</a> ]</span></li>
35
 
36
';
37
             }
38
 
39
           $return = '
40
<ul>' . $result . '</ul>
41
 
42
';
43
 
44
           /* Set transient */
45
           beliefmedia_set_transient($transient, $return);
46
 
47
           } else {
48
 
49
           $return = beliefmedia_get_transient_data($transient);
50
 
51
         }
52
 
53
     }
54
 
55
  }
56
 
57
 return $return;
58
}
59
 
60
/* Usage */
61

Download


Title: Display WordPress Import Plugins (WP Plugin)
Description: Display WordPress Import Plugins With Shortcode (or PHP).
  Download • Version 0.1, 1.6K, zip, Category: WordPress Plugins (General)
WordPress Shortcodes, (867.0B)    PHP Code & Snippets, (845.0B)    

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment