Skip to content

Commit

Permalink
Whitespace + docblock fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bekarice committed Mar 17, 2017
1 parent fbd4aca commit 2ea65a1
Show file tree
Hide file tree
Showing 41 changed files with 225 additions and 217 deletions.
26 changes: 13 additions & 13 deletions woocommerce-checkout-add-ons/conditionally-hide-add-ons.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
*/
function sv_wc_checkout_add_ons_conditionally_show_gift_add_on() {

wc_enqueue_js( "
$( 'input[name=ship_to_different_address]' ).change( function () {
wc_enqueue_js( "
$( 'input[name=ship_to_different_address]' ).change( function () {
if ( $( this ).is( ':checked' ) ) {
if ( $( this ).is( ':checked' ) ) {
// show the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).show();
// show the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).show();
} else {
} else {
// hide the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).hide();
// hide the gift checkout add-on -- replace '2' with the id of your add-on
$( '#wc_checkout_add_ons_2_field' ).hide();
}
}
} ).change();
" );
} ).change();
" );
}
add_action( 'wp_enqueue_scripts', 'sv_wc_checkout_add_ons_conditionally_show_gift_add_on' );
add_action( 'wp_enqueue_scripts', 'sv_wc_checkout_add_ons_conditionally_show_gift_add_on' );
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function sv_wc_csv_export_add_weight_to_line_item( $line_item, $item, $product,
* Add `item_weight` column to the default and custom formats
*
* @param array $column_headers the original column headers
* @param WC_Customer_Order_CSV_Export_Generator $csv_generator the generator instance
* @param \WC_Customer_Order_CSV_Export_Generator $csv_generator the generator instance
* @return array - the updated column headers
*/
function sv_wc_csv_export_modify_column_headers_item_price( $column_headers, $csv_generator ) {
Expand All @@ -53,7 +53,6 @@ function sv_wc_csv_export_modify_column_headers_item_price( $column_headers, $cs
// add the item_price after the SKU column
if ( 'item_sku' === $key ) {
$new_headers['item_weight'] = 'item_weight';

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function sv_wc_csv_export_add_product_attributes_column( $headers ) {
function sv_wc_csv_export_add_product_to_order_line_item( $line_item, $_, $product ) {

$line_item['product'] = $product;

return $line_item;
}
add_filter( 'wc_customer_order_csv_export_order_line_item', 'sv_wc_csv_export_add_product_to_order_line_item', 10, 3 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function sv_wc_customer_csv_export_column_headers( $column_headers ) {
// Adds new column after 'last_name' column
if ( 'last_name' === $key ) {
$new_headers['role'] = 'role';

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* Example: Add a heading above the calculator section
*/
function sv_wc_measurement_price_calculator_heading() {
global $product;

// bail if MPC isn't active
if ( ! class_exists( 'WC_Price_Calculator_Product' ) ) {
return;
}

global $product;
$measurement = WC_Price_Calculator_Product::calculator_enabled( $product );

// if the calculator is enabled, add the heading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
* requires HTML5 support
*/
function sv_wc_measurement_price_calculator_input_min_max() {
global $product;

// bail unless we're on a product page and MPC is active
if ( ! ( is_product() && class_exists( 'WC_Price_Calculator_Product' ) ) ) {
return;
}

global $product;

// bail unless the calculator is enabled for this product, this is also why we hook into the footer scripts
// since this isn't available immediately at page load
if ( ! WC_Price_Calculator_Product::calculator_enabled( $product ) ) {
Expand All @@ -31,10 +30,10 @@ function sv_wc_measurement_price_calculator_input_min_max() {


/**------------------------------------------------------------
Note: if you run into "Error: type property can't be changed",
then you can also use the jQuery "clone" function,
Note: if you run into "Error: type property can't be changed",
then you can also use the jQuery "clone" function,
then destroy the text field once it's replaced.
Example:
$('#length_needed').clone().attr({ type: 'number', min: '.1', max: '24', step: '.1' }).insertAfter('#length_needed').prev().remove();
------------------------------------------------------------**/
------------------------------------------------------------**/
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* the correct weight via the WooCommerce ShipStation Integration
*/


/**
* Filter the product's weight only when the WooCommerce ShipStation API is loaded.
* This ensures that the `WC_Order::woocommerce_get_product_from_item()` method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* @return int The number of decimal places
*/
function sv_wc_measurement_price_calculator_change_measurement_precision() {

return 2;
}
add_filter( 'wc_measurement_price_calculator_measurement_precision', 'sv_wc_measurement_price_calculator_change_measurement_precision' );


/**
* Round the Measurement Price Calculator total measurement on the cart page to
* 2 decimal places.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* for Measurement Calculator products
*/
function sv_wc_measurement_price_calculator_hide_unit_price() {
global $product;

// bail if the calculator isn't active or this isn't a product page
if ( ! class_exists( 'WC_Price_Calculator_Product' ) || ! is_product() ) {
return;
}

global $product;
$measurement = WC_Price_Calculator_Product::calculator_enabled( $product );

// if the calculator is enabled, hide unit price
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ function sv_wc_memberships_remove_processing_access() {
if ( function_exists( 'wc_memberships' ) ) {
remove_action( 'woocommerce_order_status_processing', array( wc_memberships(), 'grant_membership_access' ), 11 );
}

}
add_action( 'init', 'sv_wc_memberships_remove_processing_access' );
26 changes: 13 additions & 13 deletions woocommerce-memberships/create-membership-for-user-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
function sv_wc_memberships_user_membership_at_registration( $user_id ) {

// bail if Memberships isn't active
if ( ! function_exists( 'wc_memberships' ) ) {
return;
}
if ( ! function_exists( 'wc_memberships' ) ) {
return;
}

$args = array(
// Enter the ID (post ID) of the plan to grant at registration
'plan_id' => 253,
'user_id' => $user_id,
);
$args = array(
// Enter the ID (post ID) of the plan to grant at registration
'plan_id' => 253,
'user_id' => $user_id,
);

// magic!
wc_memberships_create_user_membership( $args );
// magic!
wc_memberships_create_user_membership( $args );

// Optional: get the new membership and add a note so we know how this was registered.
$user_membership = wc_memberships_get_user_membership( $user_id, $args['plan_id'] );
$user_membership->add_note( 'Membership access granted automatically from registration.' );
// Optional: get the new membership and add a note so we know how this was registered.
$user_membership = wc_memberships_get_user_membership( $user_id, $args['plan_id'] );
$user_membership->add_note( 'Membership access granted automatically from registration.' );

}
add_action( 'user_register', 'sv_wc_memberships_user_membership_at_registration', 15 );
11 changes: 5 additions & 6 deletions woocommerce-memberships/frontend/add-support-for-facet-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
*/
function sv_memberships_facetwp_compatibility( $is_main_query, $query ) {

if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
$is_main_query = false;
}

return $is_main_query;
}
if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
$is_main_query = false;
}

return $is_main_query;
}
add_filter( 'facetwp_is_main_query', 'sv_memberships_facetwp_compatibility' , 10, 2 );
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* This could let you remove the message HTML to add your own, adjust the excerpt or
* displayed content, or conditionally change restricted views for certain posts
*/


/**

/**
* Example of adjusting restricted content (v1.6.0+)
* Changes excerpts to use 120 words instead of WordPress default
*
Expand All @@ -21,11 +21,10 @@
*/
function sv_wc_memberships_filter_restricted_content( $content, $restricted, $message, $post ) {

if ( true === $restricted ) {

return wp_trim_words( $content, 120 ) . $message ;
}
if ( true === $restricted ) {
return wp_trim_words( $content, 120 ) . $message;
}

return $content;
}
add_filter( 'wc_memberships_the_restricted_content', 'sv_wc_memberships_filter_restricted_content', 10, 4 );
return $content;
}
add_filter( 'wc_memberships_the_restricted_content', 'sv_wc_memberships_filter_restricted_content', 10, 4 );
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
*/
function sv_wc_memberships_my_content_table_add_column( $columns ) {

$new_columns = array();
$new_columns = array();

foreach ( $columns as $column_id => $column_name ) {
foreach ( $columns as $column_id => $column_name ) {

$new_columns[ $column_id ] = $column_name;
$new_columns[ $column_id ] = $column_name;

// insert our new "Author" column after the "Title" column
if ( 'membership-content-title' === $column_id ) {
$new_columns['membership-content-author'] = __( 'Author', 'your-textdomain' );
}
}
// insert our new "Author" column after the "Title" column
if ( 'membership-content-title' === $column_id ) {
$new_columns['membership-content-author'] = __( 'Author', 'your-textdomain' );
}
}

return $new_columns;
return $new_columns;
}
add_filter( 'wc_memberships_members_area_my_membership_content_column_names', 'sv_members_area_content_table_columns', 11 );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
* @return string $title the updated heading text
*/
function sv_wc_memberships_members_area_section_title( $title ) {
return __( 'Exclusive Discounts', 'your-textdomain' );
return __( 'Exclusive Discounts', 'your-textdomain' );
}
add_filter( 'wc_memberships_members_area_my_membership_discounts_title', 'sv_wc_memberships_members_area_section_title' );
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
* @param array $query_args args for retrieving membership content
* @param string $type Type of request: 'content_restriction', 'product_restriction', 'purchasing_discount'
* @return array updated query args
*/
function sv_wc_memberships_sort_my_content( $query_args, $type ) {

Expand All @@ -34,6 +35,7 @@ function sv_wc_memberships_sort_my_content( $query_args, $type ) {
*
* @param array $query_args args for retrieving membership content
* @param string $type Type of request: 'content_restriction', 'product_restriction', 'purchasing_discount'
* @return array updated query args
*/
function sv_wc_memberships_adjust_my_content_query( $query_args, $type ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/
function sv_wc_memberships_my_content_table_columns( $columns ) {

// unset the "type" column, which shows post, page, etc
unset( $columns['membership-content-type'] );
return $columns;
// unset the "type" column, which shows post, page, etc
unset( $columns['membership-content-type'] );
return $columns;
}
add_filter( 'wc_memberships_members_area_my_membership_content_column_names', 'sv_wc_memberships_my_content_table_columns', 11 );
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
function sv_wc_memberships_my_products_table_columns( $columns ) {

unset( $columns['membership-product-excerpt'] );
return $columns;
unset( $columns['membership-product-excerpt'] );
return $columns;
}
add_filter('wc_memberships_members_area_my_membership_products_column_names', 'sv_wc_memberships_my_products_table_columns', 10, 1 );
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
* @param \WC_Memberships_User_Membership $user_membership User Membership object
* @return array $actions the updated array of actions
*/

function sv_wc_memberships_edit_my_memberships_actions( $actions, $user_membership ) {

// we could check the plan slug if you only want to unset this for certain memberships
// if ( 'silver' !== $user_membership->get_plan()->get_slug() ) {
// return $actions;
// if ( 'silver' !== $user_membership->get_plan()->get_slug() ) {
// return $actions;
// }

unset( $actions['renew'] );
return $actions;
}
add_filter( 'wc_memberships_members_area_my-memberships_actions', 'sv_wc_memberships_edit_my_memberships_actions', 10, 2 );
add_filter( 'wc_memberships_members_area_my-memberships_actions', 'sv_wc_memberships_edit_my_memberships_actions', 10, 2 );
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/
function sv_wc_memberships_rename_member_area_sections( $sections ) {

$sections['my-membership-content'] = __( 'Club Articles', 'my-text-domain' );
$sections['my-membership-products'] = __( 'Club Products', 'my-text-domain' );
$sections['my-membership-discounts'] = __( 'Exclusive Discounts', 'my-text-domain' );
$sections['my-membership-notes'] = __( 'Notes from MySite', 'my-text-domain' );
$sections['my-membership-content'] = __( 'Club Articles', 'my-text-domain' );
$sections['my-membership-products'] = __( 'Club Products', 'my-text-domain' );
$sections['my-membership-discounts'] = __( 'Exclusive Discounts', 'my-text-domain' );
$sections['my-membership-notes'] = __( 'Notes from MySite', 'my-text-domain' );

return $sections;
return $sections;
}
add_filter( 'wc_membership_plan_members_area_sections', 'sv_wc_memberships_rename_member_area_sections' );
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
function sv_wc_memberships_member_discount_product_notice() {

// bail if Memberships isn't active
if ( ! function_exists( 'wc_memberships' ) ) {
return;
}
if ( ! function_exists( 'wc_memberships' ) ) {
return;
}

// Set a discount end date
$discount_ends = date_i18n( wc_date_format(), strtotime( '2015-12-31' ) );
// Set a discount end date
$discount_ends = date_i18n( wc_date_format(), strtotime( '2015-12-31' ) );

// Add our top notice if the member has a discount
if ( wc_memberships_user_has_member_discount() ) {
wc_print_notice( sprintf( 'Act fast! Your member discount ends on %s.', $discount_ends ), 'notice' );
}
// Add our top notice if the member has a discount
if ( wc_memberships_user_has_member_discount() ) {
wc_print_notice( sprintf( 'Act fast! Your member discount ends on %s.', $discount_ends ), 'notice' );
}
}
add_action( 'woocommerce_before_single_product', 'sv_wc_memberships_member_discount_product_notice' );
Loading

0 comments on commit 2ea65a1

Please sign in to comment.