Description:
The slidedeck_default_options filter can be hooked into to set the default options when a SlideDeck is being created for the first time and when it is being loaded. If a new option is added to SlideDeck by a source or lens that did not exist originally, this filter can be hooked into to provide a default value for pre-existing SlideDecks that do not have a setting for the new option.
This filter is intelligently hooked into automatically to provide new default options for lenses and sources by reading the $options_model Class property. For example, in the RSS content source, two additional options are added (rssImageSource and rssValidateImages) to the option set and defaults are set by reading the $options_model property of the RSS content source's PHP Class.
For example, you will find in the sources/rss/source.php file code that looks similar to this (this example code snippet has been simplified for the purposes of this example):
class SlideDeckSource_RSS extends SlideDeck { var $options_model = array( 'Setup' => array( 'rssImageSource' => array( 'name' => "rssImageSource", 'type' => "select", 'data' => "string", 'value' => 'enclosure', 'values' => array( 'none' => "No Image", 'content' => "First image in content", 'enclosure' => "Media attachment (RSS only)" ) ), 'rssValidateImages' => array( 'name' => 'rssValidateImages', 'type' => 'radio', 'data' => 'boolean', 'value' => true ) ) ); . . .
The $options_model Class property here is read automatically in this filter and sets a new option for RSS feed sourced SlideDecks to have an option called rssImageSource with a value of enclosure and an option named rssValidateImages with a value of boolean(true). This same format will also be automatically processed for any Lens or user created SlideDeck source.
Usage:
To modify the the default options of a SlideDeck, you would hook into this filter with the following code:
<?php add_filter( 'slidedeck_default_options', 'my_function_name', 10, 4 ); ?>
Parameters:
The slidedeck_default_options filter receives four parameters:
$default_options
(array) A one dimensional associative array of default options.
$type (deprecated)
(string) This value has been deprecated
$lens
(string) The lens used by the SlideDeck being loaded/created
$source
(array) An array of sources used by the SlideDeck being created or loaded
Return:
Return an associative array of options for the SlideDeck.
Located In File:
/classes/slidedeck.php
Comments
0 comments
Article is closed for comments.