/**
  * Test WOO is active
  *
  * @since 1.1.0
  *
  * @group price
  * @group woo
  * @group functions
  *
  * @covers ingot_is_woo_active()
  * @covers ingot_check_ecommerce_active()
  */
 public function testWOOActive()
 {
     if (class_exists('WooCommerce')) {
         $this->assertTrue(ingot_is_woo_active());
         $this->assertTrue(ingot_check_ecommerce_active('woo'));
     } else {
         $this->assertFalse(ingot_is_woo_active());
         $this->assertFalse(ingot_check_ecommerce_active('woo'));
     }
 }
示例#2
0
文件: util.php 项目: Ramoonus/ingot
 /**
  * Make otpions array for eCommerce plugin select options
  *
  * @since 0.0.9
  *
  * @access protected
  *
  * @return string
  */
 protected static function price_test_plugin_options()
 {
     $options = array(0 => ' -- ' . __('Choose', 'ingot') . ' -- ', 'edd' => __('Easy Digital Downloads', 'ignot'), 'woo' => __('WooCommerce', 'ignot'));
     foreach ($options as $value => $label) {
         if (0 === $value) {
             continue;
         }
         $active = ingot_check_ecommerce_active($value);
         if (true != $active) {
             unset($options[$value]);
         }
     }
     return $options;
 }
示例#3
0
 /**
  * Get plugins we can use for price tests
  *
  * @since 0.2.0
  *
  * @param \WP_REST_Request $request Full data about the request.
  * @return \WP_Error|\WP_REST_Response
  */
 public function get_plugins($request)
 {
     $allowed = ingot_accepted_plugins_for_price_tests(true);
     if (!empty($allowed)) {
         foreach ($allowed as $value => $label) {
             if (ingot_check_ecommerce_active($value)) {
                 $plugins[] = array('value' => $value, 'label' => $label);
             }
         }
         return rest_ensure_response($plugins);
     } else {
         return rest_ensure_response('', 404);
     }
 }
示例#4
0
 /**
  * Get plugins we can use for price tests
  *
  * @since 0.2.0
  *
  * @param \WP_REST_Request $request Full data about the request.
  * @return \WP_Error|\WP_REST_Response
  */
 public function get_plugins($request)
 {
     if ('list' == $request->get_param('context')) {
         $plugins = ingot_ecommerce_plugins_list();
         return ingot_rest_response($plugins);
     }
     $plugins = [];
     $allowed = ingot_accepted_plugins_for_price_tests(true);
     if (!empty($allowed)) {
         foreach ($allowed as $value => $label) {
             if (ingot_check_ecommerce_active($value)) {
                 $plugins[] = array('value' => $value, 'label' => $label);
             }
         }
         return ingot_rest_response($plugins);
     } else {
         return ingot_rest_response('', 404);
     }
 }
示例#5
0
/**
 * Get eCommerce plugins list with banner/active status
 *
 * @since 1.1.0
 *
 * @return array
 */
function ingot_ecommerce_plugins_list()
{
    $plugins = ingot_accepted_plugins_for_price_tests(true);
    if (!empty($plugins) && is_array($plugins)) {
        foreach ($plugins as $value => $label) {
            $_plugins[$value] = ['value' => $value, 'label' => $label];
        }
        $plugins = $_plugins;
        if (isset($plugins['edd'])) {
            $plugins['edd']['logo'] = esc_url_raw(INGOT_URL . 'assets/img/edd_logo.png');
        }
        if (isset($plugins['woo'])) {
            $plugins['woo']['logo'] = esc_url_raw(INGOT_URL . 'assets/img/woocommerce_logo.png');
        }
        foreach ($plugins as $plugin => $plugin_data) {
            if (ingot_check_ecommerce_active($plugin)) {
                $plugins[$plugin]['active'] = true;
            } else {
                $plugins[$plugin]['active'] = false;
            }
        }
    }
    return $plugins;
}