PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.2.6
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.2.6
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
← All changes | includes/Core/Migration.php +82 -81 3.5.24.2.6 View file →
@@ -7,103 +7,104 @@
7 7 use WPDeveloper\BetterDocs\Utils\Database;
8 8 use WPDeveloper\BetterDocs\Dependencies\DI\Container;
9 9
10 10 class Migration extends Base {
11 - /**
12 - * Database
13 - * @var Database
14 - */
15 - private $database;
16 - private $settings;
17 - private $container;
11 + /**
12 + * Database
13 + * @var Database
14 + */
15 + private $database;
16 + private $settings;
17 + private $container;
18 18
19 - public function __construct( Container $container ) {
20 - $this->container = $container;
21 - $this->database = $container->get( Database::class );
22 - $this->settings = $container->get( Settings::class );
23 - }
19 + public function __construct( Container $container ) {
20 + $this->container = $container;
21 + $this->database = $container->get( Database::class );
22 + $this->settings = $container->get( Settings::class );
23 + }
24 24
25 - public function init( $version ) {
26 - if( $version > 250 ) {
27 - for( $_version = 250; $_version <= $version; $_version++ ) {
28 - if( method_exists( $this, "v$_version") ) {
29 - call_user_func([$this, "v$_version"]);
30 - }
31 - }
32 - }
25 + public function init( $version ) {
26 + if ( $version > 250 ) {
27 + for ( $_version = 250; $_version <= $version; $_version++ ) {
28 + if ( method_exists( $this, "v$_version" ) ) {
29 + call_user_func( [ $this, "v$_version" ] );
30 + }
31 + }
32 + }
33 33
34 - $this->search_migration();
34 + $this->search_migration();
35 35
36 - /**
37 - * Settings Migration
38 - */
39 - $this->settings->migration( $version );
40 - }
36 + /**
37 + * Settings Migration
38 + */
39 + $this->settings->migration( $version );
40 + }
41 41
42 - public function search_migration() {
43 - global $wpdb;
44 - if ( ! $this->database->get( 'betterdocs_search_data_migration', false ) ) {
45 - $search_data = $this->database->get( 'betterdocs_search_data' );
46 - if ( ! empty( $search_data ) ) {
47 - $search_data_arr = unserialize( $search_data );
48 - foreach ( $search_data_arr as $key => $value ) {
49 - $args = [
50 - 'post_type' => 'docs',
51 - 'post_status' => 'publish',
52 - 'posts_per_page' => -1,
53 - 'suppress_filters' => true,
54 - 's' => $key
55 - ];
42 + public function search_migration() {
43 + global $wpdb;
44 + if ( ! $this->database->get( 'betterdocs_search_data_migration', false ) ) {
45 + $search_data = $this->database->get( 'betterdocs_search_data' );
46 + if ( ! empty( $search_data ) ) {
47 + $search_data_arr = unserialize( $search_data );
48 + foreach ( $search_data_arr as $key => $value ) {
49 + $args = [
50 + 'post_type' => 'docs',
51 + 'post_status' => 'publish',
52 + 'posts_per_page' => -1,
53 + 'suppress_filters' => true,
54 + 's' => $key
55 + ];
56 56
57 - $loop = new WP_Query( $args );
58 - if ( $loop->have_posts() ) {
59 - $count = $value;
60 - $not_found_count = 0;
61 - } else {
62 - $count = 0;
63 - $not_found_count = $value;
64 - }
57 + $loop = new WP_Query( $args );
58 + if ( $loop->have_posts() ) {
59 + $count = $value;
60 + $not_found_count = 0;
61 + } else {
62 + $count = 0;
63 + $not_found_count = $value;
64 + }
65 65
66 - $keyword = $wpdb->get_var(
67 - $wpdb->prepare( "
66 + $keyword = $wpdb->get_var(
67 + $wpdb->prepare(
68 + "
68 69 SELECT keyword
69 70 FROM {$wpdb->prefix}betterdocs_search_keyword
70 71 WHERE keyword = %s",
71 - $key
72 - )
73 - );
72 + $key
73 + )
74 + );
74 75
75 - if ( $keyword == NUll ) {
76 - $insert = $wpdb->query(
77 - $wpdb->prepare(
78 - "INSERT INTO {$wpdb->prefix}betterdocs_search_keyword
76 + if ( $keyword == null ) {
77 + $insert = $wpdb->query(
78 + $wpdb->prepare(
79 + "INSERT INTO {$wpdb->prefix}betterdocs_search_keyword
79 80 ( keyword )
80 81 VALUES ( %s )",
81 - [
82 - $key
83 - ]
84 - )
85 - );
82 + [
83 + $key
84 + ]
85 + )
86 + );
86 87
87 - if ( $insert ) {
88 - $wpdb->query(
89 - $wpdb->prepare(
90 - "INSERT INTO {$wpdb->prefix}betterdocs_search_log
88 + if ( $insert ) {
89 + $wpdb->query(
90 + $wpdb->prepare(
91 + "INSERT INTO {$wpdb->prefix}betterdocs_search_log
91 92 (keyword_id, count, not_found_count, created_at)
92 93 VALUES (%d, %d, %d, %s)",
93 - [
94 - $wpdb->insert_id,
95 - $count,
96 - $not_found_count,
97 - date( 'Y-m-d' )
98 - ]
99 - )
100 - );
101 - }
102 - }
103 - }
94 + [
95 + $wpdb->insert_id,
96 + $count,
97 + $not_found_count,
98 + date( 'Y-m-d' )
99 + ]
100 + )
101 + );
102 + }
103 + }
104 + }
104 105
105 - $this->database->save( 'betterdocs_search_data_migration', '1.0' );
106 - }
107 - }
108 - }
106 + $this->database->save( 'betterdocs_search_data_migration', '1.0' );
107 + }
108 + }
109 + }
109 110 }