PageRenderTime 27ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/public/wp-content/plugins/better-wp-security/core/modules/core/class-itsec-core-admin.php

https://gitlab.com/kath.de/cibedo_cibedo.de
PHP | 390 lines | 221 code | 91 blank | 78 comment | 40 complexity | a67b76d0e05e38c76ccbe1939f84da4d MD5 | raw file
  1. <?php
  2. class ITSEC_Core_Admin {
  3. function run() {
  4. add_action( 'itsec_add_admin_meta_boxes', array( $this, 'add_admin_meta_boxes' ) ); //add meta boxes to admin page
  5. add_filter( 'itsec_meta_links', array( $this, 'add_plugin_meta_links' ) );
  6. //Process support plugin nag
  7. add_action( 'itsec_admin_init', array( $this, 'setup_nag' ) );
  8. //Process support plugin nag
  9. add_action( 'itsec_admin_init', array( $this, 'support_nag' ) );
  10. }
  11. /**
  12. * Add meta boxes to primary options pages.
  13. *
  14. * @since 4.0
  15. *
  16. * @param array $available_pages array of available page_hooks
  17. *
  18. * @return void
  19. */
  20. public function add_admin_meta_boxes( $available_pages ) {
  21. foreach ( $available_pages as $page ) {
  22. add_meta_box(
  23. 'itsec_security_updates',
  24. __( 'Download Our WordPress Security Pocket Guide', 'better-wp-security' ),
  25. array( $this, 'metabox_security_updates' ),
  26. $page,
  27. 'priority_side',
  28. 'core'
  29. );
  30. if ( ! class_exists( 'backupbuddy_api' ) ) {
  31. add_meta_box(
  32. 'itsec_get_backup',
  33. __( 'Complete Your Security Strategy With BackupBuddy', 'better-wp-security' ),
  34. array( $this, 'metabox_get_backupbuddy' ),
  35. $page,
  36. 'priority_side',
  37. 'core'
  38. );
  39. }
  40. add_meta_box(
  41. 'itsec_sync_integration',
  42. __( 'Manage Your Sites Remotely', 'better-wp-security' ),
  43. array( $this, 'metabox_sync_integration' ),
  44. $page,
  45. 'side',
  46. 'core'
  47. );
  48. add_meta_box(
  49. 'itsec_need_help',
  50. __( 'Need Help Securing Your Site?', 'better-wp-security' ),
  51. array( $this, 'metabox_need_help' ),
  52. $page,
  53. 'side',
  54. 'core'
  55. );
  56. }
  57. add_meta_box(
  58. 'itsec_get_started',
  59. __( 'Getting Started', 'better-wp-security' ),
  60. array( $this, 'metabox_get_started' ),
  61. 'toplevel_page_itsec',
  62. 'normal',
  63. 'core'
  64. );
  65. }
  66. /**
  67. * Adds links to the plugin row meta
  68. *
  69. * @since 4.0
  70. *
  71. * @param array $meta Existing meta
  72. *
  73. * @return array
  74. */
  75. public function add_plugin_meta_links( $meta ) {
  76. $meta[] = '<a href="https://ithemes.com/security?utm_source=wordpressadmin&utm_medium=banner&utm_campaign=itsecfreecta" target="_blank">' . __( 'Get Support', 'better-wp-security' ) . '</a>';
  77. return $meta;
  78. }
  79. /**
  80. * Display the Get BackupBuddy metabox
  81. *
  82. * @since 4.0
  83. *
  84. * @return void
  85. */
  86. public function metabox_get_backupbuddy() {
  87. echo '<p style="text-align: center;"><img src="' . plugins_url( 'img/backupbuddy-logo.png', __FILE__ ) . '" alt="BackupBuddy"></p>';
  88. echo '<p>' . __( 'BackupBuddy is the complete backup, restore and migration solution for your WordPress site. Schedule automated backups, store your backups safely off-site and restore your site quickly & easily.', 'better-wp-security' ) . '</p>';
  89. echo sprintf( '<p style="font-weight: bold; font-size: 1em;">%s<span style="display: block; text-align: center; font-size: 1.2em; background: #ebebeb; padding: .5em;">%s</span></p>', __( '25% off BackupBuddy with coupon code', 'better-wp-security' ), __( 'BACKUPPROTECT', 'better-wp-security' ) );
  90. echo '<a href="http://ithemes.com/better-backups" class="button-secondary" target="_blank">' . __( 'Get BackupBuddy', 'better-wp-security' ) . '</a>';
  91. }
  92. /**
  93. * Display the metabox for getting started
  94. *
  95. * @since 4.0
  96. *
  97. * @return void
  98. */
  99. public function metabox_get_started() {
  100. echo '<div class="itsec_getting_started">';
  101. echo '<div class="column">';
  102. echo '<h2>' . __( 'Watch the Walk-Through Video', 'better-wp-security' ) . '</h2>';
  103. echo '<a class="itsec-video-link" href="#" data-video-id="itsec_video"><img src="' . plugins_url( 'img/video.png', __FILE__ ) . '" /></a>';
  104. echo sprintf( '<p class="itsec-video-description">%s <a href="http://ithem.es/6y" target="_blank">%s</a> %s </p>', __( 'In this short video, we walk through', 'better-wp-security' ), __( 'how to get started securing your site', 'better-wp-security' ), __( 'with iThemes Security.', 'better-wp-security' ) );
  105. echo '<p class="itsec_video"><iframe src="//player.vimeo.com/video/89142424?title=0&amp;byline=0&amp;portrait=0" width="853" height="480" frameborder="0" ></iframe></p>';
  106. echo '</div>';
  107. echo '<div class="column two">';
  108. echo '<h2>' . __( 'Website Security is a complicated subject, but we have experts that can help.', 'better-wp-security' ) . '</h2>';
  109. echo '<p>' . __( 'Get added peace of mind with professional support from our expert team and pro features to take your site security to the next level with iThemes Security Pro.', 'better-wp-security' ) . '</p>';
  110. echo '<p><a class="button-primary" href="https://ithemes.com/security?utm_source=wordpressadmin&utm_medium=banner&utm_campaign=itsecfreecta" target="_blank">' . __( 'Get Support and Pro Features', 'better-wp-security' ) . '</a></p>';
  111. echo '</div>';
  112. echo '</div>';
  113. }
  114. /**
  115. * Display the Need Help metabox
  116. *
  117. * @since 4.0
  118. *
  119. * @return void
  120. */
  121. public function metabox_need_help() {
  122. echo '<p>' . __( 'Since you are using the free version of iThemes Security from WordPress.org, you can get free support from the WordPress community.', 'better-wp-security' ) . '</p>';
  123. echo '<p><a class="button-secondary" href="http://wordpress.org/support/plugin/better-wp-security" target="_blank">' . __( 'Get Free Support', 'better-wp-security' ) . '</a></p>';
  124. echo '<p>' . __( 'Get added peace of mind with professional support from our expert team and pro features with iThemes Security Pro.', 'better-wp-security' ) . '</p>';
  125. echo '<p><a class="button-secondary" href="https://ithemes.com/security/?utm_source=wordpressadmin&utm_medium=widget&utm_campaign=itsecfreecta" target="_blank">' . __( 'Get iThemes Security Pro', 'better-wp-security' ) . '</a></p>';
  126. }
  127. /**
  128. * Display the Security Updates signup metabox.
  129. *
  130. * @since 4.0
  131. *
  132. * @return void
  133. */
  134. public function metabox_security_updates() {
  135. ob_start();
  136. ?>
  137. <div id="mc_embed_signup">
  138. <form
  139. action="https://ithemes.us2.list-manage.com/subscribe/post?u=7acf83c7a47b32c740ad94a4e&amp;id=5176bfed9e"
  140. method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
  141. target="_blank" novalidate>
  142. <div style="text-align: center;">
  143. <img src="<?php echo plugins_url( 'img/security-ebook.png', __FILE__ ) ?>" width="145"
  144. height="187" alt="WordPress Security - A Pocket Guide">
  145. </div>
  146. <p><?php _e( 'Get tips for securing your site + the latest WordPress security updates, news and releases from iThemes.', 'better-wp-security' ); ?></p>
  147. <div id="mce-responses" class="clear">
  148. <div class="response" id="mce-error-response" style="display:none"></div>
  149. <div class="response" id="mce-success-response" style="display:none"></div>
  150. </div>
  151. <label for="mce-EMAIL"
  152. style="display: block;margin-bottom: 3px;"><?php _e( 'Email Address', 'better-wp-security' ); ?></label>
  153. <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL"
  154. placeholder="email@domain.com"> <br/><br/> <input type="submit"
  155. value="<?php _e( 'Subscribe', 'better-wp-security' ); ?>"
  156. name="subscribe"
  157. id="mc-embedded-subscribe"
  158. class="button button-secondary">
  159. </form>
  160. </div>
  161. <?php
  162. ob_end_flush();
  163. }
  164. /**
  165. * Display the Need Help metabox
  166. *
  167. * @since 4.0
  168. *
  169. * @return void
  170. */
  171. public function metabox_sync_integration() {
  172. ?>
  173. <div style="text-align: center;">
  174. <img src="<?php echo plugins_url( 'img/sync-logo.png', __FILE__ ) ?>" width="173"
  175. height="65" alt="Manage Your Sites Remotely">
  176. </div>
  177. <?php
  178. echo '<p>' . __( 'Manage updates remotely for up to 10 WordPress sites today for free!', 'better-wp-security' ) . '</p>';
  179. echo '<p>' . __( 'Integrated with iThemes Security, so you can release lockouts and turn Away Mode on or off right from your Sync dashboard or your phone.', 'better-wp-security' ) . '</p>';
  180. echo '<div style="text-align: center;">';
  181. echo '<p><a class="button-primary" href="http://www.ithemes.com/sync" target="_blank">' . __( 'Try iThemes Sync for Free', 'better-wp-security' ) . '</a></p>';
  182. echo '</div>';
  183. }
  184. /**
  185. * Display (and hide) setup nag.
  186. *
  187. * @since 4.0
  188. *
  189. * @return void
  190. */
  191. public function setup_nag() {
  192. global $blog_id, $itsec_globals;
  193. if ( is_multisite() && ( $blog_id != 1 || ! current_user_can( 'manage_network_options' ) ) ) { //only display to network admin if in multisite
  194. return;
  195. }
  196. $options = $itsec_globals['data'];
  197. //display the notifcation if they haven't turned it off
  198. if ( ( ! isset( $options['setup_completed'] ) || $options['setup_completed'] === false ) ) {
  199. if ( ! function_exists( 'ithemes_plugin_setup_notice' ) ) {
  200. function ithemes_plugin_setup_notice() {
  201. global $itsec_globals;
  202. echo '<div class="updated" id="itsec_setup_notice"><span class="it-icon-itsec"></span>'
  203. . $itsec_globals['plugin_name'] . ' ' . __( 'is almost ready.', 'better-wp-security' ) . '<a href="#" class="itsec-notice-button" onclick="document.location.href=\'?itsec_setup=yes&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';">' . __( 'Secure Your Site Now', 'better-wp-security' ) . '</a><a href="#" class="itsec-notice-hide" onclick="document.location.href=\'?itsec_setup=no&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';">&times;</a>
  204. </div>';
  205. }
  206. }
  207. if ( is_multisite() ) {
  208. add_action( 'network_admin_notices', 'ithemes_plugin_setup_notice' ); //register notification
  209. } else {
  210. add_action( 'admin_notices', 'ithemes_plugin_setup_notice' ); //register notification
  211. }
  212. }
  213. //if they've clicked a button hide the notice
  214. if ( isset( $_GET['itsec_setup'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'itsec-nag' ) ) {
  215. $options = $itsec_globals['data'];
  216. $options['setup_completed'] = true;
  217. update_site_option( 'itsec_data', $options );
  218. if ( is_multisite() ) {
  219. remove_action( 'network_admin_notices', 'ithemes_plugin_setup_notice' );
  220. } else {
  221. remove_action( 'admin_notices', 'ithemes_plugin_setup_notice' );
  222. }
  223. if ( sanitize_text_field( $_GET['itsec_setup'] ) == 'no' && isset( $_SERVER['HTTP_REFERER'] ) ) {
  224. wp_redirect( $_SERVER['HTTP_REFERER'], '302' );
  225. } else {
  226. wp_redirect( 'admin.php?page=itsec', '302' );
  227. }
  228. }
  229. }
  230. /**
  231. * Display (and hide) support the plugin reminder.
  232. *
  233. * This will display a notice to the admin of the site only asking them to support
  234. * the plugin after they have used it for 30 days.
  235. *
  236. * @since 4.0
  237. *
  238. * @return void
  239. */
  240. public function support_nag() {
  241. global $blog_id, $itsec_globals;
  242. if ( is_multisite() && ( $blog_id != 1 || ! current_user_can( 'manage_network_options' ) ) ) { //only display to network admin if in multisite
  243. return;
  244. }
  245. $options = $itsec_globals['data'];
  246. //display the notifcation if they haven't turned it off and they've been using the plugin at least 30 days
  247. if ( ( ! isset( $options['already_supported'] ) || $options['already_supported'] === false ) && $options['activation_timestamp'] < ( $itsec_globals['current_time_gmt'] - 2592000 ) ) {
  248. if ( ! function_exists( 'ithemes_plugin_support_notice' ) ) {
  249. function ithemes_plugin_support_notice() {
  250. global $itsec_globals;
  251. echo '<div class="updated" id="itsec_support_notice">
  252. <span class="itsec_notice_text">' . __( 'It looks like you\'ve been enjoying', 'better-wp-security' ) . ' ' . $itsec_globals['plugin_name'] . ' ' . __( "for at least 30 days. It's time to take the next step.", 'better-wp-security' ) . '</span><input type="button" class="itsec-notice-button" value="' . __( 'Upgrade to Pro', 'better-wp-security' ) . '" onclick="document.location.href=\'?itsec_donate=yes&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';"> <input type="button" class="itsec-notice-button" value="' . __( 'Rate it 5★\'s', 'better-wp-security' ) . '" onclick="document.location.href=\'?itsec_rate=yes&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';"> <input type="button" class="itsec-notice-button" value="' . __( 'Tell Your Followers', 'better-wp-security' ) . '" onclick="document.location.href=\'?itsec_tweet=yes&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';"> <input type="button" class="itsec-notice-hide" value="&times;" onclick="document.location.href=\'?itsec_no_nag=off&_wpnonce=' . wp_create_nonce( 'itsec-nag' ) . '\';">
  253. </div>';
  254. }
  255. }
  256. if ( is_multisite() ) {
  257. add_action( 'network_admin_notices', 'ithemes_plugin_support_notice' ); //register notification
  258. } else {
  259. add_action( 'admin_notices', 'ithemes_plugin_support_notice' ); //register notification
  260. }
  261. }
  262. //if they've clicked a button hide the notice
  263. if ( ( isset( $_GET['itsec_no_nag'] ) || isset( $_GET['itsec_rate'] ) || isset( $_GET['itsec_tweet'] ) || isset( $_GET['itsec_donate'] ) ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'itsec-nag' ) ) {
  264. $options = $itsec_globals['data'];
  265. $options['already_supported'] = true;
  266. update_site_option( 'itsec_data', $options );
  267. if ( is_multisite() ) {
  268. remove_action( 'network_admin_notices', 'ithemes_plugin_support_notice' );
  269. } else {
  270. remove_action( 'admin_notices', 'ithemes_plugin_support_notice' );
  271. }
  272. //take the user to paypal if they've clicked donate
  273. if ( isset( $_GET['itsec_donate'] ) ) {
  274. wp_redirect( 'https://ithemes.com/security', '302' );
  275. exit();
  276. }
  277. //Go to the WordPress page to let them rate it.
  278. if ( isset( $_GET['itsec_rate'] ) ) {
  279. wp_redirect( 'http://wordpress.org/plugins/better-wp-security/', '302' );
  280. exit();
  281. }
  282. //Compose a Tweet
  283. if ( isset( $_GET['itsec_tweet'] ) ) {
  284. wp_redirect( 'http://twitter.com/home?status=' . urlencode( 'I use ' . $itsec_globals['plugin_name'] . ' for WordPress by @iThemes and you should too - http://ithemes.com/security' ), '302' );
  285. exit();
  286. }
  287. if ( sanitize_text_field( $_GET['itsec_no_nag'] ) == 'off' && isset( $_SERVER['HTTP_REFERER'] ) ) {
  288. wp_redirect( $_SERVER['HTTP_REFERER'], '302' );
  289. } else {
  290. wp_redirect( 'admin.php?page=itsec', '302' );
  291. }
  292. }
  293. }
  294. }