示例#1
0
 /**
  * Returns a list of known built-in smart categories
  *
  * Operates on the list of already loaded categories in the $this->category property
  *
  * @author Jonathan Davis
  * @since 1.0
  * @version 1.1
  *
  * @param string $method Add smart categories 'before' the list of the loaded categores or 'after' (defaults after)
  * @return void
  **/
 public function collections($method = 'after')
 {
     $Shopp = Shopp::object();
     $collections = $Shopp->Collections;
     if ('before' == $method) {
         krsort($collections);
     } else {
         ksort($collections);
     }
     foreach ($collections as $Collection) {
         $auto = get_class_property($Collection, '_menu');
         if (!$auto) {
             continue;
         }
         $category = new $Collection(array('noload' => true));
         switch ($method) {
             case 'before':
                 array_unshift($this->categories, $category);
                 break;
             default:
                 array_push($this->categories, $category);
         }
     }
 }
示例#2
0
 /**
  * Overrides the URL properties for Shopp storefront pages and collections added to the WordPress Menu system
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @param array $items Menu items from WordPress
  * @return array Shopp-enabled menu items
  **/
 public function menulinks(array $items)
 {
     foreach ($items as &$item) {
         switch (strtolower($item->type)) {
             case ShoppPages::QUERYVAR:
                 $item->url = Shopp::url(false, $item->object);
                 break;
             case SmartCollection::$taxon:
                 $namespace = get_class_property('SmartCollection', 'namespace');
                 $taxonomy = get_class_property('SmartCollection', 'taxon');
                 $prettyurls = '' != get_option('permalink_structure');
                 $item->url = Shopp::url($prettyurls ? "{$namespace}/{$item->object}" : array($taxonomy => $item->object), false);
                 break;
         }
     }
     return $items;
 }
示例#3
0
文件: API.php 项目: forthrobot/inuvik
 public function register()
 {
     // Hook _context
     $api = $this->classname;
     $apicontext = call_user_func(array($api, '_apicontext'));
     $setobject_call = method_exists($api, '_setobject') ? array($api, '_setobject') : array($this, 'setobject');
     add_filter('shopp_themeapi_object', $setobject_call, 10, 3);
     // Define a static $map property as an associative array or tag => member function names.
     // Without the tag key, it will be registered as a general purpose filter for all tags in this context
     $register = get_class_property($api, 'register');
     if (!empty($register)) {
         foreach ($register as $tag => $method) {
             $apiclass = $api;
             if (is_array($method)) {
                 $apiclass = $method[0];
                 $method = $method[1];
             } elseif (is_string($method) && strpos($method, '::') !== false) {
                 list($apiclass, $method) = explode('::', $method);
             }
             if (is_callable(array($apiclass, $method))) {
                 if (is_numeric($tag)) {
                     add_filter('shopp_themeapi_' . strtolower($apicontext), array($apiclass, $method), 9, 4);
                 } else {
                     add_filter('shopp_themeapi_' . strtolower($apicontext . '_' . $tag), array($apiclass, $method), 9, 3);
                 }
             }
         }
         return;
     }
     // Otherwise, the register function will assume that all method names (excluding _ prefixed methods) correspond to tag you want.
     // _ prefix members can be used as helper functions
     $methods = array_filter(get_class_methods($api), create_function('$m', 'return ( "_" != $m{0} );'));
     foreach ($methods as $tag) {
         add_filter('shopp_themeapi_' . strtolower($apicontext . '_' . $tag), array($api, $tag), 9, 3);
     }
 }
示例#4
0
 /**
  * Removes this entry from the parent OrderTotals controller
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return void
  **/
 public function remove()
 {
     if (!$this->parent) {
         return;
     }
     $register = get_class_property(get_class($this), 'register');
     $OrderTotals = $this->parent;
     $OrderTotals->takeoff($register, $this->id);
 }
示例#5
0
文件: DB.php 项目: crunnells/shopp
 public static function register($class, $slug)
 {
     $posttype = get_class_property($class, 'posttype');
     register_post_type($posttype, array('labels' => call_user_func(array($class, 'labels')), 'capabilities' => call_user_func(array($class, 'capabilities')), 'supports' => call_user_func(array($class, 'supports')), 'rewrite' => array('slug' => $slug, 'with_front' => false), 'public' => true, 'has_archive' => true, 'show_ui' => false, '_edit_link' => 'admin.php?page=shopp-products&id=%d'));
 }
示例#6
0
 public function slug()
 {
     $classname = get_class($this);
     $slug = apply_filters('shopp_' . get_class_property($classname, 'name') . '_storefront_page_slug', $this->slug);
     return apply_filters('shopp_storefront_page_slug', $slug);
 }
示例#7
0
 public static function slugs($class)
 {
     return apply_filters('shopp_' . strtolower($class) . '_collection_slugs', get_class_property($class, 'slugs'));
 }
示例#8
0
	/**
	 * Handles rendering the [category] shortcode
	 *	 
	 * @since 1.1
	 *
	 * @param array $attrs The parsed shortcode attributes
	 * @return string The processed content
	 **/
	function category_shortcode ($atts) {
		global $Ecart;

		$tag = 'category';
		if (isset($atts['name'])) {
			$Ecart->Category = new Category($atts['name'],'name');
			unset($atts['name']);
		} elseif (isset($atts['slug'])) {
			foreach ($Ecart->SmartCategories as $SmartCategory) {
				$SmartCategory_slug = get_class_property($SmartCategory,'_slug');
				if ($atts['slug'] == $SmartCategory_slug) {
					$tag = "$SmartCategory_slug-products";
					if ($tag == "search-results-products") $tag = "search-products";
					unset($atts['slug']);
				}
			}
		} elseif (isset($atts['id'])) {
			$Ecart->Category = new Category($atts['id']);
			unset($atts['id']);
		} else return "";

		return apply_filters('ecart_category_shortcode',$Ecart->Catalog->tag($tag,$atts).'');

	}
示例#9
0
	/**
	 * Load a any category from the catalog including smart categories
	 * 
	 * @since 1.0
	 * @version 1.1
	 *
	 * @param string|int $category The identifying element of a category (by id/slug or uri)
	 * @param array $options (optional) Any ecart() tag-compatible options to pass on to smart categories
	 * @return object The loaded Category object
	 **/
	function load_category ($category,$options=array()) {
		global $Ecart;
		foreach ($Ecart->SmartCategories as $SmartCategory) {
			$SmartCategory_slug = get_class_property($SmartCategory,'_slug');
			if ($category == $SmartCategory_slug)
				return new $SmartCategory($options);
		}

		$key = "id";
		if (!preg_match("/^\d+$/",$category)) $key = "uri";
		return new Category($category,$key);

	}
示例#10
0
 /**
  * Start the element output.
  *
  * @see Walker::start_el()
  *
  * @since 2.1.0
  *
  * @param string $output   Passed by reference. Used to append additional content.
  * @param object $category Category data object.
  * @param int    $depth    Depth of category in reference to parents. Default 0.
  * @param array  $args     An array of arguments. @see wp_list_categories()
  * @param int    $id       ID of the current category.
  */
 public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     extract($args);
     $smartcollection = $category->taxonomy == get_class_property('SmartCollection', 'taxon');
     $categoryname = $category->name;
     $href = get_term_link($category);
     $classes = '';
     if ('list' == $args['style']) {
         $classes = 'cat-item cat-item-' . $category->term_id;
         $Collection = ShoppCollection();
         if (isset($Collection->slug) && $Collection->slug == $category->slug) {
             $classes .= ' current-cat current';
         }
         if (!empty($Collection->parent) && $Collection->parent == $category->term_id) {
             $classes .= ' current-cat-parent current-parent';
         }
     }
     $total = isset($category->count) ? $category->count : false;
     $title = Shopp::__('View all "%s" products', $categoryname);
     $filtered = apply_filters('shopp_storefront_categorylist_link', compact('href', 'classes', 'categoryname', 'title', 'total'));
     extract($filtered, EXTR_OVERWRITE);
     $link = '<a href="' . esc_url($href) . '" title="' . esc_attr($title) . '" class="' . $classes . '">';
     $link .= $categoryname . '</a>';
     if (empty($total) && !Shopp::str_true($linkall) && !$smartcollection) {
         $link = $categoryname;
     }
     if (false !== $total && Shopp::str_true($products)) {
         $link .= ' (' . intval($total) . ')';
     }
     $link = apply_filters('shopp_storefront_categorylist_item', $link, compact('href', 'classes', 'categoryname', 'title', 'total', 'products', 'linkall', 'smartcollection'));
     if ('list' == $args['style']) {
         $output .= "\t<li";
         if (!empty($classes)) {
             $output .= ' class="' . $classes . '"';
         }
         $output .= ">{$link}\n";
     } else {
         $output .= "\t{$link}<br />\n";
     }
 }
示例#11
0
文件: Admin.php 项目: borkweb/shopp
    /**
     * Registers the Shopp Collections meta box in the WordPress theme menus screen
     *
     * @author Jonathan Davis
     * @since 1.2
     *
     * @return void
     **/
    public static function shopp_collections_meta_box()
    {
        global $_nav_menu_placeholder, $nav_menu_selected_id;
        $Shopp = Shopp::object();
        $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
        ?>
		<br />
		<div class="shopp-collections-menu-item customlinkdiv" id="shopp-collections-menu-item">
			<div id="tabs-panel-shopp-collections" class="tabs-panel tabs-panel-active">

				<ul class="categorychecklist form-no-clear">

				<?php 
        $collections = $Shopp->Collections;
        foreach ($collections as $slug => $CollectionClass) {
            $menu = get_class_property($CollectionClass, '_menu');
            if (!$menu) {
                continue;
            }
            $Collection = new $CollectionClass();
            $Collection->smart();
            $_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
            ?>
					<li>
						<label class="menu-item-title">
						<input type="checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-shopp-collection]" value="<?php 
            echo $slug;
            ?>
" class="menu-item-checkbox" /> <?php 
            echo esc_html($Collection->name);
            ?>
</label>
						<input type="hidden" class="menu-item-db-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-db-id]" value="0" />
						<input type="hidden" class="menu-item-object-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $slug;
            ?>
" />
						<input type="hidden" class="menu-item-object" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object]" value="<?php 
            echo $slug;
            ?>
" />
						<input type="hidden" class="menu-item-parent-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-parent-id]" value="0">
						<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="<?php 
            echo SmartCollection::$taxon;
            ?>
" />
						<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo $Collection->name;
            ?>
" />

					</li>
				<?php 
        }
        ?>
				<?php 
        // Promo Collections
        $select = sDB::select(array('table' => ShoppDatabaseObject::tablename(ShoppPromo::$table), 'columns' => 'SQL_CALC_FOUND_ROWS id,name', 'where' => array("target='Catalog'", "status='enabled'"), 'orderby' => 'created DESC'));
        $Promotions = sDB::query($select, 'array');
        foreach ($Promotions as $promo) {
            $slug = sanitize_title_with_dashes($promo->name);
            ?>
					<li>
						<label class="menu-item-title">
						<input type="checkbox" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-shopp-collection]" value="<?php 
            echo $slug;
            ?>
" class="menu-item-checkbox" /> <?php 
            echo esc_html($promo->name);
            ?>
</label>
						<input type="hidden" class="menu-item-db-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-db-id]" value="0" />
						<input type="hidden" class="menu-item-object-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object-id]" value="<?php 
            echo $slug;
            ?>
" />
						<input type="hidden" class="menu-item-object" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-object]" value="<?php 
            echo $slug;
            ?>
" />
						<input type="hidden" class="menu-item-parent-id" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-parent-id]" value="0">
						<input type="hidden" class="menu-item-type" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-type]" value="<?php 
            echo SmartCollection::$taxon;
            ?>
" />
						<input type="hidden" class="menu-item-title" name="menu-item[<?php 
            echo $_nav_menu_placeholder;
            ?>
][menu-item-title]" value="<?php 
            echo $promo->name;
            ?>
" />

					</li>
				<?php 
        }
        ?>
				</ul>

			</div>

			<p class="button-controls">
				<span class="list-controls">
					<a href="<?php 
        echo esc_url(add_query_arg(array('shopp-pages-menu-item' => 'all', 'selectall' => 1), remove_query_arg($removed_args)));
        ?>
#shopp-collections-menu-item" class="select-all"><?php 
        _e('Select All');
        ?>
</a>
				</span>

				<span class="add-to-menu">
					<span class="spinner"></span>
					<input type="submit"<?php 
        disabled($nav_menu_selected_id, 0);
        ?>
 class="button-secondary submit-add-to-menu" value="<?php 
        esc_attr_e('Add to Menu');
        ?>
" name="add-shopp-menu-item" id="submit-shopp-collections-menu-item" />
				</span>
			</p>

		</div><!-- /.customlinkdiv -->
		<?php 
    }
示例#12
0
?>
,
	uidir = '<?php 
echo SHOPP_ADMIN_URI;
?>
',
	siteurl = '<?php 
bloginfo('url');
?>
',
	adminurl = '<?php 
echo admin_url();
?>
',
	canonurl = '<?php 
echo trailingslashit(Shopp::url('' != get_option('permalink_structure') ? get_class_property('ProductCategory', 'namespace') : $Category->taxonomy . '='));
?>
',
	ajaxurl = adminurl+'admin-ajax.php',
	addcategory_url = '<?php 
echo wp_nonce_url(admin_url() . "admin-ajax.php", "shopp-ajax_add_category");
?>
',
	editslug_url = '<?php 
echo wp_nonce_url(admin_url() . "admin-ajax.php", "wp_ajax_shopp_edit_slug");
?>
',
	fileverify_url = '<?php 
echo wp_nonce_url(admin_url() . "admin-ajax.php", "shopp-ajax_verify_file");
?>
',
示例#13
0
<div class="shopp-collections-menu-item taxonomydiv" id="shopp-collections-menu-item">
	<div id="tabs-panel-shopp-collections" class="tabs-panel tabs-panel-active">

		<ul class="categorychecklist form-no-clear">

		<?php 
$collections = $Shopp->Collections;
foreach ((array) $collections as $slug => $CollectionClass) {
    $menu = get_class_property($CollectionClass, '_menu');
    if (!$menu) {
        continue;
    }
    $Collection = new $CollectionClass();
    $Collection->smart();
    $navmenu_placeholder = 0 > $navmenu_placeholder ? $navmenu_placeholder - 1 : -1;
    ?>
			<li>
				<label class="menu-item-title">
				<input type="checkbox" name="menu-item[<?php 
    echo $navmenu_placeholder;
    ?>
][menu-item-shopp-collection]" value="<?php 
    echo $slug;
    ?>
" class="menu-item-checkbox" /> <?php 
    echo esc_html($Collection->name);
    ?>
</label>
				<input type="hidden" class="menu-item-db-id" name="menu-item[<?php 
    echo $navmenu_placeholder;
    ?>