/** * Returns options for a given app. * * @param int $app_post_id The app ID. * * @return array $options The app options. */ public static function get_app_options($app_post_id) { /** * Filter the default options values. * * @param array $default Default options values. * @param int $app_post_id The app ID. */ $default = apply_filters('wpak_default_options', self::$default, $app_post_id); $options = WpakOptionsStorage::get_options($app_post_id, $default); return $options; }
/** * Attached to 'save_post' hook. * * Handles options saving for a given app. * * @param int $post_id The app ID. */ public static function save_post($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (empty($_POST['post_type']) || $_POST['post_type'] != 'wpak_apps') { return; } if (!current_user_can('edit_post', $post_id) && !current_user_can('wpak_edit_apps', $post_id)) { return; } if (!check_admin_referer('wpak-options-' . $post_id, 'wpak-nonce-options')) { return; } if (!empty($_POST['wpak_app_options'])) { WpakOptionsStorage::update_options($post_id, $_POST['wpak_app_options']); } }