function webdados_fb_open_graph() { global $webdados_fb_open_graph_plugin_settings, $webdados_fb_open_graph_plugin_name, $webdados_fb_open_graph_plugin_version, $webdados_fb_open_graph_settings; //Upgrade webdados_fb_open_graph_upgrade(); //Get options - OLD (until 0.5.4) /*foreach($webdados_fb_open_graph_plugin_settings as $key) { $$key=get_option('wonderm00n_open_graph_'.$key); }*/ //Get options - NEW (after 0.5.4) extract($webdados_fb_open_graph_settings); //Also set Title Tag? $fb_set_title_tag = 0; //Additional images $fb_image_additional = array(); $fb_type = 'article'; if (is_singular()) { //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page global $post; $fb_title = esc_attr(strip_tags(stripslashes($post->post_title))); //SubHeading if ($fb_show_subheading == 1) { if (webdados_fb_open_graph_subheadingactive()) { $fb_title .= ' - ' . get_the_subheading(); } } $fb_url = get_permalink(); if (is_front_page()) { /* Fix homepage type when it's a static page */ $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : ''); $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage); } if (trim($post->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($post->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($post->post_content); } $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))); if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { $fb_image = webdados_fb_open_graph_post_image($fb_image_use_specific, $fb_image_use_featured, $fb_image_use_content, $fb_image_use_media, $fb_image_use_default, $fb_image); } //Author $author_id = $post->post_author; if ($author_id > 0) { $fb_author = get_the_author_meta('facebook', $author_id); $fb_author_meta = get_the_author_meta('display_name', $author_id); $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id); $fb_author_twitter = get_the_author_meta('twitter', $author_id); } else { $fb_author = ''; $fb_author_meta = ''; $fb_author_linkrelgp = ''; $fb_author_twitter = ''; } //Author - Hide on pages? if (is_page() && $fb_author_hide_on_pages == 1) { $fb_author = ''; $fb_author_meta = ''; $fb_author_linkrelgp = ''; $fb_author_twitter = ''; } //Published and Modified time if (is_singular('post')) { $fb_article_pub_date = get_the_date('c'); $fb_article_mod_date = get_the_modified_date('c'); } else { $fb_article_dates_show = 0; $fb_article_pub_date = ''; $fb_article_mod_date = ''; } //Categories if (is_singular('post')) { $cats = get_the_category(); if (!is_wp_error($cats) && (is_array($cats) && count($cats) > 0)) { $fb_sections = array(); foreach ($cats as $cat) { $fb_sections[] = $cat->name; } } } else { $fb_article_sections_show = 0; } //Business Directory Plugin if ($fb_show_businessdirectoryplugin == 1) { @(include_once ABSPATH . 'wp-admin/includes/plugin.php'); if (is_plugin_active('business-directory-plugin/wpbusdirman.php')) { global $wpbdp; //$bdpaction = _wpbdp_current_action(); $bdpaction = $wpbdp->controller->get_current_action(); switch ($bdpaction) { case 'showlisting': //Listing $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id')); $bdppost = get_post($listing_id); $fb_title = esc_attr(strip_tags(stripslashes($bdppost->post_title))) . ' - ' . $fb_title; $fb_set_title_tag = 1; $fb_url = get_permalink($listing_id); if (trim($bdppost->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($bdppost->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($bdppost->post_content); } $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))); if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { $thumbdone = false; if (intval($fb_image_use_featured) == 1) { //Featured if ($id_attachment = get_post_thumbnail_id($bdppost->ID)) { //There's a featured/thumbnail image for this listing $fb_image = wp_get_attachment_url($id_attachment, false); $thumbdone = true; } } if (!$thumbdone) { //Main image loaded if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($bdppost->ID)) { $fb_image = wp_get_attachment_url($thumbnail_id, false); } } } break; case 'browsecategory': //Categories $term = get_term_by('slug', get_query_var('category'), wpbdp_categories_taxonomy()); $fb_title = esc_attr(strip_tags(stripslashes($term->name))) . ' - ' . $fb_title; $fb_set_title_tag = 1; $fb_url = get_term_link($term); if (trim($term->description) != '') { $fb_desc = trim($term->description); } break; case 'main': //Main page //No changes break; default: //No changes break; } } } } else { global $wp_query; //Other pages - Defaults $fb_title = esc_attr(strip_tags(stripslashes(get_bloginfo('name')))); //$fb_url=get_option('home').(intval($fb_url_add_trailing)==1 ? '/' : ''); //2013-11-4 changed from 'siteurl' to 'home' $fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //Not really canonical but will work for now //These are only used in posts/pages $fb_article_sections_show = 0; $fb_article_dates_show = 0; $fb_author_show = 0; $fb_author_show_meta = 0; $fb_author_show_linkrelgp = 0; $fb_author_show_twitter = 0; switch (trim($fb_desc_homepage)) { case 'custom': $fb_desc = esc_attr(strip_tags(stripslashes($fb_desc_homepage_customtext))); //WPML? if (function_exists('icl_object_id') && function_exists('icl_register_string')) { global $sitepress; if (ICL_LANGUAGE_CODE != $sitepress->get_default_language()) { $fb_desc = icl_t('wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc); } else { //We got it already } } break; default: $fb_desc = esc_attr(strip_tags(stripslashes(get_bloginfo('description')))); break; } if (is_category()) { $fb_title = esc_attr(strip_tags(stripslashes(single_cat_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $cat_desc = trim(esc_attr(strip_tags(stripslashes(category_description())))); if (trim($cat_desc) != '') { $fb_desc = $cat_desc; } } else { if (is_tag()) { $fb_title = esc_attr(strip_tags(stripslashes(single_tag_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $tag_desc = trim(esc_attr(strip_tags(stripslashes(tag_description())))); if (trim($tag_desc) != '') { $fb_desc = $tag_desc; } } else { if (is_tax()) { $fb_title = esc_attr(strip_tags(stripslashes(single_term_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); //WooCommerce if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { if (class_exists('woocommerce') && $fb_wc_usecategthumb == 1 && is_product_category()) { if ($thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)) { if ($image = wp_get_attachment_url($thumbnail_id)) { $fb_image = $image; } } } } } else { if (is_search()) { $fb_title = esc_attr(strip_tags(stripslashes(__('Search for') . ' "' . get_search_query() . '"'))); $fb_url = get_search_link(); } else { if (is_author()) { $fb_title = esc_attr(strip_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author'))))); $fb_url = get_author_posts_url(get_query_var('author'), get_query_var('author_name')); } else { if (is_archive()) { if (is_day()) { $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('day') . ' ' . single_month_title(' ', false) . ' ' . __('Archives')))); $fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')); } else { if (is_month()) { $fb_title = esc_attr(strip_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives')))); $fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum')); } else { if (is_year()) { $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('year') . ' ' . __('Archives')))); $fb_url = get_year_link(get_query_var('year')); } } } } else { if (is_front_page()) { $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : ''); $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage); } else { //Others... Defaults already set up there } } } } } } } } //If no description let's just add the title if (trim($fb_desc) == '') { $fb_desc = $fb_title; } //YOAST? if ($fb_show_wpseoyoast == 1) { if (defined('WPSEO_VERSION')) { $wpseo = WPSEO_Frontend::get_instance(); //App ID - From our plugin //Admin ID - From our plugin //Locale - From our plugin //Sitename - From our plugin //Title - From WPSEO $fb_title = strip_tags($wpseo->title(false)); //Title - SubHeading plugin if ($fb_show_subheading == 1) { if (webdados_fb_open_graph_subheadingactive()) { $fb_title .= ' - ' . get_the_subheading(); } } //URL - From WPSEO $fb_url = $wpseo->canonical(false); //Description - From WPSEO or our plugin $fb_desc_temp = $wpseo->metadesc(false); $fb_desc = strip_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc); //Image - From our plugin } } //WooCommerce - Additional product images? if (intval($fb_image_show) == 1 && class_exists('woocommerce') && $fb_wc_useproductgallery == 1 && is_product()) { global $post; $product = new WC_Product($post->ID); if ($attachment_ids = $product->get_gallery_attachment_ids()) { foreach ($attachment_ids as $attachment_id) { if ($image_link = wp_get_attachment_url($attachment_id)) { if (trim($image_link) != '') { $fb_image_additional[] = trim($image_link); } } } } } //Apply Filters $fb_title = apply_filters('fb_og_title', $fb_title); $fb_desc = apply_filters('fb_og_desc', $fb_desc); $fb_image = apply_filters('fb_og_image', $fb_image); $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional); $fb_locale = apply_filters('fb_og_locale', $fb_locale); $fb_image_size = false; if (intval($fb_image_show) == 1 && trim($fb_image) != '') { if (intval($fb_image_size_show) == 1) { if (isset($GLOBALS['webdados_fb_img_size'])) { //Already fetched $fb_image_size = $GLOBALS['webdados_fb_img_size']; } else { $fb_image_size = webdados_fb_open_graph_getimagesize($fb_image); } } } else { $fb_image_size_show = 0; } //No spaces on URLs if (isset($fb_url) && trim($fb_url) != '') { $fb_url = str_replace(' ', '%20', trim($fb_url)); } if (isset($fb_publisher) && trim($fb_publisher) != '') { $fb_publisher = str_replace(' ', '%20', trim($fb_publisher)); } if (isset($fb_publisher_schema) && trim($fb_publisher_schema) != '') { $fb_publisher_schema = str_replace(' ', '%20', trim($fb_publisher_schema)); } if (isset($fb_author) && trim($fb_author) != '') { $fb_author = str_replace(' ', '%20', trim($fb_author)); } if (isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp) != '') { $fb_author_linkrelgp = str_replace(' ', '%20', trim($fb_author_linkrelgp)); } if (isset($fb_image) && trim($fb_image) != '') { $fb_image = str_replace(' ', '%20', trim($fb_image)); } if (isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)) { foreach ($fb_image_additional as $key => $value) { $fb_image_additional[$key] = str_replace(' ', '%20', trim($value)); } } $html = ' <!-- START - ' . $webdados_fb_open_graph_plugin_name . ' ' . $webdados_fb_open_graph_plugin_version . ' --> '; if (intval($fb_app_id_show) == 1 && trim($fb_app_id) != '') { $html .= '<meta property="fb:app_id" content="' . trim(esc_attr($fb_app_id)) . '"/> '; } if (intval($fb_admin_id_show) == 1 && trim($fb_admin_id) != '') { $html .= '<meta property="fb:admins" content="' . trim(esc_attr($fb_admin_id)) . '"/> '; } if (intval($fb_locale_show) == 1) { $html .= '<meta property="og:locale" content="' . trim(esc_attr(trim($fb_locale) != '' ? trim($fb_locale) : trim(get_locale()))) . '"/> '; } if (intval($fb_sitename_show) == 1) { $html .= '<meta property="og:site_name" content="' . trim(esc_attr(get_bloginfo('name'))) . '"/> '; } if (intval($fb_title_show) == 1) { $html .= '<meta property="og:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_set_title_tag) == 1) { //Does nothing so far. We try to create the <title> tag but it's too late now } if (intval($fb_title_show_schema) == 1) { $html .= '<meta itemprop="name" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_title_show_twitter) == 1) { $html .= '<meta name="twitter:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_url_show) == 1) { $html .= '<meta property="og:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_url_show_twitter) == 1) { $html .= '<meta name="twitter:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_url_canonical) == 1) { $html .= '<link rel="canonical" href="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_type_show) == 1) { $html .= '<meta property="og:type" content="' . trim(esc_attr($fb_type)) . '"/> '; } if (intval($fb_article_dates_show) == 1 && trim($fb_article_pub_date) != '') { $html .= '<meta property="article:published_time" content="' . trim(esc_attr($fb_article_pub_date)) . '"/> '; } if (intval($fb_article_dates_show) == 1 && trim($fb_article_mod_date) != '') { $html .= '<meta property="article:modified_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> <meta property="og:updated_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> '; } if (intval($fb_article_sections_show) == 1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections) > 0) { foreach ($fb_sections as $fb_section) { $html .= '<meta property="article:section" content="' . trim(esc_attr($fb_section)) . '"/> '; } } if (intval($fb_publisher_show) == 1 && trim($fb_publisher) != '') { $html .= '<meta property="article:publisher" content="' . trim(esc_attr($fb_publisher)) . '"/> '; } if (intval($fb_publisher_show_schema) == 1 && trim($fb_publisher_schema) != '') { $html .= '<link rel="publisher" href="' . trim(esc_attr($fb_publisher_schema)) . '"/> '; } if (intval($fb_publisher_show_twitter) == 1 && trim($fb_publisher_twitteruser) != '') { $html .= '<meta name="twitter:site" content="@' . trim(esc_attr($fb_publisher_twitteruser)) . '"/> '; } if (intval($fb_author_show) == 1 && $fb_author != '') { $html .= '<meta property="article:author" content="' . trim(esc_attr($fb_author)) . '"/> '; } if (intval($fb_author_show_meta) == 1 && $fb_author_meta != '') { $html .= '<meta name="author" content="' . trim(esc_attr($fb_author_meta)) . '"/> '; } if (intval($fb_author_show_linkrelgp) == 1 && trim($fb_author_linkrelgp) != '') { $html .= '<link rel="author" href="' . trim(esc_attr($fb_author_linkrelgp)) . '"/> '; } if (intval($fb_author_show_twitter) == 1 && (trim($fb_author_twitter) != '' || trim($fb_publisher_twitteruser) != '')) { $html .= '<meta name="twitter:creator" content="@' . trim(esc_attr(trim($fb_author_twitter) != '' ? trim($fb_author_twitter) : trim($fb_publisher_twitteruser))) . '"/> '; } if (intval($fb_desc_show) == 1) { $html .= '<meta property="og:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_meta) == 1) { $html .= '<meta name="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_schema) == 1) { $html .= '<meta itemprop="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_twitter) == 1) { $html .= '<meta name="twitter:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_image_show) == 1 && trim($fb_image) != '') { $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_image_show) == 1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) > 0) { foreach ($fb_image_additional as $fb_image_additional_temp) { $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image_additional_temp)) . '"/> '; } } else { //We only show the image size if we only have one image if (intval($fb_image_size_show) == 1 && isset($fb_image_size) && is_array($fb_image_size) != '') { $html .= '<meta property="og:image:width" content="' . intval(esc_attr($fb_image_size[0])) . '"/> <meta property="og:image:height" content="' . intval(esc_attr($fb_image_size[1])) . '"/> '; } } if (intval($fb_image_show_schema) == 1 && trim($fb_image) != '') { $html .= '<meta itemprop="image" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_image_show_twitter) == 1 && trim($fb_image) != '') { $html .= '<meta name="twitter:image:src" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_title_show_twitter) == 1 || intval($fb_url_show_twitter) == 1 || $fb_author_show_twitter == 1 || $fb_publisher_show_twitter == 1 || $fb_image_show_twitter == 1) { $html .= '<meta name="twitter:card" content="' . trim(esc_attr($fb_twitter_card_type)) . '"/> '; } $html .= '<!-- END - ' . $webdados_fb_open_graph_plugin_name . ' --> '; echo $html; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } echo sprintf('<form action="%s" method="GET">', wpbdp_get_page_link()); echo '<input type="hidden" name="action" value="search" />'; echo sprintf('<input type="hidden" name="page_id" value="%s" />', wpbdp_get_page_id('main')); echo '<input type="hidden" name="dosrch" value="1" />'; if (wpbdp_getv($instance, 'form_mode', 'basic') == 'advanced') { $fields_api = wpbdp_formfields_api(); foreach ($fields_api->get_fields() as $field) { if ($field->display_in('search') && in_array($field->get_id(), $instance['search_fields'])) { echo $field->render(null, 'search'); } } } else { echo '<input type="text" name="q" value="" />'; } echo sprintf('<p><input type="submit" value="%s" class="submit wpbdp-search-widget-submit" /></p>', _x('Search', 'widgets', 'WPBDM')); echo '</form>'; echo $after_widget; }
public function __construct($action = '') { $this->action = $action; if ('showlisting' == $this->action) { $this->listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id')); add_filter('get_the_time', array(&$this, 'listing_page__get_the_time'), 10, 2); add_filter('get_the_date', array(&$this, 'listing_page__get_the_date'), 10, 2); add_filter('get_the_modified_time', array(&$this, 'listing_page__get_the_modified_time'), 10, 2); add_filter('get_the_modified_date', array(&$this, 'listing_page__get_the_modified_date'), 10, 2); } }
function dispatch() { $action = wpbdp_getv($_REQUEST, 'action'); switch ($action) { case 'example-csv': $this->example_csv(); break; case 'do-import': $this->import(); break; default: $this->import_settings(); break; } }
function before_listing($trail) { // XXX: Taken from core/views.php:show_listing(). Probably a good idea to move this to an utility function. $id_or_slug = ''; if (get_query_var('listing') || isset($_GET['listing'])) { $id_or_slug = get_query_var('listing') ? get_query_var('listing') : wpbdp_getv($_GET, 'listing', 0); } else { $id_or_slug = get_query_var('id') ? get_query_var('id') : wpbdp_getv($_GET, 'id', 0); } $listing_id = wpbdp_get_post_by_id_or_slug($id_or_slug, 'id', 'id'); if (!$listing_id) { return; } $this->state['post'] = $GLOBALS['post']; $GLOBALS['post'] = get_post($listing_id); }
private function listing_fields() { $formfields_api = wpbdp_formfields_api(); $post_values = wpbdp_getv($_POST, 'listingfields', array()); echo wp_nonce_field(plugin_basename(__FILE__), 'wpbdp-listing-fields-nonce'); echo '<div style="border-bottom: solid 1px #dedede; padding-bottom: 10px;">'; echo sprintf('<strong>%s</strong>', _x('Listing Fields', 'admin', 'WPBDM')); echo '<div style="padding-left: 10px;">'; foreach ($formfields_api->find_fields(array('association' => 'meta')) as $field) { $value = isset($post_values[$field->get_id()]) ? $field->convert_input($post_values[$field->get_id()]) : $field->value($this->listing->get_id()); echo $field->render($value, 'admin-submit'); } echo '</div>'; echo '</div>'; echo '<div class="clear"></div>'; }
public function dispatch() { $action = wpbdp_getv($_REQUEST, 'action'); $_SERVER['REQUEST_URI'] = remove_query_arg(array('action', 'id'), $_SERVER['REQUEST_URI']); switch ($action) { case 'addfee': case 'editfee': $this->processFieldForm(); break; case 'deletefee': $this->delete_fee(); break; default: $this->feesTable(); break; } }
public function search() { $_REQUEST = stripslashes_deep($_REQUEST); $search_args = array(); $results = array(); if (isset($_GET['dosrch'])) { $search_args['q'] = wpbdp_getv($_GET, 'q', null); $search_args['fields'] = array(); // standard search fields $search_args['extra'] = array(); // search fields added by plugins foreach (wpbdp_getv($_GET, 'listingfields', array()) as $field_id => $field_search) { $search_args['fields'][] = array('field_id' => $field_id, 'q' => $field_search); } foreach (wpbdp_getv($_GET, '_x', array()) as $label => $field) { $search_args['extra'][$label] = $field; } $listings_api = wpbdp_listings_api(); if ($search_args['q'] && !$search_args['fields'] && !$search_args['extra']) { $results = $listings_api->quick_search($search_args['q']); } else { $results = $listings_api->search($search_args); } } $form_fields = wpbdp_get_form_fields(array('display_flags' => 'search', 'validators' => '-email')); $fields = ''; foreach ($form_fields as &$field) { $field_value = isset($_REQUEST['listingfields']) && isset($_REQUEST['listingfields'][$field->get_id()]) ? $field->convert_input($_REQUEST['listingfields'][$field->get_id()]) : $field->convert_input(null); $fields .= $field->render($field_value, 'search'); } $args = array('post_type' => WPBDP_POST_TYPE, 'posts_per_page' => wpbdp_get_option('listings-per-page') > 0 ? wpbdp_get_option('listings-per-page') : -1, 'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 'post__in' => $results ? $results : array(0), 'orderby' => wpbdp_get_option('listings-order-by', 'date'), 'order' => wpbdp_get_option('listings-sort', 'ASC')); $args = apply_filters('wpbdp_search_query_posts_args', $args, $search_args); query_posts($args); wpbdp_push_query($GLOBALS['wp_query']); $html = wpbdp_render('search', array('fields' => $fields, 'searching' => isset($_GET['dosrch']) ? true : false, 'show_form' => !isset($_GET['dosrch']) || wpbdp_get_option('show-search-form-in-results')), false); wp_reset_query(); wpbdp_pop_query(); return $html; }
/** * Returns the domain used in the current request, optionally stripping * the www part of the domain. * * @since 2.1.5 * @param $www boolean true to include the 'www' part, * false to attempt to strip it. */ function wpbdp_get_current_domain($www = true, $prefix = '') { $domain = wpbdp_getv($_SERVER, 'HTTP_HOST', ''); if (empty($domain)) { $domain = wpbdp_getv($_SERVER, 'SERVER_NAME', ''); } if (!$www && substr($domain, 0, 4) === 'www.') { $domain = $prefix . substr($domain, 4); } return $domain; }
?> <span class="description">(required)</span></label> </th> <td> <input name="fee[images]" type="text" aria-required="true" value="<?php echo wpbdp_getv($post_values, 'images', $fee ? $fee->images : '0'); ?> " style="width: 80px;" /> </td> </tr> <?php $post_values_categories = wpbdp_getv(isset($post_values['categories']) ? $post_values['categories'] : array(), 'categories', $fee ? $fee->categories['categories'] : array()); if ($fee && $fee->categories['all'] && !isset($post_values['categories']['categories'])) { $post_values_categories[] = 0; } ?> <tr class="form-field form-required"> <th scope="row"> <label> <?php _ex('Apply to category', 'fees admin', 'WPBDM'); ?> <span class="description">(required)</span></label> </th> <td> <select name="fee[categories][categories][]" multiple="multiple" size="10"> <option value="0" <?php echo in_array(0, $post_values_categories) || empty($post_values_categories) ? 'selected="selected"' : '';
public function dispatch() { global $wpdb; $api = wpbdp_payments_api(); switch (wpbdp_getv($_REQUEST, 'action')) { case 'approve': if ($trans = $api->get_transaction($_GET['id'])) { $trans->processed_on = current_time('mysql'); $trans->processed_by = 'admin'; $trans->status = 'approved'; $api->save_transaction($trans); } wpbdp_admin()->messages[] = _x('The transaction has been approved.', 'admin', 'WPBDM'); break; case 'reject': if ($trans = $api->get_transaction($_GET['id'])) { $trans->processed_on = current_time('mysql'); $trans->processed_by = 'admin'; $trans->status = 'rejected'; $api->save_transaction($trans); } wpbdp_admin()->messages[] = _x('The transaction has been rejected.', 'admin', 'WPBDM'); break; case 'delete': $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}wpbdp_payments WHERE id = %d", $_GET['id'])); wpbdp_admin()->messages[] = _x('The transaction has been deleted.', 'admin', 'WPBDM'); break; default: break; } $_SERVER['REQUEST_URI'] = remove_query_arg(array('action', 'id'), $_SERVER['REQUEST_URI']); $this->clear_transactions(); $this->transactions_table(); }
public function &get_field_type($field_type) { $field_type_obj = wpbdp_getv($this->field_types, $field_type, null); return $field_type_obj; }
<input type="text" id="wpbdp-billing-field-address-2" name="address_line2" size="25" value="<?php echo esc_attr(wpbdp_getv($posted, 'address_line2')); ?> " /> </td> </tr> <tr class="wpbdp-billing-field customer-zip-code"> <td scope="row"> <label for="wpbdp-billing-field-zip-code"><?php _ex('ZIP Code:', 'checkout form', 'WPBDM'); ?> </label> </td> <td> <input type="text" id="wpbdp-billing-field-zip-code" name="zipcode" size="25" value="<?php echo esc_attr(wpbdp_getv($posted, 'zipcode')); ?> " /> </td> </tr> </table> </div> <div class="form-buttons"> <!-- <input type="submit" name="cancel" value="<?php _ex('Cancel', 'WPBDM'); ?> " /> --> <input type="submit" name="pay" value="<?php _ex('Submit Payment', 'WPBDM'); ?>
</label> <input type="text" class="intextbox" name="commentauthoremail" value="<?php echo esc_attr(wpbdp_getv($_POST, 'commentauthoremail')); ?> " /> </p> <?php } ?> <p><label style="width:4em;"><?php _ex("Message", 'templates', "WPBDM"); ?> </label><br/> <textarea id="wpbdp-contact-form-message" name="commentauthormessage" rows="4" class="intextarea"><?php echo esc_textarea(wpbdp_getv($_POST, 'commentauthormessage', '')); ?> </textarea> </p> <?php if ($recaptcha) { ?> <?php echo $recaptcha; ?> <?php } ?>
function wpbdp_get_current_sort_option() { if ($sort = trim(wpbdp_getv($_GET, 'wpbdp_sort', null))) { $order = substr($sort, 0, 1) == '-' ? 'DESC' : 'ASC'; $sort = ltrim($sort, '-'); $obj = new StdClass(); $obj->option = $sort; $obj->order = $order; return $obj; } return null; }
public function tracking() { global $wpdb; wpbdp_log('Performing (scheduled) site tracking.'); $site_hash = $this->site_hash(); $data = get_transient('wpbdp-site_tracking_data'); if (!$data) { wpbdp_log('Gathering site tracking metrics.'); $data = array(); // General site info. $data['hash'] = $site_hash; $data['site-info'] = array('title' => get_bloginfo('name'), 'wp-version' => get_bloginfo('version'), 'bd-version' => WPBDP_VERSION, 'lang' => get_locale(), 'users' => count(get_users())); // Plugins info. if (!function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/admin.php'; } $data['plugins'] = array(); foreach (get_option('active_plugins') as $path) { $plugin = get_plugin_data(WP_PLUGIN_DIR . '/' . $path); $data['plugins'][] = array('id' => str_replace('/' . basename($path), '', $path), 'name' => wpbdp_getv($plugin, 'Name', ''), 'version' => wpbdp_getv($plugin, 'Version', ''), 'plugin_uri' => wpbdp_getv($plugin, 'PluginURI', ''), 'author' => wpbdp_getv($plugin, 'AuthorName', ''), 'author_uri' => wpbdp_getv($plugin, 'AuthorURI', '')); } // Theme info. $data['theme'] = array(); if (function_exists('wp_get_theme')) { $theme = wp_get_theme(); foreach (array('Name', 'ThemeURI', 'Version', 'Author', 'AuthorURI') as $k) { $data['theme'][strtolower($k)] = $theme->display($k, false, false); } $data['theme']['parent'] = array(); if ($theme_parent = $theme->parent()) { foreach (array('Name', 'ThemeURI', 'Version', 'Author', 'AuthorURI') as $k) { $data['theme']['parent'][strtolower($k)] = $theme_parent->display($k, false, false); } } else { $data['theme']['parent'] = null; } } else { $theme = (object) get_theme_data(get_stylesheet_directory() . '/style.css'); foreach (array('Name', 'Version', 'Author') as $k) { $data['theme'][strtolower($k)] = wpbdp_getv($theme, $k, ''); } } // Posts. $data['posts'] = array(); foreach (get_post_types(array('public' => true)) as $post_type) { $count = wp_count_posts($post_type); $data['posts'][$post_type] = intval($count->publish); } // Taxonomies. $data['taxonomies'] = array(); foreach (get_taxonomies(array('public' => true), 'objects') as $tax) { $data['taxonomies'][$tax->name] = array('name' => $tax->name, 'label' => $tax->label, 'terms' => intval(wp_count_terms($tax->name, array('hide_empty' => 0)))); } // Environment. $data['environment'] = array(); $data['environment']['os'] = php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('m'); $data['environment']['php'] = phpversion(); $data['environment']['mysql'] = $wpdb->get_var('SELECT @@version'); $data['environment']['server-software'] = $_SERVER['SERVER_SOFTWARE']; wp_remote_post(self::TRACKING_URL, array('method' => 'POST', 'blocking' => false, 'body' => $data)); set_transient('wpbdp-site_tracking_data', true, 7 * 60 * 60 * 24); } // delete_transient( 'wpbdp-site_tracking_data' ); }
function dispatch($plain = false) { global $wpdb; $debug_info = array(); // basic BD setup info & tests $debug_info['basic']['_title'] = _x('BD Info', 'debug-info', 'WPBDM'); $debug_info['basic']['BD version'] = WPBDP_VERSION; $debug_info['basic']['BD database revision (current)'] = WPBDP_Installer::DB_VERSION; $debug_info['basic']['BD database revision (installed)'] = get_option('wpbdp-db-version'); $tables = apply_filters('wpbdp_debug_info_tables_check', array('wpbdp_form_fields', 'wpbdp_fees', 'wpbdp_payments', 'wpbdp_listing_fees')); $missing_tables = array(); foreach ($tables as &$t) { if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->prefix . $t)) == '') { $missing_tables[] = $t; } } $debug_info['basic']['Table check'] = $missing_tables ? sprintf(_('Missing tables: %s', 'debug-info', 'WPBDM'), implode(',', $missing_tables)) : _x('OK', 'debug-info', 'WPBDM'); $debug_info['basic']['Main Page'] = sprintf('%d (%s)', wpbdp_get_page_id('main'), get_post_status(wpbdp_get_page_id('main'))); $debug_info['basic'] = apply_filters('wpbdp_debug_info_section', $debug_info['basic'], 'basic'); // BD options $blacklisted = array('googlecheckout-merchant', 'paypal-business-email', 'wpbdp-2checkout-seller', 'recaptcha-public-key', 'recaptcha-private-key'); $debug_info['options']['_title'] = _x('BD Options', 'debug-info', 'WPBDM'); $settings_api = wpbdp_settings_api(); foreach ($settings_api->settings as &$s) { if ($s->type == 'core' || in_array($s->name, $blacklisted)) { continue; } $value = wpbdp_get_option($s->name); $debug_info['options'][$s->name] = is_array($value) ? implode(',', $value) : $value; } $debug_info['options'] = apply_filters('wpbdp_debug_info_section', $debug_info['options'], 'options'); // environment info $debug_info['environment']['_title'] = _x('Environment', 'debug-info', 'WPBDM'); $debug_info['environment']['WordPress version'] = get_bloginfo('version', 'raw'); $debug_info['environment']['OS'] = php_uname('s') . ' ' . php_uname('r') . ' ' . php_uname('m'); if (function_exists('apache_get_version')) { $apache_version = apache_get_version(); $debug_info['environment']['Apache version'] = $apache_version; } $debug_info['environment']['PHP version'] = phpversion(); $mysql_version = $wpdb->get_var('SELECT @@version'); if ($sql_mode = $wpdb->get_var('SELECT @@sql_mode')) { $mysql_version .= ' ( ' . $sql_mode . ' )'; } $debug_info['environment']['MySQL version'] = $mysql_version ? $mysql_version : 'N/A'; $sqlite_version = class_exists('SQLite3') ? wpbdp_getv(SQLite3::version(), 'versionString', '') : (function_exists('sqlite_libversion') ? sqlite_libversion() : null); $debug_info['environment']['SQLite version'] = $sqlite_version ? $sqlite_version : 'N/A'; $debug_info['environment']['cURL version'] = function_exists('curl_init') ? wpbdp_getv(curl_version(), 'version') : 'N/A'; $debug_info['environment'] = apply_filters('wpbdp_debug_info_section', $debug_info['environment'], 'environment'); $debug_info = apply_filters('wpbdp_debug_info', $debug_info); if ($plain) { foreach ($debug_info as &$section) { foreach ($section as $k => $v) { if ($k == '_title') { printf('== %s ==', $v); print PHP_EOL; continue; } printf("%-33s = %s", $k, $v); print PHP_EOL; } print str_repeat(PHP_EOL, 2); } return; } echo wpbdp_render_page(WPBDP_PATH . 'admin/templates/debug-info.tpl.php', array('debug_info' => $debug_info)); }
public function upgrade_to_2_1() { global $wpdb; /* This is only to make this routine work for BD 3.0. It's not necessary in other versions. */ $wpdb->query("ALTER TABLE {$wpdb->prefix}wpbdp_form_fields ADD COLUMN validator VARCHAR(255) NULL;"); $wpdb->query("ALTER TABLE {$wpdb->prefix}wpbdp_form_fields ADD COLUMN display_options BLOB NULL;"); $wpdb->query("ALTER TABLE {$wpdb->prefix}wpbdp_form_fields ADD COLUMN is_required TINYINT(1) NOT NULL DEFAULT 0;"); $wpdb->query("ALTER TABLE {$wpdb->prefix}wpbdp_form_fields ADD COLUMN type VARCHAR(255) NOT NULL;"); static $pre_2_1_types = array(null, 'textfield', 'select', 'textarea', 'radio', 'multiselect', 'checkbox'); static $pre_2_1_validators = array('email' => 'EmailValidator', 'url' => 'URLValidator', 'missing' => null, 'numericwhole' => 'IntegerNumberValidator', 'numericdeci' => 'DecimalNumberValidator', 'date' => 'DateValidator'); static $pre_2_1_associations = array('title' => 'title', 'description' => 'content', 'category' => 'category', 'excerpt' => 'excerpt', 'meta' => 'meta', 'tags' => 'tags'); $field_count = $wpdb->get_var(sprintf("SELECT COUNT(*) FROM {$wpdb->prefix}options WHERE option_name LIKE '%%%s%%'", 'wpbusdirman_postform_field_label')); for ($i = 1; $i <= $field_count; $i++) { $label = get_option('wpbusdirman_postform_field_label_' . $i); $type = get_option('wpbusdirman_postform_field_type_' . $i); $validation = get_option('wpbusdirman_postform_field_validation_' . $i); $association = get_option('wpbusdirman_postform_field_association_' . $i); $required = strtolower(get_option('wpbusdirman_postform_field_required_' . $i)); $show_in_excerpt = strtolower(get_option('wpbusdirman_postform_field_showinexcerpt_' . $i)); $hide_field = strtolower(get_option('wpbusdirman_postform_field_hide_' . $i)); $options = get_option('wpbusdirman_postform_field_options_' . $i); $newfield = array(); $newfield['label'] = $label; $newfield['type'] = wpbdp_getv($pre_2_1_types, intval($type), 'textfield'); $newfield['validator'] = wpbdp_getv($pre_2_1_validators, $validation, null); $newfield['association'] = wpbdp_getv($pre_2_1_associations, $association, 'meta'); $newfield['is_required'] = $required == 'yes' ? true : false; $newfield['display_options'] = serialize(array('show_in_excerpt' => $show_in_excerpt == 'yes' ? true : false, 'hide_field' => $hide_field == 'yes' ? true : false)); $newfield['field_data'] = $options ? serialize(array('options' => explode(',', $options))) : null; if ($wpdb->insert($wpdb->prefix . 'wpbdp_form_fields', $newfield)) { delete_option('wpbusdirman_postform_field_label_' . $i); delete_option('wpbusdirman_postform_field_type_' . $i); delete_option('wpbusdirman_postform_field_validation_' . $i); delete_option('wpbusdirman_postform_field_association_' . $i); delete_option('wpbusdirman_postform_field_required_' . $i); delete_option('wpbusdirman_postform_field_showinexcerpt_' . $i); delete_option('wpbusdirman_postform_field_hide_' . $i); delete_option('wpbusdirman_postform_field_options_' . $i); delete_option('wpbusdirman_postform_field_order_' . $i); } } }
function listing_opentags() { $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id')); $listing = WPBDP_Listing::get($listing_id); if (!$listing) { return; } echo '<meta property="og:type" content="website" />'; echo '<meta property="og:title" content="' . esc_attr(WPBDP_SEO::listing_title($listing_id)) . '" />'; echo '<meta property="og:url" content="' . esc_url($listing->get_permalink()) . '" />'; echo '<meta property="og:description" content="' . esc_attr(WPBDP_SEO::listing_og_description($listing_id)) . '" />'; if ($thumbnail_id = $listing->get_thumbnail_id()) { if ($img = wp_get_attachment_image_src($thumbnail_id, 'wpbdp-large')) { echo '<meta property="og:image" content="' . $img[0] . '" />'; } } }
protected function step_listing_fields() { $fields = wpbdp_get_form_fields(array('association' => '-category')); $fields = apply_filters_ref_array('wpbdp_listing_submit_fields', array(&$fields, &$this->state)); $validation_errors = array(); if (isset($_POST['listingfields']) && isset($_POST['step']) && 'listing_fields' == $_POST['step']) { $_POST['listingfields'] = stripslashes_deep($_POST['listingfields']); foreach ($fields as &$f) { $value = $f->convert_input(wpbdp_getv($_POST['listingfields'], $f->get_id(), null)); $this->state->fields[$f->get_id()] = $value; $field_errors = null; $validate_res = apply_filters_ref_array('wpbdp_listing_submit_validate_field', array($f->validate($value, $field_errors), &$field_errors, &$f, $value, &$this->state)); if (!$validate_res) { $validation_errors = array_merge($validation_errors, $field_errors); } } if (!$this->state->editing && !current_user_can('administrator') && wpbdp_get_option('display-terms-and-conditions')) { $tos = trim(wpbdp_get_option('terms-and-conditions')); if ($tos && (!isset($_POST['terms-and-conditions-agreement']) || $_POST['terms-and-conditions-agreement'] != 1)) { $validation_errors[] = _x('Please agree to the Terms and Conditions.', 'templates', 'WPBDM'); } } if (wpbdp_get_option('recaptcha-for-submits')) { if (!wpbdp_recaptcha_check_answer()) { $validation_errors[] = _x("The reCAPTCHA wasn't entered correctly.", 'templates', 'WPBDM'); } } if (!$validation_errors) { $this->state->advance(); return $this->dispatch(); } } $terms_field = ''; if (!$this->state->editing && wpbdp_get_option('display-terms-and-conditions')) { $tos = trim(wpbdp_get_option('terms-and-conditions')); if ($tos) { if (wpbdp_starts_with($tos, 'http://', false) || wpbdp_starts_with($tos, 'https://', false)) { $terms_field .= sprintf('<a href="%s" target="_blank">%s</a>', esc_url($tos), _x('Read our Terms and Conditions', 'templates', 'WPBDM')); } else { $terms_field .= '<div class="wpbdp-form-field-label">'; $terms_field .= '<label>'; $terms_field .= _x('Terms and Conditions:', 'templates', 'WPBDM'); $terms_field .= '</label>'; $terms_field .= '</div>'; $terms_field .= '<div class="wpbdp-form-field-html wpbdp-form-field-inner">'; $terms_field .= sprintf('<textarea readonly="readonly" rows="5" cols="50">%s</textarea>', esc_textarea($tos)); $terms_field .= '</div>'; } $terms_field .= '<label>'; $terms_field .= '<input type="checkbox" name="terms-and-conditions-agreement" value="1" />'; $terms_field .= _x('I agree to the Terms and Conditions', 'templates', 'WPBDM'); $terms_field .= '</label>'; } } $recaptcha = ''; if (wpbdp_get_option('recaptcha-for-submits')) { $recaptcha = wpbdp_recaptcha(); } return $this->render('listing-fields', array('fields' => $fields, 'validation_errors' => $validation_errors, 'recaptcha' => $recaptcha, 'terms_and_conditions' => $terms_field)); }
function handle_actions() { if (!isset($_REQUEST['wpbdmaction']) || !isset($_REQUEST['post'])) { return; } $action = $_REQUEST['wpbdmaction']; $posts = is_array($_REQUEST['post']) ? $_REQUEST['post'] : array($_REQUEST['post']); $listings_api = wpbdp_listings_api(); $upgrades_api = wpbdp_listing_upgrades_api(); if (!current_user_can('administrator')) { exit; } switch ($action) { case 'publish': foreach ($posts as $post_id) { wp_update_post(array('ID' => $post_id, 'post_status' => 'publish')); } $this->messages[] = _nx('The listing has been published.', 'The listings have been published.', count($posts), 'admin', 'WPBDM'); break; case 'setaspaid': foreach ($posts as $post_id) { $listing = WPBDP_Listing::get($post_id); $listing->mark_as_paid(); } $this->messages[] = _nx('The listing status has been set as paid.', 'The listings status has been set as paid.', count($posts), 'admin', 'WPBDM'); break; case 'changesticky': foreach ($posts as $post_id) { $upgrades_api->set_sticky($post_id, wpbdp_getv($_GET, 'u')); } $this->messages[] = _nx('The listing has been modified.', 'The listings have been modified.', count($posts), 'admin', 'WPBDM'); break; case 'upgradefeatured': foreach ($posts as $post_id) { $upgrades_api->set_sticky($post_id, 'sticky', true); } $this->messages[] = _nx('The listing has been upgraded.', 'The listings have been upgraded.', count($posts), 'admin', 'WPBDM'); break; case 'cancelfeatured': foreach ($posts as $post_id) { $upgrades_api->set_sticky($post_id, 'normal'); } $this->messages[] = _nx('The listing has been downgraded.', 'The listings have been downgraded.', count($posts), 'admin', 'WPBDM'); break; case 'approvetransaction': $transaction = WPBDP_Payment::get($_GET['transaction_id']); $transaction->set_status(WPBDP_Payment::STATUS_COMPLETED, 'admin'); $transaction->save(); $this->messages[] = _x('The transaction has been approved.', 'admin', 'WPBDM'); break; case 'rejecttransaction': $transaction = WPBDP_Payment::get($_GET['transaction_id']); $transaction->set_status(WPBDP_Payment::STATUS_REJECTED, 'admin'); $transaction->save(); $this->messages[] = _x('The transaction has been rejected.', 'admin', 'WPBDM'); break; case 'assignfee': $listing = WPBDP_Listing::get($posts[0]); $listing->add_category($_GET['category_id'], $_GET['fee_id']); $this->messages[] = _x('The fee was successfully assigned.', 'admin', 'WPBDM'); break; case 'renewlisting': foreach ($posts as $post_id) { $listings_api->auto_renew($post_id); } $this->messages[] = _nx('Listing was renewed.', 'Listings were renewed.', count($posts), 'admin', 'WPBDM'); break; case 'send-renewal-email': $renewal_id = intval($_GET['renewal_id']); if ($listings_api->send_renewal_email($renewal_id)) { $this->messages[] = _x('Renewal email sent.', 'admin', 'WPBDM'); } break; default: do_action('wpbdp_admin_directory_handle_action', $action); break; } $_SERVER['REQUEST_URI'] = remove_query_arg(array('wpbdmaction', 'wpbdmfilter', 'transaction_id', 'category_id', 'fee_id', 'u', 'renewal_id'), $_SERVER['REQUEST_URI']); }
?> <p><?php _e('Use this option if you want to go back to the original factory settings for BD. <b>Please note that all of your existing settings will be lost.</b>', 'WPBDM'); ?> </p> <form action="" method="POST"> <input type="hidden" name="resetdefaults" value="1" /> <?php echo submit_button(__('Reset Defaults', 'WPBDM')); ?> </form> <?php } else { $group = $wpbdp_settings->groups[wpbdp_getv($_REQUEST, 'groupid', 'general')]; ?> <form action="<?php echo admin_url('options.php'); ?> " method="POST" id="wpbdp-admin-settings"> <input type="hidden" name="groupid" value="<?php echo $group->slug; ?> " /> <?php if ($group->help_text) { ?> <p class="description"><?php echo $group->help_text;
/** * @since 3.5.8 */ public function abandonment_admin_views($views, $post_statuses) { global $wpdb; if (!wpbdp_get_option('payment-abandonment')) { return $views; } $threshold = max(1, absint(wpbdp_get_option('payment-abandonment-threshold'))); $now = current_time('timestamp'); $within_pending = wpbdp_format_time(strtotime(sprintf('-%d hours', $threshold), $now), 'mysql'); $within_abandonment = wpbdp_format_time(strtotime(sprintf('-%d hours', $threshold * 2), $now), 'mysql'); $count_pending = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}wpbdp_payments ps LEFT JOIN {$wpdb->posts} p ON p.ID = ps.listing_id WHERE ps.created_on > %s AND ps.created_on <= %s AND ps.status = %s AND ps.tag = %s AND p.post_status IN ({$post_statuses})", $within_abandonment, $within_pending, 'pending', 'initial')); $count_abandoned = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}wpbdp_payments ps LEFT JOIN {$wpdb->posts} p ON p.ID = ps.listing_id WHERE ps.created_on <= %s AND ps.status = %s AND ps.tag = %s AND p.post_status IN ({$post_statuses})", $within_abandonment, 'pending', 'initial')); $views['pending-abandonment'] = sprintf('<a href="%s" class="%s">%s</a> <span class="count">(%s)</span></a>', esc_url(add_query_arg('wpbdmfilter', 'pending-abandonment')), 'pending-abandonment' == wpbdp_getv($_REQUEST, 'wpbdmfilter') ? 'current' : '', _x('Pending Abandonment', 'admin', 'WPBDM'), number_format_i18n($count_pending)); $views['abandoned'] = sprintf('<a href="%s" class="%s">%s</a> <span class="count">(%s)</span></a>', esc_url(add_query_arg('wpbdmfilter', 'abandoned')), 'abandoned' == wpbdp_getv($_REQUEST, 'wpbdmfilter') ? 'current' : '', _x('Abandoned', 'admin', 'WPBDM'), number_format_i18n($count_abandoned)); return $views; }
public function save_post($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // Handle listings saved admin-side. if (is_admin() && isset($_POST['post_type']) && $_POST['post_type'] == WPBDP_POST_TYPE) { $listing = WPBDP_Listing::get($post_id); if (!$listing) { return; } $listing->fix_categories(true); // Save custom fields. //if ( isset( $_POST['wpbdp-listing-fields-nonce'] ) && wp_verify_nonce( $_POST['wpbdp-listing-fields-nonce'], plugin_basename( __FILE__ ) ) ) if (isset($_POST['wpbdp-listing-fields-nonce'])) { $formfields_api = wpbdp_formfields_api(); $listingfields = wpbdp_getv($_POST, 'listingfields', array()); foreach ($formfields_api->find_fields(array('association' => 'meta')) as $field) { if (isset($listingfields[$field->get_id()])) { $value = $field->convert_input($listingfields[$field->get_id()]); $field->store_value($listing->get_id(), $value); } else { $field->store_value($listing->get_id(), $field->convert_input(null)); } } if (isset($_POST['thumbnail_id'])) { $listing->set_thumbnail_id($_POST['thumbnail_id']); } } } }
public static function _render_field_settings() { $api = wpbdp_formfields_api(); $association = wpbdp_getv($_REQUEST, 'association', false); $field_type = $api->get_field_type(wpbdp_getv($_REQUEST, 'field_type', false)); $field_id = wpbdp_getv($_REQUEST, 'field_id', 0); $response = array('ok' => false, 'html' => ''); if ($field_type && in_array($association, $field_type->get_supported_associations(), true)) { $field = $api->get_field($field_id); $field_settings = ''; $field_settings .= $field_type->render_field_settings($field, $association); ob_start(); do_action_ref_array('wpbdp_form_field_settings', array(&$field, $association)); $field_settings .= ob_get_contents(); ob_end_clean(); $response['ok'] = true; $response['html'] = $field_settings; } echo json_encode($response); exit; }
public function process(&$payment, $action) { if (!$payment->is_pending()) { return; } $a = ''; if (isset($_REQUEST['success']) && 1 == $_REQUEST['success']) { $a = 'success'; } elseif (isset($_REQUEST['postback']) && 1 == $_REQUEST['postback']) { $a = 'postback'; } elseif (isset($_REQUEST['error']) && !empty($_REQUEST['error']) && (!isset($_REQUEST['success']) || 0 == $_REQUEST['success'])) { $a = 'error'; } switch ($a) { case 'success': $jwt = JWT::decode(wpbdp_getv($_REQUEST, 'jwt', ''), wpbdp_get_option('googlewallet-seller-secret')); if (!$this->validate_jwt($jwt, $payment)) { $payment->add_error(_x('Payment was rejected because internal data does not look like a valid Google Wallet transaction.', 'google-wallet', 'WPBDM')); $payment->set_status(WPBDP_Payment::STATUS_REJECTED, WPBDP_Payment::HANDLER_GATEWAY); } else { $payment->set_status(WPBDP_Payment::STATUS_COMPLETED, WPBDP_Payment::HANDLER_GATEWAY); } break; case 'error': $error = $_REQUEST['error']; switch ($error) { case 'MERCHANT_ERROR': case 'POSTBACK_ERROR': case 'INTERNAL_SERVER_ERROR': $payment->add_error(_x('Payment has been rejected because an internal error occurred.', 'google-wallet', 'WPBDM')); $payment->set_status(WPBDP_Payment::STATUS_REJECTED, WPBDP_Payment::HANDLER_GATEWAY); break; case 'PURCHASE_CANCELED': case 'PURCHASE_CANCELLED': $payment->add_error(_x("The transaction has been canceled at user's request.", 'google-wallet', 'WPBDM')); $payment->set_status(WPBDP_Payment::STATUS_CANCELED, WPBDP_Payment::HANDLER_GATEWAY); break; } break; case 'postback': // TODO: implement postback URL support. break; default: break; } $payment->save(); wp_redirect(esc_url_raw($payment->get_redirect_url())); }
?> <?php if ($allow_recurring) { if (wpbdp_get_option('listing-renewal-auto-dontask')) { ?> <input type="hidden" name="autorenew_fees" value="autorenew" /> <?php } else { ?> <div class="make-charges-recurring-option"> <b><?php echo _x('Would you like to make your fee renew automatically at the end of the period?', 'submit', 'WPBDM'); ?> </b> <input type="checkbox" name="autorenew_fees" value="autorenew" <?php echo wpbdp_getv($_POST, 'autorenew_fees') == 'autorenew' ? 'checked="checked"' : ''; ?> /> </div> <?php } } ?> <input type="submit" value="<?php _ex('Continue', 'templates', 'WPBDM'); ?> " /> </form>
public function get($upgrade_id) { return wpbdp_getv($this->_levels, $upgrade_id, null); }
function language_switcher($languages) { global $wpbdp; $action = $wpbdp->controller->get_current_action(); switch ($action) { case 'browsecategory': if (get_query_var('category')) { if ($term = get_term_by('slug', get_query_var('category'), WPBDP_CATEGORY_TAX)) { $category_id = $term->term_id; } else { $category_id = intval(get_query_var('category')); } } $category_id = $category_id ? $category_id : intval(get_query_var('category_id')); $category_id = is_array($category_id) && 1 == count($category_id) ? $category_id[0] : $category_id; if (!$category_id) { return $languages; } foreach ($languages as $l_code => $l) { $trans_id = (int) icl_object_id($category_id, WPBDP_CATEGORY_TAX, false, $languages[$l_code]['language_code']); $link = get_term_link($trans_id, WPBDP_CATEGORY_TAX); if (!$trans_id || is_wp_error($link)) { unset($languages[$l_code]); continue; } $languages[$l_code]['url'] = $this->translate_link($link, $languages[$l_code]['language_code']); } break; case 'showlisting': $id_or_slug = ''; if (get_query_var('listing') || isset($_GET['listing'])) { $id_or_slug = get_query_var('listing') ? get_query_var('listing') : wpbdp_getv($_GET, 'listing', 0); } else { $id_or_slug = get_query_var('id') ? get_query_var('id') : wpbdp_getv($_GET, 'id', 0); } $listing_id = wpbdp_get_post_by_id_or_slug($id_or_slug, 'id', 'id'); if (!$listing_id) { break; } foreach ($languages as $l_code => $l) { $trans_id = icl_object_id($listing_id, WPBDP_POST_TYPE, true, $languages[$l_code]['language_code']); if (!$trans_id) { unset($languages[$l_code]); continue; } $languages[$l_code]['url'] = $this->translate_link(get_permalink($trans_id), $languages[$l_code]['language_code']); } break; default: break; } return $languages; }