コード例 #1
0
ファイル: type-reviews.php プロジェクト: riaface/GrowBeyond
    function getReviewsMarkup($field, $value, $editable = false, $clear = false, $snippets = false)
    {
        $maxLevel = max(5, (int) get_custom_option('reviews_max_level'));
        $reviews_style = get_custom_option('reviews_style');
        $output = '';
        $criterias = $field['options'];
        $marks = explode(',', $value);
        if (is_array($criterias) && count($criterias) > 0) {
            $i = 0;
            foreach ($criterias as $num => $sb) {
                if (empty($sb)) {
                    continue;
                }
                if ($clear || !isset($marks[$i]) || $marks[$i] == '' || is_inherit_option($marks[$i])) {
                    $marks[$i] = 0;
                }
                $output .= '<div class="revWrap revStyle' . $maxLevel . '">' . getReviewsSummaryStars($marks[$i], $editable, true, $reviews_style) . '<div class="revName">' . $sb . '</div>' . '</div>';
                $i++;
            }
        }
        $output .= isset($field['accept']) && $field['accept'] ? '<div class="revAccept">' . do_shortcode('[trx_button id="rev_author" skin="global" style="bg" size="medium" title="' . __('Accept your votes', 'themerex') . '"]' . __('Accept your votes', 'themerex') . '[/trx_button]') . '</div>' : '';
        $avg = getReviewsRatingAverage($value);
        $output .= '
            <div class="revTotalWrap">
            	<div class="revTotal"><div class="revRating" data-mark="' . $avg . '">' . $avg . (themerex_strlen($avg) == 1 ? '.0' : '') . '</div></div>
                <div class="revDesc">' . (isset($field['descr']) ? $field['descr'] : '') . '</div>
            </div>
		';
        return $output;
    }
コード例 #2
0
ファイル: functions.php プロジェクト: eq0rip/Hamroreview.com
    function getReviewsMarkup($field, $value, $clear = false, $snippets = false)
    {
        $maxLevel = max(5, (int) get_custom_option('reviews_max_level'));
        $output = '
			<input type="hidden" name="reviews_id" class="reviews_id" value="' . $field['id'] . '" />
			<input type="hidden" name="criterias_list" class="criterias_list" value="' . $field['options'] . '" />
			<input type="hidden" name="marks_list" class="marks_list" value="' . $value . '" />
			<div class="reviews_data">
		';
        $criterias = explode(',', $field['options']);
        $marks = explode(',', $value);
        for ($i = 0; $i < count($criterias); $i++) {
            if (empty($criterias[$i])) {
                continue;
            }
            $sb = explode('|', $criterias[$i]);
            if (empty($sb[0])) {
                continue;
            }
            if (count($sb) == 1) {
                $sb[1] = $i + 1;
            }
            if (!isset($marks[$i]) || $marks[$i] == '') {
                $marks[$i] = 0;
            }
            $output .= '
				<div class="criteria_row theme_field">
					<input type="hidden" name="' . $field['id'] . '[]" value="' . ($clear ? 0 : $marks[$i]) . '" />
					<span class="criteria_label theme_strong">' . $sb[0] . '</span>';
            if ($maxLevel < 100) {
                $output .= '<span class="criteria_stars">';
                // title="'.sprintf(__('%s from %s', 'themerex'), number_format($marks[$i],1), $maxLevel).'">';
                for ($s = 1; $s <= $maxLevel; $s++) {
                    $output .= '<span class="theme_stars" data-mark="' . $s . '"></span>';
                }
                $output .= '</span>';
            } else {
                $output .= '<span class="criteria_stars"><span class="criteria_bar theme_rating_bar"><span class="criteria_level theme_rating_level"></span></span><span class="criteria_dragger theme_rating_drag"></span></span>';
            }
            $output .= '
					<span class="criteria_mark theme_accent_bg">' . ($clear ? '' : $marks[$i] + ($maxLevel == 100 ? '%' : '')) . '</span>
				</div>
				';
        }
        $avg = getReviewsRatingAverage($value);
        $output .= '
			</div>
			<div class="reviews_summary blog_reviews">
				<div class="criteria_summary_text criteria_row theme_field">' . (isset($field['descr']) ? $field['descr'] : '') . '</div>
				<div class="criteria_summary criteria_row theme_field">
					<span class="criteria_label theme_strong">' . __('Summary', 'themerex') . '</span>
					' . getReviewsSummaryStars($avg, $snippets) . '
					<span class="criteria_mark theme_accent_bg">' . $avg . (themerex_strlen($avg) == 1 ? '.0' : '') . '</span>
					<span class="criteria_word theme_accent_bg">' . getReviewsRatingWordValue($avg) . '</span>
				</div>
			</div>
		';
        return $output;
    }
コード例 #3
0
ファイル: type-post.php プロジェクト: derwegas/strubbelkinder
function save_meta_box_post($post_id)
{
    global $THEMEREX_meta_box_post, $THEMEREX_options;
    // verify nonce
    if (!isset($_POST['meta_box_post_nonce']) || !wp_verify_nonce($_POST['meta_box_post_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return $post_id;
        }
    }
    $custom_options = array();
    $post_options = array_merge($THEMEREX_options, $THEMEREX_meta_box_post['fields']);
    if (themerex_options_merge_new_values($post_options, $custom_options, $_POST, 'save', 'post')) {
        update_post_meta($post_id, 'post_custom_options', $custom_options);
        // Post type specific data handling
        foreach ($post_options as $field) {
            if (isset($field['id']) && $field['id'] == 'reviews_marks') {
                if (($avg = getReviewsRatingAverage($custom_options[$field['id']])) > 0) {
                    update_post_meta($post_id, 'reviews_avg', $avg);
                }
                break;
            }
        }
    }
}
コード例 #4
0
ファイル: type-post.php プロジェクト: riaface/GrowBeyond
function save_meta_box_post($post_id)
{
    global $THEMEREX_meta_box_post, $THEMEREX_options;
    // verify nonce
    if (!isset($_POST['meta_box_post_nonce']) || !wp_verify_nonce($_POST['meta_box_post_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return $post_id;
        }
    }
    $custom_options = array();
    $post_options = array_merge($THEMEREX_options, $THEMEREX_meta_box_post['fields']);
    $need_save = false;
    foreach ($post_options as $field) {
        if (!isset($field['override']) || !in_array('post', explode(',', $field['override']))) {
            continue;
        }
        if (!isset($field['std'])) {
            continue;
        }
        $id = $field['id'];
        if (!isset($_POST[$id . '_inherit'])) {
            continue;
        }
        $need_save = true;
        if (is_inherit_option($_POST[$id . '_inherit'])) {
            $new = '';
        } else {
            if (isset($_POST[$id])) {
                if ($field['type'] == 'socials') {
                    if (!empty($field['cloneable'])) {
                        foreach ($_POST[$id] as $k => $v) {
                            $_POST[$id][$k] = array('url' => stripslashes($v), 'icon' => stripslashes($_POST[$id . '_icon'][$k]));
                        }
                    } else {
                        $_POST[$id] = array('url' => stripslashes($_POST[$id]), 'icon' => stripslashes($_POST[$id . '_icon']));
                    }
                } else {
                    if (is_array($_POST[$id])) {
                        foreach ($_POST[$id] as $k => $v) {
                            $_POST[$id][$k] = stripslashes($v);
                        }
                    } else {
                        $_POST[$id] = stripslashes($_POST[$id]);
                    }
                }
                // Add cloneable index
                if (!empty($field['cloneable'])) {
                    $rez = array();
                    foreach ($_POST[$id] as $k => $v) {
                        $rez[$_POST[$id . '_numbers'][$k]] = $v;
                    }
                    $_POST[$id] = $rez;
                }
                $new = $_POST[$id];
                if ($id == 'reviews_marks') {
                    $new = join(',', $new);
                    if (($avg = getReviewsRatingAverage($new)) > 0) {
                        $new = marksToSave($new);
                        update_post_meta($post_id, 'reviews_avg', marksToSave($avg));
                    }
                }
            } else {
                $new = $field['type'] == 'checkbox' ? 'false' : '';
            }
        }
        $custom_options[$id] = $new ? $new : 'inherit';
    }
    if ($need_save) {
        update_post_meta($post_id, 'post_custom_options', $custom_options);
    }
}
コード例 #5
0
function themerex_options_merge_new_values(&$post_options, &$custom_options, &$post_data, $mode, $override)
{
    $need_save = false;
    foreach ($post_options as $field) {
        if ($override != 'general' && (!isset($field['override']) || !in_array($override, explode(',', $field['override'])))) {
            continue;
        }
        if (!isset($field['std'])) {
            continue;
        }
        $id = $field['id'];
        if ($override != 'general' && !isset($post_data[$id . '_inherit'])) {
            continue;
        }
        if ($id == 'reviews_marks' && $mode == 'export') {
            continue;
        }
        $need_save = true;
        if ($mode == 'save' || $mode == 'export') {
            if ($override != 'general' && is_inherit_option($post_data[$id . '_inherit'])) {
                $new = '';
            } else {
                if (isset($post_data[$id])) {
                    // Prepare specific (combined) fields
                    if (!empty($field['subset'])) {
                        $sbs = $post_data[$field['subset']];
                        $field['val'][$sbs] = $post_data[$id];
                        $post_data[$id] = $field['val'];
                    }
                    if ($field['type'] == 'socials') {
                        if (!empty($field['cloneable'])) {
                            foreach ($post_data[$id] as $k => $v) {
                                $post_data[$id][$k] = array('url' => stripslashes($v), 'icon' => stripslashes($post_data[$id . '_icon'][$k]));
                            }
                        } else {
                            $post_data[$id] = array('url' => stripslashes($post_data[$id]), 'icon' => stripslashes($post_data[$id . '_icon']));
                        }
                    } else {
                        if (is_array($post_data[$id])) {
                            foreach ($post_data[$id] as $k => $v) {
                                $post_data[$id][$k] = stripslashes($v);
                            }
                        } else {
                            $post_data[$id] = stripslashes($post_data[$id]);
                        }
                    }
                    // Add cloneable index
                    if (!empty($field['cloneable'])) {
                        $rez = array();
                        foreach ($post_data[$id] as $k => $v) {
                            $rez[$post_data[$id . '_numbers'][$k]] = $v;
                        }
                        $post_data[$id] = $rez;
                    }
                    $new = $post_data[$id];
                    // Post type specific data handling
                    if ($id == 'reviews_marks') {
                        $new = join(',', $new);
                        if (($avg = getReviewsRatingAverage($new)) > 0) {
                            $new = marksToSave($new);
                        }
                    }
                } else {
                    $new = $field['type'] == 'checkbox' ? 'false' : '';
                }
            }
        } else {
            $new = $field['std'];
        }
        $custom_options[$id] = $new || $override == 'general' ? $new : 'inherit';
    }
    return $need_save;
}
コード例 #6
0
    function getReviewsMarkup($field, $value, $editable = false, $clear = false, $snippets = false)
    {
        $maxLevel = max(5, (int) get_custom_option('reviews_max_level'));
        $output = '';
        $criterias = $field['options'];
        $marks = explode(',', $value);
        if (is_array($criterias) && count($criterias) > 0) {
            $i = 0;
            foreach ($criterias as $num => $sb) {
                if (empty($sb)) {
                    continue;
                }
                if ($clear || !isset($marks[$i]) || $marks[$i] == '' || is_inherit_option($marks[$i])) {
                    $marks[$i] = 0;
                }
                $output .= '<div class="ratBody">' . getReviewsSummaryStars($marks[$i], $editable) . '<span class="name">' . $sb . '</span>' . '</div>';
                $i++;
            }
        }
        $output .= isset($field['accept']) && $field['accept'] ? '<div class="accept"><div class="squareButton global"><a href="#" title="' . __('Accept your votes', 'themerex') . '">' . __('Accept', 'themerex') . '</a></div></div>' : '';
        $avg = getReviewsRatingAverage($value);
        $output .= '
            <div class="infoTotal">
                <div class="infoRat">' . (isset($field['descr']) ? $field['descr'] : '') . '</div>
                <div class="totalWrap">
                    <div class="totalStar">
						' . getReviewsSummaryStars($avg, false, $snippets) . '
                    </div>
                    <div class="totalRating" data-mark="' . $avg . '">' . $avg . (themerex_strlen($avg) == 1 ? '.0' : '') . '</div>
                </div>
            </div>
		';
        return $output;
    }
コード例 #7
0
ファイル: type-post.php プロジェクト: eq0rip/Hamroreview.com
function save_meta_box_post($post_id)
{
    global $THEMEREX_meta_box_post, $THEMEREX_theme_options;
    // verify nonce
    if (!isset($_POST['meta_box_post_nonce']) || !wp_verify_nonce($_POST['meta_box_post_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return $post_id;
        }
    }
    $custom_options = array();
    $need_save = false;
    foreach ($THEMEREX_meta_box_post['fields'] as $field) {
        if (!isset($field['id'])) {
            continue;
        }
        if (!isset($_POST[$field['id']])) {
            continue;
        }
        $need_save = true;
        $new = isset($_POST[$field['id']]) ? is_array($_POST[$field['id']]) ? join(',', $_POST[$field['id']]) : $_POST[$field['id']] : '';
        $custom_options[$field['id']] = $new ? $new : 'default';
        if ($field['id'] == 'reviews_marks' && ($avg = getReviewsRatingAverage($new)) > 0) {
            $custom_options[$field['id']] = marksToSave($custom_options[$field['id']]);
            update_post_meta($post_id, 'reviews_avg', marksToSave($avg));
        }
    }
    foreach ($THEMEREX_theme_options as $option) {
        if (!isset($option['override']) || !in_array('post', explode(',', $option['override']))) {
            continue;
        }
        if (!isset($option['id'])) {
            continue;
        }
        $id = get_option_name($option['id']);
        if (!isset($_POST[$id])) {
            continue;
        }
        $need_save = true;
        $new = isset($_POST[$id]) ? $_POST[$id] : '';
        $custom_options[$id] = $new ? $new : 'default';
    }
    if ($need_save) {
        update_post_meta($post_id, 'post_custom_options', $custom_options);
    }
}