Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function onInit()
 {
     parent::onInit();
     $dispatcher = $this->getEnvironment()->getDispatcher();
     $dispatcher->on('after_overview_loaded', array($this, 'registerMenu'));
     $this->registerShortcode();
     $resources = new GridGallery_Galleries_Model_Resources();
     $config = $this->getEnvironment()->getConfig();
     $prefix = $config->get('hooks_prefix');
     add_action($prefix . 'after_ui_loaded', array($this, 'registerAssets'));
     add_action($prefix . 'gallery_delete', array($resources, 'deleteByGalleryId'));
     /* Delete attachment */
     add_action('grid_gallery_delete_image', array($resources, 'deleteByResourceId'));
     add_action('gg_delete_photo_id', array($resources, 'deletePhotoById'));
     add_image_size('gg_gallery_thumbnail', 450, 250, true);
     // !!!!!! use {} for preg_* functions as start and end of the expresion.
     $pregReplaceFilter = new Twig_SimpleFilter('preg_replace', array($this, 'pregReplace'));
     $httpFilter = new Twig_SimpleFilter('force_http', array($this, 'forceHttpUrl'));
     $function = new Twig_SimpleFunction('translate', array($this->getController(), 'translate'));
     $twig = $this->getEnvironment()->getTwig();
     $twig->addFilter($pregReplaceFilter);
     $twig->addFilter($httpFilter);
     $twig->addFunction($function);
     // To avoid conflict with other plugins which have older twig version.
     $twig->addFilter(new Twig_SimpleFilter('round', 'round'));
     // Widget
     add_action('widgets_init', array($this, 'registerWidget'));
     // Cache dir
     $this->cacheDirectory = $this->getConfig()->get('plugin_cache_galleries');
 }
Esempio n. 2
0
 /**
  * {@inhertidoc}
  */
 public function onInstall()
 {
     parent::onInstall();
     $model = self::getModel();
     $queries = self::getQueries();
     if (!$model->install($queries)) {
         wp_die('Failed to update database.');
     }
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function onInit()
 {
     parent::onInit();
     add_action('sg_after_ui_loaded', array($this, 'load'));
 }
Esempio n. 4
0
 /**
  * Module initialization.
  */
 public function onInit()
 {
     parent::onInit();
     add_action($this->getConfig()->get('hooks_prefix') . 'after_ui_loaded', array($this, 'loadAssets'));
     add_action('wp_ajax_sgg-tutorial-close', array($this, 'endTutorial'));
 }