* @version 0.1 - Oct 21 2006
*/
//print_r($_POST);
global $wpdb, $wp_rewrite;
$options = $newoptions = get_option('scrib');
if(empty($options['browse_id']) || $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE ID = ". intval($options['browse_id']) .' AND post_status = "publish" AND post_type = "page" ') == FALSE){
// create the default browse page
$postdata['post_title'] = 'Browse';
$postdata['post_name'] = 'browse';
$postdata['comment_status'] = 0;
$postdata['ping_status'] = 0;
$postdata['post_status'] = 'publish';
$postdata['post_type'] = 'page';
$postdata['post_content'] = 'Browse new titles.';
$postdata['post_excerpt'] = 'Browse new titles.';
$postdata['post_author'] = 0;
$post_id = wp_insert_post($postdata); // insert the post
// set the options with this new page
$options['browse_id'] = (int) $post_id;
update_option('scrib', $options);
echo '
'.__('New Browse page created.', 'Scriblio').'
';
$options = $newoptions = get_option('scrib');
}
if( empty( $options['catalog_category_id'] ) || !get_category( $options['catalog_category_id'] ) ){
wp_insert_category( array( 'cat_name' => __( 'Catalog', 'Scriblio' )));
$options['catalog_category_id'] = get_cat_ID( __( 'Catalog', 'Scriblio' ));
update_option('scrib', $options);
echo ''.__('New category created for catalog records.', 'Scriblio').'
';
$options = $newoptions = get_option('scrib');
}
if ($_REQUEST['command'] == __('Rebuild Search Suggest Table', 'Scriblio')){
$this->suggest_init_table();
}
if ($_POST['scrib-submit']) {
$newoptions['sphinxsearch'] = (int) $_POST['sphinxsearch'];
$newoptions['browse_id'] = (int) $_POST['browse_id'];
$newoptions['catalog_author_id'] = (int) $_POST['catalog_author_id'];
$newoptions['catalog_category_id'] = (int) $_POST['catalog_category_id'];
unset($newoptions['taxonomies_for_related']);
unset($newoptions['taxonomies_for_suggest']);
foreach($this->taxonomies_getall() as $taxonomy){
if(!empty($_POST['taxonomy_use_' . $taxonomy ]))
$newoptions['taxonomies'][$taxonomy] = $_POST['taxonomy_name_' . $taxonomy ];
if(!empty($_POST['taxonomy_for_related_' . $taxonomy ]))
$newoptions['taxonomies_for_related'][] = $taxonomy;
if(!empty($_POST['taxonomy_for_suggest_' . $taxonomy ]))
$newoptions['taxonomies_for_suggest'][] = $taxonomy;
}
array_filter($newoptions);
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('scrib', $options);
echo ''.__('Options updated.', 'Scriblio').'
';
}
foreach($this->taxonomies_getall() as $taxonomy){
$taxonomy_name[$taxonomy] = attribute_escape($options['taxonomies'][$taxonomy]);
}
?>
';
global $wp_rewrite;
$wp_rewrite->flush_rules();
print_r($wp_rewrite->wp_rewrite_rules());
*/
?>