Released under the terms of the GNU General Public License.
You should have received a copy of the GNU General Public License,
along with this software. In the main directory, see: /licensing/
If not, see: .
*/
/*
Direct access denial.
*/
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
exit ("Do not access this file directly.");
/*
This is the function for registering the widget.
Attach to: add_action("widgets_init");
*/
if (!function_exists ("ws_widget__ad_codes_register"))
{
function ws_widget__ad_codes_register ()
{
do_action ("ws_widget__ad_codes_before_register", get_defined_vars ());
/**/
register_widget ("ws_widget__ad_codes");
/**/
do_action ("ws_widget__ad_codes_after_register", get_defined_vars ());
/**/
return;
}
}
/*
The extended WP_Widget class that handles several things.
*/
if (!class_exists ("ws_widget__ad_codes"))
{
class ws_widget__ad_codes /* < Register this widget class. */
extends WP_Widget /* See: /wp-includes/widgets.php for further details. */
{
/*
Constructor function.
*/
function ws_widget__ad_codes () /* Builds the classname, id_base, description, etc. */
{
$widget_ops = array ("classname" => "ad-codes", "description" => $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["description"]);
$control_ops = array ("width" => $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["control_w"], "id_base" => "ws_widget__ad_codes");
/**/
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_before_widget_construction", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/**/
$this->WP_Widget ($control_ops["id_base"], $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["name"], $widget_ops, $control_ops);
/**/
do_action ("ws_widget__ad_codes_class_after_widget_construction", get_defined_vars (), $this);
/**/
return;
}
/*
Widget display function. This is where the widget actually does something.
*/
function widget ($args = FALSE, $instance = FALSE)
{
$options = ws_widget__ad_codes_configure_options_and_their_defaults (false, (array)$instance);
/**/
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_before_widget_display", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/**/
echo $args["before_widget"]; /* Ok, here we go into this widget.
/**/
if (strlen ($options["title"])) /* If there is. */
echo $args["before_title"] . apply_filters ("widget_title", $options["title"]) . $args["after_title"];
/**/
$options["code"] = preg_split ("/\<\!--rotate--\>/", $options["code"]);
shuffle ($options["code"]); /* Support multiple random rotations. */
/**/
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_during_widget_display_before", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/**/
echo '
' . "\n";
if ($GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["is_multisite_farm"])
echo trim ($options["code"][0]);
else /* ^ Not if secure. */
eval ("?>" . trim ($options["code"][0]));
echo "\n" . '
' . "\n";
/**/
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_during_widget_display_after", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/**/
echo $args["after_widget"];
/**/
do_action ("ws_widget__ad_codes_class_after_widget_display", get_defined_vars (), $this);
/**/
return;
}
/*
Widget form control function. This is where options are made configurable.
*/
function form ($instance = FALSE)
{
$options = ws_widget__ad_codes_configure_options_and_their_defaults (false, (array)$instance);
/**/
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_before_widget_form", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/*
Ok, here is where we need to handle the widget control form. This allows a user to further customize the widget.
*/
echo ' ' . "\n";
echo '
' . "\n";
/**/
echo ' ' . "\n";
echo ' ' . "\n";
echo 'Quick Tip: If you\'d like to rotate a few different ads, just insert this tag: ' . esc_html ("") . ' between every ad code that you want to rotate through.' . "\n";
/**/
do_action ("ws_widget__ad_codes_class_after_widget_form", get_defined_vars (), $this);
/**/
echo ' ' . "\n";
/**/
return;
}
/*
Widget update function. This is where an updated instance is configured/stored.
*/
function update ($instance = FALSE, $old = FALSE)
{
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
do_action ("ws_widget__ad_codes_class_before_widget_update", get_defined_vars (), $this);
unset ($__refs, $__v); /* Unset defined __refs, __v. */
/**/
return ws_widget__ad_codes_configure_options_and_their_defaults (false, (array)$instance);
}
}
}
?>