Skip to content
Pierre Saikali edited this page Oct 27, 2018 · 3 revisions

Hooks in WP Timeliner

Many hooks are available in the plugin code to change its default behaviour or extend its logic.

If you think that a vital hook is missing, just let us know by creating an issue and we will fix this!

Filters

wpt.achievements.color_palette

Allows changing the predefined color palette displayed in the "Main color" Achievement field.

  • Type: array
  • Default value: [ '#00171F', '#5BC0EB', '#FDE74C', '#9BC53D', '#FA7921', '#D90429', '#7D5CD1', '#FF80D9' ]
  • Extra params: none

wpt.timeline.themes

Allows extending the list of Timeline themes available. See the custom theme plugin repo for a practical example.

  • Type: associative array (key is a theme slug, value is an instance of a Abstract_Theme-extended class object)
  • Default value: [ 'minimalist' => new \WP_Timeliner\Themes\Minimalist\Minimalist_Theme(), 'snake' => new \WP_Timeliner\Themes\Snake\Snake_Theme() ]
  • Extra params: none

wpt.template.locate

Allows changing the path to a template file that will be loaded by the plugin. Useful to force a different location for the taxonomy-wpt-timeline.php template file if necessary.

  • Type: string
  • Default value: $template
  • Extra params: $template_name, $template_path, $default_path

wpt.theme.load_fontawesome

Allows disabling the loading of FontAwesome icon webfont.

  • Type: boolean
  • Default value: true
  • Extra params: none

wpt.theme.load_theme_css

Allows disabling the loading of a specific timeline theme CSS.

  • Type: boolean
  • Default value: true
  • Extra params: $theme_slug

wpt.theme.load_compatibility_hooks

Allows disabling the loading of current-theme-compatibility logic provided by the plugin.

  • Type: boolean
  • Default value: true
  • Extra params: $current_theme

wpt.timeline.date_format

Allows changing the date format used for displaying the achievement date on a timeline.

  • Type: string: A valid PHP date format.
  • Default value: $date_format
  • Extra params: $timeline_date_format, $achievement, $timeline

wpt.timeline.date_string_format_for_one_date

Allows changing the formatting of a date computed-string when displaying only one start date.

  • Type: string: A sprintf()-friendly string
  • Default value: %1$s
  • Extra params: $timeline_date_format, $achievement, $timeline

wpt.timeline.date_string_format_for_two_dates

Allows changing the formatting of a date computed-string when displaying a start and an end date.

  • Type: string: A sprintf()-friendly string
  • Default value: From %1$s to %2$s
  • Extra params: $timeline_date_format, $achievement, $timeline

wpt.metaboxes.achievement

Allows adding new metaboxes to Achievement admin pages. Requires an id and a title.

  • Type: array
  • Default value: $metaboxes: The Achievement plugin default metaboxes
  • Extra params: none
  • Example:
function alter_achievement_metaboxes( $metaboxes ) {
	$metaboxes[] = [
		'id' => 'new_metabox',
		'title' => 'My new Achievement metabox!',
	];

	return $metaboxes;
}
add_filter( 'wpt.metaboxes.achievement', 'alter_achievement_metaboxes', 10 );

wpt.metaboxes.timeline

Allows adding new metaboxes to Timeline admin pages. Requires an id and a title.

  • Type: array
  • Default value: $metaboxes: The Timeline plugin default metaboxes
  • Extra params: none
  • Example: see above

wpt.fields.achievement.{$metabox_id}

Allows adding fields to your newly registered metabox on Achievement admin pages.

function alter_achievement_fields( $fields ) {
	$fields[] = Carbon_Fields\Field\Field::make( 'text', 'new_field', 'My new field!' );

	return $fields;
}
add_filter( 'wpt.fields.achievement.new_metabox', 'alter_achievement_fields', 10 );

wpt.fields.timeline.{$metabox_id}

Allows adding fields to your newly registered metabox on Timeline admin pages.


Actions

TODO !

wpt.template.before-inclusion

wpt.template.after-inclusion

wpt.template.before-header

wpt.template.after-header

wpt.template.before-loop

wpt.timeline.after-loop

wpt.template.start-loop-item

wpt.template.end-loop-item

wpt.template.before-no-achievement-found

wpt.template.after-no-achievement-found

wpt.timeline.after-footer