• Resolved mrcangrejero

    (@mrcangrejero)


    Hope I’m posting to the right place. My apologies if not. This is my issue:

    I have four different blogs on a multisites setup, each using the same child theme but with different Theme Name and slight variations on their style.css. This works OK.

    Now, each blog has, and will always have the same functions.php on its child theme. The problem is that, when I update one functions.php file, I have to update all four. I wonder if I can keep a centrally located functions.php where I can make changes and have each child theme’s functions.php read from that central file.

    Any guidance is appreciated. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator cubecolour

    (@numeeja)

    It might be better to take the shared functions out of functions.php and create a custom plugin instead

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Thanks, cubecolour, for your prompt response.

    I read, and tried to follow all the instructions at “How to write a WordPress plugin” and must confess that I failed.

    My PHP file has the following functions:

    function new_excerpt_more
    function twentythirteen_credits_handler_for_cangrejero
    function twentythirteen_entry_meta
    function twentythirteen_entry_date
    function cangrejero_custom_header_setup
    function cangrejero_remove_default_headers
    function cangrejero_add_headers

    I just don’t know how to incorporate them in the plugin.

    Hope you can help. If not, thanks anyway and the best to you.

    Moderator cubecolour

    (@numeeja)

    I notice you have some twentythirteen functions. Are you using a child theme or have you edited twentythirteen directly?

    Thread Starter mrcangrejero

    (@mrcangrejero)

    I’m using a child theme. Actually, four child themes.

    Moderator cubecolour

    (@numeeja)

    Can you paste the content of the functions.php file you have in one of your child themes into a pastebin at http://pastebin.com & post a link here to that here?

    Thread Starter mrcangrejero

    (@mrcangrejero)

    Pastebin link. Thanks!!

    Moderator cubecolour

    (@numeeja)

    You should be able to turn these functions into a new plugin by the following method. I don’t have a test multisite installation to test this on, but if there are any problems, we are not deleting anything so this is all reversible.

    • Connect to your site files by ftp
    • rename the functions.php in each child theme to old-functions.php
    • Create a new folder in your wp-content/plugins folder called ‘my-twentythirteen-functions’
    • In the new folder create a new file called my-twentythirteen-functions.php
    • copy the contents of your functions.php into this file
    • Edit the content you have just pasted into this file & save:
    • Replace
      <?php
      /**
       * Twenty Thirteen functions and definitions.
       *
       * Sets up the theme and provides some helper functions, which are used in the
       * theme as custom template tags. Others are attached to action and filter
       * hooks in WordPress to change core functionality.
       *
       * When using a child theme (see http://codex.wordpress.org/Theme_Development
       * and http://codex.wordpress.org/Child_Themes), you can override certain
       * functions (those wrapped in a function_exists() call) by defining them first
       * in your child theme's functions.php file. The child theme's functions.php
       * file is included before the parent theme's file, so the child theme
       * functions would be used.
       *
       * Functions that are not pluggable (not wrapped in function_exists()) are
       * instead attached to a filter or action hook.
       *
       * For more information on hooks, actions, and filters,
       * see http://codex.wordpress.org/Plugin_API
       *
       * @package WordPress
       * @subpackage Twenty_Thirteen
       * @since Twenty Thirteen 1.0
       */

      with

      <?php
      /*
      Plugin Name: My Functions plugin
      Description: My Functions for twentythirteen
      Version: 1.0.0
      */

    • Network activate this plugin
      Thread Starter mrcangrejero

      (@mrcangrejero)

      Thanks, cubecolour! Works like a charm.

    Viewing 8 replies - 1 through 8 (of 8 total)

    The topic ‘Centrally located functions.php; maybe?’ is closed to new replies.