<commit_before><?php
/**
 * Plugin Name: Shared Post Type & Taxonomies Table + Uploads Folder
 * Plugin URI: https://www.f5sites.com/shared-wordpress-tables-posts-and-taxonomies
 * Description: Shared WordPress Tables Posts and Taxonomies for multiple wp install under multiple domains (using the same database), by default wp-config.php only can share users, limiting scalability. It is for advanced users and optimized for WordPress as composer package. Just create a wordpress category with the current site domain, like www.f5sites.com or www.franciscomat.com and it will only be displayed in the correct location Original project for use in f5sites fnetwork. (woocommerce, pdfcatalog, wpmu, buddypress, bp xprofile, projectimer ready)
 * Version: 1.1
 * Author: <NAME>
 * Author URI: https://www.franciscomat.com
 * License: Apache 2.0
 */


if(!is_network_admin()) {
	#need to be inserted in the that 3 hooks (and probably more)
	#if(is_admin())
	add_action( 'pre_get_posts', 'force_database_aditional_tables_share', 10, 2 );

	#if ( !is_woocommerce() ) {
		
		#add_action( 'wp_head', 'force_database_aditional_tables_share', 10, 2 );

		#if (! is_admin() )
		#add_action( 'after_setup_theme', 'force_database_aditional_tables_share', 10, 2 );	
	#}
	
	add_action( 'init', 'force_database_aditional_tables_share', 10, 2 );
	add_action( 'plugins_loaded', 'force_database_aditional_tables_share', 10, 2 );
	add_action( 'switch_blog', 'force_database_aditional_tables_share', 10, 2 );
		
	#shared upload dir, comment to un-share
	add_filter( 'upload_dir', 'shared_upload_dir' );

	#Work in progress for buddypress integration, some problems might occur with sensitivy user data, like user_blogs table, making impossible to cross-share between multiple installs, but it is a good start point
	#add_action( 'bp_loaded', 'buddypress_tables_share', 10, 2 );
}

#$settings = {#	"post_table":"1fnetwork_posts", "postmeta_table":"1fnetwork_postmeta"#}

function set_shared_database_schema() {
	global $wpdb;
	#var_dump($wpdb);
	#$olddbname = DB_NAME;
	#$wpdb = new wpdb( DB_USER, DB_PASSWORD, "pom<PASSWORD>os", DB_HOST );
	#define('DB_NAME', "pomodoros2");
	#require_wp_db();
	#wp_set_wpdb_vars();
	#die;
	#
	$wpdb->posts 				="1fnetwork_posts";
	$wpdb->postmeta 			="1fnetwork_postmeta";
	#
	$wpdb->comments 			="1fnetwork_comments";
	$wpdb->commentmeta 			="1fnetwork_commentmeta";
	#
	$wpdb->links 				="1fnetwork_links";
	#
	$wpdb->terms 				="1fnetwork_terms";
	$wpdb->term_taxonomy 		="1fnetwork_term_taxonomy";<commit_msg>new level of integration, buddypress, woocommerce, and base for more<commit_after><?php
/**
 * Plugin Name: Shared Post Type & Taxonomies Table + Uploads Folder
 * Plugin URI: https://www.f5sites.com/shared-wordpress-tables-posts-and-taxonomies
 * Description: Shared WordPress Tables Posts and Taxonomies for multiple wp install under multiple domains (using the same database), by default wp-config.php only can share users, limiting scalability. It is for advanced users and optimized for WordPress as composer package. Just create a wordpress category with the current site domain, like www.f5sites.com or www.franciscomat.com and it will only be displayed in the correct location Original project for use in f5sites fnetwork. (woocommerce, pdfcatalog, wpmu, buddypress, bp xprofile, projectimer ready)
 * Version: 1.1
 * Author: <NAME>
 * Author URI: https://www.franciscomat.com
 * License: Apache 2.0
 */


if(!is_network_admin()) {
	#need to be inserted in the that 3 hooks (and probably more)
	#if(is_admin())
	add_action( 'pre_get_posts', 'force_database_aditional_tables_share', 10, 2 );

	#if ( !is_woocommerce() ) {
		
		#add_action( 'wp_head', 'force_database_aditional_tables_share', 10, 2 );

		#if (! is_admin() )
		#add_action( 'after_setup_theme', 'force_database_aditional_tables_share', 10, 2 );	
	#}
	
	add_action( 'init', 'force_database_aditional_tables_share', 10, 2 );
	add_action( 'plugins_loaded', 'force_database_aditional_tables_share', 10, 2 );
	add_action( 'switch_blog', 'force_database_aditional_tables_share', 10, 2 );
		
	#shared upload dir, comment to un-share
	add_filter( 'upload_dir', 'shared_upload_dir' );

	#Work in progress for buddypress integration, some problems might occur with sensitivy user data, like user_blogs table, making impossible to cross-share between multiple installs, but it is a good start point
	#add_action( 'bp_loaded', 'buddypress_tables_share', 10, 2 );
	add_filter( 'nav_menu_link_attributes', 'filter_function_name', 10, 3 );
}

function filter_function_name( $atts, $item, $args ) {
    // Manipulate attributes
    //var_dump($args);
    return $atts;
}

#$settings = {#	"post_table":"1fnetwork_posts", "postmeta_table":"1fnetwork_postmeta"#}

function set_shared_database_schema() {
	global $wpdb;
	#var_dump($wpdb);
	#$olddbname = DB_NAME;
	#$wpdb = new wpdb( DB_USER, DB_PASSWORD, "pomodoros", DB_HOST );
	#define('DB_NAME', "pomodoros2");
	#require_wp_db();
	#wp_set_wpdb_vars();
	#die;
	#
	$wpdb->posts 				="1fnetwork_posts";
	$wpdb->postmeta 			="1fnetwork_postmeta";
	#
	$wpdb->comments 			="1fnetwork_comments";
	$wpdb->commentmeta 			="1fnetwork_commentmeta";
	#
	$wpdb->links 				="1fnetwork_links";
	#
	$wpdb->terms 				="1fnetwork_terms";
	$wpdb->term_taxonomy 		="1fnetwork_term_taxonomy";
{'fraction_non_alphanumeric': 0.12035465006602528, 'fraction_numerical': 0.015280135823429542, 'mean_word_length': 5.465853658536585, 'pattern_counts': {'":': 4, '<': 8, '<?xml version=': 0, '>': 20, 'https://': 4, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '256862', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1787, 'n_words': 483}