-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjamstack-preview-and-deployments.php
68 lines (62 loc) · 2.66 KB
/
jamstack-preview-and-deployments.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
<?php
/**
* Plugin Name: JAMstack preview and deployments
* Plugin URI: https://github.com/emilpriver/jamstack-preview-and-deployments
* Description: Enable preview and deployments from the wordpress admin to your JAMstack application.
* Version: 1.1.1
* Author: Emil Privér
* Author URI: https://priver.dev
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* php version 7.2.10
*
* @category Plugins
* @package Wordpress
* @author Emil Priver <[email protected]>
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
* @link https://priver.dev
*/
define('JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY', plugin_dir_path(__FILE__));
define('JAMSTACK_PREVIEW_AND_DEPLOYMENTS_URL_DIRECTORY', plugin_dir_url(__FILE__));
define('JAMSTACK_PREVIEW_AND_DEPLOYMENTS_TEXT_DOMAIN', 'JamstackPreviewAndDEeloymentsTextDomain');
define('JAMSTACK_PREVIEW_AND_DEPLOYMENTS_SETTINGS_KEY', 'JamstackPreviewAndDeploymentsSettings');
define('JAMSTACK_PREVIEW_AND_DEPLOYMENTS_OPTIONS_KEY', 'JamstackPreviewAndDeploymentsOptionsKey');
/**
* Needed includes
*/
require_once JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY . 'admin/admin.php';
require_once JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY . 'admin/functions.php';
require_once JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY . 'preview/preview.php';
require_once JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY . 'actions.php';
require_once JAMSTACK_PREVIEW_AND_DEPLYOMENTS_PLUGIN_DIRECTORY . 'admin-bar.php';
/**
* Include scripts and styles
*/
add_action('admin_enqueue_scripts', function () {
wp_enqueue_script('jamstackPreviewDeploymentsScripts', JAMSTACK_PREVIEW_AND_DEPLOYMENTS_URL_DIRECTORY . 'admin/js/admin.js', array(), false, true);
wp_enqueue_style('jamstackPreviewDeploymentsStyles', JAMSTACK_PREVIEW_AND_DEPLOYMENTS_URL_DIRECTORY . 'admin/css/admin.css');
});
/**
* Create Admin interface
*/
add_action('admin_menu', function () {
add_options_page(
__('Jamstack preview and deployments', JAMSTACK_PREVIEW_AND_DEPLOYMENTS_TEXT_DOMAIN),
__('Jamstack preview and deployments', JAMSTACK_PREVIEW_AND_DEPLOYMENTS_TEXT_DOMAIN),
'manage_options',
'jamstack-preview-and-deployments',
'jamstackPreviewAndDeployments'
);
});
/**
* Ajax function that trigger a deploy only if user is loggedin
*
* @return Number
*/
add_action('wp_ajax_jamstack_deploy_website', 'jamstackPreviewAndDeploymentsTriggerDeploy');
function jamstackPreviewAndDeploymentsTriggerDeploy()
{
do_action('jamstack_preview_deployments_deploy_webhook');
echo 1;
wp_die();
}