Alert frequency buttons integration into theme

Osclass 8.3 brings possibility to select alerts (subscriptions) frequency. Available values are:

  • Instant (using minutely cron)
  • Hourly
  • Daily
  • Weekly

To support this feature, place following code into your alert section:

<?php echo osc_alert_change_frequency(osc_alert()); ?>

Note that in some themes, osc_alert() might not return valida values, as alerts might be printed with loop. Identify what object stores current alert object and replace osc_alert() with for example $alert.

In such case, integration code would look like:

<?php echo osc_alert_change_frequency(osc_alert()); ?>

Update your style.css to show it nicely:

/* ALERTS FREQUENCY */
.alert-frequency {display:flex;float: left; align-items: center; flex-wrap: nowrap;margin:2px 0 10px 0;}
.alert-frequency > a {padding:5px 10px;font-size:14px;line-height:16px;margin:0 -1px 0 0;border:1px solid #ccc;background:#fff;}
.alert-frequency > a:first-child {border-radius:4px 0 0 4px;}
.alert-frequency > a:last-child {border-radius:0 4px 4px 0;}
.alert-frequency > a.active {background:#f0f0f0;font-weight:600;}
.alert-frequency > a:hover {text-decoration:none;background:#f0f0f0;}

Alert name

Osclass 8.3 also generates alert names and store these values into database. Up to now, alert names might be generated dynamically that was pretty expensive task and could also be inaccurate.

To use alert name, just replace current name with:

<?php echo osc_alert_name(); ?>

As in previous integration, even here might happen that osc_alert() is not available and alert object is stored in variable. Let's say it's again variable $alert. In such case update your integration to:

<?php echo $alert['s_name']; ?>

Note that existing alerts will not be given name, it's valid just for newly created alerts, so it could be helpful to check if name is defined, if not use old method. Example is here:

<?php
  if(function_exists('osc_alert_name') && isset($a['s_name']) && $a['s_name'] != '') {
    echo $a['s_name'];
  } else {
    echo __('Alert', 'alpha') . ' #' . $c;
  }
?>

Hope this article helps you to implement new Osclass features!