Example #1
0
 /**
  * Check if there is a multilingual plugin that's active.
  * If support is enabled, but there are no plugins, a notice will be generated
  */
 static function check()
 {
     # If there is an adapter set, it's all okay
     if (isset(self::$adapter)) {
         return true;
     }
     # Check if the multilingual UF functionality is available
     $enabled = get_option('uf_multilingual');
     # The option might not be set but the theme might allow/deny it
     if (defined('UF_ENABLE_MULTILINGUAL')) {
         $enabled = UF_ENABLE_MULTILINGUAL;
     }
     # Stop if not enabled
     if (!$enabled) {
         return false;
     }
     # Now that it's allowed, check adapters
     $available_adapters = array('UF_Qtranslate');
     $available_adapters = apply_filters('uf_ml_adapters', $available_adapters);
     foreach ($available_adapters as $adapter) {
         if (call_user_func(array($adapter, 'check'))) {
             self::$adapter = new $adapter();
             break;
         }
     }
     # After checking adapters
     if (isset(self::$adapter)) {
         return true;
     } else {
         $message = __('There is no multilingual plugin that UF supports being installed or activated! Such a plugin is required for multilingual functionality the active theme or a plugin. Please don\'t edit anything before installing a plugin!', 'uf');
         $message = apply_filters('uf_no_ml_plugin', $message);
         UF_Notices::add($message, true);
         return false;
     }
 }
Example #2
0
 /**
  * Adds an exception to the pool.
  * 
  * @param string $message The message of the error
  * @param string $type The type of the error/notification
  */
 static function add($message, $type = null)
 {
     # If there's no type set, we can't know if it should be saved
     if (!$type) {
         uf_die($message);
     }
     # If the type is not set to be buffered, die
     if (!isset(self::$catchable[$type])) {
         uf_die($message);
     } else {
         self::$buffer[$type][] = $message;
         UF_Notices::add($message, true);
     }
 }
 /**
  * Looks for added post types and registers them.
  * 
  * @since 2.0
  */
 public function register_post_types()
 {
     $post_types = get_posts(array('post_type' => $this->slug, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
     $need_migration = 0;
     foreach ($post_types as $post_type) {
         # Check if the post type has fields, which have not been migrated to v.2
         if (get_post_meta($post_type->ID, 'fields', true) && !get_post_meta($post_type->ID, 'migrated_v2', true)) {
             $need_migration++;
         }
         $this->register_post_type($post_type);
     }
     # Add a notice for migration if needed.
     if (!$need_migration) {
         return;
     }
     update_option('upt_2_migrate', 'yes');
     $text = __('Thank you for updating to Ultimate Post Types 2!', 'ultimate-post-types');
     $text .= ' ' . sprintf(_n('There is %s post type that needs to be migrated from Ultimate Post Types version 1 to version 2.', 'There are %s post types that need to be migrated from Ultimate Post Types version 1 to version 2.', $need_migration, 'ultimate-post-types'), $need_migration > 1 ? $need_migration : 'one');
     $text .= "\n\n" . __('Those post types will be registered, but their fields will not be available until the database is updated.', 'ultimate-fields-ui');
     $text .= "\n\n" . sprintf('<a href="%s" class="button-secondary uf-button"><span class="dashicons dashicons-update"></span> %s</a>', admin_url('edit.php?post_type=ultimate-fields&amp;page=uf-settings&amp;tab=migrate-post-types'), __('Go to the migration page', 'ultimate-fields-ui'));
     if (!(isset($_GET['page']) && 'uf-settings' == $_GET['page'])) {
         UF_Notices::add($text);
     }
 }
Example #4
0
 /**
  * Connects fields to the datastore, processes tabs and adds notices.
  */
 private function setup()
 {
     if ($this->set) {
         return;
     }
     if (!$this->id) {
         uf_die('<strong>UF_Options</strong>: You need to set a title/ID for each page!');
     }
     if (!$this->datastore) {
         $this->datastore = apply_filters('uf_options_datastore', new UF_Datastore_Options());
     }
     foreach ($this->fields as $field) {
         if (is_a($field, 'UF_Field') && $this->datastore->check_field_id($field->get_id())) {
             $field->set_datastore($this->datastore, true);
         }
     }
     $this->end_tab();
     if ($this->tabs_open && !$this->tab_open) {
         $this->fields[] = array('item' => 'tabs_end');
     }
     $this->set = true;
     if (isset($_GET['success'])) {
         UF_Notices::add(__('Your changes were succesufully saved!', 'uf'));
     }
 }