1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plugin Name: Test Content Generator |
4
|
|
|
* Plugin URI: https://github.com/oldtownmedia/test-content-suite |
5
|
|
|
* Description: Spin up test posts, pages, CPTs, and terms from an easy-to-use admin page. |
6
|
|
|
* Version: 1.0 |
7
|
|
|
* Author: Old Town Media |
8
|
|
|
* Author URI: https://github.com/oldtownmedia/ |
9
|
|
|
* Text Domain: otm-test-content |
10
|
|
|
* Domain Path: /languages |
11
|
|
|
* License: GPL2 |
12
|
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace testContent; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Autoloader callback. |
19
|
|
|
* |
20
|
|
|
* Converts a class name to a file path and requires it if it exists. |
21
|
|
|
* |
22
|
|
|
* @param string $class Class name. |
23
|
|
|
*/ |
24
|
|
|
function test_content_autoloader( $class ) { |
25
|
|
|
if ( __NAMESPACE__ !== explode( '\\', $class )[0] ){ |
26
|
|
|
return; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
$class = str_replace( __NAMESPACE__ . '\\', '', $class ); |
30
|
|
|
$class = strtolower( preg_replace( '/(?<!^)([A-Z])/', '-\\1', $class ) ); |
31
|
|
|
|
32
|
|
|
$file = dirname( __FILE__ ) . '/includes/class-' . $class . '.php'; |
33
|
|
|
|
34
|
|
|
if ( file_exists( $file ) ) { |
35
|
|
|
require_once( $file ); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
spl_autoload_register( __NAMESPACE__ . '\test_content_autoloader' ); |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Retrieve the plugin instance. |
43
|
|
|
* |
44
|
|
|
* @return object Plugin |
45
|
|
|
*/ |
46
|
|
|
function plugin() { |
47
|
|
|
static $instance; |
48
|
|
|
|
49
|
|
|
if ( null === $instance ) { |
50
|
|
|
$instance = new Plugin(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $instance; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
// Set our definitions for later use |
57
|
|
|
plugin()->set_definitions( |
58
|
|
|
(object) array( |
59
|
|
|
'basename' => plugin_basename( __FILE__ ), |
60
|
|
|
'directory' => plugin_dir_path( __FILE__ ), |
61
|
|
|
'file' => __FILE__, |
62
|
|
|
'slug' => 'structure', |
63
|
|
|
'url' => plugin_dir_url( __FILE__ ) |
64
|
|
|
) |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
// Register hook providers. |
68
|
|
|
plugin()->register_hooks( new AdminPage() ); |
69
|
|
|
|
70
|
|
|
// Load textdomain hook |
71
|
|
|
add_action( 'plugins_loaded', array( plugin(), 'load_textdomain' ) ); |
72
|
|
|
|