-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathappthemes-updater.php
98 lines (78 loc) · 3.04 KB
/
appthemes-updater.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/*
* Plugin Name: AppThemes Updater
* Description: Automatically notifies you when AppThemes and Marketplace product updates are available.
* Version: 1.4.1
* Author: AppThemes
* Author URI: https://www.appthemes.com
* AppThemes ID: appthemes-updater
* Text Domain: appthemes-updater
* Domain Path: /languages
*/
function app_updater_activate() {
app_refresh_themes();
app_refresh_plugins();
}
function app_refresh_themes() {
delete_site_transient( 'update_themes' );
wp_update_themes();
}
function app_refresh_plugins() {
delete_site_transient( 'update_plugins' );
wp_update_plugins();
}
function app_extra_headers( $headers ) {
$headers['AppThemes ID'] = 'AppThemes ID';
return $headers;
}
function app_updater_init() {
require_once( dirname( __FILE__ ) . '/updater-class.php' );
require_once( dirname( __FILE__ ) . '/updater-ui.php' );
new APP_Theme_Upgrader;
new APP_Plugin_Upgrader;
new APP_Upgrader_Regular;
}
if ( is_admin() ) {
app_updater_init();
add_filter( 'extra_plugin_headers', 'app_extra_headers' );
add_filter( 'extra_theme_headers', 'app_extra_headers' );
add_action( 'load-update-core.php', 'app_updater_activate' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_themes' );
register_activation_hook( __FILE__, 'app_updater_activate' );
}
/**
* Load the localization files.
*
* @since 1.4.0
*
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
*
* Locales found in (unless WP_LANG_DIR is defined differently in wp-config.php:
* - wp-content/languages/appthemes-updater/appthemes-updater-LOCALE.mo
* - wp-content/languages/plugins/appthemes-updater-LOCALE.mo
*/
function app_updater_load_textdomain() {
$domain = 'appthemes-updater';
// Load the locale (e.g. de_DE) based on the WordPress site language set (wp-admin => Settings => General).
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
// Load any custom .mo file first, if it's found.
load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
// Load the plugin's .mo file if it's found and no custom .mo file exists.
load_plugin_textdomain( $domain, false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'app_updater_load_textdomain' );
/**
* Adds plugin action links.
*
* @since 1.4.0
*/
function app_updater_action_links( $links ) {
$plugin_links = array(
'<a href="' . esc_url( get_admin_url( null, 'options-general.php?page=appthemes-key-config' ) ) . '">' . __( 'Settings', 'appthemes-updater' ) . '</a>',
'<a href="https://docs.appthemes.com/tutorials/installing-the-appthemes-updater-plugin/" target="_blank">' . __( 'Docs', 'appthemes-updater' ) . '</a>',
'<a href="http://forums.appthemes.com/appthemes-updater-plugin/" target="_blank">' . __( 'Support', 'appthemes-updater' ) . '</a>',
);
return array_merge( $plugin_links, $links );
}
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'app_updater_action_links' );