If you want to add custom code to the theme, then we suggest you to install and activate child theme. Otherwise, after each update of Kalium you have to re-insert that custom code you had previously used. Show
We occasionally ask our users to add custom code to their WordPress website to add simple features to GiveWP. We do this because 80% of GiveWP users don’t need that feature so we don’t want to add it to the core plugin. But where and how exactly are you supposed to add this custom code to your website? This article gives you an overview of why and how to do this right. Dispelling the Myths of Custom Code in WordPressExperienced developers know the best way to extend the functionality of a plugin is by adding their own code into what’s often called a “Functionality Plugin“. You might think that you can simply go into the plugin files and change them there. While it is true that you CAN do that, it’s not “best practice” because the next time your plugin is updated you will lose that custom code. Another thing you’ll often hear is that you should just put this code into your theme’s `functions.php` file. Again, while this will work, it’s not considered “best practice” because your site most likely will update it’s theme in the near future and again you’ll lose that added functionality to the plugin once your theme changes. So, the GiveWP Support team gave you some custom code to use on your website, or you pulled it from our documentation. But you CAN’T change the plugin, you can’t add it to your theme’s `functions.php` file, and you don’t know how to create a Functionality Plugin. What are you supposed to do? It is not “Best Practice” to put custom plugin code in your theme’s functions.php file. Use the “Code Snippets” pluginThe “Code Snippets” plugin is an easy and safe way to insert custom functions into your WordPress website without having to learn how to use a Custom Functionality plugin. It’s also recommend because it allows you to avoid potentially taking down the site if a custom snippet is missing some syntax or throws an error. You can avoid issues like this for example: This tool helps folks to avoid adding a snippet that breaks the site. Check your snippets before activating!To get started:
The snippets page includes some example snippets for reference, those can be deleted as needed. Included in those examples are snippets that can be helpful in sorting snippets on this page by name or by date if you plan to add multiple snippets. If needed, the snippet settings can be adjusted and configured under Snippets > Settings. This will allow you to adjust general settings and settings within the editors. Be sure to click “Save Changes” when finished. With Great Power Comes Great ResponsibilityWe provide this documentation in order to help our GiveWP users to add custom functions. Please be aware that this type of customization can create conflicts or issues on your website. We always highly recommend that you add custom functions in an environment that allows you to quickly undo what you’ve done without causing issues your live site. We also recomend you test thoroughly before going live. Here are a few important things to keep in mind
Last updated 1 year ago Thank you for your feedback! Loading... Sending feedback... There was an error recording your feedback. We have been notified and will look into the problem. Please try again later. Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Plugins can specify that one or more of its PHP functions are executed at these points, using the Action API. 0 string RequiredThe name of the action to add the callback to. 1 callable RequiredThe callback to be run when the action is called. 2 int OptionalUsed to specify the order in which the functions associated with a particular action are executed. Default: 3 4 int OptionalThe number of arguments the function accepts. Default: 5true Always returns true.
To find out the number and name of arguments for an action, simply search the code base for the matching do_action() call. For example, if you are hooking into ‘save_post’, you would find it in post.php:
Your add_action call would look like:
And your function would be:
File: 6. View all references
Adds a callback function to a filter hook. Hooks inline styles in the proper place, depending on the active theme. _wp_theme_json_webfonts_handler() wp-includes/script-loader.phpRuns the theme.json webfonts handler. wp_enqueue_block_style() wp-includes/script-loader.phpEnqueues a stylesheet for a specific block. locate_block_template() wp-includes/block-template.phpFinds a block template with equal or higher specificity than a given PHP template file. WP_Sitemaps::init() wp-includes/sitemaps/class-wp-sitemaps.phpInitiates all sitemap functionality. WP_Recovery_Mode::initialize() wp-includes/class-wp-recovery-mode.phpInitialize recovery mode for the current request. WP_Site_Health::__construct() wp-admin/includes/class-wp-site-health.phpWP_Site_Health constructor. wp_is_site_initialized() wp-includes/ms-site.phpChecks whether a site is initialized. register_and_do_post_meta_boxes() wp-admin/includes/meta-boxes.phpRegisters the default post meta boxes, and runs the 7 actions.WP_Privacy_Policy_Content::text_change_check() wp-admin/includes/class-wp-privacy-policy-content.phpQuick check if any privacy info has changed. WP_Roles::get_roles_data() wp-includes/class-wp-roles.phpGets the available roles data. WP_Widget_Text::_register_one() wp-includes/widgets/class-wp-widget-text.phpAdd hooks for enqueueing assets when registering all widget instances of this widget class. WP_Widget_Custom_HTML::_register_one() wp-includes/widgets/class-wp-widget-custom-html.phpAdd hooks for enqueueing assets when registering all widget instances of this widget class. WP_Widget_Media::_register_one() wp-includes/widgets/class-wp-widget-media.phpAdd hooks while registering all widget instances of this widget class. _WP_Editors::enqueue_default_editor() wp-includes/class-wp-editor.phpEnqueue all editor scripts. _wp_delete_customize_changeset_dependent_auto_drafts() wp-includes/nav-menu.phpDeletes auto-draft posts associated with the supplied changeset. WP_Customize_Manager::import_theme_starter_content() wp-includes/class-wp-customize-manager.phpImports theme starter content into the customized state. WP_Post_Type::register_meta_boxes() wp-includes/class-wp-post-type.phpRegisters the post type meta box if a custom callback was specified. WP_Post_Type::add_hooks() wp-includes/class-wp-post-type.phpAdds the future post hook action for the post type. WP_Customize_Widgets::selective_refresh_init() wp-includes/class-wp-customize-widgets.phpAdds hooks for selective refresh. WP_Customize_Selective_Refresh::init_preview() wp-includes/customize/class-wp-customize-selective-refresh.phpInitializes the Customizer preview. WP_Customize_Selective_Refresh::enqueue_preview_scripts() wp-includes/customize/class-wp-customize-selective-refresh.phpEnqueues preview scripts. WP_Customize_Selective_Refresh::__construct() wp-includes/customize/class-wp-customize-selective-refresh.phpPlugin bootstrap for Partial Refresh functionality. Registers the default REST API filters. WP_Customize_Setting::aggregate_multidimensional() wp-includes/class-wp-customize-setting.phpSet up the setting for aggregated multidimensional values. wp_admin_bar_customize_menu() wp-includes/admin-bar.phpAdds the “Customize” link to the Toolbar. WP_Widget_Factory::__construct() wp-includes/class-wp-widget-factory.phpPHP5 constructor. WP_Customize_Site_Icon_Control::__construct() wp-includes/customize/class-wp-customize-site-icon-control.phpConstructor. WP_Customize_Nav_Menu_Item_Setting::__construct() wp-includes/customize/class-wp-customize-nav-menu-item-setting.phpConstructor. WP_Customize_Nav_Menus::customize_preview_init() wp-includes/class-wp-customize-nav-menus.phpAdds hooks for the Customizer preview. WP_Customize_Nav_Menus::__construct() wp-includes/class-wp-customize-nav-menus.phpConstructor. WP_Site_Icon::__construct() wp-admin/includes/class-wp-site-icon.phpRegisters actions and filters. login_header() wp-login.phpOutput the login page header. Language_Pack_Upgrader::bulk_upgrade() wp-admin/includes/class-language-pack-upgrader.phpBulk upgrade language packs. Theme_Upgrader::install() wp-admin/includes/class-theme-upgrader.phpInstall a theme package. Theme_Upgrader::upgrade() wp-admin/includes/class-theme-upgrader.phpUpgrade a theme. Plugin_Upgrader::install() wp-admin/includes/class-plugin-upgrader.phpInstall a plugin package. Plugin_Upgrader::upgrade() wp-admin/includes/class-plugin-upgrader.phpUpgrade a plugin. WP_List_Table::__construct() wp-admin/includes/class-wp-list-table.phpConstructor. WP_Theme_Install_List_Table::prepare_items() wp-admin/includes/class-wp-theme-install-list-table.phpwp_plugin_update_rows() wp-admin/includes/update.phpAdds a callback to display update information for plugins with updates available. wp_theme_update_rows() wp-admin/includes/update.phpAdds a callback to display update information for themes with updates available. uninstall_plugin() wp-admin/includes/plugin.phpUninstalls a single plugin. add_menu_page() wp-admin/includes/plugin.phpAdds a top-level menu page. add_submenu_page() wp-admin/includes/plugin.phpAdds a submenu page. WP_Plugin_Install_List_Table::prepare_items() wp-admin/includes/class-wp-plugin-install-list-table.phpWP_Internal_Pointers::enqueue_scripts() wp-admin/includes/class-wp-internal-pointers.phpInitializes the new feature pointers. Custom_Image_Header::__construct() wp-admin/includes/class-custom-image-header.phpConstructor – Register administration header callback. Custom_Image_Header::init() wp-admin/includes/class-custom-image-header.phpSet up the hooks for the Custom Header admin page. Custom_Background::__construct() wp-admin/includes/class-custom-background.phpConstructor – Registers administration header callback. Custom_Background::init() wp-admin/includes/class-custom-background.phpSets up the hooks for the Custom Background admin page. WP_Customize_Manager::customize_preview_init() wp-includes/class-wp-customize-manager.phpPrints JavaScript settings. WP_Customize_Manager::setup_theme() wp-includes/class-wp-customize-manager.phpStarts preview and customize theme. WP_Customize_Manager::__construct() wp-includes/class-wp-customize-manager.phpConstructor. wp_cron() wp-includes/cron.phpRegister _wp_cron() to run on the {@see ‘wp_loaded’} action. _custom_header_background_just_in_time() wp-includes/theme.phpRegisters the internal custom header and background routines. add_thickbox() wp-includes/general-template.phpEnqueues the default ThickBox js and css. wp_auth_check_load() wp-includes/functions.phpLoads the auth check for monitoring whether the user is still logged in. wp_maybe_load_widgets() wp-includes/functions.phpDetermines if Widgets library should be loaded. Sets up a new Recent Comments widget instance. WP_Embed::__construct() wp-includes/class-wp-embed.phpConstructor WP_Admin_Bar::add_menus() wp-includes/class-wp-admin-bar.phpAdds menus to the admin bar. WP_Admin_Bar::initialize() wp-includes/class-wp-admin-bar.phpInitializes the admin bar. register_activation_hook() wp-includes/plugin.phpSet the activation hook for a plugin. register_deactivation_hook() wp-includes/plugin.phpSets the deactivation hook for a plugin. WP_Customize_Setting::preview() wp-includes/class-wp-customize-setting.phpAdd filters to supply the setting’s value when accessed. wp_enqueue_media() wp-includes/media.phpEnqueues all scripts, styles, settings, and templates necessary to use all media JS APIs. wp_playlist_scripts() wp-includes/media.phpOutputs and enqueues default scripts and styles for playlists. WP_Rewrite::wp_rewrite_rules() wp-includes/class-wp-rewrite.phpRetrieves the rewrite rules. WP_Rewrite::flush_rules() wp-includes/class-wp-rewrite.phpRemoves rewrite rules and then recreate rewrite rules. add_feed() wp-includes/rewrite.phpAdds a new feed type like /atom1/. WP_Scripts::__construct() wp-includes/class-wp-scripts.phpConstructor. WP_Customize_Header_Image_Control::prepare_control() wp-includes/customize/class-wp-customize-header-image-control.phpWP_Customize_Widgets::customize_preview_init() wp-includes/class-wp-customize-widgets.phpAdds hooks for the Customizer preview. WP_Customize_Widgets::__construct() wp-includes/class-wp-customize-widgets.phpInitial loader. WP_Customize_Widgets::schedule_customize_register() wp-includes/class-wp-customize-widgets.phpEnsures widgets are available for all types of previews. wp_set_comment_status() wp-includes/comment.phpSets the status of a comment. _WP_Editors::editor_settings() wp-includes/class-wp-editor.phpwp_print_media_templates() wp-includes/media-template.phpPrints the templates used in the media manager.
|