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."); /* Function that saves all options from any page. Options can also be passed in directly. Can also be self-verified. */ if (!function_exists ("ws_widget__ad_codes_update_all_options")) { function ws_widget__ad_codes_update_all_options ($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE) { do_action ("ws_widget__ad_codes_before_update_all_options", get_defined_vars ()); /* If you use this Hook, be sure to use `wp_verify_nonce()`. */ /**/ if ($verified || ( ($nonce = $_POST["ws_widget__ad_codes_options_save"]) && wp_verify_nonce ($nonce, "ws-widget--ad-codes-options-save"))) { $options = $GLOBALS["WS_WIDGET__"]["ad_codes"]["o"]; /* Here we get all of the existing options. */ $new_options = (is_array ($new_options)) ? $new_options : (array)$_POST; /* Force array. */ $new_options = ws_widget__ad_codes_trim_deep (stripslashes_deep ($new_options)); /**/ foreach ((array)$new_options as $key => $value) /* Looking for relevant keys. */ if (preg_match ("/^" . preg_quote ("ws_widget__ad_codes_", "/") . "/", $key)) /**/ if ($key === "ws_widget__ad_codes_configured") /* Configured. */ { update_option ("ws_widget__ad_codes_configured", $value); $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["configured"] = $value; } else /* Place this option into the array. Remove ws_widget__ad_codes_. */ { (is_array ($value)) ? array_shift ($value) : null; /* Arrays should be padded. */ $key = preg_replace ("/^" . preg_quote ("ws_widget__ad_codes_", "/") . "/", "", $key); $options[$key] = $value; /* Overriding a possible existing option. */ } /**/ $options["options_version"] = $options["options_version"] + 0.001; $options = ws_widget__ad_codes_configure_options_and_their_defaults ($options); /**/ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action ("ws_widget__ad_codes_during_update_all_options", get_defined_vars ()); unset ($__refs, $__v); /* Unset defined __refs, __v. */ /**/ update_option ("ws_widget__ad_codes_options", $options); /**/ if (($display_notices === true || in_array ("success", (array)$display_notices)) && ($notice = 'Options saved.' . (($request_refresh) ? ' Please refresh.' : '') . '')) ($enqueue_notices === true || in_array ("success", (array)$enqueue_notices)) ? ws_widget__ad_codes_enqueue_admin_notice ($notice) : ws_widget__ad_codes_display_admin_notice ($notice); } /**/ do_action ("ws_widget__ad_codes_after_update_all_options", get_defined_vars ()); /**/ return; /* Return for uniformity. */ } } /* Add options, details, info, etc. Attach to: add_action("admin_menu"); */ if (!function_exists ("ws_widget__ad_codes_add_admin_options")) { function ws_widget__ad_codes_add_admin_options () { do_action ("ws_widget__ad_codes_before_add_admin_options", get_defined_vars ()); /**/ if (!ws_widget__ad_codes_is_multisite_farm ()) /* NOT on Multisite Farms. */ { add_filter ("plugin_action_links", "_ws_widget__ad_codes_add_details_link", 10, 2); /**/ if (apply_filters ("ws_widget__ad_codes_during_add_admin_options_create_menu_items", true, get_defined_vars ())) { if (apply_filters ("ws_widget__ad_codes_during_add_admin_options_add_info_page", true, get_defined_vars ())) add_theme_page ("Ad Codes / Widget Information", "Ad Codes Widget", "edit_plugins", "theme-ws-widget--ad-codes-info", "ws_widget__ad_codes_info_page"); } } /**/ do_action ("ws_widget__ad_codes_after_add_admin_options", get_defined_vars ()); /**/ return; } } /* A sort of callback function to add the details link. */ if (!function_exists ("_ws_widget__ad_codes_add_details_link")) { function _ws_widget__ad_codes_add_details_link ($links = array (), $file = "") { eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action ("_ws_widget__ad_codes_before_add_details_link", get_defined_vars ()); unset ($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (preg_match ("/" . preg_quote ($file, "/") . "$/", $GLOBALS["WS_WIDGET__"]["ad_codes"]["l"]) && is_array ($links)) { $details = 'Details'; array_unshift ($links, $details); /**/ eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action ("_ws_widget__ad_codes_during_add_details_link", get_defined_vars ()); unset ($__refs, $__v); /* Unset defined __refs, __v. */ /**/ } /**/ return apply_filters ("_ws_widget__ad_codes_add_details_link", $links, get_defined_vars ()); } } /* Add scripts to admin panels. Attach to: add_action("admin_print_scripts"); */ if (!function_exists ("ws_widget__ad_codes_add_admin_scripts")) { function ws_widget__ad_codes_add_admin_scripts () { do_action ("ws_widget__ad_codes_before_add_admin_scripts", get_defined_vars ()); /**/ if ($_GET["page"] && preg_match ("/ws-widget--ad-codes-/", $_GET["page"])) { wp_enqueue_script ("jquery"); wp_enqueue_script ("thickbox"); wp_enqueue_script ("media-upload"); wp_enqueue_script ("jquery-ui-core"); wp_enqueue_script ("jquery-json-ps", $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"] . "/includes/menu-pages/jquery-json-ps-min.js", array ("jquery"), $GLOBALS["WS_WIDGET__"]["ad_codes"]["o"]["options_version"] . $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["filemtime"]); wp_enqueue_script ("jquery-ui-effects", $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"] . "/includes/menu-pages/jquery-ui-effects.js", array ("jquery", "jquery-ui-core"), $GLOBALS["WS_WIDGET__"]["ad_codes"]["o"]["options_version"] . $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["filemtime"]); wp_enqueue_script ("ws-widget--ad-codes-menu-pages", get_bloginfo ("wpurl") . "/?ws_widget__ad_codes_menu_pages_js=1", array ("jquery", "thickbox", "media-upload", "jquery-json-ps", "jquery-ui-core", "jquery-ui-effects"), $GLOBALS["WS_WIDGET__"]["ad_codes"]["o"]["options_version"] . $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["filemtime"]); /**/ do_action ("ws_widget__ad_codes_during_add_admin_scripts", get_defined_vars ()); } /**/ do_action ("ws_widget__ad_codes_after_add_admin_scripts", get_defined_vars ()); /**/ return; } } /* Add styles to admin panels. Attach to: add_action("admin_print_styles"); */ if (!function_exists ("ws_widget__ad_codes_add_admin_styles")) { function ws_widget__ad_codes_add_admin_styles () { do_action ("ws_widget__ad_codes_before_add_admin_styles", get_defined_vars ()); /**/ if ($_GET["page"] && preg_match ("/ws-widget--ad-codes-/", $_GET["page"])) { wp_enqueue_style ("thickbox"); wp_enqueue_style ("ws-widget--ad-codes-menu-pages", get_bloginfo ("wpurl") . "/?ws_widget__ad_codes_menu_pages_css=1", array ("thickbox"), $GLOBALS["WS_WIDGET__"]["ad_codes"]["o"]["options_version"] . $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["filemtime"], "all"); /**/ do_action ("ws_widget__ad_codes_during_add_admin_styles", get_defined_vars ()); } /**/ do_action ("ws_widget__ad_codes_after_add_admin_styles", get_defined_vars ()); /**/ return; } } /* Function that outputs the js for menu pages. Attach to: add_action("init"); */ if (!function_exists ("ws_widget__ad_codes_menu_pages_js")) { function ws_widget__ad_codes_menu_pages_js () { do_action ("ws_widget__ad_codes_before_menu_pages_js", get_defined_vars ()); /**/ if ($_GET["ws_widget__ad_codes_menu_pages_js"] && is_user_logged_in () && current_user_can ("edit_plugins")) { header ("Content-Type: text/javascript; charset=utf-8"); header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT"); header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate, max-age=0"); header ("Pragma: no-cache"); /**/ $u = $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"]; $i = $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"] . "/images"; /**/ include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-min.js"; /**/ echo "\n"; /* Add a line break before inclusion of this file. */ /**/ @include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s-min.js"; /**/ do_action ("ws_widget__ad_codes_during_menu_pages_js", get_defined_vars ()); /**/ exit (); } /**/ do_action ("ws_widget__ad_codes_after_menu_pages_js", get_defined_vars ()); } } /* Function that outputs the css for menu pages. Attach to: add_action("init"); */ if (!function_exists ("ws_widget__ad_codes_menu_pages_css")) { function ws_widget__ad_codes_menu_pages_css () { do_action ("ws_widget__ad_codes_before_menu_pages_css", get_defined_vars ()); /**/ if ($_GET["ws_widget__ad_codes_menu_pages_css"] && is_user_logged_in () && current_user_can ("edit_plugins")) { header ("Content-Type: text/css; charset=utf-8"); header ("Expires: " . gmdate ("D, d M Y H:i:s", strtotime ("-1 week")) . " GMT"); header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate, max-age=0"); header ("Pragma: no-cache"); /**/ $u = $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"]; $i = $GLOBALS["WS_WIDGET__"]["ad_codes"]["c"]["dir_url"] . "/images"; /**/ ob_start ("ws_widget__ad_codes_compress_css"); /* Compress. */ /**/ include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages.css"; /**/ echo "\n"; /* Add a line break before inclusion of this file. */ /**/ @include_once dirname (dirname (__FILE__)) . "/menu-pages/menu-pages-s.css"; /**/ do_action ("ws_widget__ad_codes_during_menu_pages_css", get_defined_vars ()); /**/ exit (); } /**/ do_action ("ws_widget__ad_codes_after_menu_pages_css", get_defined_vars ()); } } /* Function for building the info page. */ if (!function_exists ("ws_widget__ad_codes_info_page")) { function ws_widget__ad_codes_info_page () { do_action ("ws_widget__ad_codes_before_info_page", get_defined_vars ()); /**/ include_once dirname (dirname (__FILE__)) . "/menu-pages/info.inc.php"; /**/ do_action ("ws_widget__ad_codes_after_info_page", get_defined_vars ()); /**/ return; } } ?>