Permalink
Browse files

Store taxonomy is created.

  • Loading branch information...
1 parent 63c476a commit 226f3091a8310b59c1b08c92fa413c8defe980d5 @zakirsajib committed May 16, 2012
Showing with 306 additions and 21 deletions.
  1. +0 −1 category.php
  2. +4 −6 content-type/upcoming/functions.php
  3. +42 −3 functions.php
  4. +3 −2 single.php
  5. +23 −0 store/dbtable-store.php
  6. +201 −0 store/functions.php
  7. +15 −0 store/storeupload.js
  8. +9 −9 style.css
  9. +9 −0 taxonomy-go.php
View
@@ -283,7 +283,6 @@
<?php $ribbon_data = get_post_meta($post->ID, "prod_picks", true); ?>
<?php if($ribbon_data=='Y'){?>
- <!-- <div><span class="ribbon-area"></span></div> -->
<div class="product-box">
<div><span class="ribbon-area-one"></span></div>
@@ -1,6 +1,6 @@
-<style type="text/css">
-
-#up-date, #up-title, #up-link, #up-descr{
+<?php
+echo '<style type="text/css" media="screen">
+ #up-date, #up-title, #up-link, #up-descr{
padding: 9px;
border: solid 1px #E5E5E5;
outline: 0;
@@ -10,7 +10,6 @@
-moz-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0,0,0, 0.1) 0px 0px 8px;
}
-
.lbl_1, .lbl_2, .lbl_3, .lbl_4 {
float: left;
text-align: left;
@@ -19,8 +18,7 @@
font-family:"Century Gothic"; font-size: 12px; font-weight:bold;
margin: 10px 0;
}
-</style>
-<?php
+ </style>';
add_action('init', 'upcoming_occassions_register');
function upcoming_occassions_register() {
View
@@ -4,15 +4,50 @@
if(is_admin()){
require_once( $current_path. '/content-type/upcoming/functions.php');
require_once( $current_path. '/meta-box/functions.php');
+
+ require_once( $current_path. '/store/dbtable-store.php');// create 'store_meta' table for store taxonomy
+ require_once( $current_path. '/store/functions.php');
+
}
+// REmove admin bar
+if (!function_exists('disableAdminBar')) {
+
+ function disableAdminBar(){
+
+ remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
+ remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end
+
+ function remove_admin_bar_style_backend() { // css override for the admin page
+ echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
+ }
+
+ add_filter('admin_head','remove_admin_bar_style_backend');
+
+ function remove_admin_bar_style_frontend() { // css override for the frontend
+ echo '<style type="text/css" media="screen">
+ html { margin-top: 0px !important; }
+ * html body { margin-top: 0px !important; }
+ </style>';
+ }
+
+ add_filter('wp_head','remove_admin_bar_style_frontend', 99);
+
+ }
+
+}
+
+// add_filter('admin_head','remove_admin_bar_style_backend'); // Original version
+//add_action('init','disableAdminBar'); // New version
+
+
add_action( 'after_setup_theme', 'my_setup' );
if ( !function_exists('my_setup') ):
function my_setup(){
add_theme_support( 'post-thumbnails' ); // This theme uses post thumbnails
//set_post_thumbnail_size( 600, 390 ); // 299 pixels wide by 375 pixels tall, set last parameter to true for hard crop mode
- //add_image_size( 'featured-image', 680, 280 );
+ add_image_size( 'featured-image', 680, 280 );
add_image_size( 'product-thumbnail', 150, 150 );
}
endif;
@@ -126,7 +161,7 @@ function upcoming_ticker(){
define('edit_category_fields', 'gift_category_fields_option');
-// Add extra custom field in category
+// Add extra custom field in category EDIT mode
add_action( 'category_edit_form_fields', 'edit_category_fields', 10, 2);
function edit_category_fields($tag, $taxonomy){
$tag_extra_fields = get_option(edit_category_fields);
@@ -162,17 +197,21 @@ function my_admin_scripts() {
wp_enqueue_script('thickbox');
wp_register_script('category-upload', WP_CONTENT_URL.'/themes/gift/category/catupload.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script('category-upload');
+
}
function my_admin_styles() {
wp_enqueue_style('thickbox');
+
}
-
+// These actions were called for both category and store extra fields. We cant use more than one of each fucntion in one theme.
add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
+
+
add_action( 'category_add_form_fields', 'add_category_fields', 10, 2);
function add_category_fields(){?>
<tr class="form-field">
View
@@ -2,7 +2,8 @@
get_header();
update_option('current_result', '');
update_option('current_sort', '');
+?>
+<div id="main-content">
-
-get_footer();
+<?php get_footer();
?>
View
@@ -0,0 +1,23 @@
+<?php
+class storeTable{
+ function __construct(){
+ global $wpdb;
+ $table_name = $wpdb->prefix . "storemeta";
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){
+
+ $sql = "CREATE TABLE " . $table_name . " (
+ meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ store_id bigint(20) unsigned NOT NULL DEFAULT '0',
+ meta_key varchar(255) DEFAULT NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY post_id (store_id),
+ KEY meta_key (meta_key)
+ );";
+
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
+ dbDelta($sql);
+ }
+ }
+}
+$store_table = new storeTable();?>
View
@@ -0,0 +1,201 @@
+<?php
+ /* Create Store Taxonomy with 4 custom fields */
+add_action( 'init', 'store_init', 0);
+function store_init(){
+
+ global $wpdb;
+ $labels = array(
+ 'name' => _x( 'Stores', 'taxonomy general name' ),
+ 'singular_name' => _x( 'Store', 'taxonomy singular name' ),
+ 'search_items' => __( 'Search Store' ),
+ 'all_items' => __( 'All Stores' ),
+ 'parent_item' => __( 'Parent Store' ),
+ 'parent_item_colon' => __( 'Parent Store:' ),
+ 'edit_item' => __( 'Edit Store' ),
+ 'update_item' => __( 'Update Store' ),
+ 'add_new_item' => __( 'Add New Store ' ),
+ 'new_item_name' => __( 'New Store Name' ),
+ 'menu_name' => __( 'Store' ),
+ );
+
+
+ register_taxonomy( 'store', 'post',
+ array( 'hierarchical' => true,
+ 'labels' =>$labels,
+ 'rewrite' => array('slug' => 'go'),
+ 'query_var' => false
+ )
+ );
+
+ # Define the database table 'wp_storemeta'
+ $wpdb->storemeta = $wpdb->prefix."storemeta";
+
+ add_filter( 'manage_edit-store_columns','admin_store_column_headers', 10, 1);
+ add_filter( 'manage_store_custom_column', 'admin_store_column_row', 10, 3 );
+}
+
+/* show columns headers only no rows (without data) */
+function admin_store_column_headers($columns){
+ $columns_local = array();
+ if (isset($columns['cb'])) {
+ $columns_local['cb'] = $columns['cb'];
+ unset($columns['cb']);
+ }
+ if (isset($columns['name'])){
+ $columns_local['name'] = $columns['name'];
+ unset($columns['name']);
+ }
+ if (isset($columns['post']))
+ $columns['post'] = "Post";
+
+ if (!isset($columns_local['store_url']))
+ $columns_local['store_url'] = "Store URL";
+
+ if (!isset($columns_local['store_promo']))
+ $columns_local['store_promo'] = "Promotion";
+
+ return array_merge($columns_local, $columns);
+}
+
+
+/* show columns and rows with data */
+function admin_store_column_row($row_content, $column_name, $term_id){
+
+ switch($column_name)
+ {
+ case 'name':
+ return get_metadata('store', $term_id, 'name', true);
+ break;
+ case 'store_url':
+ return get_metadata('store', $term_id, 'store_url', true);
+ break;
+ case 'store_promo':
+ return get_metadata('store', $term_id, 'store_promo', true);
+ break;
+ default:
+ break;
+ }
+}
+
+
+
+
+
+/* ADD Mode */
+add_action( 'store_add_form_fields', 'add_store', 10, 2);
+
+function add_store(){
+?>
+
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_photo"><strong>Store Logo</strong></label></th>
+ <td>
+ <input type="text" size="40" name="category_photo" id="category_photo" value="" />
+ <input id="upload_image_button" type="button" value="Upload logo" />
+ <p class="description">Image Size: </p>
+ </td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_url"><strong>Store URL</strong></label></th>
+ <td>
+ <input type="text" name="store_url" id="store_url" size="50" value=""/><br />
+ <p class="description">Enter Store URL</p>
+ </td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_promo"><strong>Store Promotion</strong></label></th>
+ <td>
+ <textarea name="store_promo" id="store_promo" cols="50" rows="10" value=""></textarea><br />
+ <p class="description">Enter Store Promotion code</p>
+ </td>
+ </tr>
+ <?php }
+
+
+
+
+add_action( 'created_store', 'save_store_add_mode', 10, 2);
+/* SAVE Mode for ADD page */
+function save_store_add_mode($term_id)
+{
+ if (!$term_id) return;
+
+ if (isset($_POST['category_photo']))
+ update_metadata($_POST['taxonomy'], $term_id, 'category_photo',
+ $_POST['category_photo']);
+
+ if (isset($_POST['store_url']))
+ update_metadata($_POST['taxonomy'], $term_id, 'store_url',
+ $_POST['store_url']);
+
+ if (isset($_POST['store_promo']))
+ update_metadata($_POST['taxonomy'], $term_id, 'store_promo',
+ $_POST['store_promo']);
+
+}
+
+
+
+
+/* EDIT Mode */
+add_action( 'store_edit_form_fields', 'edit_store', 10, 2);
+function edit_store($tag, $taxonomy){
+ $category_photo = get_metadata($tag->taxonomy, $tag->term_id, 'category_photo', true);
+ $store_url = get_metadata($tag->taxonomy, $tag->term_id, 'store_url', true);
+ $store_promo = get_metadata($tag->taxonomy, $tag->term_id, 'store_promo', true);
+?>
+
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_photo"><strong>Store Logo</strong></label></th>
+ <td>
+ <img src="<?php echo $category_photo; ?>" /><br/><br/>
+ <input type="text" size="40" name="category_photo" id="category_photo" value="<?php echo $category_photo; ?>" />
+ <input id="upload_image_button" type="button" value="Upload Image" />
+ <p class="description">Image Size: </p>
+ </td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_url"><strong>Store URL</strong></label></th>
+ <td>
+ <input type="text" name="store_url" id="store_url" size="50" value="<?php echo $store_url; ?>"/><br />
+ <p class="description">Enter Store URL</p>
+ </td>
+ </tr>
+ <tr class="form-field">
+ <th scope="row" valign="top"><label for="store_promo"><strong>Store Promotion</strong></label></th>
+ <td>
+ <textarea name="store_promo" id="store_promo" cols="50" rows="10"><?php echo $store_promo; ?></textarea><br />
+ <p class="description">Enter Store Promotion code</p>
+ </td>
+ </tr>
+
+
+<?php
+
+ echo '<style type="text/css" media="screen">
+ #upload_image_button {width:100px;}
+ #category_photo {width:400px;}
+ </style>';
+
+}
+
+add_action( 'edited_store', 'save_store', 10, 2);
+
+/* SAVE Mode for EDIT page */
+function save_store($term_id, $tt_id)
+{
+ if (!$term_id) return;
+
+ if (isset($_POST['category_photo']))
+ update_metadata($_POST['taxonomy'], $term_id, 'category_photo',
+ $_POST['category_photo']);
+
+ if (isset($_POST['store_url']))
+ update_metadata($_POST['taxonomy'], $term_id, 'store_url',
+ $_POST['store_url']);
+
+ if (isset($_POST['store_promo']))
+ update_metadata($_POST['taxonomy'], $term_id, 'store_promo',
+ $_POST['store_promo']);
+}
+?>
View
@@ -0,0 +1,15 @@
+jQuery(document).ready(function() {
+
+jQuery('#upload_store_button').click(function() {
+ formfield = jQuery('#store_photo').attr('name');
+ tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
+ return false;
+});
+
+window.send_to_editor = function(html) {
+ imgurl = jQuery('img',html).attr('src');
+ jQuery('#store_photo').val(imgurl);
+ tb_remove();
+}
+
+});
Oops, something went wrong.

0 comments on commit 226f309

Please sign in to comment.