Repository navigation
Expand file tree
/
Copy pathAWDatafeed.php
More file actions
92 lines (79 loc) · 3.04 KB
/
Copy pathAWDatafeed.php
File metadata and controls
92 lines (79 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
defined( 'ABSPATH' ) OR exit;
/*
Plugin Name: Awin Data Feed
Version: 1.0
Plugin URI: https://wordpress.org/plugins/awin-data-feed
Description: Sell your affiliate product from affiliate window product data feed
Author: digitalwindow
Author URI: http://mmrs151.wordpress.com/
Text Domain: awin-data-feed
Domain Path: /languages
*/
use Datafeed\PluginContainer;
spl_autoload_register( 'datafeed_autoloader' );
function datafeed_autoloader( $class_name ) {
if ( false !== strpos( $class_name, 'Datafeed' ) ) {
$classes_dir = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
$class_file = str_replace( '\\', DIRECTORY_SEPARATOR, $class_name ) . '.php';
require_once $classes_dir . $class_file;
}
}
add_action( 'plugins_loaded', 'datafeed_init' ); // Hook initialization function
function datafeed_init() {
$container = new PluginContainer(); // Create container
$container['path'] = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR;
$container['url'] = plugin_dir_url( __FILE__ );
$container['version'] = '1.0.0';
$container['settings_page_properties'] = array(
'parent_slug' => 'datafeed-settings',
'page_title' => __('Datafeed', 'awin-data-feed'),
'menu_title' => __('Datafeed', 'awin-data-feed'),
'sub_menu_title' => __('Settings', 'awin-data-feed'),
'help_menu_title' => __('Datafeed Guide', 'awin-data-feed'),
'help_menu_slug' => 'data-feed-guide',
'capability' => 'manage_options',
'menu_slug' => 'datafeed-settings',
'option_group' => 'datafeed_option_group',
'option_name' => 'datafeed_option_name',
'icon' => plugins_url( 'assets/icon.png' , __FILE__),
);
$container['settings_page'] = function ( $container ) {
return new Datafeed\SettingsMenu(
$container['db_adapter'],
$container['option_handler'],
$container['importer'],
$container['upload_error_handler'],
$container['processor'],
$container['settings_page_properties']
);
};
$container['option_handler'] = function ( $container ) {
return new \Datafeed\OptionHandler();
};
$container['db_adapter'] = function ( $container ) {
return new \Datafeed\DBAdapter($container['option_handler']);
};
$container['widget_printer'] = function ( $container ) {
return new \Datafeed\WidgetPrinter();
};
$container['processor'] = function ( $container ) {
return new \Datafeed\Processor($container['db_adapter'], $container['widget_printer']);
};
$container['upload_error_handler'] = function ( $container ) {
return new \Datafeed\UploadErrorHandler(array());
};
$container['importer'] = function ( $container ) {
return new \Datafeed\Importer( $container['db_adapter']);
};
$container['shortcode_handler'] = function ( $container ) {
return new \Datafeed\ShortcodeHandler();
};
$container['widget'] = function ( $container ) {
return new \Datafeed\Widget();
};
$container['ajax_handler'] = function ( $container ) {
return new \Datafeed\AjaxHandler($container['processor'], $container['db_adapter']);
};
$container->run();
}