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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if (! class_exists ( 'PostmanAdminPointer' )) {
/**
* From http://code.tutsplus.com/articles/integrating-with-wordpress-ui-admin-pointers--wp-26853
*
* @author jasonhendriks
*
*/
class PostmanAdminPointer {
private $logger;
private $rootPluginFilenameAndPath;
/**
*
* @param mixed $rootPluginFilenameAndPath
*/
function __construct($rootPluginFilenameAndPath) {
$this->logger = new PostmanLogger ( get_class ( $this ) );
$this->rootPluginFilenameAndPath = $rootPluginFilenameAndPath;
// Don't run on WP < 3.3
if (get_bloginfo ( 'version' ) < '3.3' || true)
return;
add_action ( 'admin_enqueue_scripts', array (
$this,
'wptuts_pointer_load'
), 1000 );
add_filter ( 'postman_admin_pointers-settings_page_postman', array (
$this,
'wptuts_register_pointer_testing'
) );
}
/**
*
* @param mixed $hook_suffix
*/
function wptuts_pointer_load($hook_suffix) {
// only do this for administrators
if (PostmanUtils::isAdmin ()) {
$this->logger->trace ( 'wptuts' );
$screen = get_current_screen ();
$screen_id = $screen->id;
// Get pointers for this screen
$pointers = apply_filters ( 'postman_admin_pointers-' . $screen_id, array () );
if (! $pointers || ! is_array ( $pointers ))
return;
// Get dismissed pointers
$dismissed = explode ( ',', ( string ) get_user_meta ( get_current_user_id (), 'dismissed_wp_pointers', true ) );
$this->logger->trace ( $dismissed );
$valid_pointers = array ();
// Check pointers and remove dismissed ones.
foreach ( $pointers as $pointer_id => $pointer ) {
// Sanity check
if (in_array ( $pointer_id, $dismissed ) || empty ( $pointer ) || empty ( $pointer_id ) || empty ( $pointer ['target'] ) || empty ( $pointer ['options'] ))
continue;
$pointer ['pointer_id'] = $pointer_id;
// Add the pointer to $valid_pointers array
$valid_pointers ['pointers'] [] = $pointer;
}
// No valid pointers? Stop here.
if (empty ( $valid_pointers )) {
return;
}
// Add pointers style to queue.
wp_enqueue_style ( 'wp-pointer' );
// Add pointers script to queue. Add custom script.
wp_enqueue_script ( 'postman_admin_pointer', plugins_url ( 'script/postman-admin-pointer.js', $this->rootPluginFilenameAndPath ), array (
'wp-pointer'
) );
// Add pointer options to script.
wp_localize_script ( 'postman_admin_pointer', 'postman_admin_pointer', $valid_pointers );
$this->logger->trace ( 'out wptuts' );
}
}
function wptuts_register_pointer_testing($p) {
// only do this for administrators
if (PostmanUtils::isAdmin () && false) {
$p ['postman16_log'] = array (
'target' => '.configure_manually',
'options' => array (
'content' => '',
'position' => array (
'edge' => 'top',
'align' => 'left'
)
)
);
return $p;
}
}
}
}
|