سؤال

Is it possible to erase user-defined function?

My CMS has one function, which I want to update with additions.

Trying to add some code to theme's code, that would make my code work only when this theme is switched on.

هل كانت مفيدة؟

المحلول

Try rename_function() to rename the function you want to override to something else and then write the function under the original name.

نصائح أخرى

Do not include or launch that code until the required theme is chosen.

My code for Default Theme from functions.php:

<?php
function sample()
{
    // the specific code here
}

Somewhere in the theme bootstrapping:

<?php
include 'functions.php';
sample();

// OR inside a theme.

if ($theme_name == 'default')
{
    // Call the function
    sample();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top