コード例 #1
0
 public static function update_all_options($new_options = FALSE, $verified = FALSE, $update_other = TRUE, $display_notices = TRUE, $enqueue_notices = FALSE, $request_refresh = FALSE)
 {
     do_action("ws_widget__super_tags_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__super_tags_options_save"]) && wp_verify_nonce($nonce, "ws-widget--super-tags-options-save")) {
         $options = $GLOBALS["WS_WIDGET__"]["super_tags"]["o"];
         /* Here we get all of the existing options. */
         $new_options = is_array($new_options) ? $new_options : (array) $_POST;
         /* Force array. */
         $new_options = c_ws_widget__super_tags_utils_strings::trim_deep(stripslashes_deep($new_options));
         /**/
         foreach ((array) $new_options as $key => $value) {
             /* Looking for relevant keys. */
             if (preg_match("/^" . preg_quote("ws_widget__super_tags_", "/") . "/", $key)) {
                 /**/
                 if ($key === "ws_widget__super_tags_configured") {
                     update_option("ws_widget__super_tags_configured", $value);
                     $GLOBALS["WS_WIDGET__"]["super_tags"]["c"]["configured"] = $value;
                 } else {
                     is_array($value) ? array_shift($value) : null;
                     /* Arrays should be padded. */
                     $key = preg_replace("/^" . preg_quote("ws_widget__super_tags_", "/") . "/", "", $key);
                     $options[$key] = $value;
                     /* Overriding a possible existing option. */
                 }
             }
         }
         /**/
         $options["options_version"] = (string) ($options["options_version"] + 0.001);
         $options = ws_widget__super_tags_configure_options_and_their_defaults($options);
         /**/
         eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
         do_action("ws_widget__super_tags_during_update_all_options", get_defined_vars());
         unset($__refs, $__v);
         /* Unset defined __refs, __v. */
         /**/
         update_option("ws_widget__super_tags_options", $options);
         /**/
         if (($display_notices === true || in_array("success", (array) $display_notices)) && ($notice = '<strong>Options saved.' . ($request_refresh ? ' Please <a href="' . esc_attr($_SERVER["REQUEST_URI"]) . '">refresh</a>.' : '') . '</strong>')) {
             $enqueue_notices === true || in_array("success", (array) $enqueue_notices) ? c_ws_widget__super_tags_admin_notices::enqueue_admin_notice($notice, "*:*") : c_ws_widget__super_tags_admin_notices::display_admin_notice($notice);
         }
         /**/
         $updated_all_options = true;
         /* Flag indicating this routine was indeed processed. */
     }
     /**/
     do_action("ws_widget__super_tags_after_update_all_options", get_defined_vars());
     /**/
     return $updated_all_options;
     /* Return status update. */
 }
コード例 #2
0
 public function update($instance = FALSE, $old = FALSE)
 {
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_widget__super_tags_class_before_widget_update", get_defined_vars(), $this);
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     $instance = (array) c_ws_widget__super_tags_utils_strings::trim_deep(stripslashes_deep($instance));
     return ws_widget__super_tags_configure_options_and_their_defaults(false, $instance);
 }