Page scroll to id - Version 1.5.9

Version Description

  • Extended ps2id shortcode for creating div elements (in addition to anchors).
  • Added ps2id_wrap shortcode for creating target wrappers in content editor.
  • Extended offset selector expressions with :position, :height() and :width().
  • Updated readme.txt.
  • Updated help.
Download this release

Release Info

Developer malihu
Plugin Icon 128x128 Page scroll to id
Version 1.5.9
Comparing to
See all releases

Code changes from version 1.5.8 to 1.5.9

includes/help/plugin-settings.inc CHANGED
@@ -39,6 +39,17 @@ $help_plugin_settings_text=<<<EOD
39
  You may also define link specific offsets by using the <code>ps2id</code> shortcode in your content, e.g. <code>[ps2id url='#id' offset='100']link[/ps2id]</code>.
40
  </p>
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  <p>
43
  <strong>Highlight selector(s)</strong> -
44
  The matching set of elements already handled by the plugin (defined in Selector(s) field) that will be highlighted. <br />
39
  You may also define link specific offsets by using the <code>ps2id</code> shortcode in your content, e.g. <code>[ps2id url='#id' offset='100']link[/ps2id]</code>.
40
  </p>
41
 
42
+ <p>
43
+ The plugin offers few extra selector expressions in order to define more advanced offsets. Examples:
44
+ </p>
45
+
46
+ <ul>
47
+ <li>Offset by element with id "some-id" and CSS position fixed: <code>#some-id:fixed</code> </li>
48
+ <li>Offset by element with class "class-name" and height equal to 100 pixels: <code>.class-name:height(100)</code> </li>
49
+ <li>Offset by element with id "some-id" and width greater than 800 pixels: <code>#some-id:width(>800)</code> </li>
50
+ <li>Offset by element with id "some-id", CSS position fixed and height between 50 and 100 pixels: <code>#some-id:fixed:height(>50):height(<100)</code> </li>
51
+ </ul>
52
+
53
  <p>
54
  <strong>Highlight selector(s)</strong> -
55
  The matching set of elements already handled by the plugin (defined in Selector(s) field) that will be highlighted. <br />
includes/help/shortcodes.inc CHANGED
@@ -26,7 +26,7 @@ $help_shortcodes_text=<<<EOD
26
  </ul>
27
 
28
  <p>
29
- <strong>Create target</strong> - <code>[ps2id id='#id' target='']</code>
30
  </p>
31
 
32
  <p>
@@ -47,6 +47,16 @@ $help_shortcodes_text=<<<EOD
47
  </li>
48
  </ul>
49
 
 
 
 
 
 
 
 
 
 
 
50
  EOD;
51
  ?>
52
 
26
  </ul>
27
 
28
  <p>
29
+ <strong>Create target</strong> - <code>[ps2id id='id' target='']</code>
30
  </p>
31
 
32
  <p>
47
  </li>
48
  </ul>
49
 
50
+ <p>
51
+ <strong>Create target wrapper</strong> - <code>[ps2id_wrap id='id']content[/ps2id_wrap]</code>
52
+ </p>
53
+
54
+ <p>
55
+ Examples: <br />
56
+ <code>[ps2id_wrap id='some-id'] content... [/ps2id_wrap]</code> <br />
57
+ <code>[ps2id_wrap id='another-id'] content... [ps2id url='#id']link[/ps2id] [/ps2id_wrap]</code>
58
+ </p>
59
+
60
  EOD;
61
  ?>
62
 
includes/help/sidebar.inc CHANGED
@@ -3,8 +3,11 @@ $help_sidebar_text=<<<EOD
3
 
4
  <p><strong>For more information</strong></p>
5
 
6
- <p><a href="http://manos.malihu.gr/page-scroll-to-id" target="_blank">Plugin homepage</a> <br />
7
- <a href="http://manos.malihu.gr/page-scroll-to-id/2/" target="_blank">Code examples &amp; short tutorials</a></p>
 
 
 
8
 
9
  EOD;
10
  ?>
3
 
4
  <p><strong>For more information</strong></p>
5
 
6
+ <ul>
7
+ <li><a href="http://manos.malihu.gr/page-scroll-to-id-for-wordpress-tutorial/" target="_blank">Page scroll to id for WordPress tutorial</a></li>
8
+ <li><a href="http://manos.malihu.gr/page-scroll-to-id" target="_blank">Plugin homepage</a></li>
9
+ <li><a href="http://manos.malihu.gr/page-scroll-to-id/2/" target="_blank">Code examples &amp; short tutorials</a></li>
10
+ </ul>
11
 
12
  EOD;
13
  ?>
js/jquery.malihu.PageScroll2id-init.js CHANGED
@@ -79,4 +79,24 @@
79
  }
80
  }
81
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  })(jQuery);
79
  }
80
  }
81
  });
82
+ //extend jQuery's selectors
83
+ $.extend($.expr[":"],{
84
+ //position based - e.g. :fixed
85
+ absolute:$.expr[":"].absolute || function(el){return $(el).css("position")==="absolute";},
86
+ relative:$.expr[":"].relative || function(el){return $(el).css("position")==="relative";},
87
+ static:$.expr[":"].static || function(el){return $(el).css("position")==="static";},
88
+ fixed:$.expr[":"].fixed || function(el){return $(el).css("position")==="fixed";},
89
+ //width based - e.g. :width(200), :width(>200), :width(>200):width(<300) etc.
90
+ width:$.expr[":"].width || function(a,i,m){
91
+ var val=m[3].replace("&lt;","<").replace("&gt;",">");
92
+ if(!val){return false;}
93
+ return val.substr(0,1)===">" ? $(a).width()>val.substr(1) : val.substr(0,1)==="<" ? $(a).width()<val.substr(1) : $(a).width()===parseInt(val);
94
+ },
95
+ //height based - e.g. :height(200), :height(>200), :height(>200):height(<300) etc.
96
+ height:$.expr[":"].height || function(a,i,m){
97
+ var val=m[3].replace("&lt;","<").replace("&gt;",">");
98
+ if(!val){return false;}
99
+ return val.substr(0,1)===">" ? $(a).height()>val.substr(1) : val.substr(0,1)==="<" ? $(a).height()<val.substr(1) : $(a).height()===parseInt(val);
100
+ }
101
+ });
102
  })(jQuery);
malihu-pagescroll2id.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Page scroll to id
4
  Plugin URI: http://manos.malihu.gr/page-scroll-to-id
5
  Description: Page scroll to id is an easy-to-use jQuery plugin that enables animated page scrolling to specific id within the document.
6
- Version: 1.5.8
7
  Author: malihu
8
  Author URI: http://manos.malihu.gr
9
  License: MIT License (MIT)
@@ -45,7 +45,7 @@ if(!class_exists('malihuPageScroll2id')){ // --edit--
45
 
46
  class malihuPageScroll2id{ // --edit--
47
 
48
- protected $version='1.5.8'; // Plugin version --edit--
49
  protected $update_option=null;
50
 
51
  protected $plugin_name='Page scroll to id'; // Plugin name --edit--
@@ -307,11 +307,14 @@ if(!class_exists('malihuPageScroll2id')){ // --edit--
307
 
308
  public function add_plugin_shortcode(){
309
  $pl_shortcodes=array();
 
310
  $instances=get_option($this->db_prefix.'instances');
311
  for($i=1; $i<=count($instances); $i++){
312
  $pl_shortcodes[]='pl_shortcode_fn_'.$i;
 
313
  // --edit--
314
  $tag=$shortcode_class=$this->sc_pfx; // Shortcode without suffix
 
315
  //$tag=$shortcode_class=$this->sc_pfx.'_'.$i; // Shortcode with suffix
316
  $pl_shortcodes[$i]=create_function('$atts,$content=null','
317
  extract(shortcode_atts(array(
@@ -323,12 +326,27 @@ if(!class_exists('malihuPageScroll2id')){ // --edit--
323
  "target" => "",
324
  ), $atts));
325
  if($id!==""){
326
- return "<a id=\"".$id."\" data-ps2id-target=\"".sanitize_text_field($target)."\">".do_shortcode($content)."</a>";
 
 
 
 
327
  }else{
328
  return "<a href=\"".$url."\" class=\"".$shortcode_class."\" data-ps2id-offset=\"".esc_attr($offset)."\">".do_shortcode($content)."</a>";
329
  }
330
  ');
331
  add_shortcode($tag, $pl_shortcodes[$i]);
 
 
 
 
 
 
 
 
 
 
 
332
  }
333
  }
334
 
3
  Plugin Name: Page scroll to id
4
  Plugin URI: http://manos.malihu.gr/page-scroll-to-id
5
  Description: Page scroll to id is an easy-to-use jQuery plugin that enables animated page scrolling to specific id within the document.
6
+ Version: 1.5.9
7
  Author: malihu
8
  Author URI: http://manos.malihu.gr
9
  License: MIT License (MIT)
45
 
46
  class malihuPageScroll2id{ // --edit--
47
 
48
+ protected $version='1.5.9'; // Plugin version --edit--
49
  protected $update_option=null;
50
 
51
  protected $plugin_name='Page scroll to id'; // Plugin name --edit--
307
 
308
  public function add_plugin_shortcode(){
309
  $pl_shortcodes=array();
310
+ $pl_shortcodes_b=array();
311
  $instances=get_option($this->db_prefix.'instances');
312
  for($i=1; $i<=count($instances); $i++){
313
  $pl_shortcodes[]='pl_shortcode_fn_'.$i;
314
+ $pl_shortcodes_b[]='pl_shortcode_fn_'.$i;
315
  // --edit--
316
  $tag=$shortcode_class=$this->sc_pfx; // Shortcode without suffix
317
+ $tag_b=$this->sc_pfx.'_wrap'; // Shortcode without suffix
318
  //$tag=$shortcode_class=$this->sc_pfx.'_'.$i; // Shortcode with suffix
319
  $pl_shortcodes[$i]=create_function('$atts,$content=null','
320
  extract(shortcode_atts(array(
326
  "target" => "",
327
  ), $atts));
328
  if($id!==""){
329
+ if($content){
330
+ return "<div id=\"".$id."\" data-ps2id-target=\"".sanitize_text_field($target)."\">".do_shortcode($content)."</div>";
331
+ }else{
332
+ return "<a id=\"".$id."\" data-ps2id-target=\"".sanitize_text_field($target)."\">".do_shortcode($content)."</a>";
333
+ }
334
  }else{
335
  return "<a href=\"".$url."\" class=\"".$shortcode_class."\" data-ps2id-offset=\"".esc_attr($offset)."\">".do_shortcode($content)."</a>";
336
  }
337
  ');
338
  add_shortcode($tag, $pl_shortcodes[$i]);
339
+ $pl_shortcodes_b[$i]=create_function('$atts,$content=null','
340
+ extract(shortcode_atts(array(
341
+ "i" => "'.$i.'",
342
+ "id" => "",
343
+ "target" => "",
344
+ ), $atts));
345
+ if($id!==""){
346
+ return "<div id=\"".$id."\" data-ps2id-target=\"".sanitize_text_field($target)."\">".do_shortcode($content)."</div>";
347
+ }
348
+ ');
349
+ add_shortcode($tag_b, $pl_shortcodes_b[$i]);
350
  }
351
  }
352
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: malihu
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UYJ5G65M6ZA28
4
  Tags: page scrolling, page animation, navigation, single-page navigation
5
  Requires at least: 3.3
6
- Tested up to: 4.0
7
- Stable tag: 1.5.8
8
  License: The MIT License (MIT)
9
  License URI: http://opensource.org/licenses/MIT
10
 
@@ -36,6 +36,10 @@ Page scroll to id requires WordPress version **3.3** or higher and jQuery versio
36
  1. [Install the plugin](http://wordpress.org/plugins/page-scroll-to-id/installation/).
37
  2. Add `rel="m_PageScroll2id"` to your links that point to existing sections within your page, making sure each link's href value contains a hash (`#`) with the id of the section you want to scroll-to. To enable the rel attribute field in WordPress Menus, click 'Screen Options' and check 'Link Relationship (XFN)'. To enable the plugin on a menu item, click the arrow on the right of the item and insert `m_PageScroll2id` in the 'Link Relationship (XFN)' field.
38
 
 
 
 
 
39
  For more information see Help in plugin settings and resources below.
40
 
41
  = Plugin Resources =
@@ -140,6 +144,13 @@ Yes but you probably need to implement the plugin in your theme **manually**. Se
140
 
141
  == Changelog ==
142
 
 
 
 
 
 
 
 
143
  = 1.5.8 =
144
  * Fixed various PHP notices in debug mode.
145
  * Minor script optimizations.
@@ -206,6 +217,10 @@ Yes but you probably need to implement the plugin in your theme **manually**. Se
206
 
207
  == Upgrade Notice ==
208
 
 
 
 
 
209
  = 1.5.8 =
210
 
211
  Fixed various PHP notices in debug mode, minor script optimizations.
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UYJ5G65M6ZA28
4
  Tags: page scrolling, page animation, navigation, single-page navigation
5
  Requires at least: 3.3
6
+ Tested up to: 4.2.2
7
+ Stable tag: 1.5.9
8
  License: The MIT License (MIT)
9
  License URI: http://opensource.org/licenses/MIT
10
 
36
  1. [Install the plugin](http://wordpress.org/plugins/page-scroll-to-id/installation/).
37
  2. Add `rel="m_PageScroll2id"` to your links that point to existing sections within your page, making sure each link's href value contains a hash (`#`) with the id of the section you want to scroll-to. To enable the rel attribute field in WordPress Menus, click 'Screen Options' and check 'Link Relationship (XFN)'. To enable the plugin on a menu item, click the arrow on the right of the item and insert `m_PageScroll2id` in the 'Link Relationship (XFN)' field.
38
 
39
+ = Tutorials =
40
+
41
+ * [Page scroll to id for WordPress tutorial](http://manos.malihu.gr/page-scroll-to-id-for-wordpress-tutorial/)
42
+
43
  For more information see Help in plugin settings and resources below.
44
 
45
  = Plugin Resources =
144
 
145
  == Changelog ==
146
 
147
+ = 1.5.9 =
148
+ * Extended `ps2id` shortcode for creating `div` elements (in addition to anchors).
149
+ * Added `ps2id_wrap` shortcode for creating target wrappers in content editor.
150
+ * Extended offset selector expressions with `:position`, `:height()` and `:width()`.
151
+ * Updated readme.txt.
152
+ * Updated help.
153
+
154
  = 1.5.8 =
155
  * Fixed various PHP notices in debug mode.
156
  * Minor script optimizations.
217
 
218
  == Upgrade Notice ==
219
 
220
+ = 1.5.9 =
221
+
222
+ Extended `ps2id` shortcode, added `ps2id_wrap` shortcode, extended offset selector expressions, updated help and readme.txt.
223
+
224
  = 1.5.8 =
225
 
226
  Fixed various PHP notices in debug mode, minor script optimizations.