/** * Returns url of order connected to given Post ID. * * @param int $post_id * @return string */ function cp_get_order_permalink($post_id) { if (!cp_payments_is_enabled()) { return; } $order = appthemes_get_order_connected_to($post_id); if (!$order) { return; } return appthemes_get_order_url($order->get_id()); }
/** * Returns user dashboard ad listing actions. * * @param int $listing_id (optional) * * @return string */ function cp_get_dashboard_listing_actions($listing_id = 0) { global $cp_options; $actions = array(); $listing_id = $listing_id ? $listing_id : get_the_ID(); $listing = get_post($listing_id); $listing_status = cp_get_listing_status_name($listing_id); // edit button if ($cp_options->ad_edit) { $edit_attr = array('title' => __('Edit Ad', APP_TD), 'href' => add_query_arg(array('listing_edit' => $listing->ID), CP_EDIT_URL)); if (in_array($listing_status, array('live', 'offline'))) { $actions['edit'] = $edit_attr; } if ($cp_options->moderate_edited_ads && in_array($listing_status, array('pending_moderation', 'pending_payment'))) { $actions['edit'] = $edit_attr; } } // delete button $actions['delete'] = array('title' => __('Delete Ad', APP_TD), 'href' => add_query_arg(array('aid' => $listing->ID, 'action' => 'delete'), CP_DASHBOARD_URL), 'onclick' => 'return confirmBeforeDeleteAd();'); // pause button if ($listing_status == 'live') { $actions['pause'] = array('title' => __('Pause Ad', APP_TD), 'href' => add_query_arg(array('aid' => $listing->ID, 'action' => 'pause'), CP_DASHBOARD_URL)); } // restart button if ($listing_status == 'offline') { $actions['restart'] = array('title' => __('Restart ad', APP_TD), 'href' => add_query_arg(array('aid' => $listing->ID, 'action' => 'restart'), CP_DASHBOARD_URL)); } // set/unset sold links if (in_array($listing_status, array('live', 'offline'))) { $sold = get_post_meta($listing->ID, 'cp_ad_sold', true); if ($sold != 'yes') { // set sold $actions['set_sold'] = array('title' => __('Mark Sold', APP_TD), 'href' => add_query_arg(array('aid' => $listing->ID, 'action' => 'setSold'), CP_DASHBOARD_URL)); } else { // unset sold $actions['unset_sold'] = array('title' => __('Unmark Sold', APP_TD), 'href' => add_query_arg(array('aid' => $listing->ID, 'action' => 'unsetSold'), CP_DASHBOARD_URL)); } } // relist link if ($cp_options->allow_relist && in_array($listing_status, array('ended', 'live_expired'))) { $actions['relist'] = array('title' => __('Relist Ad', APP_TD), 'href' => add_query_arg(array('listing_renew' => $listing->ID), get_permalink(CP_Renew_Listing::get_id()))); } // payment links if ($listing_status == 'pending_payment') { $order = appthemes_get_order_connected_to($listing->ID); // pay order $actions['pay_order'] = array('title' => __('Pay now', APP_TD), 'href' => appthemes_get_order_url($order->get_id())); if ($order->get_gateway()) { // reset gateway $actions['reset_gateway'] = array('title' => __('Reset Gateway', APP_TD), 'href' => get_the_order_cancel_url($order->get_id())); } } return apply_filters('cp_dashboard_listing_actions', $actions, $listing); }