示例#1
0
 /**
  * Updates the database settings from the webform
  */
 function opts_update()
 {
     //Do some security related thigns as we are not using the normal WP settings API
     $this->security();
     //Do a nonce check, prevent malicious link/form problems
     check_admin_referer($this->unique_prefix . '_options-options');
     //Update local options from database
     $this->opt = mtekk_adminKit::parse_args(get_option($this->unique_prefix . '_options'), $this->opt);
     $this->opts_update_prebk($this->opt);
     //Update our backup options
     update_option($this->unique_prefix . '_options_bk', $this->opt);
     //Grab our incomming array (the data is dirty)
     $input = $_POST[$this->unique_prefix . '_options'];
     //Run the update loop
     $this->opts_update_loop($this->opt, $input);
     //Commit the option changes
     update_option($this->unique_prefix . '_options', $this->opt);
     //Check if known settings match attempted save
     if (count(array_diff_key($input, $this->opt)) == 0) {
         //Let the user know everything went ok
         $this->message['updated fade'][] = __('Settings successfully saved.', $this->identifier) . $this->admin_anchor('undo', __('Undo the options save.', $this->identifier), __('Undo', $this->identifier));
     } else {
         //Let the user know the following were not saved
         $this->message['updated fade'][] = __('Some settings were not saved.', $this->identifier) . $this->admin_anchor('undo', __('Undo the options save.', $this->identifier), __('Undo', $this->identifier));
         $temp = __('The following settings were not saved:', $this->identifier);
         foreach (array_diff_key($input, $this->opt) as $setting => $value) {
             $temp .= '<br />' . $setting;
         }
         $this->message['updated fade'][] = $temp . '<br />' . sprintf(__('Please include this message in your %sbug report%s.', $this->identifier), '<a title="' . sprintf(__('Go to the %s support post for your version.', $this->identifier), $this->short_name) . '" href="' . $this->support_url . $this->version . '/#respond">', '</a>');
     }
     add_action('admin_notices', array($this, 'message'));
 }
 function fetch_print()
 {
     //Sync our options
     $this->opt = mtekk_adminKit::parse_args(get_option('llynx_options'), $this->opt);
     $this->llynx_scrape->opt = $this->opt;
     //Grab the nonce and check
     //$nonce = intval($_POST['nonce']);
     //Clean up the URL
     $url = esc_url_raw($_POST['url']);
     //Clean the title
     $title = esc_attr($_POST['title']);
     //Clean the image
     $image = esc_url_raw($_POST['image']);
     //Clean the description
     $description = wp_kses($_POST['description'], wp_kses_allowed_html('post'));
     //Assemble the lynx print and echo
     echo $this->url_insert_handler($url, $title, $description, $image, false);
     die;
 }