-
Notifications
You must be signed in to change notification settings - Fork 21
/
progressive-web-apps.php
69 lines (53 loc) · 2.04 KB
/
progressive-web-apps.php
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
<?php
/**
* Plugin Name: Progressive Web Apps
* Plugin URI: http://wordpress.org/plugins/progressive-web-apps/
* Description: Progressive Web Apps use modern web capabilities to deliver app-like user experiences. They're reliable, fast and engaging.
* Author: PWAThemes.com
* Author URI: https://pwathemes.com/
* Version: 1.0
* Copyright (c) 2017 PWAThemes.com
* License: The Progressive Web Apps is Licensed under the Apache License, Version 2.0
* Text Domain: progressive-web-apps
*/
namespace PWAPP;
use PWAPP\Admin\Admin_Init;
use PWAPP\Admin\Admin_Ajax;
use PWAPP\Frontend\Application;
use PWAPP\Inc\Api;
use PWAPP\Core\PWAPP;
require_once 'vendor/autoload.php';
require_once 'core/config.php';
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
global $progressive_web_apps;
$progressive_web_apps = new PWAPP();
/**
* Used to load the required files on the plugins_loaded hook, instead of immediately.
*/
function pwapp_admin_init() {
new Admin_Init();
}
function pwapp_frontend_init() {
new Application();
}
$api = new Api();
add_action( 'rest_api_init', [ $api, 'register_pwapp_routes' ] );
// Uncomment the line below to enable comments
// add_filter( 'rest_allow_anonymous_comments', '__return_true' );
// Add hooks for activating & deactivating the plugin
register_activation_hook( __FILE__, [ $progressive_web_apps, 'activate' ] );
register_deactivation_hook( __FILE__, [ $progressive_web_apps, 'deactivate' ] );
// Initialize the plugin's check logic and rendering
if ( is_admin() ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
$admin_ajax = new Admin_Ajax();
add_action( 'wp_ajax_pwapp_editimages', [ $admin_ajax, 'theme_editimages' ] );
add_action( 'wp_ajax_pwapp_theme_settings', [ $admin_ajax, 'theme_settings' ] );
add_action( 'wp_ajax_pwapp_send_feedback', [ $admin_ajax, 'send_feedback' ] );
add_action( 'wp_ajax_pwapp_settings_save', [ $admin_ajax, 'settings_save' ] );
} else {
add_action( 'plugins_loaded', 'PWAPP\pwapp_admin_init' );
}
} else {
add_action( 'plugins_loaded', 'PWAPP\pwapp_frontend_init' );
}