forked from stuttter/wp-post-publish-ays
/
wp-post-publish-ays.php
83 lines (72 loc) · 1.97 KB
/
wp-post-publish-ays.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Plugin Name: WP Post Publish AYS
* Plugin URI: https://wordpress.org/plugins/wp-post-publish-ays/
* Author: John James Jacoby
* Author URI: https://profiles.wordpress.org/johnjamesjacoby/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Description: Shows an "Are you sure?" message before posts go live
* Version: 0.1.0
* Text Domain: wp-post-publish-ays
* Domain Path: /assets/lang/
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Enqueue the main JavaScript file
*
* @since 0.1.0
*/
function _wp_post_publish_ays() {
$url = wp_post_publish_ays_get_plugin_url();
$ver = wp_post_publish_ays_get_asset_version();
// Enqueues
wp_enqueue_script( 'wp_post_publish_ays', $url . 'assets/js/wp-post-publish-ays.js', array( 'jquery' ), $ver, true );
// Localize
wp_localize_script( 'wp_post_publish_ays', 'WP_Post_Publish_AYS', array(
'publish' => __( 'Publish', 'wp-post-publish-ays' ),
'update' => __( 'Update', 'wp-post-publish-ays' ),
'confirm' => wp_post_publish_ays_confirm_text()
) );
}
add_action( 'admin_enqueue_scripts', '_wp_post_publish_ays' );
/**
* Return the plugin's URL
*
* @since 0.1.0
*
* @return string
*/
function wp_post_publish_ays_get_plugin_url() {
return plugin_dir_url( __FILE__ );
}
/**
* Return the asset version
*
* @since 0.1.0
*
* @return int
*/
function wp_post_publish_ays_get_asset_version() {
return 201602080001;
}
/**
* Loads the translation file.
*
* @since 0.1.0
*/
function wp_post_publish_ays_i18n() {
load_plugin_textdomain( 'wp-post-publish-ays', false, dirname( plugin_basename( __FILE__ ) ) . '/assets/lang/' );
}
/**
* Allow confirmation text to be filtered
*
* @since 0.1.0
*
* @return string
*/
function wp_post_publish_ays_confirm_text() {
$default = __( 'Are you really ready to publish this?', 'wp-post-publish-ays' );
return apply_filters( 'wp_post_publish_ays_confirm_text', $default );
}