isset( $settings['username'] ) ? preg_replace( '/[^0-9A-Za-z_-]/', '', (string) $settings['username'] ) : '',
'key' => isset( $settings['key'] ) ? preg_replace( '/[^0-9A-Za-z]/', '', (string) $settings['key'] ) : '',
'hideKey' => ! empty( $settings['hideKey'] ),
'hideName' => ! empty( $settings['hideName'] ),
'autoUpdate' => ! empty( $settings['autoUpdate'] ),
'hideNotice' => ! empty( $settings['hideNotice'] ),
'notification'=> ! empty( $settings['notification'] ),
'noticeEmail' => isset( $settings['noticeEmail'] ) && is_email( $settings['noticeEmail'] ) ? sanitize_email( $settings['noticeEmail'] ) : '',
);
}
function activate_themify_updater() {
delete_option('themify_updater_cache');
delete_transient('themify_updater_cache');
$timestamp = wp_next_scheduled('updater_hourly_schedule_notification');
if ( $timestamp ) {
$schedule = wp_get_schedule('updater_hourly_schedule_notification');
if ( $schedule === 'hourly' ) {
wp_clear_scheduled_hook('updater_hourly_schedule_notification');
}
}
$path = plugin_dir_path( __FILE__ );
if ( file_exists( $path . 'config.json' ) ) {
if ( ! get_option( 'themify_updater_licence' ) ) {
$settings = file_get_contents( $path . 'config.json' );
$settings = themify_updater_sanitize_settings_payload( $settings );
if ( ! empty( $settings ) ) {
update_option( 'themify_updater_licence', wp_json_encode( $settings ), false );
}
}
@unlink( $path . 'config.json' );
}
}
register_activation_hook(__FILE__, 'activate_themify_updater');
function deactivate_themify_updater() {
wp_clear_scheduled_hook('updater_hourly_schedule_notification');
delete_option('themify_updater_cache');
delete_transient('themify_updater_cache');
}
register_deactivation_hook(__FILE__, 'deactivate_themify_updater');
function themify_updater_init() {
if ( ! is_admin() && ! wp_doing_cron() && ! defined( 'WP_CLI' ) ) {
return;
}
load_plugin_textdomain( 'themify-updater', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
$path = plugin_dir_path(__FILE__);
require $path . 'includes/class.utils.php';
require $path . 'includes/class.cache.php';
require $path . 'includes/class.request.php';
require $path . 'includes/class.notifications.php';
require $path . 'includes/class.version.php';
require $path . 'includes/class.license.php';
require $path . 'includes/class.promotion.php';
require $path . 'includes/themify.updater.php';
require $path . 'includes/class.auto.update.php';
if( !function_exists('get_plugin_data') || !function_exists('is_plugin_active_for_network') ){
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
define('THEMIFY_UPDATER_DIR_PATH', dirname( __FILE__ ) );
define('THEMIFY_UPDATER_VERSION', '1.5.9');
define('THEMIFY_UPDATER_DIR_URL', plugin_dir_url(__FILE__));
define('THEMIFY_UPDATER_NETWORK_ENABLED', is_plugin_active_for_network(basename(dirname(__FILE__)).'/'.basename(__FILE__)));
Themify_Updater::get_instance();
}
add_action( 'init', 'themify_updater_init' );
function themify_updater_plugin_row_meta( $links, $file ) {
if ( plugin_basename( __FILE__ ) === $file ) {
$row_meta = array(
'changelogs' => '' . esc_html__( 'View Changelogs', 'themify-updater' ) . ''
);
return array_merge( $links, $row_meta );
}
return (array) $links;
}
add_filter( 'plugin_row_meta', 'themify_updater_plugin_row_meta', 10, 2 );
function themify_updater_action_links( $links ) {
$tlinks = array(
''.__('Themify License', 'themify-updater') .'',
);
return array_merge( $links, $tlinks );
}
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'themify_updater_action_links' );