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; }
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>'; }
/** * Tries to delete this field from the database. * @return mixed True if successfully deleted, WP_Error in the other case */ public function delete() { if (!$this->id) { return new WP_Error('wpbdp-delete-error', _x('Invalid field ID', 'form-fields-api', 'WPBDM')); } global $wpbdp; $flags = $wpbdp->formfields->get_association_flags($this->association); if (in_array('required', $flags)) { $otherfields = wpbdp_get_form_fields(array('association' => $this->association)); if (!$otherfields || $otherfields[0]->get_id() == $this->id) { return new WP_Error('wpbdp-delete-error', _x("This form field can't be deleted because it is required for the plugin to work.", 'form-fields api', 'WPBDM')); } } global $wpdb; if ($wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}wpbdp_form_fields WHERE id = %d", $this->id)) !== false) { $this->type->cleanup($this); wp_cache_delete($this->id, 'wpbdp formfields'); $this->id = 0; } else { return new WP_Error('wpbdp-delete-error', _x('An error occurred while trying to delete this field.', 'form-fields-api', 'WPBDM')); } $api = wpbdp_formfields_api(); $api->_calculate_short_names(); return true; }
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']); } } } }
<?php $api = wpbdp_formfields_api(); ?> <div id="wpbdp-search-page" class="wpbdp-search-page businessdirectory-search businessdirectory wpbdp-page"> <div class="wpbdp-bar cf"><?php wpbdp_the_main_links(); ?> </div> <h2 class="title"><?php _ex('Search', 'search', 'WPBDM'); ?> </h2> <?php if (!$show_form) { ?> <a href="#" style="font-size: 90%; float: right; margin-right: 20px;" onclick="jQuery('#wpbdp-search-form-wrapper').show(); jQuery(this).remove();"><?php _ex('Return to Advanced Search', 'search', 'WPBDM'); ?> </a> <?php } ?> <!-- Search Form --> <div id="wpbdp-search-form-wrapper" style="<?php echo !$show_form ? 'display: none;' : ''; ?>
private function example_csv() { echo wpbdp_admin_header(_x('Example CSV Import File', 'admin csv-import', 'WPBDM'), null, array(array(_x('← Return to "CSV Import"', 'admin csv-import', 'WPBDM'), esc_url(remove_query_arg('action'))))); $posts = get_posts(array('post_type' => WPBDP_POST_TYPE, 'post_status' => 'publish', 'numberposts' => 10)); //echo sprintf('<input type="button" value="%s" />', _x('Copy CSV', 'admin csv-import', 'WPBDM')); echo '<textarea class="wpbdp-csv-import-example" rows="30">'; $fields_api = wpbdp_formfields_api(); $short_names = $fields_api->get_short_names(); foreach ($short_names as $name) { echo $name . ','; } echo 'username'; echo "\n"; if (count($posts) >= 5) { foreach ($posts as $post) { foreach (array_keys($short_names) as $field_id) { $field = $fields_api->get_field($field_id); $value = $field->plain_value($post->ID); echo str_replace(',', ';', $value); echo ','; } echo get_the_author_meta('user_login', $post->post_author); echo "\n"; } } else { for ($i = 0; $i < 5; $i++) { foreach ($short_names as $field_id => $shortname) { $field = $fields_api->get_field($field_id); echo sprintf('"%s"', $this->example_data_for_field($field, $shortname)); echo ','; } echo sprintf('"%s"', $this->example_data_for_field(null, 'user')); echo "\n"; } } echo '</textarea>'; echo wpbdp_admin_footer(); }
function wpbusdirman_display_the_listing_fields() { global $post; $html = ''; foreach (wpbdp_formfields_api()->get_fields() as $field) { if (!$field->display_in('excerpt')) { continue; } $html .= $field->display($post->ID, 'excerpt'); } return $html; }
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; }
function wpbdp_get_formfield($id) { if (is_numeric($id) && is_string($id)) { return wpbdp_get_formfield(intval($id)); } if (is_string($id)) { return wpbdp_formfields_api()->getFieldsByAssociation($id, true); } return wpbdp_formfields_api()->get_field($id); }
public static function &from_state($state) { $export = new self($state['settings'], trailingslashit($state['workingdir']), (array) $state['listings']); $export->exported = abs(intval($state['exported'])); // Setup columns. $shortnames = wpbdp_formfields_api()->get_short_names(); foreach ($state['columns'] as $fshortname) { if (in_array($fshortname, array('images', 'username', 'featured_level', 'expires_on', 'sequence_id'))) { $export->columns[$fshortname] = $fshortname; continue; } $field_id = array_search($fshortname, $shortnames); if ($field_id === FALSE) { throw new Exception('Invalid field shortname.'); } $export->columns[$fshortname] = wpbdp_get_form_field($field_id); } return $export; }