PluginProbe
WP Coder – Insert & Manage Code Snippets / 1.1
WP Coder – Insert & Manage Code Snippets v1.1
4.5.1 1.1 2.3.1 2.3.2 2.4.1 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 3.2 3.2.1 3.3 3.4 3.5 3.5.1 All 39 releases
wp-coder / include / class / data.php

data.php in WP Coder – Insert & Manage Code Snippets 1.1, at include/class/data.php

87 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit;
2 class WOW_DATA {
3 function addNewItem($tblname, $info) {
4 global $wpdb;
5 $fields = $wpdb->get_col("DESC ".$tblname, 0);
6 $data = array();
7 foreach ($fields as $key) {
8 if (is_array($info[$key]) == true){
9 $data[$key] = serialize($info[$key]);
10 }
11 else {
12 $data[$key] = $info[$key];
13 }
14 }
15 $wpdb->insert($tblname,$data);
16 $lastid = $wpdb->insert_id;
17 $result = $wpdb->get_results("SELECT * FROM ".$tblname." WHERE id = ".$lastid);
18 if (count($result) > 0) {
19 foreach ($result as $key => $val) {
20 $param = unserialize($val->param);
21 $file_script = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/admin/partials/generator/script.php';
22 if (file_exists ( $file_script )){
23 $path_script = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/asset/js/script-'.$lastid.'.js';
24 ob_start();
25 include ($file_script);
26 $content_script = ob_get_contents();
27 $packer = new JavaScriptPacker($content_script, 'Normal', true, false);
28 $packed = $packer->pack();
29 ob_end_clean();
30 file_put_contents($path_script, $packed);
31 }
32 $file_style = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/admin/partials/generator/style.php';
33 if (file_exists ( $file_style )){
34 $path_style = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/asset/css/style-'.$lastid.'.css';
35 ob_start();
36 include ($file_style);
37 $content_style = ob_get_contents();
38 ob_end_clean();
39 file_put_contents($path_style, $content_style);
40 }
41 }
42 }
43 }
44 function updItem($tblname, $info) {
45 global $wpdb;
46 $fields = $wpdb->get_col("DESC ".$tblname, 0);
47 $data = array();
48 foreach ($fields as $key) {
49 if (is_array($info[$key]) == true){
50 $data[$key] = serialize($info[$key]);
51 }
52 else {
53 $data[$key] = $info[$key];
54 }
55 }
56 $where = array('id' => $info["id"]);
57 $id = $info["id"];
58 $wpdb->update( $tblname, $data, array('id' => $id), $format = null, $where_format = null );
59 $result = $wpdb->get_results("SELECT * FROM ".$tblname." WHERE id = ".$id);
60 if (count($result) > 0) {
61 foreach ($result as $key => $val) {
62 $param = unserialize($val->param);
63 $file_script = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/admin/partials/generator/script.php';
64 if (file_exists ( $file_script )){
65 $path_script = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/asset/js/script-'.$id.'.js';
66 ob_start();
67 include ($file_script);
68 $content_script = ob_get_contents();
69 $packer = new JavaScriptPacker($content_script, 'Normal', true, false);
70 $packed = $packer->pack();
71 ob_end_clean();
72 file_put_contents($path_script, $packed);
73 }
74 $file_style = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/admin/partials/generator/style.php';
75 if (file_exists ( $file_style )){
76 $path_style = WP_PLUGIN_DIR.'/'.$info["plugdir"] .'/asset/css/style-'.$id.'.css';
77 ob_start();
78 include ($file_style);
79 $content_style = ob_get_contents();
80 ob_end_clean();
81 file_put_contents($path_style, $content_style);
82 }
83 }
84 }
85 }
86 }
87 ?>