Due to some custom modifications in the hierarchical_select module I need to be able to override the the taxonomy_field_validate function in the core taxonomy module.
I've tried creating a function in a custom module called MYMODULE_taxonomy_field_validate which it doesn't pick up on and I tried changing the field settings, but that changes how the data is stored in the database and it needs to be kept as a taxonomy term.
Any other ideas?
You need to unset this function on form validation.
In your module, write a hook_form_alter implementation and write this code inside
unset($form['#validate']['taxonomy_field_validate']);
Hope this works.
Related
I am currently developing a prestashop module where the user can add as many visual elements (an accordion) as he wishes. I finished the configuration of the back office with my own database, everything is ok on that side.
The problem comes from the fact that depending on the hook chosen by the user (displayHome or a custom hook) the visual element will be added to it.
During my testing phases, I managed to display the corresponding visual rendering on the displayHome hook, via this method in my main file :
public function hookDisplayHome($params)
{
$this->context->smarty->assign([
//...
]);
return $this->display(__FILE__, 'my_file.tpl');
}
The prestashop documentation for the FrontController explains how to configure it for visual rendering on a custom page, but nothing related to hooks.
I tried a similar process with the initContent() method but it doesn't seem to work.
I think that if() will be enough to assign the variables to different places according to the choice of the user. But if I can't just display it, I won't be able to think about it anyway.
How to interact with hooks via the FrontController ?
I have customized some wp-option return values with the dynamic pre_option_{option} hook and for completeness would like to also override these option values when they are returned via wp_load_alloptions(). This function has a hook that is available to allow for this customization: pre_cache_alloptions.
However, although the hook exists there doesn't appear to be any way to call add_filter("pre_cache_alloptions", ...) early enough for it to take effect before the first call to wp_load_alloptions(). Since wp_load_alloptions() is called very early when loading WordPress, and since the values are cached on first-call, I haven't been able to register the hook in time for it to take effect. I have tried calling add_filter("pre_cache_alloptions", ...) during a mu-plugin load and also in a custom theme functions.php file, but neither of those places appear to hook in early enough for this to work.
The only solution I have found so far is to hack the actual wp-includes\plugin.php file and add in the add_filter("pre_cache_alloptions", ...) call right after the require of class-wp-hook.php at the top. This does work as expected when registered at that code point... but I'm searching for a way to register this filter so that it works without altering the core WordPress code.
Since this hook must be registered after the add_filter() function is declared in plugin.php, but before the first call to wp_load_alloptions(), the only user-customizable code point that appears to work is the optional custom db.php file, which is loaded in wp-settings via require_wp_db(). Adding a custom wp-content/db.php file with the necessary add_filter("pre_cache_alloptions", ...) reference at the top works as a means to register this customization in time for it to be useful. After much searching, this appears to be the only way to handle this without mucking with the core itself.
I'm working on my own store, and I want to add some custom functionality. But this functionality is not something standalone, so I'd prefer to completely implemented via overriding controllers/classes and not to create a separate module for this.
But I have to use some hooks (for example - displayAdminProductsExtra to add new tab to admin product page, or actionProductAdd/actionProductUpdate to make some custom edits to DB). I know the way to use hooks from within the modules, but I cant find the way to do without creating my own module).
So the question - is there a way to do so?
Thanks in advance.
Hooks are only meant to be used with modules.
When Hook::exec() is called it will first check if a module is attached to this hook and stop otherwise.
Here is the related code:
// If no modules associated to hook_name or recompatible hook name, we stop the function
if (!$module_list = Hook::getHookModuleExecList($hook_name)) {
return '';
}
I am new to plugin development/editing with Wordpress. I am using a famous plugin called Polylang for multilingual support.
And I am using another plugin called Clean and Simple contact form for creating an AJAX based contact form.
Now, looking into the documentation for Polylang I have found the following function:
Register String
Allows plugins to add their own strings in the “strings translation” panel. The function must be called on admin side (the functions.php file is OK for themes).
Usage:
pll_register_string($name, $string, $multiline);
As it says, function must be called on admin side. I am unable to figure out what that means ...
I intend to add a few custom strings to the strings translation tab. Calling this function from functions.php in the theme worked but didn't translate strings from the plugin. The plugin doesn't yet support Japanese so I am having to take this path.
Can you tell me where exactly am I supposed to call this function. I tried to call it in class.view.php and the file with the name: clean-and-simple-contact-form-by-meg-nicholas.php
But, both ended up giving a fatal error saying that the function is undefined. What's the exact meaning of "The function must be called on admin side of a plugin..."
Thanks and Regards !
You might need to adjust your ajax plugin, so the function gets called in the admin. (I don't really know the ajax plugin but I am sure that there is some configuration part, which will be called somewhere in the admin panel)
Another way would be to create another plugin, which is just taking care of that function call. Just be sure, that this new plugin has some link you can call from the admin, so it is run in the right userspace.
I want to override prestashop's default front-office template and controller in my newly created module without modifying prestashop's internal code/structure.
Example :
I have created one module i.e. "mymodule" in /modules folder where I want use prestashop's address form (address.tpl).
see : http://demo-store.prestashop.com/en/address.
I want to enhance address form by providing some additional fields/functionality but without changing prestashop's core functionality.
So, How can I override its controller/themes/templates in my module? I have searched lot of about this on google but didn't found anything :(
Any help would be appreciated.
Modules can work like you ask only if there's an HOOK inside the template/controller that allow you to run your customized function. Look if you have a chance of hooking your module somewhere by watching on the list showed inside
backoffice > modules > position
the Address controllers hasn't got any Hook if i recall well, so you have 3 ways to edit its functionality:
Go for an (imho) horrible client-side modification, by an heavy usage of jquery/ajax call to perform the action you need. Place the code by using a module that only add your js script in the header by using the hookHeader() function. Since this hook it's always called in all the site you can exploit the missing hook in the address template.
add yourself an hook inside the Controller and the template by following this procedure: http://www.prestashop.com/forums/topic/218291-create-custom-and-new-hook-in-ps-15/
use the amazing override features of the prestashop framework to modify what you need in the Controller file placed inside your prestashop_root/override/controllers/front/AddressController.php and inside your /prestashop_root/themes/my_theme/address.tpl. this way you can ovverride any function of the Controller withouth loosing the original functionality and if you'll need to upgrade your installation you will just need to check for the function you changed in the overrided file just as you would do for your module.