Ejemplo n.º 1
0
 public function ajax_reset_occ()
 {
     $id = wp_stream_filter_input(INPUT_GET, 'id');
     $nonce = wp_stream_filter_input(INPUT_GET, 'wp_stream_nonce');
     if (!wp_verify_nonce($nonce, 'reset-occ_' . $id)) {
         wp_send_json_error(esc_html__('Invalid nonce', 'stream-notifications'));
     }
     if (empty($id) || (int) $id !== $id) {
         wp_send_json_error(esc_html__('Invalid record ID', 'stream-notifications'));
     }
     wp_stream_update_meta($id, 'occurrences', 0);
     wp_send_json_success();
 }
Ejemplo n.º 2
0
/**
 * @action   wp_stream_after_connectors_registration
 * @return string $current_version if updated correctly
 */
function wp_stream_update_migrate_installer_edits_to_theme_editor_connector()
{
    global $wpdb;
    $db_version = WP_Stream_Install::$db_version;
    $current_version = WP_Stream_Install::$current;
    $args = array('connector' => 'installer', 'context' => 'themes', 'action' => 'edited');
    $records = wp_stream_query($args);
    foreach ($records as $record) {
        $file_name = wp_stream_get_meta($record->ID, 'file', true);
        $theme_name = wp_stream_get_meta($record->ID, 'name', true);
        if ('' !== $theme_name) {
            $matched_themes = array_filter(wp_get_themes(), function ($theme) use($theme_name) {
                return (string) $theme === $theme_name;
            });
            $theme = array_shift($matched_themes);
            // `stream`
            $wpdb->update($wpdb->stream, array('summary' => sprintf(WP_Stream_Connector_Editor::get_message(), $file_name, $theme_name)), array('ID' => $record->ID));
            // `stream_context`
            $wpdb->update($wpdb->streamcontext, array('connector' => 'editor', 'context' => is_object($theme) ? $theme->get_template() : $theme_name, 'action' => 'updated'), array('record_id' => $record->ID));
            wp_stream_update_meta($record->ID, 'theme_name', $theme_name);
            if (is_object($theme)) {
                wp_stream_update_meta($record->ID, 'theme_slug', $theme->get_template());
            }
        }
    }
    do_action('wp_stream_after_db_update_' . $db_version, $current_version, $wpdb->last_error);
    if ($wpdb->last_error) {
        return false;
    }
    return $current_version;
}
Ejemplo n.º 3
0
/**
 * update_stream_meta()
 *
 * @deprecated 1.3.2
 * @deprecated Use wp_stream_update_meta
 * @see wp_stream_update_meta()
 */
function update_stream_meta($record_id, $meta_key, $meta_value, $prev_value = '')
{
    _deprecated_function(__FUNCTION__, '1.3.2', 'wp_stream_update_meta()');
    return wp_stream_update_meta($record_id, $meta_key, $meta_value, $prev_value);
}
 private function alert($rules, $log)
 {
     foreach ($rules as $rule_id => $rule) {
         // Update occurrences
         wp_stream_update_meta($rule_id, 'occurrences', (int) wp_stream_get_meta($rule_id, 'occurrences', true) + 1);
         foreach ($rule['alerts'] as $alert) {
             if (!isset(WP_Stream_Notifications::$adapters[$alert['type']])) {
                 continue;
             }
             $adapter = new WP_Stream_Notifications::$adapters[$alert['type']]['class']();
             $adapter->load($alert)->send($log);
         }
     }
 }