From 6729ba6219b0f3de105e65c36bd021ee55c38b6d Mon Sep 17 00:00:00 2001 From: bfintal Date: Mon, 30 Sep 2013 23:08:12 +0800 Subject: [PATCH 1/2] PHP error fix + more Fixed PHP undefined variable error. Enhancements: if screen is not specified, pointer is displayed in all screens. If no id is specified, a unique id is generated. --- class.wp-help-pointers.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/class.wp-help-pointers.php b/class.wp-help-pointers.php index 1ea255c..2dc6b4f 100644 --- a/class.wp-help-pointers.php +++ b/class.wp-help-pointers.php @@ -59,7 +59,19 @@ public function __construct( $pntrs = array() ) { public function register_pointers( $pntrs ) { + $pointers = $this->pointers; + foreach( $pntrs as $ptr ) { + + // show in all screens if not specified + if ( empty($ptr['screen']) ) { + $screen = get_current_screen(); + $ptr['screen'] = $screen->id; + } + // if no id is specified, generate a unique one + if ( empty($ptr['id']) ) { + $ptr['id'] = md5( $ptr['title'] . $ptr['content'] ); + } if( $ptr['screen'] == $this->screen_id ) { @@ -78,7 +90,7 @@ public function register_pointers( $pntrs ) { } } - $this->pointers = $pointers; + $this->pointers = $pointers; } @@ -151,4 +163,4 @@ function wp_help_pointer_open(i) { } -} // end class +} // end class \ No newline at end of file From 86a3841bd0ad7ed70895529df342133846323490 Mon Sep 17 00:00:00 2001 From: bfintal Date: Mon, 30 Sep 2013 23:39:37 +0800 Subject: [PATCH 2/2] removed __() function it's only recommended to use __() on static strings --- class.wp-help-pointers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class.wp-help-pointers.php b/class.wp-help-pointers.php index 2dc6b4f..2e5f9bd 100644 --- a/class.wp-help-pointers.php +++ b/class.wp-help-pointers.php @@ -80,8 +80,8 @@ public function register_pointers( $pntrs ) { 'target' => $ptr['target'], 'options' => array( 'content' => sprintf( '

%s

%s

', - __( $ptr['title'] , 'plugindomain' ), - __( $ptr['content'], 'plugindomain' ) + $ptr['title'], + $ptr['content'] ), 'position' => $ptr['position'] )