When using filter and actions, use a filter priority above 10. We apply most of our filters around 15 or 16. To apply filters before our plugin, use a filter below 15. To apply filters after ours, use a filter above 15.
Here are some of the filters available in the plugin. See the free colorbox addon for an example on creating an addon for the plugin.
This may not be a complete list. Please search through the code for apply_filters and do_action for more filters and actions.
Contents
Examples
add_action_once ( featured_image_pro_masonry_register_scripts’, ‘myaction', 16 );
function myaction()
{
dosomething();
}
add_filter_once ('proto_grid_container_class', ‘myfunction’, 16, 2);
function myfunction($class, $options)
{
$class = $class . $options[‘somesetting’];
}
Actions
Initialize before the grid is created
do_action(‘proto_image_pro_init’,
$options //array of widget options
);
Execute an action after the query
do_action(‘proto_masonry_after_query’,
$query, //query results
$attributes //the query attributes
);
Filters
Add a class to the grid container element
apply_filters('proto_grid_container_class',
$gridclass, //current grid class
$options //array of widget options
);
returns modified grid class
Extract options from the arguments sent to the widget
Use this to filter out your own options from the shortcode for later use.
Move options from the $args array to the $options array and return the $options array.
apply_filters('proto_masonry_options',
$options, //current array of options
$args //arguments sent to the widget
);
returns modified options
Insert additional styles into the inline styles
apply_filters('proto_inline_css’,
$styles, //current inline styles
$options //array of widget options
);
returns inline styles
You must encapsulate your scripts with script tags (note, this has changed since version 2 of the plugin)
$script = "
//some data
";
apply_filters('proto_masonry_footer_scripts',
$script, //current footer scripts
$options //array of widget options
);
returns footer scripts
Add a style to the inline styles for the excerpts
apply_filters('proto_masonry_excerptstyles',
$excerptstyle, //current inline styles for the excerpts
$options //array of widget options
);
returns inline styles for excerpts
apply_filters('proto_masonry_captionstyles',
$captionstyle, //current inline styles for the figcaption element
$options //array of widget options
);
returns styles for the figcaption element
Add a style to the inline styles for the grid items
apply_filters('proto_masonry_itemstyles',
$itemstyle, //current inline styles for the grid items
$options //array of widget options
);
returns styles for the grid items
Add a style to the inline styles for the grid
apply_filters('proto_masonry_gridstyles',
$gridstyle, //current inline styles for the grid
$options //array of widget options
);
returns styles for the grid
Add a style to the inline styles for the images
apply_filters('proto_masonry_imagestyles',
$imagestyle, //current inline styles for the grid items
$options //array of widget options
);
returns styles for the images
Insert options into the masonry json script
apply_filters('proto_masonry_script_options',
$script, //masonry script
$options //array of widget options
);
returns masonry script
Apply Filters to the title for specific posts
(replaces proto_image_pro_post_title)
apply_filters('proto_masonry_post_title',
$title, //post caption/title
$options, //array of widget options
$postid //post identifier
);
return title/caption
(replaces ‘proto_image_after_caption')
apply_filters('proto_masonry_post_caption',
$extra, //elements & text to be appended after the caption
$options, //array of widget options
$postid //the post ID
);
returns content to be displayed after the title/caption
Add/remove/change properties to an image object
(replaces ‘proto_snap_image_object')
apply_filters('proto_snap_post_object',
$img, //image object
$options, //array of widget options
$postid //the post ID );
returns image object
Add/remove/change properties to an attachment object
apply_filters('proto_masonry_attachments',
$attobject, //attachment option
$options, //array of widget options
$_query //WordPress query object
);
return attachment object
Remove Filters
Filters must be removed after every grid. Add an action to remove your filters.
apply_action('proto_masonry_remove_filters');