Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. // My Store link to WCVendors Pro dashboard
  2. if ( class_exists('WCV_Vendors') && class_exists('WCVendors_Pro') && WCV_Vendors::is_vendor( get_current_user_id() ) ) {
  3. add_action( 'wp_enqueue_scripts', function() {
  4. wp_add_inline_script( 'c27-main', sprintf(
  5. "jQuery('.user-menu-my-store a, .woocommerce-MyAccount-navigation-link--my-store a').attr('href', %s);",
  6. json_encode( get_permalink( WCVendors_Pro::get_option( 'dashboard_page_id' ) ) )
  7. ) );
  8. }, 100 );
  9. }
  10.  
  11.  
  12. add_action( 'init', function() {
  13. if ( class_exists( 'WCV_Admin_Users' ) ) {
  14. // @link https://gist.github.com/tripflex/c6518efc1753cf2392559866b4bd1a53
  15. function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
  16. global $wp_filter;
  17. if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
  18. if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
  19. $fob = $wp_filter[ $tag ];
  20. $callbacks = &$wp_filter[ $tag ]->callbacks;
  21. } else { $callbacks = &$wp_filter[ $tag ]; }
  22. if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
  23. foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
  24. if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
  25. if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
  26. if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
  27. if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
  28. if( isset( $fob ) ){
  29. $fob->remove_filter( $tag, $filter['function'], $priority );
  30. } else {
  31. unset( $callbacks[ $priority ][ $filter_id ] );
  32. if ( empty( $callbacks[ $priority ] ) ) {
  33. unset( $callbacks[ $priority ] );
  34. }
  35. if ( empty( $callbacks ) ) {
  36. $callbacks = array();
  37. }
  38. unset( $GLOBALS['merged_filters'][ $tag ] );
  39. }
  40. return TRUE;
  41. }
  42. }
  43. return FALSE;
  44. }
  45.  
  46. remove_class_filter( 'product_type_selector', 'WCV_Admin_Users', 'filter_product_types', 99 );
  47. }
  48. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement