= 4.7 ) { $get_locale = get_user_locale(); } // Traditional WordPress plugin locale filter $locale = apply_filters( 'plugin_locale', $get_locale, 'wtpsw' ); $mofile = sprintf( '%1$s-%2$s.mo', 'wtpsw', $locale ); // Setup paths to current locale file $mofile_global = WP_LANG_DIR . '/plugins/' . basename( WTPSW_DIR ) . '/' . $mofile; if ( file_exists( $mofile_global ) ) { // Look in global /wp-content/languages/plugin-name folder load_textdomain( 'wtpsw', $mofile_global ); } else { // Load the default language files load_plugin_textdomain( 'wtpsw', false, $wtpsw_lang_dir ); } } // Action to load plugin text domain add_action('plugins_loaded', 'wtpsw_load_textdomain'); /** * Activation Hook * * Register plugin activation hook. * * @since 1.0.0 */ register_activation_hook( __FILE__, 'wtpsw_install' ); /** * Deactivation Hook * * Register plugin deactivation hook. * * @since 1.0.0 */ register_deactivation_hook( __FILE__, 'wtpsw_uninstall'); /** * Plugin Activation Function * Does the initial setup, sets the default values for the plugin options * * @since 1.0.0 */ function wtpsw_install(){ // get settings for the plugin $wtpsw_options = get_option( 'wtpsw_options' ); if( empty( $wtpsw_options ) ) { // Check plugin version option // set default settings wtpsw_default_settings(); // Update plugin version to option update_option( 'wtpsw_plugin_version', '1.1' ); } // Version 1.1 $plugin_version = get_option('wtpsw_plugin_version'); if( version_compare( $plugin_version, '1.0', '=' ) && !isset($wtpsw_options['post_types']) ) { $wtpsw_options['post_types'][0] = 'post'; update_option( 'wtpsw_options', $wtpsw_options ); update_option( 'wtpsw_plugin_version', '1.1' ); } // Deactivate free version if( is_plugin_active( 'featured-and-trending-post-pro/featured-and-trending-post-pro.php' )) { add_action( 'update_option_active_plugins', 'wtpsw_deactivate_version' ); } } /** * Plugin Deactivation Function * Delete plugin options * * @since 1.0.0 */ function wtpsw_uninstall() { } /** * Deactivate free plugin * * @since 1.2.3 */ function wtpsw_deactivate_version() { if( is_plugin_active( 'featured-and-trending-post-pro/featured-and-trending-post-pro.php' ) ) { deactivate_plugins( 'featured-and-trending-post-pro/featured-and-trending-post-pro.php', true ); } } /** * Function to display admin notice of activated plugin. * * @since 1.2.3 */ function wtpsw_admin_notice() { global $pagenow; // If not plugin screen if( 'plugins.php' != $pagenow ) { return; } // Check Lite Version $dir = ABSPATH . 'wp-content/plugins/featured-and-trending-post-pro/featured-and-trending-post-pro.php'; if( ! file_exists( $dir ) ) { return; } $notice_link = add_query_arg( array('message' => 'wtpsw-plugin-notice'), admin_url('plugins.php') ); $notice_transient = get_transient( 'wtpsw_install_notice' ); // If free plugin exist if( $notice_transient == false && current_user_can( 'install_plugins' ) ) { echo '
'.sprintf( __( 'Thank you for activating %s', 'wtpsw' ), 'Trending/Popular Post Slider and Widget' ).'.
'.sprintf( __( 'It looks like you had PRO version %s of this plugin activated. To avoid conflicts the extra version has been deactivated and we recommend you delete it.', 'wtpsw' ), '(Featured and Trending Post Pro)' ).'