PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/icwp-optionshandler-email.php

https://github.com/stackgrinder/wp-simple-firewall
PHP | 88 lines | 55 code | 12 blank | 21 comment | 6 complexity | 3d443e0abf186036ce19c07af34763a1 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright (c) 2014 iControlWP <support@icontrolwp.com>
  4. * All rights reserved.
  5. *
  6. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  7. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  8. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  9. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  10. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  11. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  12. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  13. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  15. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. */
  17. require_once( dirname(__FILE__).'/icwp-optionshandler-base.php' );
  18. if ( !class_exists('ICWP_OptionsHandler_Email') ):
  19. class ICWP_OptionsHandler_Email extends ICWP_OptionsHandler_Base_Wpsf {
  20. const StoreName = 'email_options';
  21. public function __construct( $oPluginVo ) {
  22. parent::__construct( $oPluginVo, self::StoreName );
  23. $this->sFeatureName = _wpsf__('Email');
  24. $this->sFeatureSlug = 'email';
  25. $this->fShowFeatureMenuItem = false;
  26. }
  27. /**
  28. * @return bool|void
  29. */
  30. public function defineOptions() {
  31. $aEmail = array(
  32. 'section_title' => _wpsf__( 'Email Options' ),
  33. 'section_options' => array(
  34. array(
  35. 'block_send_email_address',
  36. '',
  37. '',
  38. 'email',
  39. _wpsf__( 'Report Email' ),
  40. _wpsf__( 'Where to send email reports' ),
  41. _wpsf__( 'If this is empty, it will default to the blog admin email address' )
  42. ),
  43. array(
  44. 'send_email_throttle_limit',
  45. '',
  46. '10',
  47. 'integer',
  48. _wpsf__( 'Email Throttle Limit' ),
  49. _wpsf__( 'Limit Emails Per Second' ),
  50. _wpsf__( 'You throttle emails sent by this plugin by limiting the number of emails sent every second. This is useful in case you get hit by a bot attack. Zero (0) turns this off. Suggested: 10' )
  51. )
  52. )
  53. );
  54. $this->m_aOptions = array(
  55. $aEmail
  56. );
  57. }
  58. /**
  59. * This is the point where you would want to do any options verification
  60. */
  61. protected function doPrePluginOptionsSave() {
  62. $sEmail = $this->getOpt( 'block_send_email_address');
  63. if ( empty( $sEmail ) || !is_email( $sEmail ) ) {
  64. $sEmail = get_option('admin_email');
  65. }
  66. if ( is_email( $sEmail ) ) {
  67. $this->setOpt( 'block_send_email_address', $sEmail );
  68. }
  69. $sLimit = $this->getOpt( 'send_email_throttle_limit' );
  70. if ( !is_numeric( $sLimit ) || $sLimit < 0 ) {
  71. $sLimit = 0;
  72. }
  73. $this->setOpt( 'send_email_throttle_limit', $sLimit );
  74. }
  75. }
  76. endif;