function generate_config_content($template_content) { global $wpdb, $table_prefix; $sql_sock = ''; if ('' != trim(ini_get('mysql.default_socket'))) { $sql_sock = 'sql_sock = ' . ini_get('mysql.default_socket'); } $wizard = new WizardController($this->config); /** * We have to rewrite following variables: * {sql_sock} to database socket * * {source} to Sphinx Index name * {sphinx_path} to Sphinx Server root dir * {searchd_port} to Sphinx search daemon port * {wp_posts} to Wordpress posts table * {wp_comments} to Wordpress comments table * {path_to_php} path to php executable file * {path_to_wp_config_php} path to wp-config.php - requiered by shebung syntax */ $search = array('{sql_sock}' => $sql_sock, '{prefix}' => $this->config->admin_options['sphinx_index'], '{sphinx_path}' => $this->config->admin_options['sphinx_path'], '{searchd_port}' => $this->config->admin_options['sphinx_port'], '{wp_posts}' => $wpdb->posts, '{wp_comments}' => $wpdb->comments, '{wp_term_relationships}' => $wpdb->term_relationships, '{wp_term_taxonomy}' => $wpdb->term_taxonomy, '{wp_terms}' => $wpdb->terms, '{path_to_php}' => $wizard->detect_program('php'), '{path_to_wp_config_php}' => dirname(dirname(dirname($this->plugin_sphinx_dir))), '{max_matches}' => $this->config->admin_options['sphinx_max_matches'], '{db_host}' => DB_HOST, '{db_user}' => DB_USER, '{db_pass}' => DB_PASSWORD, '{db_name}' => DB_NAME, '{table_prefix}' => $table_prefix); $rewrited_content = str_replace(array_keys($search), $search, $template_content); return $rewrited_content; }