Skip to content

Actions & Filters

Jory Hogeveen edited this page Dec 8, 2021 · 27 revisions

Filters

ocs_website_before_hook & ocs_website_after_hook

Change the before and after hooks with filters. This will disable the option on the settings page.

@since  0.3
@param  string  $hook  The hook name/identifier
@return string  $hook

ocs_website_before_hook_priority & ocs_website_after_hook_priority

Change the before and after hook priority.

Default priorities:

  • ocs_website_before_hook_priority: 5
  • ocs_website_after_hook_priority: 50 (in case of wp_footer: -50)
@since  0.5.3
@param  int  $priority  The hook priority
@return int  $priority

ocs_sidebar_classes

Filter the classes for a sidebar

@since  0.3
@see    OCS_Off_Canvas_Sidebars_Settings::$default_sidebar_settings for the sidebar settings
@param  array   $classes       Classes
@param  string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param  array   $sidebar_data  The sidebar settings
@return array   $classes

ocs_register_sidebar_args

Filter the register_sidebar arguments
Please note that the ID will be overwritten!

@since  0.3
@see    https://codex.wordpress.org/Function_Reference/register_sidebar
@see    OCS_Off_Canvas_Sidebars_Settings::$default_sidebar_settings for the sidebar settings
@param  array   $args          The register_sidebar() arguments
@param  string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param  array   $sidebar_data  The sidebar settings
@return array   $args

ocs_wp_nav_menu_args

Filter nav menu arguments
Please note that the ID will be overwritten!

@since  0.3
@see    https://developer.wordpress.org/reference/functions/wp_nav_menu/
@see    OCS_Off_Canvas_Sidebars_Settings::$default_sidebar_settings for the sidebar settings
@param  array   $args          The wp_nav_menu() arguments
@param  string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param  array   $sidebar_data  The sidebar settings
@return array   $args

ocs_is_sidebar_enabled

Filter whether an off-canvas sidebar should be rendered.

@since   0.5.2
@param   bool    $enabled       True if the sidebar is enabled in the sidebar settings, false otherwise.
@param   string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param   array   $sidebar_data  The sidebar settings
@return  bool

ocs_default_settings

Change the default settings.

@since   0.5.6
@param   array  $settings  The default settings.
@return  array

ocs_default_sidebar_settings

Change the default sidebar settings.

@since   0.5.6
@param   array  $settings  The default sidebar settings.
@return  array

ocs_inline_styles

Modify the inline styles.

@since   0.5.8
@param   string  $css     The rendered inline styles.
@param   string  $prefix  The CSS prefix.
@return  string

Actions

ocs_container_before

Add content before the site container

ocs_container_inner_before

Add content before other content in the site container

ocs_container_inner_after

Add content after other content in the site container

ocs_container_after

Add content after the site container


ocs_custom_content_sidebar_before & ocs_custom_content_sidebar_after

Add content before or after an off canvas sidebar

@since  0.3
@see    OCS_Off_Canvas_Sidebars_Settings::$default_sidebar_settings for the sidebar settings
@param  string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param  array   $sidebar_data  The sidebar settings

ocs_custom_content_sidebar_{$sidebar_id}

Action to hook into the sidebar content instead of using a WP Sidebar of WP Menu

@since  0.3
@see    OCS_Off_Canvas_Sidebars_Settings::$default_sidebar_settings for the sidebar settings
@param  string  $sidebar_id    The ID of this sidebar as configured in: Appearances > Off-Canvas Sidebars > Sidebars
@param  array   $sidebar_data  The sidebar settings