コード例 #1
0
ファイル: init.php プロジェクト: rene-hermenau/ingot
 /**
  * Setup tracking hooks
  *
  * @since 1.1.0
  *
  * @return array Groups being tracked
  */
 public static function set_tracking()
 {
     $groups = self::get_destination_tests();
     if (!empty($groups)) {
         self::clear_invalid($groups);
     }
     if (!empty($groups)) {
         foreach ($groups as $group_id) {
             $group = group::read($group_id);
             if (group::valid($group)) {
                 if (destination::is_tagline($group)) {
                     if (!self::$tagline) {
                         $variant_id = self::get_test($group_id);
                         $variant = variant::read($variant_id);
                         if (variant::valid($variant)) {
                             self::$tagline = $variant['content'];
                         }
                     }
                     if (is_string(self::$tagline)) {
                         add_filter('bloginfo', function ($output, $show) {
                             if ('description' == $show) {
                                 return self::$tagline;
                             }
                             return $output;
                         }, 24, 2);
                     }
                 }
             }
         }
         if (!empty($groups)) {
             new \ingot\testing\tests\click\destination\hooks($groups);
         }
         return $groups;
     }
 }
コード例 #2
0
ファイル: hooks.php プロジェクト: rene-hermenau/ingot
 /**
  * Setup tracking for hook tests
  *
  * @access protected
  *
  * @since 1.1.0
  */
 protected function set_hook_tests()
 {
     foreach ($this->groups as $group) {
         if (destination::is_hook($group) && isset($group['meta']['hook'])) {
             $hook = $group['meta']['hook'];
             $variant_id = init::get_test($group['ID']);
             if (is_numeric($variant_id)) {
                 $this->hook_tests[sanitize_key($hook)] = $variant_id;
                 add_action($hook, [$this, 'hook_test_cb'], 55);
             }
         }
     }
 }
コード例 #3
0
 /**
  * Check getting page ID
  *
  * @since 1.1.0
  *
  * @group group
  * @group destination
  *
  * \ingot\testing\utility\destination::get_page_id()
  */
 public function testGetPageID()
 {
     $data = ingot_test_desitnation::create('page', true);
     $group = \ingot\testing\crud\group::read($data['group_ID']);
     $this->assertSame($data['page'], \ingot\testing\utility\destination::get_page_id($group));
 }
コード例 #4
0
ファイル: group.php プロジェクト: rene-hermenau/ingot
 /**
  * Validate and sanitize meta array
  *
  * @since 0.4.0
  *
  * @param array $data
  *
  * @return array|\WP_Error Prepared array or WP_Error if invalid
  */
 protected static function prepare_meta($data)
 {
     if (!isset($data['meta']) || empty($data['meta'] || !is_array($data['meta']))) {
         $data['meta'] = [];
         return $data;
     }
     if ('click' == $data['type']) {
         if ('destination' == $data['sub_type']) {
             return destination::prepare_meta($data);
         }
         foreach (['color', 'background_color', 'color_test_text', 'link'] as $field) {
             if (isset($data['meta'][$field]) && !empty($data['meta'][$field]) && is_string($data['meta'][$field])) {
                 if ('link' == $field) {
                     if (filter_var($data['meta'][$field], FILTER_VALIDATE_URL)) {
                         $data['meta'][$field] = esc_url_raw($data['meta'][$field]);
                     } else {
                         return new \WP_Error('ingot-invalid-config-click-link', __('Click groups must have a valid link.', 'ingot'));
                     }
                 } else {
                     $data['meta'][$field] = strip_tags($data['meta'][$field]);
                 }
             } else {
                 $data['meta'][$field] = '';
             }
         }
     }
     if ('price' == $data['type']) {
         if (!isset($data['meta']['product_ID'])) {
             return new \WP_Error('ingot-invalid-config-no-product-id', __('Ingot price tests must set product ID in meta.product_ID', 'ingot'));
         }
         if (isset($data['meta']['variable_prices']) && is_array($data['meta']['variable_prices'])) {
             $data['meta']['variable_prices'] = helpers::make_array_values_numeric($data['meta']['variable_prices']);
         } else {
             $data['meta']['variable_prices'] = [];
         }
     }
     return $data;
 }