You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: model/common/page.php
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,11 @@ public function getPage($page_id)
8
8
9
9
$sql = "SELECT p.ID, p.post_title AS title, p.`post_content` AS description, p.`menu_order` AS sort_order FROM ".$wpdb->prefix."posts p WHERE p.`post_type` = 'page' AND p.`ID` = '".(int)$page_id."'";
10
10
11
-
$result = $wpdb->get_row($sql);
11
+
$result = get_transient(md5($sql));
12
+
if($result === false) {
13
+
$result = $wpdb->get_row( $sql );
14
+
set_transient(md5($sql), $result, 300);
15
+
}
12
16
13
17
return$result;
14
18
}
@@ -62,7 +66,11 @@ public function getPages($data = array())
Copy file name to clipboardExpand all lines: model/store/option.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,13 @@ class VFA_ModelStoreOption extends VFA_Model
5
5
publicfunctiongetOptionLabel($name) {
6
6
global$wpdb;
7
7
8
-
$result = $wpdb->get_row("SELECT wat.`attribute_label` AS label FROM `".$wpdb->prefix."woocommerce_attribute_taxonomies` wat WHERE wat.`attribute_name` = '".str_replace('pa_', '', $name)."'");
8
+
$sql = "SELECT wat.`attribute_label` AS label FROM `".$wpdb->prefix."woocommerce_attribute_taxonomies` wat WHERE wat.`attribute_name` = '".str_replace('pa_', '', $name)."'";
Copy file name to clipboardExpand all lines: model/store/product.php
+55-14Lines changed: 55 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,13 @@ public function getProductRelated($product_id)
6
6
{
7
7
global$wpdb;
8
8
9
-
$result = $wpdb->get_row("SELECT pm.`meta_value` AS related FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_upsell_ids'");
9
+
$sql = "SELECT pm.`meta_value` AS related FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_upsell_ids'";
10
+
11
+
$result = get_transient(md5($sql));
12
+
if($result === false) {
13
+
$result = $wpdb->get_row( $sql );
14
+
set_transient(md5($sql), $result, 300);
15
+
}
10
16
11
17
$product_data = unserialize($result->related);
12
18
@@ -17,7 +23,13 @@ public function getProductImages($product_id)
17
23
{
18
24
global$wpdb;
19
25
20
-
$result = $wpdb->get_row("SELECT pm.`meta_value` AS images FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_product_image_gallery'");
26
+
$sql = "SELECT pm.`meta_value` AS images FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_product_image_gallery'";
@@ -28,7 +40,13 @@ public function getProductAttributes($product_id)
28
40
{
29
41
global$wpdb;
30
42
31
-
$result = $wpdb->get_row("SELECT pm.`meta_value` AS attributes FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_product_attributes'");
43
+
$sql = "SELECT pm.`meta_value` AS attributes FROM `".$wpdb->prefix."postmeta` pm WHERE pm.`post_id` = '".(int)$product_id."' AND pm.`meta_key` = '_product_attributes'";
0 commit comments