PluginProbe
Hoot Import / 1.8
Hoot Import v1.8
trunk 1.7.1 1.8
hoot-import / hoot-import.php

hoot-import.php in Hoot Import 1.8, at hoot-import.php

186 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Hoot Import
4 * Description: Hoot Import lets you import demo content for WordPress themes by wpHoot.
5 * Version: 1.8
6 * Requires at least: 6.0
7 * Requires PHP: 7.4
8 * Author: wphoot
9 * Author URI: https://wphoot.com/
10 * License: GPL-3.0+
11 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
12 * Text Domain: hoot-import
13 * Domain Path: /languages
14 */
15
16 // If this file is called directly, abort.
17 if ( ! defined( 'ABSPATH' ) ) {
18 die;
19 }
20
21 /**
22 * The core plugin class.
23 * @since 1.0
24 * @package HootImport
25 */
26 if ( ! class_exists( 'HootImport' ) ) :
27
28 class HootImport {
29
30 /**
31 * Plugin Info
32 * @since 1.0
33 * @access public
34 */
35 public $version;
36 public $name;
37 public $slug;
38 public $file;
39 public $dir;
40 public $uri;
41 public $plugin_basename;
42
43 /**
44 * Theme Config
45 * @since 1.0
46 * @access public
47 */
48 public $demopack_dir;
49 public $demopack_url;
50 public $theme_config = array();
51
52 /**
53 * Constructor method.
54 * @since 1.0
55 * @access public
56 * @return void
57 */
58 public function __construct() {
59
60 // Plugin Info
61 $this->version = '1.8';
62 $this->name = 'Hoot Import';
63 $this->slug = 'hoot-import';
64 $this->file = __FILE__;
65 $this->dir = trailingslashit( plugin_dir_path( __FILE__ ) );
66 $this->uri = trailingslashit( plugin_dir_url( __FILE__ ) );
67 $this->plugin_basename = plugin_basename( __FILE__ );
68
69 // Setup Demopack Directory
70 $import_dir = '/hoot-import-demofiles/';
71 $upload_dir = wp_upload_dir( null, false );
72 $this->demopack_dir = $upload_dir['basedir'] . $import_dir;
73 $this->demopack_url = $upload_dir['baseurl'] . $import_dir;
74
75 // Load Text Domain
76 add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) );
77
78 // DeActivation Hook
79 register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
80
81 // Load Plugin Files and Helpers
82 $this->loader();
83
84 }
85
86 /**
87 * Load Plugin Files and Helpers
88 * @since 1.0
89 * @access public
90 * @return void
91 */
92 public function loader() {
93
94 if ( is_admin() ) {
95
96 // Setup theme config (filter added at after_setup_theme hook)
97 add_action( 'init', array( $this, 'setup_theme_config' ), 5 );
98
99 // Load Files
100 require_once( $this->dir . 'include/functions.php' );
101 require_once( $this->dir . 'include/class-importer.php' );
102 require_once( $this->dir . 'include/class-admin.php' );
103
104 }
105 }
106
107 /**
108 * Load Plugin Text Domain
109 * @since 1.0
110 * @access public
111 * @return void
112 */
113 public function load_plugin_textdomain() {
114 load_plugin_textdomain(
115 $this->slug,
116 false,
117 dirname( $this->plugin_basename ) . '/languages/'
118 );
119 }
120
121 /**
122 * DeActivation Hook
123 * @since 1.0
124 * @access public
125 * @return void
126 */
127 public function deactivation() {
128 delete_option( 'hootimport_admin_footer' );
129 hootimport_cleanup( $this->demopack_dir, true );
130 }
131
132 /**
133 * Setup theme config
134 * @since 1.0
135 * @access public
136 * @return void
137 */
138 public function setup_theme_config() {
139 // Theme Config
140 $this->theme_config = apply_filters( 'hootimport_theme_config', array() );
141 if ( ! is_array( $this->theme_config ) ) {
142 $this->theme_config = array();
143 }
144 }
145
146 /**
147 * Get theme config
148 * @since 1.0
149 * @access public
150 * @return mixed
151 */
152 public function get_theme_config( $key ) {
153 return ( is_array( $this->theme_config ) && isset( $this->theme_config[ $key ] ) ) ? $this->theme_config[ $key ] : null;
154 }
155
156 /**
157 * Returns the instance
158 * @since 1.0
159 * @access public
160 * @return object
161 */
162 public static function get_instance() {
163 static $instance = null;
164 if ( is_null( $instance ) ) {
165 $instance = new self;
166 }
167 return $instance;
168 }
169
170 }
171
172 /**
173 * Gets the instance of the `HootImport` class. This function is useful for quickly grabbing data
174 * used throughout the plugin.
175 * @since 1.0
176 * @access public
177 * @return object
178 */
179 function hootimport() {
180 return HootImport::get_instance();
181 }
182
183 // Lets roll!
184 hootimport();
185
186 endif;