Widgets on Pages - Version 0.0.3

Version Description

The number of sidebars can now be defined via the settings menu. There can be up to 5 defined. Each sidebar can be called independently.

Download this release

Release Info

Developer toddhalfpenny
Plugin Icon 128x128 Widgets on Pages
Version 0.0.3
Comparing to
See all releases

Code changes from version 0.0.2 to 0.0.3

Files changed (2) hide show
  1. readme.txt +12 -6
  2. widgets_on_pages.php +84 -5
readme.txt CHANGED
@@ -1,16 +1,18 @@
1
  === Widgets on Pages ===
2
  Contributors: toddhalfpenny
3
  Donate link: n/a
4
- Tags: widgets, sidebar, pages, post
5
  Requires at least: 2.8
6
  Tested up to: 2.9.2
7
- Stable tag: 0.0.2
8
 
9
- Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content
10
 
11
  == Description ==
12
 
13
- Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content
 
 
14
 
15
 
16
  == Installation ==
@@ -19,14 +21,14 @@ Allows 'in-page' widget areas so widgets can be defined via shortcut straight in
19
  1. Install the plugin from within the Dashboard or upload the directory `widgets-on-pages` and all its contents to the `/wp-content/plugins/` directory
20
  1. Activate the plugin through the 'Plugins' menu in WordPress
21
  1. Add the widgets you want to the `Widgets on Pages` widget area in the admin screens
22
- 1. Add the shortcut `[widgets_on_pages]` to the page or post in the place where you'd like your widgets to appear.
23
 
24
 
25
  == Frequently Asked Questions ==
26
 
27
  = Can I have more than one defined sidebar area =
28
 
29
- No, sorry not yet. The plan is to get this supported though
30
 
31
  == Screenshots ==
32
 
@@ -34,6 +36,10 @@ No, sorry not yet. The plan is to get this supported though
34
 
35
  == Changelog ==
36
 
 
 
 
 
37
  = 0.0.2 =
38
 
39
  Minor update so that the functions.php code is not needed anymore... makes like easier.
1
  === Widgets on Pages ===
2
  Contributors: toddhalfpenny
3
  Donate link: n/a
4
+ Tags: widgets, sidebar, pages, post, shortcode, inline
5
  Requires at least: 2.8
6
  Tested up to: 2.9.2
7
+ Stable tag: 0.0.3
8
 
9
+ Allows 'in-page' widget areas so widgets can be defined via shortcode straight into page/post content
10
 
11
  == Description ==
12
 
13
+ Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content.
14
+ There is one default widget area that can be used or you can add more from the settings menu. You can currently have up to 5 widget areas (sidebars).
15
+ Each sidebar can be called indepentenly by a shortcode and you can call more than one per post/page.
16
 
17
 
18
  == Installation ==
21
  1. Install the plugin from within the Dashboard or upload the directory `widgets-on-pages` and all its contents to the `/wp-content/plugins/` directory
22
  1. Activate the plugin through the 'Plugins' menu in WordPress
23
  1. Add the widgets you want to the `Widgets on Pages` widget area in the admin screens
24
+ 1. Add the shortcut `[widgets_on_pages id=x]` to the page or post in the place where you'd like your widgets to appear (where 'x' = the id of the sidebar to use. If using only the default sidebar then no 'id' argument is needed (i.e. `[widgets_on_pages]`).
25
 
26
 
27
  == Frequently Asked Questions ==
28
 
29
  = Can I have more than one defined sidebar area =
30
 
31
+ Yes... there can be up to 5 sidebars defined. The number available can be administered via the settings menu.
32
 
33
  == Screenshots ==
34
 
36
 
37
  == Changelog ==
38
 
39
+ = 0.0.3 =
40
+
41
+ The number of sidebars can now be defined via the settings menu. There can be up to 5 defined. Each sidebar can be called independently.
42
+
43
  = 0.0.2 =
44
 
45
  Minor update so that the functions.php code is not needed anymore... makes like easier.
widgets_on_pages.php CHANGED
@@ -22,41 +22,120 @@ Plugin Name: Widgets on Pages
22
  Plugin URI: http://gingerbreaddesign.co.uk/wordpress/plugins/widgets-on-pages.php
23
  Description: Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content
24
  Author: Todd Halfpenny
25
- Version: 0.0.2
26
  Author URI: http://gingerbreaddesign.co.uk/todd
27
  */
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  /* ===============================
31
  C O R E C O D E
32
  ================================*/
33
 
34
 
35
- function widgets_on_page(){
36
  reg_wop_sidebar();
 
37
  $str = "<div id='widgets_on_page'>
38
  <ul>";
39
  ob_start();
40
- if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Widgets on Pages") ) :
41
  endif;
42
  $myStr = ob_get_contents();
43
  ob_end_clean();
44
  $str .= $myStr;
45
  $str .= "</ul>
46
  </div><!-- widget_on_page -->";
47
- return $str;
48
  }
49
 
50
 
 
51
  function reg_wop_sidebar() {
 
52
  if ( function_exists('register_sidebar') )
53
  register_sidebar(array(
54
- 'name' => 'Widgets on Pages',
55
  'before_widget' => '<li id="%1$s" class="widget %2$s">',
56
  'after_widget' => '</li>',
57
  'before_title' => '<h2 class="widgettitle">',
58
  'after_title' => '</h2>',
59
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
  add_action('admin_init', 'reg_wop_sidebar');
22
  Plugin URI: http://gingerbreaddesign.co.uk/wordpress/plugins/widgets-on-pages.php
23
  Description: Allows 'in-page' widget areas so widgets can be defined via shortcut straight into page/post content
24
  Author: Todd Halfpenny
25
+ Version: 0.0.3
26
  Author URI: http://gingerbreaddesign.co.uk/todd
27
  */
28
 
29
+ /* ===============================
30
+ A D M I N M E N U / P A G E
31
+ ================================*/
32
+
33
+
34
+ add_action('admin_menu', 'wop_menu');
35
+
36
+ function wop_menu() {
37
+ add_options_page('Widgets on Pages options', 'Widgets on Pages', 7, 'wop_options', 'wop_plugin_options');
38
+ add_action( 'admin_init', 'register_mysettings' );
39
+
40
+ }
41
+
42
+
43
+ function register_mysettings() { // whitelist options
44
+ register_setting( 'wop_options', 'num_of_wop_sidebars' );
45
+ }
46
+
47
+
48
+ /*--------------------------------
49
+ wop_options
50
+ ------------------------------- */
51
+ function wop_plugin_options() {
52
+ ?>
53
+ <div class="wrap">
54
+ <div id="icon-tools" class="icon32"></div>
55
+ <h2>Widgets on Pages: Options</h2>
56
+ <form method="post" action="options.php">
57
+ <?php wp_nonce_field('update-options'); ?>
58
+ <?php settings_fields( 'wop_options' ); ?>
59
+ <? $cur_num_sidebars = get_option('num_of_wop_sidebars');?>
60
+
61
+ <table class="form-table">
62
+
63
+ <tr valign="top">
64
+ <th scope="row">Number of additional sidebars</th>
65
+ <td><input type="hidden" size='3' value="<? echo get_option('num_of_wop_sidebars');?>" />
66
+ <select name="num_of_wop_sidebars">
67
+ <?php
68
+ for ( $num_sidebars = 0; $num_sidebars <= 5; $num_sidebars++){
69
+ if ($num_sidebars == $cur_num_sidebars) :
70
+ echo "<option name='num_of_wop_sidebars' selected value='$num_sidebars'>$num_sidebars&nbsp;</option>";
71
+ else :
72
+ echo "<option name='num_of_wop_sidebars' value='$num_sidebars'>$num_sidebars&nbsp;</option>";
73
+ endif;
74
+ }
75
+ ?>
76
+ </select>
77
+ </table>
78
+ <input type="hidden" name="action" value="update" />
79
+ <input type="hidden" name="page_options" value="num_of_wop_sidebars" />
80
+ <p class="submit">
81
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
82
+ </p>
83
+ </form>
84
+ </div>
85
+ <?
86
+ }
87
+
88
+
89
+
90
 
91
  /* ===============================
92
  C O R E C O D E
93
  ================================*/
94
 
95
 
96
+ function widgets_on_page($atts){
97
  reg_wop_sidebar();
98
+ extract(shortcode_atts( array('id' => '1'), $atts));
99
  $str = "<div id='widgets_on_page'>
100
  <ul>";
101
  ob_start();
102
+ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Widgets on Pages $id") ) :
103
  endif;
104
  $myStr = ob_get_contents();
105
  ob_end_clean();
106
  $str .= $myStr;
107
  $str .= "</ul>
108
  </div><!-- widget_on_page -->";
109
+ return $str;
110
  }
111
 
112
 
113
+
114
  function reg_wop_sidebar() {
115
+ // register the main sidebar
116
  if ( function_exists('register_sidebar') )
117
  register_sidebar(array(
118
+ 'name' => 'Widgets on Pages 1',
119
  'before_widget' => '<li id="%1$s" class="widget %2$s">',
120
  'after_widget' => '</li>',
121
  'before_title' => '<h2 class="widgettitle">',
122
  'after_title' => '</h2>',
123
  ));
124
+
125
+ // register any other additional sidebars
126
+ $num_sidebars = (get_option('num_of_wop_sidebars') + 1);
127
+ if ($num_sidebars > 1) :
128
+ for ( $sidebar = 2; $sidebar <= $num_sidebars; $sidebar++){
129
+ if ( function_exists('register_sidebar') )
130
+ register_sidebar(array(
131
+ 'name' => "Widgets on Pages $sidebar",
132
+ 'before_widget' => '<li id="%1$s" class="widget %2$s">',
133
+ 'after_widget' => '</li>',
134
+ 'before_title' => '<h2 class="widgettitle">',
135
+ 'after_title' => '</h2>',
136
+ ));
137
+ }
138
+ endif;
139
  }
140
 
141
  add_action('admin_init', 'reg_wop_sidebar');