function remove_easypopulate()
{
    global $gBitDb;
    global $ep_keys;
    $sql = "SELECT\n\t\t\tconfiguration_group_id\n\t\tFROM\n\t\t\t" . TABLE_CONFIGURATION_GROUP . "\n\t\tWHERE\n\t\tconfiguration_group_title = 'Easy Populate'";
    $result = ep_query($sql);
    if (mysql_num_rows($result)) {
        // we have at least 1 EP group - let's delete it
        $ep_groups = mysql_fetch_array($result);
        foreach ($ep_groups as $ep_group) {
            $gBitDb->Execute("delete from " . TABLE_CONFIGURATION_GROUP . "\n\t             where configuration_group_id = '" . (int) $ep_group . "'");
        }
    }
    // now delete any EP keys found in config
    foreach ($ep_keys as $ep_key) {
        @$gBitDb->Execute("delete from " . TABLE_CONFIGURATION . "\n\t           where configuration_key = '" . $ep_key . "'");
    }
}
示例#2
0
             // insert new into specials
             $sql = "INSERT INTO " . TABLE_SPECIALS . "\n\t\t\t\t\t\t\t\t\t\t\t\t(products_id,\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_new_products_price,\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_date_added,\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_date_available,\n\t\t\t\t\t\t\t\t\t\t\t\texpires_date,\n\t\t\t\t\t\t\t\t\t\t\t\tstatus)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . (int) $v_products_id . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $v_specials_price . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnow(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $v_specials_date_avail . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $v_specials_expires_date . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'1')";
             $result = ep_query($sql);
             $specials_print .= sprintf(EASYPOPULATE_SPECIALS_NEW, $v_products_model, substr(strip_tags($v_products_name[$epdlanguage_id]), 0, 10), $v_products_price, $v_specials_price);
         } else {
             // existing product
             if ($v_specials_price == '0') {
                 // delete of existing requested
                 $db->Execute("delete from " . TABLE_SPECIALS . "\n\t\t\t\t\t\t\t\t\t where products_id = '" . (int) $v_products_id . "'");
                 $specials_print .= sprintf(EASYPOPULATE_SPECIALS_DELETE, $v_products_model);
                 continue;
             }
             // just make an update
             $sql = "UPDATE " . TABLE_SPECIALS . " SET\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_new_products_price = '" . $v_specials_price . "',\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_last_modified = now(),\n\t\t\t\t\t\t\t\t\t\t\t\tspecials_date_available = '" . $v_specials_date_avail . "',\n\t\t\t\t\t\t\t\t\t\t\t\texpires_date = '" . $v_specials_expires_date . "',\n\t\t\t\t\t\t\t\t\t\t\t\tstatus = '1'\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE products_id = '" . (int) $v_products_id . "'";
             // echo $sql . "<br>";
             ep_query($sql);
             $specials_print .= sprintf(EASYPOPULATE_SPECIALS_UPDATE, $v_products_model, substr(strip_tags($v_products_name[$epdlanguage_id]), 0, 10), $v_products_price, $v_specials_price);
         }
         // we still have our special here..
     }
     // end specials for this product
 } else {
     // this record is missing the product_model
     $display_output .= EASYPOPULATE_DISPLAY_RESULT_NO_MODEL;
     foreach ($items as $col => $langer) {
         if ($col == $filelayout['v_products_model']) {
             continue;
         }
         $display_output .= print_el($langer);
     }
 }
 /**
  * Filter query string used for get_posts(). Query for posts and save for later.
  * Return a query that will return nothing.
  *
  * @param string $request
  * @param object $query
  * @since 0.9
  * @return string
  */
 public function filter_posts_request($request, $query)
 {
     if (!ep_elasticpress_enabled($query) || apply_filters('ep_skip_query_integration', false, $query)) {
         return $request;
     }
     $query_vars = $query->query_vars;
     /**
      * Allows us to filter in searchable post types if needed
      *
      * @since  2.1
      */
     $query_vars['post_type'] = apply_filters('ep_query_post_type', $query_vars['post_type'], $query);
     if ('any' === $query_vars['post_type']) {
         unset($query_vars['post_type']);
     }
     $new_posts = apply_filters('ep_wp_query_search_cached_posts', array(), $query);
     if (count($new_posts) < 1) {
         $scope = 'current';
         if (!empty($query_vars['sites'])) {
             $scope = $query_vars['sites'];
         }
         $formatted_args = ep_format_args($query_vars);
         /**
          * Filter search scope
          *
          * @since 2.1
          *
          * @param mixed $scope The search scope. Accepts `all` (string), a single
          *                     site id (int or string), or an array of site ids (array).
          */
         $scope = apply_filters('ep_search_scope', $scope);
         $ep_query = ep_query($formatted_args, $query->query_vars, $scope);
         if (false === $ep_query) {
             return $request;
         }
         $query->found_posts = $ep_query['found_posts'];
         $query->max_num_pages = ceil($ep_query['found_posts'] / $query->get('posts_per_page'));
         foreach ($ep_query['posts'] as $post_array) {
             $post = new stdClass();
             $post->ID = $post_array['post_id'];
             $post->site_id = get_current_blog_id();
             if (!empty($post_array['site_id'])) {
                 $post->site_id = $post_array['site_id'];
             }
             // ep_search_request_args
             $post_return_args = apply_filters('ep_search_post_return_args', array('post_type', 'post_author', 'post_name', 'post_status', 'post_title', 'post_parent', 'post_content', 'post_excerpt', 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt', 'post_mime_type', 'comment_count', 'comment_status', 'ping_status', 'menu_order', 'permalink', 'terms', 'post_meta'));
             foreach ($post_return_args as $key) {
                 if ($key === 'post_author') {
                     $post->{$key} = $post_array[$key]['id'];
                 } elseif (isset($post_array[$key])) {
                     $post->{$key} = $post_array[$key];
                 }
             }
             $post->elasticsearch = true;
             // Super useful for debugging
             if ($post) {
                 $new_posts[] = $post;
             }
         }
         do_action('ep_wp_query_non_cached_search', $new_posts, $ep_query, $query);
     }
     $this->posts_by_query[spl_object_hash($query)] = $new_posts;
     do_action('ep_wp_query_search', $new_posts, $ep_query, $query);
     global $wpdb;
     return "SELECT * FROM {$wpdb->posts} WHERE 1=0";
 }