I'm updating a widget plugin I wrote called Feature Me and am adding in WordPress pointers for first time users to help them find the widget after installing the plugin. However, I have come across a problem.
The pointer has to have a target to go to which is either an ID #
or a CLASS .
(that's fine under normal circumstances). But on the widget page, all widgets are prepended with widget-[somenumber]
.
If i know what [somenumber] is I can target it no problem, but 99% of the time, I won't know what the number is since it really depends on the order of the plugin's installation.
On a different website, this is the ID of the widget:
Hopefully you can see my problem.
For context, I'm using this method of displaying the pointer from TutsPlus. Specific function for the above message here:
function fm_message_widget_location( $p ) {
$p['fm_message_widget_location'] = array(
'target' => '#widget-7_feature_me-__i__',
'options' => array(
'content' => sprintf( '<h3> %s </h3> <p> %s </p>',
__( 'Feature Me - Getting Started' ,'plugindomain'),
__( 'Looking for Feature Me? It\'s right here! Drag the widget to create your first call to action!',
'plugindomain')
),
'position' => array( 'edge' => 'left', 'align' => 'middle' )
)
);
return $p;
}
add_filter( 'fm_admin_pointers-widgets', 'fm_message_widget_location' );
This would work fine if my widget was always in the 7th position, but it won't be.
I've attempted to pass through regex for the target, but that doesn't work, I'm assuming because the javascript code treats it as a string.
ie. 'target' => '#widget-[0-9*]_feature_me-__i__'
or 'target' => 'RegExp("#widget-[0-9*]_feature_me-__i__")'
So given all of this, has anyone ever been successful at targeting these individual widget "dragables" with success in their plugins? Any advice/recommendations would be most welcome.