Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: WP Store Locator shortcodes
- Plugin URI: http://www.damiencarbery.com
- Description: Shortcodes for use with WP Store Locator plugin.
- Author: Damien Carbery
- Version: 0.1
- $Id: $
- */
- add_shortcode('wpsl_list', 'wpsl_shortcodes');
- function wpsl_shortcodes($atts, $content, $code) {
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
- if (is_plugin_active( 'wp-store-locator.php' )) {
- return 'WPSL Plugin Not Active'; // Or return nothing.
- }
- global $wpdb;
- $wpdb->wpsl_stores = $wpdb->prefix . 'wpsl_stores';
- $all_stores = $wpdb->get_results( "SELECT * FROM $wpdb->wpsl_stores WHERE `active` ='1' ORDER BY `country`,`store` ASC", ARRAY_A );
- $stores_list = '<table><tr><td>Store Name</td><td>address</td><td>URL</td></tr>';
- foreach ($all_stores as $store_info) {
- $stores_list .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>%s', $store_info['store'], $store_info['address'], $store_info['url'], "\n");
- }
- $stores_list .= '</table>';
- return $stores_list;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement