function load_espresso_new_addon()
{
    if (class_exists('EE_Addon')) {
        // new_addon version
        require_once plugin_dir_path(__FILE__) . 'EE_New_Addon.class.php';
        EE_New_Addon::register_addon();
    }
}
/**
 *    registers addon with EE core
 */
function load_espresso_new_addon()
{
    if (class_exists('EE_Addon')) {
        // new_addon version
        require_once plugin_dir_path(__FILE__) . 'EE_New_Addon.class.php';
        EE_New_Addon::register_addon();
    } else {
        add_action('admin_notices', 'espresso_new_addon_activation_error');
    }
}
 function test_register_mock_addon_success()
 {
     //ensure model and class extensions weren't setup beforehand
     $this->assertFalse($this->_class_has_been_extended());
     $this->assertFalse($this->_model_has_been_extended());
     $this->_pretend_addon_hook_time();
     if (did_action('activate_plugin')) {
         $this->assertTrue(FALSE);
     }
     $this->assertFalse(property_exists(EE_Registry::instance()->addons, 'EE_New_Addon'));
     //just to make this test truly test the "eea-new-addon", use its own addon params
     //this way we're more likely to keep the EE_New_Addon up-to-date
     require_once EE_TESTS_DIR . 'mocks/addons/eea-new-addon/eea-new-addon.php';
     require_once EE_TESTS_DIR . 'mocks/addons/eea-new-addon/EE_New_Addon.class.php';
     EE_New_Addon::register_addon();
     $this->assertAttributeNotEmpty('EE_New_Addon', EE_Registry::instance()->addons);
     //check DMSs were setup properly too
     $DMSs_available = EE_Data_Migration_Manager::reset()->get_all_data_migration_scripts_available();
     $this->assertArrayHasKey('EE_DMS_New_Addon_1_0_0', $DMSs_available);
     //and check the deactivation hook was setup properly
     $this->assertTrue(has_action('deactivate_' . EE_Registry::instance()->addons->EE_New_Addon->get_main_plugin_file_basename()));
     //check that the model was registered properly
     EE_System::instance()->load_core_configuration();
     $this->assertArrayContains('EEM_New_Addon_Thing', EE_Registry::instance()->non_abstract_db_models);
     $this->assertArrayContains('EEM_New_Addon_Thing', EE_Registry::instance()->models);
     $dms = EE_Registry::instance()->load_dms('New_Addon_1_0_0');
     $this->assertInstanceOf('EE_Data_Migration_Script_Base', $dms);
     $dms->set_migrating(FALSE);
     $dms->schema_changes_before_migration();
     $dms->schema_changes_after_migration();
     $this->assertTableExists('esp_new_addon_thing', 'New_Addon_Thing');
     //check that the model extension was registerd properly
     $this->assertTrue($this->_class_has_been_extended(TRUE));
     $this->assertTrue($this->_model_has_been_extended(TRUE));
     //check that the caps maps were registered properly too
     $this->_pretend_capabilities_registered();
     $current_user = $this->factory->user->create_and_get();
     $other_user = $this->factory->user->create_and_get();
     //give user administrator role for test!
     $current_user->add_role('administrator');
     $a_thing = $this->new_model_obj_with_dependencies('New_Addon_Thing', array('NEW_wp_user' => $current_user->ID));
     $others_thing = $this->new_model_obj_with_dependencies('New_Addon_Thing', array('NEW_wp_user' => $other_user->ID));
     $this->assertTrue(EE_Capabilities::instance()->user_can($current_user, 'edit_thing', 'testing_edit', $a_thing->ID()));
     $this->assertTrue(EE_Capabilities::instance()->user_can($current_user, 'edit_thing', 'testing_edit', $others_thing->ID()));
 }
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     // get the current post
     global $post;
     if (isset($post->post_content)) {
         // check the post content for the short code
         if (strpos($post->post_content, '[ESPRESSO_NEW_ADDON') === FALSE) {
             EED_New_Addon::$shortcode_active = TRUE;
             // Before widget (defined by themes).
             echo $args['before_widget'];
             // Title of widget (before and after defined by themes).
             $title = apply_filters('widget_title', $instance['title']);
             if (!empty($title)) {
                 echo $args['before_title'] . $title . $args['after_title'];
             }
             // load scripts
             EE_New_Addon::instance()->enqueue_scripts();
             // settings
             $attributes = array();
             echo EE_New_Addon::instance()->display_new_addon($attributes);
             // After widget (defined by themes).
             echo $args['after_widget'];
         }
     }
 }
 public function test_get_main_plugin_file_dirname()
 {
     $this->assertEquals(dirname($this->_main_file_path), $this->_addon->get_main_plugin_file_dirname());
 }