/** * Removes all quicktags from content * * @param string $content * @return string Filtered content */ function quads_strip_quicktags($content) { $quicktags = quads_quicktag_list(); foreach ($quicktags as $id => $label) { $content = str_replace('<!--' . $id . '-->', '', $content); } return $content; }
public function save($post_id) { // Don't save data automatically via autosave feature if ($this->is_doing_autosave()) { return $post_id; } // Don't save data when doing preview if ($this->is_doing_preview()) { return $post_id; } // Don't save data when using Quick Edit if ($this->is_inline_edit()) { return $post_id; } $post_type = isset($_POST['post_type']) ? $_POST['post_type'] : null; // Update options only if they are appliable if (!in_array($post_type, $this->get_allowed_post_types())) { return $post_id; } // Check permissions $post_type_obj = get_post_type_object($post_type); if (!current_user_can($post_type_obj->cap->edit_post, $post_id)) { return $post_id; } // Verify nonce if (!check_admin_referer('quads_config', 'quads_config_nonce')) { wp_die(__('Nonce incorrect!', 'quads')); } $config = isset($_POST[$this->config_key]) ? $_POST[$this->config_key] : array(); $visibility_config = isset($config['visibility']) ? $config['visibility'] : array(); // process visibility config // store it in separate meta key $checked_qtags = array(); $allowed_fields = quads_quicktag_list(); foreach ($allowed_fields as $qtag_id => $qtag_label) { if (isset($visibility_config[$qtag_id])) { $checked_qtags[$qtag_id] = 1; } } // strip all forbidden values foreach ($visibility_config as $qtag_id => $qtag_label) { if (isset($allowed_fields[$qtag_id])) { $checked_qtags[$qtag_id] = 1; } } update_post_meta($post_id, $this->meta_key_visibility, $checked_qtags); }