Genesis Simple Hooks - Version 0.9

Version Description

  • Add new hooks, remove deprecated hooks
  • Fix textarea bug with HTML entities
  • Bump to pre-release 0.9 branch
Download this release

Release Info

Developer nathanrice
Plugin Icon 128x128 Genesis Simple Hooks
Version 0.9
Comparing to
See all releases

Version 0.9

Files changed (5) hide show
  1. admin.php +201 -0
  2. boxes.php +331 -0
  3. functions.php +71 -0
  4. plugin.php +96 -0
  5. readme.txt +81 -0
admin.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Return the defaults array
4
+ *
5
+ * @since 0.1
6
+ */
7
+ function simplehooks_defaults() {
8
+ return array( // define our defaults
9
+
10
+ ##################### globals
11
+ 'wp_head' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
12
+ 'wp_footer' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
13
+
14
+ 'genesis_init' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
15
+
16
+ 'genesis_title' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
17
+
18
+ 'genesis_meta' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
19
+
20
+ 'genesis_before' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
21
+ 'genesis_after' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
22
+
23
+ 'genesis_before_header' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
24
+ 'genesis_header' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
25
+ 'genesis_after_header' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
26
+
27
+ 'genesis_site_title' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
28
+ 'genesis_site_description' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
29
+
30
+ 'genesis_before_content_sidebar_wrap' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
31
+ 'genesis_after_content_sidebar_wrap' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
32
+
33
+ 'genesis_before_content' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
34
+ 'genesis_after_content' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
35
+
36
+ 'genesis_before_loop' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
37
+ 'genesis_loop' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
38
+ 'genesis_after_loop' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
39
+
40
+ 'genesis_before_post' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
41
+ 'genesis_after_post' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
42
+
43
+ 'genesis_before_post_title' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
44
+ 'genesis_post_title' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
45
+ 'genesis_after_post_title' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
46
+
47
+ 'genesis_before_post_content' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
48
+ 'genesis_post_content' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
49
+ 'genesis_after_post_content' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
50
+
51
+ 'genesis_after_endwhile' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
52
+ 'genesis_loop_else' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
53
+
54
+ 'genesis_before_comments' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
55
+ 'genesis_comments' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
56
+ 'genesis_list_comments' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
57
+ 'genesis_after_comments' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
58
+
59
+ 'genesis_before_pings' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
60
+ 'genesis_pings' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
61
+ 'genesis_list_pings' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
62
+ 'genesis_after_pings' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
63
+
64
+ 'genesis_before_comment' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
65
+ 'genesis_comment' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
66
+ 'genesis_after_comment' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
67
+
68
+ 'genesis_before_comment_form' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
69
+ 'genesis_comment_form' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
70
+ 'genesis_after_comment_form' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
71
+
72
+ 'genesis_before_sidebar_widget_area' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
73
+ 'genesis_after_sidebar_widget_area' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
74
+ 'genesis_before_sidebar_alt_widget_area' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
75
+ 'genesis_after_sidebar_alt_widget_area' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
76
+
77
+ 'genesis_before_footer' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
78
+ 'genesis_footer' => array('content' => '', 'php' => 0, 'shortcodes' => 0),
79
+ 'genesis_after_footer' => array('content' => '', 'php' => 0, 'shortcodes' => 0)
80
+
81
+ );
82
+
83
+ }
84
+
85
+ /**
86
+ * This registers the settings field and adds defaults to the options table
87
+ */
88
+ add_action('admin_init', 'register_simplehooks_settings');
89
+ function register_simplehooks_settings() {
90
+ register_setting(SIMPLEHOOKS_SETTINGS_FIELD, SIMPLEHOOKS_SETTINGS_FIELD);
91
+ add_option(SIMPLEHOOKS_SETTINGS_FIELD, simplehooks_defaults(), '', 'yes');
92
+ }
93
+
94
+ /**
95
+ * This is a necessary go-between to get our scripts and boxes loaded
96
+ * on the theme settings page only, and not the rest of the admin
97
+ */
98
+ add_action('admin_menu', 'simplehooks_settings_init', 15);
99
+ function simplehooks_settings_init() {
100
+ global $_simplehooks_settings_pagehook;
101
+
102
+ // Add "Design Settings" submenu
103
+ $_simplehooks_settings_pagehook = add_submenu_page('genesis', __('Simple Hooks','simplehooks'), __('Simple Hooks','simplehooks'), 'manage_options', 'simplehooks', 'simplehooks_settings_admin');
104
+
105
+ add_action('load-'.$_simplehooks_settings_pagehook, 'simplehooks_settings_scripts');
106
+ add_action('load-'.$_simplehooks_settings_pagehook, 'simplehooks_settings_boxes');
107
+ }
108
+
109
+ function simplehooks_settings_scripts() {
110
+ wp_enqueue_script('common');
111
+ wp_enqueue_script('wp-lists');
112
+ wp_enqueue_script('postbox');
113
+ }
114
+
115
+ function simplehooks_settings_boxes() {
116
+ global $_simplehooks_settings_pagehook;
117
+
118
+ add_meta_box('simplehooks-wp-hooks', __('WordPress Hooks', 'simplehooks'), 'simplehooks_wp_hooks_box', $_simplehooks_settings_pagehook, 'column1');
119
+ add_meta_box('simplehooks-document-hooks', __('Document Hooks', 'simplehooks'), 'simplehooks_document_hooks_box', $_simplehooks_settings_pagehook, 'column1');
120
+ add_meta_box('simplehooks-header-hooks', __('Header Hooks', 'simplehooks'), 'simplehooks_header_hooks_box', $_simplehooks_settings_pagehook, 'column1');
121
+ add_meta_box('simplehooks-content-hooks', __('Content Hooks', 'simplehooks'), 'simplehooks_content_hooks_box', $_simplehooks_settings_pagehook, 'column1');
122
+ add_meta_box('simplehooks-loop-hooks', __('Loop Hooks', 'simplehooks'), 'simplehooks_loop_hooks_box', $_simplehooks_settings_pagehook, 'column1');
123
+ add_meta_box('simplehooks-post-hooks', __('Post/Page Hooks', 'simplehooks'), 'simplehooks_post_hooks_box', $_simplehooks_settings_pagehook, 'column1');
124
+ add_meta_box('simplehooks-comment-list-hooks', __('Comment List Hooks', 'simplehooks'), 'simplehooks_comment_list_hooks_box', $_simplehooks_settings_pagehook, 'column1');
125
+ add_meta_box('simplehooks-ping-list-hooks', __('Ping List Hooks', 'simplehooks'), 'simplehooks_ping_list_hooks_box', $_simplehooks_settings_pagehook, 'column1');
126
+ add_meta_box('simplehooks-comment-hooks', __('Single Comment Hooks', 'simplehooks'), 'simplehooks_comment_hooks_box', $_simplehooks_settings_pagehook, 'column1');
127
+ add_meta_box('simplehooks-comment-form-hooks', __('Comment Form Hooks', 'simplehooks'), 'simplehooks_comment_form_hooks_box', $_simplehooks_settings_pagehook, 'column1');
128
+ add_meta_box('simplehooks-sidebar-hooks', __('Sidebar Hooks', 'simplehooks'), 'simplehooks_sidebar_hooks_box', $_simplehooks_settings_pagehook, 'column1');
129
+ add_meta_box('simplehooks-footer-hooks', __('Footer Hooks', 'simplehooks'), 'simplehooks_footer_hooks_box', $_simplehooks_settings_pagehook, 'column1');
130
+ }
131
+
132
+ /**
133
+ * Tell WordPress that we want only 1 column available for our meta-boxes
134
+ */
135
+ add_filter('screen_layout_columns', 'simplehooks_settings_layout_columns', 10, 2);
136
+ function simplehooks_settings_layout_columns($columns, $screen) {
137
+ global $_simplehooks_settings_pagehook;
138
+ if ($screen == $_simplehooks_settings_pagehook) {
139
+ // This page should have 3 column options
140
+ $columns[$_simplehooks_settings_pagehook] = 1;
141
+ }
142
+ return $columns;
143
+ }
144
+
145
+ /**
146
+ * This function is what actually gets output to the page. It handles the markup,
147
+ * builds the form, outputs necessary JS stuff, and fires <code>do_meta_boxes()</code>
148
+ */
149
+ function simplehooks_settings_admin() {
150
+ global $_simplehooks_settings_pagehook, $screen_layout_columns;
151
+
152
+ $width = "width: 99%;";
153
+ $hide2 = $hide3 = " display: none;";
154
+
155
+ ?>
156
+ <div id="simplehooks" class="wrap genesis-metaboxes">
157
+ <form method="post" action="options.php">
158
+
159
+ <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
160
+ <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
161
+ <?php settings_fields(SIMPLEHOOKS_SETTINGS_FIELD); // important! ?>
162
+
163
+ <?php screen_icon('plugins'); ?>
164
+ <h2>
165
+ <?php _e('Genesis - Simple Hooks', 'genesis'); ?>
166
+ <input type="submit" class="button-primary add-new-h2" value="<?php _e('Save Changes', 'simplehooks') ?>" />
167
+ <?php $reset_onclick = 'onclick="if ( confirm(\'' . esc_js( __('Are you sure you want to reset?', 'simplehooks') ) . '\') ) {return true;}return false;"'; ?>
168
+ <input type="submit" <?php echo $reset_onclick; ?> class="button-highlighted add-new-h2" name="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[reset]" value="<?php _e('Reset All', 'simplehooks'); ?>" />
169
+ </h2>
170
+
171
+ <?php
172
+ if(genesis_get_option('reset', SIMPLEHOOKS_SETTINGS_FIELD)) {
173
+ update_option(SIMPLEHOOKS_SETTINGS_FIELD, simplehooks_defaults());
174
+ echo '<div id="message" class="updated" id="message"><p><strong>'.__('Modifications Reset', 'simplehooks').'</strong></p></div>';
175
+ }
176
+ elseif( isset($_REQUEST['updated']) && $_REQUEST['updated'] == 'true') {
177
+ echo '<div id="message" class="updated" id="message"><p><strong>'.__('Modifications Saved', 'simplehooks').'</strong></p></div>';
178
+ }
179
+ ?>
180
+
181
+ <div class="metabox-holder">
182
+ <div class="postbox-container" style="<?php echo $width; ?>">
183
+ <?php do_meta_boxes($_simplehooks_settings_pagehook, 'column1', null); ?>
184
+ </div>
185
+ </div>
186
+
187
+ </form>
188
+ </div>
189
+ <script type="text/javascript">
190
+ //<![CDATA[
191
+ jQuery(document).ready( function($) {
192
+ // close postboxes that should be closed
193
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
194
+ // postboxes setup
195
+ postboxes.add_postbox_toggles('<?php echo $_simplehooks_settings_pagehook; ?>');
196
+ });
197
+ //]]>
198
+ </script>
199
+
200
+ <?php
201
+ }
boxes.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This next section defines functions that contain the content of the "boxes" that will be
4
+ * output by default on the "SEO Settings" page. There's a bunch of them.
5
+ *
6
+ */
7
+
8
+ function simplehooks_wp_hooks_box() {
9
+
10
+ simplehooks_form_generate(array(
11
+ 'hook' => 'wp_head',
12
+ 'desc' => __('This hook executes immediately before the closing <code>&lt;/head&gt;</code> tag.', 'simplehooks')
13
+ ));
14
+
15
+ simplehooks_form_generate(array(
16
+ 'hook' => 'wp_footer',
17
+ 'desc' => __('This hook executes immediately before the closing <code>&lt;/body&gt;</code> tag.', 'simplehooks')
18
+ ));
19
+
20
+ simplehooks_form_submit();
21
+
22
+ }
23
+
24
+ function simplehooks_document_hooks_box() {
25
+
26
+ simplehooks_form_generate(array(
27
+ 'hook' => 'genesis_title',
28
+ 'desc' => __('This hook executes between the main document <code>&lt;title&gt;&lt;/title&gt;</code> tags.', 'simplehooks')
29
+ ));
30
+
31
+ simplehooks_form_generate(array(
32
+ 'hook' => 'genesis_meta',
33
+ 'desc' => __('This hook executes in the document <code>&lt;head&gt;</code>.<br /> It is commonly used to output <code>META</code> information about the document.', 'simplehooks'),
34
+ 'unhook' => array('genesis_load_favicon')
35
+ ));
36
+
37
+ simplehooks_form_generate(array(
38
+ 'hook' => 'genesis_before',
39
+ 'desc' => __('This hook executes immediately after the opening <code>&lt;body&gt;</code> tag.', 'simplehooks')
40
+ ));
41
+
42
+ simplehooks_form_generate(array(
43
+ 'hook' => 'genesis_after',
44
+ 'desc' => __('This hook executes immediately before the closing <code>&lt;/body&gt;</code> tag.', 'simplehooks')
45
+ ));
46
+
47
+ simplehooks_form_submit();
48
+
49
+ }
50
+
51
+ function simplehooks_header_hooks_box() {
52
+
53
+ simplehooks_form_generate(array(
54
+ 'hook' => 'genesis_before_header',
55
+ 'desc' => __('This hook executes immediately before the header (outside the <code>#header</code> div).', 'simplehooks')
56
+ ));
57
+
58
+ simplehooks_form_generate(array(
59
+ 'hook' => 'genesis_header',
60
+ 'desc' => __('This hook outputs the default header (the <code>#header</code> div)', 'simplehooks'),
61
+ 'unhook' => array('genesis_do_header')
62
+ ));
63
+
64
+ simplehooks_form_generate(array(
65
+ 'hook' => 'genesis_after_header',
66
+ 'desc' => __('This hook executes immediately after the header (outside the <code>#header</code> div).', 'simplehooks')
67
+ ));
68
+
69
+ simplehooks_form_submit();
70
+
71
+ }
72
+
73
+ function simplehooks_content_hooks_box() {
74
+
75
+ simplehooks_form_generate(array(
76
+ 'hook' => 'genesis_before_content_sidebar_wrap',
77
+ 'desc' => __('This hook executes immediately before the div block that wraps the content and the primary sidebar (outside the <code>#content-sidebar-wrap</code> div).', 'simplehooks')
78
+ ));
79
+
80
+ simplehooks_form_generate(array(
81
+ 'hook' => 'genesis_after_content_sidebar_wrap',
82
+ 'desc' => __('This hook executes immediately after the div block that wraps the content and the primary sidebar (outside the <code>#content-sidebar-wrap</code> div).', 'simplehooks')
83
+ ));
84
+
85
+ simplehooks_form_generate(array(
86
+ 'hook' => 'genesis_before_content',
87
+ 'desc' => __('This hook executes immediately before the content column (outside the <code>#content</code> div).', 'simplehooks')
88
+ ));
89
+
90
+ simplehooks_form_generate(array(
91
+ 'hook' => 'genesis_after_content',
92
+ 'desc' => __('This hook executes immediately after the content column (outside the <code>#content</code> div).', 'simplehooks')
93
+ ));
94
+
95
+ simplehooks_form_submit();
96
+
97
+ }
98
+
99
+ function simplehooks_loop_hooks_box() {
100
+
101
+ simplehooks_form_generate(array(
102
+ 'hook' => 'genesis_before_loop',
103
+ 'desc' => __('This hook executes immediately before all loop blocks.<br /> Therefore, this hook falls outside the loop, and cannot execute functions that require loop template tags or variables.', 'simplehooks')
104
+ ));
105
+
106
+ simplehooks_form_generate(array(
107
+ 'hook' => 'genesis_loop',
108
+ 'desc' => __('This hook executes both default and custom loops.', 'simplehooks')
109
+ ));
110
+
111
+ simplehooks_form_generate(array(
112
+ 'hook' => 'genesis_after_loop',
113
+ 'desc' => __('This hook executes immediately after all loop blocks.<br /> Therefore, this hook falls outside the loop, and cannot execute functions that require loop template tags or variables.', 'simplehooks')
114
+ ));
115
+
116
+ simplehooks_form_generate(array(
117
+ 'hook' => 'genesis_after_endwhile',
118
+ 'desc' => __('This hook executes after the <code>endwhile;</code> statement.', 'simplehooks'),
119
+ 'unhook' => array('genesis_posts_nav')
120
+ ));
121
+
122
+ simplehooks_form_generate(array(
123
+ 'hook' => 'genesis_loop_else',
124
+ 'desc' => __('This hook executes after the <code>else :</code> statement in all loop blocks. The content attached to this hook will only display if there are no posts available when a loop is executed.', 'simplehooks')
125
+ ));
126
+
127
+ simplehooks_form_submit();
128
+
129
+ }
130
+
131
+ function simplehooks_post_hooks_box() {
132
+
133
+ simplehooks_form_generate(array(
134
+ 'hook' => 'genesis_before_post',
135
+ 'desc' => __('This hook executes before each post in all loop blocks (outside the <code>post_class()</code> div).', 'simplehooks')
136
+ ));
137
+
138
+ simplehooks_form_generate(array(
139
+ 'hook' => 'genesis_after_post',
140
+ 'desc' => __('This hook executes after each post in all loop blocks (outside the <code>post_class()</code> div).', 'simplehooks'),
141
+ 'unhook' => array('genesis_do_author_box')
142
+ ));
143
+
144
+ simplehooks_form_generate(array(
145
+ 'hook' => 'genesis_before_post_title',
146
+ 'desc' => __('This hook executes immediately before each post/page title within the loop.', 'simplehooks')
147
+ ));
148
+
149
+ simplehooks_form_generate(array(
150
+ 'hook' => 'genesis_post_title',
151
+ 'desc' => __('This hook outputs the post/page title.', 'simplehooks')
152
+ ));
153
+
154
+ simplehooks_form_generate(array(
155
+ 'hook' => 'genesis_after_post_title',
156
+ 'desc' => __('This hook executes immediately after each post/page title within the loop.', 'simplehooks')
157
+ ));
158
+
159
+ simplehooks_form_generate(array(
160
+ 'hook' => 'genesis_before_post_content',
161
+ 'desc' => __('This hook executes immediately before the <code>genesis_post_content</code> hook for each post/page within the loop.', 'simplehooks'),
162
+ 'unhook' => array('genesis_post_info')
163
+ ));
164
+
165
+ simplehooks_form_generate(array(
166
+ 'hook' => 'genesis_post_content',
167
+ 'desc' => __('This hook outputs the content of the post/page, by default.', 'simplehooks')
168
+ ));
169
+
170
+ simplehooks_form_generate(array(
171
+ 'hook' => 'genesis_after_post_content',
172
+ 'desc' => __('This hook executes immediately after the <code>genesis_post_content</code> hook for each post/page within the loop.', 'simplehooks'),
173
+ 'unhook' => array('genesis_post_meta')
174
+ ));
175
+
176
+ simplehooks_form_submit();
177
+
178
+ }
179
+
180
+ function simplehooks_comment_list_hooks_box() {
181
+
182
+ simplehooks_form_generate(array(
183
+ 'hook' => 'genesis_before_comments',
184
+ 'desc' => __('This hook executes immediately before the comments block (outside the <code>#comments</code> div).', 'simplehooks')
185
+ ));
186
+
187
+ simplehooks_form_generate(array(
188
+ 'hook' => 'genesis_comments',
189
+ 'desc' => __('This hook outputs the comments block, including the <code>#comments</code> div.', 'simplehooks')
190
+ ));
191
+
192
+ simplehooks_form_generate(array(
193
+ 'hook' => 'genesis_list_comments',
194
+ 'desc' => __('This hook executes inside the comments block, inside the <code>.comment-list</code> OL. By default, it outputs a list of comments associated with a post via the <code>genesis_default_list_comments()</code> function.', 'simplehooks')
195
+ ));
196
+
197
+ simplehooks_form_generate(array(
198
+ 'hook' => 'genesis_after_comments',
199
+ 'desc' => __('This hook executes immediately after the comments block (outside the <code>#comments</code> div).', 'simplehooks')
200
+ ));
201
+
202
+ }
203
+
204
+ function simplehooks_ping_list_hooks_box() {
205
+
206
+ simplehooks_form_generate(array(
207
+ 'hook' => 'genesis_before_pings',
208
+ 'desc' => __('This hook executes immediately before the pings block (outside the <code>#pings</code> div).', 'simplehooks')
209
+ ));
210
+
211
+ simplehooks_form_generate(array(
212
+ 'hook' => 'genesis_pings',
213
+ 'desc' => __('This hook outputs the pings block, including the <code>#pings</code> div.', 'simplehooks')
214
+ ));
215
+
216
+ simplehooks_form_generate(array(
217
+ 'hook' => 'genesis_list_pings',
218
+ 'desc' => __('This hook executes inside the pings block, inside the <code>.ping-list</code> OL. By default, it outputs a list of pings associated with a post via the <code>genesis_default_list_pings()</code> function.', 'simplehooks')
219
+ ));
220
+
221
+ simplehooks_form_generate(array(
222
+ 'hook' => 'genesis_after_pings',
223
+ 'desc' => __('This hook executes immediately after the pings block (outside the <code>#pings</code> div).', 'simplehooks')
224
+ ));
225
+
226
+ simplehooks_form_submit();
227
+
228
+ }
229
+
230
+ function simplehooks_comment_hooks_box() {
231
+
232
+ simplehooks_form_generate(array(
233
+ 'hook' => 'genesis_before_comment',
234
+ 'desc' => __('This hook executes immediately before each individual comment (inside the <code>.comment</code> list item).', 'simplehooks')
235
+ ));
236
+
237
+ simplehooks_form_generate(array(
238
+ 'hook' => 'genesis_comment',
239
+ 'desc' => __('This hook is available to add to the content of each comment.', 'simplehooks')
240
+ ));
241
+
242
+ simplehooks_form_generate(array(
243
+ 'hook' => 'genesis_after_comment',
244
+ 'desc' => __('This hook executes immediately after each individual comment (inside the <code>.comment</code> list item).', 'simplehooks')
245
+ ));
246
+
247
+ simplehooks_form_submit();
248
+
249
+ }
250
+
251
+ function simplehooks_comment_form_hooks_box() {
252
+
253
+ simplehooks_form_generate(array(
254
+ 'hook' => 'genesis_before_comment_form',
255
+ 'desc' => __('This hook executes immediately before the comment form, outside the <code>#respond</code> div.', 'simplehooks')
256
+ ));
257
+
258
+ simplehooks_form_generate(array(
259
+ 'hook' => 'genesis_comment_form',
260
+ 'desc' => __('This hook outputs the entire comment form, including the <code>#respond</code> div.', 'simplehooks')
261
+ ));
262
+
263
+ simplehooks_form_generate(array(
264
+ 'hook' => 'genesis_after_comment_form',
265
+ 'desc' => __('This hook executes immediately after the comment form, outside the <code>#respond</code> div.', 'simplehooks')
266
+ ));
267
+
268
+ simplehooks_form_submit();
269
+
270
+ }
271
+
272
+ function simplehooks_sidebar_hooks_box() {
273
+
274
+ simplehooks_form_generate(array(
275
+ 'hook' => 'genesis_before_sidebar_widget_area',
276
+ 'desc' => __('This hook executes immediately before the primary sidebar widget area (inside the <code>#sidebar</code> div).', 'simplehooks')
277
+ ));
278
+
279
+ simplehooks_form_generate(array(
280
+ 'hook' => 'genesis_after_sidebar_widget_area',
281
+ 'desc' => __('This hook executes immediately after the primary sidebar widget area (inside the <code>#sidebar</code> div).', 'simplehooks')
282
+ ));
283
+
284
+ simplehooks_form_generate(array(
285
+ 'hook' => 'genesis_before_sidebar_alt_widget_area',
286
+ 'desc' => __('This hook executes immediately before the alternate sidebar widget area (inside the <code>#sidebar-alt</code> div).', 'simplehooks')
287
+ ));
288
+
289
+ simplehooks_form_generate(array(
290
+ 'hook' => 'genesis_after_sidebar_alt_widget_area',
291
+ 'desc' => __('This hook executes immediately after the alternate sidebar widget area (inside the <code>#sidebar-alt</code> div).', 'simplehooks')
292
+ ));
293
+
294
+ simplehooks_form_submit();
295
+
296
+ }
297
+
298
+ function simplehooks_footer_hooks_box() {
299
+
300
+ simplehooks_form_generate(array(
301
+ 'hook' => 'genesis_before_footer',
302
+ 'desc' => __('This hook executes immediately before the footer (outside the <code>#footer</code> div).', 'simplehooks')
303
+ ));
304
+
305
+ simplehooks_form_generate(array(
306
+ 'hook' => 'genesis_footer',
307
+ 'desc' => __('This hook, by default, outputs the content of the footer (inside the <code>#footer</code> div).', 'simplehooks'),
308
+ 'unhook' => array('genesis_do_footer')
309
+ ));
310
+
311
+ simplehooks_form_generate(array(
312
+ 'hook' => 'genesis_after_footer',
313
+ 'desc' => __('This hook executes immediately after the footer (outside the <code>#footer</code> div).', 'simplehooks')
314
+ ));
315
+
316
+ simplehooks_form_submit();
317
+
318
+ }
319
+
320
+ /* Sample box and box content
321
+ function simplehooks__hooks_box() {
322
+
323
+ simplehooks_form_generate(array(
324
+ 'hook' => 'genesis_',
325
+ 'desc' => __('', 'simplehooks')
326
+ ));
327
+
328
+ simplehooks_form_submit();
329
+
330
+ }
331
+ */
functions.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Pull an EasyHook option from the database, return value
5
+ *
6
+ * @since 0.1
7
+ */
8
+ function simplehooks_get_option($hook = null, $field = null, $all = false) {
9
+
10
+ static $options = array();
11
+
12
+ $options = $options ? $options : get_option(SIMPLEHOOKS_SETTINGS_FIELD);
13
+
14
+ if( $all ) return $options;
15
+
16
+ if ( ! array_key_exists( $hook, (array)$options ) )
17
+ return '';
18
+
19
+ $option = $options[$hook][$field];
20
+ return wp_kses_stripslashes( wp_kses_decode_entities( $option ) );
21
+
22
+ }
23
+ /**
24
+ * Pull an EasyHook option from the database, echo value
25
+ *
26
+ * @since 0.1
27
+ */
28
+ function simplehooks_option($hook = null, $field = null) {
29
+ echo simplehooks_get_option($hook, $field);
30
+ }
31
+
32
+ /**
33
+ * This function generates the form code to be used in the metaboxes
34
+ *
35
+ * @since 0.1
36
+ */
37
+ function simplehooks_form_generate( $args = array() ) {
38
+
39
+ ?>
40
+
41
+ <h4><code><?php echo $args['hook']; ?></code> <?php _e('Hook', 'simplehooks'); ?></h4>
42
+ <p><span class="description"><?php echo $args['desc']; ?></span></p>
43
+
44
+ <?php
45
+ if( isset( $args['unhook'] ) ) {
46
+
47
+ foreach( (array)$args['unhook'] as $function ) {
48
+ ?>
49
+
50
+ <input type="checkbox" name="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][unhook][]" id="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][unhook][]" value="<?php echo $function; ?>" <?php if( in_array( $function, (array)simplehooks_get_option($args['hook'], 'unhook') ) ) echo 'checked'; ?> /> <label for="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][unhook][]"><?php printf(__('Unhook <code>%s()</code> function from this hook?', 'simplehooks'), $function); ?></label><br />
51
+
52
+ <?php
53
+ }
54
+
55
+ }
56
+ ?>
57
+
58
+ <p><textarea name="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][content]" cols="70" rows="5"><?php echo htmlentities( simplehooks_get_option($args['hook'], 'content') ); ?></textarea></p>
59
+
60
+ <p>
61
+ <input type="checkbox" name="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][shortcodes]" id="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][shortcodes]" value="1" <?php checked(1, simplehooks_get_option($args['hook'], 'shortcodes')); ?> /> <label for="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][shortcodes]"><?php _e('Execute Shortcodes on this hook?', 'simplehooks'); ?></label><br />
62
+ <input type="checkbox" name="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][php]" id="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][php]" value="1" <?php checked(1, simplehooks_get_option($args['hook'], 'php')); ?> /> <label for="<?php echo SIMPLEHOOKS_SETTINGS_FIELD; ?>[<?php echo $args['hook']; ?>][php]"><?php _e('Execute PHP on this hook?', 'simplehooks'); ?></label>
63
+ </p>
64
+
65
+ <hr class="div" />
66
+
67
+ <?php
68
+ }
69
+ function simplehooks_form_submit( $args = array() ) {
70
+ echo '<p><input type="submit" class="button-primary" value="'. __('Save Changes', 'simplehooks') .'" /></p>';
71
+ }
plugin.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Genesis Simple Hooks
4
+ Plugin URI: http://www.studiopress.com/plugins/simple-hooks
5
+ Description: Genesis Simple Hooks allows you easy access to the 50+ Action Hooks in the Genesis Theme.
6
+ Version: 0.9
7
+ Author: Nathan Rice
8
+ Author URI: http://www.nathanrice.net/
9
+ */
10
+
11
+ // require Genesis 1.1.2 upon activation
12
+ register_activation_hook(__FILE__, 'simplehooks_activation_check');
13
+ function simplehooks_activation_check() {
14
+
15
+ $latest = '1.1.2';
16
+
17
+ $theme_info = get_theme_data(TEMPLATEPATH.'/style.css');
18
+
19
+ if( basename(TEMPLATEPATH) != 'genesis' ) {
20
+ deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
21
+ wp_die('Sorry, you can\'t activate unless you have installed <a href="http://www.studiopress.com/themes/genesis">Genesis</a>');
22
+ }
23
+
24
+ if( version_compare( $theme_info['Version'], $latest, '<' ) ) {
25
+ deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
26
+ wp_die('Sorry, you can\'t activate without <a href="http://www.studiopress.com/support/showthread.php?t=19576">Genesis '.$latest.'</a> or greater');
27
+ }
28
+
29
+ }
30
+
31
+ // Define our constants
32
+ define('SIMPLEHOOKS_SETTINGS_FIELD', 'simplehooks-settings');
33
+ define('SIMPLEHOOKS_PLUGIN_DIR', dirname(__FILE__));
34
+
35
+ // Include files
36
+ require_once(SIMPLEHOOKS_PLUGIN_DIR . '/admin.php');
37
+ require_once(SIMPLEHOOKS_PLUGIN_DIR . '/functions.php');
38
+ require_once(SIMPLEHOOKS_PLUGIN_DIR . '/boxes.php');
39
+
40
+ /**
41
+ * The following code loops through all the hooks, and attempts to
42
+ * execute the code in the proper location.
43
+ *
44
+ * @since 0.1
45
+ */
46
+ add_action('genesis_init', 'simplehooks_execute_hooks');
47
+ function simplehooks_execute_hooks() {
48
+
49
+ $hooks = get_option(SIMPLEHOOKS_SETTINGS_FIELD);
50
+
51
+ foreach( (array)$hooks as $hook => $array ) {
52
+
53
+ // Add new content to hook
54
+ if( simplehooks_get_option($hook, 'content') ) {
55
+ add_action($hook, 'simplehooks_execute_hook');
56
+ }
57
+
58
+ // Unhook stuff
59
+ if( isset( $array['unhook'] ) ) {
60
+
61
+ foreach( (array)$array['unhook'] as $function ) {
62
+
63
+ remove_action($hook, $function);
64
+
65
+ }
66
+
67
+ }
68
+
69
+ }
70
+
71
+ }
72
+
73
+ /**
74
+ * The following function executes any code meant to be hooked.
75
+ * It checks to see if shortcodes or PHP should be executed as well.
76
+ *
77
+ * @since 0.1
78
+ */
79
+ function simplehooks_execute_hook() {
80
+
81
+ $hook = current_filter();
82
+ $content = simplehooks_get_option($hook, 'content');
83
+
84
+ if( !$hook || !$content ) return;
85
+
86
+ $shortcodes = simplehooks_get_option($hook, 'shortcodes');
87
+ $php = simplehooks_get_option($hook, 'php');
88
+
89
+ $value = $shortcodes ? do_shortcode($content) : $content;
90
+
91
+ if( $php )
92
+ eval( "?>$value<?php " );
93
+ else
94
+ echo $value;
95
+
96
+ }
readme.txt ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: nathanrice
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
4
+ Tags: hooks, genesis, genesiswp, studiopress
5
+ Requires at least: 2.9
6
+ Tested up to: 2.9.2
7
+ Stable tag: 0.9
8
+
9
+ This plugin creates a new Genesis settings page that allows you to insert code (HTML, Shortcodes, and PHP), and attach it to any of the 50+ action hooks throughout the Genesis Theme Framework, from StudioPress.
10
+
11
+ == Description ==
12
+
13
+ This plugin creates a new Genesis settings page that allows you to insert code (HTML, Shortcodes, and PHP), and attach it to any of the 50+ action hooks throughout the Genesis Theme Framework, from StudioPress.
14
+
15
+ Instead of the sometimes tedious and unfamiliar process of creating functions in your theme files, this plugin gives you an attractive, easy to use interface for modifying your Genesis theme via the hook system. The plugin accepts HTML, Shortcodes, and PHP and gives you access to all 50+ hooks built into the Genesis theme, and a few built-in WordPress hooks as well.
16
+
17
+ == Installation ==
18
+
19
+ 1. Upload the entire `genesis-simple-hooks` folder to the `/wp-content/plugins/` directory
20
+ 1. DO NOT change the name of the `genesis-simple-hooks` folder
21
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
22
+ 1. Find a hook that you'd like to use (they're grouped together logically)
23
+ 1. Insert the code you'd like to execute on that hook
24
+ 1. Choose whether or not to execute Shortcodes and PHP on that hook
25
+ 1. Save the changes
26
+
27
+ == Frequently Asked Questions ==
28
+
29
+ = What are Shortcodes? =
30
+
31
+ Check out the [Shortcodes API](http://codex.wordpress.org/Shortcode_API) for an explanation.
32
+
33
+ = My PHP isn't working =
34
+
35
+ Make sure the checkbox that says "Execute PHP on this hook" is checked.
36
+
37
+ If so, be sure to wrap any PHP code in `<?php ?>` tags. That's how the system recognizes code that needs to be executed as PHP.
38
+
39
+ = The plugin won't activate =
40
+
41
+ You must have Genesis or a Genesis child theme installed and activated on your site.
42
+
43
+ == Code Snippets ==
44
+
45
+ The most common request from Genesis users is how to properly modify their footer, post-info, and post-meta text. Here are some code snippets that might prove helpful in doing this:
46
+
47
+ **Modifying the post-info**
48
+ `
49
+ <div class="post-info">
50
+ <span class="time"><?php the_time('F j, Y'); ?></span> <span class="author">by <?php the_author_posts_link(); ?></span> <span class="post-comments"><a href="<?php the_permalink(); ?>#respond"><?php comments_number('Leave a Comment', '1 Comment', '% Comments'); ?></a></span> <a class="post-edit-link"><?php edit_post_link('(Edit)', '', ''); ?></a>
51
+ </div>
52
+ `
53
+
54
+ **Modifying the post-meta**
55
+ `
56
+ <div class="post-meta">
57
+ <span class="categories">Filed under: <?php the_category(', ') ?></span> <span class="tags">Tagged with <?php the_tags('') ?></span>
58
+ </div>
59
+ `
60
+
61
+ **Modifying the Footer**
62
+ `
63
+ <div class="gototop">
64
+ <p><a href="#wrap" rel="nofollow">Return to top of page</a></p>
65
+ </div>
66
+ <div class="creds">
67
+ <p>Copyright &copy; <?php echo date('Y'); ?> &middot; <a href="http://www.studiopress.com/themes/genesis" title="Genesis Theme Framework">Genesis Theme Framework</a> by <a href="http://www.studiopress.com/">StudioPress</a> &middot; <a href="http://wordpress.org/" title="WordPress">WordPress</a> &middot; <?php wp_loginout(); ?></p>
68
+ </div>
69
+ `
70
+
71
+ *Note: You must have the `Execute PHP on this hook` option selected in order to use template tags*
72
+
73
+ == Changelog ==
74
+
75
+ = 0.1 =
76
+ * Initial Release
77
+
78
+ = 0.9 =
79
+ * Add new hooks, remove deprecated hooks
80
+ * Fix textarea bug with HTML entities
81
+ * Bump to pre-release 0.9 branch