public function test_get_the_order_total() { $total = get_the_order_total(self::$order->get_id()); $this->assertEquals($total, appthemes_get_price(self::$order->get_total(), self::$order->get_currency())); $this->expectOutputString($total); the_order_total(self::$order->get_id()); }
function appthemes_display_mixed_price($mixed_prices) { $strings = array(); foreach ($mixed_prices as $currency => $amount) { $strings[] = appthemes_get_price($amount, $currency, 'code'); } echo join('</br> ', $strings); }
protected function row($item) { if (!APP_Item_Registry::is_registered($item['type'])) { return html('tr', array(), html('td', array('colspan' => '3', 'style' => 'font-style: italic;'), __('This item could not be recognized. It might be from another theme or an uninstalled plugin.', APP_TD))); } $ptype_obj = get_post_type_object($item['post']->post_type); $item_link = $ptype_obj->public ? html_link(get_permalink($item['post_id']), $item['post']->post_title) : ''; $cells = array(APP_Item_Registry::get_title($item['type']), appthemes_get_price($item['price'], $this->currency), $item_link); return html('tr', array(), $this->cells($cells)); }
/** * Displays the non-custom fields below the main listing submission form. * * @param int $listing_id * * @return void */ function cp_other_fields($listing_id) { global $cp_options; // are images on ads allowed if ($cp_options->ad_images) { if (appthemes_plupload_is_enabled()) { echo html('div class="ad-details-images-sep"', ' '); appthemes_plupload_form($listing_id); } else { $images_count = cp_get_ad_images($listing_id); cp_ad_edit_image_input_fields($images_count); } } // show the chargeable options if enabled if (cp_payments_is_enabled()) { // show the featured ad box if enabled if ($cp_options->sys_feat_price) { ?> <div class="ad-details-featured-sep"></div> <li id="list_featured_ad" class="withborder"> <div class="labelwrapper"> <label><?php printf(__('Featured Listing %s', APP_TD), appthemes_get_price($cp_options->sys_feat_price)); ?> </label> </div> <div class="clr"></div> <input name="featured_ad" value="1" type="checkbox" <?php checked(is_sticky($listing_id)); ?> /> <?php _e('Your listing will appear in the featured slider section at the top of the front page.', APP_TD); ?> <div class="clr"></div> </li> <?php } if ($cp_options->price_scheme == 'single') { ?> <li> <div class="labelwrapper"> <label><?php _e('Ad Package:', APP_TD); ?> </label> </div> <?php // go get all the active ad packs and create a drop-down of options $packages = cp_get_listing_packages(); if ($packages) { ?> <select name="ad_pack_id" class="dropdownlist required"> <?php foreach ($packages as $package) { // external plugins can modify or disable field $result = apply_filters('cp_package_field', $package, 'ad'); if (!$package) { continue; } ?> <option value="<?php echo esc_attr($package->ID); ?> "><?php echo esc_attr($package->pack_name); ?> </option> <?php } ?> </select> <?php } else { _e('Error: no ad pack has been defined. Please contact the site administrator.', APP_TD); } ?> <div class="clr"></div> </li> <?php } ?> <?php } }
echo $rowclass . ' ' . $requiredClass; ?> "> <td><strong><?php echo stripslashes($result->pack_name); ?> </strong><a class="tip" tip="<?php echo $result->pack_desc; ?> " tabindex="99"><div class="helpico"></div></a></td> <td><?php echo $benefit; ?> </td> <td><?php printf(__('%1$s / %2$s days', APP_TD), appthemes_get_price($result->pack_membership_price), $result->pack_duration); ?> </td> <td><input type="submit" name="step1" id="step1" class="btn_orange" onclick="document.getElementById('pack').value=<?php echo $result->pack_id; ?> ;" value="<?php _e('Buy Now ››', APP_TD); ?> " style="margin-left: 5px; margin-bottom: 5px;" /></td> </tr> <?php } // end for each ?>
<input type="submit" name="getcat" id="getcat" class="btn_orange" value="<?php _e('Go ››', APP_TD); ?> " /> <div id="chosenCategory"><input id="ad_cat_id" name="cat" type="hidden" value="15" /></div> <div style="clear:both;"></div> </div> <div style="clear:both;"></div> </li> <?php } else { if ($cp_options->price_scheme == 'category' && cp_payments_is_enabled()) { $prices = $cp_options->price_per_cat; $cat_fee = isset($prices[$category->term_id]) ? (double) $prices[$category->term_id] : 0; $cat_fee = ' - ' . appthemes_get_price($cat_fee); } else { $cat_fee = ''; } ?> <li> <div class="labelwrapper"><label><?php _e('Category:', APP_TD); ?> </label></div> <strong><?php echo $category->name; ?> </strong><?php echo $cat_fee;
/** * Returns membership package benefit text. * * @param int $pack_id * * @return string */ function cp_get_membership_package_benefit_text($pack_id) { global $cp_options; if (!current_theme_supports('app-price-format')) { return ''; } $package = cp_get_membership_package($pack_id); if (!$package) { return ''; } $benefit = ''; if (!$cp_options->charge_ads) { $benefit .= __('Free Posting', APP_TD); } else { if ($package->pack_type == 'percentage') { //$benefit .= sprintf( __( '%s%% of price', APP_TD ), preg_replace( '/.00$/', '', $package->price_modifier ) ); //remove decimal when decimal is .00 $benefit .= sprintf(__('%s%% of price', APP_TD), (double) $package->price_modifier); } else { if ($package->pack_type == 'discount') { $benefit .= sprintf(__('%s\'s less per ad', APP_TD), appthemes_get_price($package->price_modifier)); } else { if ($package->pack_type == 'static') { if ($package->price_modifier == 0) { $benefit .= __('Free Posting', APP_TD); } else { $benefit .= sprintf(__('%s per ad', APP_TD), appthemes_get_price($package->price_modifier)); } } } } } if (!empty($benefit) && $package->pack_satisfies_required) { $benefit .= ' (' . __('required to post', APP_TD) . ')'; } return $benefit; }
function cp_ad_packs() { global $wpdb, $current_user, $options_new_ad_pack, $options_new_membership_pack, $cp_options; $current_user = wp_get_current_user(); $theswitch = isset($_GET['action']) ? $_GET['action'] : ''; ?> <script type="text/javascript"> /* <![CDATA[ */ /* initialize the form validation */ jQuery(document).ready(function($) { $("#mainform").validate({errorClass: "invalid"}); }); /* ]]> */ </script> <?php $options_new_pack = isset($_GET['type']) && $_GET['type'] == 'membership' ? $options_new_membership_pack : $options_new_ad_pack; switch ($theswitch) { case 'addpack': ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php if ($_GET['type'] == 'membership') { _e('New Membership Pack', APP_TD); } else { _e('New Ad Pack', APP_TD); } ?> </h2> <?php // check and make sure the form was submitted if (isset($_POST['submitted'])) { //setup optional variables for the package $post_pack_satisfies_required = isset($_POST['pack_satisfies_required']) ? $_POST['pack_satisfies_required'] : ''; $post_pack_type = isset($_POST['pack_type']) ? $post_pack_satisfies_required . $_POST['pack_type'] : ''; $post_pack_membership_price = isset($_POST['pack_membership_price']) ? $_POST['pack_membership_price'] : 0; $data = array('pack_name' => appthemes_clean($_POST['pack_name']), 'pack_desc' => appthemes_clean($_POST['pack_desc']), 'pack_price' => appthemes_clean_price($_POST['pack_price'], 'float'), 'pack_duration' => appthemes_clean($_POST['pack_duration']), 'pack_status' => appthemes_clean($_POST['pack_status']), 'pack_type' => appthemes_clean($post_pack_type), 'pack_membership_price' => appthemes_clean_price($post_pack_membership_price, 'float'), 'pack_owner' => appthemes_clean($_POST['pack_owner']), 'pack_modified' => current_time('mysql'), 'pack_horse_limit' => appthemes_clean($_POST['pack_horse_limit']), 'pack_video_limit' => appthemes_clean($_POST['pack_video_limit']), 'pack_imagelimit' => appthemes_clean($_POST['pack_imagelimit']), 'pack_secure_mail' => appthemes_clean($_POST['pack_secure_mail']), 'pack_social_media' => appthemes_clean($_POST['pack_social_media']), 'pack_cancel' => appthemes_clean($_POST['pack_cancel']), 'pack_ad_views' => appthemes_clean($_POST['pack_ad_views']), 'pack_link_to_site' => appthemes_clean($_POST['pack_link_to_site']), 'pack_iso_ad' => appthemes_clean($_POST['pack_iso_ad'])); $insert = $wpdb->insert($wpdb->cp_ad_packs, $data); if ($insert) { ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Creating your ad package.....', APP_TD); ?> <br /><br /><img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=packages"> <?php } } else { ?> <form method="post" id="mainform" action=""> <?php cp_admin_fields($options_new_pack); ?> <p class="submit"> <input class="btn button-primary" name="save" type="submit" value="<?php _e('Create New Ad Package', APP_TD); ?> " /> <input class="btn button-secondary" name="cancel" type="button" onClick="location.href='?page=packages'" value="<?php _e('Cancel', APP_TD); ?> " /> <input name="submitted" type="hidden" value="yes" /> <input name="pack_owner" type="hidden" value="<?php echo $current_user->user_login; ?> " /> </p> </form> <?php } ?> </div><!-- end wrap --> <?php break; case 'editpack': ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Edit Ad Package', APP_TD); ?> </h2> <?php if (isset($_POST['submitted']) && $_POST['submitted'] == 'yes') { //setup optional variables for the package $post_pack_satisfies_required = isset($_POST['pack_satisfies_required']) ? $_POST['pack_satisfies_required'] : ''; $post_pack_type = isset($_POST['pack_type']) ? $post_pack_satisfies_required . $_POST['pack_type'] : ''; $post_pack_membership_price = isset($_POST['pack_membership_price']) ? $_POST['pack_membership_price'] : 0; $data = array('pack_name' => appthemes_clean($_POST['pack_name']), 'pack_desc' => appthemes_clean($_POST['pack_desc']), 'pack_price' => appthemes_clean_price($_POST['pack_price'], 'float'), 'pack_duration' => appthemes_clean($_POST['pack_duration']), 'pack_status' => appthemes_clean($_POST['pack_status']), 'pack_type' => appthemes_clean($post_pack_type), 'pack_membership_price' => appthemes_clean_price($post_pack_membership_price, 'float'), 'pack_owner' => appthemes_clean($_POST['pack_owner']), 'pack_modified' => current_time('mysql'), 'pack_horse_limit' => appthemes_clean($_POST['pack_horse_limit']), 'pack_video_limit' => appthemes_clean($_POST['pack_video_limit']), 'pack_imagelimit' => appthemes_clean($_POST['pack_imagelimit']), 'pack_secure_mail' => appthemes_clean($_POST['pack_secure_mail']), 'pack_social_media' => appthemes_clean($_POST['pack_social_media']), 'pack_cancel' => appthemes_clean($_POST['pack_cancel']), 'pack_ad_views' => appthemes_clean($_POST['pack_ad_views']), 'pack_link_to_site' => appthemes_clean($_POST['pack_link_to_site']), 'pack_iso_ad' => appthemes_clean($_POST['pack_iso_ad'])); $update = $wpdb->update($wpdb->cp_ad_packs, $data, array('pack_id' => $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Saving your changes.....', APP_TD); ?> <br /><br /><img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=packages"> <?php } else { ?> <form method="post" id="mainform" action=""> <?php cp_admin_db_fields($options_new_pack, 'cp_ad_packs', 'pack_id'); ?> <p class="submit"> <input class="btn button-primary" name="save" type="submit" value="<?php _e('Save changes', APP_TD); ?> " /> <input class="btn button-secondary" name="cancel" type="button" onClick="location.href='?page=packages'" value="<?php _e('Cancel', APP_TD); ?> " /> <input name="submitted" type="hidden" value="yes" /> <input name="pack_owner" type="hidden" value="<?php echo $current_user->user_login; ?> " /> </p> </form> <?php } ?> </div><!-- end wrap --> <?php break; case 'delete': $delete = $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->cp_ad_packs} WHERE pack_id = %d", $_GET['id'])); ?> <p style="text-align:center;padding-top:50px;font-size:22px;"><?php _e('Deleting ad package.....', APP_TD); ?> <br /><br /><img src="<?php echo get_template_directory_uri(); ?> /images/loader.gif" alt="" /></p> <meta http-equiv="refresh" content="0; URL=?page=packages"> <?php break; default: $results = $wpdb->get_results("SELECT * FROM {$wpdb->cp_ad_packs} ORDER BY pack_id desc"); ?> <div class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Ad Packs', APP_TD); ?> <a class="add-new-h2" href="?page=packages&action=addpack&type=ad"><?php _e('Add New', APP_TD); ?> </a></h2> <?php if ($cp_options->price_scheme != 'single') { ?> <div class="error"><p><?php printf(__('Ad Packs are disabled. Change the <a href="%1$s">pricing model</a> to enable Ad Packs.', APP_TD), 'admin.php?page=app-pricing&tab=general'); ?> </p></div> <?php } ?> <p class="admin-msg"><?php _e('Ad Packs allow you to create bundled listing options for your customers to choose from. For example, instead of only offering a set price for xx days (30 days for $5), you could also offer discounts for longer terms (60 days for $7). These only work if you are selling ads and using the "Fixed Price Per Ad" price model.', APP_TD); ?> </p> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Name', APP_TD); ?> </th> <th scope="col"><?php _e('Description', APP_TD); ?> </th> <th scope="col"><?php _e('Price Per Ad', APP_TD); ?> </th> <th scope="col"><?php _e('Duration', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Modified', APP_TD); ?> </th> <th scope="col" style="width:75px;"><?php _e('Status', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { if ($result->pack_status == 'active' || $result->pack_status == 'inactive') { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i++; ?> .</td> <td><a href="?page=packages&action=editpack&type=ad&id=<?php echo $result->pack_id; ?> "><strong><?php echo stripslashes($result->pack_name); ?> </strong></a></td> <td><?php echo $result->pack_desc; ?> </td> <td><?php appthemes_display_price($result->pack_price); ?> </td> <td><?php echo $result->pack_duration; ?> <?php _e('days', APP_TD); ?> </td> <td><?php echo appthemes_display_date($result->pack_modified); ?> <?php _e('by', APP_TD); ?> <?php echo $result->pack_owner; ?> </td> <td><?php echo cp_get_status_i18n($result->pack_status); ?> </td> <td style="text-align:center"> <a href="?page=packages&action=editpack&type=ad&id=<?php echo $result->pack_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/edit.png" alt="<?php _e('Edit ad package', APP_TD); ?> " title="<?php _e('Edit ad package', APP_TD); ?> " /></a> <a onclick="return confirmBeforeDelete();" href="?page=packages&action=delete&id=<?php echo $result->pack_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/cross.png" alt="<?php _e('Delete ad package', APP_TD); ?> " title="<?php _e('Delete ad package', APP_TD); ?> " /></a> </td> </tr> <?php } //end if('active' || 'inactive') } // end foreach unset($i); ?> </tbody> <?php } else { ?> <tr> <td colspan="7"><?php _e('No ad packs found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> </div><!-- end wrap for ad packs --> <div id="membership-packs" class="wrap"> <div class="icon32" id="icon-themes"><br /></div> <h2><?php _e('Membership Packs', APP_TD); ?> <a class="add-new-h2" href="?page=packages&action=addpack&type=membership"><?php _e('Add New', APP_TD); ?> </a></h2> <p class="admin-msg"><?php printf(__('Membership Packs allow you to setup subscription-based pricing packages. This enables your customers to post unlimited ads for a set period of time or until the membership becomes inactive. These memberships affect pricing regardless of the ad packs or pricing model you have set as long as you have enabled the <a href="%1$s">membership packs</a> option.', APP_TD), 'admin.php?page=app-pricing&tab=membership'); ?> </p> <table id="tblspacer" class="widefat fixed"> <thead> <tr> <th scope="col" style="width:35px;"> </th> <th scope="col"><?php _e('Name', APP_TD); ?> </th> <th scope="col"><?php _e('Description', APP_TD); ?> </th> <th scope="col"><?php _e('Price Modifier', APP_TD); ?> </th> <th scope="col"><?php _e('Terms', APP_TD); ?> </th> <th scope="col" style="width:150px;"><?php _e('Modified', APP_TD); ?> </th> <th scope="col" style="width:75px;"><?php _e('Status', APP_TD); ?> </th> <th scope="col" style="text-align:center;width:100px;"><?php _e('Actions', APP_TD); ?> </th> </tr> </thead> <?php if ($results) { $rowclass = ''; $i = 1; ?> <tbody id="list"> <?php foreach ($results as $result) { if ($result->pack_status == 'active_membership' || $result->pack_status == 'inactive_membership') { $rowclass = 'even' == $rowclass ? 'alt' : 'even'; ?> <tr class="<?php echo $rowclass; ?> "> <td style="padding-left:10px;"><?php echo $i++; ?> .</td> <td><a href="?page=packages&action=editpack&type=membership&id=<?php echo $result->pack_id; ?> "><strong><?php echo stripslashes($result->pack_name); ?> </strong></a></td> <td><?php echo $result->pack_desc; ?> </td> <td> <?php switch ($result->pack_type) { case 'percentage': echo preg_replace('/.00$/', '', $result->pack_price) . '% ' . __('of price', APP_TD); //remove decimal when decimal is .00 break; case 'discount': printf(__('%s\'s less per ad', APP_TD), appthemes_get_price($result->pack_price)); break; case 'required_static': if ((double) $result->pack_price == 0) { _e('Free', APP_TD); } else { printf(__('%s per ad', APP_TD), appthemes_get_price($result->pack_price)); } echo ' (' . __('required to post', APP_TD) . ')'; break; case 'required_discount': printf(__('%s\'s less per ad', APP_TD), appthemes_get_price($result->pack_price)); echo ' (' . __('required to post', APP_TD) . ')'; break; case 'required_percentage': echo preg_replace('/.00$/', '', $result->pack_price) . '% ' . __('of price', APP_TD); //remove decimal when decimal is .00 echo ' (' . __('required to post', APP_TD) . ')'; break; default: //likely 'static' if ((double) $result->pack_price == 0) { _e('Free', APP_TD); } else { printf(__('%s per ad', APP_TD), appthemes_get_price($result->pack_price)); } } ?> </td> <td><?php printf(__('%1$s / %2$s days', APP_TD), appthemes_get_price($result->pack_membership_price), $result->pack_duration); ?> </td> <td><?php echo appthemes_display_date($result->pack_modified); ?> <?php _e('by', APP_TD); ?> <?php echo $result->pack_owner; ?> </td> <td><?php echo cp_get_status_i18n($result->pack_status); ?> </td> <td style="text-align:center"> <a href="?page=packages&action=editpack&type=membership&id=<?php echo $result->pack_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/edit.png" alt="<?php _e('Edit ad package', APP_TD); ?> " title="<?php _e('Edit ad package', APP_TD); ?> " /></a> <a onclick="return confirmBeforeDelete();" href="?page=packages&action=delete&id=<?php echo $result->pack_id; ?> "><img src="<?php echo get_template_directory_uri(); ?> /images/cross.png" alt="<?php _e('Delete ad package', APP_TD); ?> " title="<?php _e('Delete ad package', APP_TD); ?> " /></a> </td> </tr> <?php } //end if('active_membership' || 'inactive_membership') } // end foreach unset($i); ?> </tbody> <?php } else { ?> <tr> <td colspan="7"><?php _e('No ad packs found.', APP_TD); ?> </td> </tr> <?php } // end $results ?> </table> </div><!-- end wrap for membership packs--> <?php } // end switch ?> <script type="text/javascript"> /* <![CDATA[ */ function confirmBeforeDelete() { return confirm("<?php _e('Are you sure you want to delete this ad package?', APP_TD); ?> "); } /* ]]> */ </script> <?php }
/** * Outputs column data for orders * @param string $column_index Name of the column being processed * @param int $post_id ID of order being dispalyed * @return void */ function appthemes_order_add_column_data($column_index, $post_id) { $order = appthemes_get_order($post_id); switch ($column_index) { case 'order': echo '<a href="' . get_edit_post_link($post_id) . '">' . $order->get_ID() . '</a>'; break; case 'order_author': $user = get_userdata($order->get_author()); echo $user->display_name; echo '<br>'; echo $order->get_ip_address(); break; case 'item': $count = count($order->get_items()); $string = _n('Purchased %s item', 'Purchased %s items', $count, APP_TD); printf($string, $count); break; case 'price': $currency = $order->get_currency(); if (!empty($currency)) { echo appthemes_get_price($order->get_total(), $order->get_currency()); } else { echo appthemes_get_price($order->get_total()); } break; case 'payment': $gateway_id = $order->get_gateway(); if (!empty($gateway_id)) { $gateway = APP_Gateway_Registry::get_gateway($gateway_id); if ($gateway) { echo $gateway->display_name('admin'); } else { _e('Unknown', APP_TD); } } else { _e('Undecided', APP_TD); } echo '</br>'; $status = $order->get_display_status(); if ($order->get_status() == APPTHEMES_ORDER_PENDING) { echo '<strong>' . ucfirst($status) . '</strong>'; } else { echo ucfirst($status); } break; case 'status': echo ucfirst($order->get_status()); break; case 'order_date': $order_post = get_post($order->get_ID()); if ('0000-00-00 00:00:00' == $order_post->post_date) { $t_time = $h_time = __('Unpublished', APP_TD); $time_diff = 0; } else { $t_time = get_the_time(_x('Y/m/d g:i:s A', 'Order Date Format', APP_TD)); $m_time = $order_post->post_date; $time = get_post_time('G', true, $order_post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', APP_TD), human_time_diff($time)); } else { $h_time = mysql2date(_x('Y/m/d', 'Order Date Format', APP_TD), $m_time); } } echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; break; } }
/** * Returns listing category fee. * * @param int $category_id * * return string */ protected function get_category_fee($category_id) { global $cp_options; if ($cp_options->price_scheme == 'category' && cp_payments_is_enabled()) { $prices = $cp_options->price_per_cat; $category_fee = isset($prices[$category_id]) ? (double) $prices[$category_id] : 0; $category_fee = ' - ' . appthemes_get_price($category_fee); } else { $category_fee = ''; } return $category_fee; }
echo $rowclass . ' ' . $requiredClass; ?> "> <td><strong><?php echo $package->pack_name; ?> </strong><a class="tip" tip="<?php echo $package->description; ?> " tabindex="99"><div class="dashicons-before helpico"></div></a></td> <td><?php echo $benefit; ?> </td> <td><?php printf(__('%1$s / %2$s days', APP_TD), appthemes_get_price($package->price), $package->duration); ?> </td> <td><input type="submit" name="step1" id="step1" class="btn_orange" onclick="document.getElementById('pack').value=<?php echo $package->ID; ?> ;" value="<?php echo esc_attr_e('Buy Now ››', APP_TD); ?> " style="margin-left: 5px; margin-bottom: 5px;" /></td> </tr> <?php } // end for each ?>
function cp_custom_fields_meta_box() { global $wpdb, $post, $meta_boxes; // use nonce for verification wp_nonce_field(basename(__FILE__), 'ad_meta_wpnonce', false, true); // get the ad category id $ad_cat_id = appthemes_get_custom_taxonomy($post->ID, APP_TAX_CAT, 'term_id'); // get the form id $fid = cp_get_form_id($ad_cat_id); // if there's no form id it must mean the default form is being used so let's go grab those fields if (!$fid) { // use this if there's no custom form being used and give us the default form $sql = "SELECT field_label, field_name, field_type, field_values, field_tooltip, field_req FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc"; } else { // now we should have the formid so show the form layout based on the category selected $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, f.field_tooltip, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid); } $results = $wpdb->get_results($sql); // display the write panel for the custom fields if ($results) { ?> <script type="text/javascript"> //<![CDATA[ /* initialize the datepicker feature */ jQuery(document).ready(function($) { $('table input#datepicker').datetimepicker({ showSecond: true, timeFormat: 'hh:mm:ss', showOn: 'button', dateFormat: 'yy-mm-dd', minDate: 0, buttonImageOnly: true, buttonText: '', buttonImage: '../wp-includes/images/blank.gif' // calling the real calendar image in the admin.css. need a blank placeholder image b/c of IE. }); }); //]]> </script> <table class="form-table ad-meta-table"> <tr> <th style="width:20%"><label for="cp_sys_ad_conf_id"><?php _e('Ad Info', APP_TD); ?> :</label></th> <td class="ad-conf-id"> <div id="ad-id"><div id="keyico"></div><?php _e('Ad ID', APP_TD); ?> : <span><?php echo esc_html(get_post_meta($post->ID, 'cp_sys_ad_conf_id', true)); ?> </span></div> <div id="ad-stats"><div id="statsico"></div><?php _e('Views Today', APP_TD); ?> : <strong><?php echo esc_html(get_post_meta($post->ID, 'cp_daily_count', true)); ?> </strong> | <?php _e('Views Total:', APP_TD); ?> <strong><?php echo esc_html(get_post_meta($post->ID, 'cp_total_count', true)); ?> </strong></div> </td> </tr> <tr> <th style="width:20%"><label for="cp_sys_ad_conf_id"><?php _e('Submitted By', APP_TD); ?> :</label></th> <td style="line-height:3.4em;"> <?php // show the gravatar for the author echo get_avatar($post->post_author, $size = '48', $default = ''); // show the author drop-down box wp_dropdown_users(array('who' => 'authors', 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author, 'include_selected' => true)); // display the author display name $author = get_userdata($post->post_author); echo '<br/><a href="user-edit.php?user_id=' . $author->ID . '">' . $author->display_name . '</a>'; ?> </td> </tr> <?php if (cp_payments_is_enabled()) { ?> <tr> <th style="width:20%"><label for="cp_sys_total_ad_cost"><?php _e('Ad Terms', APP_TD); ?> :</label></th> <td><?php printf(__('%1$s for %2$s days', APP_TD), appthemes_get_price(get_post_meta($post->ID, 'cp_sys_total_ad_cost', true)), get_post_meta($post->ID, 'cp_sys_ad_duration', true)); ?> </td> </tr> <?php } else { ?> <tr> <th style="width:20%"><label for="cp_sys_ad_duration"><?php _e('Duration', APP_TD); ?> :</label></th> <td><?php printf(__('Listed for %s days', APP_TD), get_post_meta($post->ID, 'cp_sys_ad_duration', true)); ?> </td> </tr> <?php } ?> <tr> <th style="width:20%"><label for="cp_sys_expire_date"><?php _e('Ad Expires', APP_TD); ?> :</label></th> <td><input readonly type="text" name="cp_sys_expire_date" class="text" id="datepicker" value="<?php echo esc_attr(get_post_meta($post->ID, 'cp_sys_expire_date', true)); ?> " /></td> </tr> <tr> <th colspan="2" style="padding:0px;"> </th> </tr> <?php cp_edit_ad_fields($results, $post->ID); // build the edit ad meta box ?> <tr> <th style="width:20%"><label for="cp_sys_userIP"><?php _e('Submitted from IP', APP_TD); ?> :</label></th> <td><?php echo esc_html(get_post_meta($post->ID, 'cp_sys_userIP', true)); ?> </td> </tr> </table> <?php } ?> <?php }
function cp_other_fields($renew_id = false) { global $wpdb, $cp_options; // are images on ads allowed if ($cp_options->ad_images) { if (appthemes_plupload_is_enabled()) { echo appthemes_plupload_form($renew_id); } else { if ($renew_id) { $imagecount = cp_get_ad_images($renew_id); echo cp_ad_edit_image_input_fields($imagecount); } else { echo cp_image_input_fields(); } } } // show the chargeable options if enabled if (cp_payments_is_enabled()) { // show the featured ad box if enabled if ($cp_options->sys_feat_price) { ?> <li id="list_featured_ad" class="withborder"> <div class="labelwrapper"> <label><?php printf(__('Featured Listing %s', APP_TD), appthemes_get_price($cp_options->sys_feat_price)); ?> </label> </div> <div class="clr"></div> <input name="featured_ad" value="1" type="checkbox" <?php checked(isset($_POST['featured_ad'])); ?> /> <?php _e('Your listing will appear in the featured slider section at the top of the front page.', APP_TD); ?> <div class="clr"></div> </li> <?php } if ($cp_options->price_scheme == 'single') { ?> <li> <div class="labelwrapper"> <label><?php _e('Ad Package:', APP_TD); ?> </label> </div> <?php // go get all the active ad packs and create a drop-down of options $results = $wpdb->get_results("SELECT * FROM {$wpdb->cp_ad_packs} WHERE pack_status = 'active' ORDER BY pack_id asc"); if ($results) { ?> <select name="ad_pack_id" class="dropdownlist required"> <?php foreach ($results as $result) { // external plugins can modify or disable field $result = apply_filters('cp_package_field', $result, 'ad'); if (!$result) { continue; } ?> <option value="<?php echo esc_attr($result->pack_id); ?> "><?php echo esc_attr(stripslashes($result->pack_name)); ?> </option> <?php } ?> </select> <?php } else { _e('Error: no ad pack has been defined. Please contact the site administrator.', APP_TD); } ?> <div class="clr"></div> </li> <?php } ?> <?php } // end charge for ads check }
/** * Helper function for generating dropdown list of categories with prices. * Determines when the price should be displayed. * * @param object $category * @param array $args * * @return string */ function cp_category_dropdown_price($category, $args) { global $cp_options; if ($cp_options->price_scheme != 'category' || !cp_payments_is_enabled()) { return ''; } if ($cp_options->ad_parent_posting == 'no' && $category->parent == 0) { return ''; } if ($cp_options->ad_parent_posting == 'whenEmpty' && $category->parent == 0) { $child_terms = get_terms($args['taxonomy'], array('parent' => $category->term_id, 'number' => 1, 'hide_empty' => 0)); if (!empty($child_terms)) { return ''; } } $prices = $cp_options->price_per_cat; $cat_price = isset($prices[$category->term_id]) ? (double) $prices[$category->term_id] : 0; return ' - ' . appthemes_get_price($cat_price); }
public function test_output() { $string = appthemes_get_price(1); $this->expectOutputString($string); appthemes_display_price(1); }
function get_pack_benefit($membership, $returnTotal = false) { $benefitHTML = ''; if (!current_theme_supports('app-price-format')) { return false; } switch ($membership->pack_type) { case 'percentage': if ($returnTotal) { return number_format($returnTotal * ($membership->pack_price / 100), 2); } $benefitHTML .= preg_replace('/.00$/', '', $membership->pack_price) . '% ' . __('of price', APP_TD); //remove decimal when decimal is .00 break; case 'discount': if ($returnTotal) { return number_format($returnTotal - $membership->pack_price * 1, 2); } $benefitHTML .= sprintf(__('%s\'s less per ad', APP_TD), appthemes_get_price($membership->pack_price)); break; case 'required_static': if ($returnTotal) { return number_format($membership->pack_price * 1, 2); } if ((double) $membership->pack_price == 0) { $benefitHTML .= __('Free Posting', APP_TD); } else { $benefitHTML .= sprintf(__('%s per ad', APP_TD), appthemes_get_price($membership->pack_price)); } $benefitHTML .= ' (' . __('required to post', APP_TD) . ')'; break; case 'required_discount': if ($returnTotal) { return number_format($returnTotal - $membership->pack_price * 1, 2); } if ($membership->pack_price > 0) { $benefitHTML .= sprintf(__('%s\'s less per ad', APP_TD), appthemes_get_price($membership->pack_price)); } $benefitHTML .= ' (' . __('required to post', APP_TD) . ')'; break; case 'required_percentage': if ($returnTotal) { return number_format($returnTotal * ($membership->pack_price / 100), 2); } if ($membership->pack_price < 100) { $benefitHTML .= preg_replace('/.00$/', '', $membership->pack_price) . '% ' . __('of price', APP_TD); } //remove decimal when decimal is .00 $benefitHTML .= ' (' . __('required to post', APP_TD) . ')'; break; default: //likely 'static' if ($returnTotal) { return number_format($membership->pack_price * 1, 2); } if ((double) $membership->pack_price == 0) { $benefitHTML .= __('Free Posting', APP_TD); } else { $benefitHTML .= sprintf(__('%s per ad', APP_TD), appthemes_get_price($membership->pack_price)); } } return $benefitHTML; }
<div class="pricing_table"> <form name="mainform" id="mainform" class="form_membership_step" action="" method="post" enctype="multipart/form-data"> <div class="table_heading"> <h1><?php echo stripslashes($result->pack_name); ?> </h1> <?php //echo appthemes_get_price( $result->pack_membership_price ).'<br>'; //echo $result->pack_duration.'<br>'; //echo '%1$s / %2$s days', APP_TD; //printf( __( '%1$s / %2$s days', APP_TD ), appthemes_get_price( $result->pack_membership_price ), $result->pack_duration ); ?> <p><span><?php echo appthemes_get_price($result->pack_membership_price); ?> </span> <?php echo ' / ' . $result->pack_duration . ' days'; ?> </p> <ul> <li><?php echo $benefit; ?> </li> <?php if ($result->pack_horse_limit != 0) { ?> <li><?php
/** * Displays membership package custom columns data. * * @param string $column_index * @param int $post_id * * @return void */ function cp_package_membership_add_column_data($column_index, $post_id) { $package = cp_get_membership_package($post_id); if (!$package) { return; } switch ($column_index) { case 'description': echo strip_tags($package->description); break; case 'price': echo cp_get_membership_package_benefit_text($package->ID); break; case 'terms': printf(__('%1$s / %2$s days', APP_TD), appthemes_get_price($package->price), $package->duration); break; case 'status': if ($package->post_status == 'publish') { _e('Active', APP_TD); } else { _e('Inactive', APP_TD); } break; } }
?> </strong><br/><span class="year"><?php the_time(__('Y', APP_TD)); ?> </span></td> <td class="order-history-summary left"> <span class="order-history-ad"><?php the_order_ad_link($order); ?> </span> <?php echo cp_get_the_order_summary($order, $output_type = 'html'); ?> </td> <td class="order-history-price center"><?php echo appthemes_get_price($order->get_total()); ?> </td> <td class="order-history-payment center"><?php the_orders_history_payment($order); ?> </td> </tr> <?php } ?> <?php } else { ?>
?> </h2> </div> <div class="content"> <p><strong><?php _e('Order ID:', APP_TD); ?> </strong> <?php echo $order->get_id(); ?> </p> <p><strong><?php _e('Order Total:', APP_TD); ?> </strong> <?php echo appthemes_get_price($order->get_total(), $order->get_currency()); ?> </p> <p><?php _e('For questions or problems, please contact us directly at', APP_TD); ?> <?php echo get_option('admin_email'); ?> </p> <p><?php printf(__('To cancel this request and use a regular gateway instead, <a href="%s">click here</a>.', APP_TD), get_the_order_cancel_url()); ?> </p> </div> </fieldset>
public function stats_box() { $users = array(); $users_stats = $this->get_user_counts(); ?> <div class="stats_overview"> <h3><?php _e('New Registrations', APP_TD); ?> </h3> <div class="overview_today"> <p class="overview_day"><?php _e('Today', APP_TD); ?> </p> <p class="overview_count"><?php echo $users_stats['today']; ?> </p> <p class="overview_type"><em><?php _e('Customers', APP_TD); ?> </em></p> </div> <div class="overview_previous"> <p class="overview_day"><?php _e('Yesterday', APP_TD); ?> </p> <p class="overview_count"><?php echo $users_stats['yesterday']; ?> </p> <p class="overview_type"><em><?php _e('Customers', APP_TD); ?> </em></p> </div> </div> <?php $stats = array(); $listings = $this->get_listing_counts(); if (isset($listings['publish'])) { $stats[__('Total Live Ads', APP_TD)] = array('text' => $listings['publish'], 'url' => add_query_arg(array('post_type' => APP_POST_TYPE, 'post_status' => 'publish'), admin_url('edit.php'))); } else { $stats[__('Total Live Ads', APP_TD)] = 0; } if (isset($listings['pending'])) { $stats[__('Total Pending Ads', APP_TD)] = array('text' => $listings['pending'], 'url' => add_query_arg(array('post_type' => APP_POST_TYPE, 'post_status' => 'pending'), admin_url('edit.php'))); } else { $stats[__('Total Pending Ads', APP_TD)] = 0; } $stats[__('Total Users', APP_TD)] = array('text' => $users_stats['total_users'], 'url' => 'users.php'); if (current_theme_supports('app-payments')) { $revenue = $this->get_orders_revenue(); $stats[__('Revenue (7 days)', APP_TD)] = appthemes_get_price($revenue['week']); $stats[__('Total Revenue', APP_TD)] = appthemes_get_price($revenue['total']); } $stats[__('Product Version', APP_TD)] = CP_VERSION; $stats[__('Product Support', APP_TD)] = html('a', array('href' => 'http://forums.appthemes.com'), __('Forum', APP_TD)); $stats[__('Product Support', APP_TD)] .= ' | ' . html('a', array('href' => 'http://docs.appthemes.com/'), __('Documentation', APP_TD)); $this->output_list($stats); }
protected function row($item) { if (!APP_Item_Registry::is_registered($item['type'])) { return ''; } $cells = array(APP_Item_Registry::get_title($item['type']), appthemes_get_price($item['price'], $this->currency)); return html($this->args['row_html'], array(), $this->cells($cells)); }
public function stats_box() { $users_stats = $this->_get_user_counts(); ?> <style type="text/css"> #stats ul {font-size: 12px;} div.stats-info {float:left;width:45%;} div.stats_overview { float: right; width: 45%; background: none repeat scroll 0 0 #F9F9F9; border: 1px solid #DFDFDF; -moz-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius: 5px;-khtml-border-radius: 5px;border-radius: 5px;} .stats_overview, .overview_today {float: left; width: 50%;} .stats_overview, .overview_previous {float: left; width: 50%;} .stats_overview p.overview_day { font-size: 12px !important;color: #666666; font-weight: bold; margin-top: 6px;} .stats_overview p {margin: 0;padding: 0;text-align: center;text-shadow: 0 1px 0 #FFFFFF;text-transform: uppercase;} .stats_overview h3 {text-align: center;text-shadow: 0 1px 0 #FFFFFF;} .stats_overview p.overview_count {color: #333333;font-size: 20px !important;font-weight: bold;} .stats_overview p.overview_type em {background: none repeat scroll 0 0 #FFFBE4;border-radius: 3px 3px 3px 3px;padding: 1px 5px 2px;} .stats_overview p.overview_type, .stats_overview p.overview_type_seek { color: #999999; font-size: 9px !important; margin-bottom: 7px;} .stats_overview p.overview_type_seek em { background: none repeat scroll 0 0 #FFFBE4; border-radius: 3px 3px 3px 3px;padding: 1px 5px 2px;} </style> <div class="stats_overview"> <h3><?php _e('New Registrations', APP_TD); ?> </h3> <div class="overview_today"> <p class="overview_day"><?php _e('Today', APP_TD); ?> </p> <p class="overview_count"><?php echo $users_stats['today']; ?> </p> <p class="overview_type"><em><?php _e('Customers', APP_TD); ?> </em></p> </div> <div class="overview_previous"> <p class="overview_day"><?php _e('Yesterday', APP_TD); ?> </p> <p class="overview_count"><?php echo $users_stats['yesterday']; ?> </p> <p class="overview_type"><em><?php _e('Customers', APP_TD); ?> </em></p> </div> </div> <div class="stats-info"> <?php /** * Hook to add app-specific stats sections * * @param array $sections { * An array of a sections and section items within. Where array key is * section slug and value is an array of section items * * @type array $section { * An array of section items. Where key is item label and value is item text * * @type string $item Item value * } * @type array $apps { * A single dimentional array of activated apps. Section slug 'apps'. * * @type string $app App name and version (i.e 'Vantage 1.4.1') * } * } */ $sections = apply_filters('appthemes_dashboard_stats_box', array()); // total users section $sections['total_users'][__('Total Users', APP_TD)] = array('text' => $users_stats['total_users'], 'url' => 'users.php'); // revenue section if (current_theme_supports('app-payments')) { $date_week_ago = date('Y-m-d', strtotime('-7 days', current_time('timestamp'))); $sections['revenue'][__('Last 7 Days', APP_TD)] = appthemes_get_price(appthemes_get_orders_revenue($date_week_ago)); $sections['revenue'][__('Overall', APP_TD)] = appthemes_get_price(appthemes_get_orders_revenue()); } // merge 'apps' section and move to the end if (isset($sections['apps'])) { $apps = $sections['apps']; unset($sections['apps']); if (is_array($apps)) { $sections['apps'][__('Installed Apps', APP_TD)] = implode(', ', $apps); } } // support links section $sections['support'][__('Support', APP_TD)] = html('a', array('href' => 'http://forums.appthemes.com', 'target' => '_blank'), __('Forums', APP_TD)); $sections['support'][__('Support', APP_TD)] .= ' | ' . html('a', array('href' => 'https://docs.appthemes.com/', 'target' => '_blank'), __('Docs', APP_TD)); foreach ($sections as $section) { $this->_output_list((array) $section); } ?> </div> <?php }