Ejemplo n.º 1
1
 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;
 }
 function main_page_breadcrumb($trail)
 {
     $last = $trail->trail[count($trail->trail) - 1];
     if (in_array('home', $last->type, true)) {
         array_pop($trail->trail);
     }
     $trail->add(new bcn_breadcrumb(get_the_title(wpbdp_get_page_id()), '', array(), wpbdp_get_page_link(), wpbdp_get_page_id()));
 }
Ejemplo n.º 3
0
 public function check_main_page(&$msg)
 {
     $msg = '';
     $wpbdp = wpbdp();
     if (!wpbdp_get_page_id('main')) {
         if (current_user_can('administrator') || current_user_can('activate_plugins')) {
             $msg = __('You need to create a page with the [businessdirectory] shortcode for the Business Directory plugin to work correctly.', 'WPBDM');
         } else {
             $msg = __('The directory is temporarily disabled.', 'WPBDM');
         }
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
function wpbdp_search_form()
{
    $html = '';
    $html .= sprintf('<form id="wpbdmsearchform" action="" method="GET" class="wpbdp-search-form">
                      <input type="hidden" name="action" value="search" />
                      <input type="hidden" name="page_id" value="%d" />
                      <input type="hidden" name="dosrch" value="1" />', wpbdp_get_page_id('main'));
    $html .= '<input id="intextbox" maxlength="150" name="q" size="20" type="text" value="" />';
    $html .= sprintf('<input id="wpbdmsearchsubmit" class="submit" type="submit" value="%s" />', _x('Search Listings', 'templates', 'WPBDM'));
    $html .= sprintf('<a href="%s" class="advanced-search-link">%s</a>', esc_url(add_query_arg('action', 'search', wpbdp_get_page_link('main'))), _x('Advanced Search', 'templates', 'WPBDM'));
    $html .= '</form>';
    return $html;
}
Ejemplo n.º 5
0
<!-- Search Form -->
<div id="wpbdp-search-form-wrapper" style="<?php 
echo !$show_form ? 'display: none;' : '';
?>
">
<h3><?php 
_ex('Find a listing', 'templates', 'WPBDM');
?>
</h3>
<form action="<?php 
echo esc_url(wpbdp_get_page_link('main'));
?>
" id="wpbdp-search-form" method="GET">
    <input type="hidden" name="action" value="search" />
    <input type="hidden" name="page_id" value="<?php 
echo wpbdp_get_page_id('main');
?>
" />
    <input type="hidden" name="dosrch" value="1" />
    <input type="hidden" name="q" value="" />

    <?php 
echo $fields;
?>
    <?php 
do_action('wpbdp_after_search_fields');
?>

    <p>
        <input type="reset" class="reset" value="<?php 
_ex('Clear', 'search', 'WPBDM');
 public function _comments_template($template)
 {
     // disable comments in WPBDP pages or if comments are disabled for listings
     if (is_single() && get_post_type() == WPBDP_POST_TYPE && !$this->settings->get('show-comment-form') || get_post_type() == 'page' && get_the_ID() == wpbdp_get_page_id('main')) {
         return WPBDP_TEMPLATES_PATH . '/empty-template.php';
     }
     return $template;
 }
Ejemplo n.º 7
0
function wpbusdirman_menu_button_editlisting()
{
    global $post;
    $wpbusdirman_permalink = get_permalink(wpbdp_get_page_id('main'));
    $html = '';
    if (is_user_logged_in()) {
        global $current_user;
        get_currentuserinfo();
        $wpbusdirmanloggedinuseremail = $current_user->user_email;
        $wpbusdirmanauthoremail = get_the_author_meta('user_email');
        if ($wpbusdirmanloggedinuseremail == $wpbusdirmanauthoremail || current_user_can('administrator') || wp_get_current_user()->ID == get_the_author_meta('ID')) {
            $html .= '<form method="post" action="' . $wpbusdirman_permalink . '"><input type="hidden" name="action" value="editlisting" /><input type="hidden" name="listing_id" value="' . $post->ID . '" /><input type="submit" class="editlistingbutton" value="' . __("Edit Listing", "WPBDM") . '" /></form>';
        }
    }
    return $html;
}
Ejemplo n.º 8
0
function wpbdp_get_page_link($name = 'main', $arg0 = null)
{
    $page_id = wpbdp_get_page_id($name);
    if ($page_id) {
        $link = _get_page_link($page_id);
    } else {
        switch ($name) {
            case 'view':
            case 'viewlisting':
            case 'show-listing':
            case 'showlisting':
                $link = get_permalink(intval($arg0));
                break;
            case 'edit':
            case 'editlisting':
            case 'edit-listing':
            case 'delete':
            case 'deletelisting':
            case 'delete-listing':
            case 'upgrade':
            case 'upgradetostickylisting':
            case 'upgradelisting':
            case 'upgrade-listing':
                $link = add_query_arg(array('action' => $name, 'listing_id' => intval($arg0)), wpbdp_get_page_link('main'));
                break;
            case 'viewlistings':
            case 'view-listings':
                $link = add_query_arg(array('action' => 'viewlistings'), wpbdp_get_page_link('main'));
                break;
            case 'add':
            case 'addlisting':
            case 'add-listing':
            case 'submit':
            case 'submitlisting':
            case 'submit-listing':
                $link = add_query_arg(array('action' => 'submitlisting'), wpbdp_get_page_link('main'));
                break;
            case 'search':
                $link = add_query_arg(array('action' => 'search'), wpbdp_get_page_link('main'));
                break;
            default:
                if (!wpbdp_get_page_id('main')) {
                    return '';
                }
                $link = wpbdp_get_page_link('main');
                break;
        }
    }
    return apply_filters('wpbdp_get_page_link', $link, $name, $arg0);
}
Ejemplo n.º 9
0
 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));
 }
Ejemplo n.º 10
0
 public function check_for_required_pages()
 {
     if (!wpbdp_get_page_id('main') && current_user_can('administrator')) {
         $message = _x('<b>Business Directory Plugin</b> requires a page with the <tt>[businessdirectory]</tt> shortcode to function properly.', 'admin', 'WPBDM');
         $message .= '<br />';
         $message .= _x('You can create this page by yourself or let Business Directory do this for you automatically.', 'admin', 'WPBDM');
         $message .= '<p>';
         $message .= sprintf('<a href="#" class="button wpbdp-create-main-page-button" data-nonce="%s">%s</a>', wp_create_nonce('create main page'), _x('Create required pages for me', 'admin', 'WPBDM'));
         $message .= '</p>';
         $this->messages[] = array($message, 'error');
     }
 }
Ejemplo n.º 11
0
 function translate_link($link, $lang = null)
 {
     $lang = $lang ? $lang : $this->get_current_language();
     if (!$lang) {
         return $link;
     }
     if (wpbdp_rewrite_on()) {
         $main_id = wpbdp_get_page_id('main');
         $trans_id = icl_object_id($main_id, 'page', false, $lang);
         if (!$trans_id) {
             return $link;
         }
         $link = str_replace(_get_page_link($main_id), _get_page_link($trans_id), $link);
         $link = add_query_arg('lang', $lang, $link);
     } else {
         $link = add_query_arg('lang', $lang, $link);
     }
     return $link;
 }