本文整理汇总了PHP中ThemexCore::getUserRelations方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemexCore::getUserRelations方法的具体用法?PHP ThemexCore::getUserRelations怎么用?PHP ThemexCore::getUserRelations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThemexCore
的用法示例。
在下文中一共展示了ThemexCore::getUserRelations方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAnswerStatistics
/**
* Gets answer statistics
*
* @access public
* @param int $ID
* @param int $user
* @return array
*/
public static function getAnswerStatistics($ID, $user)
{
$answers = array();
$quiz = ThemexCore::getPostRelations(0, $ID, 'quiz_lesson', true);
if (!empty($quiz)) {
$relations = explode(' ; ', ThemexCore::getUserRelations($user, $quiz, 'answers', true) . ' ');
foreach ($relations as $relation) {
$answer = array();
$relation = explode(' , ', $relation);
if (count($relation) == 3) {
$answer['question'] = themex_value($relation, 0);
$answer['answer'] = themex_value($relation, 1);
$answer['result'] = themex_value($relation, 2);
$answers[] = $answer;
}
}
}
return $answers;
}
示例2: getQuestions
/**
* Gets quiz questions
*
* @access public
* @param int $ID
* @return array
*/
public static function getQuestions($ID)
{
$selection = absint(ThemexCore::getPostMeta($ID, 'quiz_selection'));
$questions = themex_filter(ThemexCore::getPostMeta($ID, 'quiz_questions'));
if (!empty($selection) && $selection < count($questions)) {
$keys = ThemexCore::getUserRelations(get_current_user_id(), $ID, 'questions', true);
if (!empty($keys)) {
$keys = explode(',', $keys);
$questions = array_intersect_key($questions, array_flip($keys));
}
if ($selection != count($questions)) {
$questions = themex_shuffle($questions);
$questions = array_slice($questions, 0, $selection);
$keys = implode(',', array_keys($questions));
ThemexCore::addUserRelation(get_current_user_id(), $ID, 'questions', $keys);
}
}
return $questions;
}
示例3: renderOption
//.........这里部分代码省略.........
$out .= '<option value="0">' . __('None', 'academy') . '</option>';
foreach ($items as $item) {
$selected = '';
if ($item->ID == $option['value']) {
$selected = 'selected="selected"';
}
$out .= '<option value="' . $item->ID . '" ' . $selected . '>' . $item->post_title . '</option>';
}
$out .= '</select>';
break;
//sidebars dropdown
//sidebars dropdown
case 'select_sidebar':
$sidebars = array();
foreach ($wp_registered_sidebars as $sidebar) {
$sidebars[$sidebar['name']] = $sidebar['name'];
}
$out .= self::renderOption(array('id' => $option['id'], 'type' => 'select', 'wrap' => false, 'options' => $sidebars));
break;
//categories dropdown
//categories dropdown
case 'select_category':
$args = array('hide_empty' => 0, 'echo' => 0, 'selected' => $option['value'], 'show_option_all' => __('None', 'academy'), 'hierarchical' => 0, 'name' => $option['id'], 'id' => $option['id'], 'depth' => 0, 'tab_index' => 0, 'taxonomy' => $option['taxonomy'], 'hide_if_empty' => false);
if (isset($option['attributes'])) {
$args['class'] = $option['attributes']['class'];
}
$out .= wp_dropdown_categories($args);
break;
//range slider
//range slider
case 'slider':
$out .= '<div class="themex-slider-controls"></div><div class="themex-slider-value"></div>';
$out .= '<input type="hidden" class="slider-max" value="' . $option['max_value'] . '" />';
$out .= '<input type="hidden" class="slider-min" value="' . $option['min_value'] . '" />';
$out .= '<input type="hidden" class="slider-unit" value="' . $option['unit'] . '" />';
$out .= '<input type="hidden" class="slider-value" name="' . $option['id'] . '" id="' . $option['id'] . '" value="' . $option['value'] . '" />';
break;
//quiz questions
//quiz questions
case 'questions':
if (empty($option['value']) || !is_array($option['value'])) {
$option['value'] = array('q' . uniqid() => array('title' => '', 'type' => ''));
}
$out .= '<div class="themex-clone-pane"><input type="hidden" id="' . $option['id'] . '" name="' . $option['id'] . '" value="" />';
foreach ($option['value'] as $key => $field) {
$out .= '<div class="themex-clone-item" id="' . $option['id'] . '_' . $key . '">';
$out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '" title="' . __('Remove', 'academy') . '"></a>';
$out .= '<a href="#" class="themex-button themex-clone-button themex-trigger" data-value="' . $key . '" title="' . __('Add', 'academy') . '"></a>';
$out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][title]', 'type' => 'text', 'value' => htmlspecialchars(themex_value($field, 'title')), 'wrap' => false, 'attributes' => array('placeholder' => __('Question', 'academy'))));
$out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][type]', 'type' => 'select', 'value' => themex_value($field, 'type'), 'wrap' => false, 'options' => array('single' => __('Single Choice', 'academy'), 'multiple' => __('Multiple Choice', 'academy'), 'string' => __('Short Answer', 'academy'))));
if (!isset($field['answers']) || empty($field['answers'])) {
$field['answers'] = array('a' . uniqid() => array('title' => ''));
}
foreach ($field['answers'] as $index => $answer) {
$out .= '<div class="themex-clone-item clearfix" id="' . $option['id'] . '_' . $key . '_' . $index . '">';
$out .= '<a href="#" class="themex-button themex-remove-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '_' . $index . '" title="' . __('Remove', 'academy') . '"></a>';
$out .= '<a href="#" class="themex-button themex-clone-button themex-trigger" data-element="' . $option['id'] . '_' . $key . '_' . $index . '" data-value="' . $index . '" title="' . __('Add', 'academy') . '"></a>';
$out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][answers][' . $index . '][title]', 'type' => 'text', 'value' => htmlspecialchars(themex_value($answer, 'title')), 'wrap' => false, 'attributes' => array('placeholder' => __('Answer', 'academy'))));
$out .= ThemexInterface::renderOption(array('id' => $option['id'] . '[' . $key . '][answers][' . $index . '][result]', 'type' => 'checkbox', 'value' => themex_value($answer, 'result'), 'wrap' => false));
$out .= '</div>';
}
$out .= '</div>';
}
$out .= '</div>';
break;
//users manager
//users manager
case 'users':
$users = ThemexCore::getUserRelations(0, $post->ID, $post->post_type);
$out .= '<div class="themex-row clearfix">';
$out .= wp_dropdown_users(array('echo' => false, 'exclude' => $users, 'name' => 'add_user_id', 'id' => 'add_user_id'));
$out .= '<input type="submit" name="add_user" class="button" value="' . __('Add', 'academy') . '" /></div>';
if (!empty($users)) {
$out .= '<div class="themex-row clearfix">';
$out .= wp_dropdown_users(array('echo' => false, 'include' => $users, 'name' => 'remove_user_id', 'id' => 'remove_user_id'));
$out .= '<input type="submit" name="remove_user" class="button" value="' . __('Remove', 'academy') . '" /></div>';
}
break;
//module settings
//module settings
case 'module':
$out .= '<div class="' . substr(strtolower(implode('-', preg_split('/(?=[A-Z])/', str_replace(THEMEX_PREFIX, '', $option['id'])))), 1) . '">';
if (isset($option['slug'])) {
$out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings'), $option['slug']);
} else {
$out .= call_user_func(array(str_replace(THEMEX_PREFIX, '', $option['id']), 'renderSettings'));
}
$out .= '</div>';
break;
}
//option after
if (isset($option['after'])) {
$out .= $option['after'];
}
//wrap option
if (!isset($option['wrap']) || $option['wrap']) {
$out .= '</div>';
}
return $out;
}
示例4: removeRelation
/**
* Removes user relation
*
* @access public
* @param int $ID
* @param array $data
* @return void
*/
public static function removeRelation($ID, $data)
{
$relation = themex_value('relation_id', $data);
$type = themex_value('relation_type', $data);
if (in_array($type, array('shop', 'product'))) {
ThemexCore::removeUserRelation($ID, $relation, $type);
if ($type == 'shop') {
$relations = count(ThemexCore::getUserRelations(0, $relation, 'shop'));
ThemexCore::updatePostMeta($relation, 'admirers', $relations);
}
}
die;
}