-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlike-posts.php
More file actions
102 lines (91 loc) · 3.27 KB
/
like-posts.php
File metadata and controls
102 lines (91 loc) · 3.27 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
93
94
95
96
97
98
99
100
101
102
<?php
/**
* Plugin Name: Modularity Like Posts
* Plugin URI: https://github.com/helsingborg-stad/modularity-like
* Description: Lets users like and save posts.
* Version: 3.1.3
* Author: Niclas Norin
* Author URI: https://github.com/NiclasNorin
* License: MIT
* License URI: https://opensource.org/licenses/MIT
* Text Domain: modularity-like
* Domain Path: /languages
*/
use ModularityLikePosts\Blade\Blade;
use ComponentLibrary\Init as ComponentLibraryInit;
use WpService\Implementations\NativeWpService;
use WpService\Implementations\WpServiceWithTypecastedReturns;
use Municipio\Helper\SiteSwitcher\SiteSwitcher;
use AcfService\AcfService;
use AcfService\Implementations\NativeAcfService;
use ModularityLikePosts\Helper\CacheBust;
// Protect agains direct file access
if (! defined('WPINC')) {
die;
}
define('MODULARITYLIKEPOSTS_PATH', plugin_dir_path(__FILE__));
define('MODULARITYLIKEPOSTS_URL', plugins_url('', __FILE__));
define('MODULARITYLIKEPOSTS_TEMPLATE_PATH', MODULARITYLIKEPOSTS_PATH . 'templates/');
define('MODULARITYLIKEPOSTS_VIEW_PATH', MODULARITYLIKEPOSTS_PATH . 'views/');
define('MODULARITYLIKEPOSTS_MODULE_VIEW_PATH', MODULARITYLIKEPOSTS_PATH . 'source/php/Module/views');
// Register the autoloader
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
}
$bladeInstance = new Blade(new ComponentLibraryInit([]));
require_once MODULARITYLIKEPOSTS_PATH . 'Public.php';
add_action('init', function () {
load_plugin_textdomain('modularity-like', false, plugin_basename(dirname(__FILE__)) . '/languages');
});
add_filter('/Modularity/externalViewPath', function ($arr) {
$arr['mod-liked-posts'] = MODULARITYLIKEPOSTS_MODULE_VIEW_PATH;
return $arr;
}, 10, 3);
// Acf auto import and export
add_action('acf/init', function () {
if (function_exists('acf_add_options_page')) {
acf_add_options_page([
'page_title' => _x('Modularity Like', 'Admin page title', 'modularity-like'),
'menu_slug' => 'modularity_like',
'icon_url' => 'dashicons-heart',
'position' => 105,
]);
}
$acfExportManager = new \AcfExportManager\AcfExportManager();
$acfExportManager->setTextdomain('modularity-like');
$acfExportManager->setExportFolder(MODULARITYLIKEPOSTS_PATH . 'source/php/AcfFields/');
$acfExportManager->autoExport(array(
'liked-posts-settings' => 'group_63e9fb49ad0f4',
'liked-posts-options' => 'group_63ecfd0993f44'
));
$acfExportManager->import();
});
//Services
$wpService = new WpServiceWithTypecastedReturns(new NativeWpService());
$acfService = new NativeAcfService();
$siteSwitcher = new SiteSwitcher(
$wpService,
$acfService
);
$getOptionFieldsHelper = new \ModularityLikePosts\Helper\GetOptionFields(
$acfService
);
$cacheBust = new \ModularityLikePosts\Helper\CacheBust();
$getPostsHelper = new \ModularityLikePosts\Api\GetPosts(
$wpService,
$getOptionFieldsHelper,
$siteSwitcher
);
$wpUtilService = new WpUtilService\WpUtilService(
$wpService
);
//Init
(new ModularityLikePosts\App(
$bladeInstance,
$siteSwitcher,
$wpService,
$wpUtilService,
$getPostsHelper,
$getOptionFieldsHelper,
$cacheBust
))->addHooks();