Version: 1.5.13 Author: E-Moxie Author URI: www.emoxie.com */ if ( ! class_exists( 'AppBanners' ) ) : class AppBanners { /** * Initialization function */ public static function init() { add_action( 'wp_enqueue_scripts', 'AppBanners_enqueue_scripts' ); add_action( 'wp_head', 'AppBanners_Meta' ); add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'AppBanners_settings_link' ); /** * If logged into administration area call the Admin functions of the AppBanners */ if ( is_admin() ) { require_once dirname( __FILE__ ) . '/appBanners-admin.php'; App_Banners_Admin::init(); } } } /* * Scripts to be enqueued into Wordpress. Making sure that jquery is added as a dependency * for SmartBanner.js */ function AppBanners_enqueue_scripts() { wp_register_style( 'app-banners-styles', plugins_url( '/lib/smartbanner/jquery.smartbanner.min.css', __FILE__ ) ); wp_enqueue_style( 'app-banners-styles' ); //Script files are placed in Footer wp_register_script( 'app-banners-scripts', plugins_url( '/lib/smartbanner/jquery.smartbanner.min.js', __FILE__ ), array( 'jquery' ), false, true ); wp_enqueue_script( 'app-banners-scripts' ); wp_register_script( 'app-banners-custom-scripts', plugins_url( '/js/config.min.js', __FILE__ ), array( 'jquery' ), false, true ); wp_localize_script( 'app-banners-custom-scripts', 'appBannersConfig', AppBanners_config() ); wp_enqueue_script( 'app-banners-custom-scripts' ); } function AppBanners_config() { $author = htmlspecialchars( get_option( 'APP_BANNERS_author' ), ENT_QUOTES ); $price = get_option( 'APP_BANNERS_price' ); $title = htmlspecialchars( get_option( 'APP_BANNERS_title' ), ENT_QUOTES ); $icon = get_option( 'APP_BANNERS_icon' ); $button = htmlspecialchars( get_option( 'APP_BANNERS_button' ), ENT_QUOTES ); $url = get_option( 'APP_BANNERS_url' ); $daysHidden = get_option( 'APP_BANNERS_daysHidden' ); $daysReminder = get_option( 'APP_BANNERS_daysReminder' ); $speedOut = get_option( 'APP_BANNERS_speedOut' ); $speedIn = get_option( 'APP_BANNERS_speedIn' ); $iconGloss = get_option( 'APP_BANNERS_iconGloss' ); $inAppStore = htmlspecialchars( get_option( 'APP_BANNERS_inAppStore' ), ENT_QUOTES ); $inGooglePlay = htmlspecialchars( get_option( 'APP_BANNERS_inGooglePlay' ), ENT_QUOTES ); $appStoreLanguage = get_option( 'APP_BANNERS_appStoreLanguage' ); $appendToSelector = get_option( 'APP_BANNERS_appendToSelector', 'body' ); $pushSelector = get_option( 'APP_BANNERS_pushSelector', 'html' ); $printViewPort = get_option( 'APP_BANNERS_printViewPort' ); $options = array( 'title' => $title, 'author' => $author, 'price' => $price, 'appStoreLanguage' => $appStoreLanguage, 'inAppStore' => $inAppStore, 'inGooglePlay' => $inGooglePlay, 'inAmazonAppStore' => 'In the Amazon Appstore', 'inWindowsStore' => 'In the Windows Store', 'GooglePlayParams' => null, 'icon' => $icon, 'iconGloss' => $iconGloss, 'url' => $url, 'button' => $button, 'scale' => 'auto', 'speedIn' => $speedIn, 'speedOut' => $speedOut, 'daysHidden' => $daysHidden, 'daysReminder' => $daysReminder, 'force' => null, 'hideOnInstall' => true, 'layer' => false, 'iOSUniversalApp' => true, 'appendToSelector' => $appendToSelector, 'printViewPort' => $printViewPort, 'pushSelector' => $pushSelector ); return $options; } /* * Function to inject the default app banner meta tags into the head of the * site. Utilizing wp_head action. */ function AppBanners_Meta() { $appleID = get_option( 'APP_BANNERS_apple_id' ); $androidID = get_option( 'APP_BANNERS_android_id' ); $author = get_option( 'APP_BANNERS_author' ); $msApplicationID = get_option( 'APP_BANNERS_ms_application_id' ); $msApplicationPackageName = get_option( 'APP_BANNERS_ms_application_package_name' ); $printViewPort = get_option( 'APP_BANNERS_printViewPort' ); if ( $appleID ) { echo '' . PHP_EOL; } if ( $androidID ) { echo '' . PHP_EOL; } if ( $msApplicationID ) { echo '' . PHP_EOL; } if ( $msApplicationPackageName ) { echo '' . PHP_EOL; } if ( $author ) { echo '' . PHP_EOL; } if ( $printViewPort ) { echo '' . PHP_EOL; } } /** * Add in Settings link to plugin details. * * @param $links * * @return mixed */ function AppBanners_settings_link( $links ) { $settings_link = 'Settings'; array_unshift( $links, $settings_link ); return $links; } AppBanners::init(); endif;