/** * @param $args * @param $instance * * @return string */ public function getContent($args, $instance) { $output = ''; $title = apply_filters('widget_title', $instance['title']); // Get the data from the argument. require_once GIGYA__PLUGIN_DIR . 'features/gamification/GigyaGamificationSet.php'; $type = esc_attr($instance['type']); $gm = new GigyaGamificationSet(); $data = $gm->getParams($type); $data['type'] = $type; $data['width'] = (int) esc_attr($instance['width']); // Set the output. $output .= $args['before_widget']; if (!empty($title)) { $output .= $args['before_title'] . $title . $args['after_title']; } $output .= '<div class="gigya-gamification-widget"></div>'; $output .= '<script class="data-gamification" type="application/json">' . json_encode($data) . '</script>'; $output .= $args['after_widget']; return $output; }
public function gigyaGmScode($attrs, $content, $tag) { $type = ""; switch ($tag) { case "gigya-gm-achievements": $type = "achievements"; break; case "gigya-gm-challenge-status": $type = "challenge"; break; case "gigya-gm-leaderboard": $type = "leaderboard"; break; case "gigya-gm-user-status": $type = "game"; break; } require_once GIGYA__PLUGIN_DIR . 'features/gamification/GigyaGamificationSet.php'; $gm = new GigyaGamificationSet(); if (empty($attrs)) { $attrs = $gm->getParams($type); if (isset($attrs['advanced'])) { $advanced = gigyaCms::jsonToArray($attrs['advanced']); if (is_array($advanced)) { $attrs = array_merge($attrs, $advanced); } else { if (is_string($advanced)) { _gigya_error_log("Error in " . __FUNCTION__ . " shortcode advanced parameters message: " . $advanced); } } } } $attrs['type'] = $type; $attrs = $this->attrs_to_gigya($attrs); $output = '<div class="gigya-gamification-widget"></div>'; $output .= '<script class="data-gamification" type="application/json">' . json_encode($attrs) . '</script>'; return $output; }