コード例 #1
0
 function activate()
 {
     // Check to see if we have  environment variables. If not, bail. If so, create the initial options.
     if ($errMessage = SolrPower::get_instance()->sanity_check()) {
         wp_die($errMessage);
     }
     // Don't try to send a schema if we're not on Pantheon servers.
     if (!defined('SOLR_PATH')) {
         $schemaSubmit = SolrPower_Api::get_instance()->submit_schema();
         if (strpos($schemaSubmit, 'Error')) {
             wp_die('Submitting the schema failed with the message ' . $errMessage);
         }
     }
     SolrPower_Options::get_instance()->initalize_options();
     return;
 }
コード例 #2
0
 function submit_schema()
 {
     // Solarium does not currently support submitting schemas to the server.
     // So we'll do it ourselves
     $returnValue = '';
     $upload_dir = wp_upload_dir();
     // Let's check for a custom Schema.xml. It MUST be located in
     // wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml
     if (is_file(realpath(ABSPATH) . '/' . $_ENV['FILEMOUNT'] . '/solr-for-wordpress-on-pantheon/schema.xml')) {
         $schema = realpath(ABSPATH) . '/' . $_ENV['FILEMOUNT'] . '/solr-for-wordpress-on-pantheon/schema.xml';
     } else {
         $schema = SOLR_POWER_PATH . '/schema.xml';
     }
     $path = $this->compute_path();
     $url = 'https://' . getenv('PANTHEON_INDEX_HOST') . ':' . getenv('PANTHEON_INDEX_PORT') . '/' . $path;
     $client_cert = realpath(ABSPATH . '../certs/binding.pem');
     /*
      * A couple of quick checks to make sure everything seems sane
      */
     if ($errorMessage = SolrPower::get_instance()->sanity_check()) {
         return $errorMessage;
     }
     if (!file_exists($schema)) {
         return $schema . ' does not exist.';
     }
     if (!file_exists($client_cert)) {
         return $client_cert . ' does not exist.';
     }
     $file = fopen($schema, 'r');
     // set URL and other appropriate options
     $opts = array(CURLOPT_URL => $url, CURLOPT_PORT => 449, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSLCERT => $client_cert, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HTTPHEADER => array('Content-type:text/xml; charset=utf-8'), CURLOPT_PUT => TRUE, CURLOPT_BINARYTRANSFER => 1, CURLOPT_INFILE => $file, CURLOPT_INFILESIZE => filesize($schema));
     $ch = curl_init();
     curl_setopt_array($ch, $opts);
     $response = curl_exec($ch);
     $curl_opts = curl_getinfo($ch);
     fclose($file);
     $returnValue = (int) $curl_opts['http_code'];
     if ((int) $curl_opts['http_code'] == 200) {
         $returnValue = 'Schema Upload Success: ' . $curl_opts['http_code'];
     } else {
         $returnValue = 'Schema Upload Error: ' . $curl_opts['http_code'];
     }
     return $returnValue;
 }
コード例 #3
0
ファイル: solr-power.php プロジェクト: csemrm/solr-power
 *
 * Make a backup!
 *  - Cal
 *
 * @TODO refactor as an object
 *
 */
define('SOLR_POWER_PATH', plugin_dir_path(__FILE__) . '/');
define('SOLR_POWER_URL', plugin_dir_url(__FILE__));
require_once SOLR_POWER_PATH . '/vendor/autoload.php';
require_once SOLR_POWER_PATH . '/includes/class-solrpower.php';
require_once SOLR_POWER_PATH . '/includes/class-solrpower-options.php';
require_once SOLR_POWER_PATH . '/includes/class-solrpower-sync.php';
require_once SOLR_POWER_PATH . '/includes/class-solrpower-api.php';
require_once SOLR_POWER_PATH . '/includes/class-solrpower-wp-query.php';
register_activation_hook(__FILE__, array(SolrPower::get_instance(), 'activate'));
function s4wp_search_form()
{
    $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
    $order = filter_input(INPUT_GET, 'order', FILTER_SANITIZE_STRING);
    $server = filter_input(INPUT_GET, 'server', FILTER_SANITIZE_STRING);
    if ($sort == 'date') {
        $sortval = __('<option value="score">Score</option><option value="date" selected="selected">Date</option><option value="modified">Last Modified</option>');
    } else {
        if ($sort == 'modified') {
            $sortval = __('<option value="score">Score</option><option value="date">Date</option><option value="modified" selected="selected">Last Modified</option>');
        } else {
            $sortval = __('<option value="score" selected="selected">Score</option><option value="date">Date</option><option value="modified">Last Modified</option>');
        }
    }
    if ($order == 'asc') {