[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/includes/settings/subscriptions/ -> update.php (source)

   1  <?php //subscriptions => no sanitize here, checkboxes and selects
   2  
   3  $old_subscriptions = get_option( MailPress::option_name_subscriptions );
   4  
   5  $subscriptions = MP_AdminPage::$pst_['subscriptions'];
   6  
   7  if ( isset( MP_AdminPage::$pst_['newsletter']['on'] ) )
   8  {
   9      if ( isset( MP_AdminPage::$pst_['newsletter']['post_limits'] ) )
  10      {
  11          update_option( MailPress_newsletter::option_post_limits, MP_AdminPage::$pst_['newsletter']['post_limits'] );
  12      }
  13  
  14      if ( isset( MP_AdminPage::$pst_['comment_newsletter_subscription'] ) )
  15      {
  16          update_option ( MailPress_comment_newsletter_subscription::option_name, MP_AdminPage::$pst_['comment_newsletter_subscription'] );
  17      }
  18  
  19      $diff_default_newsletters = array();
  20      if ( !isset( $subscriptions['default_newsletters'] ) )      $subscriptions['default_newsletters']     = array();
  21      $old_default_newsletters = $old_subscriptions ['default_newsletters'] ?? MP_Newsletter::get_defaults();
  22  
  23      foreach( $subscriptions['default_newsletters'] as $k => $v ) if ( !isset( $old_default_newsletters[$k] ) )  $diff_default_newsletters[$k] = true;
  24      foreach( $old_default_newsletters as $k => $v ) if ( !isset( $subscriptions ['default_newsletters'][$k] ) ) $diff_default_newsletters[$k] = true;
  25      foreach ( $diff_default_newsletters as $k => $v ) MP_Newsletter::reverse_subscriptions( $k );
  26  
  27      if ( $old_subscriptions['default_newsletters'] != $subscriptions['default_newsletters'] || $old_subscriptions['newsletters'] != $subscriptions['newsletters'] ) wp_schedule_single_event( current_time( 'timestamp', 'gmt' ) - 1, 'mp_schedule_newsletters', array( 'args' => array( 'event' => '** Subscriptions updated **' ) ) );
  28  }
  29  else  
  30  {    // so we don't delete settings if addon deactivated !
  31      if ( isset( $old_subscriptions['newsletters'] ) )        $subscriptions['newsletters']        = $old_subscriptions['newsletters'];
  32      if ( isset( $old_subscriptions['default_newsletters'] ) )    $subscriptions['default_newsletters']    = $old_subscriptions['default_newsletters'];
  33  }
  34  
  35  if ( !isset( MP_AdminPage::$pst_['mailinglist']['on'] ) )
  36  {    // so we don't delete settings if addon deactivated !
  37      if ( isset( MP_AdminPage::$pst_['default_mailinglist'] ) ) update_option ( MailPress_mailinglist::option_name_default, MP_AdminPage::$pst_['default_mailinglist'] );
  38      if ( isset( $old_subscriptions['display_mailinglists'] ) ) $subscriptions['display_mailinglists']     = $old_subscriptions['display_mailinglists'];
  39  }
  40  
  41  if ( isset( MP_AdminPage::$pst_['comment']['on'] ) )
  42  {
  43      // so we don't delete settings if addon deactivated !
  44      update_option( MailPress_comment::option, ( isset( $subscriptions['comment_checked'] ) ) );
  45  }
  46  
  47  $mp_subscriptions = $subscriptions;
  48      
  49  update_option( MailPress::option_name_subscriptions, $mp_subscriptions );
  50  
  51  $message = __( '"Subscriptions" settings saved', 'MailPress' );


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1