/** * Retrieve a single addon. * * @since 1.4 * @param int $addon_id The ID of the addon * @return WP_Post object. */ function mdjm_get_addon($addon_id) { return mdjm_get_addon_by('id', $addon_id); }
/** * Retrieve a single addon by ID, name, or slug. * * @since 1.4 * @return void */ public function get_addon() { $response = array(); if (!isset($this->request['addon'])) { $this->missing_params('addon'); } do_action('mdjm_before_api_get_addon', $this); if (!is_numeric($this->request['addon'])) { // Using name or slug $addon = mdjm_get_addon_by('name', $this->request['addon']); } else { $addon = mdjm_get_addon($this->request['addon']); } if (!$addon) { $error = array(); $error['error'] = __('Addon does not exist.', 'mobile-dj-manager'); $this->data = $error; $this->output(); } $response['addon'] = mdjm_get_addon_data($addon); $response['addon'] = array_merge(array('id' => $addon->ID), $response['addon']); $this->data = array_merge($this->data, $response); do_action('mdjm_after_api_get_addon', $this); $this->output(); }
/** * Retrieve the cost of an addon. * * @since 1.4 * @param str $slug The slug identifier for the addon. * @return int The cost of the addon. */ function mdjm_get_addon_cost($slug) { _deprecated_function(__FUNCTION__, '1.4', "mdjm_get_addon_by( 'field', 'value' )"); $addon = mdjm_get_addon_by('slug', $slug); if ($addon) { return mdjm_format_amount(mdjm_get_addon_price($addon->ID)); } }