WordPress: common sources codes with many WP sites

Publicidad Google

WordPress Plugin WP_common_sources

Sharing source code with several sites has lots of advantages, you only write 1 time in the shared CSS file and styles are apply to all websites, a PHP function, JavaScript code or even plugins installed manually on shared directory are instantly available for all instances of WordPress, and with the same configurations.

The plugin to to share sources codes need be installed on every site:

Plugin file wp_common_sources.php

  Plugin Name: wp_common_sources
  Plugin URI:
  Description: WordPress: common sources codes with many WP sites
  Version: 1
  Author: Ernesto Bustos
  Author URI:

function get_domain(){
        $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
        $protocol = 'http';
    return $protocol . "://" . $_SERVER['HTTP_HOST'];

function wp_common_sources_scripts() {

    // share common CSS file
    wp_enqueue_style( 'wp_common_sources', get_domain() + '/wp_common_sources/wp_common_sources.css', array(), '1.0.0' );

    // share common JS file
    wp_enqueue_script( 'wp_common_sources-script', get_domain() +  '/wp_common_sources/wp_common_sources.js', array(), '1.0.0', true );
add_action( 'wp_enqueue_scripts', 'wp_common_sources_scripts' );

// share common PHP file (shared "function.php")
include_once $_SERVER["DOCUMENT_ROOT"] . "/wp_common_sources/wp_common_sources_common.php";

Download plugin (do save link as) wp_common_sources.php and change html by php extension.

Put your mains files in:


Add directories like;