コード例 #1
0
 /**
  * Setup test case
  *
  * @since 1.0.0
  */
 public function setUp()
 {
     parent::setUp();
     // Add custom factories
     $this->factory = new AC_Unit_Test_Factory();
     $this->setOutputCallback(array($this, 'filter_output'));
     // Register post types before each test
     AC_Post_Types::register_post_types();
     AC_Post_Types::register_taxonomies();
 }
コード例 #2
0
 /**
  * Install AC.
  */
 public static function install()
 {
     global $wpdb;
     if (!defined('AC_INSTALLING')) {
         define('AC_INSTALLING', true);
     }
     // Ensure needed classes are loaded
     include_once dirname(__FILE__) . '/admin/class-ac-admin-notices.php';
     self::create_options();
     self::create_roles();
     self::create_files();
     // Register post types
     AC_Post_Types::register_post_types();
     AC_Post_Types::register_taxonomies();
     // Queue upgrades wizard
     $current_ac_version = get_option('axiscomposer_version', null);
     $current_db_version = get_option('axiscomposer_db_version', null);
     AC_Admin_Notices::remove_all_notices();
     // No versions? This is a new install :)
     if (is_null($current_ac_version) && is_null($current_db_version) && apply_filters('axiscomposer_enable_setup_wizard', true)) {
         set_transient('_ac_activation_redirect', 1, 30);
     }
     if (!is_null($current_db_version) && version_compare($current_db_version, max(array_keys(self::$db_updates)), '<')) {
         AC_Admin_Notices::add_notice('update');
     } else {
         self::update_db_version();
     }
     self::update_ac_version();
     // Flush rules after install
     flush_rewrite_rules();
     /*
      * Deletes all expired transients. The multi-table delete syntax is used
      * to delete the transient record from table a, and the corresponding
      * transient_timeout record from table b.
      *
      * Based on code inside core's upgrade_network() function.
      */
     $sql = "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b\n\t\t\tWHERE a.option_name LIKE %s\n\t\t\tAND a.option_name NOT LIKE %s\n\t\t\tAND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )\n\t\t\tAND b.option_value < %d";
     $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_transient_') . '%', $wpdb->esc_like('_transient_timeout_') . '%', time()));
     // Trigger action
     do_action('axiscomposer_installed');
 }