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; /* This is the function for registering the widget. Attach to: add_action("widgets_init"); */ function ws_widget__ad_codes_register () { register_widget("ws_widget__ad_codes"); /**/ return; } /* The extended WP_Widget class that handles several things. */ 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"); $this->WP_Widget($control_ops["id_base"], $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["name"], $widget_ops, $control_ops); /**/ 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); /**/ 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. */ /**/ 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"; /**/ echo $args["after_widget"]; /**/ 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); /* 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"; /**/ echo '
' . "\n"; /**/ return; } /* Widget update function. This is where an updated instance is configured/stored. */ function update ($instance = FALSE, $old = FALSE) { return ws_widget__ad_codes_configure_options_and_their_defaults(false, (array)$instance); } } ?>