-
Notifications
You must be signed in to change notification settings - Fork 4
/
pinim-dummy-importer.php
69 lines (54 loc) · 1.77 KB
/
pinim-dummy-importer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
* Register pinim in Tools > Import
* But redirects it to the Tools > Pinterest Importer page
*
*/
class Pinim_Dummy_Importer {
/**
* @var The one true Instance
*/
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new Pinim_Dummy_Importer;
self::$instance->init();
}
return self::$instance;
}
private function __construct() { /* Do nothing here */ }
function init(){
add_action( 'admin_init', array($this,'register_importer') );
add_action( 'admin_init', array( $this, 'auto_redirect' ) );
}
function register_importer(){
register_importer(
'pinim',
__('Pinterest', 'pinim'),
__('Install the Pinterest importer to import pins from Pinterest and convert them into Wordpress posts.', 'pinim'),
array ($this, 'dispatch')
);
}
function dispatch(){
$url = pinim_get_menu_url(array('page'=>'boards'));
printf(__('You should be redirected to <a href="%1$s">the Pinterest Importer page</a>.',"pinim"),$url);
die();
}
function is_importer_page(){
global $pagenow;
if (($pagenow == 'admin.php') && isset($_REQUEST['import']) && ($_REQUEST['import']=='pinim')) return true;
return false;
}
function auto_redirect(){
if (!$this->is_importer_page()) return false;
$url = pinim_get_menu_url(array('page'=>'account'));
wp_redirect( $url );
die();
}
}
function pinim_dummy_importer() {
return Pinim_Dummy_Importer::instance();
}
if (is_admin()){
pinim_dummy_importer();
}