PluginProbe
wpForo Forum / 3.0.9
wpForo Forum v3.0.9
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / integrations / functions.php

functions.php in wpForo Forum 3.0.9, at integrations/functions.php

139 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use wpforo\integrations\BuddyPress as wpForoBuddyPress;
4
5 // Exit if accessed directly
6 if( ! defined( 'ABSPATH' ) ) exit;
7
8 function wpforo_has_shop_plugin() {
9 $profile_url = false;
10 if( is_user_logged_in() ) {
11 // WooCommerce | Account Page URL
12 if( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
13 $profile_url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );
14 }
15 }
16
17 return $profile_url;
18 }
19
20 function wpforo_has_profile_plugin( $userid = 0 ) {
21 $profile_url = false;
22 if( $userid ) {
23 // Ultimate Member | Profile Page URL
24 if( function_exists( 'UM' ) ) {
25 um_fetch_user( $userid );
26 $profile_url = um_user_profile_url();
27 um_reset_user();
28 } // BuddyPress | Profile Page URL
29 elseif( class_exists( 'BuddyPress' ) ) {
30 $profile_url = bp_members_get_user_url( $userid );
31 } // Users Ultra | Profile Page URL
32 elseif( class_exists( 'XooUserUltra' ) ) {
33 global $xoouserultra;
34 $profile_url = $xoouserultra->userpanel->get_user_profile_permalink( $userid );
35 }
36 // User Pro | Profile Page URL
37 if( class_exists( 'userpro_api' ) ) {
38 global $userpro;
39 $profile_url = $userpro->permalink( $userid );
40 }
41 }
42
43 return $profile_url;
44 }
45
46 add_action( 'wpforo_actions_end', function() {
47 if( ! wpforo_setting( 'seo', 'seo_meta' ) ) return;
48
49 if( is_wpforo_page() && ! is_wpforo_shortcode_page() ) {
50 remove_action( 'wp_head', 'jetpack_og_tags' ); // JetPack}
51 if( defined( 'WPSEO_VERSION' ) ) { // Yoast SEO
52 remove_action( 'wp_head', 'wpseo_head', 20 );
53 remove_action( 'wp_head', 'wpseo_opengraph', 20 );
54 add_filter( 'wpseo_canonical', '__return_false' );
55 add_filter( 'wpseo_title', '__return_false' );
56 add_filter( 'wpseo_metadesc', '__return_false' );
57 add_filter( 'wpseo_author_link', '__return_false' );
58 add_filter( 'wpseo_metakey', '__return_false' );
59 add_filter( 'wpseo_locale', '__return_false' );
60 add_filter( 'wpseo_opengraph_title', '__return_false' );
61 add_filter( 'wpseo_opengraph_url', '__return_false' );
62 add_filter( 'wpseo_opengraph_desc', '__return_false' );
63 add_filter( 'wpseo_opengraph_author_facebook', '__return_false' );
64 add_filter( 'wpseo_opengraph_type', '__return_false' );
65 add_filter( 'wpseo_opengraph_image', '__return_false' );
66 add_filter( 'wpseo_opengraph_image_size', '__return_false' );
67 add_filter( 'wpseo_opengraph_site_name', '__return_false' );
68 add_filter( 'wpseo_twitter_card_type', '__return_false' );
69 add_filter( 'wpseo_twitter_description', '__return_false' );
70 add_filter( 'wpseo_twitter_title', '__return_false' );
71 add_filter( 'wpseo_twitter_image', '__return_false' );
72 add_filter( 'wpseo_twitter_image_size', '__return_false' );
73 add_filter( 'wp_seo_get_bc_ancestors', '__return_false' );
74 add_filter( 'wpseo_whitelist_permalink_vars', '__return_false' );
75 add_filter( 'wpseo_prev_rel_link', '__return_false' );
76 add_filter( 'wpseo_next_rel_link', '__return_false' );
77 add_filter( 'wpseo_xml_sitemap_img_src', '__return_false' );
78 add_filter( 'wpseo_json_ld_output', '__return_false' );
79 }
80 if( function_exists( 'aioseo' ) || defined( 'AIOSEOP_VERSION' ) ) { // All-In-One SEO
81 if( array_key_exists( 'aiosp', $GLOBALS ) ) {
82 global $aiosp;
83 remove_action( 'wp_head', [ $aiosp, 'wp_head' ] );
84 add_filter( 'aioseop_title', '__return_false' );
85 add_filter( 'aioseop_canonical_url', '__return_false' );
86 } else {
87 add_filter( 'aioseo_disable', '__return_true' );
88 }
89 }
90 remove_action( 'wp_head', 'rel_canonical' );
91 remove_action( 'wp_head', 'index_rel_link' );
92 remove_action( 'wp_head', 'start_post_rel_link' );
93 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
94 remove_all_filters( 'pre_get_document_title', 15 );
95 }
96 } );
97
98 //Stops Rank Math SEO overwriting wpForo SEO
99 add_action( 'wpforo_after_init', function() {
100 if( ! wpforo_setting( 'seo', 'seo_meta' ) ) return;
101 if( is_wpforo_page() && ! is_wpforo_shortcode_page() ) {
102 if( defined( 'RANK_MATH_FILE' ) ) {
103 add_filter( 'rank_math/frontend/remove_credit_notice', '__return_true' );
104 remove_all_actions( 'rank_math/head' );
105 remove_all_filters( 'pre_get_document_title', 15 );
106 add_action( 'wp_head', '_wp_render_title_tag', 1 );
107 }
108 }
109 } );
110
111 ////////////////////////////////////////////////////////////////////////////////////////
112 // BuddyPress Integration //////////////////////////////////////////////////////////////
113 ////////////////////////////////////////////////////////////////////////////////////////
114 add_action( 'bp_init', function() {
115 if( ! function_exists( 'buddypress' ) ) {
116 function buddypress() { return isset( $GLOBALS['bp'] ) ? $GLOBALS['bp'] : false; }
117 }
118 if( ! buddypress() || buddypress()->maintenance_mode ) return;
119 require( WPFORO_DIR . '/integrations/BuddyPressHooks.php' );
120 if( wpforo_setting( 'buddypress', 'forum_tab' ) ) {
121 new wpForoBuddyPress();
122 }
123 if( wpforo_setting( 'profiles', 'profile' ) === 'bp' ) {
124 add_filter( 'wpforo_member_profile_url', 'wpforo_bp_profile_url', 10, 3 );
125 }
126 }, 0 );
127
128 ////////////////////////////////////////////////////////////////////////////////////////
129 // General Data Protection Regulation (GDPR) ///////////////////////////////////////////
130 ////////////////////////////////////////////////////////////////////////////////////////
131 include( WPFORO_DIR . '/integrations/legal.php' );
132
133 ////////////////////////////////////////////////////////////////////////////////////////
134 // Ultimate Member Integration /////////////////////////////////////////////////////////
135 ////////////////////////////////////////////////////////////////////////////////////////
136 if( class_exists( 'UM' ) ){
137 include( WPFORO_DIR . '/integrations/UltimateMember.php' );
138 }
139