0); $categoryList = get_categories($args); foreach($categoryList as $category) { $catId = $category->cat_ID; $IWId = null; $tagId = IWOptions::key_CategoryMap($catId); if( IWOptions::has_CategoryMap($catId) ) { $IWId = IWOptions::get_CategoryMap($catId); } add_settings_field($tagId, 'From '.$category->name.' to ', array('IWOptions', 'settings_dropdown'), self::$_options_page, self::$_options_category_section, array( $tagId, $IWId,$IWCategoryList, 'auto' )); } } add_settings_section(self::$_options_performance_section, 'Performance', array('IWOptions', 'options_performance_section_text'), self::$_options_page); if(IWOptions::has_MinTimeOut()) { add_settings_field(self::$_minTimeOutKey, 'Minimum time out (sec)', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_minTimeOutKey, IWOptions::get_MinTimeOut(), "Minimum acceptable latency between your server and InsideWord. Increase this if you have issues connecting to InsideWord.")); } if(IWOptions::has_RankCacheTime()) { add_settings_field(self::$_rankCacheTimeKey, 'Rank cache time (sec)', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_rankCacheTimeKey, IWOptions::get_RankCacheTime(), "How long to cache your article's InsideWord rankings before fetching them again from InsideWord. Increase this to reduce server load.")); } if(IWOptions::has_PublishIncrement()) { add_settings_field(self::$_publishIncrementKey, 'Post batch rate', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_publishIncrementKey, IWOptions::get_PublishIncrement(), "How many articles should be synched up at a time. This is only used when the plugin is first activated.")); } if(IWOptions::has_RescheduleDelay()) { add_settings_field(self::$_rescheduleDelayKey, 'Scheduled download delay (sec)', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_rescheduleDelayKey, IWOptions::get_RescheduleDelay(), "How frequently your server should fetch data from InsideWord. Increase this to reduce server load." )); } if(IWOptions::has_LoginSessionTime()) { add_settings_field(self::$_loginSessionTimeKey, 'Login session time (sec)', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_loginSessionTimeKey, IWOptions::get_LoginSessionTime(), "How long to store the login cookie. Increasing this will improve performance but can cause issues.")); } if(IWOptions::has_MaxRetry()) { add_settings_field(self::$_maxRetryKey, 'Max retry attempts', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_maxRetryKey, IWOptions::get_MaxRetry(), "Number of tries to connect to InsideWord before aborting. Increase this if you have an unstable connection.")); } if(IWOptions::has_RetryDelay()) { add_settings_field(self::$_retryDelayKey, 'Retry delay (sec)', array('IWOptions', 'settings_string'), self::$_options_page, self::$_options_performance_section, array( self::$_retryDelayKey, IWOptions::get_RetryDelay(), "Delay between retries.")); } add_settings_section(self::$_options_debug_section, 'Debug', array('IWOptions', 'options_debug_section_text'), self::$_options_page); if(IWOptions::has_Status()) { add_settings_field( self::$_statusKey, 'Plugin status', array('IWOptions', 'settings_label'), self::$_options_page, self::$_options_debug_section, array(IWOptions::get_Status())); } add_settings_field(self::$_loggingKey, 'Enable Logging', array('IWOptions', 'settings_checkbox'), self::$_options_page, self::$_options_debug_section, array(self::$_loggingKey, (IWOptions::has_Logging())? IWOptions::get_Logging() : false)); add_settings_field(self::$_errorHandlerKey, 'Enable Error Handler', array('IWOptions', 'settings_checkbox'), self::$_options_page, self::$_options_debug_section, array(self::$_errorHandlerKey, (IWOptions::has_ErrorHandler())? IWOptions::get_ErrorHandler() : false)); add_settings_field(self::$_saveSettingsKey, 'Save Settings', array('IWOptions', 'settings_checkbox'), self::$_options_page, self::$_options_debug_section, array(self::$_saveSettingsKey, IWOptions::has_SaveSettings()? IWOptions::get_SaveSettings() : false, "Saves your settings when deactivating the plugin.")); } static function options_page_parse($form_values) { IWOptions::load_options(); if( WP_DEBUG === true ){ error_log("parse -\n" . print_r($form_values, true)); error_log("options -\n" . print_r(self::$_options, true)); } if(!empty($form_values)) { // check boxes don't get retrieved normally if they aren't 'checked' so handle them with a special case self::$_options[self::$_loggingKey] = array_key_exists(self::$_loggingKey, $form_values); self::$_options[self::$_errorHandlerKey] = array_key_exists(self::$_errorHandlerKey, $form_values); self::$_options[self::$_saveSettingsKey] = array_key_exists(self::$_saveSettingsKey, $form_values); $args = array('hide_empty' => 0); $categoryList = get_categories($args); foreach($categoryList as $category) { $catId = $category->cat_ID; $catMapKey = IWOptions::key_CategoryMap( $catId ); if( array_key_exists( $catMapKey, $form_values ) ) { self::$_options[$catMapKey] = (int)$form_values[$catMapKey]; } else { self::$_options[$catMapKey] = null; } } if( array_key_exists( self::$_minTimeOutKey, $form_values ) ) { $intVal = $form_values[self::$_minTimeOutKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_minTimeOutKey] = $intVal; } } } if( array_key_exists( self::$_publishIncrementKey, $form_values ) ) { $intVal = $form_values[self::$_publishIncrementKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_publishIncrementKey] = (int)$intVal; } } } if( array_key_exists( self::$_rankCacheTimeKey, $form_values ) ) { $intVal = $form_values[self::$_rankCacheTimeKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_rankCacheTimeKey] = (int)$intVal; } } } if( array_key_exists( self::$_rescheduleDelayKey, $form_values ) ) { $intVal = $form_values[self::$_rescheduleDelayKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_rescheduleDelayKey] = $intVal; } } } if( array_key_exists( self::$_loginSessionTimeKey, $form_values ) ) { $intVal = $form_values[self::$_loginSessionTimeKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_loginSessionTimeKey] = $intVal; } } } if( array_key_exists( self::$_maxRetryKey, $form_values ) ) { $intVal = $form_values[self::$_maxRetryKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_maxRetryKey] = $intVal; } } } if( array_key_exists( self::$_retryDelayKey, $form_values ) ) { $intVal = $form_values[self::$_retryDelayKey]; if(is_numeric($intVal)) { $intVal = (int)$intVal; if($intVal > 0) { self::$_options[self::$_retryDelayKey] = $intVal; } } } } else { // check boxes don't get retrieved normally if they aren't 'checked' so handle them with a special case self::$_options[self::$_loggingKey] = false; self::$_options[self::$_errorHandlerKey] = false; self::$_options[self::$_saveSettingsKey] = false; } return self::$_options; } static function options_info_section_text() { echo "
These settings provide general info and InsideWord account.
\n"; } static function options_category_section_text() { echo "The settings below allow you to match your categories to InsideWord categories. This will allow your posts to be sent to the correct categories in InsideWord.com.
\n"; } static function options_performance_section_text() { echo "Adjust these settings only if you need to fix an issue.
\n"; } static function options_debug_section_text() { echo "These are debug settings. Turning them on can slow down your server considerably.
\n"; } static function options_page() { if(is_admin()) { if(!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } ?>