WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 31 2011

How to Make a Private eCommerce Store Using Shopp

So one person asked if I could make Shopp available for users who have a registered customer login that they control. So the first thing you have to do is setup Shopp on the backend by allowing Customer Accounts via Shopp > Settings > Checkout. I always select Enable Account Logins integrated with WordPress Accounts just in case the person wants to move towards some sort of Client Portal as well.

Then in Shopp > Settings > Presentation, I used Enable theme templates, which enables me to edit some files without having to worry about hacking core (never hack core!) to customize the way I want it. So then I open my catalog.php template file. As you can see the catalog.php template consists of only one line.

[php]<?php shopp('catalog','catalog-products'); ?>[/php]

Then I open login.php template file, which contains the login information I need for a private ecommerce store for my customers, or my invite-only elite customers. I copy the entire file and paste it with my catalog.php. Then I add one line ahead of the login.php file:
[php]if( ! shopp('customer','loggedin')) {
//login.php login form code
}
else
shopp('catalog','catalog-products');
[/php]

Don't forget that you may also want to hide/unregister your sidebars, or if you are using a genesis theme you can force a content only layout.

So now my store page which calls the shortcode [ catalog ] will now refer to my edited template forcing customers to login before they can see anything. Since I have my customers connected to WordPress accounts, I could also refer customers to the WordPress login screen. Since my store was a bit more complicated as I used a secondary menu system (full of custom links referring to Shopp Categories), connecting customers to WordPress accounts made making the menu system workable. For the front page, I created a fake WordPress custom menu and upon login, the menu system was replaced with a live custom menu, which I talk about here.

Written by Travis Smith · Categorized: Plugins, Tutorials

Mar 22 2011

Add a Genesis Authorbox Anywhere Using My Genesis Authorbox Shortcode

As I am slowly developing a new plugin, Genesis Simple Authorbox, I realized that I should just release parts to the community that I believe would be beneficial. Follow these simple steps to incorporate the Authorbox Shortcode.

  1. Download the Genesis Simple Authorbox Shortcode: [download id="6"]
  2. Upload it to your Child Theme folder
  3. Add the following PHP Code to your functions.php file:
    [php]require_once( CHILD_DIR.'/genesis-author-box-shortcode.php' );[/php]

Now you can use [genauthorbox] to produce the Genesis Authorbox anywhere you'd like. This is also perfect for Genesis Child Theme developers using do_shortcode().

Attributes

[genauthorbox] takes a few attributes. They are:

  • before: Text/markup to place before the authorbox; default: <div class="author-box">
  • after: Text/markup to place after the authorbox; default: </div>
  • context: Context of the authorbox; default: '' NOTE: don't use this unless you are comfortable with it
  • title: Title of the authorbox; default: "About First Last Name" (e.g., get_the_author())
  • description: The author description/Biographical Info from Your Profile; default: (empty)
  • gclass: Adds a class to the gravatar img; default: alignleft
  • galt: Adds ability to provide an Alt Tag to the gravatar img; default: (empty)
  • gsize: Adds ability to resize gravatar image; default: 70
  • gemail: Fetch gravatar image by email (only changes the avatar & does not change the author information [e.g., title, description]); default: get_the_author_meta('email')
  • userid: Overrides gemail, title, & description with the default user's (title: About First Last; description: biographical info; gemail: user's email); default: (empty)

Example

[genauthorbox title="About Mr. Starbucks" Description="I am a hopeless Starbucks addict, freelance web designer..." gsize=72 galt="not me" gemail="[email protected]"]

Written by Travis Smith · Categorized: Genesis, Plugins

Mar 20 2011

How to Add More Icons to the Genesis Social Profiles Widget

Nathan Rice wrote a simple but excellent plugin called the Social Profiles Widget. I love the simplicity and only wanted to add one feature, the ability to quickly add my own icons by dumping a folder with the other social profiles folders. So this required changing the code. Because I have not received permission from Nathan Rice to update and contribute to his plugin, I'll share it here. Download: [download id="4"]

[php]<?php
/*
Plugin Name: Social Profiles Widget
Plugin URI: http://www.studiopress.com/plugins/social-profiles-widget
Description: This plugin/widget allows you to insert social profile icons into your sidebar via a widget.
Version: 1.1.1
Author: Nathan Rice
Author URI: http://www.nathanrice.net/

This plugin is released under the GPLv2 license. The images packaged with this plugin are the property of
their respective owners, and do not, necessarily, inherit the GPLv2 license.
*/
/*
Slightly modified by Travis Smith, https://wpsmith.net, to allow for additional icon folders to be uploaded. Simply upload custom folder to the images folder. Be sure to name your icons [SOCIAL]_32x32.* and [SOCIAL]_48x48.* [SOCIAL]=Delicious, Digg, Facebook, Feed, Flickr, Linkedin, Myspace, Stumbleupon, Twitter (e.g., Twitter_32x32.png)
*/
/**
* Register the Widget
*/
add_action('widgets_init', 'social_profiles_widget_register');
function social_profiles_widget_register() {
register_widget('Social_Profiles_Widget');
}

/**
* The Widget Class
*/
if ( !class_exists('Social_Profiles_Widget') ) {
class Social_Profiles_Widget extends WP_Widget {

function Social_Profiles_Widget() {
$widget_ops = array( 'classname' => 'social-profiles', 'description' => __('Displays Social Profile links as icons', 'spw') );
$this->WP_Widget( 'socialprofiles', __('Social Profiles', 'spw'), $widget_ops );
}

var $plugin_imgs_url;

function spw_fields_array( $instance = array() ) {

$this->plugins_imgs_url = plugin_dir_url(__FILE__) . 'images/';

return array(
'feedburner' => array(
'title' => __('RSS/Feedburner URL', 'spw'),
'img' => sprintf( '%s/Feed_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Feed_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('RSS', 'spw')
),
'twitter' => array(
'title' => __('Twitter URL', 'spw'),
'img' => sprintf( '%s/Twitter_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Twitter_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Twitter', 'spw')
),
'facebook' => array(
'title' => __('Facebook URL', 'spw'),
'img' => sprintf( '%s/Facebook_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Facebook_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Facebook', 'spw')
),
'linkedin' => array(
'title' => __('Linkedin URL', 'spw'),
'img' => sprintf( '%s/Linkedin_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Linkedin_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Linkedin', 'spw')
),
'youtube' => array(
'title' => __('YouTube URL', 'spw'),
'img' => sprintf( '%s/Youtube_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Youtube_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Youtube', 'spw')
),
'flickr' => array(
'title' => __('Flickr URL', 'spw'),
'img' => sprintf( '%s/Flickr_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Flickr_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Flickr', 'spw')
),
'delicious' => array(
'title' => __('Delicious URL', 'spw'),
'img' => sprintf( '%s/Delicious_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Delicious_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Delicious', 'spw')
),
'stumbleupon' => array(
'title' => __('StumbleUpon URL', 'spw'),
'img' => sprintf( '%s/Stumbleupon_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Stumbleupon_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('StumbleUpon', 'spw')
),
'digg' => array(
'title' => __('Digg URL', 'spw'),
'img' => sprintf( '%s/Digg_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Digg_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('Digg', 'spw')
),
'myspace' => array(
'title' => __('MySpace URL', 'spw'),
'img' => sprintf( '%s/Myspace_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), esc_attr( $instance['size'] ) ),
'img_widget' => sprintf( '%s/Myspace_%s.png', $this->plugins_imgs_url . esc_attr( $instance['icon_set'] ), '48x48' ),
'img_title' => __('MySpace', 'spw')
),
);
}

function widget($args, $instance) {

extract($args);

$instance = wp_parse_args($instance, array(
'title' => '',
'icon_set' => 'default',
'size' => '48x48'
) );

echo $before_widget;

if ( !empty( $instance['title'] ) )
echo $before_title . $instance['title'] . $after_title;

foreach ( $this->spw_fields_array( $instance ) as $key => $data ) {
if ( !empty ( $instance[$key] ) ) {
printf( '<a href="%s"><img src="%s" alt="%s" /></a>', esc_url( $instance[$key] ), esc_url( $data['img'] ), esc_attr( $data['img_title'] ) );
}
}

echo $after_widget;

}

function update($new_instance, $old_instance) {
return $new_instance;
}

function dir_list($d){
foreach(array_diff(scandir($d),array('.','..')) as $f) {
if(is_dir($d.'/'.$f)) {
$l[]=$f;
}
}
return $l;
}

function form($instance) {
$dir = WP_PLUGIN_DIR.'/social-profiles-widget/images';
$imagefolders = $this->dir_list($dir);
$instance = wp_parse_args($instance, array(
'title' => '',
'icon_set' => 'default',
'size' => '48x48'
) );
?>

<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'spw'); ?>:</label><br />
<input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:95%;" />
</p>

<p>
<label for="<?php echo $this->get_field_id('icon_set'); ?>"><?php _e('Icon Set', 'spw'); ?>:</label>
<select id="<?php echo $this->get_field_id('icon_set'); ?>" name="<?php echo $this->get_field_name('icon_set'); ?>">
<?php
foreach ($imagefolders as $key => $folder) :
?>
<option style="padding-right:10px;" value="<?php echo $folder; ?>" <?php selected($folder, $instance['icon_set']); ?>><?php _e($folder, 'spw'); ?></option>
<?php endforeach; ?>
</select>
</p>

<p>
<label for="<?php echo $this->get_field_id('size'); ?>"><?php _e('Icon Size', 'spw'); ?>:</label>
<select id="<?php echo $this->get_field_id('size'); ?>" name="<?php echo $this->get_field_name('size'); ?>">
<option style="padding-right:10px;" value="32x32" <?php selected('32x32', $instance['size']); ?>><?php _e('Small', 'spw'); ?> (32px)</option>
<option style="padding-right:10px;" value="48x48" <?php selected('48x48', $instance['size']); ?>><?php _e('Large', 'spw'); ?> (48px)</option>
</select>
</p>

<p><?php _e('Enter the URL(s) for your various social profiles below. If you leave a profile URL field blank, it will not be used.', 'spw'); ?></p>

<?php

foreach ( $this->spw_fields_array( $instance ) as $key => $data ) {
echo '<p>';
printf( '<img style="float: left; margin-right: 3px;" src="%s" title="%s" />', $data['img_widget'], $data['img_title'] );
printf( '<label for="%s"> %s:</label>', esc_attr( $this->get_field_id($key) ), esc_attr( $data['title'] ) );
printf( '<input id="%s" name="%s" value="%s" style="%s" />', esc_attr( $this->get_field_id($key) ), esc_attr( $this->get_field_name($key) ), esc_url( $instance[$key] ), 'width:65%;' );
echo '</p>' . "n";
}

}
}}[/php]

Written by Travis Smith · Categorized: Genesis, Plugins

Feb 23 2011

Creating Multiple Custom Menus in WordPress 3.1

Ever since WordPress Custom Menus were created and launched, I have been overly excited about it's potential. I have finally had some time where I could attempt to do something fun with them. However, it wasn't until the release of WordPress 3.1 that had the functionality that I was looking for. So I have developed a plugin that will allow you to filter out the custom menu instead of simply hiding portions of the menu through CSS {display:none;}.

This plugin can only be used in WordPress 3.0.5 if one change is made to a core WordPress file. However, I never advise making any changes or hacking to WordPress core on production environments. So if you make this change in production, do so at your own risk. That being said, in wp-includes folder, open the file nav-menu-template.php and add this line at line 199.

[php]$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );[/php]

This line of code is already in WordPress 3.1 at line 201 hence why I don't mind sharing this. This line of code needs to appear after:

[php] // Set up the $menu_item variables
_wp_menu_item_classes_by_context( $menu_items );

$sorted_menu_items = array();
foreach ( (array) $menu_items as $key => $menu_item )
$sorted_menu_items[$menu_item->menu_order] = $menu_item;

unset($menu_items);[/php]

And before:

[php] $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
unset($sorted_menu_items);[/php]

Now you can access that filter via add_filter(); So,

[php]function wps_custom_nav_menu_items($args){
//do something
}
add_filter( 'wp_nav_menu_objects', 'wps_custom_nav_menu_items',10,3);[/php]

Written by Travis Smith · Categorized: Plugins, Tutorials

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in