/** * Get complete click type HTML * * @since 0.0.6 * * @param int $id Group ID * * @return string */ function ingot_click_test($id) { $html = ''; if (!is_array($id)) { $group = \ingot\testing\crud\group::read($id); } else { $group = $id; } if (!is_array($group) || 'click' !== $group['type']) { return $html; } $type = $group['sub_type']; if (in_array($type, \ingot\testing\types::allowed_click_types())) { switch ($type) { case in_array($type, \ingot\testing\types::internal_click_types()): $html = ingot_click_html_link($type, $group); break; case is_callable($type): $html = call_user_func($type, $group); break; default: $html = ''; } } return $html; }
/** * Data needed in app * * @since 0.2.0 * * @access protected * * @return array */ protected function vars() { return array('api' => esc_url_raw(util::get_url()), 'nonce' => wp_create_nonce('wp_rest'), 'partials' => esc_url_raw(INGOT_URL . 'assets/admin/partials/'), 'spinner_url' => trailingslashit(INGOT_URL) . 'assets/img/loading.gif', 'edd_active' => esc_attr(ingot_is_edd_active()), 'woo_active' => esc_attr(ingot_is_woo_active()), 'price_tests_enabled' => esc_attr(ingot_enable_price_testing()), 'click_type_options' => types::allowed_click_types(true), 'price_type_options' => types::allowed_price_types(), 'destinations' => \ingot\testing\tests\click\destination\types::destination_types(true, true), 'dev_mode' => INGOT_DEV_MODE); }
/** * Validate item click type * * @since 0.0.7 * * @access protected * * @param array $data Item config * * @return bool True if valid, false if not */ protected static function validate_click_type($data) { if (!in_array($data['sub_type'], types::allowed_click_types())) { return false; } return true; }
/** * Validate sub_type click type * * @since 0.4.0 * * @param $value * * @return bool */ public function allowed_sub_tupe($value, $request) { $type = $request->get_param('type'); if ('click' == $type) { return in_array($value, types::allowed_click_types()); } else { return in_array($value, types::allowed_price_types()); } }