Skip to content

Commit 8fecee9

Browse files
committed
Merge pull request #53 from Codeinwp/development
!!!update
2 parents 7f454e0 + 16a9fbe commit 8fecee9

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,30 @@ public function __construct( Visualizer_Plugin $plugin ) {
6262
$this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
6363
$this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
6464
$this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
65+
$this->_addFilter( 'visualizer_admin_pointers', 'visualizerAdminPointers', 10, 2 );
66+
}
67+
68+
/**
69+
* Returns wp pointers for visualizer
70+
*
71+
* @since 1.5
72+
*
73+
* @static
74+
* @access private
75+
* @return array The associated array of pointer
76+
*/
77+
function visualizerAdminPointers( $p ) {
78+
$p['visualizer'] = array(
79+
'target' => '#menu-media',
80+
'options' => array(
81+
'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
82+
__( 'Visualizer New Features ' , Visualizer_Plugin::NAME),
83+
__( 'Right now the Visualizer Charts and Graphics plugin integrates a live editor and a new importing option for your charts. ',Visualizer_Plugin::NAME)
84+
),
85+
'position' => array( 'edge' => 'top', 'align' => 'middle' )
86+
)
87+
);
88+
return $p;
6589
}
6690

6791
/**
@@ -186,6 +210,46 @@ public function enqueueLibraryScripts( $suffix ) {
186210
wp_enqueue_script( 'google-jsapi', '//www.google.com/jsapi', array(), null, true );
187211
wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi', 'visualizer-library' ), Visualizer_Plugin::VERSION, true );
188212
}
213+
if ( get_bloginfo( 'version' ) < '3.3' )
214+
return;
215+
216+
217+
// Get pointers for this screen
218+
$pointers = apply_filters( 'visualizer_admin_pointers', array() );
219+
220+
if ( ! $pointers || ! is_array( $pointers ) )
221+
return;
222+
223+
// Get dismissed pointers
224+
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
225+
$valid_pointers =array();
226+
// Check pointers and remove dismissed ones.
227+
foreach ( $pointers as $pointer_id => $pointer ) {
228+
229+
// Sanity check
230+
if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) )
231+
continue;
232+
233+
$pointer['pointer_id'] = $pointer_id;
234+
235+
// Add the pointer to $valid_pointers array
236+
$valid_pointers['pointers'][] = $pointer;
237+
}
238+
239+
// No valid pointers? Stop here.
240+
if ( empty( $valid_pointers ) )
241+
return;
242+
243+
// Add pointers style to queue.
244+
wp_enqueue_style( 'wp-pointer' );
245+
// Add pointers script to queue. Add custom script.
246+
wp_enqueue_script( 'visualizer-pointer', VISUALIZER_ABSURL."js/visualizer-pointer.js", array( 'wp-pointer' ),Visualizer_Plugin::VERSION );
247+
248+
// Add pointer options to script.
249+
wp_localize_script( 'visualizer-pointer', 'visualizer', $valid_pointers );
250+
251+
252+
189253
}
190254

191255
/**

js/visualizer-pointer.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
jQuery(document).ready( function($) {
2+
visualizer_pointer_open_pointer(0);
3+
function visualizer_pointer_open_pointer(i) {
4+
pointer = visualizer.pointers[i];
5+
options = $.extend(pointer.options, {
6+
close: function () {
7+
$.post(ajaxurl, {
8+
pointer: pointer.pointer_id,
9+
action: 'dismiss-wp-pointer'
10+
});
11+
}
12+
});
13+
$(pointer.target).pointer(options).pointer('open');
14+
}
15+
});

0 commit comments

Comments
 (0)