commit
f5ff10711d
|
@ -2,14 +2,15 @@
|
|||
/**
|
||||
* Adds settings to the permalinks admin settings page.
|
||||
*
|
||||
* @class WC_Admin_Permalink_Settings
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 2.1.0
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Admin_Permalink_Settings' ) ) :
|
||||
|
@ -28,7 +29,7 @@ class WC_Admin_Permalink_Settings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Init our settings
|
||||
* Init our settings.
|
||||
*/
|
||||
public function settings_init() {
|
||||
// Add a section to the permalinks page
|
||||
|
@ -89,7 +90,7 @@ class WC_Admin_Permalink_Settings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show the settings
|
||||
* Show the settings.
|
||||
*/
|
||||
public function settings() {
|
||||
echo wpautop( __( 'These settings control the permalinks used for products. These settings only apply when <strong>not using "default" permalinks above</strong>.', 'woocommerce' ) );
|
||||
|
@ -153,7 +154,7 @@ class WC_Admin_Permalink_Settings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save the settings
|
||||
* Save the settings.
|
||||
*/
|
||||
public function settings_save() {
|
||||
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments
|
||||
*
|
||||
* Handle comments (reviews and order notes)
|
||||
*
|
||||
* @class WC_Post_types
|
||||
* @class WC_Comments
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes/Products
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class WC_Comments {
|
||||
|
||||
/**
|
||||
* Hook in methods
|
||||
* Hook in methods.
|
||||
*/
|
||||
public static function init() {
|
||||
|
||||
// Rating posts
|
||||
add_filter( 'preprocess_comment', array( __CLASS__, 'check_comment_rating' ), 0 );
|
||||
add_action( 'comment_post', array( __CLASS__, 'add_comment_rating' ), 1 );
|
||||
|
||||
// clear transients
|
||||
// Clear transients
|
||||
add_action( 'wp_update_comment_count', array( __CLASS__, 'clear_transients' ) );
|
||||
|
||||
// Secure order notes
|
||||
|
@ -41,7 +42,7 @@ class WC_Comments {
|
|||
// Count comments
|
||||
add_filter( 'wp_count_comments', array( __CLASS__, 'wp_count_comments' ), 10, 2 );
|
||||
|
||||
// support avatars for `review` comment type
|
||||
// Support avatars for `review` comment type
|
||||
add_filter( 'get_avatar_comment_types', array( __CLASS__, 'add_avatar_for_review_comment_type' ) );
|
||||
}
|
||||
|
||||
|
@ -53,8 +54,7 @@ class WC_Comments {
|
|||
* shop managers can view orders anyway.
|
||||
*
|
||||
* The frontend view order pages get around this filter by using remove_filter('comments_clauses', array( 'WC_Comments' ,'exclude_order_comments'), 10, 1 );
|
||||
*
|
||||
* @param array $clauses
|
||||
* @param array $clauses
|
||||
* @return array
|
||||
*/
|
||||
public static function exclude_order_comments( $clauses ) {
|
||||
|
@ -83,8 +83,7 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Exclude order comments from queries and RSS
|
||||
*
|
||||
* @param string $join
|
||||
* @param string $join
|
||||
* @return string
|
||||
*/
|
||||
public static function exclude_order_comments_from_feed_join( $join ) {
|
||||
|
@ -99,8 +98,7 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Exclude order comments from queries and RSS
|
||||
*
|
||||
* @param string $where
|
||||
* @param string $where
|
||||
* @return string
|
||||
*/
|
||||
public static function exclude_order_comments_from_feed_where( $where ) {
|
||||
|
@ -117,9 +115,8 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Exclude webhook comments from queries and RSS
|
||||
*
|
||||
* @since 2.2
|
||||
* @param array $clauses
|
||||
* @since 2.2
|
||||
* @param array $clauses
|
||||
* @return array
|
||||
*/
|
||||
public static function exclude_webhook_comments( $clauses ) {
|
||||
|
@ -144,9 +141,8 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Exclude webhook comments from queries and RSS
|
||||
*
|
||||
* @since 2.2
|
||||
* @param string $join
|
||||
* @since 2.2
|
||||
* @param string $join
|
||||
* @return string
|
||||
*/
|
||||
public static function exclude_webhook_comments_from_feed_join( $join ) {
|
||||
|
@ -161,9 +157,8 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Exclude webhook comments from queries and RSS
|
||||
*
|
||||
* @since 2.1
|
||||
* @param string $where
|
||||
* @since 2.1
|
||||
* @param string $where
|
||||
* @return string
|
||||
*/
|
||||
public static function exclude_webhook_comments_from_feed_where( $where ) {
|
||||
|
@ -180,8 +175,7 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Validate the comment ratings.
|
||||
*
|
||||
* @param array $comment_data
|
||||
* @param array $comment_data
|
||||
* @return array
|
||||
*/
|
||||
public static function check_comment_rating( $comment_data ) {
|
||||
|
@ -196,7 +190,6 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Rating field for comments.
|
||||
*
|
||||
* @param int $comment_id
|
||||
*/
|
||||
public static function add_comment_rating( $comment_id ) {
|
||||
|
@ -211,7 +204,6 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Clear transients for a review.
|
||||
*
|
||||
* @param int $post_id
|
||||
*/
|
||||
public static function clear_transients( $post_id ) {
|
||||
|
@ -229,10 +221,9 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Remove order notes from wp_count_comments()
|
||||
*
|
||||
* @since 2.2
|
||||
* @param object $stats
|
||||
* @param int $post_id
|
||||
* @since 2.2
|
||||
* @param object $stats
|
||||
* @param int $post_id
|
||||
* @return object
|
||||
*/
|
||||
public static function wp_count_comments( $stats, $post_id ) {
|
||||
|
@ -276,9 +267,8 @@ class WC_Comments {
|
|||
|
||||
/**
|
||||
* Make sure WP displays avatars for comments with the `review` type
|
||||
*
|
||||
* @since 2.3
|
||||
* @param array $comment_types
|
||||
* @since 2.3
|
||||
* @param array $comment_types
|
||||
* @return array
|
||||
*/
|
||||
public static function add_avatar_for_review_comment_type( $comment_types ) {
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle frontend scripts
|
||||
*
|
||||
* @class WC_Frontend_Scripts
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes/
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
* @class WC_Frontend_Scripts
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes/
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Frontend_Scripts Class
|
||||
*/
|
||||
class WC_Frontend_Scripts {
|
||||
|
||||
|
@ -28,7 +31,7 @@ class WC_Frontend_Scripts {
|
|||
private static $wp_localize_scripts = array();
|
||||
|
||||
/**
|
||||
* Hook in methods
|
||||
* Hook in methods.
|
||||
*/
|
||||
public static function init() {
|
||||
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'load_scripts' ) );
|
||||
|
@ -37,7 +40,7 @@ class WC_Frontend_Scripts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get styles for the frontend
|
||||
* Get styles for the frontend.
|
||||
* @access private
|
||||
* @return array
|
||||
*/
|
||||
|
@ -65,15 +68,15 @@ class WC_Frontend_Scripts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register a script for use
|
||||
* Register a script for use.
|
||||
*
|
||||
* @uses wp_register_script()
|
||||
* @access private
|
||||
* @param string $handle [description]
|
||||
* @param string $path [description]
|
||||
* @param string[] $deps [description]
|
||||
* @param string $version [description]
|
||||
* @param boolean $in_footer [description]
|
||||
* @param string $handle [description]
|
||||
* @param string $path [description]
|
||||
* @param string[] $deps [description]
|
||||
* @param string $version [description]
|
||||
* @param boolean $in_footer [description]
|
||||
*/
|
||||
private static function register_script( $handle, $path, $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {
|
||||
self::$scripts[] = $handle;
|
||||
|
@ -81,15 +84,15 @@ class WC_Frontend_Scripts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register and enqueue a script for use
|
||||
* Register and enqueue a script for use.
|
||||
*
|
||||
* @uses wp_enqueue_script()
|
||||
* @access private
|
||||
* @param string $handle [description]
|
||||
* @param string $path [description]
|
||||
* @param string[] $deps [description]
|
||||
* @param string $version [description]
|
||||
* @param boolean $in_footer [description]
|
||||
* @param string $handle [description]
|
||||
* @param string $path [description]
|
||||
* @param string[] $deps [description]
|
||||
* @param string $version [description]
|
||||
* @param boolean $in_footer [description]
|
||||
*/
|
||||
private static function enqueue_script( $handle, $path = '', $deps = array( 'jquery' ), $version = WC_VERSION, $in_footer = true ) {
|
||||
if ( ! in_array( $handle, self::$scripts ) && $path ) {
|
||||
|
@ -100,8 +103,6 @@ class WC_Frontend_Scripts {
|
|||
|
||||
/**
|
||||
* Register/queue frontend scripts.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public static function load_scripts() {
|
||||
global $post;
|
||||
|
@ -184,7 +185,7 @@ class WC_Frontend_Scripts {
|
|||
/**
|
||||
* Localize a WC script once.
|
||||
* @access private
|
||||
* @since 2.3.0 this needs less wp_script_is() calls due to https://core.trac.wordpress.org/ticket/28404 being added in WP 4.0.
|
||||
* @since 2.3.0 this needs less wp_script_is() calls due to https://core.trac.wordpress.org/ticket/28404 being added in WP 4.0.
|
||||
* @param string $handle
|
||||
*/
|
||||
private static function localize_script( $handle ) {
|
||||
|
@ -196,7 +197,7 @@ class WC_Frontend_Scripts {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return data for script handles
|
||||
* Return data for script handles.
|
||||
* @access private
|
||||
* @param string $handle
|
||||
* @return array|bool
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Post types
|
||||
* Post Types
|
||||
*
|
||||
* Registers post types and taxonomies
|
||||
*
|
||||
* @class WC_Post_types
|
||||
* @version 2.2.0
|
||||
* @package WooCommerce/Classes/Products
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
* @class WC_Post_types
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes/Products
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WC_Post_types Class
|
||||
*/
|
||||
class WC_Post_types {
|
||||
|
||||
/**
|
||||
* Hook in methods
|
||||
* Hook in methods.
|
||||
*/
|
||||
public static function init() {
|
||||
add_action( 'init', array( __CLASS__, 'register_taxonomies' ), 5 );
|
||||
|
@ -28,7 +31,7 @@ class WC_Post_types {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register WooCommerce taxonomies.
|
||||
* Register core taxonomies.
|
||||
*/
|
||||
public static function register_taxonomies() {
|
||||
if ( taxonomy_exists( 'product_type' ) ) {
|
||||
|
@ -40,16 +43,16 @@ class WC_Post_types {
|
|||
$permalinks = get_option( 'woocommerce_permalinks' );
|
||||
|
||||
register_taxonomy( 'product_type',
|
||||
apply_filters( 'woocommerce_taxonomy_objects_product_type', array( 'product' ) ),
|
||||
apply_filters( 'woocommerce_taxonomy_args_product_type', array(
|
||||
'hierarchical' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'query_var' => is_admin(),
|
||||
'rewrite' => false,
|
||||
'public' => false
|
||||
) )
|
||||
);
|
||||
apply_filters( 'woocommerce_taxonomy_objects_product_type', array( 'product' ) ),
|
||||
apply_filters( 'woocommerce_taxonomy_args_product_type', array(
|
||||
'hierarchical' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'query_var' => is_admin(),
|
||||
'rewrite' => false,
|
||||
'public' => false
|
||||
) )
|
||||
);
|
||||
|
||||
register_taxonomy( 'product_cat',
|
||||
apply_filters( 'woocommerce_taxonomy_objects_product_cat', array( 'product' ) ),
|
||||
|
@ -210,7 +213,7 @@ class WC_Post_types {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register core post types
|
||||
* Register core post types.
|
||||
*/
|
||||
public static function register_post_types() {
|
||||
if ( post_type_exists('product') ) {
|
||||
|
@ -404,7 +407,7 @@ class WC_Post_types {
|
|||
}
|
||||
|
||||
/**
|
||||
* Register our custom post statuses, used for order status
|
||||
* Register our custom post statuses, used for order status.
|
||||
*/
|
||||
public static function register_post_status() {
|
||||
register_post_status( 'wc-pending', array(
|
||||
|
@ -466,13 +469,13 @@ class WC_Post_types {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add Product Support to Jetpack Omnisearch
|
||||
*/
|
||||
public static function support_jetpack_omnisearch() {
|
||||
if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
|
||||
new Jetpack_Omnisearch_Posts( 'product' );
|
||||
}
|
||||
}
|
||||
* Add Product Support to Jetpack Omnisearch.
|
||||
*/
|
||||
public static function support_jetpack_omnisearch() {
|
||||
if ( class_exists( 'Jetpack_Omnisearch_Posts' ) ) {
|
||||
new Jetpack_Omnisearch_Posts( 'product' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WC_Post_types::init();
|
||||
|
|
|
@ -21,15 +21,15 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
|
||||
parent::setUp();
|
||||
|
||||
// add custom factories
|
||||
// Add custom factories
|
||||
$this->factory = new WC_Unit_Test_Factory();
|
||||
|
||||
// setup mock WC session handler
|
||||
// Setup mock WC session handler
|
||||
add_filter( 'woocommerce_session_handler', array( $this, 'set_mock_session_handler' ) );
|
||||
|
||||
$this->setOutputCallback( array( $this, 'filter_output' ) );
|
||||
|
||||
// register post types before each test
|
||||
// Register post types before each test
|
||||
WC_Post_types::register_post_types();
|
||||
WC_Post_types::register_taxonomies();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
* Mock the WC session using the abstract class as cookies are not available
|
||||
* during tests
|
||||
*
|
||||
* @since 2.2
|
||||
* @since 2.2
|
||||
* @return string
|
||||
*/
|
||||
public function set_mock_session_handler() {
|
||||
|
@ -64,7 +64,7 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
* Asserts thing is not WP_Error
|
||||
*
|
||||
* @since 2.2
|
||||
* @param mixed $actual
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*/
|
||||
public function assertNotWPError( $actual, $message = '' ) {
|
||||
|
@ -74,7 +74,7 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
/**
|
||||
* Asserts thing is WP_Error
|
||||
*
|
||||
* @param $actual
|
||||
* @param mixed $actual
|
||||
* @param string $message
|
||||
*/
|
||||
public function assertIsWPError( $actual, $message = '' ) {
|
||||
|
@ -84,9 +84,9 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
/**
|
||||
* Backport assertNotFalse to PHPUnit 3.6.12 which only runs in PHP 5.2
|
||||
*
|
||||
* @since 2.2
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @since 2.2
|
||||
* @param $condition
|
||||
* @param string $message
|
||||
* @return mixed
|
||||
*/
|
||||
public static function assertNotFalse( $condition, $message = '' ) {
|
||||
|
|
Loading…
Reference in New Issue