('.__('Sign up to earn money.','nrelate') . ')', 'setting_admin_validate_ad', __FILE__, 'ad_section'); // Communication Section add_settings_section('comm_section', __('Communication','nrelate'), 'section_text_nr_comm', __FILE__); add_settings_field('admin_email_address', ''.__('Send email address','nrelate').'', 'setting_admin_email', __FILE__, 'comm_section'); // Custom Fields add_settings_section('customfield_section', __('Custom Field for Images','nrelate'), 'section_text_nr_customfield', __FILE__); add_settings_field('admin_custom_field', __('Enter your Custom Field for images, here:','nrelate'), 'setting_admin_custom_field',__FILE__,'customfield_section'); // Exclude categories add_settings_section('excludecat_section', __('Exclude Categories','nrelate'), 'section_text_nr_excludecat', __FILE__); add_settings_field('admin_exclude_categories', __('Categories:','nrelate'), 'setting_admin_exclude_categories',__FILE__,'excludecat_section'); } add_action('admin_init', 'options_admin_init_nr' ); /**************************************************************** ************************** Admin Sections ********************** *****************************************************************/ /////////////////////////// // Advertising Settings ////////////////////////// // Section HTML: Advertising function section_text_nr_ad() { _e('

Become a part of the nrelate advertising network and earn some extra money on your blog.

','nrelate'); } // TEXTBOX - Validate ads function setting_admin_validate_ad() { $options = get_option('nrelate_admin_options'); echo '
'; echo ''; } /////////////////////////// // Communciation Settings ////////////////////////// // Section HTML: Communication function section_text_nr_comm() { _e('

nrelate may need to communicate with you when we release new features or have a problem accessing your website.
Check the box, below, to send nrelate the admin email address (under "General Settings"). We promise not to overwhelm you with email.

','nrelate'); } // CHECKBOX - Admin email address function setting_admin_email() { $options = get_option('nrelate_admin_options'); $checked = @$options['admin_email_address']=='on' ? ' checked="checked" ' : ''; echo ""; } /////////////////////////// // customfield Settings ////////////////////////// // Section HTML: customfield function section_text_nr_customfield() { _e('

If you use a Custom Field to show images in your posts, you can have nrelate show those images.

','nrelate'); } // TEXTBOX - Name: nrelate_admin_options[admin_custom_field] function setting_admin_custom_field() { $options = get_option('nrelate_admin_options'); $customfield = $options['admin_custom_field']; echo '
'; } /////////////////////////// // Exclude Categories Settings ////////////////////////// // Section HTML: customfield function section_text_nr_excludecat() { _e('

Select the categories you want to exclude from ALL nrelate products.

', 'nrelate'); } // CHECKBOX LIST - Name: nrelate_admin_options[admin_exclude_categories] function setting_admin_exclude_categories() { $options = get_option('nrelate_admin_options'); echo '
'; $javascript = <<< JAVA_SCRIPT jQuery(document).ready(function(){ var nrel_excluded_cats_changed = false; jQuery('#nrelate-exclude-cats :checkbox').change(function(){ var me= jQuery(this); if (!nrel_excluded_cats_changed) { if (confirm("Any changes to this section will cause a site reindex. Are you sure you want to continue?\u000AIf Yes, press OK and then SAVE CHANGES.")) { nrel_excluded_cats_changed = true; } else { me.attr('checked', !me.is(':checked')); } } if ( nrel_excluded_cats_changed ) { me.parent().siblings('.children').find(':checkbox').attr('checked', me.is(':checked')); if ( me.closest('#nrelate-exclude-cats').find(':checkbox').size() == me.closest('#nrelate-exclude-cats').find(':checkbox:checked').size() ) { alert("WARNING: You have marked all your categories for exclusion. Nothing will show up in nrelate. Please uncheck at least one category."); } } }); }); JAVA_SCRIPT; echo ""; } // Walker class to customize Checkbox List input names class nrelate_Walker_Category_Checklist extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); function start_lvl(&$output, $depth, $args) { $indent = str_repeat("\t", $depth); $output .= "$indent\n"; } function end_el(&$output, $category, $depth, $args) { $output .= "\n"; } function start_el(&$output, $category, $depth, $args) { extract($args); if ( empty($taxonomy) ) $taxonomy = 'category'; $name = isset($name) ? $name : 'nrelate_admin_options[admin_exclude_categories]'; $value_field = isset($value_field) ? $value_field : 'term_id'; $css_classes = !$category->parent ? ' top-level-category' : ''; $css_classes .= $has_children ? ' parent-category' : ''; $css_classes .= in_array( $category->$value_field, $selected_cats ) ? ' excluded-category' : ''; $class = $css_classes ? "class='{$css_classes}'" : ''; // Supports WP v2.9 $output .= "\n
  • " . ''; } } /* * Executes when nrelate_admin_options changes so it can call nrelate_reindex() * if one of the changes requires complete site re-indexation */ function nrelate_check_options_change($new_value) { $old_value = (array) get_option('nrelate_admin_options'); $reindex = false; if( @$new_value['admin_exclude_categories'] !== @$old_value['admin_exclude_categories'] ) { $reindex = true; } if( @$new_value['admin_custom_field'] !== @$old_value['admin_custom_field'] ) { $reindex = true; } if ( $reindex ) { nrelate_reindex(); } return $new_value; } add_filter('pre_update_option_nrelate_admin_options', 'nrelate_check_options_change'); /**************************************************************** ******************** Build the Admin Page ********************** *****************************************************************/ function nrelate_admin_do_page() { ?>

    $wp_root_nr, 'EMAIL'=>$nr_user_email, 'RSSMODE'=>$rss_mode, 'RSSURL'=>$rssurl, 'KEY'=>get_option('nrelate_key'), 'CUSTOM'=>$custom_field, 'EMAILOPT'=>$send_email ); $url = 'http://api.nrelate.com/common_wp/'.NRELATE_LATEST_ADMIN_VERSION.'/processWPadmin.php'; $request=new WP_Http; $result=$request->request($url,array('method'=>'POST','body'=>$body,'blocking'=>false)); } // Validate user data for some/all of our input fields function admin_options_validate($input) { // Like escape all text fields $input['admin_validate_ad'] = like_escape($input['admin_validate_ad']); // Add slashes to all text fields $input['admin_validate_ad'] = esc_sql($input['admin_validate_ad']); /** * Make sure that unchecked checkboxes are stored as empty strings * * nrelate_admin_options doesn't have a "defaults" global array * so let's keep an array of checkbox settings here, the only place * it's required by now */ $empty_settings_array = array( 'admin_email_address' => '' ); $input = wp_parse_args( $input, $empty_settings_array ); return $input; // return validated input } ?>