getOption( 'an_option_selectors' ) == false ) || ( !ini_get('allow_url_fopen') && !function_exists('curl_init') ) ) {
wp_enqueue_script( 'an_scripts', AN_URL . 'js/an-scripts.min.js', array( 'jquery' ), NULL, true);
wp_register_style( 'an_style', AN_URL . 'css/an-style.min.css', array(), NULL, NULL);
} else if($anScripts['temp-path'] != false && ini_get('allow_url_fopen') ) {
wp_enqueue_script( 'an_scripts', $anScripts['temp-url'].$anScripts['files']['js'], array( 'jquery' ), NULL, true);
wp_register_style( 'an_style', $anScripts['temp-url'].$anScripts['files']['css'], array(), NULL, NULL);
//CSS file does not exist anymore
wp_dequeue_style('tf-compiled-options-adblocker_notify');
}
//AJAX
wp_localize_script( 'an_scripts', 'ajax_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
if( $an_option->getOption( 'an_option_choice' ) == 2 || $an_option->getOption( 'an_alternative_activation' ) == true ) {
//Enqeue AN style
wp_enqueue_style('an_style');
}
}
}
add_action( 'wp_enqueue_scripts', 'an_enqueue_an_sripts', 100);
/***************************************************************function_exists('curl_init')
* Front-End Scripts & Styles printing
* Only if an-temp is not writable && ini_get('allow_url_fopen')
***************************************************************/
function an_print_an_sripts(){
if( ini_get('allow_url_fopen') || function_exists('curl_init') ){
$an_option = TitanFramework::getInstance( 'adblocker_notify' );
if($an_option->getOption( 'an_option_selectors' ) != false){
$anScripts = unserialize( get_option( 'adblocker_notify_selectors' ) );
if($anScripts['temp-path'] == false || !ini_get('allow_url_fopen'))
an_print_change_files_css_selectors();
}
}
}
add_action('wp_footer', 'an_print_an_sripts');
/***************************************************************
* Back-End Scripts & Styles enqueueing
***************************************************************/
function an_register_admin_scripts() {
//JS
wp_enqueue_script( 'an_admin_scripts', AN_URL . 'js/an-admin-scripts.js', array( 'jquery' ), NULL, true);
//CSS
wp_enqueue_style( 'an_admin_style', AN_URL . 'css/an-admin-style.css', array(), NULL, NULL);
}
function an_enqueue_admin_scripts() {
$screen = get_current_screen();
if ( $screen->id != 'toplevel_page_'. AN_ID )
return;
an_register_admin_scripts();
}
add_action('admin_enqueue_scripts', 'an_enqueue_admin_scripts');
add_filter( 'user_contactmethods', 'user_contactmethods_example' );
/***************************************************************
* Add settings link on plugin list page
***************************************************************/
function an_settings_link($links) {
$settings_link = ''. __( 'Settings', 'an-translate' ) .'';
array_unshift($links, $settings_link);
return $links;
}
add_filter('plugin_action_links_'.AN_BASE, 'an_settings_link' );
/***************************************************************
* Add custom meta link on plugin list page
***************************************************************/
if ( ! function_exists( 'an_meta_links' ) ) {
function an_meta_links( $links, $file ) {
if ( strpos( $file, 'adblock-notify.php' ) !== false ) {
$links[0] = '
'. $links[0];
$links = array_merge( $links, array( ''. __( 'More b*web Plugins', 'an-translate' ) .'' ) );
$links = array_merge( $links, array( ''. __( 'Donate', 'an-translate' ) .'' ) );
}
return $links;
}
add_filter( 'plugin_row_meta', 'an_meta_links', 10, 2 );
}
/***************************************************************
* Admin Panel Favico
***************************************************************/
function an_add_favicon() {
$screen = get_current_screen();
if ( $screen->id != 'toplevel_page_'. AN_ID )
return;
$favicon_url = AN_URL . 'img/icon-bweb.svg';
echo '';
}
add_action('admin_head', 'an_add_favicon');
/***************************************************************
* Create random selectors and files on plugin activation
***************************************************************/
function adblocker_notify_activate() {
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');
}
//Remove directory
function an_delete_temp_folder($dirPath) {
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
self::deleteDir($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}
//Uninstall function
function adblocker_notify_uninstall() {
// Remove temp files
$anTempDir = unserialize( get_option( 'adblocker_notify_selectors' ) );
an_delete_temp_folder($anTempDir['temp-path']);
$uploadDir = wp_upload_dir();
unlink(trailingslashit( $uploadDir['basedir'] ) . 'titan-framework-adblocker_notify-css.css');
// Remove option from DB
delete_option( 'adblocker_notify_options' );
delete_option( 'adblocker_notify_counter' );
delete_option( 'adblocker_notify_selectors' );
}