function template_redirect() { global $cp_options; // if not logged in, redirect to login page //appthemes_auth_redirect_login(); // this is needed for IE to work with the go back button header("Cache-control: private"); global $current_user; if ($current_user->roles[0] != 'administrator') { cp_redirect_membership(); } //cp_redirect_membership(); // redirect to dashboard if can't renew if (isset($_GET['renew'])) { CP_Add_New::can_renew_ad(); } // needed for image uploading and deleting to work require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; // include all the functions needed for this form require_once get_template_directory() . '/includes/forms/step-functions.php'; // load up the validate and tinymce scripts add_action('wp_enqueue_scripts', 'cp_load_form_scripts'); // load app-plupload scripts if (isset($_POST['cat']) && !isset($_POST['step1']) && $cp_options->ad_images && appthemes_plupload_is_enabled()) { add_action('wp_enqueue_scripts', 'appthemes_plupload_enqueue_scripts'); } }
function can_renew_ad() { if (isset($_GET['renew'])) { if (get_option('cp_allow_relist') != 'yes') { return CP_Add_New::redirect_dashboard('renew-disabled'); } if (!is_numeric($_GET['renew']) || $_GET['renew'] != preg_replace('/[^0-9]/', '', $_GET['renew'])) { return CP_Add_New::redirect_dashboard('renew-invalid-id'); } $post = get_post($_GET['renew']); if (!$post) { return CP_Add_New::redirect_dashboard('renew-invalid-id'); } if (!in_array($post->post_status, array('draft', 'pending'))) { return CP_Add_New::redirect_dashboard('renew-not-expired'); } $expire_date = get_post_meta($post->ID, 'cp_sys_expire_date', true); if (strtotime($expire_date) > strtotime(date('Y-m-d H:i:s'))) { return CP_Add_New::redirect_dashboard('renew-not-expired'); } } }
require_once TEMPLATEPATH . '/includes/gateways/paypal/ipn.php'; } new CP_Blog_Archive(); new CP_Ads_Categories(); new CP_Add_New(); new CP_Add_New_Confirm(); new CP_Membership(); new CP_Membership_Confirm(); new CP_Edit_Item(); new CP_User_Dashboard(); new CP_User_Profile(); // set global path variables define('CP_DASHBOARD_URL', get_permalink(CP_User_Dashboard::get_id())); define('CP_PROFILE_URL', get_permalink(CP_User_Profile::get_id())); define('CP_EDIT_URL', get_permalink(CP_Edit_Item::get_id())); define('CP_ADD_NEW_URL', get_permalink(CP_Add_New::get_id())); define('CP_ADD_NEW_CONFIRM_URL', get_permalink(CP_Add_New_Confirm::get_id())); define('CP_MEMBERSHIP_PURCHASE_URL', get_permalink(CP_Membership::get_id())); define('CP_MEMBERSHIP_PURCHASE_CONFIRM_URL', get_permalink(CP_Membership_Confirm::get_id())); add_theme_support('app-versions', array('update_page' => 'admin.php?page=settings&firstrun=1', 'current_version' => $app_version, 'option_key' => 'cp_version')); add_theme_support('app-plupload', array('max_file_size' => get_option('cp_max_image_size') . 'kb', 'allowed_files' => get_option('cp_num_images'))); add_theme_support('app-wrapping'); add_theme_support('app-login', array('login' => 'tpl-login.php', 'register' => 'tpl-registration.php', 'recover' => 'tpl-password-recovery.php', 'reset' => 'tpl-password-reset.php', 'redirect' => get_option('cp_disable_wp_login') == 'yes', 'settings_page' => 'admin.php?page=settings&setTabIndex=4')); add_theme_support('app-feed', array('post_type' => APP_POST_TYPE, 'blog_template' => 'tpl-blog.php', 'alternate_feed_url' => get_option('cp_feedburner_url'))); // add query var for search functions function cp_add_query_vars() { global $wp; $wp->add_query_var('scat'); } add_filter('init', 'cp_add_query_vars');
function __construct() { self::$_template = 'create-listing.php'; parent::__construct(self::$_template, __('Create Listing', APP_TD)); }
/** * Update orders to include urls, checkout type, and hash. * * @since 3.4 */ function cp_upgrade_340_orders() { $order_ids = get_option('cp_upgrade_340_orders'); if (!$order_ids || $order_ids == 'done') { return; } $i = 0; $left_orders = $order_ids; foreach ($order_ids as $key => $order_id) { $i++; // all orders updated, quit the loop if (empty($left_orders)) { break; } // save current progress, and continue on next page load (memory and execution time have limits) if ($i > 50) { echo scb_admin_notice(sprintf(__('Orders Update Progress: %d orders left.', APP_TD), count($left_orders))); update_option('cp_upgrade_340_orders', $left_orders); return; } unset($left_orders[$key]); // updated order check if ($checkout_hash = get_post_meta($order_id, 'checkout_hash', true)) { continue; } // retrieve order object $order = appthemes_get_order($order_id); if (!$order) { continue; } // determine checkout type and url if ($item = $order->get_item(CP_ITEM_LISTING)) { $listing_orders_args = array('connected_type' => APPTHEMES_ORDER_CONNECTION, 'connected_query' => array('post_status' => 'any'), 'connected_to' => $item['post_id'], 'post_status' => 'any', 'fields' => 'ids', 'nopaging' => true); $listing_orders = new WP_Query($listing_orders_args); if (empty($listing_orders->posts) || $order_id == min($listing_orders->posts)) { $checkout_type = 'create-listing'; $checkout_url = get_permalink(CP_Add_New::get_id()); } else { $checkout_type = 'renew-listing'; $checkout_url = add_query_arg('listing_renew', $item['post_id'], get_permalink(CP_Renew_Listing::get_id())); } } else { if ($item = $order->get_item(CP_ITEM_MEMBERSHIP)) { $checkout_type = 'membership-purchase'; $checkout_url = get_permalink(CP_Membership::get_id()); } else { // unknown/invalid order continue; } } // generate new checkout hash $hash = substr(sha1(time() . mt_rand(0, 1000)), 0, 20); // if url set, get the hash if ($complete_url = get_post_meta($order_id, 'complete_url', true)) { $parsed_url = parse_url($complete_url); parse_str($parsed_url['query'], $url_args); if (!empty($url_args['hash'])) { $hash = $url_args['hash']; } } $complete_url = add_query_arg(array('step' => 'order-summary', 'hash' => $hash), $checkout_url); $cancel_url = add_query_arg(array('step' => 'gateway-select', 'hash' => $hash), $checkout_url); update_post_meta($order_id, 'complete_url', $complete_url); update_post_meta($order_id, 'cancel_url', $cancel_url); update_post_meta($order_id, 'checkout_type', $checkout_type); update_post_meta($order_id, 'checkout_hash', $hash); } // mark this upgrage as completed update_option('cp_upgrade_340_orders', 'done'); }