PluginProbe
Customize WordPress Emails and Alerts – Better Notifications for WP / 1.9
Customize WordPress Emails and Alerts – Better Notifications for WP v1.9
1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.8 1.8.1 1.8.10 1.8.11 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 All 81 releases
bnfw / includes / admin / bnfw-settings.php

bnfw-settings.php in Customize WordPress Emails and Alerts – Better Notifications for WP 1.9, at includes/admin/bnfw-settings.php

288 lines 9.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Register the Admin pages and load the scripts action
4 */
5
6 /**
7 * Sub-menu pages
8 */
9 function bnfw_admin_menu() {
10
11 // New Notifications Sub-menu
12 add_submenu_page(
13 'edit.php?post_type=bnfw_notification',
14 esc_html__( 'Notification Settings', 'bnfw' ),
15 esc_html__( 'Settings', 'bnfw' ),
16 'bnfw',
17 'bnfw-settings',
18 'bnfw_settings_page'
19 );
20 }
21
22 // Add the Admin pages to the WordPress menu
23 add_action( 'admin_menu', 'bnfw_admin_menu' );
24 add_action( 'admin_menu', 'bnfw_menu_item_links', 12 );
25 add_action( 'admin_head', 'bnfw_menu_item_link_targets' );
26
27 /* ------------------------------------------------------------------------ *
28 * Menu Pages
29 * ------------------------------------------------------------------------ */
30
31 /**
32 * Settings Page
33 */
34 function bnfw_settings_page() {
35 ob_start(); ?>
36
37 <div class="wrap">
38 <h2><?php esc_html_e( 'BNFW Settings', 'bnfw' ); ?></h2>
39
40 <form method="post" action="options.php" class="bnfw-form">
41 <?php
42 settings_errors();
43 settings_fields( 'bnfw-settings' );
44 do_settings_sections( 'bnfw-settings' );
45
46 submit_button( __( 'Save Settings', 'bnfw' ) );
47 ?>
48 </form>
49 </div>
50
51 <?php echo ob_get_clean();
52 }
53
54 /**
55 * External Menu Item Links
56 */
57 function bnfw_menu_item_links() {
58 global $submenu;
59
60 if ( current_user_can( 'bnfw' ) ) {
61 $doc_url = 'https://betternotificationsforwp.com/documentation/';
62 $store_url = 'https://betternotificationsforwp.com/downloads/';
63 $support_url = 'https://betternotificationsforwp.com/priority-support/';
64
65 if ( bnfw_is_tracking_allowed() ) {
66 $doc_url .= '?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Documentation"&amp;utm_medium=referral';
67 $store_url .= '?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Add-on"&amp;utm_medium=referral';
68 $support_url .= '?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Priority%20Support"&amp;utm_medium=referral';
69 }
70
71 // Documentation Link
72 $submenu['edit.php?post_type=bnfw_notification'][500] = array(
73 '<div id="bnfw-menu-item-documentation" style="color: #93a2cb;">' . __( 'Documentation', 'bnfw' ) . '</div>',
74 'bnfw',
75 $doc_url,
76 );
77
78 // Add-ons Link
79 $submenu['edit.php?post_type=bnfw_notification'][600] = array(
80 '<div id="bnfw-menu-item-addons" style="color: #d5c2f3;">' . __( 'Premium Add-ons', 'bnfw' ) . '</div>',
81 'bnfw',
82 $store_url,
83 );
84
85 // Add-ons Link
86 $submenu['edit.php?post_type=bnfw_notification'][700] = array(
87 '<div id="bnfw-menu-item-support" style="color: #e98c90;">' . __( 'Priority Support', 'bnfw' ) . '</div>',
88 'bnfw',
89 $support_url,
90 );
91 }
92 }
93
94 function bnfw_menu_item_link_targets() {
95 ?>
96 <script type="text/javascript">
97 jQuery( document ).ready( function ( $ ) {
98 // Documentation Link
99 $( '#bnfw-menu-item-documentation' ).parent().attr( 'target', '_blank' );
100 $( '#bnfw-menu-item-documentation' ).hover( function () {
101 $( this ).css( 'color', '#93a2cb' );
102 }, function () {
103 $( this ).css( 'color', '#7f91c0' );
104 } );
105
106 // Add-ons Link
107 $( '#bnfw-menu-item-addons' ).parent().attr( 'target', '_blank' );
108 $( '#bnfw-menu-item-addons' ).hover( function () {
109 $( this ).css( 'color', '#d5c2f3' );
110 }, function () {
111 $( this ).css( 'color', '#bea6e3' );
112 } );
113
114 // Priority Support Link
115 $( '#bnfw-menu-item-support' ).parent().attr( 'target', '_blank' );
116 $( '#bnfw-menu-item-support' ).hover( function () {
117 $( this ).css( 'color', '#e98c90' );
118 }, function () {
119 $( this ).css( 'color', '#db7b7f' );
120 } );
121 } );
122 </script>
123 <?php }
124
125 /* ------------------------------------------------------------------------ *
126 * Settings Page - Setting Registration
127 * ------------------------------------------------------------------------ */
128
129 /**
130 *
131 */
132 function bnfw_general_options() {
133 // Set-up - General Options Section
134 add_settings_section(
135 'bnfw_general_options_section', // Section ID
136 '', // Title above settings section
137 'bnfw_general_options_callback', // Name of function that renders a description of the settings section
138 'bnfw-settings' // Page to show on
139 );
140
141 // Register - Suppress SPAM Checkbox
142 register_setting(
143 'bnfw-settings',
144 'bnfw_suppress_spam'
145 );
146
147 // Suppress notifications for SPAM comments
148 add_settings_field(
149 'bnfw_suppress_spam', // Field ID
150 esc_html__( 'Suppress SPAM comment notification', 'bnfw' ) . '<div class="bnfw-help-tip"><p>' . esc_html__( 'Comments that are correctly marked as SPAM by a 3rd party plugin (such as Akismet) will not generate a notification if this is ticked.', 'bnfw' ) . '</p></div>', // Label to the left
151 'bnfw_suppress_spam_checkbox', // Name of function that renders options on the page
152 'bnfw-settings', // Page to show on
153 'bnfw_general_options_section', // Associate with which settings section?
154 array(
155 esc_html__( 'Don\'t send notifications for comments marked as SPAM', 'bnfw' )
156 )
157 );
158
159 // Register - Email Format setting
160 register_setting(
161 'bnfw-settings',
162 'bnfw_email_format'
163 );
164
165 add_settings_field(
166 'bnfw_email_format', // Field ID
167 esc_html__( 'Default Email Format', 'bnfw' ) . '<div class="bnfw-help-tip"><p>' . esc_html__( 'This will apply to all emails sent out via WordPress, even those from other plugins. For more details, please see the ', 'bnfw' ) . '<a href="https://wordpress.org/plugins/bnfw/faq/" target="_blank">FAQ</a>.</p></div>', // Label to the left
168 'bnfw_email_format_radio', // Name of function that renders options on the page
169 'bnfw-settings', // Page to show on
170 'bnfw_general_options_section' // Associate with which settings section?
171 );
172
173 // Register - Email Format setting
174 register_setting(
175 'bnfw-settings',
176 'bnfw_enable_shortcodes'
177 );
178
179 add_settings_field(
180 'bnfw_enable_shortcodes', // Field ID
181 esc_html__( 'Enable Content Shortcodes?', 'bnfw' ) . '<div class="bnfw-help-tip"><p>' . esc_html__( 'Shortcodes in the post/page content are disabled by default.', 'bnfw' ) . '</p></div>', // Label to the left
182 'bnfw_enable_shortcodes_checkbox', // Name of function that renders options on the page
183 'bnfw-settings', // Page to show on
184 'bnfw_general_options_section', // Associate with which settings section?
185 array(
186 esc_html__( 'Enable shortcode output in the page/post content', 'bnfw' ),
187 )
188 );
189
190 // Register - Allow tracking setting
191 register_setting(
192 'bnfw-settings',
193 'bnfw_allow_tracking'
194 );
195
196 add_settings_field(
197 'bnfw_allow_tracking', // Field ID
198 esc_html__( 'Allow Usage Tracking?', 'bnfw' ), // Label to the left
199 'bnfw_render_allow_tracking', // Name of function that renders options on the page
200 'bnfw-settings', // Page to show on
201 'bnfw_general_options_section', // Associate with which settings section?
202 array(
203 esc_html__( 'Allow Better Notifications for WP to anonymously track how this plugin is used and help make the plugin better.', 'bnfw' )
204 )
205 );
206 }
207
208 add_action( 'admin_init', 'bnfw_general_options', 10 );
209
210 /* ------------------------------------------------------------------------ *
211 * Settings Page - Settings Section Callbacks
212 * ------------------------------------------------------------------------ */
213
214 /**
215 *
216 */
217 function bnfw_general_options_callback() {
218 }
219
220 /* ------------------------------------------------------------------------ *
221 * Settings Page - Settings Field Callbacks
222 * ------------------------------------------------------------------------ */
223
224 /**
225 * Suppress SPAM checkbox.
226 *
227 * @since 1.0
228 *
229 * @param $args
230 */
231 function bnfw_suppress_spam_checkbox( $args ) {
232 ?>
233 <input type="checkbox" id="bnfw_suppress_spam" name="bnfw_suppress_spam"
234 value="1" <?php checked( 1, get_option( 'bnfw_suppress_spam' ), true ); ?>>
235 <label for="bnfw_suppress_spam"><?php echo esc_html( $args[0] ); ?></label>
236 <?php
237 }
238
239 /**
240 * Show email format radio
241 *
242 * @since 1.4
243 *
244 * @param array $args
245 */
246 function bnfw_email_format_radio( $args ) {
247 $email_format = get_option( 'bnfw_email_format', 'html' );
248 ?>
249 <label>
250 <input type="radio" value="html"
251 name="bnfw_email_format" <?php checked( $email_format, 'html', true ); ?>><?php esc_html_e( 'HTML Formatting', 'bnfw' ); ?>
252 </label>
253 <br/>
254 <label>
255 <input type="radio" value="text"
256 name="bnfw_email_format" <?php checked( $email_format, 'text', true ); ?>><?php esc_html_e( 'Plain Text', 'bnfw' ); ?>
257 </label>
258 <?php
259 }
260
261 /**
262 * Render allow tracking checkbox.
263 *
264 * @since 1.6
265 *
266 * @param array $args
267 */
268 function bnfw_render_allow_tracking( $args ) {
269 ?>
270 <input type="checkbox" id="bnfw_allow_tracking" name="bnfw_allow_tracking"
271 value="on" <?php checked( 'on', get_option( 'bnfw_allow_tracking' ), true ); ?>>
272 <label for="bnfw_allow_tracking"><?php echo esc_html( $args[0] ); ?></label>
273 <?php
274 }
275
276 /**
277 * Render Enable shortcode checkbox.
278 *
279 * @param array $args
280 */
281 function bnfw_enable_shortcodes_checkbox( $args ) {
282 ?>
283 <input type="checkbox" id="bnfw_enable_shortcodes" name="bnfw_enable_shortcodes"
284 value="1" <?php checked( 1, get_option( 'bnfw_enable_shortcodes' ), true ); ?>>
285 <label for="bnfw_enable_shortcodes"><?php echo esc_html( $args[0] ); ?></label>
286 <?php
287 }
288