Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
update for version 1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
divergeinfinity committed Oct 22, 2012
1 parent 5c93a61 commit 2f0de38
Show file tree
Hide file tree
Showing 23 changed files with 223 additions and 229 deletions.
36 changes: 30 additions & 6 deletions admin/jigoshop-admin-settings-api.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ public function output_markup() {
<?php do_settings_sections( JIGOSHOP_OPTIONS ); ?> <?php do_settings_sections( JIGOSHOP_OPTIONS ); ?>


<?php $tabname = $this->get_current_tab_name(); ?> <?php $tabname = $this->get_current_tab_name(); ?>
<?php self::get_options()->set_option( 'jigoshop_settings_current_tabname', $tabname ); ?>


<p class="submit"><input name="Submit" type="submit" class="button-primary" value="<?php echo sprintf( __( "Save %s Changes", 'jigoshop' ), $tabname ); ?>" /></p> <p class="submit"><input name="Submit" type="submit" class="button-primary" value="<?php echo sprintf( __( "Save %s Changes", 'jigoshop' ), $tabname ); ?>" /></p>


Expand Down Expand Up @@ -294,11 +293,21 @@ function build_tab_menu_items() {
public function get_current_tab_slug() { public function get_current_tab_slug() {
$current = ""; $current = "";


if ( isset( $_GET['tab'] ) ): if ( isset( $_GET['tab'] ) ) {
$current = $_GET['tab']; $current = $_GET['tab'];
else: } else if ( isset( $_POST['_wp_http_referer'] ) ) {
// /site/wp-admin/admin.php?page=jigoshop_settings&tab=products-inventory&settings-updated=true
// find the 'tab'
$result = strstr( $_POST['_wp_http_referer'], '&tab=' );
// &tab=products-inventory&settings-updated=true
$result = substr( $result, 5 );
// products-inventory&settings-updated=true
$end_pos = strpos( $result, '&' );
$current = substr( $result, 0 , $end_pos !== false ? $end_pos : strlen( $result ) );
// products-inventory
} else {
$current = sanitize_title( $this->our_parser->these_options[0]['name'] ); $current = sanitize_title( $this->our_parser->these_options[0]['name'] );
endif; }
return $current; return $current;
} }


Expand All @@ -317,6 +326,21 @@ public function get_current_tab_name() {
$current = $option['name']; $current = $option['name'];
} }
} }
} else if ( isset( $_POST['_wp_http_referer'] ) ) {
// /site/wp-admin/admin.php?page=jigoshop_settings&tab=products-inventory&settings-updated=true
// find the 'tab'
$result = strstr( $_POST['_wp_http_referer'], '&tab=' );
// &tab=products-inventory&settings-updated=true
$result = substr( $result, 5 );
// products-inventory&settings-updated=true
$end_pos = strpos( $result, '&' );
$tab_slug = substr( $result, 0 , $end_pos !== false ? $end_pos : strlen( $result ) );
// products-inventory
foreach ( $this->our_parser->these_options as $option ) {
if ( $option['type'] == 'tab' && sanitize_title( $option['name'] ) == $tab_slug ) {
$current = $option['name'];
}
}
} else { } else {
$current = $this->our_parser->these_options[0]['name']; $current = $this->our_parser->these_options[0]['name'];
} }
Expand All @@ -341,7 +365,7 @@ public function validate_settings( $input ) {
$valid_input = $current_options; // we start with the current options $valid_input = $current_options; // we start with the current options


// Find the current TAB we are working with and use it's option settings // Find the current TAB we are working with and use it's option settings
$this_section = self::get_options()->get_option( 'jigoshop_settings_current_tabname' ); $this_section = self::get_current_tab_name();
$tab = $this->our_parser->tabs[sanitize_title( $this_section )]; $tab = $this->our_parser->tabs[sanitize_title( $this_section )];


// with each option, get it's type and validate it // with each option, get it's type and validate it
Expand Down Expand Up @@ -509,7 +533,7 @@ public function validate_settings( $input ) {
add_settings_error( add_settings_error(
'', '',
'settings_updated', 'settings_updated',
sprintf(__('"%s" settings were updated successfully.','jigoshop'), self::get_options()->get_option( 'jigoshop_settings_current_tabname' )), sprintf(__('"%s" settings were updated successfully.','jigoshop'), self::get_current_tab_name()),
'updated' 'updated'
); );
} }
Expand Down
101 changes: 0 additions & 101 deletions admin/jigoshop-admin.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
require_once( 'jigoshop-admin-help.php' ); require_once( 'jigoshop-admin-help.php' );
} }


add_action('admin_init', 'jigoshop_admin_init');
function jigoshop_admin_init() {
add_action('wp_dashboard_setup', 'jigoshop_setup_dashboard_widgets' );
}

add_action('admin_notices', 'jigoshop_update'); add_action('admin_notices', 'jigoshop_update');
function jigoshop_update() { function jigoshop_update() {
// Run database upgrade if required // Run database upgrade if required
Expand Down Expand Up @@ -343,100 +338,4 @@ function boolval($in, $strict = false) {
} }
return $out; return $out;
} }
}

/**
* Replaces Recent Comments Dashboard widget with shop message filtered ver
*
* The only difference between the two is the query now takes into account
* shop order messages. Unfortunately WordPress hasn't made this very easy
* to achieve due to the query being hard coded so a complete
* replacement was necessary :(
*
* Sourced from dashboard.php
*/
function jigoshop_setup_dashboard_widgets() {
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
wp_add_dashboard_widget('jigoshop_recent_comments', 'Recent Comments', 'jigoshop_dashboard_recent_comments', 'jigoshop_dashboard_recent_comments_control');
}

function jigoshop_dashboard_recent_comments() {
global $wpdb;

if ( current_user_can('edit_posts') )
$allowed_states = array('0', '1');
else
$allowed_states = array('1');

// Select all comment types and filter out spam later for better query performance.
$comments = array();
$start = 0;

$widgets = get_option( 'dashboard_widget_options' );
$total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;

while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' AND c.comment_type != 'jigoshop' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {

foreach ( $possible as $comment ) {
if ( count( $comments ) >= $total_items )
break;
if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )
$comments[] = $comment;
}

$start = $start + 50;
}

if ( $comments ) :
?>

<div id="the-comment-list" class="list:comment">
<?php
foreach ( $comments as $comment )
_wp_dashboard_recent_comments_row( $comment );
?>

</div>

<?php
if ( current_user_can('edit_posts') ) { ?>
<?php _get_list_table('WP_Comments_List_Table')->views(); ?>
<?php }

wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();

else :
?>

<p><?php _e( 'No comments yet.' ); ?></p>

<?php
endif; // $comments;
}

/**
* The recent comments dashboard widget control.
*
* @since 3.0.0
*/
function jigoshop_dashboard_recent_comments_control() {
$jigoshop_options = Jigoshop_Base::get_options();
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();

if ( !isset($widget_options['dashboard_recent_comments']) )
$widget_options['dashboard_recent_comments'] = array();

if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) {
$number = absint( $_POST['widget-recent-comments']['items'] );
$widget_options['dashboard_recent_comments']['items'] = $number;
$jigoshop_options->set_option( 'dashboard_widget_options', $widget_options );
}

$number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';

echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>';
echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . esc_attr( $number ) . '" size="3" /></p>';
} }
2 changes: 1 addition & 1 deletion assets/css/admin.css

Large diffs are not rendered by default.

47 changes: 0 additions & 47 deletions assets/css/admin.less
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1323,53 +1323,6 @@ div.multi_select_countries.shipping_services {
} }
} }


/* Custom Recent Products Widget */
#jigoshop_recent_comments .inside {
margin-top: 0;
}
#jigoshop_recent_comments #the-comment-list .trackback blockquote,
#jigoshop_recent_comments #the-comment-list .pingback blockquote {
display: block;
}
#jigoshop_recent_comments h3 {
margin-bottom: 0;
}

#jigoshop_recent_comments .inside {
margin-top: 0;
}

#jigoshop_recent_comments .comment-meta .approve {
font-style: italic;
font-family: sans-serif;
font-size: 10px;
}

#jigoshop_recent_comments .subsubsub {
float: none;
white-space: normal;
}
#jigoshop_recent_comments div.undo {
border-top-style: solid;
border-top-width: 1px;
margin: 0 -10px;
padding: 3px 8px;
font-size: 11px;
}
#jigoshop_recent_comments .delete a,
#jigoshop_recent_comments .trash a,
#jigoshop_recent_comments .spam a {
color: #bc0b0b;
}
#jigoshop_recent_comments .delete a:hover,
#jigoshop_recent_comments .trash a:hover
#jigoshop_recent_comments .spam a:hover {
color: #f00;
}
#jigoshop_recent_comments div.undo {
border-top-color: #dfdfdf;
}

/* Hidden Tabs Ect Settings */ /* Hidden Tabs Ect Settings */
.attribute_is_variable { .attribute_is_variable {
display: none; display: none;
Expand Down
4 changes: 2 additions & 2 deletions assets/js/variable.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@


.on('click', '.postbox h3', function(e) { .on('click', '.postbox h3', function(e) {


//console.log( e.target.tagName.toLowerCase() ); // the jquery event can still be triggered by other child elements, so we need to be explicit
if ( e.target.tagName.toLowerCase() === 'select' ) if ( e.target.tagName.toLowerCase() != 'h3' && !$(this).hasClass('handlediv'))
return false; return false;


$(this).parent().toggleClass('closed'); $(this).parent().toggleClass('closed');
Expand Down
10 changes: 7 additions & 3 deletions classes/jigoshop_cart.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function add_to_cart($product_id, $quantity = 1, $variation_id = '', $variation


$quantity = (int) $quantity + self::$cart_contents[$cart_item_key]['quantity']; $quantity = (int) $quantity + self::$cart_contents[$cart_item_key]['quantity'];


self::set_quantity($cart_item_key, $quantity); self::set_quantity( $cart_item_key, apply_filters( 'jigoshop_cart_item_quantity', $quantity, $product, $cart_item_key ) );


} else { } else {
// otherwise add new item to the cart // otherwise add new item to the cart
Expand Down Expand Up @@ -968,10 +968,14 @@ public static function get_cart_shipping_total($for_display = true, $order_exclu
/* Title of the chosen shipping method. */ /* Title of the chosen shipping method. */
function get_cart_shipping_title() { function get_cart_shipping_title() {


if ( !jigoshop_shipping::get_label() ) // in this instance we want the title of the shipping method only. If no title is provided, use
// the label.
$title = jigoshop_shipping::get_chosen_method_title();
$label = ($title ? $title : jigoshop_shipping::get_label());
if ( !$label )
return false; return false;


return __(sprintf('via %s', jigoshop_shipping::get_label()), 'jigoshop'); return __(sprintf('via %s', $label), 'jigoshop');


} }


Expand Down
7 changes: 4 additions & 3 deletions classes/jigoshop_checkout.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ function process_checkout() {
? $_product->get_price() ? $_product->get_price()
: -1 : -1
); );

if ( !empty( $values['variation_id'] )) { if ( !empty( $values['variation_id'] )) {
$product_id = $values['variation_id']; $product_id = $values['variation_id'];
} else { } else {
Expand Down Expand Up @@ -928,8 +928,9 @@ static function get_shipping_dropdown() {
if ($method->get_selected_service($i) == $selected_service) : if ($method->get_selected_service($i) == $selected_service) :
echo 'selected="selected"'; echo 'selected="selected"';
endif; endif;
echo '>' . $method->get_selected_service($i) . ' &ndash; ';

echo '>' . $method->get_selected_service($i) . ' &ndash; ';

if ($method->get_selected_price($i) > 0) : if ($method->get_selected_price($i) > 0) :


$tax_label = 0; // 0 no label, 1 ex. tax, 2 inc. tax $tax_label = 0; // 0 no label, 1 ex. tax, 2 inc. tax
Expand Down
Loading

0 comments on commit 2f0de38

Please sign in to comment.