options = $this->getDefaultOptions(); // Get options from WP options $options_from_table = get_option( STAGS_OPTIONS_NAME ); // Update default options by getting not empty values from options table foreach( (array) $this->options as $key => $value ) { if ( !is_null($options_from_table[$key]) ) { $this->options[$key] = $options_from_table[$key]; } } // Clean memory $options_from_table = array(); unset($options_from_table, $value); } /** * Escape string so that it can used in Regex. E.g. used for [tags]...[/tags] * * @param string $content * @return string */ function regexEscape( $content ) { return strtr($content, array("\\" => "\\\\", "/" => "\\/", "[" => "\\[", "]" => "\\]")); } /** * Add initial ST options in DB * */ function installSimpleTags() { $options_from_table = get_option( STAGS_OPTIONS_NAME ); if ( $options_from_table == false ) { $this->resetToDefaultOptions(); } } /** * Remove ST options when user delete plugin (use WP API Uninstall) * */ function uninstall() { delete_option( STAGS_OPTIONS_NAME ); delete_option( 'widget_stags_cloud' ); } /** * Set an option value -- note that this will NOT save the options. * * @param string $optname * @param string $optval */ function setOption( $optname = '', $optval = '') { $this->options[$optname] = $optval; } /** * Save all current options * */ function saveOptions() { return update_option(STAGS_OPTIONS_NAME, $this->options); } /** * Reset to default options * */ function resetToDefaultOptions() { $this->options = $this->getDefaultOptions(); return update_option( STAGS_OPTIONS_NAME, $this->options ); } /* * Get all array options. * * */ function getDefaultOptions() { return array( // General 'use_tag_pages' => 1, 'allow_embed_tcloud' => 0, 'no_follow' => 0, // Auto link 'auto_link_tags' => 0, 'auto_link_min' => 1, 'auto_link_case' => 1, 'auto_link_exclude' => '', 'auto_link_max_by_post' => 10, // Administration 'use_click_tags' => 1, 'use_suggested_tags' => 1, 'use_autocompletion' => 1, // Embedded Tags 'use_embed_tags' => 0, 'start_embed_tags' => '[tags]', 'end_embed_tags' => '[/tags]', // Related Posts 'rp_feed' => 0, 'rp_embedded' => 'no', 'rp_order' => 'count-desc', 'rp_limit_qty' => 5, 'rp_notagstext' => __('No related posts.', 'simpletags'), 'rp_title' => __('