| 1 |
<?php |
| 2 |
/** |
| 3 |
* WP-Members Admin Functions |
| 4 |
* |
| 5 |
* Handles functions that output admin dialogs to adminstrative users. |
| 6 |
* |
| 7 |
* This file is part of the WP-Members plugin by Chad Butler |
| 8 |
* You can find out more about this plugin at https://rocketgeek.com |
| 9 |
* Copyright (c) 2006-2026 Chad Butler |
| 10 |
* WP-Members(tm) is a trademark of butlerblog.com |
| 11 |
* |
| 12 |
* @package WP-Members |
| 13 |
* @author Chad Butler |
| 14 |
* @copyright 2006-2026 |
| 15 |
*/ |
| 16 |
|
| 17 |
// Exit if accessed directly. |
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit(); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Outputs the various admin warning messages. |
| 24 |
* |
| 25 |
* @since 2.8.0 |
| 26 |
* |
| 27 |
* @param string $did_update Contains the update message. |
| 28 |
* @param array $wpmem_settings Array containing the plugin settings. |
| 29 |
*/ |
| 30 |
function wpmem_a_do_warnings( $did_update ) { |
| 31 |
|
| 32 |
global $wpmem; |
| 33 |
|
| 34 |
/** This filter is documented in /includes/class-wp-members-admin-api.php */ |
| 35 |
$dialogs = apply_filters( 'wpmem_dialogs', get_option( 'wpmembers_dialogs' ) ); |
| 36 |
|
| 37 |
if ( $did_update != false ) {?> |
| 38 |
<div id="message" class="updated fade"><p><strong><?php echo $did_update; ?></strong></p></div><?php |
| 39 |
} |
| 40 |
|
| 41 |
/* |
| 42 |
* Configuration warnings. |
| 43 |
*/ |
| 44 |
|
| 45 |
// Are warnings turned off? |
| 46 |
$warnings_on = ( $wpmem->warnings == 0 ) ? true : false; |
| 47 |
|
| 48 |
// Is there an active warning? |
| 49 |
$active_warnings = array(); |
| 50 |
|
| 51 |
// Settings allow anyone to register. |
| 52 |
if ( get_option( 'users_can_register' ) != 0 && $warnings_on ) { |
| 53 |
$active_warnings[] = wpmem_a_warning_msg( 'users_can_register' ); |
| 54 |
} |
| 55 |
|
| 56 |
// Settings allow anyone to comment. |
| 57 |
if ( get_option( 'comment_registration' ) !=1 && $warnings_on ) { |
| 58 |
$active_warnings[] = wpmem_a_warning_msg( 'comment_registration' ); |
| 59 |
} |
| 60 |
|
| 61 |
// Rss set to full text feeds. |
| 62 |
if ( get_option( 'rss_use_excerpt' ) !=1 && $warnings_on ) { |
| 63 |
$active_warnings[] = wpmem_a_warning_msg( 'rss_use_excerpt' ); |
| 64 |
} |
| 65 |
|
| 66 |
// Holding registrations but haven't changed default successful registration message. |
| 67 |
if ( $warnings_on && $wpmem->mod_reg == 1 && $dialogs['success'] == wpmem_get_text( 'success' ) ) { |
| 68 |
$active_warnings[] = wpmem_a_warning_msg( 'success' ); |
| 69 |
} |
| 70 |
|
| 71 |
// Haven't entered recaptcha api keys. |
| 72 |
if ( $warnings_on && $wpmem->captcha > 0 ) { |
| 73 |
$wpmem_captcha = get_option( 'wpmembers_captcha' ); |
| 74 |
if ( 1 == $wpmem->captcha || 3 == $wpmem->captcha ) { |
| 75 |
if ( ! isset( $wpmem_captcha['recaptcha']['public'] ) || ! isset( $wpmem_captcha['recaptcha']['private'] ) ) { |
| 76 |
$active_warnings[] = wpmem_a_warning_msg( 'wpmembers_captcha' ); |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
// If there is an active warning, display message about warnings. |
| 82 |
if ( ! empty( $active_warnings ) ) { |
| 83 |
$strong_msg = esc_html__( 'WP-Members Options', 'wp-members' ) . ': ' . esc_html__( 'You have active settings that are not recommended.', 'wp-members' ); |
| 84 |
$remain_msg = esc_html__( 'If you will not be changing these settings, you can turn off this warning message by checking the "Ignore warning messages" in the settings below.', 'wp-members' ); |
| 85 |
|
| 86 |
echo '<div class="error"><p><strong>' . $strong_msg . '</strong></p><ul style="list-style:initial; margin:5px 20px">'; |
| 87 |
foreach ( $active_warnings as $warning ) { |
| 88 |
echo $warning; |
| 89 |
} |
| 90 |
echo '</ul>'; |
| 91 |
echo '<p>' . $remain_msg . '</p></div>'; |
| 92 |
} |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
/** |
| 98 |
* Assembles the various admin warning messages. |
| 99 |
* |
| 100 |
* @since 2.4.0 |
| 101 |
* @since 3.1.0 Changed $msg argument to string. |
| 102 |
* |
| 103 |
* @param string $msg The number for which message should be displayed. |
| 104 |
*/ |
| 105 |
function wpmem_a_warning_msg( $msg ) { |
| 106 |
|
| 107 |
$strong_msg = $remain_msg = $span_msg = ''; |
| 108 |
|
| 109 |
switch ( $msg ) { |
| 110 |
|
| 111 |
case 'users_can_register': |
| 112 |
$strong_msg = esc_html__( 'Your WP settings allow anyone to register - this is not the recommended setting.', 'wp-members' ); |
| 113 |
$remain_msg = sprintf( esc_html__( 'You can %s change this here %s making sure the box next to "Anyone can register" is unchecked.', 'wp-members'), '<a href="options-general.php" target="_blank">', '</a>' ); |
| 114 |
$span_msg = esc_html__( 'If you do not want users to register through wp-login.php, uncheck this option.', 'wp-members' ); |
| 115 |
break; |
| 116 |
|
| 117 |
case 'comment_registration': |
| 118 |
$strong_msg = esc_html__( 'Your WP settings allow anyone to comment - this is not the recommended setting.', 'wp-members' ); |
| 119 |
$remain_msg = sprintf( esc_html__( 'You can %s change this here %s by checking the box next to "Users must be registered and logged in to comment."', 'wp-members' ), '<a href="options-discussion.php" target="_blank">', '</a>' ); |
| 120 |
$span_msg = esc_html__( 'If you do not want non-registered users to comment, change this setting.', 'wp-members' ); |
| 121 |
break; |
| 122 |
|
| 123 |
case 'rss_use_excerpt': |
| 124 |
$strong_msg = esc_html__( 'Your WP settings allow full text rss feeds - this is not the recommended setting.', 'wp-members' ); |
| 125 |
$remain_msg = sprintf( esc_html__( 'You can %s change this here %s by changing "For each article in a feed, show" to "Summary."', 'wp-members' ), '<a href="options-reading.php" target="_blank">' , '</a>' ); |
| 126 |
$span_msg = esc_html__( 'Full text feeds allow your protected content in an RSS reader.', 'wp-members' ); |
| 127 |
break; |
| 128 |
|
| 129 |
case 'success': |
| 130 |
$strong_msg = esc_html__( 'You have set WP-Members to hold registrations for approval', 'wp-members' ); |
| 131 |
$remain_msg = esc_html__( 'but you have not changed the default message for "Registration Completed" under "WP-Members Dialogs and Error Messages." You should change this message to let users know they are pending approval.', 'wp-members' ); |
| 132 |
break; |
| 133 |
|
| 134 |
case 'wpmembers_captcha': |
| 135 |
$strong_msg = esc_html__( 'You have turned on reCAPTCHA', 'wp-members'); |
| 136 |
$remain_msg = esc_html__( 'but you have not entered API keys. You will need both a public and private key. The CAPTCHA will not display unless a valid API key is included.', 'wp-members' ); |
| 137 |
break; |
| 138 |
|
| 139 |
} |
| 140 |
|
| 141 |
if ( $span_msg ) { |
| 142 |
$span_msg = ' [<span data-tooltip="' . $span_msg . '">why is this?</span>]'; |
| 143 |
} |
| 144 |
|
| 145 |
return '<li><strong>' . $strong_msg . '</strong> ' . $remain_msg . $span_msg . '</li>'; |
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
/** |
| 151 |
* Assemble the side meta box. |
| 152 |
* |
| 153 |
* @since 2.8.0 |
| 154 |
* |
| 155 |
* @global object $wpmem |
| 156 |
*/ |
| 157 |
function wpmem_a_meta_box() { |
| 158 |
|
| 159 |
global $wpmem; |
| 160 |
|
| 161 |
?><div class="postbox"> |
| 162 |
<h3><span>WP-Members Information</span></h3> |
| 163 |
<div class="inside"> |
| 164 |
|
| 165 |
<p><strong><?php _e( 'Version:', 'wp-members' ); echo " " . $wpmem->version; ?></strong><br /> |
| 166 |
<a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/"><?php _e( 'Quick Start Guide', 'wp-members' ); ?></a><br /> |
| 167 |
<a href="https://rocketgeek.com/plugins/wp-members/docs/"><?php _e( 'Online User Guide', 'wp-members' ); ?></a><br /> |
| 168 |
<a href="https://rocketgeek.com/plugins/wp-members/docs/faqs/"><?php _e( 'FAQs', 'wp-members' ); ?></a> |
| 169 |
<?php if( ! defined( 'WPMEM_REMOVE_ATTR' ) ) { ?> |
| 170 |
<br /><br /><a href="https://rocketgeek.com/about/site-membership-subscription/">Find out how to get access</a> to WP-Members private members forum, premium code snippets, tutorials, and add-on modules! |
| 171 |
<?php } ?> |
| 172 |
</p> |
| 173 |
|
| 174 |
<p><i> |
| 175 |
<?php _e( 'Thank you for using WP-Members', 'wp-members' ); ?>™!<br /><br /> |
| 176 |
<?php _e( 'A plugin developed by', 'wp-members' ); ?> <a href="http://butlerblog.com">Chad Butler</a><br /> |
| 177 |
<?php _e( 'Follow', 'wp-members' ); ?> ButlerBlog: <a href="http://feeds.butlerblog.com/butlerblog" target="_blank">RSS</a> | <a href="http://www.twitter.com/butlerblog" target="_blank">Twitter</a><br /> |
| 178 |
Copyright © 2006-<?php echo date("Y"); ?><br /><br /> |
| 179 |
Premium support and installation service <a href="https://rocketgeek.com/about/site-membership-subscription/">available at rocketgeek.com</a>. |
| 180 |
</i></p> |
| 181 |
</div> |
| 182 |
</div><?php |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
/** |
| 187 |
* Assemble the rocketgeek.com rss feed box. |
| 188 |
* |
| 189 |
* @since 2.8.0 |
| 190 |
*/ |
| 191 |
function wpmem_a_rss_box() { |
| 192 |
|
| 193 |
?><div class="postbox"> |
| 194 |
<h3><span><?php _e( 'Latest from RocketGeek', 'wp-members' ); ?></span></h3> |
| 195 |
<div class="inside"><?php |
| 196 |
wp_widget_rss_output( array( |
| 197 |
'url' => 'https://rocketgeek.com/feed/', //put your feed URL here |
| 198 |
'title' => esc_html__( 'Latest from RocketGeek', 'wp-members' ), |
| 199 |
'items' => 4, //how many posts to show |
| 200 |
'show_summary' => 0, |
| 201 |
'show_author' => 0, |
| 202 |
'show_date' => 0, |
| 203 |
) );?> |
| 204 |
</div> |
| 205 |
</div><?php |
| 206 |
} |
| 207 |
|
| 208 |
/** |
| 209 |
* Adds the rating request meta box. |
| 210 |
* |
| 211 |
* @since 3.2.0 |
| 212 |
*/ |
| 213 |
function wpmem_a_rating_box() { |
| 214 |
?><div class="postbox"> |
| 215 |
<h3><?php _e( 'Like WP-Members?', 'wp-members' ); ?></h3> |
| 216 |
<div class="inside"><?php echo sprintf( esc_html__( 'If you like WP-Members please give it a %s★★★★★%s rating. Thanks!!', 'wp-members' ), '<a href="https://wordpress.org/support/plugin/wp-members/reviews?rate=5#new-post">', '</a>' ); ?></div> |
| 217 |
</div><?php |
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
/** |
| 222 |
* Add the dashboard widget. |
| 223 |
* |
| 224 |
* @since 2.8.0 |
| 225 |
*/ |
| 226 |
function butlerblog_dashboard_widget() { |
| 227 |
wp_add_dashboard_widget( 'dashboard_custom_feed', esc_html__( 'Latest from ButlerBlog', 'wp-members' ), 'butlerblog_feed_output' ); |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
/** |
| 232 |
* Output the rss feed for the dashboard widget. |
| 233 |
* |
| 234 |
* @since 2.8.0 |
| 235 |
*/ |
| 236 |
function butlerblog_feed_output() { |
| 237 |
echo '<div class="rss-widget">'; |
| 238 |
wp_widget_rss_output( array( |
| 239 |
'url' => 'https://feeds.feedburner.com/butlerblog', |
| 240 |
'title' => esc_html__( 'Latest from ButlerBlog', 'wp-members' ), |
| 241 |
'items' => 5, |
| 242 |
'show_summary' => 0, |
| 243 |
'show_author' => 0, |
| 244 |
'show_date' => 1, |
| 245 |
) ); |
| 246 |
echo "</div>"; |
| 247 |
} |
| 248 |
|
| 249 |
// End of file. |