PluginProbe
Boxzilla – WordPress Popup Builder / 3.2.13
Boxzilla – WordPress Popup Builder v3.2.13
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / src / admin / class-installer.php

class-installer.php in Boxzilla – WordPress Popup Builder 3.2.13, at src/admin/class-installer.php

99 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace Boxzilla\Admin;
5
6 class Installer
7 {
8
9 /**
10 * Run the installer
11 */
12 public static function run()
13 {
14 $installer = new self;
15 $installer->install();
16 }
17
18 /**
19 * The main install method
20 */
21 public function install()
22 {
23
24 // don't install sample boxes on multisite
25 if (is_multisite()) {
26 return;
27 }
28
29 $this->transfer_from_stb();
30 $this->create_sample_box();
31 }
32
33 /**
34 *
35 */
36 public function transfer_from_stb()
37 {
38 global $wpdb;
39
40 // transfer post types
41 $query = $wpdb->prepare("UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", 'boxzilla-box', 'scroll-triggered-box');
42 $wpdb->query($query);
43
44 // transfer post meta
45 $query = $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s", 'boxzilla_options', 'stb_options');
46 $wpdb->query($query);
47
48 // transfer rules
49 $query = $wpdb->prepare("UPDATE {$wpdb->options} SET option_name = %s WHERE option_name = %s", 'boxzilla_rules', 'stb_rules');
50 $wpdb->query($query);
51 }
52
53 /**
54 * @return bool
55 */
56 protected function create_sample_box()
57 {
58
59 // only create sample box if no boxes were found
60 $boxes = get_posts(
61 array(
62 'post_type' => 'boxzilla-box',
63 'post_status' => array( 'publish', 'draft' )
64 )
65 );
66
67 if (! empty($boxes)) {
68 return false;
69 }
70
71 $box_id = wp_insert_post(
72 array(
73 'post_type' => 'boxzilla-box',
74 'post_title' => "Sample Box",
75 'post_content' => "<h4>Hello world.</h4><p>This is a sample box, with some sample content in it.</p>",
76 'post_status' => 'draft',
77 )
78 );
79
80 // set box settings
81 $settings = array(
82 'css' => array(
83 'background_color' => '#edf9ff',
84 'color' => '',
85 'width' => '340',
86 'border_color' => '#dd7575',
87 'border_width' => '4',
88 'border_style' => 'dashed',
89 'position' => 'bottom-right',
90 'manual' => ''
91 )
92 );
93
94 update_post_meta($box_id, 'boxzilla_options', $settings);
95
96 return true;
97 }
98 }
99