Example #1
0
 public static function instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 public function __construct()
 {
     // manages plugin activation and deactivation
     register_activation_hook(__FILE__, array(&$this, 'activate'));
     register_deactivation_hook(__FILE__, array(&$this, 'deactivate'));
     // stopping here if we are going to deactivate the plugin (avoids breaking rewrite rules)
     if (isset($_GET['action'], $_GET['plugin']) && 'deactivate' == $_GET['action'] && plugin_basename(__FILE__) == $_GET['plugin']) {
         return;
     }
     // loads the admin side of Polylang for the dashboard
     if (defined('DOING_AJAX') && DOING_AJAX && isset($_REQUEST['action']) && 'lingotek_language' == $_REQUEST['action']) {
         define('PLL_AJAX_ON_FRONT', false);
         add_filter('pll_model', create_function('$c', 'return "PLL_Admin_Model";'));
     }
     spl_autoload_register(array(&$this, 'autoload'));
     // autoload classes
     // init
     add_filter('pll_model', array(&$this, 'pll_model'));
     add_action('init', array(&$this, 'init'));
     add_action('admin_init', array(&$this, 'admin_init'));
     // add Lingotek locale to languages
     add_filter('pll_languages_list', array(&$this, 'pre_set_languages_list'));
     // flag title
     add_filter('pll_flag_title', array(&$this, 'pll_flag_title'), 10, 3);
     // adds a pointer upon plugin activation to draw attention to Lingotek
     if (!get_option('lingotek_token')) {
         add_action('init', array(&$this, 'lingotek_activation_pointer'));
     }
     // adds extra plugin compatibility - borrowed from Polylang
     if (!defined('LINGOTEK_PLUGINS_COMPAT') || LINGOTEK_PLUGINS_COMPAT) {
         Lingotek_Plugins_Compat::instance();
     }
 }