function update($new_instance, $old_instance) { $instance = $old_instance; /* Strip tags (if needed) and update the widget settings. */ $instance['title'] = strip_tags($new_instance['title']); $instance['advert'] = $new_instance['advert']; $options = adinj_options(); write_ad_to_file($instance['advert'], $this->get_ad_file_path2()); return $instance; }
function update($new_instance, $old_instance) { $updated = $this->adinj_upgrade_widget_db($new_instance, $old_instance); // Only strip tags when potential for updated title $updated['title'] = strip_tags($new_instance['title']); // After first save mark it as saved $updated['saved'] = 1; for ($i = 1; $i <= 10; ++$i) { write_ad_to_file($updated['advert_' . $i], $this->get_ad_file_path($i)); } for ($i = 1; $i <= 3; ++$i) { write_ad_to_file($updated['advert_alt_' . $i], $this->get_alt_file_path($i)); } return $updated; }
function extract_text_args($name, &$ops, $start = NULL, $end = NULL, $save_path_stem = NULL) { if ($start === NULL) { if (isset($_POST[$name])) { $ops[$name] = stripslashes($_POST[$name]); if ($save_path_stem != NULL) { write_ad_to_file($ops[$name], $save_path_stem . '1.txt'); } } } else { for ($i = $start; $i <= $end; ++$i) { if (isset($_POST[$name . $i])) { $ops[$name . $i] = stripslashes($_POST[$name . $i]); if ($save_path_stem != NULL) { write_ad_to_file($ops[$name . $i], $save_path_stem . $i . '.txt'); } } } } }
function adinj_activate_hook() { $stored_options = adinj_options(); $pending_options = adinj_default_options(); if (empty($stored_options)) { // Save defaults to DB below. if (!is_plugin_active('wp-super-cache/wp-cache.php')) { $pending_options['ad_insertion_mode'] = 'direct_dynamic'; } } else { // Upgrade options if necessary. Use default as a baseline, // and then overwrite default with the saved ones. foreach ($pending_options as $key => $value) { if (array_key_exists($key, $stored_options)) { $pending_options[$key] = $stored_options[$key]; } } } $random_file2 = ADINJ_AD_PATH . '/' . ADINJ_AD_RANDOM_FILE; $top_file2 = ADINJ_AD_PATH . '/' . ADINJ_AD_TOP_FILE; $bottom_file2 = ADINJ_AD_PATH . '/' . ADINJ_AD_BOTTOM_FILE; if ($pending_options['ad_insertion_mode'] == 'mfunc') { // Restore data after automatic upgrade // TODO could remove this code further down the line when everyone // has moved to the new ad store location if (!@file_exists($random_file2) && !empty($pending_options['ad_code_random_1'])) { write_ad_to_file($pending_options['ad_code_random_1'], $random_file2); } if (!@file_exists($top_file2) && !empty($pending_options['ad_code_top_1'])) { write_ad_to_file($pending_options['ad_code_top_1'], $top_file2); } if (!@file_exists($bottom_file2) && !empty($pending_options['ad_code_bottom_1'])) { write_ad_to_file($pending_options['ad_code_bottom_1'], $bottom_file2); } if (!@file_exists(ADINJ_CONFIG_FILE)) { adinj_write_config_file(); } } adinj_update_options($pending_options); }