-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from itthinx/pre-2.1.2
Pre 2.1.2
- Loading branch information
Showing
7 changed files
with
146 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* class-groups-extra.php | ||
* | ||
* Copyright (c) "kento" Karim Rahimpur www.itthinx.com | ||
* | ||
* This code is released under the GNU General Public License. | ||
* See COPYRIGHT.txt and LICENSE.txt. | ||
* | ||
* This code is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This header and all notices must be kept intact. | ||
* | ||
* @author Karim Rahimpur | ||
* @package groups | ||
* @since groups 2.1.2 | ||
*/ | ||
|
||
if ( !defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Compatibility actions, filters, etc as needed. | ||
*/ | ||
class Groups_Extra { | ||
|
||
/** | ||
* Registers actions, filters ... | ||
*/ | ||
public static function init() { | ||
add_filter( 'woocommerce_product_is_visible', array( __CLASS__, 'woocommerce_product_is_visible' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* Up-sell and cross-sell products are obtained directly by their ids and | ||
* no normal filters are executed that would hide them. This filter is used | ||
* instead to determine the visibility. | ||
* | ||
* If at some point we had a get_post filter in WordPress, it could filter these | ||
* and we wouldn't need this. | ||
* | ||
* @param boolean $visible | ||
* @param int $product_id | ||
* @return boolean | ||
*/ | ||
public static function woocommerce_product_is_visible( $visible, $product_id ) { | ||
if ( $visible ) { | ||
$visible = Groups_Post_Access::user_can_read_post( $product_id ); | ||
} | ||
return $visible; | ||
} | ||
} | ||
add_action( 'init', array( 'Groups_Extra', 'init' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters