コード例 #1
0
 public static function getInstance()
 {
     if (!is_object(self::$_instance)) {
         self::$_instance = new Credits_Coins_Model();
     }
     return self::$_instance;
 }
コード例 #2
0
 function test_method_user_can_access_post()
 {
     $data_model = Credits_Coins_Model::getinstance();
     $user_id = 1;
     $post_id = $this->factory->post->create();
     $post_value = 10;
     $purchase_note = 'phpunit testing purchase';
     $data_model->set_post_credits($post_id, $post_value);
     $this->assertEquals(false, $data_model->user_can_access_post($user_id, $post_id));
     $this->assertEquals(1, $data_model->register_user_purchase($user_id, $post_id, $post_value, $purchase_note));
     $number_informaton_purchase = 7;
     $this->assertCount($number_informaton_purchase, $data_model->user_can_access_post($user_id, $post_id));
 }
コード例 #3
0
 /**
  * Defines the hooks and callback functions that are used for rendering information on the front
  * end of the site.
  *
  * @access private
  */
 private function define_public_hooks()
 {
     $public = new Credits_Coins_Manager_Public($this->version, $this->options, Credits_Coins_Model::getInstance());
     $this->loader->add_action('init', $public, 'register_scripts');
     $this->loader->add_action('wp_enqueue_scripts', $public, 'enqueue_scripts');
     $this->loader->add_filter('the_content', $public, 'the_content_filter', 99);
     Credits_Coins_Theme_Functions::define_theme_functions();
 }
コード例 #4
0
 function cc_get_user_credits($user_id = null)
 {
     $cc_data_model = Credits_Coins_Model::getInstance();
     return $cc_data_model->get_user_credits($user_id);
 }