WPML
add_action( 'wpml_loaded', callable $function_to_add );
类型
action
类别
杂项
WPML 版本
3.2.1

说明

  • 为了确保依赖 WPML 的代码在正确的时间执行,应将该代码挂钩到 wpml_loaded 操作。该操作在 WPML 完全配置并加载后被调用。
  • 如果我们不挂钩到 wpml_loaded,有时依赖 WPML 的代码可能会被过早调用。这样一来,即使 WPML 已激活并配置完成,我们也可能无法获得预期的结果。
  • wpml_loadedplugins_loaded 操作期间执行。
  • WPML 字符串翻译 wpml_st_loaded 和 WPML 翻译管理 wpml_tm_loaded 也有类似的钩子。它们都挂钩到 wpml_loaded

参数

$function_to_add
(callable) (必填) 应用过滤器时要运行的回调。

使用示例

示例
function my_plugin_wpml_code() {
  // Run WPML dependent actions
  // These actions will be executed right after WPML is fully configured and loaded.
}

add_action( 'wpml_loaded', 'my_plugin_wpml_code' );

icl_ls_languages, wpml_sync_custom_field_copied_value, wpml_ls_enable_ajax_navigation, wpml_element_type, wpml_setting, wpml_sub_setting, wpml_exclude_post_from_auto_translate, wpml_forms_config_ninja-forms, wpml_forms_config_wpforms, wpml_tf_feedback_open_link

所有 30 个 杂项 钩子 →