getOption( 'an_option_selectors' ) == false ) {
wp_register_script( 'an_scripts', AN_URL . 'js/an-scripts.js', array( 'jquery' ), $anVersion, true );
wp_register_style( 'an_style', AN_URL . 'css/an-style.css', array(), $anVersion, null );
} elseif ( $anScripts['temp-path'] != false ) {
// check if server is SSL
if ( is_ssl() ) {
$anScripts['temp-url'] = preg_replace( '/^http:/i', 'https:', $anScripts['temp-url'] );
}
wp_register_script( 'an_scripts', $anScripts['temp-url'] . $anScripts['files']['js'], array( 'jquery' ), $anVersion, true );
wp_register_style( 'an_style', $anScripts['temp-url'] . $anScripts['files']['css'], array(), $anVersion, null );
$content_style = $wp_filesystem->get_contents( $anScripts['temp-path'] . $anScripts['files']['css'] );
}
if ( $anScripts['temp-path'] == false && $an_option->getOption( 'an_option_selectors' ) == true ) {
// Print Style and script in the footer with an_prepare (functions.php)
// CSS file does not exist anymore
wp_dequeue_style( 'tf-compiled-options-adblocker_notify' );
}
wp_enqueue_script( 'an_scripts' );
wp_enqueue_style( 'an_style' );
$content_style = str_replace( array( "\r\n", "\r", "\n" ), '', $content_style );
wp_add_inline_style( 'an_style', $content_style );
// AJAX
wp_localize_script(
'an_scripts', 'ajax_object', array(
'nonce' => wp_create_nonce( 'an-nonce' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
)
);
// CSS file does not exist anymore
if ( $an_option->getOption( 'an_option_selectors' ) == true ) {
wp_dequeue_style( 'tf-compiled-options-adblocker_notify' );
}
}// End if().
}
add_action( 'wp_enqueue_scripts', 'an_enqueue_an_sripts', 100 );
/**
* ************************************************************
* Back-End Styles enqueueing
***************************************************************/
function an_register_global_styles() {
?>
get_contents( AN_PATH . 'css/an-admin-style.css' );
$ttfcss = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/css/admin-styles.css' );
?>
get_contents( AN_PATH . 'js/an-admin-scripts.js' );
$ttfjs1 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/admin-styling.js' );
$ttfjs2 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/min/serialize-min.jss' );
$ttfjs3 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/min/wp-color-picker-alpha-min.js' );
$ttfjs4 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/ace-min-noconflict/ace.js' );
$ttfjs5 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/ace-min-noconflict/theme-chrome.js' );
$ttfjs6 = $wp_filesystem->get_contents( AN_PATH . 'vendor/titan-framework/js/ace-min-noconflict/mode-css.js' );
?>
id != 'toplevel_page_' . AN_ID . $prefix ) {
return;
}
an_register_admin_scripts();
}
/**
* Enqueue admin scripts
*/
function an_enqueue_admin_syles() {
an_register_global_styles();
$prefix = an_is_bussiness() ? '-network' : '';
$screen = get_current_screen();
if ( $screen && ($screen->id === 'toplevel_page_' . AN_ID . $prefix || $screen->id === 'ad-blocker-notify_page_adblock-notify-admiral' ) ) {
an_register_admin_styles();
}
}
add_action( 'admin_head', 'an_enqueue_admin_syles' );
add_action( 'admin_footer', 'an_enqueue_admin_scripts' );
/**
* ************************************************************
* Add settings link on plugin list page
***************************************************************/
function an_settings_link_init() {
if ( an_is_bussiness() ) {
add_filter( 'network_admin_plugin_action_links_' . AN_BASE, 'an_settings_link' );
} else {
add_filter( 'plugin_action_links_' . AN_BASE, 'an_settings_link' );
}
}
/**
* ************************************************************
* Add settings link on plugin list page
***************************************************************/
function an_settings_link( $links ) {
$url = an_is_bussiness() ? network_admin_url( 'admin.php' ) : admin_url( 'options-general.php' );
$links[] = '' . __( 'Settings', 'an-translate' ) . '';
return $links;
}
add_action( 'plugins_loaded', 'an_settings_link_init' );
/**
* ************************************************************
* Add custom meta link on plugin list page
***************************************************************/
function an_meta_links( $links, $file ) {
if ( $file === 'adblock-notify-by-bweb/adblock-notify.php' ) {
$links[] = '' . __( 'More features', 'an-translate' ) . '';
}
return $links;
}
add_filter( 'plugin_row_meta', 'an_meta_links', 10, 2 );
/**
* ************************************************************
* Admin Panel Favico
***************************************************************/
function an_add_favicon() {
$prefix = an_is_bussiness() ? '-network' : '';
$screen = get_current_screen();
if ( $screen && $screen->id != 'toplevel_page_' . AN_ID . $prefix ) {
return;
}
$favicon_url = AN_URL . 'img/icon-adblock-notify.png';
echo '';
an_register_admin_scripts();
}
add_action( 'admin_head', 'an_add_favicon' );
/**
* ************************************************************
* Create random selectors and files on plugin activation
***************************************************************/
function adblocker_notify_activate() {
an_flag_user();
add_action( 'tf_create_options', 'an_create_options' );
an_save_setting_random_selectors();
}
if ( function_exists( 'adblocker_notify_activate' ) ) {
register_activation_hook( __FILE__, 'adblocker_notify_activate' );
}
/**
*************************************************************
* Remove Plugin settings from DB on uninstallation (= plugin deletion)
*/
// Hooks for install
if ( function_exists( 'register_uninstall_hook' ) ) {
register_uninstall_hook( __FILE__, 'adblocker_notify_uninstall' );
}
/**
* Delete the tempoarary folder
*
* @param string $dirPath the path to temp directory.
*/
function an_delete_temp_folder( $dirPath ) {
try {
if ( file_exists( $dirPath ) ) {
$files = glob( $dirPath . '*', GLOB_MARK );
foreach ( $files as $file ) {
if ( is_dir( $file ) ) {
deleteDir( $file );
} else {
unlink( $file );
}
}
rmdir( $dirPath );
}
} catch ( Exception $e ) {
error_log( $e->getMessage() );
}
}
/**
* Uninstall routine
*/
function adblocker_notify_uninstall() {
// Remove temp files
$anTempDir = unserialize( an_get_option( 'adblocker_notify_selectors' ) );
if ( isset( $anTempDir['temp-path'] ) ) {
an_delete_temp_folder( $anTempDir['temp-path'] );
}
// Remove TitanFramework Generated Style
$uploadDir = wp_upload_dir();
$TfCssFile = trailingslashit( $uploadDir['basedir'] ) . 'titan-framework-adblocker_notify-css.css';
if ( file_exists( $TfCssFile ) ) {
unlink( $TfCssFile );
}
// Remove option from DB
an_delete_option( 'adblocker_notify_options' );
an_delete_option( 'adblocker_notify_counter' );
an_delete_option( 'adblocker_notify_selectors' );
}
/**
* Added Freemius support
*
* @return Freemius
*/
function anbb_fs() {
global $anbb_fs;
$check_phpunit = getenv( 'PHPUNIT_RUNNING' );
if ( ! isset( $anbb_fs ) && $check_phpunit != 'yes' ) {
// Include Freemius SDK.
require_once AN_PATH . 'vendor/freemius/wordpress-sdk/start.php';
$anbb_fs = fs_dynamic_init(
array(
'id' => '503',
'slug' => 'adblock-notify-by-bweb',
'type' => 'plugin',
'public_key' => 'pk_80661c61db7cdcbedd0f6461d6a1b',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => false,
'menu' => array(
'slug' => 'adblock-notify',
),
)
);
}
return $anbb_fs;
}
/**
* Admiral initialization
*/
require_once("vendor/AdmiralAdBlockAnalytics.php");
\anbb\AdmiralAdBlockAnalytics::setClientIDSecret("965b57fa190c8cf9836c", "2y965b57fa190c8cf9836c0001e2fe320889b4ec756400952af8f2ea4d1622b23890f36f91");
function admiraladblock_load_settings_anbb()
{
try {
$didInitialize = \anbb\AdmiralAdBlockAnalytics::initialize("anbb", "2.3.0", "Ad Blocker Notify");
if($didInitialize && (!function_exists('is_admin') || !is_admin())){
add_action('wp_print_scripts', function(){
\anbb\AdmiralAdBlockAnalytics::printEmbedScripts();
});
} else if(!$didInitialize) {
\anbb\AdmiralAdBlockAnalytics::createNewProperty("");
}
} catch (Exception $e) {
error_log("Error loading settings: " . $e->getMessage());
}
}
admiraladblock_load_settings_anbb();
// Init Freemius.
anbb_fs();